From b855c9c8db59582409a91fe91a4d470507e5c35d Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Sat, 1 Aug 2020 22:03:41 +0100 Subject: [PATCH 1/2] Remove redundant boolean literal Autofix RCS1033: Remove redundant boolean literal --- .../cmdletization/cim/CreateInstanceJob.cs | 6 +-- .../commands/management/Process.cs | 2 +- .../commands/management/Service.cs | 4 +- .../commands/utility/CsvCommands.cs | 4 +- .../utility/ImplicitRemotingCommands.cs | 2 +- .../commands/utility/StartSleepCommand.cs | 4 +- .../Common/WebRequestPSCmdlet.Common.cs | 2 +- .../commands/utility/WebCmdlet/JsonObject.cs | 2 +- .../commands/utility/XmlCommands.cs | 6 +-- .../host/msh/ConsoleControl.cs | 52 +++++++++---------- .../host/msh/ConsoleHost.cs | 4 +- .../ConfigProvider.cs | 6 +-- .../common/FormatViewGenerator.cs | 2 +- .../engine/CommandDiscovery.cs | 2 +- .../engine/CommandMetadata.cs | 2 +- .../engine/CommandProcessor.cs | 2 +- .../engine/CoreAdapter.cs | 4 +- .../engine/ErrorPackage.cs | 2 +- .../engine/GetCommandCommand.cs | 2 +- .../engine/LanguagePrimitives.cs | 2 +- .../engine/Modules/ModuleCmdletBase.cs | 16 +++--- .../engine/NativeCommandProcessor.cs | 12 ++--- .../engine/SessionStateContainer.cs | 2 +- .../engine/TypeTable.cs | 2 +- .../engine/hostifaces/ConnectionBase.cs | 4 +- .../engine/hostifaces/History.cs | 16 +++--- .../hostifaces/InternalHostUserInterface.cs | 2 +- .../engine/hostifaces/LocalConnection.cs | 2 +- .../engine/hostifaces/LocalPipeline.cs | 2 +- .../engine/hostifaces/PSDataCollection.cs | 2 +- .../engine/hostifaces/PowerShell.cs | 2 +- .../engine/hostifaces/pipelinebase.cs | 8 +-- .../engine/parser/Parser.cs | 2 +- .../engine/parser/SemanticChecks.cs | 2 +- .../engine/remoting/client/Job.cs | 8 +-- .../engine/remoting/client/JobManager.cs | 2 +- .../remoting/client/PowerShellStreams.cs | 4 +- .../client/RemoteRunspacePoolInternal.cs | 2 +- ...clientremotesessionprotocolstatemachine.cs | 2 +- .../engine/remoting/client/remotepipeline.cs | 4 +- .../engine/remoting/client/remoterunspace.cs | 2 +- .../remoting/commands/CustomShellCommands.cs | 4 +- .../remoting/commands/InvokeCommandCommand.cs | 2 +- .../engine/remoting/common/AsyncObject.cs | 2 +- .../server/ServerRunspacePoolDriver.cs | 2 +- .../engine/runtime/Binding/Binders.cs | 2 +- .../engine/runtime/Operations/MiscOps.cs | 4 +- .../engine/serialization.cs | 6 +-- .../namespaces/RegistryProvider.cs | 2 +- .../utils/ObjectStream.cs | 8 +-- .../utils/PsUtils.cs | 2 +- 51 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs index 7f76ff98574..d8a1bdd44ea 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs @@ -67,8 +67,8 @@ internal override IObservable 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(); @@ -77,7 +77,7 @@ internal override IObservable 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 diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index c20ef98a80d..2791453f01e 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -924,7 +924,7 @@ public int Timeout /// public void Dispose() { - if (_disposed == false) + if (!_disposed) { if (_waitHandle != null) { diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 9e1d6c69c53..8ed9ed85003 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -2831,7 +2831,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; } @@ -2869,7 +2869,7 @@ internal static bool QueryServiceConfig2(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; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs index 0372298d7b5..bc6787d1d9f 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs @@ -491,7 +491,7 @@ public override void WriteCsvLine(string line) /// public void Dispose() { - if (_disposed == false) + if (!_disposed) { CleanUp(); } @@ -1144,7 +1144,7 @@ internal static void AppendStringWithEscapeAlways(StringBuilder dest, string sou /// public void Dispose() { - if (_disposed == false) + if (!_disposed) { GC.SuppressFinalize(this); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs index feeb0cd091b..035a7266a4a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs @@ -1191,7 +1191,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) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/StartSleepCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/StartSleepCommand.cs index 4fe5c641ff9..16328eb9025 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/StartSleepCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/StartSleepCommand.cs @@ -23,7 +23,7 @@ public sealed class StartSleepCommand : PSCmdlet, IDisposable /// public void Dispose() { - if (_disposed == false) + if (!_disposed) { if (_waitHandle != null) { @@ -76,7 +76,7 @@ private void Sleep(int milliSecondsToSleep) { lock (_syncObject) { - if (_stopping == false) + if (!_stopping) { _waitHandle = new ManualResetEvent(false); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 94dde3c00fb..947b8aa9fbe 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -1892,7 +1892,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 IEnumerable)) + if (!enumerate || fieldValue is string || !(fieldValue is IEnumerable)) { formData.Add(GetMultipartStringContent(fieldName: fieldName, fieldValue: fieldValue)); return; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs index 2b15f150984..b1fa272b0e1 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs @@ -645,7 +645,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; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs index 8736965fd61..50c4fa4b369 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs @@ -261,7 +261,7 @@ private void CreateFileStream() void Dispose() { - if (_disposed == false) + if (!_disposed) { CleanUp(); } @@ -606,7 +606,7 @@ private void CleanUp() void Dispose() { - if (_disposed == false) + if (!_disposed) { CleanUp(); } @@ -705,7 +705,7 @@ private void CleanUp() /// public void Dispose() { - if (_disposed == false) + if (!_disposed) { CleanUp(); } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs index 6159e349497..da8ef00fbd0 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs @@ -516,7 +516,7 @@ internal static void AddBreakHandler(BreakHandler handlerDelegate) { bool result = NativeMethods.SetConsoleCtrlHandler(handlerDelegate, true); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -537,7 +537,7 @@ internal static void RemoveBreakHandler() { bool result = NativeMethods.SetConsoleCtrlHandler(null, false); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -666,7 +666,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(); @@ -698,7 +698,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(); @@ -777,7 +777,7 @@ internal static string ReadConsole( out charsReaded, ref control); keyState = control.dwControlKeyState; - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -826,7 +826,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(); @@ -871,7 +871,7 @@ ref INPUT_RECORD[] buffer (DWORD)buffer.Length, out recordsRead); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -904,7 +904,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(); @@ -934,7 +934,7 @@ internal static void FlushConsoleInputBuffer(ConsoleHandle consoleHandle) NakedWin32Handle h = consoleHandle.DangerousGetHandle(); result = NativeMethods.FlushConsoleInputBuffer(h); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -969,7 +969,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(); @@ -1002,7 +1002,7 @@ internal static void SetConsoleScreenBufferSize(ConsoleHandle consoleHandle, Siz bool result = NativeMethods.SetConsoleScreenBufferSize(consoleHandle.DangerousGetHandle(), s); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -1515,7 +1515,7 @@ private static void WriteConsoleOutputCJK(ConsoleHandle consoleHandle, Coordinat ref writeRegion); } - if (result == false) + if (!result) { // When WriteConsoleOutput fails, half bufferLimit if (bufferLimit < 2) @@ -1643,7 +1643,7 @@ private static void WriteConsoleOutputPlain(ConsoleHandle consoleHandle, Coordin bufferCoord, ref writeRegion); - if (result == false) + if (!result) { // When WriteConsoleOutput fails, half bufferLimit if (bufferLimit < 2) @@ -1972,7 +1972,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) @@ -2144,7 +2144,7 @@ private static void ReadConsoleOutputPlain bufferCoord, ref readRegion); - if (result == false) + if (!result) { // When WriteConsoleOutput fails, half bufferLimit if (bufferLimit < 2) @@ -2293,7 +2293,7 @@ Coordinates origin (DWORD)numberToWrite, c, out unused); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -2348,7 +2348,7 @@ Coordinates origin c, out unused); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -2399,7 +2399,7 @@ internal static void ScrollConsoleScreenBuffer destOrigin, ref fill); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -2438,7 +2438,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(); @@ -2527,7 +2527,7 @@ internal static void SetConsoleWindowTitle(string consoleTitle) { bool result = NativeMethods.SetConsoleTitle(consoleTitle); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -2618,7 +2618,7 @@ private static void WriteConsole(ConsoleHandle consoleHandle, ReadOnlySpan out charsWritten, IntPtr.Zero); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -2651,7 +2651,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(); @@ -2862,7 +2862,7 @@ internal static void SetConsoleCursorPosition(ConsoleHandle consoleHandle, Coord bool result = NativeMethods.SetConsoleCursorPosition(consoleHandle.DangerousGetHandle(), c); - if (result == false) + if (!result) { int err = Marshal.GetLastWin32Error(); @@ -2894,7 +2894,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(); @@ -2915,7 +2915,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(); @@ -2947,7 +2947,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(); diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index 206a7e44e7f..2e579da52f2 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -1279,7 +1279,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; @@ -1313,7 +1313,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; } diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 326f53d4d94..fa7a06a6e19 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -193,7 +193,7 @@ protected override PSDriveInfo NewDrive(PSDriveInfo drive) return null; } - if (string.IsNullOrEmpty(drive.Root) == false) + if (!string.IsNullOrEmpty(drive.Root)) { AssertError(helper.GetResourceMsgFromResourcetext("NewDriveRootDoesNotExist"), false); return null; @@ -1237,7 +1237,7 @@ protected override void SetItem(string path, object value) pluginConfiguration.PutConfigurationOnServer(resourceUri); // Show Win RM service restart warning only when the changed setting is not picked up dynamically - if (settingPickedUpDynamically == false) + if (!settingPickedUpDynamically) { if (IsPathLocalMachine(host)) { @@ -4089,7 +4089,7 @@ private bool ItemExistListenerOrClientCertificate(object sessionobj, string Reso CurrentNode = RemainingPath.Substring(0, pos); } - if (objcache.Contains(CurrentNode) == false) + if (!objcache.Contains(CurrentNode)) { return false; } diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs index cf6a4d2eb88..f29033e3c8d 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs @@ -307,7 +307,7 @@ internal bool IsObjectApplicable(Collection typeNames) // we were unable to find a best match so far..try // to get rid of Deserialization prefix and see if a // match can be found. - if (false == result) + if (!result) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (typesWithoutPrefix != null) diff --git a/src/System.Management.Automation/engine/CommandDiscovery.cs b/src/System.Management.Automation/engine/CommandDiscovery.cs index f5f2a0501f0..62cfaa20163 100644 --- a/src/System.Management.Automation/engine/CommandDiscovery.cs +++ b/src/System.Management.Automation/engine/CommandDiscovery.cs @@ -784,7 +784,7 @@ internal static CommandInfo LookupCommandInfo( // Check the module auto-loading preference PSModuleAutoLoadingPreference moduleAutoLoadingPreference = GetCommandDiscoveryPreference(context, SpecialVariables.PSModuleAutoLoadingPreferenceVarPath, "PSModuleAutoLoadingPreference"); - if (eventArgs == null || eventArgs.StopSearch != true) + if (eventArgs == null || !eventArgs.StopSearch) { do { diff --git a/src/System.Management.Automation/engine/CommandMetadata.cs b/src/System.Management.Automation/engine/CommandMetadata.cs index edcd9a9cd66..029b5247f48 100644 --- a/src/System.Management.Automation/engine/CommandMetadata.cs +++ b/src/System.Management.Automation/engine/CommandMetadata.cs @@ -926,7 +926,7 @@ internal string GetDecl() separator = ", "; } - if (PositionalBinding == false) + if (!PositionalBinding) { decl.Append(separator); decl.Append("PositionalBinding=$false"); diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs index 4433d75ca99..a44909f2c3b 100644 --- a/src/System.Management.Automation/engine/CommandProcessor.cs +++ b/src/System.Management.Automation/engine/CommandProcessor.cs @@ -528,7 +528,7 @@ internal sealed override bool Read() try { // Process the input pipeline object - if (false == ProcessInputPipelineObject(inputObject)) + if (!ProcessInputPipelineObject(inputObject)) { // The input object was not bound to any parameters of the cmdlet. // Write a non-terminating error and continue with the next input diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs index b6752387d58..956ae5a5395 100644 --- a/src/System.Management.Automation/engine/CoreAdapter.cs +++ b/src/System.Management.Automation/engine/CoreAdapter.cs @@ -1395,8 +1395,8 @@ private static MethodInformation FindBestMethodImpl( // We also skip the optimization if the number of arguments and parameters is different // so we let the loop deal with possible optional parameters. if ((methods.Length == 1) && - (methods[0].hasVarArgs == false) && - (methods[0].isGeneric == false) && + (!methods[0].hasVarArgs) && + (!methods[0].isGeneric) && (methods[0].method == null || !(methods[0].method.DeclaringType.IsGenericTypeDefinition)) && // generic methods need to be double checked in a loop below - generic methods can be rejected if type inference fails (methods[0].parameters.Length == arguments.Length)) diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index fc346e2ee96..696923d7dfa 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -1338,7 +1338,7 @@ private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord) string errorDetails_ScriptStackTrace = GetNoteValue(serializedErrorRecord, "ErrorDetails_ScriptStackTrace") as string; - RemoteException re = new RemoteException((string.IsNullOrWhiteSpace(exceptionMessage) == false) ? exceptionMessage : errorCategory_Message, serializedException, invocationInfo); + RemoteException re = new RemoteException((!string.IsNullOrWhiteSpace(exceptionMessage)) ? exceptionMessage : errorCategory_Message, serializedException, invocationInfo); // Create ErrorRecord PopulateProperties( diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs index b3ab36ae19c..fca1c9dc06e 100644 --- a/src/System.Management.Automation/engine/GetCommandCommand.cs +++ b/src/System.Management.Automation/engine/GetCommandCommand.cs @@ -1421,7 +1421,7 @@ private IEnumerable GetMatchingCommandsFromModules(string commandNa { PSModuleInfo module = null; - if (Context.EngineSessionState.ModuleTable.TryGetValue(Context.EngineSessionState.ModuleTableKeys[i], out module) == false) + if (!Context.EngineSessionState.ModuleTable.TryGetValue(Context.EngineSessionState.ModuleTableKeys[i], out module)) { Dbg.Assert(false, "ModuleTableKeys should be in sync with ModuleTable"); } diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index 5929a5637e9..acf2ce919ea 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -4747,7 +4747,7 @@ private static string GetAvailableProperties(PSObject pso) { foreach (PSPropertyInfo p in pso.Properties) { - if (first == false) + if (!first) { availableProperties.Append(" , "); } diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index f1f8aaff1f7..d518c28267e 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -723,7 +723,7 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module // NestedModules = 'test2' ---> test2 is a directory under current module directory (e.g - Test1) // We also need to look for Test1\Test2\Test2.(psd1/psm1/dll) // With the call above, we are only looking at Test1\Test2.(psd1/psm1/dll) - if (found == false && moduleFileFound == false) + if (!found && !moduleFileFound) { string newRootedPath = Path.Combine(rootedPath, moduleSpecification.Name); string newModuleBase = Path.Combine(moduleBase, moduleSpecification.Name); @@ -764,7 +764,7 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module // Win8: 262157 - Import-Module is giving errors while loading Nested Modules. (This is a V2 bug) // Only look for the file if the file was not found with the previous search - if (found == false && moduleFileFound == false) + if (!found && !moduleFileFound) { string newRootedPath = Path.Combine(rootedPath, moduleSpecification.Name); string newModuleBase = Path.Combine(moduleBase, moduleSpecification.Name); @@ -786,10 +786,10 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module } // The rooted files wasn't found, so don't search anymore... - if (found == false && wasRooted) + if (!found && wasRooted) return null; - if (searchModulePath && found == false && moduleFileFound == false) + if (searchModulePath && !found && !moduleFileFound) { if (VerifyIfNestedModuleIsAvailable(moduleSpecification, null, null, out tempModuleInfoFromVerification)) { @@ -846,7 +846,7 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module // At this point, we haven't found an actual module, so try loading it as a // PSSnapIn and then finally as an assembly in the GAC... - if ((found == false) && (moduleSpecification.Guid == null) && (moduleSpecification.Version == null) && (moduleSpecification.RequiredVersion == null) && (moduleSpecification.MaximumVersion == null)) + if ((!found) && (moduleSpecification.Guid == null) && (moduleSpecification.Version == null) && (moduleSpecification.RequiredVersion == null) && (moduleSpecification.MaximumVersion == null)) { // If we are in module analysis and the parent module declares non-wildcarded ExportedCmdlets, then we don't need to // actually process the binary module. @@ -4956,7 +4956,7 @@ internal void RemoveModule(PSModuleInfo module, string moduleNameInRemoveModuleC args: new object[] { module }); } - if (module.ImplementingAssembly != null && module.ImplementingAssembly.IsDynamic == false) + if (module.ImplementingAssembly != null && !module.ImplementingAssembly.IsDynamic) { var exportedTypes = PSSnapInHelpers.GetAssemblyTypes(module.ImplementingAssembly, module.Name); foreach (var type in exportedTypes) @@ -6666,7 +6666,7 @@ internal PSModuleInfo LoadBinaryModule(PSModuleInfo parentModule, bool trySnapIn } } - if (importSuccessful == false) + if (!importSuccessful) { if (importingModule) { @@ -7087,7 +7087,7 @@ internal static void AddModuleToModuleTables(ExecutionContext context, SessionSt } var privateDataHashTable = module.PrivateData as Hashtable; - if (context.Modules.IsImplicitRemotingModuleLoaded == false && + if (!context.Modules.IsImplicitRemotingModuleLoaded && privateDataHashTable != null && privateDataHashTable.ContainsKey("ImplicitRemoting")) { context.Modules.IsImplicitRemotingModuleLoaded = true; diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 3a12dab6295..9dc14ae53a3 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -503,7 +503,7 @@ private void InitNativeProcess() // we will try launching one last time using ShellExecute... if (notDone) { - if (soloCommand && startInfo.UseShellExecute == false) + if (soloCommand && !startInfo.UseShellExecute) { startInfo.UseShellExecute = true; startInfo.RedirectStandardInput = false; @@ -530,7 +530,7 @@ private void InitNativeProcess() else { _isRunningInBackground = true; - if (startInfo.UseShellExecute == false) + if (!startInfo.UseShellExecute) { _isRunningInBackground = IsWindowsApplication(_nativeProcess.StartInfo.FileName); } @@ -562,7 +562,7 @@ private void InitNativeProcess() throw; } - if (_isRunningInBackground == false) + if (!_isRunningInBackground) { InitOutputQueue(); } @@ -653,7 +653,7 @@ private ProcessOutputObject DequeueProcessOutput(bool blocking) /// private void ConsumeAvailableNativeProcessOutput(bool blocking) { - if (_isRunningInBackground == false) + if (!_isRunningInBackground) { if (_nativeProcess.StartInfo.RedirectStandardOutput || _nativeProcess.StartInfo.RedirectStandardError) { @@ -677,7 +677,7 @@ internal override void Complete() Exception exceptionToRethrow = null; try { - if (_isRunningInBackground == false) + if (!_isRunningInBackground) { // Wait for input writer to finish. _inputWriter.Done(); @@ -1246,7 +1246,7 @@ private void CalculateIORedirection(out bool redirectOutput, out bool redirectEr // In minishell scenario, if output is redirected // then error should also be redirected. - if (redirectError == false && redirectOutput && _isMiniShell) + if (!redirectError && redirectOutput && _isMiniShell) { redirectError = true; } diff --git a/src/System.Management.Automation/engine/SessionStateContainer.cs b/src/System.Management.Automation/engine/SessionStateContainer.cs index f4f2a46d2a5..d99fdcc58f6 100644 --- a/src/System.Management.Automation/engine/SessionStateContainer.cs +++ b/src/System.Management.Automation/engine/SessionStateContainer.cs @@ -628,7 +628,7 @@ internal bool IsItemContainer( foreach (string providerPath in providerPaths) { result = IsItemContainer(providerInstance, providerPath, context); - if (result == false) + if (!result) { break; } diff --git a/src/System.Management.Automation/engine/TypeTable.cs b/src/System.Management.Automation/engine/TypeTable.cs index 74b2f6910f8..beefa7c698b 100644 --- a/src/System.Management.Automation/engine/TypeTable.cs +++ b/src/System.Management.Automation/engine/TypeTable.cs @@ -3192,7 +3192,7 @@ private static bool CheckStandardMembers(ConcurrentBag errors, string ty } while (false); - if (serializationSettingsOk == false) + if (!serializationSettingsOk) { AddError(errors, typeName, TypesXmlStrings.SerializationSettingsIgnored); members.Remove(InheritPropertySerializationSet); diff --git a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs index 4b933b590b9..3327eccf89c 100644 --- a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs +++ b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs @@ -829,7 +829,7 @@ internal void AddToRunningPipelineList(PipelineBase pipeline) lock (_pipelineListLock) { - if (ByPassRunspaceStateCheck == false && RunspaceState != RunspaceState.Opened) + if (!ByPassRunspaceStateCheck && RunspaceState != RunspaceState.Opened) { InvalidRunspaceStateException e = new InvalidRunspaceStateException @@ -1002,7 +1002,7 @@ internal void StopNestedPipelines(Pipeline pipeline) // first check if this pipeline is in the list of running // pipelines. It is possible that pipeline has already // completed. - if (RunningPipelines.Contains(pipeline) == false) + if (!RunningPipelines.Contains(pipeline)) { return; } diff --git a/src/System.Management.Automation/engine/hostifaces/History.cs b/src/System.Management.Automation/engine/hostifaces/History.cs index a88692a91e7..b88b12975ea 100644 --- a/src/System.Management.Automation/engine/hostifaces/History.cs +++ b/src/System.Management.Automation/engine/hostifaces/History.cs @@ -264,7 +264,7 @@ internal HistoryInfo GetEntry(long id) HistoryInfo entry = CoreGetEntry(id); if (entry != null) - if (entry.Cleared == false) + if (!entry.Cleared) return entry.Clone(); return null; @@ -498,7 +498,7 @@ internal HistoryInfo[] GetEntries(WildcardPattern wildcardpattern, long count, S for (long i = 0; i <= count - 1;) { if (id > _countEntriesAdded) break; - if (_buffer[GetIndexFromId(id)].Cleared == false && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) + if (!_buffer[GetIndexFromId(id)].Cleared && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) { cmdlist.Add(_buffer[GetIndexFromId(id)].Clone()); i++; } @@ -522,7 +522,7 @@ internal HistoryInfo[] GetEntries(WildcardPattern wildcardpattern, long count, S } if (id < 1) break; - if (_buffer[GetIndexFromId(id)].Cleared == false && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) + if (!_buffer[GetIndexFromId(id)].Cleared && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) { cmdlist.Add(_buffer[GetIndexFromId(id)].Clone()); i++; } @@ -535,7 +535,7 @@ internal HistoryInfo[] GetEntries(WildcardPattern wildcardpattern, long count, S { for (long i = 1; i <= _countEntriesAdded; i++) { - if (_buffer[GetIndexFromId(i)].Cleared == false && wildcardpattern.IsMatch(_buffer[GetIndexFromId(i)].CommandLine.Trim())) + if (!_buffer[GetIndexFromId(i)].Cleared && wildcardpattern.IsMatch(_buffer[GetIndexFromId(i)].CommandLine.Trim())) { cmdlist.Add(_buffer[GetIndexFromId(i)].Clone()); } @@ -663,7 +663,7 @@ private long SmallestIDinBuffer() for (int i = 0; i < _buffer.Length; i++) { // assign the first entry in the buffer as min. - if (_buffer[i] != null && _buffer[i].Cleared == false) + if (_buffer[i] != null && !_buffer[i].Cleared) { minID = _buffer[i].Id; break; @@ -672,7 +672,7 @@ private long SmallestIDinBuffer() // check for the minimum id that is not cleared for (int i = 0; i < _buffer.Length; i++) { - if (_buffer[i] != null && _buffer[i].Cleared == false) + if (_buffer[i] != null && !_buffer[i].Cleared) if (minID > _buffer[i].Id) minID = _buffer[i].Id; } @@ -1826,7 +1826,7 @@ private void ClearHistoryByID() else { // confirmation message if all the clearhistory cmdlet is used without any parameters - if (_countParameterSpecified == false) + if (!_countParameterSpecified) { string message = StringUtil.Format(HistoryStrings.ClearHistoryWarning, "Warning");// "The command would clear all the entry(s) from the session history,Are you sure you want to continue ?"; if (!ShouldProcess(message)) @@ -1968,7 +1968,7 @@ private void ClearHistoryEntries(long id, int count, string cmdline, SwitchParam // Clear the History value. foreach (HistoryInfo entry in _entries) { - if (entry != null && entry.Cleared == false) + if (entry != null && !entry.Cleared) _history.ClearEntry(entry.Id); } diff --git a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs index 8432b4432d0..468a94d8581 100644 --- a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs @@ -527,7 +527,7 @@ internal PSInformationalBuffers GetInformationalMessageBuffers() endLoop = false; break; } - } while (endLoop != true); + } while (!endLoop); return shouldContinue; } diff --git a/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs b/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs index 92740acf8dd..b606885fe10 100644 --- a/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs +++ b/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs @@ -987,7 +987,7 @@ private void StopOrDisconnectAllJobs() foreach (Job job in this.JobRepository.Jobs) { // Only stop or disconnect PowerShell jobs. - if (job is PSRemotingJob == false) + if (!(job is PSRemotingJob)) { continue; } diff --git a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs index fd34123937a..145f2c8596a 100644 --- a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs +++ b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs @@ -1131,7 +1131,7 @@ protected override { try { - if (_disposed == false) + if (!_disposed) { _disposed = true; if (disposing) diff --git a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs index dfd33cc2257..7da5d77e20e 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs @@ -1925,7 +1925,7 @@ public object Current /// public bool MoveNext() { - return MoveNext(_neverBlock == false); + return MoveNext(!_neverBlock); } /// diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index e5015a010a6..f55203cae57 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -3674,7 +3674,7 @@ public PSDataCollection EndInvoke(IAsyncResult asyncResult) if ((psAsyncResult == null) || (psAsyncResult.OwnerId != InstanceId) || - (psAsyncResult.IsAssociatedWithAsyncInvoke != true)) + (!psAsyncResult.IsAssociatedWithAsyncInvoke)) { throw PSTraceSource.NewArgumentException(nameof(asyncResult), PowerShellStrings.AsyncResultNotOwned, "IAsyncResult", "BeginInvoke"); diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs index 64efdb12e4a..0a99ec0ef20 100644 --- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs +++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs @@ -616,7 +616,7 @@ internal void DoConcurrentCheck(bool syncCall, object syncObject, bool isInLock) { PipelineBase currentPipeline = (PipelineBase)RunspaceBase.GetCurrentlyRunningPipeline(); - if (IsNested == false) + if (!IsNested) { if (currentPipeline == null) { @@ -663,7 +663,7 @@ internal void DoConcurrentCheck(bool syncCall, object syncObject, bool isInLock) { if (_performNestedCheck) { - if (syncCall == false) + if (!syncCall) { throw PSTraceSource.NewInvalidOperationException( RunspaceStrings.NestedPipelineInvokeAsync); @@ -688,7 +688,7 @@ internal void DoConcurrentCheck(bool syncCall, object syncObject, bool isInLock) Dbg.Assert(currentPipeline.NestedPipelineExecutionThread != null, "Current pipeline should always have NestedPipelineExecutionThread set"); Thread th = Thread.CurrentThread; - if (currentPipeline.NestedPipelineExecutionThread.Equals(th) == false) + if (!currentPipeline.NestedPipelineExecutionThread.Equals(th)) { throw PSTraceSource.NewInvalidOperationException( RunspaceStrings.NestedPipelineNoParentPipeline); @@ -1044,7 +1044,7 @@ protected override { try { - if (_disposed == false) + if (!_disposed) { _disposed = true; if (disposing) diff --git a/src/System.Management.Automation/engine/parser/Parser.cs b/src/System.Management.Automation/engine/parser/Parser.cs index e3245e91564..ebc0fab32cb 100644 --- a/src/System.Management.Automation/engine/parser/Parser.cs +++ b/src/System.Management.Automation/engine/parser/Parser.cs @@ -198,7 +198,7 @@ private ScriptBlockAst ParseTask(string fileName, string input, List toke } catch (InsufficientExecutionStackException) { - if (recursed == false) + if (!recursed) { // We'll try parsing once more, this time on a new thread. The assumption here is // that the stack was close to overflowing before we tried to parse, and that won't diff --git a/src/System.Management.Automation/engine/parser/SemanticChecks.cs b/src/System.Management.Automation/engine/parser/SemanticChecks.cs index f46b366785b..5f119b43b32 100644 --- a/src/System.Management.Automation/engine/parser/SemanticChecks.cs +++ b/src/System.Management.Automation/engine/parser/SemanticChecks.cs @@ -348,7 +348,7 @@ internal static void CheckArrayTypeNameDepth(ITypeName typeName, IScriptExtent e { int count = 0; ITypeName type = typeName; - while ((type is TypeName) == false) + while ((!(type is TypeName))) { count++; if (count > 200) diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 6db4da1670c..19f532f05b4 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -3477,11 +3477,11 @@ protected override void Dispose(bool disposing) protected virtual void DoCleanupOnFinished() { bool doCleanup = false; - if (_cleanupDone == false) + if (!_cleanupDone) { lock (SyncObject) { - if (_cleanupDone == false) + if (!_cleanupDone) { _cleanupDone = true; doCleanup = true; @@ -4233,11 +4233,11 @@ internal PSInvokeExpressionSyncJob(List operations, Throttle protected override void DoCleanupOnFinished() { bool doCleanup = false; - if (_cleanupDone == false) + if (!_cleanupDone) { lock (SyncObject) { - if (_cleanupDone == false) + if (!_cleanupDone) { _cleanupDone = true; doCleanup = true; diff --git a/src/System.Management.Automation/engine/remoting/client/JobManager.cs b/src/System.Management.Automation/engine/remoting/client/JobManager.cs index 6ef47c19752..b2e4f0d6454 100644 --- a/src/System.Management.Automation/engine/remoting/client/JobManager.cs +++ b/src/System.Management.Automation/engine/remoting/client/JobManager.cs @@ -643,7 +643,7 @@ private bool CheckTypeNames(JobSourceAdapter sourceAdapter, string[] jobSourceAd private string GetAdapterName(JobSourceAdapter sourceAdapter) { - return (string.IsNullOrEmpty(sourceAdapter.Name) == false ? + return (!string.IsNullOrEmpty(sourceAdapter.Name) ? sourceAdapter.Name : sourceAdapter.GetType().ToString()); } diff --git a/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs b/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs index 288bc1449e9..df859a7bc2b 100644 --- a/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs +++ b/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs @@ -238,11 +238,11 @@ public PSDataCollection InformationStream /// public void CloseAll() { - if (_disposed == false) + if (!_disposed) { lock (_syncLock) { - if (_disposed == false) + if (!_disposed) { _outputStream.Complete(); _errorStream.Complete(); diff --git a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs index 17b07b0f148..45e29c8762e 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs @@ -1270,7 +1270,7 @@ internal static RunspacePool[] GetRemoteRunspacePools(RunspaceConnectionInfo con Guid shellId = Guid.Parse(pspShellId.Value.ToString()); // Filter returned items for PowerShell sessions. - if (strShellUri.StartsWith(WSManNativeApi.ResourceURIPrefix, StringComparison.OrdinalIgnoreCase) == false) + if (!strShellUri.StartsWith(WSManNativeApi.ResourceURIPrefix, StringComparison.OrdinalIgnoreCase)) { continue; } diff --git a/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs b/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs index ec55f22fc22..b3de2795bff 100644 --- a/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs +++ b/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs @@ -277,7 +277,7 @@ private void SetStateHandler(object sender, RemoteSessionStateMachineEventArgs e Dbg.Assert(_state >= RemoteSessionState.Established, "Client can send a public key only after reaching the Established state"); - Dbg.Assert(_keyExchanged == false, "Client should do key exchange only once"); + Dbg.Assert(!_keyExchanged, "Client should do key exchange only once"); if (_state == RemoteSessionState.Established || _state == RemoteSessionState.EstablishedAndKeyRequested) diff --git a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs index 58931499610..ae83f6e871f 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs @@ -1048,7 +1048,7 @@ internal void DoConcurrentCheck(bool syncCall) RemotePipeline currentPipeline = (RemotePipeline)((RemoteRunspace)_runspace).GetCurrentlyRunningPipeline(); - if (_isNested == false) + if (!_isNested) { if (currentPipeline == null && ((RemoteRunspace)_runspace).RunspaceAvailability != RunspaceAvailability.Busy && @@ -1093,7 +1093,7 @@ internal void DoConcurrentCheck(bool syncCall) return; } - if (syncCall == false) + if (!syncCall) { throw PSTraceSource.NewInvalidOperationException( RunspaceStrings.NestedPipelineInvokeAsync); diff --git a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs index a927b49481f..09f5675ca06 100644 --- a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs +++ b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs @@ -1113,7 +1113,7 @@ internal void AddToRunningPipelineList(RemotePipeline pipeline) lock (_syncRoot) { - if (_bypassRunspaceStateCheck == false && + if (!_bypassRunspaceStateCheck && _runspaceStateInfo.State != RunspaceState.Opened && _runspaceStateInfo.State != RunspaceState.Disconnected) // Disconnected runspaces can have running pipelines. { diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 71985462fc5..bc72537e520 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -869,7 +869,7 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d if (configTable.ContainsKey(ConfigFileConstants.PowerShellVersion)) { - if (isPSVersionSpecified == false) + if (!isPSVersionSpecified) { try { @@ -1071,7 +1071,7 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d } // Default value for PSVersion - if (isPSVersionSpecified == false) + if (!isPSVersionSpecified) { psVersion = PSVersionInfo.PSVersion; } diff --git a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs index daef292017f..4f66511496b 100644 --- a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs @@ -972,7 +972,7 @@ protected override void BeginProcessing() // of this bug in Win8 where not responding can occur during data piping. // We are reverting to Win7 behavior for {icm | icm} and {proxycommand | proxycommand} // cases. For ICM | % ICM case, we are using remote steppable pipeline. - if ((MyInvocation != null) && (MyInvocation.PipelinePosition == 1) && (MyInvocation.ExpectingInput == false)) + if ((MyInvocation != null) && (MyInvocation.PipelinePosition == 1) && (!MyInvocation.ExpectingInput)) { PSPrimitiveDictionary table = (object)runspaceInfo.ApplicationPrivateData[PSVersionInfo.PSVersionTableName] as PSPrimitiveDictionary; if (table != null) diff --git a/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs b/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs index a68a6f78869..2ba391efdfc 100644 --- a/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs +++ b/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs @@ -32,7 +32,7 @@ internal T Value get { bool result = _valueWasSet.WaitOne(); - if (result == false) + if (!result) { _value = null; } diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs index 10814c3ea2b..ac4f200c617 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs @@ -831,7 +831,7 @@ private void HandleCreateAndInvokePowerShell(object _, RemoteDataEventArgs or . In // this case isEmpty is false. - if (isEmpty == false && _reader.NodeType == XmlNodeType.EndElement) + if (!isEmpty && _reader.NodeType == XmlNodeType.EndElement) { ReadEndElement(); isEmpty = true; diff --git a/src/System.Management.Automation/namespaces/RegistryProvider.cs b/src/System.Management.Automation/namespaces/RegistryProvider.cs index cb2963f40c7..48bf85b2f96 100644 --- a/src/System.Management.Automation/namespaces/RegistryProvider.cs +++ b/src/System.Management.Automation/namespaces/RegistryProvider.cs @@ -3061,7 +3061,7 @@ private void GetFilteredRegistryKeyProperties(string path, if ( expandAll || - ((Context.SuppressWildcardExpansion == false) && (valueNameMatcher.IsMatch(valueNameToMatch))) || + ((!Context.SuppressWildcardExpansion) && (valueNameMatcher.IsMatch(valueNameToMatch))) || ((Context.SuppressWildcardExpansion) && (string.Equals(valueNameToMatch, requestedValueName, StringComparison.OrdinalIgnoreCase)))) { if (string.IsNullOrEmpty(valueNameToMatch)) diff --git a/src/System.Management.Automation/utils/ObjectStream.cs b/src/System.Management.Automation/utils/ObjectStream.cs index eccfdfad901..35bf96d02be 100644 --- a/src/System.Management.Automation/utils/ObjectStream.cs +++ b/src/System.Management.Automation/utils/ObjectStream.cs @@ -755,7 +755,7 @@ internal override bool EndOfPipeline lock (_monitorObject) { - endOfStream = (_objects.Count == 0 && _isOpen == false); + endOfStream = (_objects.Count == 0 && !_isOpen); } return endOfStream; @@ -824,7 +824,7 @@ internal override int Count /// private bool WaitRead() { - if (EndOfPipeline == false) + if (!EndOfPipeline) { try { @@ -839,7 +839,7 @@ private bool WaitRead() } } - return EndOfPipeline == false; + return !EndOfPipeline; } /// @@ -1383,7 +1383,7 @@ internal override int Write(object obj, bool enumerateCollection) // wait for buffer available // false indicates EndOfPipeline - if (WaitWrite() == false) + if (!WaitWrite()) { break; } diff --git a/src/System.Management.Automation/utils/PsUtils.cs b/src/System.Management.Automation/utils/PsUtils.cs index 5866e3d52f9..a4c1dbf79f9 100644 --- a/src/System.Management.Automation/utils/PsUtils.cs +++ b/src/System.Management.Automation/utils/PsUtils.cs @@ -532,7 +532,7 @@ internal static object[] Base64ToArgsConverter(string base64) object dso; Deserializer deserializer = new Deserializer(reader); dso = deserializer.Deserialize(); - if (deserializer.Done() == false) + if (!deserializer.Done()) { // This helper function should move to host and it should provide appropriate // error message there. From 5d3dbe5e7875508dd1fd7275128a2ce7aa79a9d8 Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Sat, 15 Aug 2020 17:14:23 +0100 Subject: [PATCH 2/2] revert changes in System.Management.Automation --- .../engine/CommandDiscovery.cs | 2 +- .../engine/CommandMetadata.cs | 2 +- .../engine/CommandProcessor.cs | 2 +- .../engine/CoreAdapter.cs | 4 ++-- .../engine/ErrorPackage.cs | 2 +- .../engine/GetCommandCommand.cs | 2 +- .../engine/LanguagePrimitives.cs | 2 +- .../engine/Modules/ModuleCmdletBase.cs | 16 ++++++++-------- .../engine/NativeCommandProcessor.cs | 12 ++++++------ .../engine/SessionStateContainer.cs | 2 +- .../engine/TypeTable.cs | 2 +- .../engine/hostifaces/ConnectionBase.cs | 4 ++-- .../engine/hostifaces/History.cs | 16 ++++++++-------- .../hostifaces/InternalHostUserInterface.cs | 2 +- .../engine/hostifaces/LocalConnection.cs | 2 +- .../engine/hostifaces/LocalPipeline.cs | 2 +- .../engine/hostifaces/PSDataCollection.cs | 2 +- .../engine/hostifaces/PowerShell.cs | 2 +- .../engine/hostifaces/pipelinebase.cs | 8 ++++---- .../engine/parser/Parser.cs | 2 +- .../engine/parser/SemanticChecks.cs | 2 +- .../engine/remoting/client/Job.cs | 8 ++++---- .../engine/remoting/client/JobManager.cs | 2 +- .../engine/remoting/client/PowerShellStreams.cs | 4 ++-- .../client/RemoteRunspacePoolInternal.cs | 2 +- .../clientremotesessionprotocolstatemachine.cs | 2 +- .../engine/remoting/client/remotepipeline.cs | 4 ++-- .../engine/remoting/client/remoterunspace.cs | 2 +- .../remoting/commands/CustomShellCommands.cs | 4 ++-- .../remoting/commands/InvokeCommandCommand.cs | 2 +- .../engine/remoting/common/AsyncObject.cs | 2 +- .../remoting/server/ServerRunspacePoolDriver.cs | 2 +- .../engine/runtime/Binding/Binders.cs | 2 +- .../engine/runtime/Operations/MiscOps.cs | 4 ++-- .../engine/serialization.cs | 6 +++--- 35 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/System.Management.Automation/engine/CommandDiscovery.cs b/src/System.Management.Automation/engine/CommandDiscovery.cs index 62cfaa20163..f5f2a0501f0 100644 --- a/src/System.Management.Automation/engine/CommandDiscovery.cs +++ b/src/System.Management.Automation/engine/CommandDiscovery.cs @@ -784,7 +784,7 @@ internal static CommandInfo LookupCommandInfo( // Check the module auto-loading preference PSModuleAutoLoadingPreference moduleAutoLoadingPreference = GetCommandDiscoveryPreference(context, SpecialVariables.PSModuleAutoLoadingPreferenceVarPath, "PSModuleAutoLoadingPreference"); - if (eventArgs == null || !eventArgs.StopSearch) + if (eventArgs == null || eventArgs.StopSearch != true) { do { diff --git a/src/System.Management.Automation/engine/CommandMetadata.cs b/src/System.Management.Automation/engine/CommandMetadata.cs index 029b5247f48..edcd9a9cd66 100644 --- a/src/System.Management.Automation/engine/CommandMetadata.cs +++ b/src/System.Management.Automation/engine/CommandMetadata.cs @@ -926,7 +926,7 @@ internal string GetDecl() separator = ", "; } - if (!PositionalBinding) + if (PositionalBinding == false) { decl.Append(separator); decl.Append("PositionalBinding=$false"); diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs index a44909f2c3b..4433d75ca99 100644 --- a/src/System.Management.Automation/engine/CommandProcessor.cs +++ b/src/System.Management.Automation/engine/CommandProcessor.cs @@ -528,7 +528,7 @@ internal sealed override bool Read() try { // Process the input pipeline object - if (!ProcessInputPipelineObject(inputObject)) + if (false == ProcessInputPipelineObject(inputObject)) { // The input object was not bound to any parameters of the cmdlet. // Write a non-terminating error and continue with the next input diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs index 956ae5a5395..b6752387d58 100644 --- a/src/System.Management.Automation/engine/CoreAdapter.cs +++ b/src/System.Management.Automation/engine/CoreAdapter.cs @@ -1395,8 +1395,8 @@ private static MethodInformation FindBestMethodImpl( // We also skip the optimization if the number of arguments and parameters is different // so we let the loop deal with possible optional parameters. if ((methods.Length == 1) && - (!methods[0].hasVarArgs) && - (!methods[0].isGeneric) && + (methods[0].hasVarArgs == false) && + (methods[0].isGeneric == false) && (methods[0].method == null || !(methods[0].method.DeclaringType.IsGenericTypeDefinition)) && // generic methods need to be double checked in a loop below - generic methods can be rejected if type inference fails (methods[0].parameters.Length == arguments.Length)) diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index 696923d7dfa..fc346e2ee96 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -1338,7 +1338,7 @@ private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord) string errorDetails_ScriptStackTrace = GetNoteValue(serializedErrorRecord, "ErrorDetails_ScriptStackTrace") as string; - RemoteException re = new RemoteException((!string.IsNullOrWhiteSpace(exceptionMessage)) ? exceptionMessage : errorCategory_Message, serializedException, invocationInfo); + RemoteException re = new RemoteException((string.IsNullOrWhiteSpace(exceptionMessage) == false) ? exceptionMessage : errorCategory_Message, serializedException, invocationInfo); // Create ErrorRecord PopulateProperties( diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs index fca1c9dc06e..b3ab36ae19c 100644 --- a/src/System.Management.Automation/engine/GetCommandCommand.cs +++ b/src/System.Management.Automation/engine/GetCommandCommand.cs @@ -1421,7 +1421,7 @@ private IEnumerable GetMatchingCommandsFromModules(string commandNa { PSModuleInfo module = null; - if (!Context.EngineSessionState.ModuleTable.TryGetValue(Context.EngineSessionState.ModuleTableKeys[i], out module)) + if (Context.EngineSessionState.ModuleTable.TryGetValue(Context.EngineSessionState.ModuleTableKeys[i], out module) == false) { Dbg.Assert(false, "ModuleTableKeys should be in sync with ModuleTable"); } diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index acf2ce919ea..5929a5637e9 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -4747,7 +4747,7 @@ private static string GetAvailableProperties(PSObject pso) { foreach (PSPropertyInfo p in pso.Properties) { - if (!first) + if (first == false) { availableProperties.Append(" , "); } diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index d518c28267e..f1f8aaff1f7 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -723,7 +723,7 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module // NestedModules = 'test2' ---> test2 is a directory under current module directory (e.g - Test1) // We also need to look for Test1\Test2\Test2.(psd1/psm1/dll) // With the call above, we are only looking at Test1\Test2.(psd1/psm1/dll) - if (!found && !moduleFileFound) + if (found == false && moduleFileFound == false) { string newRootedPath = Path.Combine(rootedPath, moduleSpecification.Name); string newModuleBase = Path.Combine(moduleBase, moduleSpecification.Name); @@ -764,7 +764,7 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module // Win8: 262157 - Import-Module is giving errors while loading Nested Modules. (This is a V2 bug) // Only look for the file if the file was not found with the previous search - if (!found && !moduleFileFound) + if (found == false && moduleFileFound == false) { string newRootedPath = Path.Combine(rootedPath, moduleSpecification.Name); string newModuleBase = Path.Combine(moduleBase, moduleSpecification.Name); @@ -786,10 +786,10 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module } // The rooted files wasn't found, so don't search anymore... - if (!found && wasRooted) + if (found == false && wasRooted) return null; - if (searchModulePath && !found && !moduleFileFound) + if (searchModulePath && found == false && moduleFileFound == false) { if (VerifyIfNestedModuleIsAvailable(moduleSpecification, null, null, out tempModuleInfoFromVerification)) { @@ -846,7 +846,7 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module // At this point, we haven't found an actual module, so try loading it as a // PSSnapIn and then finally as an assembly in the GAC... - if ((!found) && (moduleSpecification.Guid == null) && (moduleSpecification.Version == null) && (moduleSpecification.RequiredVersion == null) && (moduleSpecification.MaximumVersion == null)) + if ((found == false) && (moduleSpecification.Guid == null) && (moduleSpecification.Version == null) && (moduleSpecification.RequiredVersion == null) && (moduleSpecification.MaximumVersion == null)) { // If we are in module analysis and the parent module declares non-wildcarded ExportedCmdlets, then we don't need to // actually process the binary module. @@ -4956,7 +4956,7 @@ internal void RemoveModule(PSModuleInfo module, string moduleNameInRemoveModuleC args: new object[] { module }); } - if (module.ImplementingAssembly != null && !module.ImplementingAssembly.IsDynamic) + if (module.ImplementingAssembly != null && module.ImplementingAssembly.IsDynamic == false) { var exportedTypes = PSSnapInHelpers.GetAssemblyTypes(module.ImplementingAssembly, module.Name); foreach (var type in exportedTypes) @@ -6666,7 +6666,7 @@ internal PSModuleInfo LoadBinaryModule(PSModuleInfo parentModule, bool trySnapIn } } - if (!importSuccessful) + if (importSuccessful == false) { if (importingModule) { @@ -7087,7 +7087,7 @@ internal static void AddModuleToModuleTables(ExecutionContext context, SessionSt } var privateDataHashTable = module.PrivateData as Hashtable; - if (!context.Modules.IsImplicitRemotingModuleLoaded && + if (context.Modules.IsImplicitRemotingModuleLoaded == false && privateDataHashTable != null && privateDataHashTable.ContainsKey("ImplicitRemoting")) { context.Modules.IsImplicitRemotingModuleLoaded = true; diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 9dc14ae53a3..3a12dab6295 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -503,7 +503,7 @@ private void InitNativeProcess() // we will try launching one last time using ShellExecute... if (notDone) { - if (soloCommand && !startInfo.UseShellExecute) + if (soloCommand && startInfo.UseShellExecute == false) { startInfo.UseShellExecute = true; startInfo.RedirectStandardInput = false; @@ -530,7 +530,7 @@ private void InitNativeProcess() else { _isRunningInBackground = true; - if (!startInfo.UseShellExecute) + if (startInfo.UseShellExecute == false) { _isRunningInBackground = IsWindowsApplication(_nativeProcess.StartInfo.FileName); } @@ -562,7 +562,7 @@ private void InitNativeProcess() throw; } - if (!_isRunningInBackground) + if (_isRunningInBackground == false) { InitOutputQueue(); } @@ -653,7 +653,7 @@ private ProcessOutputObject DequeueProcessOutput(bool blocking) /// private void ConsumeAvailableNativeProcessOutput(bool blocking) { - if (!_isRunningInBackground) + if (_isRunningInBackground == false) { if (_nativeProcess.StartInfo.RedirectStandardOutput || _nativeProcess.StartInfo.RedirectStandardError) { @@ -677,7 +677,7 @@ internal override void Complete() Exception exceptionToRethrow = null; try { - if (!_isRunningInBackground) + if (_isRunningInBackground == false) { // Wait for input writer to finish. _inputWriter.Done(); @@ -1246,7 +1246,7 @@ private void CalculateIORedirection(out bool redirectOutput, out bool redirectEr // In minishell scenario, if output is redirected // then error should also be redirected. - if (!redirectError && redirectOutput && _isMiniShell) + if (redirectError == false && redirectOutput && _isMiniShell) { redirectError = true; } diff --git a/src/System.Management.Automation/engine/SessionStateContainer.cs b/src/System.Management.Automation/engine/SessionStateContainer.cs index d99fdcc58f6..f4f2a46d2a5 100644 --- a/src/System.Management.Automation/engine/SessionStateContainer.cs +++ b/src/System.Management.Automation/engine/SessionStateContainer.cs @@ -628,7 +628,7 @@ internal bool IsItemContainer( foreach (string providerPath in providerPaths) { result = IsItemContainer(providerInstance, providerPath, context); - if (!result) + if (result == false) { break; } diff --git a/src/System.Management.Automation/engine/TypeTable.cs b/src/System.Management.Automation/engine/TypeTable.cs index beefa7c698b..74b2f6910f8 100644 --- a/src/System.Management.Automation/engine/TypeTable.cs +++ b/src/System.Management.Automation/engine/TypeTable.cs @@ -3192,7 +3192,7 @@ private static bool CheckStandardMembers(ConcurrentBag errors, string ty } while (false); - if (!serializationSettingsOk) + if (serializationSettingsOk == false) { AddError(errors, typeName, TypesXmlStrings.SerializationSettingsIgnored); members.Remove(InheritPropertySerializationSet); diff --git a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs index 3327eccf89c..4b933b590b9 100644 --- a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs +++ b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs @@ -829,7 +829,7 @@ internal void AddToRunningPipelineList(PipelineBase pipeline) lock (_pipelineListLock) { - if (!ByPassRunspaceStateCheck && RunspaceState != RunspaceState.Opened) + if (ByPassRunspaceStateCheck == false && RunspaceState != RunspaceState.Opened) { InvalidRunspaceStateException e = new InvalidRunspaceStateException @@ -1002,7 +1002,7 @@ internal void StopNestedPipelines(Pipeline pipeline) // first check if this pipeline is in the list of running // pipelines. It is possible that pipeline has already // completed. - if (!RunningPipelines.Contains(pipeline)) + if (RunningPipelines.Contains(pipeline) == false) { return; } diff --git a/src/System.Management.Automation/engine/hostifaces/History.cs b/src/System.Management.Automation/engine/hostifaces/History.cs index b88b12975ea..a88692a91e7 100644 --- a/src/System.Management.Automation/engine/hostifaces/History.cs +++ b/src/System.Management.Automation/engine/hostifaces/History.cs @@ -264,7 +264,7 @@ internal HistoryInfo GetEntry(long id) HistoryInfo entry = CoreGetEntry(id); if (entry != null) - if (!entry.Cleared) + if (entry.Cleared == false) return entry.Clone(); return null; @@ -498,7 +498,7 @@ internal HistoryInfo[] GetEntries(WildcardPattern wildcardpattern, long count, S for (long i = 0; i <= count - 1;) { if (id > _countEntriesAdded) break; - if (!_buffer[GetIndexFromId(id)].Cleared && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) + if (_buffer[GetIndexFromId(id)].Cleared == false && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) { cmdlist.Add(_buffer[GetIndexFromId(id)].Clone()); i++; } @@ -522,7 +522,7 @@ internal HistoryInfo[] GetEntries(WildcardPattern wildcardpattern, long count, S } if (id < 1) break; - if (!_buffer[GetIndexFromId(id)].Cleared && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) + if (_buffer[GetIndexFromId(id)].Cleared == false && wildcardpattern.IsMatch(_buffer[GetIndexFromId(id)].CommandLine.Trim())) { cmdlist.Add(_buffer[GetIndexFromId(id)].Clone()); i++; } @@ -535,7 +535,7 @@ internal HistoryInfo[] GetEntries(WildcardPattern wildcardpattern, long count, S { for (long i = 1; i <= _countEntriesAdded; i++) { - if (!_buffer[GetIndexFromId(i)].Cleared && wildcardpattern.IsMatch(_buffer[GetIndexFromId(i)].CommandLine.Trim())) + if (_buffer[GetIndexFromId(i)].Cleared == false && wildcardpattern.IsMatch(_buffer[GetIndexFromId(i)].CommandLine.Trim())) { cmdlist.Add(_buffer[GetIndexFromId(i)].Clone()); } @@ -663,7 +663,7 @@ private long SmallestIDinBuffer() for (int i = 0; i < _buffer.Length; i++) { // assign the first entry in the buffer as min. - if (_buffer[i] != null && !_buffer[i].Cleared) + if (_buffer[i] != null && _buffer[i].Cleared == false) { minID = _buffer[i].Id; break; @@ -672,7 +672,7 @@ private long SmallestIDinBuffer() // check for the minimum id that is not cleared for (int i = 0; i < _buffer.Length; i++) { - if (_buffer[i] != null && !_buffer[i].Cleared) + if (_buffer[i] != null && _buffer[i].Cleared == false) if (minID > _buffer[i].Id) minID = _buffer[i].Id; } @@ -1826,7 +1826,7 @@ private void ClearHistoryByID() else { // confirmation message if all the clearhistory cmdlet is used without any parameters - if (!_countParameterSpecified) + if (_countParameterSpecified == false) { string message = StringUtil.Format(HistoryStrings.ClearHistoryWarning, "Warning");// "The command would clear all the entry(s) from the session history,Are you sure you want to continue ?"; if (!ShouldProcess(message)) @@ -1968,7 +1968,7 @@ private void ClearHistoryEntries(long id, int count, string cmdline, SwitchParam // Clear the History value. foreach (HistoryInfo entry in _entries) { - if (entry != null && !entry.Cleared) + if (entry != null && entry.Cleared == false) _history.ClearEntry(entry.Id); } diff --git a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs index 468a94d8581..8432b4432d0 100644 --- a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs @@ -527,7 +527,7 @@ internal PSInformationalBuffers GetInformationalMessageBuffers() endLoop = false; break; } - } while (!endLoop); + } while (endLoop != true); return shouldContinue; } diff --git a/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs b/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs index b606885fe10..92740acf8dd 100644 --- a/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs +++ b/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs @@ -987,7 +987,7 @@ private void StopOrDisconnectAllJobs() foreach (Job job in this.JobRepository.Jobs) { // Only stop or disconnect PowerShell jobs. - if (!(job is PSRemotingJob)) + if (job is PSRemotingJob == false) { continue; } diff --git a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs index 145f2c8596a..fd34123937a 100644 --- a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs +++ b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs @@ -1131,7 +1131,7 @@ protected override { try { - if (!_disposed) + if (_disposed == false) { _disposed = true; if (disposing) diff --git a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs index 7da5d77e20e..dfd33cc2257 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs @@ -1925,7 +1925,7 @@ public object Current /// public bool MoveNext() { - return MoveNext(!_neverBlock); + return MoveNext(_neverBlock == false); } /// diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index f55203cae57..e5015a010a6 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -3674,7 +3674,7 @@ public PSDataCollection EndInvoke(IAsyncResult asyncResult) if ((psAsyncResult == null) || (psAsyncResult.OwnerId != InstanceId) || - (!psAsyncResult.IsAssociatedWithAsyncInvoke)) + (psAsyncResult.IsAssociatedWithAsyncInvoke != true)) { throw PSTraceSource.NewArgumentException(nameof(asyncResult), PowerShellStrings.AsyncResultNotOwned, "IAsyncResult", "BeginInvoke"); diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs index 0a99ec0ef20..64efdb12e4a 100644 --- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs +++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs @@ -616,7 +616,7 @@ internal void DoConcurrentCheck(bool syncCall, object syncObject, bool isInLock) { PipelineBase currentPipeline = (PipelineBase)RunspaceBase.GetCurrentlyRunningPipeline(); - if (!IsNested) + if (IsNested == false) { if (currentPipeline == null) { @@ -663,7 +663,7 @@ internal void DoConcurrentCheck(bool syncCall, object syncObject, bool isInLock) { if (_performNestedCheck) { - if (!syncCall) + if (syncCall == false) { throw PSTraceSource.NewInvalidOperationException( RunspaceStrings.NestedPipelineInvokeAsync); @@ -688,7 +688,7 @@ internal void DoConcurrentCheck(bool syncCall, object syncObject, bool isInLock) Dbg.Assert(currentPipeline.NestedPipelineExecutionThread != null, "Current pipeline should always have NestedPipelineExecutionThread set"); Thread th = Thread.CurrentThread; - if (!currentPipeline.NestedPipelineExecutionThread.Equals(th)) + if (currentPipeline.NestedPipelineExecutionThread.Equals(th) == false) { throw PSTraceSource.NewInvalidOperationException( RunspaceStrings.NestedPipelineNoParentPipeline); @@ -1044,7 +1044,7 @@ protected override { try { - if (!_disposed) + if (_disposed == false) { _disposed = true; if (disposing) diff --git a/src/System.Management.Automation/engine/parser/Parser.cs b/src/System.Management.Automation/engine/parser/Parser.cs index ebc0fab32cb..e3245e91564 100644 --- a/src/System.Management.Automation/engine/parser/Parser.cs +++ b/src/System.Management.Automation/engine/parser/Parser.cs @@ -198,7 +198,7 @@ private ScriptBlockAst ParseTask(string fileName, string input, List toke } catch (InsufficientExecutionStackException) { - if (!recursed) + if (recursed == false) { // We'll try parsing once more, this time on a new thread. The assumption here is // that the stack was close to overflowing before we tried to parse, and that won't diff --git a/src/System.Management.Automation/engine/parser/SemanticChecks.cs b/src/System.Management.Automation/engine/parser/SemanticChecks.cs index 5f119b43b32..f46b366785b 100644 --- a/src/System.Management.Automation/engine/parser/SemanticChecks.cs +++ b/src/System.Management.Automation/engine/parser/SemanticChecks.cs @@ -348,7 +348,7 @@ internal static void CheckArrayTypeNameDepth(ITypeName typeName, IScriptExtent e { int count = 0; ITypeName type = typeName; - while ((!(type is TypeName))) + while ((type is TypeName) == false) { count++; if (count > 200) diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 19f532f05b4..6db4da1670c 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -3477,11 +3477,11 @@ protected override void Dispose(bool disposing) protected virtual void DoCleanupOnFinished() { bool doCleanup = false; - if (!_cleanupDone) + if (_cleanupDone == false) { lock (SyncObject) { - if (!_cleanupDone) + if (_cleanupDone == false) { _cleanupDone = true; doCleanup = true; @@ -4233,11 +4233,11 @@ internal PSInvokeExpressionSyncJob(List operations, Throttle protected override void DoCleanupOnFinished() { bool doCleanup = false; - if (!_cleanupDone) + if (_cleanupDone == false) { lock (SyncObject) { - if (!_cleanupDone) + if (_cleanupDone == false) { _cleanupDone = true; doCleanup = true; diff --git a/src/System.Management.Automation/engine/remoting/client/JobManager.cs b/src/System.Management.Automation/engine/remoting/client/JobManager.cs index b2e4f0d6454..6ef47c19752 100644 --- a/src/System.Management.Automation/engine/remoting/client/JobManager.cs +++ b/src/System.Management.Automation/engine/remoting/client/JobManager.cs @@ -643,7 +643,7 @@ private bool CheckTypeNames(JobSourceAdapter sourceAdapter, string[] jobSourceAd private string GetAdapterName(JobSourceAdapter sourceAdapter) { - return (!string.IsNullOrEmpty(sourceAdapter.Name) ? + return (string.IsNullOrEmpty(sourceAdapter.Name) == false ? sourceAdapter.Name : sourceAdapter.GetType().ToString()); } diff --git a/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs b/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs index df859a7bc2b..288bc1449e9 100644 --- a/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs +++ b/src/System.Management.Automation/engine/remoting/client/PowerShellStreams.cs @@ -238,11 +238,11 @@ public PSDataCollection InformationStream /// public void CloseAll() { - if (!_disposed) + if (_disposed == false) { lock (_syncLock) { - if (!_disposed) + if (_disposed == false) { _outputStream.Complete(); _errorStream.Complete(); diff --git a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs index 45e29c8762e..17b07b0f148 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs @@ -1270,7 +1270,7 @@ internal static RunspacePool[] GetRemoteRunspacePools(RunspaceConnectionInfo con Guid shellId = Guid.Parse(pspShellId.Value.ToString()); // Filter returned items for PowerShell sessions. - if (!strShellUri.StartsWith(WSManNativeApi.ResourceURIPrefix, StringComparison.OrdinalIgnoreCase)) + if (strShellUri.StartsWith(WSManNativeApi.ResourceURIPrefix, StringComparison.OrdinalIgnoreCase) == false) { continue; } diff --git a/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs b/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs index b3de2795bff..ec55f22fc22 100644 --- a/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs +++ b/src/System.Management.Automation/engine/remoting/client/clientremotesessionprotocolstatemachine.cs @@ -277,7 +277,7 @@ private void SetStateHandler(object sender, RemoteSessionStateMachineEventArgs e Dbg.Assert(_state >= RemoteSessionState.Established, "Client can send a public key only after reaching the Established state"); - Dbg.Assert(!_keyExchanged, "Client should do key exchange only once"); + Dbg.Assert(_keyExchanged == false, "Client should do key exchange only once"); if (_state == RemoteSessionState.Established || _state == RemoteSessionState.EstablishedAndKeyRequested) diff --git a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs index ae83f6e871f..58931499610 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs @@ -1048,7 +1048,7 @@ internal void DoConcurrentCheck(bool syncCall) RemotePipeline currentPipeline = (RemotePipeline)((RemoteRunspace)_runspace).GetCurrentlyRunningPipeline(); - if (!_isNested) + if (_isNested == false) { if (currentPipeline == null && ((RemoteRunspace)_runspace).RunspaceAvailability != RunspaceAvailability.Busy && @@ -1093,7 +1093,7 @@ internal void DoConcurrentCheck(bool syncCall) return; } - if (!syncCall) + if (syncCall == false) { throw PSTraceSource.NewInvalidOperationException( RunspaceStrings.NestedPipelineInvokeAsync); diff --git a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs index 09f5675ca06..a927b49481f 100644 --- a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs +++ b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs @@ -1113,7 +1113,7 @@ internal void AddToRunningPipelineList(RemotePipeline pipeline) lock (_syncRoot) { - if (!_bypassRunspaceStateCheck && + if (_bypassRunspaceStateCheck == false && _runspaceStateInfo.State != RunspaceState.Opened && _runspaceStateInfo.State != RunspaceState.Disconnected) // Disconnected runspaces can have running pipelines. { diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index bc72537e520..71985462fc5 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -869,7 +869,7 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d if (configTable.ContainsKey(ConfigFileConstants.PowerShellVersion)) { - if (!isPSVersionSpecified) + if (isPSVersionSpecified == false) { try { @@ -1071,7 +1071,7 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d } // Default value for PSVersion - if (!isPSVersionSpecified) + if (isPSVersionSpecified == false) { psVersion = PSVersionInfo.PSVersion; } diff --git a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs index 4f66511496b..daef292017f 100644 --- a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs @@ -972,7 +972,7 @@ protected override void BeginProcessing() // of this bug in Win8 where not responding can occur during data piping. // We are reverting to Win7 behavior for {icm | icm} and {proxycommand | proxycommand} // cases. For ICM | % ICM case, we are using remote steppable pipeline. - if ((MyInvocation != null) && (MyInvocation.PipelinePosition == 1) && (!MyInvocation.ExpectingInput)) + if ((MyInvocation != null) && (MyInvocation.PipelinePosition == 1) && (MyInvocation.ExpectingInput == false)) { PSPrimitiveDictionary table = (object)runspaceInfo.ApplicationPrivateData[PSVersionInfo.PSVersionTableName] as PSPrimitiveDictionary; if (table != null) diff --git a/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs b/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs index 2ba391efdfc..a68a6f78869 100644 --- a/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs +++ b/src/System.Management.Automation/engine/remoting/common/AsyncObject.cs @@ -32,7 +32,7 @@ internal T Value get { bool result = _valueWasSet.WaitOne(); - if (!result) + if (result == false) { _value = null; } diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs index ac4f200c617..10814c3ea2b 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs @@ -831,7 +831,7 @@ private void HandleCreateAndInvokePowerShell(object _, RemoteDataEventArgs or . In // this case isEmpty is false. - if (!isEmpty && _reader.NodeType == XmlNodeType.EndElement) + if (isEmpty == false && _reader.NodeType == XmlNodeType.EndElement) { ReadEndElement(); isEmpty = true;