Skip to content

Fix RCS1033: Remove redundant boolean literal part 1 #13454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ internal override IObservable<CimInstance> GetCimOperation()
}

#if DEBUG
Dbg.Assert(_getInstanceOperationGotStarted == false, "CreateInstance should be started *before* GetInstance");
Dbg.Assert(_createInstanceOperationGotStarted == false, "Should not start CreateInstance operation twice");
Dbg.Assert(!_getInstanceOperationGotStarted, "CreateInstance should be started *before* GetInstance");
Dbg.Assert(!_createInstanceOperationGotStarted, "Should not start CreateInstance operation twice");
_createInstanceOperationGotStarted = true;
#endif
return GetCreateInstanceOperation();
Expand All @@ -77,7 +77,7 @@ internal override IObservable<CimInstance> GetCimOperation()
{
#if DEBUG
Dbg.Assert(_createInstanceOperationGotStarted, "GetInstance should be started *after* CreateInstance");
Dbg.Assert(_getInstanceOperationGotStarted == false, "Should not start GetInstance operation twice");
Dbg.Assert(!_getInstanceOperationGotStarted, "Should not start GetInstance operation twice");
Dbg.Assert(_resultFromGetInstance == null, "GetInstance operation shouldn't happen twice");
_getInstanceOperationGotStarted = true;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ public int Timeout
/// </summary>
public void Dispose()
{
if (_disposed == false)
if (!_disposed)
{
if (_waitHandle != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,7 @@ internal static bool QueryServiceConfig(NakedWin32Handle hService, out NativeMet
cbBufSize: 0,
pcbBytesNeeded: out bufferSizeNeeded);

if (status != true && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
if (!status && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
return status;
}
Expand Down Expand Up @@ -2868,7 +2868,7 @@ internal static bool QueryServiceConfig2<T>(NakedWin32Handle hService, DWORD inf
cbBufSize: 0,
pcbBytesNeeded: out bufferSizeNeeded);

if (status != true && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
if (!status && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
return status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public override void WriteCsvLine(string line)
/// </summary>
public void Dispose()
{
if (_disposed == false)
if (!_disposed)
{
CleanUp();
}
Expand Down Expand Up @@ -1171,7 +1171,7 @@ internal static void AppendStringWithEscapeAlways(StringBuilder dest, string sou
/// </summary>
public void Dispose()
{
if (_disposed == false)
if (!_disposed)
{
GC.SuppressFinalize(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ private bool IsSafeCommandMetadata(CommandMetadata commandMetadata)
}

Dbg.Assert(commandMetadata.CommandType == null, "CommandType shouldn't get rehydrated");
Dbg.Assert(commandMetadata.ImplementsDynamicParameters == false, "Proxies shouldn't do dynamic parameters");
Dbg.Assert(!commandMetadata.ImplementsDynamicParameters, "Proxies shouldn't do dynamic parameters");

if (commandMetadata.Parameters != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class StartSleepCommand : PSCmdlet, IDisposable
/// </summary>
public void Dispose()
{
if (_disposed == false)
if (!_disposed)
{
if (_waitHandle != null)
{
Expand Down Expand Up @@ -76,7 +76,7 @@ private void Sleep(int milliSecondsToSleep)
{
lock (_syncObject)
{
if (_stopping == false)
if (!_stopping)
{
_waitHandle = new ManualResetEvent(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ private void AddMultipartContent(object fieldName, object fieldValue, MultipartF
// Treat Strings and other single values as a StringContent.
// If enumeration is false, also treat IEnumerables as StringContents.
// String implements IEnumerable so the explicit check is required.
if (enumerate == false || fieldValue is string || fieldValue is not IEnumerable)
if (!enumerate || fieldValue is string || fieldValue is not IEnumerable)
{
formData.Add(GetMultipartStringContent(fieldName: fieldName, fieldValue: fieldValue));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ private static object AddPsProperties(object psObj, object obj, int depth, bool

AppendPsProperties(pso, dict, depth, isCustomObj, in context);

if (wasDictionary == false && dict.Count == 1)
if (!wasDictionary && dict.Count == 1)
{
return obj;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private void CreateFileStream()
void
Dispose()
{
if (_disposed == false)
if (!_disposed)
{
CleanUp();
}
Expand Down Expand Up @@ -620,7 +620,7 @@ private void CleanUp()
void
Dispose()
{
if (_disposed == false)
if (!_disposed)
{
CleanUp();
}
Expand Down Expand Up @@ -719,7 +719,7 @@ private void CleanUp()
/// </summary>
public void Dispose()
{
if (_disposed == false)
if (!_disposed)
{
CleanUp();
}
Expand Down
52 changes: 26 additions & 26 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ internal static void AddBreakHandler(BreakHandler handlerDelegate)
{
bool result = NativeMethods.SetConsoleCtrlHandler(handlerDelegate, true);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand All @@ -533,7 +533,7 @@ internal static void RemoveBreakHandler()
{
bool result = NativeMethods.SetConsoleCtrlHandler(null, false);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -661,7 +661,7 @@ internal static ConsoleModes GetMode(ConsoleHandle consoleHandle)
UInt32 m = 0;
bool result = NativeMethods.GetConsoleMode(consoleHandle.DangerousGetHandle(), out m);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -692,7 +692,7 @@ internal static void SetMode(ConsoleHandle consoleHandle, ConsoleModes mode)

bool result = NativeMethods.SetConsoleMode(consoleHandle.DangerousGetHandle(), (DWORD)mode);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -770,7 +770,7 @@ internal static string ReadConsole(
out charsReaded,
ref control);
keyState = control.dwControlKeyState;
if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -818,7 +818,7 @@ internal static int ReadConsoleInput(ConsoleHandle consoleHandle, ref INPUT_RECO
buffer,
(DWORD)buffer.Length,
out recordsRead);
if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -862,7 +862,7 @@ ref INPUT_RECORD[] buffer
(DWORD)buffer.Length,
out recordsRead);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -894,7 +894,7 @@ internal static int GetNumberOfConsoleInputEvents(ConsoleHandle consoleHandle)
DWORD numEvents;
bool result = NativeMethods.GetNumberOfConsoleInputEvents(consoleHandle.DangerousGetHandle(), out numEvents);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -924,7 +924,7 @@ internal static void FlushConsoleInputBuffer(ConsoleHandle consoleHandle)
NakedWin32Handle h = consoleHandle.DangerousGetHandle();
result = NativeMethods.FlushConsoleInputBuffer(h);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -959,7 +959,7 @@ internal static CONSOLE_SCREEN_BUFFER_INFO GetConsoleScreenBufferInfo(ConsoleHan
CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
bool result = NativeMethods.GetConsoleScreenBufferInfo(consoleHandle.DangerousGetHandle(), out bufferInfo);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -991,7 +991,7 @@ internal static void SetConsoleScreenBufferSize(ConsoleHandle consoleHandle, Siz

bool result = NativeMethods.SetConsoleScreenBufferSize(consoleHandle.DangerousGetHandle(), s);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -1503,7 +1503,7 @@ private static void WriteConsoleOutputCJK(ConsoleHandle consoleHandle, Coordinat
ref writeRegion);
}

if (result == false)
if (!result)
{
// When WriteConsoleOutput fails, half bufferLimit
if (bufferLimit < 2)
Expand Down Expand Up @@ -1631,7 +1631,7 @@ private static void WriteConsoleOutputPlain(ConsoleHandle consoleHandle, Coordin
bufferCoord,
ref writeRegion);

if (result == false)
if (!result)
{
// When WriteConsoleOutput fails, half bufferLimit
if (bufferLimit < 2)
Expand Down Expand Up @@ -1959,7 +1959,7 @@ internal static void ReadConsoleOutputCJK
new Coordinates(readRegion.Left, readRegion.Top),
atContents,
ref contents);
if (result == false)
if (!result)
{
// When WriteConsoleOutput fails, half bufferLimit
if (bufferLimit < 2)
Expand Down Expand Up @@ -2131,7 +2131,7 @@ private static void ReadConsoleOutputPlain
bufferCoord,
ref readRegion);

if (result == false)
if (!result)
{
// When WriteConsoleOutput fails, half bufferLimit
if (bufferLimit < 2)
Expand Down Expand Up @@ -2280,7 +2280,7 @@ Coordinates origin
(DWORD)numberToWrite,
c,
out unused);
if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2335,7 +2335,7 @@ Coordinates origin
c,
out unused);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2385,7 +2385,7 @@ internal static void ScrollConsoleScreenBuffer
destOrigin,
ref fill);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2423,7 +2423,7 @@ internal static void SetConsoleWindowInfo(ConsoleHandle consoleHandle, bool abso

bool result = NativeMethods.SetConsoleWindowInfo(consoleHandle.DangerousGetHandle(), absolute, ref windowInfo);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2509,7 +2509,7 @@ internal static void SetConsoleWindowTitle(string consoleTitle)
{
bool result = NativeMethods.SetConsoleTitle(consoleTitle);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2602,7 +2602,7 @@ private static void WriteConsole(ConsoleHandle consoleHandle, ReadOnlySpan<char>
out charsWritten,
IntPtr.Zero);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2634,7 +2634,7 @@ internal static void SetConsoleTextAttribute(ConsoleHandle consoleHandle, WORD a

bool result = NativeMethods.SetConsoleTextAttribute(consoleHandle.DangerousGetHandle(), attribute);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2844,7 +2844,7 @@ internal static void SetConsoleCursorPosition(ConsoleHandle consoleHandle, Coord

bool result = NativeMethods.SetConsoleCursorPosition(consoleHandle.DangerousGetHandle(), c);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2875,7 +2875,7 @@ internal static CONSOLE_CURSOR_INFO GetConsoleCursorInfo(ConsoleHandle consoleHa

bool result = NativeMethods.GetConsoleCursorInfo(consoleHandle.DangerousGetHandle(), out cursorInfo);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand All @@ -2896,7 +2896,7 @@ internal static CONSOLE_FONT_INFO_EX GetConsoleFontInfo(ConsoleHandle consoleHan
fontInfo.cbSize = Marshal.SizeOf(fontInfo);
bool result = NativeMethods.GetCurrentConsoleFontEx(consoleHandle.DangerousGetHandle(), false, ref fontInfo);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -2927,7 +2927,7 @@ internal static void SetConsoleCursorInfo(ConsoleHandle consoleHandle, CONSOLE_C

bool result = NativeMethods.SetConsoleCursorInfo(consoleHandle.DangerousGetHandle(), ref cursorInfo);

if (result == false)
if (!result)
{
int err = Marshal.GetLastWin32Error();

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ internal bool ShouldEndSession
{
// If ShouldEndSession is already true, you can't set it back

Dbg.Assert(_shouldEndSession != true || value,
Dbg.Assert(!_shouldEndSession || value,
"ShouldEndSession can only be set from false to true");

_shouldEndSession = value;
Expand Down Expand Up @@ -1321,7 +1321,7 @@ internal WrappedDeserializer.DataFormat ErrorFormat

// If this shell is invoked in non-interactive, error is redirected, and OutputFormat was not
// specified write data in error stream in xml format assuming PowerShell->PowerShell usage.
if (!OutputFormatSpecified && IsInteractive == false && Console.IsErrorRedirected && _wasInitialCommandEncoded)
if (!OutputFormatSpecified && !IsInteractive && Console.IsErrorRedirected && _wasInitialCommandEncoded)
{
format = Serialization.DataFormat.XML;
}
Expand Down
Loading