From d44fa0dab5756398a1780ba87d57c5ca5c1860a0 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 13:34:43 +0500 Subject: [PATCH 01/27] Replace \((null) != (\w+)\) -> ($2 != $1) --- .../CimSessionProxy.cs | 4 +- .../NewCimInstanceCommand.cs | 2 +- .../commands/management/Eventlog.cs | 2 +- .../commands/management/Process.cs | 2 +- .../commands/management/Service.cs | 14 ++--- .../commands/management/TimeZoneCommands.cs | 2 +- .../commands/utility/CSVCommands.cs | 2 +- .../commands/utility/ExportAliasCommand.cs | 8 +-- .../OutGridView/OriginalColumnInfo.cs | 2 +- .../FormatAndOutput/OutGridView/TableView.cs | 2 +- .../FormatAndOutput/out-file/Out-File.cs | 2 +- .../commands/utility/GetMember.cs | 2 +- .../commands/utility/Measure-Object.cs | 4 +- .../Common/InvokeRestMethodCommand.Common.cs | 4 +- .../Common/WebRequestPSCmdlet.Common.cs | 48 ++++++++--------- .../Common/WebResponseObject.Common.cs | 2 +- .../utility/WebCmdlet/StreamHelper.cs | 2 +- .../commands/utility/XmlCommands.cs | 10 ++-- .../commands/utility/compare-object.cs | 10 ++-- .../commands/utility/write.cs | 4 +- ...ConsoleHostUserInterfacePromptForChoice.cs | 2 +- .../Commands/AddLocalGroupMemberCommand.cs | 8 +-- .../Commands/RemoveLocalGroupMemberCommand.cs | 8 +-- .../security/SignatureCommands.cs | 2 +- .../ConfigProvider.cs | 18 +++---- src/Microsoft.WSMan.Management/WsManHelper.cs | 2 +- .../CoreCLR/CorePsPlatform.cs | 2 +- .../common/DisplayDatabase/FormatTable.cs | 2 +- .../displayDescriptionData_List.cs | 2 +- .../displayDescriptionData_Table.cs | 2 +- .../common/DisplayDatabase/typeDataQuery.cs | 10 ++-- .../common/FormatViewGenerator.cs | 2 +- .../common/FormatViewGenerator_Complex.cs | 2 +- .../common/FormatViewGenerator_List.cs | 2 +- .../common/FormatViewGenerator_Table.cs | 2 +- .../common/FormatViewGenerator_Wide.cs | 2 +- .../common/Utilities/MshObjectUtil.cs | 12 ++--- .../engine/CommandProcessor.cs | 2 +- .../engine/CommandProcessorBase.cs | 6 +-- .../engine/CoreAdapter.cs | 4 +- .../engine/ErrorPackage.cs | 4 +- .../engine/ExtraAdapter.cs | 6 +-- .../engine/GetCommandCommand.cs | 2 +- .../engine/InitialSessionState.cs | 10 ++-- .../engine/ManagementObjectAdapter.cs | 8 +-- .../engine/MergedCommandParameterMetadata.cs | 4 +- .../engine/Modules/ImportModuleCommand.cs | 4 +- .../Modules/NewModuleManifestCommand.cs | 2 +- .../engine/MshCmdlet.cs | 6 +-- .../engine/MshCommandRuntime.cs | 6 +-- .../engine/MshObject.cs | 10 ++-- .../engine/ParameterBinderBase.cs | 2 +- .../engine/Pipe.cs | 6 +-- .../engine/SessionState.cs | 2 +- .../engine/TypeTable.cs | 4 +- .../engine/Utils.cs | 8 +-- .../engine/hostifaces/AsyncResult.cs | 6 +-- .../hostifaces/InternalHostUserInterface.cs | 4 +- .../engine/hostifaces/LocalPipeline.cs | 6 +-- .../hostifaces/NativeCultureResolver.cs | 4 +- .../engine/hostifaces/PSDataCollection.cs | 26 ++++----- .../engine/hostifaces/PowerShell.cs | 54 +++++++++---------- .../engine/hostifaces/RunspacePoolInternal.cs | 2 +- .../engine/pipeline.cs | 22 ++++---- .../remoting/client/ClientRemotePowerShell.cs | 2 +- .../engine/remoting/client/Job.cs | 18 +++---- .../client/RemoteRunspacePoolInternal.cs | 2 +- .../remoting/client/RemotingErrorRecord.cs | 2 +- .../remoting/client/RemotingProtocol2.cs | 2 +- .../engine/remoting/client/remoterunspace.cs | 2 +- .../client/remotingprotocolimplementation.cs | 6 +-- .../remoting/commands/CustomShellCommands.cs | 4 +- .../remoting/commands/PushRunspaceCommand.cs | 4 +- .../remoting/commands/newrunspacecommand.cs | 4 +- .../WireDataFormat/RemoteSessionCapability.cs | 2 +- .../WireDataFormat/RemotingDataObject.cs | 2 +- .../engine/remoting/common/fragmentor.cs | 10 ++-- .../remoting/fanin/BaseTransportManager.cs | 4 +- .../fanin/InitialSessionStateProvider.cs | 10 ++-- .../fanin/OutOfProcTransportManager.cs | 14 ++--- .../engine/remoting/fanin/PSPrincipal.cs | 6 +-- .../remoting/fanin/PriorityCollection.cs | 14 ++--- .../engine/remoting/fanin/WSManNativeAPI.cs | 6 +-- .../engine/remoting/fanin/WSManPlugin.cs | 12 ++--- .../remoting/fanin/WSManPluginFacade.cs | 4 +- .../remoting/fanin/WSManPluginShellSession.cs | 10 ++-- .../fanin/WSManPluginTransportManager.cs | 6 +-- .../remoting/fanin/WSManTransportManager.cs | 38 ++++++------- .../server/OutOfProcServerMediator.cs | 8 +-- .../remoting/server/ServerPowerShellDriver.cs | 2 +- .../server/ServerRunspacePoolDriver.cs | 2 +- .../remoting/server/serverremotesession.cs | 4 +- .../engine/runtime/Binding/Binders.cs | 4 +- .../engine/serialization.cs | 6 +-- .../help/BaseCommandHelpInfo.cs | 4 +- .../help/CabinetNativeApi.cs | 4 +- .../help/CommandHelpProvider.cs | 10 ++-- .../help/HelpCommands.cs | 16 +++--- .../help/HelpProviderWithCache.cs | 2 +- .../help/HelpSystem.cs | 2 +- .../help/MamlUtil.cs | 12 ++--- .../help/UpdatableHelpCommandBase.cs | 2 +- .../namespaces/FileSystemContentStream.cs | 2 +- .../namespaces/FileSystemProvider.cs | 18 +++---- .../namespaces/TransactedRegistryKey.cs | 6 +-- .../utils/CryptoUtils.cs | 6 +-- .../utils/ExecutionExceptions.cs | 8 +-- .../utils/PSTelemetryWrapper.cs | 2 +- 108 files changed, 366 insertions(+), 366 deletions(-) diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs index ea84a9d718a..b084c3408ca 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs @@ -226,7 +226,7 @@ internal class CimSessionProxy : IDisposable /// CimSession to be added internal static void AddCimSessionToTemporaryCache(CimSession session) { - if (null != session) + if (session != null) { lock (temporarySessionCacheLock) { @@ -252,7 +252,7 @@ internal static void AddCimSessionToTemporaryCache(CimSession session) private static void RemoveCimSessionFromTemporaryCache(CimSession session, bool dispose) { - if (null != session) + if (session != null) { bool removed = false; lock (temporarySessionCacheLock) diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs index 14f9c5f13c7..9dd8c1fcb0a 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs @@ -325,7 +325,7 @@ protected override void ProcessRecord() { conflictParameterName = @"CimSession"; } - if (null != conflictParameterName) + if (conflictParameterName != null) { ThrowConflictParameterWasSet(@"New-CimInstance", conflictParameterName, @"ClientOnly"); return; diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs index eececdd3d33..e528b031d30 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Eventlog.cs @@ -403,7 +403,7 @@ private void Process(EventLog log) + ": " + e.Message); throw; } - if ((null != entry) && + if ((entry != null) && ((lastindex == Int32.MinValue || lastindex - entry.Index == 1))) { diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index 0ac97156103..b5666c6af95 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -1406,7 +1406,7 @@ private void StopProcess(Process process) exception = e; } - if (null != exception) + if (exception != null) { if (!TryHasExited(process)) { diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index d993091378d..5192656cb79 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -852,7 +852,7 @@ internal bool DoStartService(ServiceController serviceController) exception = e; } } - if (null != exception) + if (exception != null) { // This service refused to accept the start command, // so write a non-terminating error. @@ -968,7 +968,7 @@ internal List DoStopService(ServiceController serviceControll exception = e; } } - if (null != exception) + if (exception != null) { // This service refused to accept the stop command, // so write a non-terminating error. @@ -1074,7 +1074,7 @@ internal bool DoPauseService(ServiceController serviceController) } exception = e; } - if (null != exception) + if (exception != null) { // This service refused to accept the pause command, // so write a non-terminating error. @@ -1152,7 +1152,7 @@ internal bool DoResumeService(ServiceController serviceController) } exception = e; } - if (null != exception) + if (exception != null) { // This service refused to accept the continue command, // so write a non-terminating error. @@ -1679,7 +1679,7 @@ protected override void ProcessRecord() } string username = null; - if (null != Credential) + if (Credential != null) { username = Credential.UserName; password = Marshal.SecureStringToCoTaskMemUnicode(Credential.Password); @@ -2024,7 +2024,7 @@ protected override void BeginProcessing() } // set up the double-null-terminated lpDependencies parameter IntPtr lpDependencies = IntPtr.Zero; - if (null != DependsOn) + if (DependsOn != null) { int numchars = 1; // final null foreach (string dependedOn in DependsOn) @@ -2052,7 +2052,7 @@ protected override void BeginProcessing() // set up the Credential parameter string username = null; - if (null != Credential) + if (Credential != null) { username = Credential.UserName; password = Marshal.SecureStringToCoTaskMemUnicode(Credential.Password); diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs index 42c54f74caa..426e289c562 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs @@ -76,7 +76,7 @@ protected override void ProcessRecord() } else // ParameterSetName == "Name" { - if (null != Name) + if (Name != null) { // lookup each time zone name (or wildcard pattern) foreach (string tzname in Name) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs index 3f2ebe891fc..92615db7192 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs @@ -405,7 +405,7 @@ private void CreateFileStream() _fs.Dispose(); _fs = null; // reset the read-only attribute - if (null != _readOnlyFileInfo) + if (_readOnlyFileInfo != null) _readOnlyFileInfo.Attributes |= FileAttributes.ReadOnly; } if (_helper != null) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs index fa5764b5c7e..a0df0cc18e9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs @@ -267,7 +267,7 @@ protected override void EndProcessing() writer = OpenFile(out readOnlyFileInfo); } - if (null != writer) + if (writer != null) WriteHeader(writer); // Now write out the aliases @@ -284,7 +284,7 @@ protected override void EndProcessing() line = GetAliasLine(alias, "set-alias -Name:\"{0}\" -Value:\"{1}\" -Description:\"{2}\" -Option:\"{3}\""); } - if (null != writer) + if (writer != null) writer.WriteLine(line); if (PassThru) @@ -295,10 +295,10 @@ protected override void EndProcessing() } finally { - if (null != writer) + if (writer != null) writer.Dispose(); // reset the read-only attribute - if (null != readOnlyFileInfo) + if (readOnlyFileInfo != null) readOnlyFileInfo.Attributes |= FileAttributes.ReadOnly; } } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs index 395eaee2040..a02cf72f71a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs @@ -33,7 +33,7 @@ internal override Object GetValue(PSObject liveObject) // The live object has the liveObjectPropertyName property. Object liveObjectValue = propertyInfo.Value; ICollection collectionValue = liveObjectValue as ICollection; - if (null != collectionValue) + if (collectionValue != null) { liveObjectValue = _parentCmdlet.ConvertToString(PSObjectHelper.AsPSObject(propertyInfo.Value)); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs index f828d1324de..acc7c41f459 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs @@ -233,7 +233,7 @@ private List GetActiveTableRowDefinition(TableControlBod if (matchingRowDefinition == null) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { match = new TypeMatch(_expressionFactory, _typeInfoDatabase, typesWithoutPrefix); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs index 3ff84d55de9..276ea74dc5c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs @@ -285,7 +285,7 @@ private void CleanUp() } // reset the read-only attribute - if (null != _readOnlyFileInfo) + if (_readOnlyFileInfo != null) { _readOnlyFileInfo.Attributes |= FileAttributes.ReadOnly; _readOnlyFileInfo = null; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs index 6806d930bec..3e68a9d9af9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs @@ -230,7 +230,7 @@ protected override void ProcessRecord() if (!Force) { PSMethod memberAsPSMethod = member as PSMethod; - if ((null != memberAsPSMethod) && (memberAsPSMethod.IsSpecial)) + if ((memberAsPSMethod != null) && (memberAsPSMethod.IsSpecial)) { continue; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs index 62bebc4d212..229ed959dd9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs @@ -884,11 +884,11 @@ private MeasureInfo CreateGenericMeasureInfo(Statistics stat, bool shouldUseGene gmi.Sum = sum; gmi.Average = average; gmi.StandardDeviation = StandardDeviation; - if (null != max) + if (max != null) { gmi.Maximum = (double)max; } - if (null != min) + if (min != null) { gmi.Minimum = (double)min; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs index 69b251b627f..7ba656a2607 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs @@ -166,7 +166,7 @@ private bool TryConvertToXml(string xml, out object doc, ref Exception exRef) exRef = ex; doc = null; } - return (null != doc); + return (doc != null); } private bool TryConvertToJson(string json, out object obj, ref Exception exRef) @@ -179,7 +179,7 @@ private bool TryConvertToJson(string json, out object obj, ref Exception exRef) if (null == obj) { - // This ensures that a null returned by ConvertFromJson() is the actual JSON null literal. + // This ensures that a null returned by ConvertFromJson() is the actual JSON null literal. // if not, the ArgumentException will be caught. JToken.Parse(json); } 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 e3e83260a94..ce13916ae3c 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 @@ -306,7 +306,7 @@ public virtual string CustomMethod public virtual object Body { get; set; } /// - /// Dictionary for use with RFC-7578 multipart/form-data submissions. + /// Dictionary for use with RFC-7578 multipart/form-data submissions. /// Keys are form fields and their respective values are form values. /// A value may be a collection of form values or single form value. /// @@ -369,7 +369,7 @@ public virtual string CustomMethod internal virtual void ValidateParameters() { // sessions - if ((null != WebSession) && (null != SessionVariable)) + if ((WebSession != null) && (SessionVariable != null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.SessionConflict, "WebCmdletSessionConflictException"); @@ -383,7 +383,7 @@ internal virtual void ValidateParameters() "WebCmdletAuthenticationConflictException"); ThrowTerminatingError(error); } - if ((Authentication != WebAuthenticationType.None) && (null != Token) && (null != Credential)) + if ((Authentication != WebAuthenticationType.None) && (Token != null) && (Credential != null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.AuthenticationTokenConflict, "WebCmdletAuthenticationTokenConflictException"); @@ -415,7 +415,7 @@ internal virtual void ValidateParameters() } // credentials - if (UseDefaultCredentials && (null != Credential)) + if (UseDefaultCredentials && (Credential != null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.CredentialConflict, "WebCmdletCredentialConflictException"); @@ -423,13 +423,13 @@ internal virtual void ValidateParameters() } // Proxy server - if (ProxyUseDefaultCredentials && (null != ProxyCredential)) + if (ProxyUseDefaultCredentials && (ProxyCredential != null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.ProxyCredentialConflict, "WebCmdletProxyCredentialConflictException"); ThrowTerminatingError(error); } - else if ((null == Proxy) && ((null != ProxyCredential) || ProxyUseDefaultCredentials)) + else if ((null == Proxy) && ((ProxyCredential != null) || ProxyUseDefaultCredentials)) { ErrorRecord error = GetValidationError(WebCmdletStrings.ProxyUriNotSupplied, "WebCmdletProxyUriNotSuppliedException"); @@ -437,19 +437,19 @@ internal virtual void ValidateParameters() } // request body content - if ((null != Body) && (null != InFile)) + if ((Body != null) && (InFile != null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.BodyConflict, "WebCmdletBodyConflictException"); ThrowTerminatingError(error); } - if ((null != Body) && (null != Form)) + if ((Body != null) && (Form != null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.BodyFormConflict, "WebCmdletBodyFormConflictException"); ThrowTerminatingError(error); } - if ((null != InFile) && (null != Form)) + if ((InFile != null) && (Form != null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.FormInFileConflict, "WebCmdletFormInFileConflictException"); @@ -539,7 +539,7 @@ internal virtual void PrepareSession() WebSession = new WebRequestSession(); } - if (null != SessionVariable) + if (SessionVariable != null) { // save the session back to the PS environment if requested PSVariableIntrinsics vi = SessionState.PSVariable; @@ -567,7 +567,7 @@ internal virtual void PrepareSession() WebSession.UseDefaultCredentials = true; } - if (null != CertificateThumbprint) + if (CertificateThumbprint != null) { X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); @@ -585,7 +585,7 @@ internal virtual void PrepareSession() } } - if (null != Certificate) + if (Certificate != null) { WebSession.AddCertificate(Certificate); } @@ -593,17 +593,17 @@ internal virtual void PrepareSession() // // handle the user agent // - if (null != UserAgent) + if (UserAgent != null) { // store the UserAgent string WebSession.UserAgent = UserAgent; } - if (null != Proxy) + if (Proxy != null) { WebProxy webProxy = new WebProxy(Proxy); webProxy.BypassProxyOnLocal = false; - if (null != ProxyCredential) + if (ProxyCredential != null) { webProxy.Credentials = ProxyCredential.GetNetworkCredential(); } @@ -622,7 +622,7 @@ internal virtual void PrepareSession() } // store the other supplied headers - if (null != Headers) + if (Headers != null) { foreach (string key in Headers.Keys) { @@ -671,7 +671,7 @@ private Uri PrepareUri(Uri uri) // preprocess Body if content is a dictionary and method is GET (set as query) IDictionary bodyAsDictionary; LanguagePrimitives.TryConvertTo(Body, out bodyAsDictionary); - if ((null != bodyAsDictionary) + if ((bodyAsDictionary != null) && ((IsStandardMethodSet() && (Method == WebRequestMethod.Default || Method == WebRequestMethod.Get)) || (IsCustomMethodSet() && CustomMethod.ToUpperInvariant() == "GET"))) { @@ -727,7 +727,7 @@ private string FormatDictionary(IDictionary content) // URLEncode the key and value string encodedKey = WebUtility.UrlEncode(key); string encodedValue = String.Empty; - if (null != value) + if (value != null) { encodedValue = WebUtility.UrlEncode(value.ToString()); } @@ -1132,7 +1132,7 @@ internal virtual void FillRequestStream(HttpRequestMessage request) } } - if (null != Form) + if (Form != null) { // Content headers will be set by MultipartFormDataContent which will throw unless we clear them first WebSession.ContentHeaders.Clear(); @@ -1310,8 +1310,8 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM // Request again without the Range header because the server indicated the range was not satisfiable. // This happens when the local file is larger than the remote file. // If the size of the remote file is the same as the local file, there is nothing to resume. - if (Resume.IsPresent && - response.StatusCode == HttpStatusCode.RequestedRangeNotSatisfiable && + if (Resume.IsPresent && + response.StatusCode == HttpStatusCode.RequestedRangeNotSatisfiable && (response.Content.Headers.ContentRange.HasLength && response.Content.Headers.ContentRange.Length != _resumeFileSize)) { @@ -1419,8 +1419,8 @@ protected override void ProcessRecord() // Check if the Resume range was not satisfiable because the file already completed downloading. // This happens when the local file is the same size as the remote file. if (Resume.IsPresent && - response.StatusCode == HttpStatusCode.RequestedRangeNotSatisfiable && - response.Content.Headers.ContentRange.HasLength && + response.StatusCode == HttpStatusCode.RequestedRangeNotSatisfiable && + response.Content.Headers.ContentRange.HasLength && response.Content.Headers.ContentRange.Length == _resumeFileSize) { _isSuccess = true; @@ -1779,7 +1779,7 @@ private void AddMultipartContent(object fieldName, object fieldValue, MultipartF return; } - // Treat Strings and other single values as a StringContent. + // 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)) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs index e819f246f2d..686c26331cc 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs @@ -184,7 +184,7 @@ private void SetResponse(HttpResponseMessage response, Stream contentStream) BaseResponse = response; MemoryStream ms = contentStream as MemoryStream; - if (null != ms) + if (ms != null) { _rawContentStream = ms; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs index 5c60c4058a1..0164141d737 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs @@ -237,7 +237,7 @@ private void Initialize() ProgressRecord record = new ProgressRecord(StreamHelper.ActivityId, WebCmdletStrings.ReadResponseProgressActivity, "statusDescriptionPlaceholder"); for (int read = 1; 0 < read; totalLength += read) { - if (null != _ownerCmdlet) + if (_ownerCmdlet != null) { record.StatusDescription = StringUtil.Format(WebCmdletStrings.ReadResponseProgressStatus, totalLength); _ownerCmdlet.WriteProgress(record); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs index 9111f527418..fed18cd94e0 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs @@ -143,7 +143,7 @@ protected override void ProcessRecord() { - if (null != _serializer) + if (_serializer != null) { _serializer.Serialize(InputObject); _xw.Flush(); @@ -442,10 +442,10 @@ protected override void ProcessRecord() { CreateMemoryStream(); - if (null != _serializer) + if (_serializer != null) _serializer.SerializeAsStream(InputObject); - if (null != _serializer) + if (_serializer != null) { _serializer.DoneAsStream(); _serializer = null; @@ -461,7 +461,7 @@ protected override void ProcessRecord() } else { - if (null != _serializer) + if (_serializer != null) _serializer.Serialize(InputObject); } } @@ -471,7 +471,7 @@ protected override void ProcessRecord() /// protected override void EndProcessing() { - if (null != _serializer) + if (_serializer != null) { _serializer.Done(); _serializer = null; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs index 68b5cd89abf..c864449bdcb 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs @@ -177,7 +177,7 @@ private void Process(OrderByPropertyEntry differenceEntry) // Clear differenceEntry OrderByPropertyEntry matchingEntry = MatchAndRemove(differenceEntry, _referenceEntryBacklog); - if (null != matchingEntry) + if (matchingEntry != null) { EmitMatch(matchingEntry); differenceEntry = null; @@ -189,7 +189,7 @@ private void Process(OrderByPropertyEntry differenceEntry) // Clear referenceEntry matchingEntry = MatchAndRemove(referenceEntry, _differenceEntryBacklog); - if (null != matchingEntry) + if (matchingEntry != null) { EmitMatch(referenceEntry); referenceEntry = null; @@ -203,7 +203,7 @@ private void Process(OrderByPropertyEntry differenceEntry) // Emit oldest entry in differenceEntryBacklog as unmatched // Remove oldest entry from differenceEntryBacklog // Add differenceEntry to differenceEntryBacklog - if (null != differenceEntry) + if (differenceEntry != null) { if (0 < SyncWindow) { @@ -228,7 +228,7 @@ private void Process(OrderByPropertyEntry differenceEntry) // Emit oldest entry in referenceEntryBacklog as unmatched // Remove oldest entry from referenceEntryBacklog // Add referenceEntry to referenceEntryBacklog - if (null != referenceEntry) + if (referenceEntry != null) { if (0 < SyncWindow) { @@ -248,7 +248,7 @@ private void Process(OrderByPropertyEntry differenceEntry) private void InitComparer() { - if (null != _comparer) + if (_comparer != null) return; List referenceObjectList = new List(ReferenceObject); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs index 4717ff4db7e..489e5d768c3 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs @@ -312,7 +312,7 @@ public class WriteOrThrowErrorCommand : PSCmdlet protected override void ProcessRecord() { ErrorRecord errorRecord = this.ErrorRecord; - if (null != errorRecord) + if (errorRecord != null) { // copy constructor errorRecord = new ErrorRecord(errorRecord, null); @@ -374,7 +374,7 @@ protected override void ProcessRecord() // 2005/07/14-913791 "write-error output is confusing and misleading" // set InvocationInfo to the script not the command InvocationInfo myInvocation = GetVariableValue(SpecialVariables.MyInvocation) as InvocationInfo; - if (null != myInvocation) + if (myInvocation != null) { errorRecord.SetInvocationInfo(myInvocation); errorRecord.PreserveInvocationInfoOnce = true; diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs index 719d489904c..3883c4b679c 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs @@ -197,7 +197,7 @@ public Collection PromptForChoice(string caption, Dictionary defaultChoiceKeys = new Dictionary(); - if (null != defaultChoices) + if (defaultChoices != null) { foreach (int defaultChoice in defaultChoices) { diff --git a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/AddLocalGroupMemberCommand.cs b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/AddLocalGroupMemberCommand.cs index 70b2e9f18cc..93daf95694c 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/AddLocalGroupMemberCommand.cs +++ b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/AddLocalGroupMemberCommand.cs @@ -243,10 +243,10 @@ private void ProcessGroup(LocalGroup group) foreach (var member in this.Member) { LocalPrincipal principal = MakePrincipal(groupId, member); - if (null != principal) + if (principal != null) { var ex = sam.AddLocalGroupMember(group, principal); - if (null != ex) + if (ex != null) { WriteError(ex.MakeErrorRecord()); } @@ -277,10 +277,10 @@ private void ProcessSid(SecurityIdentifier groupSid) foreach (var member in this.Member) { LocalPrincipal principal = MakePrincipal(groupSid.ToString(), member); - if (null != principal) + if (principal != null) { var ex = sam.AddLocalGroupMember(groupSid, principal); - if (null != ex) + if (ex != null) { WriteError(ex.MakeErrorRecord()); } diff --git a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/RemoveLocalGroupMemberCommand.cs b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/RemoveLocalGroupMemberCommand.cs index 26c5914fafb..d18d61f8698 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/RemoveLocalGroupMemberCommand.cs +++ b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Commands/RemoveLocalGroupMemberCommand.cs @@ -243,10 +243,10 @@ private void ProcessGroup(LocalGroup group) foreach (var member in this.Member) { LocalPrincipal principal = MakePrincipal(groupId, member); - if (null != principal) + if (principal != null) { var ex = sam.RemoveLocalGroupMember(group, principal); - if (null != ex) + if (ex != null) { WriteError(ex.MakeErrorRecord()); } @@ -277,10 +277,10 @@ private void ProcessSid(SecurityIdentifier groupSid) foreach (var member in this.Member) { LocalPrincipal principal = MakePrincipal(groupSid.ToString(), member); - if (null != principal) + if (principal != null) { var ex = sam.RemoveLocalGroupMember(groupSid, principal); - if (null != ex) + if (ex != null) { WriteError(ex.MakeErrorRecord()); } diff --git a/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs b/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs index b7a3e1cb856..0c2c579e114 100644 --- a/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs @@ -562,7 +562,7 @@ protected override Signature PerformAction(string filePath) finally { // reset the read-only attribute - if (null != readOnlyFileInfo) + if (readOnlyFileInfo != null) { readOnlyFileInfo.Attributes |= FileAttributes.ReadOnly; } diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index c4d01b9e3bc..d304e12a30c 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -744,7 +744,7 @@ protected override void GetItem(string path) } else if (path.EndsWith(host + WSManStringLiterals.DefaultPathSeparator + WSManStringLiterals.containerPlugin + WSManStringLiterals.DefaultPathSeparator + currentpluginname + WSManStringLiterals.DefaultPathSeparator + WSManStringLiterals.containerInitParameters, StringComparison.OrdinalIgnoreCase)) { - if (null != arrInitParams) + if (arrInitParams != null) { foreach (PSObject p in arrInitParams) { @@ -3099,7 +3099,7 @@ private PSObject BuildHostLevelPSObjectArrayList(object objSessionObject, string } else { - if (null != objSessionObject) + if (objSessionObject != null) { XmlDocument ConfigXml = GetResourceValue(objSessionObject, uri, null); //Moving in to @@ -3822,7 +3822,7 @@ private bool CheckValidContainerOrPath(string path) { return true; } - if (null != arrResources) + if (arrResources != null) { strpathChk = strpathChk + WSManStringLiterals.DefaultPathSeparator + WSManStringLiterals.containerResources; foreach (PSObject objresource in arrResources) @@ -3882,7 +3882,7 @@ private bool CheckValidContainerOrPath(string path) } else { - if (null != arrInitParams) + if (arrInitParams != null) { foreach (PSObject obj in arrInitParams) { @@ -4198,7 +4198,7 @@ private void GetChildItemsOrNames(string path, ProviderMethods methodname, bool strPathchk = strPathchk + currentpluginname + WSManStringLiterals.DefaultPathSeparator; if (path.EndsWith(strPathchk + WSManStringLiterals.containerResources, StringComparison.OrdinalIgnoreCase)) { - if (null != arrResources) + if (arrResources != null) { foreach (PSObject p in arrResources) { @@ -4263,7 +4263,7 @@ private void GetChildItemsOrNames(string path, ProviderMethods methodname, bool strPathchk = strPathchk + sResourceDirName + WSManStringLiterals.DefaultPathSeparator; if (path.EndsWith(strPathchk + WSManStringLiterals.containerSecurity, StringComparison.OrdinalIgnoreCase) || path.Contains(WSManStringLiterals.DefaultPathSeparator + WSManStringLiterals.containerSecurity + "_")) { - if (null != arrSecurity) + if (arrSecurity != null) { foreach (PSObject objsecurity in arrSecurity) { @@ -4679,7 +4679,7 @@ private PSObject ProcessPluginConfigurationLevel(XmlDocument xmldoc, bool setRun { PSObject objConfiglvl = null; - if (null != xmldoc) + if (xmldoc != null) { XmlNodeList nodelistPlugin = xmldoc.GetElementsByTagName("PlugInConfiguration"); if (nodelistPlugin.Count > 0) @@ -4720,7 +4720,7 @@ private ArrayList ProcessPluginResourceLevel(XmlDocument xmldoc, out ArrayList a { ArrayList Resources = null; ArrayList nSecurity = null; - if (null != xmldoc) + if (xmldoc != null) { XmlNodeList xmlpluginResource = xmldoc.GetElementsByTagName("Resource"); if (xmlpluginResource.Count > 0) @@ -4800,7 +4800,7 @@ private ArrayList ProcessPluginResourceLevel(XmlDocument xmldoc, out ArrayList a private ArrayList ProcessPluginInitParamLevel(XmlDocument xmldoc) { ArrayList InitParamLvl = null; - if (null != xmldoc) + if (xmldoc != null) { XmlNodeList nodelistInitParam = xmldoc.GetElementsByTagName("Param"); if (nodelistInitParam.Count > 0) diff --git a/src/Microsoft.WSMan.Management/WsManHelper.cs b/src/Microsoft.WSMan.Management/WsManHelper.cs index 45e906510dc..298626023c5 100644 --- a/src/Microsoft.WSMan.Management/WsManHelper.cs +++ b/src/Microsoft.WSMan.Management/WsManHelper.cs @@ -190,7 +190,7 @@ static private string FormatResourceMsgFromResourcetextS( string template = resourceManager.GetString(resourceName); string result = null; - if (null != template) + if (template != null) { result = String.Format(CultureInfo.CurrentCulture, template, args); diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index 7d5dee725e6..543645b4c56 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -227,7 +227,7 @@ internal static void RemoveTemporaryDirectory() /// internal static string GetTemporaryDirectory() { - if (null != _tempDirectory) + if (_tempDirectory != null) { return _tempDirectory; } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs index de48f5e09fa..63803b15134 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs @@ -118,7 +118,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); // If there are simple fields, serialize them with info.AddValue - if (null != _errors) + if (_errors != null) { int errorCount = _errors.Count; info.AddValue("ErrorCount", errorCount); diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs index 146da136c3e..eec2379bf69 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs @@ -32,7 +32,7 @@ internal override ControlBase Copy() { ListControlBody result = new ListControlBody(); result.autosize = this.autosize; - if (null != defaultEntryDefinition) + if (defaultEntryDefinition != null) { result.defaultEntryDefinition = this.defaultEntryDefinition.Copy(); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs index c0dcee30016..13be4995d45 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs @@ -53,7 +53,7 @@ internal override ControlBase Copy() autosize = this.autosize, header = this.header.Copy() }; - if (null != defaultDefinition) + if (defaultDefinition != null) { result.defaultDefinition = this.defaultDefinition.Copy(); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs index f5127d028f2..ad84089fc46 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs @@ -281,7 +281,7 @@ internal static EnumerableExpansion GetEnumerableExpansionFromType(MshExpression else { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { EnumerableExpansion result = GetEnumerableExpansionFromType(expressionFactory, db, typesWithoutPrefix); return result; @@ -311,7 +311,7 @@ internal static FormatShape GetShapeFromType(MshExpressionFactory expressionFact else { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { FormatShape result = GetShapeFromType(expressionFactory, db, typesWithoutPrefix); return result; @@ -385,7 +385,7 @@ internal static ViewDefinition GetOutOfBandView(MshExpressionFactory expressionF if (null == result) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { result = GetOutOfBandView(expressionFactory, db, typesWithoutPrefix); } @@ -457,7 +457,7 @@ private static ViewDefinition GetView(MshExpressionFactory expressionFactory, Ty if (null == result) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { result = GetView(expressionFactory, db, mainControlType, typesWithoutPrefix, viewName); } @@ -547,7 +547,7 @@ private static ViewDefinition GetDefaultView(MshExpressionFactory expressionFact if (null == result) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { result = GetDefaultView(expressionFactory, db, typesWithoutPrefix); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs index b6e0e0936f3..c286ba23166 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs @@ -296,7 +296,7 @@ internal bool IsObjectApplicable(Collection typeNames) if (false == result) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { result = IsObjectApplicable(typesWithoutPrefix); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs index 2b0e7a96171..bafff549c54 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs @@ -161,7 +161,7 @@ private ComplexControlEntryDefinition GetActiveComplexControlEntryDefinition(Com else { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { match = new TypeMatch(_expressionFactory, _db, typesWithoutPrefix); foreach (ComplexControlEntryDefinition x in complexBody.optionalEntryList) diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs index 04f3a0fe06d..69d7286e6a2 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs @@ -154,7 +154,7 @@ private ListControlEntryDefinition GetActiveListControlEntryDefinition(ListContr else { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix); foreach (ListControlEntryDefinition x in listBody.optionalEntryList) diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs index bc502f3a43e..b00aa6fc939 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs @@ -377,7 +377,7 @@ private List GetActiveTableRowDefinition(TableControlBod if (matchingRowDefinition == null) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix); diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Wide.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Wide.cs index 5f3af4cb9b1..964ca497b7a 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Wide.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Wide.cs @@ -105,7 +105,7 @@ private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideContr else { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null != typesWithoutPrefix) + if (typesWithoutPrefix != null) { match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix); foreach (WideControlEntryDefinition x in wideBody.optionalEntryList) diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs index fdc09b81754..b006a0dffec 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs @@ -453,10 +453,10 @@ private static PSMemberSet MaskDeserializedAndGetStandardMembers(PSObject so) private static List GetDefaultPropertySet(PSMemberSet standardMembersSet) { - if (null != standardMembersSet) + if (standardMembersSet != null) { PSPropertySet defaultDisplayPropertySet = standardMembersSet.Members[TypeTable.DefaultDisplayPropertySet] as PSPropertySet; - if (null != defaultDisplayPropertySet) + if (defaultDisplayPropertySet != null) { List retVal = new List(); foreach (string prop in defaultDisplayPropertySet.ReferencedPropertyNames) @@ -491,10 +491,10 @@ internal static List GetDefaultPropertySet(PSObject so) private static MshExpression GetDefaultNameExpression(PSMemberSet standardMembersSet) { - if (null != standardMembersSet) + if (standardMembersSet != null) { PSNoteProperty defaultDisplayProperty = standardMembersSet.Members[TypeTable.DefaultDisplayProperty] as PSNoteProperty; - if (null != defaultDisplayProperty) + if (defaultDisplayProperty != null) { string expressionString = defaultDisplayProperty.Value.ToString(); if (string.IsNullOrEmpty(expressionString)) @@ -564,7 +564,7 @@ internal static string GetExpressionDisplayValue( internal static bool ShouldShowComputerNameProperty(PSObject so) { bool result = false; - if (null != so) + if (so != null) { try { @@ -573,7 +573,7 @@ internal static bool ShouldShowComputerNameProperty(PSObject so) // if computer name property exists then this must be a remote object. see // if it can be displayed. - if ((null != computerNameProperty) && (null != showComputerNameProperty)) + if ((computerNameProperty != null) && (showComputerNameProperty != null)) { LanguagePrimitives.TryConvertTo(showComputerNameProperty.Value, out result); } diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs index 7302b72c52a..72f7e10c9e5 100644 --- a/src/System.Management.Automation/engine/CommandProcessor.cs +++ b/src/System.Management.Automation/engine/CommandProcessor.cs @@ -724,7 +724,7 @@ private void Init(CmdletInfo cmdletInformation) throw commandException; } - if (null != initError) + if (initError != null) { // Log a command health event MshLog.LogCommandHealthEvent( diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs index a2219ace10c..cceeed2aa1a 100644 --- a/src/System.Management.Automation/engine/CommandProcessorBase.cs +++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs @@ -648,7 +648,7 @@ internal void DoComplete() /// public override string ToString() { - if (null != CommandInfo) + if (CommandInfo != null) return CommandInfo.ToString(); return ""; // does not require localization } @@ -750,7 +750,7 @@ internal PipelineStoppedException ManageInvocationException(Exception e) { try { - if (null != Command) + if (Command != null) { do // false loop { @@ -930,7 +930,7 @@ private void Dispose(bool disposing) // whether IDisposable is implemented, in order to avoid // this expensive reflection cast. IDisposable id = Command as IDisposable; - if (null != id) + if (id != null) { id.Dispose(); } diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs index 6a306f5608d..c42c14fb14b 100644 --- a/src/System.Management.Automation/engine/CoreAdapter.cs +++ b/src/System.Management.Automation/engine/CoreAdapter.cs @@ -1396,7 +1396,7 @@ private static MethodInformation FindBestMethodImpl( } } - if (null != candidate) + if (candidate != null) { candidate.expandedParameters = ExpandParameters(arguments.Length, parameters, elementType); } @@ -4227,7 +4227,7 @@ protected override PSMemberInfoInternalCollection GetMembers(object obj) protected override T GetMember(object obj, string memberName) { PSProperty property = base.GetDotNetProperty(obj, memberName); - if (typeof(T).IsAssignableFrom(typeof(PSProperty)) && (null != property)) + if (typeof(T).IsAssignableFrom(typeof(PSProperty)) && (property != null)) { return property as T; } diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index b108a459c18..5fa0b90a615 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -1354,7 +1354,7 @@ private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord) _invocationInfo = new InvocationInfo(serializedErrorRecord); ArrayList iterationInfo = RemotingDecoder.GetPropertyValue(serializedErrorRecord, "PipelineIterationInfo"); - if (null != iterationInfo) + if (iterationInfo != null) { _pipelineIterationInfo = new ReadOnlyCollection((int[])iterationInfo.ToArray(typeof(Int32))); } @@ -1686,7 +1686,7 @@ public override string ToString() { return ErrorDetails.Message; } - if (null != Exception) + if (Exception != null) { if (!String.IsNullOrEmpty(Exception.Message)) { diff --git a/src/System.Management.Automation/engine/ExtraAdapter.cs b/src/System.Management.Automation/engine/ExtraAdapter.cs index a53f73545f3..9b92a533443 100644 --- a/src/System.Management.Automation/engine/ExtraAdapter.cs +++ b/src/System.Management.Automation/engine/ExtraAdapter.cs @@ -62,7 +62,7 @@ protected override T GetMember(object obj, string memberName) object invokeGetValue = entry.InvokeGet(memberName); // if entry.Properties[memberName] returns empty value and invokeGet non-empty // value..take invokeGet's value. This will fix bug Windows Bug 121188. - if ((null == collection) || ((null == collection.Value) && (null != invokeGetValue))) + if ((null == collection) || ((null == collection.Value) && (invokeGetValue != null))) { valueToTake = invokeGetValue; } @@ -187,7 +187,7 @@ protected override void PropertySet(PSProperty property, object setValue, bool c { PropertyValueCollection values = property.adapterData as PropertyValueCollection; - if (null != values) + if (values != null) { // This means GetMember returned PropertyValueCollection try @@ -348,7 +348,7 @@ protected override object MethodInvoke(PSMethod method, object[] arguments) // this code is reached only on exception // check if there is a dotnet method, invoke the dotnet method if available PSMethod dotNetmethod = s_dotNetAdapter.GetDotNetMethod(method.baseObject, method.name); - if (null != dotNetmethod) + if (dotNetmethod != null) { return dotNetmethod.Invoke(arguments); } diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs index 7796a665f48..ccdbc764eb5 100644 --- a/src/System.Management.Automation/engine/GetCommandCommand.cs +++ b/src/System.Management.Automation/engine/GetCommandCommand.cs @@ -468,7 +468,7 @@ protected override void EndProcessing() OutputResultsHelper(_accumulatedResults); object pssenderInfo = Context.GetVariableValue(SpecialVariables.PSSenderInfoVarPath); - if ((null != pssenderInfo) && (pssenderInfo is System.Management.Automation.Remoting.PSSenderInfo)) + if ((pssenderInfo != null) && (pssenderInfo is System.Management.Automation.Remoting.PSSenderInfo)) { // Win8: 593295. Exchange has around 1000 cmdlets. During Import-PSSession, // Get-Command | select-object ..,HelpURI,... is run. HelpURI is a script property diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 27b11fd1a62..a4471a87cb7 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -2846,14 +2846,14 @@ private RunspaceOpenModuleLoadException ProcessImportModule(Runspace initialized foreach (object module in moduleList) { string moduleName = module as string; - if (null != moduleName) + if (moduleName != null) { exceptionToReturn = ProcessImportModule(initializedRunspace, moduleName, null, path, publicCommands); } else { ModuleSpecification moduleSpecification = module as ModuleSpecification; - if (null != moduleSpecification) + if (moduleSpecification != null) { if ((moduleSpecification.RequiredVersion == null) && (moduleSpecification.Version == null) && (moduleSpecification.MaximumVersion == null) && (moduleSpecification.Guid == null)) { @@ -3014,7 +3014,7 @@ private RunspaceOpenModuleLoadException ProcessImportModule(Runspace initialized { CommandInfo c = new CmdletInfo("Import-Module", typeof(ImportModuleCommand), null, null, initializedRunspace.ExecutionContext); Command cmd = new Command(c); - if (null != moduleInfoToLoad) + if (moduleInfoToLoad != null) { cmd.Parameters.Add("ModuleInfo", moduleInfoToLoad); name = moduleInfoToLoad.Name; @@ -3112,7 +3112,7 @@ private RunspaceOpenModuleLoadException ValidateAndReturnRunspaceOpenModuleLoadE rome = new RunspaceOpenModuleLoadException(moduleName, mergedErrors); } - if (null != rome) + if (rome != null) { return rome; } @@ -3672,7 +3672,7 @@ public PSSnapInInfo ImportPSSnapIn(string name, out PSSnapInException warning) // Now actually load the snapin... PSSnapInInfo snapin = ImportPSSnapIn(newPSSnapIn, out warning); - if (null != snapin) + if (snapin != null) { ImportedSnapins.Add(snapin.Name, snapin); } diff --git a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs index 15518567e32..95c0c7fd71a 100644 --- a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs +++ b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs @@ -97,13 +97,13 @@ private IEnumerable GetTypeNameHierarchyFromDerivation(ManagementBaseObj // the immediate parent class, the next is its parent, and so on; the last element // is the base class. PropertyData derivationData = managementObj.SystemProperties["__Derivation"]; - if (null != derivationData) + if (derivationData != null) { Dbg.Assert(derivationData.IsArray, "__Derivation must be a string array as per MSDN documentation"); // give the typenames based on NameSpace + __Derivation string[] typeHierarchy = PropertySetAndMethodArgumentConvertTo(derivationData.Value, typeof(string[]), CultureInfo.InvariantCulture) as string[]; - if (null != typeHierarchy) + if (typeHierarchy != null) { foreach (string t in typeHierarchy) { @@ -486,7 +486,7 @@ private static void PopulateMethodTable(ManagementClass mgmtClass, CacheTable me { Dbg.Assert(null != mgmtClass, "ManagementClass cannot be null in this method"); MethodDataCollection mgmtMethods = mgmtClass.Methods; - if (null != mgmtMethods) + if (mgmtMethods != null) { ManagementPath classPath = mgmtClass.ClassPath; // new operation will never fail @@ -525,7 +525,7 @@ private static ManagementClass CreateClassFrmObject(ManagementBaseObject mgmtBas // inherit ManagementObject properties ManagementObject mgmtObject = mgmtBaseObject as ManagementObject; - if (null != mgmtObject) + if (mgmtObject != null) { mgmtClass.Scope = mgmtObject.Scope; mgmtClass.Options = mgmtObject.Options; diff --git a/src/System.Management.Automation/engine/MergedCommandParameterMetadata.cs b/src/System.Management.Automation/engine/MergedCommandParameterMetadata.cs index be186a12a35..4fbae752d73 100644 --- a/src/System.Management.Automation/engine/MergedCommandParameterMetadata.cs +++ b/src/System.Management.Automation/engine/MergedCommandParameterMetadata.cs @@ -413,10 +413,10 @@ private static string RetrieveParameterNameForAlias( IDictionary dict) { MergedCompiledCommandParameter mergedParam = dict[key]; - if (null != mergedParam) + if (mergedParam != null) { CompiledCommandParameter compiledParam = mergedParam.Parameter; - if (null != compiledParam) + if (compiledParam != null) { if (!String.IsNullOrEmpty(compiledParam.Name)) return compiledParam.Name; diff --git a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs index 4903fabed6e..7694b7eaad2 100644 --- a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs +++ b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs @@ -1729,7 +1729,7 @@ protected override void ProcessRecord() foreach (string name in Name) { PSModuleInfo foundModule = ImportModule_LocallyViaName(importModuleOptions, name); - if (null != foundModule) + if (foundModule != null) { SetModuleBaseForEngineModules(foundModule.Name, this.Context); @@ -1757,7 +1757,7 @@ protected override void ProcessRecord() BaseGuid = modulespec.Guid; PSModuleInfo foundModule = ImportModule_LocallyViaName(importModuleOptions, modulespec.Name); - if (null != foundModule) + if (foundModule != null) { SetModuleBaseForEngineModules(foundModule.Name, this.Context); } diff --git a/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs b/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs index 3f73906a0d3..92fa6ff3fbb 100644 --- a/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs +++ b/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs @@ -567,7 +567,7 @@ private string QuoteNames(IEnumerable names, StreamWriter streamWriter) /// private IEnumerable PreProcessModuleSpec(IEnumerable moduleSpecs) { - if (null != moduleSpecs) + if (moduleSpecs != null) { foreach (object spec in moduleSpecs) { diff --git a/src/System.Management.Automation/engine/MshCmdlet.cs b/src/System.Management.Automation/engine/MshCmdlet.cs index 74bac7b7ed6..735824941c6 100644 --- a/src/System.Management.Automation/engine/MshCmdlet.cs +++ b/src/System.Management.Automation/engine/MshCmdlet.cs @@ -277,7 +277,7 @@ public bool HasErrors /// public string ExpandString(string source) { - if (null != _cmdlet) + if (_cmdlet != null) _cmdlet.ThrowIfStopping(); return _context.Engine.Expand(source); } @@ -787,7 +787,7 @@ public Collection InvokeScript(string script, bool useNewScope, private Collection InvokeScript(ScriptBlock sb, bool useNewScope, PipelineResultTypes writeToPipeline, IList input, params object[] args) { - if (null != _cmdlet) + if (_cmdlet != null) _cmdlet.ThrowIfStopping(); Cmdlet cmdletToUse = null; @@ -879,7 +879,7 @@ private Collection InvokeScript(ScriptBlock sb, bool useNewScope, /// public ScriptBlock NewScriptBlock(string scriptText) { - if (null != _commandRuntime) + if (_commandRuntime != null) _commandRuntime.ThrowIfStopping(); ScriptBlock result = ScriptBlock.Create(_context, scriptText); diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 90ddd5927a3..48bdb2d799b 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -112,7 +112,7 @@ internal MshCommandRuntime(ExecutionContext context, CommandInfo commandInfo, In /// public override string ToString() { - if (null != _commandInfo) + if (_commandInfo != null) return _commandInfo.ToString(); return ""; // does not require localization } @@ -2331,7 +2331,7 @@ public Exception ManageException(Exception e) if (null == e) throw PSTraceSource.NewArgumentNullException("e"); - if (null != PipelineProcessor) + if (PipelineProcessor != null) { PipelineProcessor.RecordFailure(e, _thisCommand); } @@ -2508,7 +2508,7 @@ internal void SetupVariable(VariableStreamKind streamKind, string variableName, if (null != oldValue && AutomationNull.Value != oldValue) { IEnumerable enumerable = LanguagePrimitives.GetEnumerable(oldValue); - if (null != enumerable) + if (enumerable != null) { foreach (object o in enumerable) { diff --git a/src/System.Management.Automation/engine/MshObject.cs b/src/System.Management.Automation/engine/MshObject.cs index f786edd6e5c..e128098d2a0 100644 --- a/src/System.Management.Automation/engine/MshObject.cs +++ b/src/System.Management.Automation/engine/MshObject.cs @@ -1851,7 +1851,7 @@ internal int GetSerializationDepth(TypeTable backupTypeTable) int result = 0; TypeTable typeTable = backupTypeTable ?? this.GetTypeTable(); - if (null != typeTable) + if (typeTable != null) { PSMemberSet standardMemberSet = TypeTableGetMemberDelegate(this, typeTable, TypeTable.PSStandardMembers); @@ -1888,7 +1888,7 @@ internal SerializationMethod GetSerializationMethod(TypeTable backupTypeTable) SerializationMethod result = TypeTable.defaultSerializationMethod; TypeTable typeTable = backupTypeTable ?? this.GetTypeTable(); - if (null != typeTable) + if (typeTable != null) { PSMemberSet standardMemberSet = TypeTableGetMemberDelegate(this, typeTable, TypeTable.PSStandardMembers); @@ -1927,7 +1927,7 @@ internal PSMemberInfo GetPSStandardMember(TypeTable backupTypeTable, string memb { PSMemberSet standardMemberSet = TypeTableGetMemberDelegate( this, typeTable, TypeTable.PSStandardMembers); - if (null != standardMemberSet) + if (standardMemberSet != null) { standardMemberSet.ReplicateInstance(this); PSMemberInfoIntegratingCollection members = @@ -1953,7 +1953,7 @@ internal PSMemberInfo GetPSStandardMember(TypeTable backupTypeTable, string memb internal Type GetTargetTypeForDeserialization(TypeTable backupTypeTable) { PSMemberInfo targetType = this.GetPSStandardMember(backupTypeTable, TypeTable.TargetTypeForDeserialization); - if (null != targetType) + if (targetType != null) { return (targetType.Value as Type); } @@ -1975,7 +1975,7 @@ internal Type GetTargetTypeForDeserialization(TypeTable backupTypeTable) internal Collection GetSpecificPropertiesToSerialize(TypeTable backupTypeTable) { TypeTable typeTable = backupTypeTable ?? this.GetTypeTable(); - if (null != typeTable) + if (typeTable != null) { Collection tmp = typeTable.GetSpecificProperties(this.InternalTypeNames); return tmp; diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index b7e81e363e1..bf51f267c26 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -255,7 +255,7 @@ private void ValidatePSTypeName( PSInvalidCastException e = new PSInvalidCastException(ErrorCategory.InvalidArgument.ToString(), null, ParameterBinderStrings.MismatchedPSTypeName, - (null != _invocationInfo) && (null != _invocationInfo.MyCommand) ? _invocationInfo.MyCommand.Name : string.Empty, + (_invocationInfo != null) && (null != _invocationInfo.MyCommand) ? _invocationInfo.MyCommand.Name : string.Empty, parameterMetadata.Name, parameterMetadata.Type, parameterValue.GetType(), diff --git a/src/System.Management.Automation/engine/Pipe.cs b/src/System.Management.Automation/engine/Pipe.cs index 27ee2b46415..78fbcd5469f 100644 --- a/src/System.Management.Automation/engine/Pipe.cs +++ b/src/System.Management.Automation/engine/Pipe.cs @@ -431,7 +431,7 @@ private void AddToPipe(object obj) { _resultList.Add(obj); } - else if (null != _externalWriter) + else if (_externalWriter != null) { _externalWriter.Write(obj); } @@ -502,7 +502,7 @@ internal void AddItems(object objects) } } - if (null != _externalWriter) + if (_externalWriter != null) return; // If there are objects waiting for the downstream command @@ -539,7 +539,7 @@ internal object Retrieve() return ParserOps.Current(null, _enumeratorToProcess); } - else if (null != ExternalReader) + else if (ExternalReader != null) { try { diff --git a/src/System.Management.Automation/engine/SessionState.cs b/src/System.Management.Automation/engine/SessionState.cs index 3a8074521a3..dd82ca64150 100644 --- a/src/System.Management.Automation/engine/SessionState.cs +++ b/src/System.Management.Automation/engine/SessionState.cs @@ -535,7 +535,7 @@ internal ProviderInvocationException NewProviderInvocationException( // ProviderInvocationException, and we don't want to // re-wrap it. ProviderInvocationException pie = e as ProviderInvocationException; - if (null != pie) + if (pie != null) { pie._providerInfo = provider; return pie; diff --git a/src/System.Management.Automation/engine/TypeTable.cs b/src/System.Management.Automation/engine/TypeTable.cs index 4025850d6b1..2b327c2fb7f 100644 --- a/src/System.Management.Automation/engine/TypeTable.cs +++ b/src/System.Management.Automation/engine/TypeTable.cs @@ -1613,7 +1613,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); // If there are simple fields, serialize them with info.AddValue - if (null != _errors) + if (_errors != null) { int errorCount = _errors.Count; info.AddValue("ErrorCount", errorCount); @@ -2882,7 +2882,7 @@ private static bool CheckStandardMembers(ConcurrentBag errors, string ty } else { - if (null != targetTypeForDeserialization) + if (targetTypeForDeserialization != null) { // GetCheckNote converts the value from string to System.Type.. We should store value as Type // as this will save time spent converting string to Type. diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 5b108a97978..66cdd8721f8 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -505,7 +505,7 @@ internal static bool IsValidPSEditionValue(string editionValue) T policy = null; #if !UNIX // On Windows, group policy settings from registry take precedence. - // If the requested policy is not defined in registry, we query the configuration file. + // If the requested policy is not defined in registry, we query the configuration file. policy = GetPolicySettingFromGPO(preferenceOrder); if (policy != null) { return policy; } #endif @@ -743,7 +743,7 @@ internal static void EnsureModuleLoaded(string module, ExecutionContext context) finally { context.AutoLoadingModuleInProgress.Remove(module); - if (null != ps) + if (ps != null) { ps.Dispose(); } @@ -807,7 +807,7 @@ internal static List GetModules(string module, ExecutionContext co } finally { - if (null != ps) + if (ps != null) { ps.Dispose(); } @@ -868,7 +868,7 @@ internal static List GetModules(ModuleSpecification fullyQualified } finally { - if (null != ps) + if (ps != null) { ps.Dispose(); } diff --git a/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs b/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs index d3804aab09a..da42d3f8ab3 100644 --- a/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs +++ b/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs @@ -151,7 +151,7 @@ internal void SetAsCompleted(Exception exception) } // call the user supplied callback - if (null != Callback) + if (Callback != null) { Callback(this); } @@ -180,7 +180,7 @@ internal void SignalWaitHandle() { lock (SyncObject) { - if (null != _completedWaitHandle) + if (_completedWaitHandle != null) { _completedWaitHandle.Set(); } @@ -225,7 +225,7 @@ internal void EndInvoke() _invokeOnThreadEvent = null; // Allow early GC // Operation is done: if an exception occured, throw it - if (null != Exception) + if (Exception != null) { throw Exception; } diff --git a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs index cf69c0077ae..f4ae4d5b102 100644 --- a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs @@ -596,7 +596,7 @@ public override } // Write to Information Buffers - if (null != _informationalBuffers) + if (_informationalBuffers != null) { _informationalBuffers.AddProgress(record); } @@ -974,7 +974,7 @@ private Collection EmulatePromptForMultipleChoice(string caption, } Dictionary defaultChoiceKeys = new Dictionary(); - if (null != defaultChoices) + if (defaultChoices != null) { foreach (int defaultChoice in defaultChoices) { diff --git a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs index 472b38a9334..a740680b397 100644 --- a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs +++ b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs @@ -505,7 +505,7 @@ private FlowControlException InvokeHelper() finally { // 2004/02/26-JonN added IDisposable to PipelineProcessor - if (null != pipelineProcessor) + if (pipelineProcessor != null) { pipelineProcessor.Dispose(); pipelineProcessor = null; @@ -532,7 +532,7 @@ private void InvokeThreadProc() System.Security.Principal.WindowsImpersonationContext oldImpersonationCtxt = null; try { - if ((null != InvocationSettings) && (InvocationSettings.FlowImpersonationPolicy)) + if ((InvocationSettings != null) && (InvocationSettings.FlowImpersonationPolicy)) { // we have a valid identity to impersonate. System.Security.Principal.WindowsIdentity identityToImPersonate = @@ -591,7 +591,7 @@ private void InvokeThreadProc() // If sensitive operations such as impersonation occur in the try block, and an // exception is thrown, the filter can execute before the finally block. For the // impersonation example, this means that the filter would execute as the impersonated user. - if (null != oldImpersonationCtxt) + if (oldImpersonationCtxt != null) { try { diff --git a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs index fff7ab43d62..540250a1013 100644 --- a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs +++ b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs @@ -76,7 +76,7 @@ public override CultureInfo Parent // returns fallback cultures (specified by the user) // and also adds neutral culture where appropriate. // Ex: ja-jp ja en-us en - while ((null != _fallbacks) && (_fallbacks.Length > 0)) + while ((_fallbacks != null) && (_fallbacks.Length > 0)) { string fallback = _fallbacks[0]; string[] fallbacksForParent = null; @@ -122,7 +122,7 @@ private VistaCultureInfo ImmediateParent // remove the parentCulture from the m_fallbacks list. // ie., remove duplicates from the parent hierarchy. string[] fallbacksForTheParent = null; - if (null != _fallbacks) + if (_fallbacks != null) { fallbacksForTheParent = new string[_fallbacks.Length]; int currentIndex = 0; diff --git a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs index 03eb9b75345..851e13ad352 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs @@ -545,7 +545,7 @@ public void Complete() // raise the events outside of the lock. if (raiseEvents) { - if (null != _readWaitHandle) + if (_readWaitHandle != null) { // unblock any readers waiting on the handle _readWaitHandle.Set(); @@ -554,7 +554,7 @@ public void Complete() // A temporary variable is used as the Completed may // reach null (because of -='s) after the null check EventHandler tempCompleted = Completed; - if (null != tempCompleted) + if (tempCompleted != null) { tempCompleted(this, EventArgs.Empty); } @@ -1189,7 +1189,7 @@ internal Collection ReadAndRemove(int readCount) } } - if (null != _readWaitHandle) + if (_readWaitHandle != null) { if (_data.Count > 0 || !_isOpen) { @@ -1341,7 +1341,7 @@ private void RaiseEvents(Guid psInstanceId, int index) bool raiseDataAdded = false; lock (SyncObject) { - if (null != _readWaitHandle) + if (_readWaitHandle != null) { // TODO: Should ObjectDisposedException be caught. @@ -1392,7 +1392,7 @@ private void RaiseDataAddingEvent(Guid psInstanceId, Object itemAdded) // A temporary variable is used as the DataAdding may // reach null (because of -='s) after the null check EventHandler tempDataAdding = DataAdding; - if (null != tempDataAdding) + if (tempDataAdding != null) { tempDataAdding(this, new DataAddingEventArgs(psInstanceId, itemAdded)); } @@ -1403,7 +1403,7 @@ private void RaiseDataAddedEvent(Guid psInstanceId, int index) // A temporary variable is used as the DataAdded may // reach null (because of -='s) after the null check EventHandler tempDataAdded = DataAdded; - if (null != tempDataAdded) + if (tempDataAdded != null) { tempDataAdded(this, new DataAddedEventArgs(psInstanceId, index)); } @@ -1557,7 +1557,7 @@ internal void DecrementRef() if (_refCount != 0 && (!_blockingEnumerator || _refCount != 1)) return; // release threads blocked on waithandle - if (null != _readWaitHandle) + if (_readWaitHandle != null) { _readWaitHandle.Set(); } @@ -2080,7 +2080,7 @@ internal PSDataCollection Debug /// internal void AddProgress(ProgressRecord item) { - if (null != progress) + if (progress != null) { progress.InternalAdd(_psInstanceId, item); } @@ -2093,7 +2093,7 @@ internal void AddProgress(ProgressRecord item) /// internal void AddVerbose(VerboseRecord item) { - if (null != verbose) + if (verbose != null) { verbose.InternalAdd(_psInstanceId, item); } @@ -2106,7 +2106,7 @@ internal void AddVerbose(VerboseRecord item) /// internal void AddDebug(DebugRecord item) { - if (null != debug) + if (debug != null) { debug.InternalAdd(_psInstanceId, item); } @@ -2119,7 +2119,7 @@ internal void AddDebug(DebugRecord item) /// internal void AddWarning(WarningRecord item) { - if (null != Warning) + if (Warning != null) { Warning.InternalAdd(_psInstanceId, item); } @@ -2132,7 +2132,7 @@ internal void AddWarning(WarningRecord item) /// internal void AddInformation(InformationRecord item) { - if (null != Information) + if (Information != null) { Information.InternalAdd(_psInstanceId, item); } @@ -2140,4 +2140,4 @@ internal void AddInformation(InformationRecord item) #endregion } -} \ No newline at end of file +} diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index 51cc2b38d3b..5ea2283efca 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -881,7 +881,7 @@ public static PowerShell Create(InitialSessionState initialSessionState) [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "ps", Justification = "ps represents PowerShell and is used at many places.")] public PowerShell CreateNestedPowerShell() { - if ((null != _worker) && (null != _worker.CurrentlyRunningPipeline)) + if ((_worker != null) && (null != _worker.CurrentlyRunningPipeline)) { PowerShell result = new PowerShell(new PSCommand(), null, _worker.CurrentlyRunningPipeline.Runspace); @@ -3062,7 +3062,7 @@ private IAsyncResult BeginBatchInvoke(PSDataCollection } RunspacePool pool = _rsConnection as RunspacePool; - if ((null != pool) && (pool.IsRemote)) + if ((pool != null) && (pool.IsRemote)) { // Server supports batch invocation, in this case, we just send everything to the server and return immediately if (ServerSupportsBatchInvocation()) @@ -3136,7 +3136,7 @@ private void BatchInvocationWorkItem(object state) SetHadErrors(true); // Stop if necessarily - if ((null != _batchInvocationSettings) && _batchInvocationSettings.ErrorActionPreference == ActionPreference.Stop) + if ((_batchInvocationSettings != null) && _batchInvocationSettings.ErrorActionPreference == ActionPreference.Stop) { _stopBatchExecution = true; AppendExceptionToErrorStream(e); @@ -3849,7 +3849,7 @@ private void InternalClearSuppressExceptions() { lock (_syncObject) { - if (null != _worker) + if (_worker != null) { _worker.InternalClearSuppressExceptions(); } @@ -3976,7 +3976,7 @@ internal void SetStateChanged(PSInvocationStateInfo stateInfo) { if (RunningExtraCommands) { - if (null != tempInvokeAsyncResult) + if (tempInvokeAsyncResult != null) { tempInvokeAsyncResult.SetAsCompleted(InvocationStateInfo.Reason); } @@ -3987,13 +3987,13 @@ internal void SetStateChanged(PSInvocationStateInfo stateInfo) { RaiseStateChangeEvent(InvocationStateInfo.Clone()); - if (null != tempInvokeAsyncResult) + if (tempInvokeAsyncResult != null) { tempInvokeAsyncResult.SetAsCompleted(InvocationStateInfo.Reason); } } - if (null != tempStopAsyncResult) + if (tempStopAsyncResult != null) { tempStopAsyncResult.SetAsCompleted(null); } @@ -4009,7 +4009,7 @@ internal void SetStateChanged(PSInvocationStateInfo stateInfo) finally { // takes care exception occured with invokeAsyncResult - if (isExceptionOccured && (null != tempStopAsyncResult)) + if (isExceptionOccured && (tempStopAsyncResult != null)) { tempStopAsyncResult.Release(); } @@ -4059,7 +4059,7 @@ internal void SetStateChanged(PSInvocationStateInfo stateInfo) finally { // takes care exception occured with invokeAsyncResult - if (isExceptionOccured && (null != tempStopAsyncResult)) + if (isExceptionOccured && (tempStopAsyncResult != null)) { tempStopAsyncResult.Release(); } @@ -4103,7 +4103,7 @@ internal void ClearRemotePowerShell() { lock (_syncObject) { - if (null != RemotePowerShell) + if (RemotePowerShell != null) { RemotePowerShell.Clear(); } @@ -4181,7 +4181,7 @@ internal void SetIsNested(bool isNested) private void CoreInvoke(IEnumerable input, PSDataCollection output, PSInvocationSettings settings) { PSDataCollection inputBuffer = null; - if (null != input) + if (input != null) { inputBuffer = new PSDataCollection(); foreach (object o in input) @@ -4214,7 +4214,7 @@ private void CoreInvokeHelper(PSDataCollection input, P Runspace rsToUse = null; if (!IsNested) { - if (null != pool) + if (pool != null) { #if !CORECLR // No ApartmentState In CoreCLR VerifyThreadSettings(settings, pool.ApartmentState, pool.ThreadOptions, false); @@ -4228,7 +4228,7 @@ private void CoreInvokeHelper(PSDataCollection input, P else { rsToUse = _rsConnection as Runspace; - if (null != rsToUse) + if (rsToUse != null) { #if !CORECLR // No ApartmentState In CoreCLR VerifyThreadSettings(settings, rsToUse.ApartmentState, rsToUse.ThreadOptions, false); @@ -4332,7 +4332,7 @@ private void CoreInvoke(PSDataCollection input, PSDataC SetHadErrors(false); RunspacePool pool = _rsConnection as RunspacePool; - if ((null != pool) && (pool.IsRemote)) + if ((pool != null) && (pool.IsRemote)) { if (ServerSupportsBatchInvocation()) { @@ -4393,13 +4393,13 @@ private void CoreInvoke(PSDataCollection input, PSDataC SetHadErrors(true); // Stop if necessarily - if ((null != settings) && settings.ErrorActionPreference == ActionPreference.Stop) + if ((settings != null) && settings.ErrorActionPreference == ActionPreference.Stop) { throw; } // Ignore the exception if necessary. - if ((null != settings) && settings.ErrorActionPreference == ActionPreference.Ignore) + if ((settings != null) && settings.ErrorActionPreference == ActionPreference.Ignore) { continue; } @@ -4493,7 +4493,7 @@ private IAsyncResult CoreInvokeAsync(PSDataCollection i // IsNested is true for the icm | % { icm } scenario if (!IsNested || (pool != null && pool.IsRemote)) { - if (null != pool) + if (pool != null) { #if !CORECLR // No ApartmentState In CoreCLR VerifyThreadSettings(settings, pool.ApartmentState, pool.ThreadOptions, pool.IsRemote); @@ -4569,7 +4569,7 @@ private IAsyncResult CoreInvokeAsync(PSDataCollection i else { LocalRunspace rs = _rsConnection as LocalRunspace; - if (null != rs) + if (rs != null) { #if !CORECLR // No ApartmentState In CoreCLR VerifyThreadSettings(settings, rs.ApartmentState, rs.ThreadOptions, false); @@ -4694,7 +4694,7 @@ private void Prepare(PSDataCollection input, PSDataColl InvocationStateInfo = new PSInvocationStateInfo(PSInvocationState.Running, null); // update settings for impersonation policy - if ((null != settings) && (settings.FlowImpersonationPolicy)) + if ((settings != null) && (settings.FlowImpersonationPolicy)) { // get the identity of the thread. // false behavior: If the thread is impersonating the WindowsIdentity for the @@ -4708,7 +4708,7 @@ private void Prepare(PSDataCollection input, PSDataColl // this way pipeline will not waste resources creating // the same. ObjectStreamBase inputStream; - if (null != input) + if (input != null) { inputStream = new PSDataCollectionStream(InstanceId, input); } @@ -5104,7 +5104,7 @@ internal void CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, bool isSync) { Runspace runspace = null; - if ((null != _settings) && (null != _settings.Host)) + if ((_settings != null) && (null != _settings.Host)) { runspace = RunspaceFactory.CreateRunspace(_settings.Host); } @@ -5233,12 +5233,12 @@ internal bool ConstructPipelineAndDoWork(Runspace rs, bool performSyncInvoke) return false; } - if (null != lrs) + if (lrs != null) { LocalPipeline localPipeline = new LocalPipeline( lrs, _shell.Commands.Commands, - ((null != _settings) && (_settings.AddToHistory)) ? true : false, + ((_settings != null) && (_settings.AddToHistory)) ? true : false, _shell.IsNested, _inputStream, _outputStream, @@ -5297,7 +5297,7 @@ internal void Stop(bool isSyncCall) } _isNotActive = true; - if (null != CurrentlyRunningPipeline) + if (CurrentlyRunningPipeline != null) { if (isSyncCall) { @@ -5310,7 +5310,7 @@ internal void Stop(bool isSyncCall) return; } - if (null != GetRunspaceAsyncResult) + if (GetRunspaceAsyncResult != null) { RunspacePool pool = _shell._rsConnection as RunspacePool; Dbg.Assert(pool != null, "RunspaceConnection must be a runspace pool"); @@ -5341,7 +5341,7 @@ internal void InternalClearSuppressExceptions() { try { - if ((null != _settings) && (null != _settings.WindowsIdentityToImpersonate)) + if ((_settings != null) && (null != _settings.WindowsIdentityToImpersonate)) { _settings.WindowsIdentityToImpersonate.Dispose(); _settings.WindowsIdentityToImpersonate = null; @@ -5369,7 +5369,7 @@ internal void InternalClearSuppressExceptions() else { RunspacePool pool = _shell._rsConnection as RunspacePool; - if (null != pool) + if (pool != null) { pool.ReleaseRunspace(CurrentlyRunningPipeline.Runspace); } diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs index f7ac95f810d..ff92d87b0ed 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs @@ -1611,7 +1611,7 @@ protected void ServicePendingRequests(object useCallingThreadState) } } - if ((useCallingThread) && (null != runspaceRequester)) + if ((useCallingThread) && (runspaceRequester != null)) { // call DoComplete outside of the lock and finally..as the // DoComplete handler may handle the runspace in the same diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index 787a925e246..04420bba60b 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -491,7 +491,7 @@ internal Array SynchronousExecuteEnumerate(object input) CommandProcessorBase firstCommandProcessor = _commands[0]; // Add any input to the first command. - if (null != ExternalInput) + if (ExternalInput != null) { firstCommandProcessor.CommandRuntime.InputPipe.ExternalReader = ExternalInput; @@ -544,7 +544,7 @@ internal Array SynchronousExecuteEnumerate(object input) // The error we want to report is the first terminating error // which occurred during pipeline execution, regardless // of whether other errors occurred afterward. - if (null != _firstTerminatingError) + if (_firstTerminatingError != null) { toRethrowInfo = _firstTerminatingError; } @@ -699,7 +699,7 @@ internal Array DoComplete() // The error we want to report is the first terminating error // which occurred during pipeline execution, regardless // of whether other errors occurred afterward. - if (null != _firstTerminatingError) + if (_firstTerminatingError != null) { toRethrowInfo = _firstTerminatingError; } @@ -744,7 +744,7 @@ internal void StartStepping(bool expectInput) Start(expectInput); // If a terminating error occurred, report it now. - if (null != _firstTerminatingError) + if (_firstTerminatingError != null) { _firstTerminatingError.Throw(); } @@ -756,7 +756,7 @@ internal void StartStepping(bool expectInput) // The error we want to report is the first terminating error // which occurred during pipeline execution, regardless // of whether other errors occurred afterward. - if (null != _firstTerminatingError) + if (_firstTerminatingError != null) { _firstTerminatingError.Throw(); } @@ -856,7 +856,7 @@ internal Array Step(object input) Inject(input, enumerate: false); // If a terminating error occurred, report it now. - if (null != _firstTerminatingError) + if (_firstTerminatingError != null) { _firstTerminatingError.Throw(); } @@ -870,7 +870,7 @@ internal Array Step(object input) // The error we want to report is the first terminating error // which occurred during pipeline execution, regardless // of whether other errors occurred afterward. - if (null != _firstTerminatingError) + if (_firstTerminatingError != null) { _firstTerminatingError.Throw(); } @@ -956,7 +956,7 @@ private void Start(bool incomingStream) // "PipelineProcessor.Start(): LastCommandProcessor == null" throw PSTraceSource.NewInvalidOperationException(); } - if (null != ExternalSuccessOutput) + if (ExternalSuccessOutput != null) { LastCommandProcessor.CommandRuntime.OutputPipe.ExternalWriter = ExternalSuccessOutput; @@ -1056,7 +1056,7 @@ private void Start(bool incomingStream) /// private void SetExternalErrorOutput() { - if (null != ExternalErrorOutput) + if (ExternalErrorOutput != null) { for (int i = 0; i < _commands.Count; i++) { @@ -1285,7 +1285,7 @@ private void DisposeCommands() for (int i = 0; i < _commands.Count; i++) { CommandProcessorBase commandProcessor = _commands[i]; - if (null != commandProcessor) + if (commandProcessor != null) { #pragma warning disable 56500 // If Dispose throws an exception, record it as a @@ -1307,7 +1307,7 @@ private void DisposeCommands() ProviderInvocationException pie = e as ProviderInvocationException; - if (null != pie) + if (pie != null) { e = new CmdletProviderInvocationException( pie, diff --git a/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs b/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs index 78d605b92c5..e7cc8ddd184 100644 --- a/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs +++ b/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs @@ -163,7 +163,7 @@ internal void UnblockCollections() outputstream.Close(); errorstream.Close(); - if (null != inputstream) + if (inputstream != null) { inputstream.Close(); } diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 9b512a7c611..491e62c8e8c 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -1541,7 +1541,7 @@ internal void AssertNotDisposed() internal void CloseAllStreams() { // The Complete() method includes raising public notification events that third parties can - // handle and potentially throw exceptions on the notification thread. We don't want to + // handle and potentially throw exceptions on the notification thread. We don't want to // propagate those exceptions because it prevents this thread from completing its processing. if (_resultsOwner) { try { _results.Complete(); } catch (Exception e) { TraceException(e); } } if (_outputOwner) { try { _output.Complete(); } catch (Exception e) { TraceException(e); } } @@ -1614,7 +1614,7 @@ protected virtual void Dispose(bool disposing) // release the WaitHandle lock (syncObject) { - if (null != _finished) + if (_finished != null) { _finished.Dispose(); _finished = null; @@ -2262,7 +2262,7 @@ internal bool HideComputerName foreach (Job job in this.ChildJobs) { PSRemotingChildJob rJob = job as PSRemotingChildJob; - if (null != rJob) + if (rJob != null) { rJob.HideComputerName = value; } @@ -2729,7 +2729,7 @@ internal PSRemotingChildJob(string remoteCommand, ExecutionCmdletHelper helper, _throttleManager = throttleManager; RemoteRunspace remoteRS = Runspace as RemoteRunspace; - if ((null != remoteRS) && (remoteRS.RunspaceStateInfo.State == RunspaceState.BeforeOpen)) + if ((remoteRS != null) && (remoteRS.RunspaceStateInfo.State == RunspaceState.BeforeOpen)) { remoteRS.URIRedirectionReported += HandleURIDirectionReported; } @@ -2905,7 +2905,7 @@ internal bool HideComputerName foreach (Job job in this.ChildJobs) { PSRemotingChildJob rJob = job as PSRemotingChildJob; - if (null != rJob) + if (rJob != null) { rJob.HideComputerName = value; } @@ -3108,7 +3108,7 @@ private void HandleHostCalls(object sender, EventArgs eventArgs) /// protected virtual void HandlePipelineStateChanged(object sender, PipelineStateEventArgs e) { - if ((null != Runspace) && (e.PipelineStateInfo.State != PipelineState.Running)) + if ((Runspace != null) && (e.PipelineStateInfo.State != PipelineState.Running)) { // since we got state changed event..we dont need to listen on // URI redirections anymore @@ -4057,7 +4057,7 @@ internal PSInvokeExpressionSyncJob(List operations, Throttle ExecutionCmdletHelper helper = operation as ExecutionCmdletHelper; RemoteRunspace remoteRS = helper.Pipeline.Runspace as RemoteRunspace; - if (null != remoteRS) + if (remoteRS != null) { remoteRS.StateChanged += HandleRunspaceStateChanged; @@ -4105,7 +4105,7 @@ protected override void DoCleanupOnFinished() { // cleanup remote runspace related handlers RemoteRunspace remoteRS = helper.PipelineRunspace as RemoteRunspace; - if (null != remoteRS) + if (remoteRS != null) { remoteRS.StateChanged -= HandleRunspaceStateChanged; remoteRS.URIRedirectionReported -= HandleURIDirectionReported; @@ -4283,7 +4283,7 @@ private void HandleRunspaceStateChanged(object sender, RunspaceStateEventArgs e) RemoteRunspace remoteRS = sender as RemoteRunspace; // remote runspace must be connected (or connection failed) // we dont need URI redirection any more..so clear it - if (null != remoteRS) + if (remoteRS != null) { if (e.RunspaceStateInfo.State != RunspaceState.Opening) { diff --git a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs index b8f8e380388..700404720a8 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs @@ -1767,7 +1767,7 @@ private void HandleResponseReceived(object sender, RemoteDataEventArgs private void HandleURIDirectionReported(object sender, RemoteDataEventArgs eventArgs) { WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo; - if (null != wsmanConnectionInfo) + if (wsmanConnectionInfo != null) { wsmanConnectionInfo.ConnectionUri = eventArgs.Data; URIRedirectionReported.SafeInvoke(this, eventArgs); diff --git a/src/System.Management.Automation/engine/remoting/client/RemotingErrorRecord.cs b/src/System.Management.Automation/engine/remoting/client/RemotingErrorRecord.cs index 219268ebff2..bdb339d1780 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemotingErrorRecord.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemotingErrorRecord.cs @@ -42,7 +42,7 @@ public RemotingErrorRecord(ErrorRecord errorRecord, OriginInfo originInfo) : thi private RemotingErrorRecord(ErrorRecord errorRecord, OriginInfo originInfo, Exception replaceParentContainsErrorRecordException) : base(errorRecord, replaceParentContainsErrorRecordException) { - if (null != errorRecord) + if (errorRecord != null) { base.SetInvocationInfo(errorRecord.InvocationInfo); } diff --git a/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs b/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs index 6afed699508..b61c9b64fd5 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs @@ -1359,7 +1359,7 @@ internal void CloseConnectionAsync(Exception sessionCloseReason) // wait for the close to complete and then dispose the transport manager TransportManager.CloseCompleted += delegate (object source, EventArgs args) { - if (null != CloseCompleted) + if (CloseCompleted != null) { // If the provided event args are empty then call CloseCompleted with // RemoteSessionStateEventArgs containing session closed reason exception. diff --git a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs index 050705f6d50..cd07572372e 100644 --- a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs +++ b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs @@ -1574,7 +1574,7 @@ private void HandleHostCallReceived(object sender, RemoteDataEventArgs eventArgs) { WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo; - if (null != wsmanConnectionInfo) + if (wsmanConnectionInfo != null) { // change the runspace's uri to the new URI. wsmanConnectionInfo.ConnectionUri = eventArgs.Data; diff --git a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs index 4870bda0958..9479c45895d 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs @@ -92,7 +92,7 @@ internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, _transportManager.RobustConnectionNotification += new EventHandler(HandleRobustConnectionNotification); WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo; - if (null != wsmanConnectionInfo) + if (wsmanConnectionInfo != null) { // only WSMan transport supports redirection @@ -442,7 +442,7 @@ private void PerformURIRedirectionStep2(System.Uri newURI) } // raise warning to report the redirection - if (null != _uriRedirectionHandler) + if (_uriRedirectionHandler != null) { _uriRedirectionHandler(newURI); } @@ -486,7 +486,7 @@ internal void HandleTransportError(object sender, TransportErrorOccuredEventArgs exception = uriFormatException; } // if we are here, there must be an exception constructing a uri - if (null != exception) + if (exception != null) { PSRemotingTransportException newException = new PSRemotingTransportException(PSRemotingErrorId.RedirectedURINotWellFormatted, RemotingErrorIdStrings.RedirectedURINotWellFormatted, diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 2f1abf4e617..11dc1a60967 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1379,7 +1379,7 @@ internal static void CollectShouldProcessParameters(PSCmdlet cmdlet, out bool wh // confirm is always true to start with confirm = false; MshCommandRuntime cmdRuntime = cmdlet.CommandRuntime as MshCommandRuntime; - if (null != cmdRuntime) + if (cmdRuntime != null) { whatIf = cmdRuntime.WhatIf; // take the value of confirm only if it is explicitly set by the user @@ -2940,7 +2940,7 @@ protected override void ProcessRecord() string csNotFoundMessageFormat = RemotingErrorIdStrings.CustomShellNotFound; object arguments = "*"; - if (null != Name) + if (Name != null) { arguments = Name; } diff --git a/src/System.Management.Automation/engine/remoting/commands/PushRunspaceCommand.cs b/src/System.Management.Automation/engine/remoting/commands/PushRunspaceCommand.cs index 1501bd974d9..3a1cb56bfac 100644 --- a/src/System.Management.Automation/engine/remoting/commands/PushRunspaceCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/PushRunspaceCommand.cs @@ -493,7 +493,7 @@ protected override void ProcessRecord() { // A third-party host can throw any exception here..we should // clean the runspace created in this case. - if ((null != remoteRunspace) && (remoteRunspace.ShouldCloseOnPop)) + if ((remoteRunspace != null) && (remoteRunspace.ShouldCloseOnPop)) { remoteRunspace.Close(); } @@ -509,7 +509,7 @@ protected override void ProcessRecord() /// protected override void EndProcessing() { - if (null != _stream) + if (_stream != null) { while (true) { diff --git a/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs b/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs index 217148ae71c..2048be04210 100644 --- a/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs @@ -410,7 +410,7 @@ private void HandleRunspaceStateChanged(object sender, OperationStateEventArgs s // since we got state changed event..we dont need to listen on // URI redirections anymore - if (null != remoteRunspace) + if (remoteRunspace != null) { remoteRunspace.URIRedirectionReported -= HandleURIDirectionReported; } @@ -645,7 +645,7 @@ private List CreateRunspacesWhenRunspaceParameterSpecified() WSManConnectionInfo originalWSManConnectionInfo = remoteRunspace.ConnectionInfo as WSManConnectionInfo; WSManConnectionInfo newWSManConnectionInfo = null; - if (null != originalWSManConnectionInfo) + if (originalWSManConnectionInfo != null) { newWSManConnectionInfo = originalWSManConnectionInfo.Copy(); newWSManConnectionInfo.EnableNetworkAccess = (newWSManConnectionInfo.EnableNetworkAccess || EnableNetworkAccess) ? true : false; diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs index 8392630da82..72248e77ca5 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs @@ -125,7 +125,7 @@ internal static byte[] GetCurrentTimeZoneInByteFormat() // if there is any exception serializing the timezone information // ignore it and dont try to serialize again. - if (null != e) + if (e != null) { _timeZoneInByteFormat = Utils.EmptyArray(); } diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs index 099218f862b..34eaa43814a 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs @@ -181,7 +181,7 @@ internal virtual void Serialize(Stream streamToWriteTo, Fragmentor fragmentor) Dbg.Assert(null != fragmentor, "Fragmentor cannot be null."); SerializeHeader(streamToWriteTo); - if (null != Data) + if (Data != null) { fragmentor.SerializeToBytes(Data, streamToWriteTo); } diff --git a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs index a0812e55278..6a2f99100d7 100644 --- a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs +++ b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs @@ -97,7 +97,7 @@ internal FragmentedRemoteObject() internal FragmentedRemoteObject(byte[] blob, long objectId, long fragmentId, bool isEndFragment) { - Dbg.Assert((null != blob) || (blob.Length == 0), "Cannot create a fragment for null or empty data."); + Dbg.Assert((blob != null) || (blob.Length == 0), "Cannot create a fragment for null or empty data."); Dbg.Assert(objectId >= 0, "Object Id cannot be < 0"); Dbg.Assert(fragmentId >= 0, "Fragment Id cannot be < 0"); @@ -503,7 +503,7 @@ internal SerializedDataStream(int fragmentSize) internal SerializedDataStream(int fragmentSize, OnDataAvailableCallback callbackToNotify) : this(fragmentSize) { - if (null != callbackToNotify) + if (callbackToNotify != null) { _notifyOnWriteFragmentImmediately = true; _onDataAvailableCallback = callbackToNotify; @@ -809,7 +809,7 @@ private void WriteCurrentFragmentAndReset() } // call the callback since we have data available - if (null != _onDataAvailableCallback) + if (_onDataAvailableCallback != null) { _onDataAvailableCallback(data, _currentFragment.IsEndFragment); } @@ -862,12 +862,12 @@ protected override void Dispose(bool disposing) } } - if ((null != _readStream) && (_readStream.CanRead)) + if ((_readStream != null) && (_readStream.CanRead)) { _readStream.Dispose(); } - if ((null != _writeStream) && (_writeStream.CanRead)) + if ((_writeStream != null) && (_writeStream.CanRead)) { _writeStream.Dispose(); } diff --git a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs index c258bfddaa6..a12e2ff0299 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs @@ -700,7 +700,7 @@ internal void EnqueueAndStartProcessingThread(RemoteDataObject remoteO lock (_callbackNotificationQueue) { - if ((null != remoteObject) || (null != transportErrorArgs) || (null != privateData)) + if ((remoteObject != null) || (transportErrorArgs != null) || (privateData != null)) { CallbackNotificationInformation rcvdDataInfo = new CallbackNotificationInformation(); rcvdDataInfo.remoteObject = remoteObject; @@ -829,7 +829,7 @@ internal void ServicePendingCallbacks(object objectToProcess) rcvdDataInfo = _callbackNotificationQueue.Dequeue(); } // Handle callback. - if (null != rcvdDataInfo) + if (rcvdDataInfo != null) { // Handling transport exception in thread-pool thread if (null != rcvdDataInfo.transportError) diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs index bd3260c690e..b0ca9f5da7e 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs @@ -548,7 +548,7 @@ private static Type LoadAndAnalyzeAssembly(string shellId, string applicationBas } // configuration xml specified an assembly and typetoload. - if (null != assembly) + if (assembly != null) { try { @@ -673,7 +673,7 @@ private static Assembly LoadSsnStateProviderAssembly(string applicationBase, str s_tracer.TraceWarning("Not able to load assembly {0}: {1}", assemblyName, e.Message); } - if (null != result) + if (result != null) { return result; } @@ -2073,7 +2073,7 @@ public override InitialSessionState GetInitialSessionState(PSSenderInfo senderIn throw ioe; } - if (null != modules) + if (modules != null) { Collection modulesToImport = new Collection(); foreach (object module in modules) @@ -2087,14 +2087,14 @@ public override InitialSessionState GetInitialSessionState(PSSenderInfo senderIn else { Hashtable moduleHash = module as Hashtable; - if (null != moduleHash) + if (moduleHash != null) { moduleSpec = new ModuleSpecification(moduleHash); } } // Now add the moduleSpec to modulesToImport - if (null != moduleSpec) + if (moduleSpec != null) { if (string.Equals(InitialSessionState.CoreModule, moduleSpec.Name, StringComparison.OrdinalIgnoreCase)) diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index 01c67b8eaed..ab453d988ef 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -721,7 +721,7 @@ protected void SendOneItem() // This will either return data or register callback but doesn't do both. byte[] data = dataToBeSent.ReadOrRegisterCallback(_onDataAvailableToSendCallback, out priorityType); - if (null != data) + if (data != null) { SendData(data, priorityType); } @@ -794,7 +794,7 @@ private void OnDataPacketReceived(byte[] rawData, string stream, Guid psGuid) { // this is for a command OutOfProcessClientCommandTransportManager cmdTM = GetCommandTransportManager(psGuid); - if (null != cmdTM) + if (cmdTM != null) { // not throwing the exception in null case as the command might have already // closed. The RS data structure handler does not wait for the close ack before @@ -815,7 +815,7 @@ private void OnDataAckPacketReceived(Guid psGuid) { // this is for a command OutOfProcessClientCommandTransportManager cmdTM = GetCommandTransportManager(psGuid); - if (null != cmdTM) + if (cmdTM != null) { // not throwing the exception in null case as the command might have already // closed. The RS data structure handler does not wait for the close ack before @@ -865,7 +865,7 @@ private void OnSignalAckPacketReceived(Guid psGuid) else { OutOfProcessClientCommandTransportManager cmdTM = GetCommandTransportManager(psGuid); - if (null != cmdTM) + if (cmdTM != null) { cmdTM.OnRemoteCmdSignalCompleted(); } @@ -898,7 +898,7 @@ private void OnCloseAckReceived(Guid psGuid) _tracer.WriteMessage("OutOfProcessClientSessionTransportManager.OnCloseAckReceived, in progress command count should be greater than zero: " + commandCount + ", RunSpacePool Id : " + this.RunspacePoolInstanceId + ", psGuid : " + psGuid.ToString()); OutOfProcessClientCommandTransportManager cmdTM = GetCommandTransportManager(psGuid); - if (null != cmdTM) + if (cmdTM != null) { // this might legitimately happen if cmd is already closed before we get an // ACK back from server. @@ -957,7 +957,7 @@ internal OutOfProcessClientSessionTransportManager(Guid runspaceId, /// internal override void CreateAsync() { - if (null != _connectionInfo) + if (_connectionInfo != null) { _processInstance = _connectionInfo.Process ?? new PowerShellProcessInstance(_connectionInfo.PSVersion, _connectionInfo.Credential, @@ -2200,7 +2200,7 @@ private void SendOneItem() data = dataToBeSent.ReadOrRegisterCallback(_onDataAvailableToSendCallback, out priorityType); } - if (null != data) + if (data != null) { SendData(data, priorityType); } diff --git a/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs b/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs index ec555207545..134a2c90236 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs @@ -210,7 +210,7 @@ IIdentity IPrincipal.Identity /// public bool IsInRole(string role) { - if (null != WindowsIdentity) + if (WindowsIdentity != null) { // Get Windows Principal for this identity WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity); @@ -227,7 +227,7 @@ public bool IsInRole(string role) /// internal bool IsInRole(WindowsBuiltInRole role) { - if (null != WindowsIdentity) + if (WindowsIdentity != null) { // Get Windows Principal for this identity WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity); @@ -382,4 +382,4 @@ public PSCertificateDetails(string subject, string issuerName, string issuerThum #endregion } -} \ No newline at end of file +} diff --git a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs index 5fa03c68733..70a8702c665 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs @@ -252,13 +252,13 @@ private void OnDataAvailable(byte[] data, bool isEndFragment) _isHandlingCallback = true; } - if (null != _onDataAvailableCallback) + if (_onDataAvailableCallback != null) { DataPriorityType prType; // now get the fragment and call the callback.. byte[] result = ReadOrRegisterCallback(_onDataAvailableCallback, out prType); - if (null != result) + if (result != null) { // reset the onDataAvailableCallback so that we dont notify // multiple times. we are resetting before actually calling @@ -568,7 +568,7 @@ internal void ProcessRawData(byte[] data, OnDataAvailableCallback callback) // reset incoming stream. _pendingDataStream.Dispose(); _pendingDataStream = new MemoryStream(); - if (null != extraData) + if (extraData != null) { _pendingDataStream.Write(extraData, 0, extraData.Length); } @@ -672,7 +672,7 @@ internal void ProcessRawData(byte[] data, OnDataAvailableCallback callback) private void ResetReceiveData() { // reset resources used to store incoming data (for a single object) - if (null != _dataToProcessStream) + if (_dataToProcessStream != null) { _dataToProcessStream.Dispose(); } @@ -683,13 +683,13 @@ private void ResetReceiveData() private void ReleaseResources() { - if (null != _pendingDataStream) + if (_pendingDataStream != null) { _pendingDataStream.Dispose(); _pendingDataStream = null; } - if (null != _dataToProcessStream) + if (_dataToProcessStream != null) { _dataToProcessStream.Dispose(); _dataToProcessStream = null; @@ -899,7 +899,7 @@ public void Dispose() internal virtual void Dispose(bool isDisposing) { - if (null != _recvdData) + if (_recvdData != null) { for (int index = 0; index < _recvdData.Length; index++) { diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs index 5047bb1b243..b5c593ad831 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs @@ -345,7 +345,7 @@ internal WSManUserNameAuthenticationCredentials(string name, _cred = new WSManUserNameCredentialStruct(); _cred.authenticationMechanism = authMechanism; _cred.userName = name; - if (null != pwd) + if (pwd != null) { _cred.password = Marshal.SecureStringToCoTaskMemUnicode(pwd); } @@ -752,7 +752,7 @@ private void Dispose(bool isDisposing) /// public static implicit operator IntPtr(WSManData_ManToUn data) { - if (null != data) + if (data != null) { return data._marshalledObject; } @@ -1573,7 +1573,7 @@ internal WSManProxyInfo(ProxyAccessType proxyAccessType, internalInfo.proxyAuthCredentialsStruct = new WSManUserNameAuthenticationCredentials.WSManUserNameCredentialStruct(); internalInfo.proxyAuthCredentialsStruct.authenticationMechanism = WSManAuthenticationMechanism.WSMAN_FLAG_DEFAULT_AUTHENTICATION; - if (null != authCredentials) + if (authCredentials != null) { internalInfo.proxyAuthCredentialsStruct = authCredentials.CredentialStruct; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index 01e7460d81e..be474c7bfa2 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -312,7 +312,7 @@ internal void CreateShell( AddToActiveShellSessions(mgdShellSession); mgdShellSession.SessionClosed += new EventHandler(HandleShellSessionClosed); - if (null != inboundShellInformation) + if (inboundShellInformation != null) { if ((uint)WSManNativeApi.WSManDataType.WSMAN_DATA_TYPE_TEXT != inboundShellInformation.Type) { @@ -1097,7 +1097,7 @@ protected internal bool EnsureProtocolVersionComplies( System.Version clientVersion = Utils.StringToVersion(clientVersionString); System.Version serverVersion = Utils.StringToVersion(WSManPluginConstants.PowerShellStartupProtocolVersionValue); - if ((null != clientVersion) && (null != serverVersion) && + if ((clientVersion != null) && (serverVersion != null) && (clientVersion.Major == serverVersion.Major) && (clientVersion.Minor >= serverVersion.Minor)) { @@ -1283,7 +1283,7 @@ internal static void PerformWSManPluginSignal( { // Close operations associated with this command.. WSManPluginOperationShutdownContext cmdCtxt = new WSManPluginOperationShutdownContext(pluginContext, shellContext, commandContext, false); - if (null != cmdCtxt) + if (cmdCtxt != null) { PerformCloseOperation(cmdCtxt); } @@ -1422,7 +1422,7 @@ internal static void ReportWSManOperationComplete( String errorMessage = String.Empty; String stackTrace = String.Empty; - if (null != reasonForClose) + if (reasonForClose != null) { error = WSManPluginErrorCodes.ManagedException; errorMessage = reasonForClose.Message; @@ -1437,7 +1437,7 @@ internal static void ReportWSManOperationComplete( errorMessage, stackTrace); - if (null != reasonForClose) + if (reasonForClose != null) { // report operation complete to wsman with the error message (if any). ReportOperationComplete( @@ -1556,7 +1556,7 @@ internal static void ReportOperationComplete( WSManPluginErrorCodes errorCode, string errorMessage) { - if (null != requestDetails) + if (requestDetails != null) { ReportOperationComplete(requestDetails.unmanagedHandle, errorCode, errorMessage); } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs index 2e0241c5465..f3869cd59b6 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs @@ -327,7 +327,7 @@ private void populateDelegates() private void CleanUpDelegates() { // Free GCHandles so that the memory they point to may be unpinned (garbage collected) - if (null != _pluginShellGCHandle) + if (_pluginShellGCHandle != null) { _pluginShellGCHandle.Free(); _pluginReleaseShellContextGCHandle.Free(); @@ -479,7 +479,7 @@ public static void ShutdownPlugin( { WSManPluginInstance.PerformShutdown(pluginContext); - if (null != workerPtrs) + if (workerPtrs != null) { workerPtrs.Dispose(); } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index b94b433a9f1..a969837ddda 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -314,7 +314,7 @@ protected internal void SafeInvokeSessionClosed(Object sender, EventArgs eventAr internal void HandleTransportError(Object sender, TransportErrorOccuredEventArgs eventArgs) { Exception reasonForClose = null; - if (null != eventArgs) + if (eventArgs != null) { reasonForClose = eventArgs.Exception; } @@ -334,7 +334,7 @@ internal void Close(bool isShuttingDown) if (Interlocked.Exchange(ref registeredShutdownNotification, 0) == 1) { // release the shutdown notification handle. - if (null != registeredShutDownWaitHandle) + if (registeredShutDownWaitHandle != null) { registeredShutDownWaitHandle.Unregister(null); registeredShutDownWaitHandle = null; @@ -344,7 +344,7 @@ internal void Close(bool isShuttingDown) // Delete the context only if isShuttingDown != true. isShuttingDown will // be true only when the method is called from RegisterWaitForSingleObject // handler..in which case the context will be freed from the callback. - if (null != shutDownContext) + if (shutDownContext != null) { shutDownContext = null; } @@ -373,7 +373,7 @@ internal void ReportSendOperationComplete() { lock (_syncObject) { - if (null != sendRequestDetails) + if (sendRequestDetails != null) { // report and clear the send request details WSManPluginInstance.ReportWSManOperationComplete(sendRequestDetails, lastErrorReported); @@ -663,7 +663,7 @@ private void HandleServerRemoteSessionClosed( RemoteSessionStateMachineEventArgs eventArgs) { Exception reasonForClose = null; - if (null != eventArgs) + if (eventArgs != null) { reasonForClose = eventArgs.Reason; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs index 2b22ba87d6b..4a7fd90209d 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs @@ -109,7 +109,7 @@ internal void DoClose( } _activeCmdTransportManagers.Clear(); - if (null != _registeredShutDownWaitHandle) + if (_registeredShutDownWaitHandle != null) { // This will not wait for the callback to complete. _registeredShutDownWaitHandle.Unregister(null); @@ -119,14 +119,14 @@ internal void DoClose( // Delete the context only if isShuttingDown != true. isShuttingDown will // be true only when the method is called from RegisterWaitForSingleObject // handler..in which case the context will be freed from the callback. - if (null != _shutDownContext) + if (_shutDownContext != null) { _shutDownContext = null; } // This might happen when client did not send a receive request // but the server is closing - if (null != _requestDetails) + if (_requestDetails != null) { // Notify that no more data is being sent on this transport. WSManNativeApi.WSManPluginReceiveResult( diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index 06e2c185d75..fe9ea5ca9e0 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -916,7 +916,7 @@ internal override void ConnectAsync() DataPriorityType additionalDataType; byte[] additionalData = dataToBeSent.ReadOrRegisterCallback(null, out additionalDataType); - if (null != additionalData) + if (additionalData != null) { // WSMan expects the data to be in XML format (which is text + xml tags) // so convert byte[] into base64 encoded format @@ -1086,7 +1086,7 @@ internal override void CreateAsync() #endregion - if (null != additionalData) + if (additionalData != null) { // WSMan expects the data to be in XML format (which is text + xml tags) // so convert byte[] into base64 encoded format @@ -1476,17 +1476,17 @@ private void Initialize(Uri connectionUri, WSManConnectionInfo connectionInfo) finally { // release resources - if (null != proxyAuthCredentials) + if (proxyAuthCredentials != null) { proxyAuthCredentials.Dispose(); } - if (null != proxyInfo) + if (proxyInfo != null) { proxyInfo.Dispose(); } - if (null != authCredentials) + if (authCredentials != null) { authCredentials.Dispose(); } @@ -1662,7 +1662,7 @@ internal void ClearReceiveOrSendResources(int flags, bool shouldClearSend) { if (shouldClearSend) { - if (null != _sendToRemoteCompleted) + if (_sendToRemoteCompleted != null) { _sendToRemoteCompleted.Dispose(); _sendToRemoteCompleted = null; @@ -1686,7 +1686,7 @@ internal void ClearReceiveOrSendResources(int flags, bool shouldClearSend) _wsManReceiveOperationHandle = IntPtr.Zero; } - if (null != _receivedFromRemote) + if (_receivedFromRemote != null) { _receivedFromRemote.Dispose(); _receivedFromRemote = null; @@ -2403,7 +2403,7 @@ private void SendOneItem() // This will either return data or register callback but doesn't do both. byte[] data = dataToBeSent.ReadOrRegisterCallback(_onDataAvailableToSendCallback, out priorityType); - if (null != data) + if (data != null) { SendData(data, priorityType); } @@ -2485,7 +2485,7 @@ internal override void Dispose(bool isDisposing) // openContent is used by redirection ie., while redirecting to // a new machine and hence this is cleared only when the session // is disposing. - if (isDisposing && (null != _openContent)) + if (isDisposing && (_openContent != null)) { _openContent.Dispose(); _openContent = null; @@ -2523,7 +2523,7 @@ private void CloseSessionAndClearResources() // remove session context from session handles dictionary RemoveSessionTransportManager(_sessionContextID); - if (null != _closeSessionCompleted) + if (_closeSessionCompleted != null) { _closeSessionCompleted.Dispose(); _closeSessionCompleted = null; @@ -2532,7 +2532,7 @@ private void CloseSessionAndClearResources() // Dispose the create session completed callback here, since it is // used for periodic robust connection retry/auto-disconnect // notifications while the shell is active. - if (null != _createSessionCallback) + if (_createSessionCallback != null) { _createSessionCallbackGCHandle.Free(); _createSessionCallback.Dispose(); @@ -2540,7 +2540,7 @@ private void CloseSessionAndClearResources() } // Dispose the OnConnect callback if one present - if (null != _connectSessionCallback) + if (_connectSessionCallback != null) { _connectSessionCallback.Dispose(); _connectSessionCallback = null; @@ -2964,7 +2964,7 @@ internal override void ConnectAsync() internal override void CreateAsync() { byte[] cmdPart1 = serializedPipeline.ReadOrRegisterCallback(null); - if (null != cmdPart1) + if (cmdPart1 != null) { #region SHIM: Redirection code for command code send. @@ -3214,7 +3214,7 @@ internal void ClearReceiveOrSendResources(int flags, bool shouldClearSend) { if (shouldClearSend) { - if (null != _sendToRemoteCompleted) + if (_sendToRemoteCompleted != null) { _sendToRemoteCompleted.Dispose(); _sendToRemoteCompleted = null; @@ -3238,7 +3238,7 @@ internal void ClearReceiveOrSendResources(int flags, bool shouldClearSend) _wsManReceiveOperationHandle = IntPtr.Zero; } - if (null != _receivedFromRemote) + if (_receivedFromRemote != null) { _receivedFromRemote.Dispose(); _receivedFromRemote = null; @@ -3844,7 +3844,7 @@ private void SendOneItem() data = dataToBeSent.ReadOrRegisterCallback(_onDataAvailableToSendCallback, out priorityType); } - if (null != data) + if (data != null) { _isSendingInput = true; SendData(data, priorityType); @@ -3969,19 +3969,19 @@ internal override void Dispose(bool isDisposing) RemoveCmdTransportManager(_cmdContextId); // unregister event handlers - if (null != _sessnTm) + if (_sessnTm != null) { _sessnTm.RobustConnectionsInitiated -= HandleRobustConnectionsInitiated; _sessnTm.RobustConnectionsCompleted -= HandleRobusConnectionsCompleted; } - if (null != _closeCmdCompleted) + if (_closeCmdCompleted != null) { _closeCmdCompleted.Dispose(); _closeCmdCompleted = null; } - if (null != _reconnectCmdCompleted) + if (_reconnectCmdCompleted != null) { _reconnectCmdCompleted.Dispose(); _reconnectCmdCompleted = null; diff --git a/src/System.Management.Automation/engine/remoting/server/OutOfProcServerMediator.cs b/src/System.Management.Automation/engine/remoting/server/OutOfProcServerMediator.cs index f6bb4c6c902..7d08ceec103 100644 --- a/src/System.Management.Automation/engine/remoting/server/OutOfProcServerMediator.cs +++ b/src/System.Management.Automation/engine/remoting/server/OutOfProcServerMediator.cs @@ -133,7 +133,7 @@ protected void OnDataPacketReceived(byte[] rawData, string stream, Guid psGuid) cmdTM = sessionTM.GetCommandTransportManager(psGuid); } - if (null != cmdTM) + if (cmdTM != null) { // not throwing when there is no associated command as the command might have // legitimately closed while the client is sending data. however the client @@ -198,7 +198,7 @@ protected void OnSignalPacketReceived(Guid psGuid) } // dont throw if there is no cmdTM as it might have legitimately closed - if (null != cmdTM) + if (cmdTM != null) { cmdTM.Close(null); } @@ -265,7 +265,7 @@ protected void OnClosePacketReceived(Guid psGuid) } // dont throw if there is no cmdTM as it might have legitimately closed - if (null != cmdTM) + if (cmdTM != null) { cmdTM.Close(null); } @@ -465,7 +465,7 @@ internal static void Run(string initialCommand) { lock (SyncObject) { - if (null != s_singletonInstance) + if (s_singletonInstance != null) { Dbg.Assert(false, "Run should not be called multiple times"); return; diff --git a/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs index 58053275289..906a3d81731 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs @@ -206,7 +206,7 @@ internal ServerPowerShellDriver(PowerShell powershell, PowerShell extraPowerShel RegisterDataStructureHandlerEventHandlers(DataStructureHandler); // set the runspace pool and invoke this powershell - if (null != rsToUse) + if (rsToUse != null) { LocalPowerShell.Runspace = rsToUse; if (extraPowerShell != null) diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs index cc7e3bf645b..711dc0ce389 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs @@ -678,7 +678,7 @@ private void InvokeStartupScripts(RunspaceCreatedEventArgs args) cmdToRun = new Command(_configData.InitializationScriptForOutOfProcessRunspace, true, false); } - if (null != cmdToRun) + if (cmdToRun != null) { InvokeScript(cmdToRun, args); diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs index 02d0a649693..cc8c50e913d 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs @@ -952,14 +952,14 @@ private void HandleNegotiationReceived(object sender, RemoteSessionNegotiationEv /// private void HandleSessionDSHandlerClosing(object sender, EventArgs eventArgs) { - if (null != _runspacePoolDriver) + if (_runspacePoolDriver != null) { _runspacePoolDriver.Close(); } // dispose the session configuration object..this will let them // clean their resources. - if (null != _sessionConfigProvider) + if (_sessionConfigProvider != null) { _sessionConfigProvider.Dispose(); _sessionConfigProvider = null; diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index a750f966e92..f934c1a503c 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -5661,7 +5661,7 @@ internal static object GetAdaptedValue(object obj, string member) { ConsolidatedString typenames = PSObject.GetTypeNames(obj); memberInfo = context.TypeTable.GetMembers(typenames)[member]; - if (null != memberInfo) + if (memberInfo != null) { memberInfo = CloneMemberInfo(memberInfo, obj); } @@ -6203,7 +6203,7 @@ internal static object SetAdaptedValue(object obj, string member, object value) { ConsolidatedString typenames = PSObject.GetTypeNames(obj); memberInfo = context.TypeTable.GetMembers(typenames)[member]; - if (null != memberInfo) + if (memberInfo != null) { memberInfo = PSGetMemberBinder.CloneMemberInfo(memberInfo, obj); } diff --git a/src/System.Management.Automation/engine/serialization.cs b/src/System.Management.Automation/engine/serialization.cs index 0d3e8adf0de..93a1b2aa277 100644 --- a/src/System.Management.Automation/engine/serialization.cs +++ b/src/System.Management.Automation/engine/serialization.cs @@ -3514,7 +3514,7 @@ internal object ReadOneObject(out string streamName) // Convert deserialized object to a user-defined type (specified in a types.ps1xml file) Type targetType = mshSource.GetTargetTypeForDeserialization(_typeTable); - if (null != targetType) + if (targetType != null) { Exception rehydrationException = null; try @@ -6420,14 +6420,14 @@ public void Add(string key, PSPrimitiveDictionary[] value) /// internal static PSPrimitiveDictionary CloneAndAddPSVersionTable(PSPrimitiveDictionary originalHash) { - if ((null != originalHash) && + if ((originalHash != null) && (originalHash.ContainsKey(PSVersionInfo.PSVersionTableName))) { return (PSPrimitiveDictionary)originalHash.Clone(); } PSPrimitiveDictionary result = originalHash; - if (null != originalHash) + if (originalHash != null) { result = (PSPrimitiveDictionary)originalHash.Clone(); } diff --git a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs index f2d67f192cd..eb6b8676931 100644 --- a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs @@ -204,7 +204,7 @@ internal Uri LookupUriFromCommandInfo() if (this.FullHelp.Properties["ModuleName"] != null) { PSNoteProperty moduleNameNP = this.FullHelp.Properties["ModuleName"] as PSNoteProperty; - if (null != moduleNameNP) + if (moduleNameNP != null) { LanguagePrimitives.TryConvertTo(moduleNameNP.Value, CultureInfo.InvariantCulture, out moduleName); @@ -306,7 +306,7 @@ internal static Uri GetUriFromCommandPSObject(PSObject commandFullHelp) PSObject navigationLink = PSObject.AsPSObject(navigationLinkAsObject); PSNoteProperty uriNP = navigationLink.Properties["uri"] as PSNoteProperty; - if (null != uriNP) + if (uriNP != null) { string uriString = string.Empty; LanguagePrimitives.TryConvertTo(uriNP.Value, CultureInfo.InvariantCulture, out uriString); diff --git a/src/System.Management.Automation/help/CabinetNativeApi.cs b/src/System.Management.Automation/help/CabinetNativeApi.cs index 2176be675f6..be6022df4ed 100644 --- a/src/System.Management.Automation/help/CabinetNativeApi.cs +++ b/src/System.Management.Automation/help/CabinetNativeApi.cs @@ -69,7 +69,7 @@ protected override void Dispose(bool disposing) } // Free managed objects within 'if (disposing)' if needed - if (null != fdiContext) + if (fdiContext != null) { fdiContext.Dispose(); } @@ -151,7 +151,7 @@ private void populateDelegates() private void CleanUpDelegates() { // Free GCHandles so that the memory they point to may be unpinned (garbage collected) - if (null != _fdiAllocHandle) + if (_fdiAllocHandle != null) { _fdiAllocHandle.Free(); _fdiFreeHandle.Free(); diff --git a/src/System.Management.Automation/help/CommandHelpProvider.cs b/src/System.Management.Automation/help/CommandHelpProvider.cs index 23be0ce9c8f..56d43991768 100644 --- a/src/System.Management.Automation/help/CommandHelpProvider.cs +++ b/src/System.Management.Automation/help/CommandHelpProvider.cs @@ -372,7 +372,7 @@ private HelpInfo GetHelpInfo(CommandInfo commandInfo, bool reportErrors, bool se } } - if (null != result) + if (result != null) { if (isScriptCommand && result.GetUriForOnlineHelp() == null) { @@ -788,7 +788,7 @@ private HelpInfo GetFromCommandCache(string helpFileIdentifier, string commandNa HelpInfo result = GetCache(key); // Win8: Win8:477680: When Function/Workflow Use External Help, Category Property is "Cmdlet" - if ((null != result) && (result.HelpCategory != helpCategory)) + if ((result != null) && (result.HelpCategory != helpCategory)) { MamlCommandHelpInfo original = (MamlCommandHelpInfo)result; result = original.Copy(helpCategory); @@ -813,7 +813,7 @@ private HelpInfo GetFromCommandCache(string helpFileIdentifier, CommandInfo comm if ((commandInfo.Module != null) && (!string.IsNullOrEmpty(commandInfo.Prefix))) { MamlCommandHelpInfo newMamlHelpInfo = GetFromCommandCacheByRemovingPrefix(helpFileIdentifier, commandInfo); - if (null != newMamlHelpInfo) + if (newMamlHelpInfo != null) { // caching the changed help content under the prefixed name for faster // retrieval later. @@ -844,7 +844,7 @@ private HelpInfo GetFromCommandCacheOrCmdletInfo(CmdletInfo cmdletInfo) { MamlCommandHelpInfo newMamlHelpInfo = GetFromCommandCacheByRemovingPrefix(cmdletInfo.ModuleName, cmdletInfo); - if (null != newMamlHelpInfo) + if (newMamlHelpInfo != null) { // Noun exists only for cmdlets...since prefix will change the Noun, updating // the help content accordingly @@ -893,7 +893,7 @@ private MamlCommandHelpInfo GetFromCommandCacheByRemovingPrefix(string helpIdent Microsoft.PowerShell.Commands.ModuleCmdletBase.RemovePrefixFromCommandName(cmdInfo.Name, cmdInfo.Prefix), cmdInfo.HelpCategory) as MamlCommandHelpInfo; - if (null != originalHelpInfo) + if (originalHelpInfo != null) { result = originalHelpInfo.Copy(); // command's name can be changed using -Prefix while importing module.To give better user experience for diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index 2015d34665b..6925ec08633 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -290,7 +290,7 @@ protected override void ProcessRecord() else { // write first help object only once. - if (null != firstHelpInfoObject) + if (firstHelpInfoObject != null) { WriteObjectsOrShowOnlineHelp(firstHelpInfoObject, false); firstHelpInfoObject = null; @@ -523,7 +523,7 @@ private void WriteObjectsOrShowOnlineHelp(HelpInfo helpInfo, bool showFullHelp) // show online help s_tracer.WriteLine("Preparing to show help online."); Uri onlineUri = helpInfo.GetUriForOnlineHelp(); - if (null != onlineUri) + if (onlineUri != null) { onlineUriFound = true; LaunchOnlineHelp(onlineUri); @@ -628,7 +628,7 @@ private void LaunchOnlineHelp(Uri uriToLaunch) exception = we; } - if (null != exception) + if (exception != null) { if (wrapCaughtException) throw PSTraceSource.NewInvalidOperationException(exception, HelpErrors.CannotLaunchURI, uriToLaunch.OriginalString); @@ -708,7 +708,7 @@ private static bool DoesCurrentRunspaceIncludeCoreHelpCmdlet() foreach (SessionStateCommandEntry getHelpEntry in publicGetHelpEntries) { SessionStateCmdletEntry getHelpCmdlet = getHelpEntry as SessionStateCmdletEntry; - if ((null != getHelpCmdlet) && (getHelpCmdlet.ImplementingType.Equals(typeof(GetHelpCommand)))) + if ((getHelpCmdlet != null) && (getHelpCmdlet.ImplementingType.Equals(typeof(GetHelpCommand)))) { return true; } @@ -756,7 +756,7 @@ public static string GetHelpUri(PSObject commandInfoPSObject) } AliasInfo aliasInfo = cmdInfo as AliasInfo; - if ((null != aliasInfo) && + if ((aliasInfo != null) && (null != aliasInfo.ExternalCommandMetadata) && (!string.IsNullOrEmpty(aliasInfo.ExternalCommandMetadata.HelpUri))) { @@ -776,7 +776,7 @@ public static string GetHelpUri(PSObject commandInfoPSObject) // Win8: 651300 if core get-help is present in the runspace (and it is the only get-help command), use // help system directly and avoid perf penalty. var currentContext = System.Management.Automation.Runspaces.LocalPipeline.GetExecutionContextFromTLS(); - if ((null != currentContext) && (null != currentContext.HelpSystem)) + if ((currentContext != null) && (null != currentContext.HelpSystem)) { HelpRequest helpRequest = new HelpRequest(cmdName, cmdInfo.HelpCategory); helpRequest.ProviderContext = new ProviderContext( @@ -809,7 +809,7 @@ Uri result in { Collection helpInfos = getHelpPS.Invoke(); - if (null != helpInfos) + if (helpInfos != null) { for (int index = 0; index < helpInfos.Count; index++) { @@ -817,7 +817,7 @@ Uri result in if (LanguagePrimitives.TryConvertTo(helpInfos[index], out helpInfo)) { Uri result = helpInfo.GetUriForOnlineHelp(); - if (null != result) + if (result != null) { return result.OriginalString; } diff --git a/src/System.Management.Automation/help/HelpProviderWithCache.cs b/src/System.Management.Automation/help/HelpProviderWithCache.cs index 261015364d5..a84ff6c8ebc 100644 --- a/src/System.Management.Automation/help/HelpProviderWithCache.cs +++ b/src/System.Management.Automation/help/HelpProviderWithCache.cs @@ -123,7 +123,7 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool if (!this.CacheFullyLoaded) { IEnumerable result = DoSearchHelp(searchHelpRequest); - if (null != result) + if (result != null) { foreach (HelpInfo helpInfoToReturn in result) { diff --git a/src/System.Management.Automation/help/HelpSystem.cs b/src/System.Management.Automation/help/HelpSystem.cs index 92674f32dbf..70e03dbe4b0 100644 --- a/src/System.Management.Automation/help/HelpSystem.cs +++ b/src/System.Management.Automation/help/HelpSystem.cs @@ -247,7 +247,7 @@ internal bool VerboseHelpErrors internal Collection GetSearchPaths() { // return the cache if already present. - if (null != _searchPaths) + if (_searchPaths != null) { return _searchPaths; } diff --git a/src/System.Management.Automation/help/MamlUtil.cs b/src/System.Management.Automation/help/MamlUtil.cs index 7ddf462176f..a25acec8ab6 100644 --- a/src/System.Management.Automation/help/MamlUtil.cs +++ b/src/System.Management.Automation/help/MamlUtil.cs @@ -55,7 +55,7 @@ internal static void AddCommonProperties(PSObject maml1, PSObject maml2) if (maml1.Properties["PSSnapIn"] == null) { PSPropertyInfo snapInProperty = maml2.Properties["PSSnapIn"]; - if (null != snapInProperty) + if (snapInProperty != null) { maml1.Properties.Add(new PSNoteProperty("PSSnapIn", snapInProperty.Value)); } @@ -64,7 +64,7 @@ internal static void AddCommonProperties(PSObject maml1, PSObject maml2) if (maml1.Properties["ModuleName"] == null) { PSPropertyInfo moduleNameProperty = maml2.Properties["ModuleName"]; - if (null != moduleNameProperty) + if (moduleNameProperty != null) { maml1.Properties.Add(new PSNoteProperty("ModuleName", moduleNameProperty.Value)); } @@ -133,7 +133,7 @@ internal static void OverrideParameters(PSObject maml1, PSObject maml2) string param2Name = ""; PSPropertyInfo m2propertyInfo = m2paramObj.Properties["Name"]; - if (null != m2propertyInfo) + if (m2propertyInfo != null) { if (!LanguagePrimitives.TryConvertTo(m2propertyInfo.Value, out param2Name)) { @@ -147,7 +147,7 @@ internal static void OverrideParameters(PSObject maml1, PSObject maml2) string param1Name = ""; PSPropertyInfo m1PropertyInfo = m1ParamObj.Properties["Name"]; - if (null != m1PropertyInfo) + if (m1PropertyInfo != null) { if (!LanguagePrimitives.TryConvertTo(m1PropertyInfo.Value, out param1Name)) { @@ -239,7 +239,7 @@ internal static void PrependPropertyValue(PSObject maml1, PSObject maml2, string // For maml2: Add as collection or single item. No-op if PSPropertyInfo propertyInfo2 = GetPropertyInfo(maml2, path); - if (null != propertyInfo2) + if (propertyInfo2 != null) { var array = propertyInfo2.Value as Array; if (array != null) @@ -257,7 +257,7 @@ internal static void PrependPropertyValue(PSObject maml1, PSObject maml2, string // For maml1: Add as collection or single item. Do nothing if null or some other type. PSPropertyInfo propertyInfo1 = GetPropertyInfo(maml1, path); - if (null != propertyInfo1) + if (propertyInfo1 != null) { if (!shouldOverride) { diff --git a/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs b/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs index eddf4c3fd56..02ded508adb 100644 --- a/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs +++ b/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs @@ -304,7 +304,7 @@ private Dictionary, UpdatableHelpModuleInfo> GetModuleInf if (!helpModules.ContainsKey(keyTuple)) { List availableModules = Utils.GetModules(name.Key, context); - if (null != availableModules) + if (availableModules != null) { foreach (PSModuleInfo module in availableModules) { diff --git a/src/System.Management.Automation/namespaces/FileSystemContentStream.cs b/src/System.Management.Automation/namespaces/FileSystemContentStream.cs index ae20178e831..419f869be79 100644 --- a/src/System.Management.Automation/namespaces/FileSystemContentStream.cs +++ b/src/System.Management.Automation/namespaces/FileSystemContentStream.cs @@ -951,7 +951,7 @@ private void WaitForChanges(string filePath, FileMode fileMode, FileAccess fileA { bool isTaskCompleted = tcs.Task.Wait(500); - if (null != errorEventArgs) + if (errorEventArgs != null) { throw errorEventArgs.GetException(); } diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 4648f6a6052..7a1c9b2b3fd 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -316,7 +316,7 @@ public string GetHelpMaml(string helpItemName, string path) } finally { - if (null != reader) + if (reader != null) { ((IDisposable)reader).Dispose(); } @@ -1239,11 +1239,11 @@ private FileSystemInfo GetFileSystemItem(string path, ref bool isContainer, bool bool filterHidden = false; // "Hidden" is specified somewhere in the expression bool switchFilterHidden = false; // "Hidden" is specified somewhere in the parameters - if (null != evaluator) + if (evaluator != null) { filterHidden = evaluator.ExistsInExpression(FileAttributes.Hidden); } - if (null != switchEvaluator) + if (switchEvaluator != null) { switchFilterHidden = switchEvaluator.ExistsInExpression(FileAttributes.Hidden); } @@ -1563,12 +1563,12 @@ private void GetPathItems( bool filterHidden = false; // "Hidden" is specified somewhere in the expression bool switchFilterHidden = false; // "Hidden" is specified somewhere in the parameters - if (null != evaluator) + if (evaluator != null) { attributeFilter = evaluator.Evaluate(fileInfo.Attributes); // expressions filterHidden = evaluator.ExistsInExpression(FileAttributes.Hidden); } - if (null != switchEvaluator) + if (switchEvaluator != null) { switchAttributeFilter = switchEvaluator.Evaluate(fileInfo.Attributes); // switch parameters switchFilterHidden = switchEvaluator.ExistsInExpression(FileAttributes.Hidden); @@ -1689,12 +1689,12 @@ private void Dir( // 'Hidden' is specified somewhere in the parameters bool switchFilterHidden = false; - if (null != evaluator) + if (evaluator != null) { attributeFilter = evaluator.Evaluate(filesystemInfo.Attributes); filterHidden = evaluator.ExistsInExpression(FileAttributes.Hidden); } - if (null != switchEvaluator) + if (switchEvaluator != null) { switchAttributeFilter = switchEvaluator.Evaluate(filesystemInfo.Attributes); switchFilterHidden = switchEvaluator.ExistsInExpression(FileAttributes.Hidden); @@ -1747,11 +1747,11 @@ private void Dir( bool isFilterHiddenSpecified = false; // "Hidden" is specified somewhere in the expression bool isSwitchFilterHiddenSpecified = false; // "Hidden" is specified somewhere in the parameters - if (null != evaluator) + if (evaluator != null) { isFilterHiddenSpecified = evaluator.ExistsInExpression(FileAttributes.Hidden); } - if (null != switchEvaluator) + if (switchEvaluator != null) { isSwitchFilterHiddenSpecified = switchEvaluator.ExistsInExpression(FileAttributes.Hidden); } diff --git a/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs b/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs index 9ece1e4e247..151149af58f 100644 --- a/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs +++ b/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs @@ -221,7 +221,7 @@ private TransactedRegistryKey(SafeRegistryHandle hkey, bool writable, bool syste } // We want to take our own clone so we can dispose it when we want and // aren't susceptible to the caller disposing it. - if (null != transaction) + if (transaction != null) { _myTransaction = transaction.Clone(); _myTransactionHandle = txHandle; @@ -240,7 +240,7 @@ private SafeTransactionHandle GetTransactionHandle() // If myTransaction is not null and is not the same as Transaction.Current // this is an invalid operation. The transaction within which the RegistryKey object was created // needs to be the same as the transaction being used now. - if (null != _myTransaction) + if (_myTransaction != null) { if (!_myTransaction.Equals(Transaction.Current)) { @@ -288,7 +288,7 @@ private void Dispose(bool disposing) } } - if (null != _myTransaction) + if (_myTransaction != null) { // Dispose the transaction because we cloned it. try diff --git a/src/System.Management.Automation/utils/CryptoUtils.cs b/src/System.Management.Automation/utils/CryptoUtils.cs index c29cb7c31cd..448b3f08c9e 100644 --- a/src/System.Management.Automation/utils/CryptoUtils.cs +++ b/src/System.Management.Automation/utils/CryptoUtils.cs @@ -859,7 +859,7 @@ protected void Dispose(bool disposing) { if (disposing) { - if (null != _hSessionKey) + if (_hSessionKey != null) { if (!_hSessionKey.IsInvalid) { @@ -875,7 +875,7 @@ protected void Dispose(bool disposing) if (null == s_hStaticRSAKey) { - if (null != _hRSAKey) + if (_hRSAKey != null) { if (!_hRSAKey.IsInvalid) { @@ -887,7 +887,7 @@ protected void Dispose(bool disposing) if (null == s_hStaticProv) { - if (null != _hProv) + if (_hProv != null) { if (!_hProv.IsInvalid) { diff --git a/src/System.Management.Automation/utils/ExecutionExceptions.cs b/src/System.Management.Automation/utils/ExecutionExceptions.cs index d846144d98a..242ea19ada0 100644 --- a/src/System.Management.Automation/utils/ExecutionExceptions.cs +++ b/src/System.Management.Automation/utils/ExecutionExceptions.cs @@ -144,7 +144,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont } base.GetObjectData(info, context); - bool hasErrorRecord = (null != _errorRecord); + bool hasErrorRecord = (_errorRecord != null); info.AddValue("HasErrorRecord", hasErrorRecord); if (hasErrorRecord) info.AddValue("ErrorRecord", _errorRecord); @@ -533,9 +533,9 @@ protected ActionPreferenceStopException(SerializationInfo info, public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - if (null != info) + if (info != null) { - bool hasErrorRecord = (null != _errorRecord); + bool hasErrorRecord = (_errorRecord != null); info.AddValue("HasErrorRecord", hasErrorRecord); if (hasErrorRecord) { @@ -702,7 +702,7 @@ protected ParentContainsErrorRecordException( public override string Message { get { - return _message ?? (_message = (null != _wrapperException) ? _wrapperException.Message : String.Empty); + return _message ?? (_message = (_wrapperException != null) ? _wrapperException.Message : String.Empty); } } diff --git a/src/System.Management.Automation/utils/PSTelemetryWrapper.cs b/src/System.Management.Automation/utils/PSTelemetryWrapper.cs index 969ef39d016..707093829b8 100644 --- a/src/System.Management.Automation/utils/PSTelemetryWrapper.cs +++ b/src/System.Management.Automation/utils/PSTelemetryWrapper.cs @@ -125,7 +125,7 @@ internal static bool IsEnabled public static void TraceMessage(string message, T arguments) { - if (null != s_eventSourceOptionsForWrite) + if (s_eventSourceOptionsForWrite != null) { try { From 0e50d2a58a3f103a91eaa5f46a9811eeb010ba60 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 13:36:43 +0500 Subject: [PATCH 02/27] Replace \((null) != (\w+.\w+)\) -> ($2 != $1) --- .../NewCimInstanceCommand.cs | 4 ++-- .../Common/WebRequestPSCmdlet.Common.cs | 2 +- .../common/FormatViewGenerator_List.cs | 4 ++-- .../common/FormatViewGenerator_Table.cs | 4 ++-- .../engine/CmdletParameterBinderController.cs | 2 +- .../engine/ErrorPackage.cs | 8 ++++---- .../engine/MshObject.cs | 4 ++-- .../engine/ParameterBinderBase.cs | 2 +- .../hostifaces/NativeCultureResolver.cs | 2 +- .../engine/hostifaces/PowerShell.cs | 8 ++++---- .../engine/hostifaces/RunspacePoolInternal.cs | 2 +- .../engine/pipeline.cs | 6 +++--- .../remoting/fanin/BaseTransportManager.cs | 4 ++-- .../engine/remoting/fanin/WSManPlugin.cs | 2 +- .../remoting/fanin/WSManTransportManager.cs | 20 +++++++++---------- .../help/HelpCommands.cs | 4 ++-- .../help/HelpSystem.cs | 2 +- .../namespaces/FileSystemProvider.cs | 2 +- .../utils/ExecutionExceptions.cs | 2 +- 19 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs index 9dd8c1fcb0a..b4fa211dbef 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimInstanceCommand.cs @@ -317,11 +317,11 @@ protected override void ProcessRecord() if (this.ClientOnly) { string conflictParameterName = null; - if (null != this.ComputerName) + if (this.ComputerName != null) { conflictParameterName = @"ComputerName"; } - else if (null != this.CimSession) + else if (this.CimSession != null) { conflictParameterName = @"CimSession"; } 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 ce13916ae3c..8b125d03475 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 @@ -947,7 +947,7 @@ internal virtual HttpClient GetHttpClient(bool handleRedirect) handler.Proxy = WebSession.Proxy; } - if (null != WebSession.Certificates) + if (WebSession.Certificates != null) { handler.ClientCertificates.AddRange(WebSession.Certificates); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs index 69d7286e6a2..8b67338d357 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs @@ -16,7 +16,7 @@ internal sealed class ListViewGenerator : ViewGenerator internal override void Initialize(TerminatingErrorContext terminatingErrorContext, MshExpressionFactory mshExpressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters formatParameters) { base.Initialize(terminatingErrorContext, mshExpressionFactory, db, view, formatParameters); - if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) { _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl; } @@ -26,7 +26,7 @@ internal override void Initialize(TerminatingErrorContext errorContext, MshExpre PSObject so, TypeInfoDataBase db, FormattingCommandLineParameters parameters) { base.Initialize(errorContext, expressionFactory, so, db, parameters); - if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) { _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl; } diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs index b00aa6fc939..d9e6d1ef32d 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs @@ -17,7 +17,7 @@ internal sealed class TableViewGenerator : ViewGenerator internal override void Initialize(TerminatingErrorContext terminatingErrorContext, MshExpressionFactory mshExpressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters formatParameters) { base.Initialize(terminatingErrorContext, mshExpressionFactory, db, view, formatParameters); - if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) { _tableBody = (TableControlBody)this.dataBaseInfo.view.mainControl; } @@ -29,7 +29,7 @@ internal override void Initialize(TerminatingErrorContext errorContext, MshExpre { base.Initialize(errorContext, expressionFactory, so, db, parameters); - if ((null != this.dataBaseInfo) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) { _tableBody = (TableControlBody)this.dataBaseInfo.view.mainControl; } diff --git a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs index 6eb9a2ce35b..3b07a8a80d4 100644 --- a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs +++ b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs @@ -909,7 +909,7 @@ private void VerifyArgumentsProcessed(ParameterBindingException originalBindingE else { string argument = StringLiterals.DollarNull; - if (null != parameter.ArgumentValue) + if (parameter.ArgumentValue != null) { try { diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index 5fa0b90a615..c696ec792c1 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -278,7 +278,7 @@ public string Reason _reasonIsExceptionType = false; if (!String.IsNullOrEmpty(_errorRecord._reasonOverride)) return _errorRecord._reasonOverride; - if (null != _errorRecord.Exception) + if (_errorRecord.Exception != null) { _reasonIsExceptionType = true; return _errorRecord.Exception.GetType().Name; @@ -309,7 +309,7 @@ public string TargetName { if (!String.IsNullOrEmpty(_errorRecord._targetNameOverride)) return _errorRecord._targetNameOverride; - if (null != _errorRecord.TargetObject) + if (_errorRecord.TargetObject != null) { string targetInString; try @@ -347,7 +347,7 @@ public string TargetType { if (!String.IsNullOrEmpty(_errorRecord._targetTypeOverride)) return _errorRecord._targetTypeOverride; - if (null != _errorRecord.TargetObject) + if (_errorRecord.TargetObject != null) { return _errorRecord.TargetObject.GetType().Name; } @@ -1401,7 +1401,7 @@ public ErrorRecord(ErrorRecord errorRecord, _reasonOverride = errorRecord._reasonOverride; _targetNameOverride = errorRecord._targetNameOverride; _targetTypeOverride = errorRecord._targetTypeOverride; - if (null != errorRecord.ErrorDetails) + if (errorRecord.ErrorDetails != null) _errorDetails = new ErrorDetails(errorRecord.ErrorDetails); SetInvocationInfo(errorRecord._invocationInfo); _scriptStackTrace = errorRecord._scriptStackTrace; diff --git a/src/System.Management.Automation/engine/MshObject.cs b/src/System.Management.Automation/engine/MshObject.cs index e128098d2a0..6ffa53ecf31 100644 --- a/src/System.Management.Automation/engine/MshObject.cs +++ b/src/System.Management.Automation/engine/MshObject.cs @@ -171,7 +171,7 @@ private static PSMemberInfoInternalCollection AdapterGetMembersDelegate(PS private static PSMemberInfoInternalCollection DotNetGetMembersDelegate(PSObject msjObj) where T : PSMemberInfo { // Don't lookup dotnet members if the object doesn't insist. - if (null != msjObj.InternalBaseDotNetAdapter) + if (msjObj.InternalBaseDotNetAdapter != null) { PSMemberInfoInternalCollection retValue = msjObj.InternalBaseDotNetAdapter.BaseGetMembers(msjObj._immediateBaseObject); PSObject.memberResolution.WriteLine("DotNet members: {0}.", retValue.VisibleCount); @@ -184,7 +184,7 @@ private static PSMemberInfoInternalCollection DotNetGetMembersDelegate(PSO private static T DotNetGetMemberDelegate(PSObject msjObj, string name) where T : PSMemberInfo { // Don't lookup dotnet member if the object doesn't insist. - if (null != msjObj.InternalBaseDotNetAdapter) + if (msjObj.InternalBaseDotNetAdapter != null) { T retValue = msjObj.InternalBaseDotNetAdapter.BaseGetMember(msjObj._immediateBaseObject, name); PSObject.memberResolution.WriteLine("DotNet member: {0}.", retValue == null ? "not found" : retValue.Name); diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index bf51f267c26..4a5e3685753 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -255,7 +255,7 @@ private void ValidatePSTypeName( PSInvalidCastException e = new PSInvalidCastException(ErrorCategory.InvalidArgument.ToString(), null, ParameterBinderStrings.MismatchedPSTypeName, - (_invocationInfo != null) && (null != _invocationInfo.MyCommand) ? _invocationInfo.MyCommand.Name : string.Empty, + (_invocationInfo != null) && (_invocationInfo.MyCommand != null) ? _invocationInfo.MyCommand.Name : string.Empty, parameterMetadata.Name, parameterMetadata.Type, parameterValue.GetType(), diff --git a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs index 540250a1013..6a79b5b9f86 100644 --- a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs +++ b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs @@ -66,7 +66,7 @@ public override CultureInfo Parent // This is required because there is difference in the parent hierarchy // between CLR and Windows for Chinese. Ex: Native windows has // zh-CN->zh-Hans->neutral whereas CLR has zh-CN->zh-CHS->zh-Hans->neutral - if ((null != base.Parent) && (!string.IsNullOrEmpty(base.Parent.Name))) + if ((base.Parent != null) && (!string.IsNullOrEmpty(base.Parent.Name))) { return ImmediateParent; } diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index 5ea2283efca..6f4b85443c4 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -881,7 +881,7 @@ public static PowerShell Create(InitialSessionState initialSessionState) [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "ps", Justification = "ps represents PowerShell and is used at many places.")] public PowerShell CreateNestedPowerShell() { - if ((_worker != null) && (null != _worker.CurrentlyRunningPipeline)) + if ((_worker != null) && (_worker.CurrentlyRunningPipeline != null)) { PowerShell result = new PowerShell(new PSCommand(), null, _worker.CurrentlyRunningPipeline.Runspace); @@ -4303,7 +4303,7 @@ private void CoreInvokeRemoteHelper(PSDataCollection in EndInvokeAsyncResult = null; if ((PSInvocationState.Failed == InvocationStateInfo.State) && - (null != InvocationStateInfo.Reason)) + (InvocationStateInfo.Reason != null)) { throw InvocationStateInfo.Reason; } @@ -5104,7 +5104,7 @@ internal void CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, bool isSync) { Runspace runspace = null; - if ((_settings != null) && (null != _settings.Host)) + if ((_settings != null) && (_settings.Host != null)) { runspace = RunspaceFactory.CreateRunspace(_settings.Host); } @@ -5341,7 +5341,7 @@ internal void InternalClearSuppressExceptions() { try { - if ((_settings != null) && (null != _settings.WindowsIdentityToImpersonate)) + if ((_settings != null) && (_settings.WindowsIdentityToImpersonate != null)) { _settings.WindowsIdentityToImpersonate.Dispose(); _settings.WindowsIdentityToImpersonate = null; diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs index ff92d87b0ed..e7bfb171741 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs @@ -726,7 +726,7 @@ public Runspace GetRunspace() // throw the exception that occurred while // processing the async operation - if (null != asyncResult.Exception) + if (asyncResult.Exception != null) { throw asyncResult.Exception; } diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index 04420bba60b..bca3c05e535 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -371,7 +371,7 @@ internal int AddCommand(CommandProcessorBase commandProcessor, int readFromComma // "PipelineProcessor.AddCommand(): UpstreamPipe == null" throw PSTraceSource.NewInvalidOperationException(); } - if (null != UpstreamPipe.DownstreamCmdlet) + if (UpstreamPipe.DownstreamCmdlet != null) { throw PSTraceSource.NewInvalidOperationException( PipelineStrings.PipeAlreadyTaken); @@ -1302,7 +1302,7 @@ private void DisposeCommands() catch (Exception e) // Catch-all OK, 3rd party callout. { InvocationInfo myInvocation = null; - if (null != commandProcessor.Command) + if (commandProcessor.Command != null) myInvocation = commandProcessor.Command.MyInvocation; ProviderInvocationException pie = @@ -1388,7 +1388,7 @@ internal bool RecordFailure(Exception e, InternalCommand command) { Exception ex = e; while ((ex is TargetInvocationException || ex is CmdletInvocationException) - && (null != ex.InnerException)) + && (ex.InnerException != null)) { ex = ex.InnerException; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs index a12e2ff0299..fd554f0a4e7 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs @@ -832,12 +832,12 @@ internal void ServicePendingCallbacks(object objectToProcess) if (rcvdDataInfo != null) { // Handling transport exception in thread-pool thread - if (null != rcvdDataInfo.transportError) + if (rcvdDataInfo.transportError != null) { RaiseErrorHandler(rcvdDataInfo.transportError); break; } - else if (null != rcvdDataInfo.privateData) + else if (rcvdDataInfo.privateData != null) { ProcessPrivateData(rcvdDataInfo.privateData); } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index be474c7bfa2..2c08a88a81b 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -953,7 +953,7 @@ private PSSenderInfo GetPSSenderInfo( // Construct PSIdentity PSCertificateDetails psCertDetails = null; // Construct Certificate Details - if (null != senderDetails.certificateDetails) + if (senderDetails.certificateDetails != null) { psCertDetails = new PSCertificateDetails( senderDetails.certificateDetails.subject, diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index fe9ea5ca9e0..eb573acd943 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -1415,7 +1415,7 @@ private void Initialize(Uri connectionUri, WSManConnectionInfo connectionInfo) // use credential based authentication string userName = null; System.Security.SecureString password = null; - if ((null != connectionInfo.Credential) && (!string.IsNullOrEmpty(connectionInfo.Credential.UserName))) + if ((connectionInfo.Credential != null) && (!string.IsNullOrEmpty(connectionInfo.Credential.UserName))) { userName = connectionInfo.Credential.UserName; password = connectionInfo.Credential.Password; @@ -1900,7 +1900,7 @@ private static void OnCreateSessionCallback(IntPtr operationContext, // openContent is used by redirection ie., while redirecting to // a new machine.. this is not needed anymore as the connection // is successfully established. - if (null != sessionTM._openContent) + if (sessionTM._openContent != null) { sessionTM._openContent.Dispose(); sessionTM._openContent = null; @@ -2008,7 +2008,7 @@ private static void OnRemoteSessionDisconnectCompleted(IntPtr operationContext, //LOG ETW EVENTS // Dispose the OnDisconnect callback as it is not needed anymore - if (null != sessionTM._disconnectSessionCompleted) + if (sessionTM._disconnectSessionCompleted != null) { sessionTM._disconnectSessionCompleted.Dispose(); sessionTM._disconnectSessionCompleted = null; @@ -2076,7 +2076,7 @@ private static void OnRemoteSessionReconnectCompleted(IntPtr operationContext, //Add ETW events // Dispose the OnCreate callback as it is not needed anymore - if (null != sessionTM._reconnectSessionCompleted) + if (sessionTM._reconnectSessionCompleted != null) { sessionTM._reconnectSessionCompleted.Dispose(); sessionTM._reconnectSessionCompleted = null; @@ -2207,7 +2207,7 @@ private static void OnRemoteSessionConnectCallback(IntPtr operationContext, } //dispose openContent - if (null != sessionTM._openContent) + if (sessionTM._openContent != null) { sessionTM._openContent.Dispose(); sessionTM._openContent = null; @@ -2380,7 +2380,7 @@ private static void OnRemoteSessionDataReceived(IntPtr operationContext, } WSManNativeApi.WSManReceiveDataResult dataReceived = WSManNativeApi.WSManReceiveDataResult.UnMarshal(data); - if (null != dataReceived.data) + if (dataReceived.data != null) { tracer.WriteLine("Session Received Data : {0}", dataReceived.data.Length); PSEtwLog.LogAnalyticInformational( @@ -3303,7 +3303,7 @@ private static void OnCreateCmdCompleted(IntPtr operationContext, cmdTM.RunspacePoolInstanceId.ToString(), cmdTM.powershellInstanceId.ToString()); // dispose the cmdCompleted callback as it is not needed any more - if (null != cmdTM._createCmdCompleted) + if (cmdTM._createCmdCompleted != null) { cmdTM._createCmdCompletedGCHandle.Free(); cmdTM._createCmdCompleted.Dispose(); @@ -3400,7 +3400,7 @@ private static void OnConnectCmdCompleted(IntPtr operationContext, } // dispose the cmdCompleted callback as it is not needed any more - if (null != cmdTM._connectCmdCompleted) + if (cmdTM._connectCmdCompleted != null) { cmdTM._connectCmdCompleted.Dispose(); cmdTM._connectCmdCompleted = null; @@ -3655,7 +3655,7 @@ private static void OnRemoteCmdDataReceived(IntPtr operationContext, } WSManNativeApi.WSManReceiveDataResult dataReceived = WSManNativeApi.WSManReceiveDataResult.UnMarshal(data); - if (null != dataReceived.data) + if (dataReceived.data != null) { tracer.WriteLine("Cmd Received Data : {0}", dataReceived.data.Length); PSEtwLog.LogAnalyticInformational( @@ -3772,7 +3772,7 @@ private static void OnRemoteCmdSignalCompleted(IntPtr operationContext, cmdTM._cmdSignalOperationHandle = IntPtr.Zero; } - if (null != cmdTM._signalCmdCompleted) + if (cmdTM._signalCmdCompleted != null) { cmdTM._signalCmdCompleted.Dispose(); cmdTM._signalCmdCompleted = null; diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index 6925ec08633..c85869e5998 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -757,7 +757,7 @@ public static string GetHelpUri(PSObject commandInfoPSObject) AliasInfo aliasInfo = cmdInfo as AliasInfo; if ((aliasInfo != null) && - (null != aliasInfo.ExternalCommandMetadata) && + (aliasInfo.ExternalCommandMetadata != null) && (!string.IsNullOrEmpty(aliasInfo.ExternalCommandMetadata.HelpUri))) { return aliasInfo.ExternalCommandMetadata.HelpUri; @@ -776,7 +776,7 @@ public static string GetHelpUri(PSObject commandInfoPSObject) // Win8: 651300 if core get-help is present in the runspace (and it is the only get-help command), use // help system directly and avoid perf penalty. var currentContext = System.Management.Automation.Runspaces.LocalPipeline.GetExecutionContextFromTLS(); - if ((currentContext != null) && (null != currentContext.HelpSystem)) + if ((currentContext != null) && (currentContext.HelpSystem != null)) { HelpRequest helpRequest = new HelpRequest(cmdName, cmdInfo.HelpCategory); helpRequest.ProviderContext = new ProviderContext( diff --git a/src/System.Management.Automation/help/HelpSystem.cs b/src/System.Management.Automation/help/HelpSystem.cs index 70e03dbe4b0..78bea023414 100644 --- a/src/System.Management.Automation/help/HelpSystem.cs +++ b/src/System.Management.Automation/help/HelpSystem.cs @@ -254,7 +254,7 @@ internal Collection GetSearchPaths() _searchPaths = new Collection(); // add loaded modules paths to the search path - if (null != ExecutionContext.Modules) + if (ExecutionContext.Modules != null) { foreach (PSModuleInfo loadedModule in ExecutionContext.Modules.ModuleTable.Values) { diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 7a1c9b2b3fd..51612dcada1 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -142,7 +142,7 @@ internal override bool IsFilterSet() if (fspDynamicParam != null) { attributeFilterSet = ( - (null != fspDynamicParam.Attributes) + (fspDynamicParam.Attributes != null) || (fspDynamicParam.Directory) || (fspDynamicParam.File) || (fspDynamicParam.Hidden) diff --git a/src/System.Management.Automation/utils/ExecutionExceptions.cs b/src/System.Management.Automation/utils/ExecutionExceptions.cs index 242ea19ada0..468634d90dc 100644 --- a/src/System.Management.Automation/utils/ExecutionExceptions.cs +++ b/src/System.Management.Automation/utils/ExecutionExceptions.cs @@ -36,7 +36,7 @@ internal CmdletInvocationException(ErrorRecord errorRecord) throw new ArgumentNullException("errorRecord"); } _errorRecord = errorRecord; - if (null != errorRecord.Exception) + if (errorRecord.Exception != null) { // 2005/04/13-JonN Can't do this in an unsealed class: HelpLink = errorRecord.Exception.HelpLink; // Exception.Source is set by Throw From da71c6f58159dc5a777e376d79d2fbfd6b460317 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 13:50:57 +0500 Subject: [PATCH 03/27] Replace '\((null) != (\w+) ' -> '($2 != $1 ' --- .../commands/management/Service.cs | 4 ++-- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 6 +++--- .../commands/utility/WebCmdlet/FormObject.cs | 2 +- .../commands/utility/compare-object.cs | 2 +- src/Microsoft.WSMan.Management/ConfigProvider.cs | 4 ++-- .../FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs | 2 +- .../engine/CommandProcessorBase.cs | 4 ++-- .../engine/MshCommandRuntime.cs | 2 +- .../engine/ParameterBinderBase.cs | 2 +- src/System.Management.Automation/engine/Pipe.cs | 2 +- src/System.Management.Automation/engine/ShellVariable.cs | 4 ++-- .../engine/parser/TypeResolver.cs | 2 +- src/System.Management.Automation/engine/pipeline.cs | 2 +- .../engine/remoting/fanin/OutOfProcTransportManager.cs | 2 +- .../engine/remoting/fanin/PriorityCollection.cs | 2 +- .../engine/remoting/fanin/WSManPlugin.cs | 2 +- .../help/CommandHelpProvider.cs | 2 +- src/System.Management.Automation/logging/MshLog.cs | 6 +++--- .../logging/eventlog/EventLogLogProvider.cs | 6 +++--- .../utils/CommandDiscoveryExceptions.cs | 2 +- .../utils/ExecutionExceptions.cs | 2 +- .../utils/SessionStateExceptions.cs | 6 +++--- 22 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 5192656cb79..8b70d47467b 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -466,9 +466,9 @@ private void IncludeExcludeAdd( ServiceController service, bool checkDuplicates) { - if (null != include && !Matches(service, include)) + if (include != null && !Matches(service, include)) return; - if (null != exclude && Matches(service, exclude)) + if (exclude != null && Matches(service, exclude)) return; if (checkDuplicates) { 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 8b125d03475..91a921b26f8 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 @@ -407,7 +407,7 @@ internal virtual void ValidateParameters() "WebCmdletAllowUnencryptedAuthenticationRequiredException"); ThrowTerminatingError(error); } - if (!AllowUnencryptedAuthentication && (null != Credential || UseDefaultCredentials) && (Uri.Scheme != "https")) + if (!AllowUnencryptedAuthentication && (Credential != null || UseDefaultCredentials) && (Uri.Scheme != "https")) { ErrorRecord error = GetValidationError(WebCmdletStrings.AllowUnencryptedAuthenticationRequired, "WebCmdletAllowUnencryptedAuthenticationRequiredException"); @@ -549,7 +549,7 @@ internal virtual void PrepareSession() // // handle credentials // - if (null != Credential && Authentication == WebAuthenticationType.None) + if (Credential != null && Authentication == WebAuthenticationType.None) { // get the relevant NetworkCredential NetworkCredential netCred = Credential.GetNetworkCredential(); @@ -558,7 +558,7 @@ internal virtual void PrepareSession() // supplying a credential overrides the UseDefaultCredentials setting WebSession.UseDefaultCredentials = false; } - else if ((null != Credential || null!= Token) && Authentication != WebAuthenticationType.None) + else if ((Credential != null || null!= Token) && Authentication != WebAuthenticationType.None) { ProcessAuthentication(); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/FormObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/FormObject.cs index a4ca4ab6671..60f0ea88d59 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/FormObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/FormObject.cs @@ -47,7 +47,7 @@ public FormObject(string id, string method, string action) internal void AddField(string key, string value) { string test; - if (null != key && !Fields.TryGetValue(key, out test)) + if (key != null && !Fields.TryGetValue(key, out test)) { Fields[key] = value; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs index c864449bdcb..c409e32d883 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs @@ -164,7 +164,7 @@ private void Process(OrderByPropertyEntry differenceEntry) // Return // 2005/07/19 Switched order of referenceEntry and differenceEntry // so that we cast differenceEntry to the type of referenceEntry. - if (null != referenceEntry && null != differenceEntry && + if (referenceEntry != null && null != differenceEntry && 0 == _comparer.Compare(referenceEntry, differenceEntry)) { EmitMatch(referenceEntry); diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index d304e12a30c..20e8ce27179 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -472,7 +472,7 @@ WsMan Config Can be divided in to Four Fixed Regions to Check Whether it has Chi strPathCheck = strPathCheck + WSManStringLiterals.DefaultPathSeparator; if (path.EndsWith(strPathCheck + WSManStringLiterals.containerResources, StringComparison.OrdinalIgnoreCase)) { - if (null != arrResources && arrResources.Count > 0) + if (arrResources != null && arrResources.Count > 0) { return true; } @@ -512,7 +512,7 @@ WsMan Config Can be divided in to Four Fixed Regions to Check Whether it has Chi { if (path.EndsWith(strPathCheck + WSManStringLiterals.containerSecurity, StringComparison.OrdinalIgnoreCase)) { - if (null != arrSecurities && arrSecurities.Count > 0) + if (arrSecurities != null && arrSecurities.Count > 0) { return true; } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs index ad84089fc46..d120f462d03 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs @@ -403,7 +403,7 @@ private static ViewDefinition GetView(MshExpressionFactory expressionFactory, Ty { ActiveTracer.WriteLine( "NOT MATCH {0} NAME: {1}", - ControlBase.GetControlShapeName(vd.mainControl), (null != vd ? vd.name : string.Empty)); + ControlBase.GetControlShapeName(vd.mainControl), (vd != null ? vd.name : string.Empty)); continue; } if (IsOutOfBandView(vd)) diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs index cceeed2aa1a..8caf5d89038 100644 --- a/src/System.Management.Automation/engine/CommandProcessorBase.cs +++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs @@ -873,7 +873,7 @@ internal PipelineStoppedException ManageInvocationException(Exception e) /// internal void ManageScriptException(RuntimeException e) { - if (null != Command && null != commandRuntime.PipelineProcessor) + if (Command != null && null != commandRuntime.PipelineProcessor) { commandRuntime.PipelineProcessor.RecordFailure(e, Command); @@ -892,7 +892,7 @@ internal void ManageScriptException(RuntimeException e) /// internal void ForgetScriptException() { - if (null != Command && null != commandRuntime.PipelineProcessor) + if (Command != null && null != commandRuntime.PipelineProcessor) { commandRuntime.PipelineProcessor.ForgetFailure(); } diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 48bdb2d799b..7fc2b105125 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2505,7 +2505,7 @@ internal void SetupVariable(VariableStreamKind streamKind, string variableName, { varList = new ArrayList(); - if (null != oldValue && AutomationNull.Value != oldValue) + if (oldValue != null && AutomationNull.Value != oldValue) { IEnumerable enumerable = LanguagePrimitives.GetEnumerable(oldValue); if (enumerable != null) diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index 4a5e3685753..f1d8e20fbeb 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -1742,7 +1742,7 @@ private object EncodeCollection( null, valueElement); } - else if (null != collectionElementType && null != currentValueElement) + else if (collectionElementType != null && null != currentValueElement) { Type currentValueElementType = currentValueElement.GetType(); Type desiredElementType = collectionElementType; diff --git a/src/System.Management.Automation/engine/Pipe.cs b/src/System.Management.Automation/engine/Pipe.cs index 78fbcd5469f..9d2066b5269 100644 --- a/src/System.Management.Automation/engine/Pipe.cs +++ b/src/System.Management.Automation/engine/Pipe.cs @@ -440,7 +440,7 @@ private void AddToPipe(object obj) ObjectQueue.Enqueue(obj); // This is the "streamlet" recursive call - if (null != _downstreamCmdlet && ObjectQueue.Count > OutBufferCount) + if (_downstreamCmdlet != null && ObjectQueue.Count > OutBufferCount) { _downstreamCmdlet.DoExecute(); } diff --git a/src/System.Management.Automation/engine/ShellVariable.cs b/src/System.Management.Automation/engine/ShellVariable.cs index d2362689d67..dedcd0b39ed 100644 --- a/src/System.Management.Automation/engine/ShellVariable.cs +++ b/src/System.Management.Automation/engine/ShellVariable.cs @@ -251,7 +251,7 @@ internal void DebuggerCheckVariableRead() var context = SessionState != null ? SessionState.ExecutionContext : LocalPipeline.GetExecutionContextFromTLS(); - if (null != context && context._debuggingMode > 0) + if (context != null && context._debuggingMode > 0) { context.Debugger.CheckVariableRead(Name); } @@ -262,7 +262,7 @@ internal void DebuggerCheckVariableWrite() var context = SessionState != null ? SessionState.ExecutionContext : LocalPipeline.GetExecutionContextFromTLS(); - if (null != context && context._debuggingMode > 0) + if (context != null && context._debuggingMode > 0) { context.Debugger.CheckVariableWrite(Name); } diff --git a/src/System.Management.Automation/engine/parser/TypeResolver.cs b/src/System.Management.Automation/engine/parser/TypeResolver.cs index 3af4609d2d1..f52d84d6da2 100644 --- a/src/System.Management.Automation/engine/parser/TypeResolver.cs +++ b/src/System.Management.Automation/engine/parser/TypeResolver.cs @@ -889,7 +889,7 @@ internal static string FindBuiltinAccelerator(Type type, string expectedKey = nu { Type resultType = null; builtinTypeAccelerators.TryGetValue(expectedKey, out resultType); - if (null != resultType && resultType == type) + if (resultType != null && resultType == type) { return expectedKey; } diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index bca3c05e535..6fb37b388c4 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -187,7 +187,7 @@ private string GetCommand(InvocationInfo invocationInfo) private string GetCommand(Exception exception) { IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) return GetCommand(icer.ErrorRecord.InvocationInfo); return ""; diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index ab453d988ef..e1dc988c0d7 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -1050,7 +1050,7 @@ internal override void Dispose(bool isDisposing) if (isDisposing) { KillServerProcess(); - if (null != _serverProcess && _processCreated) + if (_serverProcess != null && _processCreated) { // null can happen if Dispose is called before ConnectAsync() _serverProcess.Dispose(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs index 70a8702c665..b9353ef468d 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs @@ -160,7 +160,7 @@ internal void Clear() causing an unhandled exception in finalize and a process crash. Verify arrays and dataToBeSent objects before referencing. */ - if (null != _dataSyncObjects && null != _dataToBeSent) + if (_dataSyncObjects != null && null != _dataToBeSent) { int promptResponseIndex = (int)DataPriorityType.PromptResponse; int defaultIndex = (int)DataPriorityType.Default; diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index 2c08a88a81b..0c71c939734 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -1572,7 +1572,7 @@ internal static void ReportOperationComplete( WSManNativeApi.WSManPluginRequest requestDetails, WSManPluginErrorCodes errorCode) { - if (null != requestDetails && + if (requestDetails != null && IntPtr.Zero != requestDetails.unmanagedHandle) { wsmanPinvokeStatic.WSManPluginOperationComplete( diff --git a/src/System.Management.Automation/help/CommandHelpProvider.cs b/src/System.Management.Automation/help/CommandHelpProvider.cs index 56d43991768..88451a9fec8 100644 --- a/src/System.Management.Automation/help/CommandHelpProvider.cs +++ b/src/System.Management.Automation/help/CommandHelpProvider.cs @@ -339,7 +339,7 @@ private HelpInfo GetHelpInfo(CommandInfo commandInfo, bool reportErrors, bool se } // Set the HelpFile property to the file that contains the help content - if (null != result && !String.IsNullOrEmpty(helpFile)) + if (result != null && !String.IsNullOrEmpty(helpFile)) { if (isCmdlet) { diff --git a/src/System.Management.Automation/logging/MshLog.cs b/src/System.Management.Automation/logging/MshLog.cs index 0ed8ed64d9a..51fe632ac32 100644 --- a/src/System.Management.Automation/logging/MshLog.cs +++ b/src/System.Management.Automation/logging/MshLog.cs @@ -222,7 +222,7 @@ internal static void LogEngineHealthEvent(ExecutionContext executionContext, InvocationInfo invocationInfo = null; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) invocationInfo = icer.ErrorRecord.InvocationInfo; foreach (LogProvider provider in GetLogProvider(executionContext)) { @@ -425,7 +425,7 @@ Severity severity InvocationInfo invocationInfo = null; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) invocationInfo = icer.ErrorRecord.InvocationInfo; foreach (LogProvider provider in GetLogProvider(executionContext)) { @@ -617,7 +617,7 @@ Severity severity InvocationInfo invocationInfo = null; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) invocationInfo = icer.ErrorRecord.InvocationInfo; foreach (LogProvider provider in GetLogProvider(executionContext)) { diff --git a/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs b/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs index 207930cbd0b..1ef000f969a 100644 --- a/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs +++ b/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs @@ -100,7 +100,7 @@ internal override void LogEngineHealthEvent(LogContext logContext, int eventId, Hashtable mapArgs = new Hashtable(); IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) { mapArgs["ExceptionClass"] = exception.GetType().Name; mapArgs["ErrorCategory"] = icer.ErrorRecord.CategoryInfo.Category; @@ -221,7 +221,7 @@ internal override void LogCommandHealthEvent(LogContext logContext, Exception ex Hashtable mapArgs = new Hashtable(); IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) { mapArgs["ExceptionClass"] = exception.GetType().Name; mapArgs["ErrorCategory"] = icer.ErrorRecord.CategoryInfo.Category; @@ -399,7 +399,7 @@ internal override void LogProviderHealthEvent(LogContext logContext, string prov mapArgs["ProviderName"] = providerName; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) { mapArgs["ExceptionClass"] = exception.GetType().Name; mapArgs["ErrorCategory"] = icer.ErrorRecord.CategoryInfo.Category; diff --git a/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs b/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs index a57925ba6b8..c53d3ea7212 100644 --- a/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs +++ b/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs @@ -171,7 +171,7 @@ params object[] messageArgs ) { object[] a; - if (null != messageArgs && 0 < messageArgs.Length) + if (messageArgs != null && 0 < messageArgs.Length) { a = new object[messageArgs.Length + 1]; a[0] = commandName; diff --git a/src/System.Management.Automation/utils/ExecutionExceptions.cs b/src/System.Management.Automation/utils/ExecutionExceptions.cs index 468634d90dc..6a56e18a836 100644 --- a/src/System.Management.Automation/utils/ExecutionExceptions.cs +++ b/src/System.Management.Automation/utils/ExecutionExceptions.cs @@ -62,7 +62,7 @@ internal CmdletInvocationException(Exception innerException, // invocationInfo may be null IContainsErrorRecord icer = innerException as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) { _errorRecord = new ErrorRecord(icer.ErrorRecord, innerException); } diff --git a/src/System.Management.Automation/utils/SessionStateExceptions.cs b/src/System.Management.Automation/utils/SessionStateExceptions.cs index a6082744eec..a236f0a16cb 100644 --- a/src/System.Management.Automation/utils/SessionStateExceptions.cs +++ b/src/System.Management.Automation/utils/SessionStateExceptions.cs @@ -73,7 +73,7 @@ internal ProviderInvocationException(ProviderInfo provider, Exception innerExcep _providerInfo = provider; IContainsErrorRecord icer = innerException as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) { _errorRecord = new ErrorRecord(icer.ErrorRecord, innerException); } @@ -226,7 +226,7 @@ internal ProviderInvocationException( } IContainsErrorRecord icer = innerException as IContainsErrorRecord; - if (null != icer && null != icer.ErrorRecord) + if (icer != null && null != icer.ErrorRecord) { _errorRecord = new ErrorRecord(icer.ErrorRecord, errorRecordException); } @@ -559,7 +559,7 @@ private static string BuildMessage( params object[] messageArgs) { object[] a; - if (null != messageArgs && 0 < messageArgs.Length) + if (messageArgs != null && 0 < messageArgs.Length) { a = new object[messageArgs.Length + 1]; a[0] = itemName; From 3015b35559f7aebbb952db7651891bc009b0fc54 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 13:55:35 +0500 Subject: [PATCH 04/27] Replace '(null) != (\w+),' -> '$2 != $1,' --- .../commands/utility/InvokeCommandCmdlet.cs | 2 +- .../commands/utility/compare-object.cs | 16 +++++++------- .../host/msh/ConsoleHost.cs | 2 +- .../common/FormatViewGenerator_List.cs | 2 +- .../common/FormatViewGenerator_Table.cs | 2 +- .../common/Utilities/MshObjectUtil.cs | 2 +- .../engine/ErrorPackage.cs | 2 +- .../engine/ManagementObjectAdapter.cs | 2 +- .../engine/Modules/ModuleCmdletBase.cs | 2 +- .../engine/ParameterBinderBase.cs | 2 +- .../engine/TypeMetadata.cs | 6 ++--- .../hostifaces/InternalHostUserInterface.cs | 2 +- .../engine/hostifaces/PSDataCollection.cs | 4 ++-- .../engine/hostifaces/Pipeline.cs | 2 +- .../engine/hostifaces/PowerShell.cs | 4 ++-- .../engine/hostifaces/RunspacePoolInternal.cs | 4 ++-- .../engine/hostifaces/pipelinebase.cs | 10 ++++----- .../engine/pipeline.cs | 4 ++-- .../remoting/client/clientremotesession.cs | 2 +- .../client/remotingprotocolimplementation.cs | 2 +- .../remoting/common/RunspaceConnectionInfo.cs | 2 +- .../WireDataFormat/RemotingDataObject.cs | 14 ++++++------ .../engine/remoting/common/fragmentor.cs | 22 +++++++++---------- .../remoting/fanin/BaseTransportManager.cs | 4 ++-- .../fanin/OutOfProcTransportManager.cs | 16 +++++++------- .../remoting/fanin/PriorityCollection.cs | 16 +++++++------- .../engine/remoting/fanin/WSManNativeAPI.cs | 6 ++--- .../engine/remoting/fanin/WSManPlugin.cs | 8 +++---- .../remoting/fanin/WSManTransportManager.cs | 16 +++++++------- .../server/ServerRemotingProtocol2.cs | 4 ++-- .../server/ServerRunspacePoolDriver.cs | 2 +- .../remoting/server/serverremotesession.cs | 4 ++-- .../serverremotingprotocolimplementation.cs | 4 ++-- .../engine/runtime/Binding/Binders.cs | 2 +- .../engine/serialization.cs | 2 +- .../help/BaseCommandHelpInfo.cs | 2 +- .../help/CommandHelpProvider.cs | 6 ++--- .../help/HelpCommands.cs | 2 +- .../help/HelpFileHelpInfo.cs | 2 +- .../help/MamlCommandHelpInfo.cs | 2 +- .../help/ProviderContext.cs | 2 +- .../help/ProviderHelpInfo.cs | 2 +- .../utils/CommandDiscoveryExceptions.cs | 2 +- 43 files changed, 108 insertions(+), 108 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/InvokeCommandCmdlet.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/InvokeCommandCmdlet.cs index 7c751922b4d..0c96cf663bd 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/InvokeCommandCmdlet.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/InvokeCommandCmdlet.cs @@ -30,7 +30,7 @@ public sealed /// protected override void ProcessRecord() { - Diagnostics.Assert(null != Command, "Command is null"); + Diagnostics.Assert(Command != null, "Command is null"); ScriptBlock myScriptBlock = InvokeCommand.NewScriptBlock(Command); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs index c409e32d883..de57416611b 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs @@ -150,7 +150,7 @@ private List _differenceEntryBacklog /// private void Process(OrderByPropertyEntry differenceEntry) { - Diagnostics.Assert(null != _referenceEntries, "null referenceEntries"); + Diagnostics.Assert(_referenceEntries != null, "null referenceEntries"); // Retrieve the next reference object (referenceEntry) if any OrderByPropertyEntry referenceEntry = null; @@ -274,11 +274,11 @@ private OrderByPropertyEntry MatchAndRemove( { if (null == match || null == list) return null; - Diagnostics.Assert(null != _comparer, "null comparer"); + Diagnostics.Assert(_comparer != null, "null comparer"); for (int i = 0; i < list.Count; i++) { OrderByPropertyEntry listEntry = list[i]; - Diagnostics.Assert(null != listEntry, "null listEntry " + i); + Diagnostics.Assert(listEntry != null, "null listEntry " + i); if (0 == _comparer.Compare(match, listEntry)) { list.RemoveAt(i); @@ -309,7 +309,7 @@ private void EmitReferenceOnly(OrderByPropertyEntry entry) private void Emit(OrderByPropertyEntry entry, string sideIndicator) { - Diagnostics.Assert(null != entry, "null entry"); + Diagnostics.Assert(entry != null, "null entry"); PSObject mshobj; if (PassThru) @@ -328,7 +328,7 @@ private void Emit(OrderByPropertyEntry entry, string sideIndicator) else { List mshParameterList = _orderByProperty.MshParameterList; - Diagnostics.Assert(null != mshParameterList, "null mshParameterList"); + Diagnostics.Assert(mshParameterList != null, "null mshParameterList"); Diagnostics.Assert(mshParameterList.Count == Property.Length, "mshParameterList.Count " + mshParameterList.Count); for (int i = 0; i < Property.Length; i++) @@ -336,11 +336,11 @@ private void Emit(OrderByPropertyEntry entry, string sideIndicator) // 2005/07/05 This is the closest we can come to // the string typed by the user MshParameter mshParameter = mshParameterList[i]; - Diagnostics.Assert(null != mshParameter, "null mshParameter"); + Diagnostics.Assert(mshParameter != null, "null mshParameter"); Hashtable hash = mshParameter.hash; - Diagnostics.Assert(null != hash, "null hash"); + Diagnostics.Assert(hash != null, "null hash"); object prop = hash[FormatParameterDefinitionKeys.ExpressionEntryKey]; - Diagnostics.Assert(null != prop, "null prop"); + Diagnostics.Assert(prop != null, "null prop"); string propName = prop.ToString(); PSNoteProperty propertyNote = new PSNoteProperty( propName, diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index f40c74a1549..36e6bde6886 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -1350,7 +1350,7 @@ internal TextWriter ConsoleTextWriter private uint Run(CommandLineParameterParser cpp, bool isPrestartWarned) { - Dbg.Assert(null != cpp, "CommandLine parameter parser cannot be null."); + Dbg.Assert(cpp != null, "CommandLine parameter parser cannot be null."); uint exitCode = ExitCodeSuccess; do diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs index 8b67338d357..96ee8800c4f 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs @@ -42,7 +42,7 @@ internal override void Initialize(TerminatingErrorContext errorContext, MshExpre /// internal override void PrepareForRemoteObjects(PSObject so) { - Diagnostics.Assert(null != so, "so cannot be null"); + Diagnostics.Assert(so != null, "so cannot be null"); // make sure computername property exists. Diagnostics.Assert(null != so.Properties[RemotingConstants.ComputerNameNoteProperty], diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs index d9e6d1ef32d..4259a8334c6 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs @@ -82,7 +82,7 @@ internal override void Initialize(TerminatingErrorContext errorContext, MshExpre /// internal override void PrepareForRemoteObjects(PSObject so) { - Diagnostics.Assert(null != so, "so cannot be null"); + Diagnostics.Assert(so != null, "so cannot be null"); // make sure computername property exists. Diagnostics.Assert(null != so.Properties[RemotingConstants.ComputerNameNoteProperty], diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs index b006a0dffec..8867980c84a 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs @@ -432,7 +432,7 @@ internal static string FormatField(FieldFormattingDirective directive, object va private static PSMemberSet MaskDeserializedAndGetStandardMembers(PSObject so) { - Diagnostics.Assert(null != so, "Shell Object to process cannot be null"); + Diagnostics.Assert(so != null, "Shell Object to process cannot be null"); var typeNames = so.InternalTypeNames; Collection typeNamesWithoutDeserializedPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (null == typeNamesWithoutDeserializedPrefix) diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index c696ec792c1..6cb4b8925fd 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -1438,7 +1438,7 @@ public Exception Exception { get { - Diagnostics.Assert(null != _error, "_error is null"); + Diagnostics.Assert(_error != null, "_error is null"); return _error; } } diff --git a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs index 95c0c7fd71a..2f9382c4063 100644 --- a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs +++ b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs @@ -484,7 +484,7 @@ protected static CacheTable GetInstanceMethodTable(ManagementBaseObject wmiObjec /// private static void PopulateMethodTable(ManagementClass mgmtClass, CacheTable methodTable, bool staticBinding) { - Dbg.Assert(null != mgmtClass, "ManagementClass cannot be null in this method"); + Dbg.Assert(mgmtClass != null, "ManagementClass cannot be null in this method"); MethodDataCollection mgmtMethods = mgmtClass.Methods; if (mgmtMethods != null) { diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index 8c64918fd86..701627a56ab 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -3894,7 +3894,7 @@ internal bool VerifyIfNestedModuleIsAvailable(ModuleSpecification nestedModuleSp string extension, out PSModuleInfo nestedModuleInfoIfAvailable) { - Dbg.Assert(null != nestedModuleSpec, "nestedModuleSpec cannot be null."); + Dbg.Assert(nestedModuleSpec != null, "nestedModuleSpec cannot be null."); nestedModuleInfoIfAvailable = null; if ((nestedModuleSpec.Guid != null) || (nestedModuleSpec.Version != null) || (nestedModuleSpec.RequiredVersion != null) || (nestedModuleSpec.MaximumVersion != null)) { diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index f1d8e20fbeb..b7c9a878c0b 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -1598,7 +1598,7 @@ private object EncodeCollection( // extract the ICollection::Add(T) method const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance; Type elementType = collectionTypeInformation.ElementType; - Diagnostics.Assert(null != elementType, "null ElementType"); + Diagnostics.Assert(elementType != null, "null ElementType"); Exception getMethodError = null; try { diff --git a/src/System.Management.Automation/engine/TypeMetadata.cs b/src/System.Management.Automation/engine/TypeMetadata.cs index 352ea45aac2..1fe444cb165 100644 --- a/src/System.Management.Automation/engine/TypeMetadata.cs +++ b/src/System.Management.Automation/engine/TypeMetadata.cs @@ -38,7 +38,7 @@ public sealed class ParameterSetMetadata /// internal ParameterSetMetadata(ParameterSetSpecificMetadata psMD) { - Dbg.Assert(null != psMD, "ParameterSetSpecificMetadata cannot be null"); + Dbg.Assert(psMD != null, "ParameterSetSpecificMetadata cannot be null"); Initialize(psMD); } @@ -474,7 +474,7 @@ public ParameterMetadata(ParameterMetadata other) /// internal ParameterMetadata(CompiledCommandParameter cmdParameterMD) { - Dbg.Assert(null != cmdParameterMD, + Dbg.Assert(cmdParameterMD != null, "CompiledCommandParameter cannot be null"); Initialize(cmdParameterMD); @@ -669,7 +669,7 @@ internal void Initialize(CompiledCommandParameter compiledParameterMD) internal static Dictionary GetParameterMetadata(MergedCommandParameterMetadata cmdParameterMetadata) { - Dbg.Assert(null != cmdParameterMetadata, "cmdParameterMetadata cannot be null"); + Dbg.Assert(cmdParameterMetadata != null, "cmdParameterMetadata cannot be null"); Dictionary result = new Dictionary(StringComparer.OrdinalIgnoreCase); diff --git a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs index f4ae4d5b102..4a601e3d27d 100644 --- a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs @@ -960,7 +960,7 @@ private Collection EmulatePromptForMultipleChoice(string caption, Collection choices, IEnumerable defaultChoices) { - Dbg.Assert(null != _externalUI, "externalUI cannot be null."); + Dbg.Assert(_externalUI != null, "externalUI cannot be null."); if (choices == null) { diff --git a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs index 851e13ad352..611bab902e5 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs @@ -1164,7 +1164,7 @@ public Collection ReadAll() /// maximum number of elements to read internal Collection ReadAndRemove(int readCount) { - Dbg.Assert(null != _data, "Collection cannot be null"); + Dbg.Assert(_data != null, "Collection cannot be null"); Dbg.Assert(readCount >= 0, "ReadCount cannot be negative"); @@ -1844,7 +1844,7 @@ internal sealed class PSDataCollectionEnumerator : IBlockingEnumerator /// internal PSDataCollectionEnumerator(PSDataCollection collection, bool neverBlock) { - Dbg.Assert(null != collection, + Dbg.Assert(collection != null, "Collection cannot be null"); Dbg.Assert(!collection.ReleaseOnEnumeration || !collection.IsEnumerated, "shouldn't enumerate more than once if ReleaseOnEnumeration is true"); diff --git a/src/System.Management.Automation/engine/hostifaces/Pipeline.cs b/src/System.Management.Automation/engine/hostifaces/Pipeline.cs index 2c9e9905b83..34a99c77a2f 100644 --- a/src/System.Management.Automation/engine/hostifaces/Pipeline.cs +++ b/src/System.Management.Automation/engine/hostifaces/Pipeline.cs @@ -308,7 +308,7 @@ internal Pipeline(Runspace runspace, CommandCollection command) } // This constructor is used only internally. // Caller should make sure the input is valid - Dbg.Assert(null != command, "Command cannot be null"); + Dbg.Assert(command != null, "Command cannot be null"); InstanceId = runspace.GeneratePipelineId(); Commands = command; diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index 6f4b85443c4..bfe8a92c93d 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -4253,7 +4253,7 @@ private void CoreInvokeHelper(PSDataCollection input, P else { rsToUse = _rsConnection as Runspace; - Dbg.Assert(null != rsToUse, + Dbg.Assert(rsToUse != null, "Nested PowerShell can only work on a Runspace"); // Perform work on the current thread. Nested Pipeline @@ -4675,7 +4675,7 @@ private void VerifyThreadSettings(PSInvocationSettings settings, ApartmentState /// private void Prepare(PSDataCollection input, PSDataCollection output, PSInvocationSettings settings, bool shouldCreateWorker) { - Dbg.Assert(null != output, "Output cannot be null"); + Dbg.Assert(output != null, "Output cannot be null"); lock (_syncObject) { diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs index e7bfb171741..40a3157b446 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs @@ -1248,7 +1248,7 @@ internal void AssertPoolIsOpen() /// protected Runspace CreateRunspace() { - Dbg.Assert(null != _initialSessionState, "_initialSessionState should not be null"); + Dbg.Assert(_initialSessionState != null, "_initialSessionState should not be null"); // TODO: exceptions thrown here need to be documented // runspace.Open() did not document all the exceptions. Runspace result = RunspaceFactory.CreateRunspaceFromSessionStateNoClone(host, _initialSessionState); @@ -1296,7 +1296,7 @@ protected Runspace CreateRunspace() /// protected void DestroyRunspace(Runspace runspace) { - Dbg.Assert(null != runspace, "Runspace cannot be null"); + Dbg.Assert(runspace != null, "Runspace cannot be null"); runspace.Events.ForwardEvent -= OnRunspaceForwardEvent; // this must be done after open since open initializes the ExecutionContext runspace.Close(); runspace.Dispose(); diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs index 89a9c57dea6..ac7ac91f43f 100644 --- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs +++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs @@ -87,11 +87,11 @@ protected PipelineBase(Runspace runspace, PSInformationalBuffers infoBuffers) : base(runspace, command) { - Dbg.Assert(null != inputStream, "Caller Should validate inputstream parameter"); - Dbg.Assert(null != outputStream, "Caller Should validate outputStream parameter"); - Dbg.Assert(null != errorStream, "Caller Should validate errorStream parameter"); - Dbg.Assert(null != infoBuffers, "Caller Should validate informationalBuffers parameter"); - Dbg.Assert(null != command, "Command cannot be null"); + Dbg.Assert(inputStream != null, "Caller Should validate inputstream parameter"); + Dbg.Assert(outputStream != null, "Caller Should validate outputStream parameter"); + Dbg.Assert(errorStream != null, "Caller Should validate errorStream parameter"); + Dbg.Assert(infoBuffers != null, "Caller Should validate informationalBuffers parameter"); + Dbg.Assert(command != null, "Command cannot be null"); // Since we are constructing this pipeline using a commandcollection we dont need // to add cmd to CommandCollection again (Initialize does this).. because of this diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index 6fb37b388c4..514eebbe465 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -569,7 +569,7 @@ internal Array SynchronousExecuteEnumerate(object input) // The only reason we should get here is if // an exception should be rethrown. - Diagnostics.Assert(null != toRethrowInfo, "Alternate protocol path failure"); + Diagnostics.Assert(toRethrowInfo != null, "Alternate protocol path failure"); toRethrowInfo.Throw(); return null; // UNREACHABLE } // internal Array SynchronousExecuteEnumerate() @@ -724,7 +724,7 @@ internal Array DoComplete() // The only reason we should get here is if // an exception should be rethrown. - Diagnostics.Assert(null != toRethrowInfo, "Alternate protocol path failure"); + Diagnostics.Assert(toRethrowInfo != null, "Alternate protocol path failure"); toRethrowInfo.Throw(); return null; // UNREACHABLE } // internal Array DoComplete() diff --git a/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs b/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs index c966574494e..fe9455bb6ff 100644 --- a/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs @@ -194,7 +194,7 @@ internal class ClientRemoteSessionImpl : ClientRemoteSession, IDisposable internal ClientRemoteSessionImpl(RemoteRunspacePoolInternal rsPool, URIDirectionReported uriRedirectionHandler) { - Dbg.Assert(null != rsPool, "RunspacePool cannot be null"); + Dbg.Assert(rsPool != null, "RunspacePool cannot be null"); base.RemoteRunspacePoolInternal = rsPool; Context.RemoteAddress = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo(rsPool.ConnectionInfo, "ConnectionUri", null); diff --git a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs index 9479c45895d..c48940fb583 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs @@ -432,7 +432,7 @@ private void HandleTransportErrorForRedirection(object sender, TransportErrorOcc /// private void PerformURIRedirectionStep2(System.Uri newURI) { - Dbg.Assert(null != newURI, "Uri cannot be null"); + Dbg.Assert(newURI != null, "Uri cannot be null"); lock (_syncObject) { // if connection is closed by the user..no need to redirect diff --git a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs index 72b2f7c5342..70d9d0b3d58 100644 --- a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs +++ b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs @@ -1137,7 +1137,7 @@ internal static T ExtractPropertyAsWsManConnectionInfo(RunspaceConnectionInfo internal void SetConnectionUri(Uri newUri) { - Dbg.Assert(null != newUri, "newUri cannot be null."); + Dbg.Assert(newUri != null, "newUri cannot be null."); _connectionUri = newUri; } diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs index 34eaa43814a..e03441e2257 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemotingDataObject.cs @@ -136,8 +136,8 @@ internal static RemoteDataObject CreateFrom(RemotingDestination destination, /// internal static RemoteDataObject CreateFrom(Stream serializedDataStream, Fragmentor defragmentor) { - Dbg.Assert(null != serializedDataStream, "cannot construct a RemoteDataObject from null data"); - Dbg.Assert(null != defragmentor, "defragmentor cannot be null."); + Dbg.Assert(serializedDataStream != null, "cannot construct a RemoteDataObject from null data"); + Dbg.Assert(defragmentor != null, "defragmentor cannot be null."); if ((serializedDataStream.Length - serializedDataStream.Position) < headerLength) { @@ -177,8 +177,8 @@ internal static RemoteDataObject CreateFrom(Stream serializedDataStream, Frag /// internal virtual void Serialize(Stream streamToWriteTo, Fragmentor fragmentor) { - Dbg.Assert(null != streamToWriteTo, "Stream to write to cannot be null."); - Dbg.Assert(null != fragmentor, "Fragmentor cannot be null."); + Dbg.Assert(streamToWriteTo != null, "Stream to write to cannot be null."); + Dbg.Assert(fragmentor != null, "Fragmentor cannot be null."); SerializeHeader(streamToWriteTo); if (Data != null) @@ -199,7 +199,7 @@ internal virtual void Serialize(Stream streamToWriteTo, Fragmentor fragmentor) /// private void SerializeHeader(Stream streamToWriteTo) { - Dbg.Assert(null != streamToWriteTo, "stream to write to cannot be null"); + Dbg.Assert(streamToWriteTo != null, "stream to write to cannot be null"); // Serialize destination SerializeUInt((uint)Destination, streamToWriteTo); @@ -215,7 +215,7 @@ private void SerializeHeader(Stream streamToWriteTo) private void SerializeUInt(uint data, Stream streamToWriteTo) { - Dbg.Assert(null != streamToWriteTo, "stream to write to cannot be null"); + Dbg.Assert(streamToWriteTo != null, "stream to write to cannot be null"); byte[] result = new byte[4]; // size of int @@ -243,7 +243,7 @@ private static uint DeserializeUInt(Stream serializedDataStream) private void SerializeGuid(Guid guid, Stream streamToWriteTo) { - Dbg.Assert(null != streamToWriteTo, "stream to write to cannot be null"); + Dbg.Assert(streamToWriteTo != null, "stream to write to cannot be null"); byte[] guidArray = guid.ToByteArray(); diff --git a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs index 6a2f99100d7..33863bb2846 100644 --- a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs +++ b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs @@ -157,7 +157,7 @@ internal byte[] Blob get { return _blob; } set { - Dbg.Assert(null != value, "Blob cannot be null"); + Dbg.Assert(value != null, "Blob cannot be null"); _blob = value; } } @@ -275,7 +275,7 @@ internal byte[] GetBytes() /// internal static long GetObjectId(byte[] fragmentBytes, int startIndex) { - Dbg.Assert(null != fragmentBytes, "fragmentBytes cannot be null"); + Dbg.Assert(fragmentBytes != null, "fragmentBytes cannot be null"); Dbg.Assert(fragmentBytes.Length >= HeaderLength, "not enough data to decode object id"); long objectId = 0; @@ -309,7 +309,7 @@ internal static long GetObjectId(byte[] fragmentBytes, int startIndex) /// internal static long GetFragmentId(byte[] fragmentBytes, int startIndex) { - Dbg.Assert(null != fragmentBytes, "fragmentBytes cannot be null"); + Dbg.Assert(fragmentBytes != null, "fragmentBytes cannot be null"); Dbg.Assert(fragmentBytes.Length >= HeaderLength, "not enough data to decode fragment id"); long fragmentId = 0; int idx = startIndex + _fragmentIdOffset; @@ -344,7 +344,7 @@ internal static long GetFragmentId(byte[] fragmentBytes, int startIndex) /// internal static bool GetIsStartFragment(byte[] fragmentBytes, int startIndex) { - Dbg.Assert(null != fragmentBytes, "fragment cannot be null"); + Dbg.Assert(fragmentBytes != null, "fragment cannot be null"); Dbg.Assert(fragmentBytes.Length >= HeaderLength, "not enough data to decode if it is a start fragment."); if ((fragmentBytes[startIndex + _flagsOffset] & SFlag) != 0) @@ -373,7 +373,7 @@ internal static bool GetIsStartFragment(byte[] fragmentBytes, int startIndex) /// internal static bool GetIsEndFragment(byte[] fragmentBytes, int startIndex) { - Dbg.Assert(null != fragmentBytes, "fragment cannot be null"); + Dbg.Assert(fragmentBytes != null, "fragment cannot be null"); Dbg.Assert(fragmentBytes.Length >= HeaderLength, "not enough data to decode if it is an end fragment."); if ((fragmentBytes[startIndex + _flagsOffset] & EFlag) != 0) @@ -402,7 +402,7 @@ internal static bool GetIsEndFragment(byte[] fragmentBytes, int startIndex) /// internal static int GetBlobLength(byte[] fragmentBytes, int startIndex) { - Dbg.Assert(null != fragmentBytes, "fragment cannot be null"); + Dbg.Assert(fragmentBytes != null, "fragment cannot be null"); Dbg.Assert(fragmentBytes.Length >= HeaderLength, "not enough data to decode blob length."); int blobLength = 0; @@ -1008,8 +1008,8 @@ internal Fragmentor(int fragmentSize, PSRemotingCryptoHelper cryptoHelper) /// internal void Fragment(RemoteDataObject obj, SerializedDataStream dataToBeSent) { - Dbg.Assert(null != obj, "Cannot fragment a null object"); - Dbg.Assert(null != dataToBeSent, "SendDataCollection cannot be null"); + Dbg.Assert(obj != null, "Cannot fragment a null object"); + Dbg.Assert(dataToBeSent != null, "SendDataCollection cannot be null"); dataToBeSent.Enter(); try @@ -1054,8 +1054,8 @@ internal int FragmentSize /// internal void SerializeToBytes(object obj, Stream streamToWriteTo) { - Dbg.Assert(null != obj, "Cannot serialize a null object"); - Dbg.Assert(null != streamToWriteTo, "Stream to write to cannot be null"); + Dbg.Assert(obj != null, "Cannot serialize a null object"); + Dbg.Assert(streamToWriteTo != null, "Stream to write to cannot be null"); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.CheckCharacters = false; @@ -1095,7 +1095,7 @@ internal void SerializeToBytes(object obj, Stream streamToWriteTo) /// internal PSObject DeserializeToPSObject(Stream serializedDataStream) { - Dbg.Assert(null != serializedDataStream, "Cannot Deserialize null data"); + Dbg.Assert(serializedDataStream != null, "Cannot Deserialize null data"); Dbg.Assert(serializedDataStream.Length != 0, "Cannot Deserialize empty data"); object result = null; diff --git a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs index fd554f0a4e7..df0373a911d 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs @@ -287,7 +287,7 @@ internal void ProcessRawData(byte[] data, string stream, ReceiveDataCollection.OnDataAvailableCallback dataAvailableCallback) { - Dbg.Assert(null != data, "Cannot process null data"); + Dbg.Assert(data != null, "Cannot process null data"); s_baseTracer.WriteLine("Processing incoming data for stream {0}.", stream); @@ -1344,7 +1344,7 @@ internal void SendDataToClient(RemoteDataObject data, bool flush, bool rep private void OnDataAvailable(byte[] dataToSend, bool isEndFragment) { - Dbg.Assert(null != dataToSend, "ServerTransportManager cannot send null fragment"); + Dbg.Assert(dataToSend != null, "ServerTransportManager cannot send null fragment"); // log to crimson log. PSEtwLog.LogAnalyticInformational(PSEventId.ServerSendData, PSOpcode.Send, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic, diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index e1dc988c0d7..06f318488b5 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -212,7 +212,7 @@ internal static void ProcessData(string data, DataProcessingDelegates callbacks) /// private static void ProcessElement(XmlReader xmlReader, DataProcessingDelegates callbacks) { - Dbg.Assert(null != xmlReader, "xmlReader cannot be null."); + Dbg.Assert(xmlReader != null, "xmlReader cannot be null."); Dbg.Assert(xmlReader.NodeType == XmlNodeType.Element, "xmlReader's NodeType should be of type Element"); PowerShellTraceSource tracer = PowerShellTraceSourceFactory.GetTraceSource(); @@ -398,7 +398,7 @@ internal class OutOfProcessTextWriter /// internal OutOfProcessTextWriter(TextWriter writerToWrap) { - Dbg.Assert(null != writerToWrap, "Cannot wrap a null writer."); + Dbg.Assert(writerToWrap != null, "Cannot wrap a null writer."); _writer = writerToWrap; } @@ -574,7 +574,7 @@ internal override BaseClientCommandTransportManager CreateClientCommandTransport ClientRemotePowerShell cmd, bool noInput) { - Dbg.Assert(null != cmd, "Cmd cannot be null"); + Dbg.Assert(cmd != null, "Cmd cannot be null"); OutOfProcessClientCommandTransportManager result = new OutOfProcessClientCommandTransportManager(cmd, noInput, this, stdInWriter); @@ -729,7 +729,7 @@ protected void SendOneItem() private void OnDataAvailableCallback(byte[] data, DataPriorityType priorityType) { - Dbg.Assert(null != data, "data cannot be null in the data available callback"); + Dbg.Assert(data != null, "data cannot be null in the data available callback"); tracer.WriteLine("Received data to be sent from the callback."); SendData(data, priorityType); @@ -2162,7 +2162,7 @@ private void StopSignalTimerAndDecrementOperations() /// internal override void ProcessPrivateData(object privateData) { - Dbg.Assert(null != privateData, "privateData cannot be null."); + Dbg.Assert(privateData != null, "privateData cannot be null."); // For this version...only a boolean can be used for privateData. bool shouldRaiseSignalCompleted = (bool)privateData; @@ -2230,7 +2230,7 @@ private void SendData(byte[] data, DataPriorityType priorityType) private void OnDataAvailableCallback(byte[] data, DataPriorityType priorityType) { - Dbg.Assert(null != data, "data cannot be null in the data available callback"); + Dbg.Assert(data != null, "data cannot be null in the data available callback"); tracer.WriteLine("Received data from dataToBeSent store."); SendData(data, priorityType); @@ -2258,8 +2258,8 @@ internal class OutOfProcessServerSessionTransportManager : AbstractServerSession internal OutOfProcessServerSessionTransportManager(OutOfProcessTextWriter outWriter, OutOfProcessTextWriter errWriter, PSRemotingCryptoHelperServer cryptoHelper) : base(BaseTransportManager.DefaultFragmentSize, cryptoHelper) { - Dbg.Assert(null != outWriter, "outWriter cannot be null."); - Dbg.Assert(null != errWriter, "errWriter cannot be null."); + Dbg.Assert(outWriter != null, "outWriter cannot be null."); + Dbg.Assert(errWriter != null, "errWriter cannot be null."); _stdOutWriter = outWriter; _stdErrWriter = errWriter; _cmdTransportManagers = new Dictionary(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs index b9353ef468d..8df154628bb 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs @@ -91,7 +91,7 @@ internal Fragmentor Fragmentor get { return _fragmentor; } set { - Dbg.Assert(null != value, "Fragmentor cannot be null."); + Dbg.Assert(value != null, "Fragmentor cannot be null."); _fragmentor = value; // create serialized streams using fragment size. string[] names = Enum.GetNames(typeof(DataPriorityType)); @@ -120,9 +120,9 @@ internal Fragmentor Fragmentor /// internal void Add(RemoteDataObject data, DataPriorityType priority) { - Dbg.Assert(null != data, "Cannot send null data object"); - Dbg.Assert(null != _fragmentor, "Fragmentor cannot be null while adding objects"); - Dbg.Assert(null != _dataToBeSent, "Serialized streams are not initialized"); + Dbg.Assert(data != null, "Cannot send null data object"); + Dbg.Assert(_fragmentor != null, "Fragmentor cannot be null while adding objects"); + Dbg.Assert(_dataToBeSent != null, "Serialized streams are not initialized"); // make sure the only one object is fragmented and added to the collection // at any give time. This way the order of fragment is maintained @@ -356,7 +356,7 @@ internal class ReceiveDataCollection : IDisposable /// internal ReceiveDataCollection(Fragmentor defragmentor, bool createdByClientTM) { - Dbg.Assert(null != defragmentor, "ReceiveDataCollection needs a defragmentor to work with"); + Dbg.Assert(defragmentor != null, "ReceiveDataCollection needs a defragmentor to work with"); // Memory streams created with an unsigned byte array provide a non-resizable stream view // of the data, and can only be written to. When using a byte array, you can neither append @@ -431,8 +431,8 @@ internal void PrepareForStreamConnect() /// internal void ProcessRawData(byte[] data, OnDataAvailableCallback callback) { - Dbg.Assert(null != data, "Cannot process null data"); - Dbg.Assert(null != callback, "Callback cannot be null"); + Dbg.Assert(data != null, "Cannot process null data"); + Dbg.Assert(callback != null, "Callback cannot be null"); lock (_syncObject) { @@ -852,7 +852,7 @@ internal void ProcessRawData(byte[] data, DataPriorityType priorityType, ReceiveDataCollection.OnDataAvailableCallback callback) { - Dbg.Assert(null != data, "Cannot process null data"); + Dbg.Assert(data != null, "Cannot process null data"); try { diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs index b5c593ad831..67385e62e6b 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs @@ -651,7 +651,7 @@ internal class WSManData_ManToUn : IDisposable /// internal WSManData_ManToUn(byte[] data) { - Dbg.Assert(null != data, "Data cannot be null"); + Dbg.Assert(data != null, "Data cannot be null"); _internalData = new WSManDataStruct(); _internalData.binaryOrTextData = new WSManBinaryOrTextDataStruct(); @@ -674,7 +674,7 @@ internal WSManData_ManToUn(byte[] data) /// internal WSManData_ManToUn(string data) { - Dbg.Assert(null != data, "Data cannot be null"); + Dbg.Assert(data != null, "Data cannot be null"); _internalData = new WSManDataStruct(); _internalData.binaryOrTextData = new WSManBinaryOrTextDataStruct(); @@ -1098,7 +1098,7 @@ internal struct WSManOptionSet : IDisposable /// internal WSManOptionSet(WSManOption[] options) { - Dbg.Assert(null != options, "options cannot be null"); + Dbg.Assert(options != null, "options cannot be null"); int sizeOfOption = Marshal.SizeOf(); _optionSet = new WSManOptionSetStruct(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index 0c71c939734..b055e25b07b 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -948,7 +948,7 @@ private PSSenderInfo GetPSSenderInfo( WSManNativeApi.WSManSenderDetails senderDetails) { // senderDetails will not be null. - Dbg.Assert(null != senderDetails, "senderDetails cannot be null"); + Dbg.Assert(senderDetails != null, "senderDetails cannot be null"); // Construct PSIdentity PSCertificateDetails psCertDetails = null; @@ -1394,7 +1394,7 @@ internal static void ReportWSManOperationComplete( WSManNativeApi.WSManPluginRequest requestDetails, WSManPluginErrorCodes errorCode) { - Dbg.Assert(null != requestDetails, "requestDetails cannot be null in operation complete."); + Dbg.Assert(requestDetails != null, "requestDetails cannot be null in operation complete."); PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete, PSOpcode.Close, PSTask.None, @@ -1416,7 +1416,7 @@ internal static void ReportWSManOperationComplete( WSManNativeApi.WSManPluginRequest requestDetails, Exception reasonForClose) { - Dbg.Assert(null != requestDetails, "requestDetails cannot be null in operation complete."); + Dbg.Assert(requestDetails != null, "requestDetails cannot be null in operation complete."); WSManPluginErrorCodes error = WSManPluginErrorCodes.NoError; String errorMessage = String.Empty; @@ -1466,7 +1466,7 @@ internal static void SetThreadProperties( WSManNativeApi.WSManPluginRequest requestDetails) { // requestDetails cannot not be null. - Dbg.Assert(null != requestDetails, "requestDetails cannot be null"); + Dbg.Assert(requestDetails != null, "requestDetails cannot be null"); //IntPtr nativeLocaleData = IntPtr.Zero; WSManNativeApi.WSManDataStruct outputStruct = new WSManNativeApi.WSManDataStruct(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index eb573acd943..8c7fe460288 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -567,7 +567,7 @@ internal WSManClientSessionTransportManager(Guid runspacePoolInstanceId, throw new PSRemotingTransportException( StringUtil.Format(RemotingErrorIdStrings.WSManInitFailed, WSManAPIData.ErrorCode)); } - Dbg.Assert(null != connectionInfo, "connectionInfo cannot be null"); + Dbg.Assert(connectionInfo != null, "connectionInfo cannot be null"); CryptoHelper = cryptoHelper; dataToBeSent.Fragmentor = base.Fragmentor; @@ -1333,10 +1333,10 @@ internal override void Redirect(Uri newUri, RunspaceConnectionInfo connectionInf internal override BaseClientCommandTransportManager CreateClientCommandTransportManager(RunspaceConnectionInfo connectionInfo, ClientRemotePowerShell cmd, bool noInput) { - Dbg.Assert(null != cmd, "Cmd cannot be null"); + Dbg.Assert(cmd != null, "Cmd cannot be null"); WSManConnectionInfo wsmanConnectionInfo = connectionInfo as WSManConnectionInfo; - Dbg.Assert(null != wsmanConnectionInfo, "ConnectionInfo must be WSManConnectionInfo"); + Dbg.Assert(wsmanConnectionInfo != null, "ConnectionInfo must be WSManConnectionInfo"); WSManClientCommandTransportManager result = new WSManClientCommandTransportManager(wsmanConnectionInfo, _wsManShellOperationHandle, cmd, noInput, this); @@ -1357,7 +1357,7 @@ internal override BaseClientCommandTransportManager CreateClientCommandTransport /// private void Initialize(Uri connectionUri, WSManConnectionInfo connectionInfo) { - Dbg.Assert(null != connectionInfo, "connectionInfo cannot be null."); + Dbg.Assert(connectionInfo != null, "connectionInfo cannot be null."); ConnectionInfo = connectionInfo; @@ -2411,7 +2411,7 @@ private void SendOneItem() private void OnDataAvailableCallback(byte[] data, DataPriorityType priorityType) { - Dbg.Assert(null != data, "data cannot be null in the data available callback"); + Dbg.Assert(data != null, "data cannot be null in the data available callback"); tracer.WriteLine("Received data to be sent from the callback."); SendData(data, priorityType); @@ -2867,7 +2867,7 @@ internal WSManClientCommandTransportManager(WSManConnectionInfo connectionInfo, base(shell, sessnTM.CryptoHelper, sessnTM) { Dbg.Assert(IntPtr.Zero != wsManShellOperationHandle, "Shell operation handle cannot be IntPtr.Zero."); - Dbg.Assert(null != connectionInfo, "connectionInfo cannot be null"); + Dbg.Assert(connectionInfo != null, "connectionInfo cannot be null"); _wsManShellOperationHandle = wsManShellOperationHandle; @@ -3192,7 +3192,7 @@ internal override void RaiseErrorHandler(TransportErrorOccuredEventArgs eventArg /// internal override void ProcessPrivateData(object privateData) { - Dbg.Assert(null != privateData, "privateData cannot be null."); + Dbg.Assert(privateData != null, "privateData cannot be null."); // For this version...only a boolean can be used for privateData. bool shouldRaiseSignalCompleted = (bool)privateData; @@ -3858,7 +3858,7 @@ private void SendOneItem() private void OnDataAvailableCallback(byte[] data, DataPriorityType priorityType) { - Dbg.Assert(null != data, "data cannot be null in the data available callback"); + Dbg.Assert(data != null, "data cannot be null in the data available callback"); tracer.WriteLine("Received data from dataToBeSent store."); Dbg.Assert(_chunkToSend == null, "data callback received while a chunk is pending to be sent"); diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs b/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs index 0b0e46cc05f..84395cdf502 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs @@ -344,7 +344,7 @@ internal TypeTable TypeTable /// data structure handler class private void SendDataAsync(RemoteDataObject data) { - Dbg.Assert(null != data, "Cannot send null object."); + Dbg.Assert(data != null, "Cannot send null object."); _transportManager.SendDataToClient(data, true); } @@ -775,7 +775,7 @@ internal Runspace RunspaceUsedToInvokePowerShell /// data structure handler class private void SendDataAsync(RemoteDataObject data) { - Dbg.Assert(null != data, "Cannot send null object."); + Dbg.Assert(data != null, "Cannot send null object."); // this is from a command execution..let transport manager collect // as much data as possible and send bigger buffer to client. _transportManager.SendDataToClient(data, false); diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs index 711dc0ce389..b136837a353 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs @@ -174,7 +174,7 @@ internal ServerRunspacePoolDriver( string configurationName) #endif { - Dbg.Assert(null != configData, "ConfigurationData cannot be null"); + Dbg.Assert(configData != null, "ConfigurationData cannot be null"); _serverCapability = serverCapability; _clientPSVersion = psClientVersion; diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs index cc8c50e913d..0958797cf49 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs @@ -123,7 +123,7 @@ internal ServerRemoteSession(PSSenderInfo senderInfo, string initializationParameters, AbstractServerSessionTransportManager transportManager) { - Dbg.Assert(null != transportManager, "transportManager cannot be null."); + Dbg.Assert(transportManager != null, "transportManager cannot be null."); // let input,output and error from native commands redirect as we have // to send (or receive) them back to client for action. @@ -1157,7 +1157,7 @@ internal ServerRunspacePoolDriver GetRunspacePoolDriver(Guid clientRunspacePoolI /// internal void ApplyQuotaOnCommandTransportManager(AbstractServerTransportManager cmdTransportManager) { - Dbg.Assert(null != cmdTransportManager, "cmdTransportManager cannot be null"); + Dbg.Assert(cmdTransportManager != null, "cmdTransportManager cannot be null"); cmdTransportManager.ReceivedDataCollection.MaximumReceivedDataSize = _maxRecvdDataSizeCommand; cmdTransportManager.ReceivedDataCollection.MaximumReceivedObjectSize = _maxRecvdObjectSize; } diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs b/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs index 84bf5890892..23d8308242a 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotingprotocolimplementation.cs @@ -36,8 +36,8 @@ internal override AbstractServerSessionTransportManager TransportManager internal ServerRemoteSessionDSHandlerImpl(ServerRemoteSession session, AbstractServerSessionTransportManager transportManager) { - Dbg.Assert(null != session, "session cannot be null."); - Dbg.Assert(null != transportManager, "transportManager cannot be null."); + Dbg.Assert(session != null, "session cannot be null."); + Dbg.Assert(transportManager != null, "transportManager cannot be null."); _session = session; _stateMachine = new ServerRemoteSessionDSHandlerStateMachine(session); diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index f934c1a503c..7836000a6c2 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -5388,7 +5388,7 @@ private static Expression WrapGetMemberInTry(Expression expr) private PSMemberInfo ResolveAlias(PSAliasProperty alias, DynamicMetaObject target, HashSet aliases, List aliasRestrictions) { - Diagnostics.Assert(null != aliasRestrictions, "aliasRestrictions cannot be null"); + Diagnostics.Assert(aliasRestrictions != null, "aliasRestrictions cannot be null"); if (aliases == null) { aliases = new HashSet { alias.Name }; diff --git a/src/System.Management.Automation/engine/serialization.cs b/src/System.Management.Automation/engine/serialization.cs index 93a1b2aa277..0e9a97b1fe1 100644 --- a/src/System.Management.Automation/engine/serialization.cs +++ b/src/System.Management.Automation/engine/serialization.cs @@ -729,7 +729,7 @@ internal static string MaskDeserializationPrefix(string typeName) /// internal static Collection MaskDeserializationPrefix(Collection typeNames) { - Dbg.Assert(null != typeNames, "typeNames cannot be null"); + Dbg.Assert(typeNames != null, "typeNames cannot be null"); bool atleastOneDeserializedTypeFound = false; diff --git a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs index eb6b8676931..6c14a7da62f 100644 --- a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs @@ -351,7 +351,7 @@ internal static Uri GetUriFromCommandPSObject(PSObject commandFullHelp) /// internal override bool MatchPatternInContent(WildcardPattern pattern) { - Dbg.Assert(null != pattern, "pattern cannot be null"); + Dbg.Assert(pattern != null, "pattern cannot be null"); string synopsis = Synopsis; string detailedDescription = DetailedDescription; diff --git a/src/System.Management.Automation/help/CommandHelpProvider.cs b/src/System.Management.Automation/help/CommandHelpProvider.cs index 88451a9fec8..01a633e8ffd 100644 --- a/src/System.Management.Automation/help/CommandHelpProvider.cs +++ b/src/System.Management.Automation/help/CommandHelpProvider.cs @@ -805,7 +805,7 @@ private HelpInfo GetFromCommandCache(string helpFileIdentifier, string commandNa /// HelpInfo object. private HelpInfo GetFromCommandCache(string helpFileIdentifier, CommandInfo commandInfo) { - Debug.Assert(null != commandInfo, "commandInfo cannot be null"); + Debug.Assert(commandInfo != null, "commandInfo cannot be null"); HelpInfo result = GetFromCommandCache(helpFileIdentifier, commandInfo.Name, commandInfo.HelpCategory); if (null == result) { @@ -835,7 +835,7 @@ private HelpInfo GetFromCommandCache(string helpFileIdentifier, CommandInfo comm /// private HelpInfo GetFromCommandCacheOrCmdletInfo(CmdletInfo cmdletInfo) { - Debug.Assert(null != cmdletInfo, "cmdletInfo cannot be null"); + Debug.Assert(cmdletInfo != null, "cmdletInfo cannot be null"); HelpInfo result = GetFromCommandCache(cmdletInfo.ModuleName, cmdletInfo.Name, cmdletInfo.HelpCategory); if (result == null) { @@ -886,7 +886,7 @@ private HelpInfo GetFromCommandCacheOrCmdletInfo(CmdletInfo cmdletInfo) /// private MamlCommandHelpInfo GetFromCommandCacheByRemovingPrefix(string helpIdentifier, CommandInfo cmdInfo) { - Dbg.Assert(null != cmdInfo, "cmdInfo cannot be null"); + Dbg.Assert(cmdInfo != null, "cmdInfo cannot be null"); MamlCommandHelpInfo result = null; MamlCommandHelpInfo originalHelpInfo = GetFromCommandCache(helpIdentifier, diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index c85869e5998..595c845aa13 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -575,7 +575,7 @@ private void WriteObjectsOrShowOnlineHelp(HelpInfo helpInfo, bool showFullHelp) /// private void LaunchOnlineHelp(Uri uriToLaunch) { - Diagnostics.Assert(null != uriToLaunch, "uriToLaunch should not be null"); + Diagnostics.Assert(uriToLaunch != null, "uriToLaunch should not be null"); if (!uriToLaunch.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase) && !uriToLaunch.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) diff --git a/src/System.Management.Automation/help/HelpFileHelpInfo.cs b/src/System.Management.Automation/help/HelpFileHelpInfo.cs index fe1338009cb..7aececdc4af 100644 --- a/src/System.Management.Automation/help/HelpFileHelpInfo.cs +++ b/src/System.Management.Automation/help/HelpFileHelpInfo.cs @@ -131,7 +131,7 @@ private static string GetLine(string text, int line) internal override bool MatchPatternInContent(WildcardPattern pattern) { - Diagnostics.Assert(null != pattern, "pattern cannot be null."); + Diagnostics.Assert(pattern != null, "pattern cannot be null."); string helpContent = string.Empty; LanguagePrimitives.TryConvertTo(FullHelp, out helpContent); diff --git a/src/System.Management.Automation/help/MamlCommandHelpInfo.cs b/src/System.Management.Automation/help/MamlCommandHelpInfo.cs index 94f2465ff14..825b840125f 100644 --- a/src/System.Management.Automation/help/MamlCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/MamlCommandHelpInfo.cs @@ -396,7 +396,7 @@ private string ExtractText(PSObject psObject) /// internal override bool MatchPatternInContent(WildcardPattern pattern) { - System.Management.Automation.Diagnostics.Assert(null != pattern, "pattern cannot be null"); + System.Management.Automation.Diagnostics.Assert(pattern != null, "pattern cannot be null"); string synopsis = Synopsis; if ((!string.IsNullOrEmpty(synopsis)) && (pattern.IsMatch(synopsis))) diff --git a/src/System.Management.Automation/help/ProviderContext.cs b/src/System.Management.Automation/help/ProviderContext.cs index 985f32c0a08..044d8524cd3 100644 --- a/src/System.Management.Automation/help/ProviderContext.cs +++ b/src/System.Management.Automation/help/ProviderContext.cs @@ -40,7 +40,7 @@ internal ProviderContext( ExecutionContext executionContext, PathIntrinsics pathIntrinsics) { - Dbg.Assert(null != executionContext, "ExecutionContext cannot be null."); + Dbg.Assert(executionContext != null, "ExecutionContext cannot be null."); _requestedPath = requestedPath; _executionContext = executionContext; _pathIntrinsics = pathIntrinsics; diff --git a/src/System.Management.Automation/help/ProviderHelpInfo.cs b/src/System.Management.Automation/help/ProviderHelpInfo.cs index 1061eac0f85..c48743091aa 100644 --- a/src/System.Management.Automation/help/ProviderHelpInfo.cs +++ b/src/System.Management.Automation/help/ProviderHelpInfo.cs @@ -164,7 +164,7 @@ internal override PSObject FullHelp /// internal override bool MatchPatternInContent(WildcardPattern pattern) { - Diagnostics.Assert(null != pattern, "pattern cannot be null"); + Diagnostics.Assert(pattern != null, "pattern cannot be null"); string synopsis = Synopsis; string detailedDescription = DetailedDescription; diff --git a/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs b/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs index c53d3ea7212..7b8949b00fe 100644 --- a/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs +++ b/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs @@ -257,7 +257,7 @@ internal ScriptRequiresException( : base(BuildMessage(commandName, requiresPSVersion.ToString(), currentPSVersion, false)) { Diagnostics.Assert(!string.IsNullOrEmpty(commandName), "commandName is null or empty when constructing ScriptRequiresException"); - Diagnostics.Assert(null != requiresPSVersion, "requiresPSVersion is null or empty when constructing ScriptRequiresException"); + Diagnostics.Assert(requiresPSVersion != null, "requiresPSVersion is null or empty when constructing ScriptRequiresException"); Diagnostics.Assert(!string.IsNullOrEmpty(errorId), "errorId is null or empty when constructing ScriptRequiresException"); _commandName = commandName; _requiresPSVersion = requiresPSVersion; From f4805cee8049d281314cb301e033fcebca4c58bc Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 14:16:15 +0500 Subject: [PATCH 05/27] Replace 'if \((null) != (\w+(.\w+)+)\)' -> 'if ($2 != $1)' --- src/System.Management.Automation/engine/pipeline.cs | 4 ++-- test/tools/WebListener/Controllers/CertController.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index 514eebbe465..9ad54dbea33 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -396,9 +396,9 @@ internal int AddCommand(CommandProcessorBase commandProcessor, int readFromComma throw PSTraceSource.NewInvalidOperationException(); } // check whether the error output is already claimed - if (null != prevcommandProcessor.CommandRuntime.ErrorOutputPipe.DownstreamCmdlet) + if (prevcommandProcessor.CommandRuntime.ErrorOutputPipe.DownstreamCmdlet != null) continue; - if (null != prevcommandProcessor.CommandRuntime.ErrorOutputPipe.ExternalWriter) + if (prevcommandProcessor.CommandRuntime.ErrorOutputPipe.ExternalWriter != null) continue; // Set the upstream cmdlet's error output to go down diff --git a/test/tools/WebListener/Controllers/CertController.cs b/test/tools/WebListener/Controllers/CertController.cs index d272eecd8a4..0e7eda84992 100644 --- a/test/tools/WebListener/Controllers/CertController.cs +++ b/test/tools/WebListener/Controllers/CertController.cs @@ -16,13 +16,13 @@ public class CertController : Controller public JsonResult Index() { // X509Certificate2 objects do not serialize as JSON. Create a HashTable instead - Hashtable output = new Hashtable + Hashtable output = new Hashtable { {"Status", "FAILED"} }; - if (null != HttpContext.Connection.ClientCertificate) - { - output = new Hashtable + if (HttpContext.Connection.ClientCertificate != null) + { + output = new Hashtable { {"Status" , "OK"}, {"Thumbprint" , HttpContext.Connection.ClientCertificate.Thumbprint}, From cd1b49db4de6ddc84954c2318a65177f45e2e3cf Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 14:21:04 +0500 Subject: [PATCH 06/27] Replace 'if \((null) != (.+)\)' -> 'if ($2 != $1)' --- .../common/Utilities/MshParameterAssociation.cs | 2 +- src/System.Management.Automation/engine/MshMemberInfo.cs | 2 +- .../remoting/common/WireDataFormat/EncodeAndDecode.cs | 6 +++--- .../engine/remoting/fanin/PriorityCollection.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs index 09a0cbcbd93..b40efda2f1c 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs @@ -180,7 +180,7 @@ internal static List ExpandAll(PSObje /// internal static void HandleComputerNameProperties(PSObject so, List activeAssociationList) { - if (null != so.Properties[RemotingConstants.ShowComputerNameNoteProperty]) + if (so.Properties[RemotingConstants.ShowComputerNameNoteProperty] != null) { // always remove PSShowComputerName for the display. This is an internal property // that should never be visible to the user. diff --git a/src/System.Management.Automation/engine/MshMemberInfo.cs b/src/System.Management.Automation/engine/MshMemberInfo.cs index b19f099db4e..02a4ae4a4d0 100644 --- a/src/System.Management.Automation/engine/MshMemberInfo.cs +++ b/src/System.Management.Automation/engine/MshMemberInfo.cs @@ -4371,7 +4371,7 @@ public static Collection PSTypeNames(PSObject o) internal static void GeneratePSTypeNames(object obj) { PSObject mshOwner = PSObject.AsPSObject(obj); - if (null != mshOwner.InstanceMembers[PSObject.PSTypeNames]) + if (mshOwner.InstanceMembers[PSObject.PSTypeNames] != null) { // PSTypeNames member set is already generated..just return. return; diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs index e1fb2a8a86e..927def72642 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs @@ -2228,7 +2228,7 @@ internal static PowerShell GetCommandDiscoveryPipeline(object data) CommandTypes commandType = GetPropertyValue(dataAsPSObject, RemoteDataNameStrings.DiscoveryType); string[] name; - if (null != GetPropertyValue(dataAsPSObject, RemoteDataNameStrings.DiscoveryName)) + if (GetPropertyValue(dataAsPSObject, RemoteDataNameStrings.DiscoveryName) != null) { IEnumerable tmp = EnumerateListProperty(dataAsPSObject, RemoteDataNameStrings.DiscoveryName); name = new List(tmp).ToArray(); @@ -2239,7 +2239,7 @@ internal static PowerShell GetCommandDiscoveryPipeline(object data) } string[] module; - if (null != GetPropertyValue(dataAsPSObject, RemoteDataNameStrings.DiscoveryModule)) + if (GetPropertyValue(dataAsPSObject, RemoteDataNameStrings.DiscoveryModule) != null) { IEnumerable tmp = EnumerateListProperty(dataAsPSObject, RemoteDataNameStrings.DiscoveryModule); module = new List(tmp).ToArray(); @@ -2259,7 +2259,7 @@ internal static PowerShell GetCommandDiscoveryPipeline(object data) } object[] argumentList; - if (null != GetPropertyValue(dataAsPSObject, RemoteDataNameStrings.DiscoveryArgumentList)) + if (GetPropertyValue(dataAsPSObject, RemoteDataNameStrings.DiscoveryArgumentList) != null) { IEnumerable tmp = EnumerateListProperty(dataAsPSObject, RemoteDataNameStrings.DiscoveryArgumentList); argumentList = new List(tmp).ToArray(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs index 8df154628bb..b104eb27410 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs @@ -167,7 +167,7 @@ Verify arrays and dataToBeSent objects before referencing. lock (_dataSyncObjects[promptResponseIndex]) { - if (null != _dataToBeSent[promptResponseIndex]) + if (_dataToBeSent[promptResponseIndex] != null) { _dataToBeSent[promptResponseIndex].Dispose(); _dataToBeSent[promptResponseIndex] = null; @@ -176,7 +176,7 @@ Verify arrays and dataToBeSent objects before referencing. lock (_dataSyncObjects[defaultIndex]) { - if (null != _dataToBeSent[defaultIndex]) + if (_dataToBeSent[defaultIndex] != null) { _dataToBeSent[defaultIndex].Dispose(); _dataToBeSent[defaultIndex] = null; From 6d863434237a9aa65b8292e3e3569ecaba732f25 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 14:26:05 +0500 Subject: [PATCH 07/27] Manual replacement 1 --- .../remoting/common/WireDataFormat/EncodeAndDecode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs index 927def72642..80f73ba9fea 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs @@ -2250,9 +2250,9 @@ internal static PowerShell GetCommandDiscoveryPipeline(object data) } ModuleSpecification[] fullyQualifiedName = null; - if (null != DeserializingTypeConverter.GetPropertyValue(dataAsPSObject, - RemoteDataNameStrings.DiscoveryFullyQualifiedModule, - DeserializingTypeConverter.RehydrationFlags.NullValueOk | DeserializingTypeConverter.RehydrationFlags.MissingPropertyOk)) + if (DeserializingTypeConverter.GetPropertyValue(dataAsPSObject, + RemoteDataNameStrings.DiscoveryFullyQualifiedModule, + DeserializingTypeConverter.RehydrationFlags.NullValueOk | DeserializingTypeConverter.RehydrationFlags.MissingPropertyOk) != null) { IEnumerable tmp = EnumerateListProperty(dataAsPSObject, RemoteDataNameStrings.DiscoveryFullyQualifiedModule); fullyQualifiedName = new List(tmp).ToArray(); From 087ab2321c4b7f6fc4668023947998ab768ec90b Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 14:29:40 +0500 Subject: [PATCH 08/27] Replace 'if \((null) != (\w+.\w+)' -> 'if ($2 != $1' --- .../commands/management/Service.cs | 4 ++-- src/System.Management.Automation/engine/ErrorPackage.cs | 6 +++--- .../engine/MshCommandRuntime.cs | 6 +++--- .../namespaces/CoreCommandContext.cs | 2 +- src/System.Management.Automation/namespaces/ProviderBase.cs | 4 ++-- src/System.Management.Automation/utils/RuntimeException.cs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 8b70d47467b..79df2ddbba5 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -1067,7 +1067,7 @@ internal bool DoPauseService(ServiceController serviceController) catch (InvalidOperationException e) { Win32Exception eInner = e.InnerException as Win32Exception; - if (null != eInner + if (eInner != null && NativeMethods.ERROR_SERVICE_NOT_ACTIVE == eInner.NativeErrorCode) { serviceNotRunning = true; @@ -1145,7 +1145,7 @@ internal bool DoResumeService(ServiceController serviceController) catch (InvalidOperationException e) { Win32Exception eInner = e.InnerException as Win32Exception; - if (null != eInner + if (eInner != null && NativeMethods.ERROR_SERVICE_NOT_ACTIVE == eInner.NativeErrorCode) { serviceNotRunning = true; diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index 6cb4b8925fd..5bada71cfb7 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -247,7 +247,7 @@ public string Activity if (!String.IsNullOrEmpty(_errorRecord._activityOverride)) return _errorRecord._activityOverride; - if (null != _errorRecord.InvocationInfo + if (_errorRecord.InvocationInfo != null && (_errorRecord.InvocationInfo.MyCommand is CmdletInfo || _errorRecord.InvocationInfo.MyCommand is IScriptCommandInfo) && !String.IsNullOrEmpty(_errorRecord.InvocationInfo.MyCommand.Name) ) @@ -1385,7 +1385,7 @@ public ErrorRecord(ErrorRecord errorRecord, throw new PSArgumentNullException("errorRecord"); } - if (null != replaceParentContainsErrorRecordException + if (replaceParentContainsErrorRecordException != null && (errorRecord.Exception is ParentContainsErrorRecordException)) { _error = replaceParentContainsErrorRecordException; @@ -1681,7 +1681,7 @@ private string GetInvocationTypeName() /// developer-readable identifier public override string ToString() { - if (null != ErrorDetails + if (ErrorDetails != null && !String.IsNullOrEmpty(ErrorDetails.Message)) { return ErrorDetails.Message; diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 7fc2b105125..14f41aea4ea 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2030,7 +2030,7 @@ public void ThrowTerminatingError(ErrorRecord errorRecord) } errorRecord.SetInvocationInfo(MyInvocation); - if (null != errorRecord.ErrorDetails + if (errorRecord.ErrorDetails != null && null != errorRecord.ErrorDetails.TextLookupError) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; @@ -2042,7 +2042,7 @@ public void ThrowTerminatingError(ErrorRecord errorRecord) } // This code forces the stack trace and source fields to be populated - if (null != errorRecord.Exception + if (errorRecord.Exception != null && String.IsNullOrEmpty(errorRecord.Exception.StackTrace)) { try @@ -2756,7 +2756,7 @@ internal void _WriteErrorSkipAllowCheck(ErrorRecord errorRecord, ActionPreferenc { ThrowIfStopping(); - if (null != errorRecord.ErrorDetails + if (errorRecord.ErrorDetails != null && null != errorRecord.ErrorDetails.TextLookupError) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; diff --git a/src/System.Management.Automation/namespaces/CoreCommandContext.cs b/src/System.Management.Automation/namespaces/CoreCommandContext.cs index a5183f68523..dd43ddac8f4 100644 --- a/src/System.Management.Automation/namespaces/CoreCommandContext.cs +++ b/src/System.Management.Automation/namespaces/CoreCommandContext.cs @@ -1195,7 +1195,7 @@ internal void WriteError(ErrorRecord errorRecord) // Since we are not streaming, just add the object to the accumulatedErrorObjects _accumulatedErrorObjects.Add(errorRecord); - if (null != errorRecord.ErrorDetails + if (errorRecord.ErrorDetails != null && null != errorRecord.ErrorDetails.TextLookupError) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; diff --git a/src/System.Management.Automation/namespaces/ProviderBase.cs b/src/System.Management.Automation/namespaces/ProviderBase.cs index eefaf9d9be7..c9814dbf7ae 100644 --- a/src/System.Management.Automation/namespaces/ProviderBase.cs +++ b/src/System.Management.Automation/namespaces/ProviderBase.cs @@ -1582,7 +1582,7 @@ public void ThrowTerminatingError(ErrorRecord errorRecord) throw PSTraceSource.NewArgumentNullException("errorRecord"); } - if (null != errorRecord.ErrorDetails + if (errorRecord.ErrorDetails != null && null != errorRecord.ErrorDetails.TextLookupError) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; @@ -2113,7 +2113,7 @@ public void WriteError(ErrorRecord errorRecord) throw PSTraceSource.NewArgumentNullException("errorRecord"); } - if (null != errorRecord.ErrorDetails + if (errorRecord.ErrorDetails != null && null != errorRecord.ErrorDetails.TextLookupError) { MshLog.LogProviderHealthEvent( diff --git a/src/System.Management.Automation/utils/RuntimeException.cs b/src/System.Management.Automation/utils/RuntimeException.cs index 9a0e04decc3..37c04fa34cd 100644 --- a/src/System.Management.Automation/utils/RuntimeException.cs +++ b/src/System.Management.Automation/utils/RuntimeException.cs @@ -224,7 +224,7 @@ internal static string RetrieveMessage(ErrorRecord errorRecord) { if (null == errorRecord) return ""; - if (null != errorRecord.ErrorDetails && + if (errorRecord.ErrorDetails != null && !String.IsNullOrEmpty(errorRecord.ErrorDetails.Message)) { return errorRecord.ErrorDetails.Message; From 2e1f53778c2ce14d7639ef6a1a4c5ba3b72a9e18 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:16:57 +0500 Subject: [PATCH 09/27] Replace '\b(null) != (\w+)\)' -> '$2 != $1)' --- .../commands/management/Service.cs | 2 +- src/System.Management.Automation/engine/ParameterBinderBase.cs | 2 +- .../engine/remoting/fanin/PriorityCollection.cs | 2 +- src/System.Management.Automation/help/HelpCommands.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 79df2ddbba5..5cc527ad692 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -1666,7 +1666,7 @@ protected override void ProcessRecord() } // Modify startup type or display name or credential if (!String.IsNullOrEmpty(DisplayName) - || ServiceStartupType.InvalidValue != StartupType || null != Credential) + || ServiceStartupType.InvalidValue != StartupType || Credential != null) { DWORD dwStartType = NativeMethods.SERVICE_NO_CHANGE; if (!NativeMethods.TryGetNativeStartupType(StartupType, out dwStartType)) diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index b7c9a878c0b..30b1069503f 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -1742,7 +1742,7 @@ private object EncodeCollection( null, valueElement); } - else if (collectionElementType != null && null != currentValueElement) + else if (collectionElementType != null && currentValueElement != null) { Type currentValueElementType = currentValueElement.GetType(); Type desiredElementType = collectionElementType; diff --git a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs index b104eb27410..5d476d89f52 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs @@ -160,7 +160,7 @@ internal void Clear() causing an unhandled exception in finalize and a process crash. Verify arrays and dataToBeSent objects before referencing. */ - if (_dataSyncObjects != null && null != _dataToBeSent) + if (_dataSyncObjects != null && _dataToBeSent != null) { int promptResponseIndex = (int)DataPriorityType.PromptResponse; int defaultIndex = (int)DataPriorityType.Default; diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index 595c845aa13..e50d31e59cf 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -787,7 +787,7 @@ public static string GetHelpUri(PSObject commandInfoPSObject) foreach ( Uri result in currentContext.HelpSystem.ExactMatchHelp(helpRequest).Select( - helpInfo => helpInfo.GetUriForOnlineHelp()).Where(result => null != result)) + helpInfo => helpInfo.GetUriForOnlineHelp()).Where(result => result != null)) { return result.OriginalString; } From 753348e81930136f3995e31f8f9d77aae232e7cf Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:19:04 +0500 Subject: [PATCH 10/27] Replace \b(null) != (\w+.\w+)\) -> '$2 != $1)' --- .../engine/CommandProcessorBase.cs | 4 ++-- .../engine/ParameterBinderBase.cs | 4 ++-- src/System.Management.Automation/engine/pipeline.cs | 4 ++-- src/System.Management.Automation/logging/MshLog.cs | 6 +++--- .../logging/eventlog/EventLogLogProvider.cs | 6 +++--- .../utils/ExecutionExceptions.cs | 2 +- .../utils/SessionStateExceptions.cs | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs index 8caf5d89038..562f6a9572e 100644 --- a/src/System.Management.Automation/engine/CommandProcessorBase.cs +++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs @@ -873,7 +873,7 @@ internal PipelineStoppedException ManageInvocationException(Exception e) /// internal void ManageScriptException(RuntimeException e) { - if (Command != null && null != commandRuntime.PipelineProcessor) + if (Command != null && commandRuntime.PipelineProcessor != null) { commandRuntime.PipelineProcessor.RecordFailure(e, Command); @@ -892,7 +892,7 @@ internal void ManageScriptException(RuntimeException e) /// internal void ForgetScriptException() { - if (Command != null && null != commandRuntime.PipelineProcessor) + if (Command != null && commandRuntime.PipelineProcessor != null) { commandRuntime.PipelineProcessor.ForgetFailure(); } diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index 30b1069503f..6ebd923b8ed 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -1793,7 +1793,7 @@ private object EncodeCollection( // The inner exception to TargetInvocationException // (if present) has a better Message if (error is TargetInvocationException && - null != error.InnerException) + error.InnerException != null) { error = error.InnerException; } @@ -1890,7 +1890,7 @@ private object EncodeCollection( // The inner exception to TargetInvocationException // (if present) has a better Message if (error is TargetInvocationException && - null != error.InnerException) + error.InnerException != null) { error = error.InnerException; } diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index 9ad54dbea33..6757080ae97 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -187,7 +187,7 @@ private string GetCommand(InvocationInfo invocationInfo) private string GetCommand(Exception exception) { IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) return GetCommand(icer.ErrorRecord.InvocationInfo); return ""; @@ -1384,7 +1384,7 @@ internal bool RecordFailure(Exception e, InternalCommand command) // before hitting the error, therefore we check whether // firstTerminatingError is PipelineStoppedException. else if ((!(_firstTerminatingError.SourceException is PipelineStoppedException)) - && null != command && null != command.Context) + && null != command && command.Context != null) { Exception ex = e; while ((ex is TargetInvocationException || ex is CmdletInvocationException) diff --git a/src/System.Management.Automation/logging/MshLog.cs b/src/System.Management.Automation/logging/MshLog.cs index 51fe632ac32..61b0e3c2208 100644 --- a/src/System.Management.Automation/logging/MshLog.cs +++ b/src/System.Management.Automation/logging/MshLog.cs @@ -222,7 +222,7 @@ internal static void LogEngineHealthEvent(ExecutionContext executionContext, InvocationInfo invocationInfo = null; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) invocationInfo = icer.ErrorRecord.InvocationInfo; foreach (LogProvider provider in GetLogProvider(executionContext)) { @@ -425,7 +425,7 @@ Severity severity InvocationInfo invocationInfo = null; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) invocationInfo = icer.ErrorRecord.InvocationInfo; foreach (LogProvider provider in GetLogProvider(executionContext)) { @@ -617,7 +617,7 @@ Severity severity InvocationInfo invocationInfo = null; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) invocationInfo = icer.ErrorRecord.InvocationInfo; foreach (LogProvider provider in GetLogProvider(executionContext)) { diff --git a/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs b/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs index 1ef000f969a..d1d02b5d784 100644 --- a/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs +++ b/src/System.Management.Automation/logging/eventlog/EventLogLogProvider.cs @@ -100,7 +100,7 @@ internal override void LogEngineHealthEvent(LogContext logContext, int eventId, Hashtable mapArgs = new Hashtable(); IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) { mapArgs["ExceptionClass"] = exception.GetType().Name; mapArgs["ErrorCategory"] = icer.ErrorRecord.CategoryInfo.Category; @@ -221,7 +221,7 @@ internal override void LogCommandHealthEvent(LogContext logContext, Exception ex Hashtable mapArgs = new Hashtable(); IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) { mapArgs["ExceptionClass"] = exception.GetType().Name; mapArgs["ErrorCategory"] = icer.ErrorRecord.CategoryInfo.Category; @@ -399,7 +399,7 @@ internal override void LogProviderHealthEvent(LogContext logContext, string prov mapArgs["ProviderName"] = providerName; IContainsErrorRecord icer = exception as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) { mapArgs["ExceptionClass"] = exception.GetType().Name; mapArgs["ErrorCategory"] = icer.ErrorRecord.CategoryInfo.Category; diff --git a/src/System.Management.Automation/utils/ExecutionExceptions.cs b/src/System.Management.Automation/utils/ExecutionExceptions.cs index 6a56e18a836..1cdde0bc30f 100644 --- a/src/System.Management.Automation/utils/ExecutionExceptions.cs +++ b/src/System.Management.Automation/utils/ExecutionExceptions.cs @@ -62,7 +62,7 @@ internal CmdletInvocationException(Exception innerException, // invocationInfo may be null IContainsErrorRecord icer = innerException as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) { _errorRecord = new ErrorRecord(icer.ErrorRecord, innerException); } diff --git a/src/System.Management.Automation/utils/SessionStateExceptions.cs b/src/System.Management.Automation/utils/SessionStateExceptions.cs index a236f0a16cb..5cc700b5f8b 100644 --- a/src/System.Management.Automation/utils/SessionStateExceptions.cs +++ b/src/System.Management.Automation/utils/SessionStateExceptions.cs @@ -73,7 +73,7 @@ internal ProviderInvocationException(ProviderInfo provider, Exception innerExcep _providerInfo = provider; IContainsErrorRecord icer = innerException as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) { _errorRecord = new ErrorRecord(icer.ErrorRecord, innerException); } @@ -226,7 +226,7 @@ internal ProviderInvocationException( } IContainsErrorRecord icer = innerException as IContainsErrorRecord; - if (icer != null && null != icer.ErrorRecord) + if (icer != null && icer.ErrorRecord != null) { _errorRecord = new ErrorRecord(icer.ErrorRecord, errorRecordException); } From a801dde066f6c781bf7c35aee503b1d180675b09 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:21:51 +0500 Subject: [PATCH 11/27] Replace '\b(null) != (\w+.\w+.\w+)\)' -> '$2 != $1)' --- .../FormatAndOutput/common/FormatViewGenerator_List.cs | 4 ++-- .../FormatAndOutput/common/FormatViewGenerator_Table.cs | 4 ++-- src/System.Management.Automation/engine/MshCommandRuntime.cs | 4 ++-- .../namespaces/CoreCommandContext.cs | 2 +- src/System.Management.Automation/namespaces/ProviderBase.cs | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs index 96ee8800c4f..227b75be241 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs @@ -16,7 +16,7 @@ internal sealed class ListViewGenerator : ViewGenerator internal override void Initialize(TerminatingErrorContext terminatingErrorContext, MshExpressionFactory mshExpressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters formatParameters) { base.Initialize(terminatingErrorContext, mshExpressionFactory, db, view, formatParameters); - if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (this.dataBaseInfo.view != null)) { _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl; } @@ -26,7 +26,7 @@ internal override void Initialize(TerminatingErrorContext errorContext, MshExpre PSObject so, TypeInfoDataBase db, FormattingCommandLineParameters parameters) { base.Initialize(errorContext, expressionFactory, so, db, parameters); - if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (this.dataBaseInfo.view != null)) { _listBody = (ListControlBody)this.dataBaseInfo.view.mainControl; } diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs index 4259a8334c6..d8d6a7f9d06 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs @@ -17,7 +17,7 @@ internal sealed class TableViewGenerator : ViewGenerator internal override void Initialize(TerminatingErrorContext terminatingErrorContext, MshExpressionFactory mshExpressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters formatParameters) { base.Initialize(terminatingErrorContext, mshExpressionFactory, db, view, formatParameters); - if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (this.dataBaseInfo.view != null)) { _tableBody = (TableControlBody)this.dataBaseInfo.view.mainControl; } @@ -29,7 +29,7 @@ internal override void Initialize(TerminatingErrorContext errorContext, MshExpre { base.Initialize(errorContext, expressionFactory, so, db, parameters); - if ((this.dataBaseInfo != null) && (null != this.dataBaseInfo.view)) + if ((this.dataBaseInfo != null) && (this.dataBaseInfo.view != null)) { _tableBody = (TableControlBody)this.dataBaseInfo.view.mainControl; } diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 14f41aea4ea..357ec023d43 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2031,7 +2031,7 @@ public void ThrowTerminatingError(ErrorRecord errorRecord) errorRecord.SetInvocationInfo(MyInvocation); if (errorRecord.ErrorDetails != null - && null != errorRecord.ErrorDetails.TextLookupError) + && errorRecord.ErrorDetails.TextLookupError != null) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; errorRecord.ErrorDetails.TextLookupError = null; @@ -2757,7 +2757,7 @@ internal void _WriteErrorSkipAllowCheck(ErrorRecord errorRecord, ActionPreferenc ThrowIfStopping(); if (errorRecord.ErrorDetails != null - && null != errorRecord.ErrorDetails.TextLookupError) + && errorRecord.ErrorDetails.TextLookupError != null) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; errorRecord.ErrorDetails.TextLookupError = null; diff --git a/src/System.Management.Automation/namespaces/CoreCommandContext.cs b/src/System.Management.Automation/namespaces/CoreCommandContext.cs index dd43ddac8f4..affa223d9de 100644 --- a/src/System.Management.Automation/namespaces/CoreCommandContext.cs +++ b/src/System.Management.Automation/namespaces/CoreCommandContext.cs @@ -1196,7 +1196,7 @@ internal void WriteError(ErrorRecord errorRecord) _accumulatedErrorObjects.Add(errorRecord); if (errorRecord.ErrorDetails != null - && null != errorRecord.ErrorDetails.TextLookupError) + && errorRecord.ErrorDetails.TextLookupError != null) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; errorRecord.ErrorDetails.TextLookupError = null; diff --git a/src/System.Management.Automation/namespaces/ProviderBase.cs b/src/System.Management.Automation/namespaces/ProviderBase.cs index c9814dbf7ae..7fb34e4bf3b 100644 --- a/src/System.Management.Automation/namespaces/ProviderBase.cs +++ b/src/System.Management.Automation/namespaces/ProviderBase.cs @@ -1583,7 +1583,7 @@ public void ThrowTerminatingError(ErrorRecord errorRecord) } if (errorRecord.ErrorDetails != null - && null != errorRecord.ErrorDetails.TextLookupError) + && errorRecord.ErrorDetails.TextLookupError != null) { Exception textLookupError = errorRecord.ErrorDetails.TextLookupError; errorRecord.ErrorDetails.TextLookupError = null; @@ -2114,7 +2114,7 @@ public void WriteError(ErrorRecord errorRecord) } if (errorRecord.ErrorDetails != null - && null != errorRecord.ErrorDetails.TextLookupError) + && errorRecord.ErrorDetails.TextLookupError != null) { MshLog.LogProviderHealthEvent( this.Context.ExecutionContext, From d57088dd372b2175dcd2aeb8f7b980c64befcc13 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:31:47 +0500 Subject: [PATCH 12/27] Replace '\((null) != (\w+.\w+),' -> '($2 != $1,' --- .../utils/GraphicalHostReflectionWrapper.cs | 2 +- src/System.Management.Automation/utils/ObjectReader.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs b/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs index 5abc98bedaf..e8bc19a185c 100644 --- a/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs +++ b/src/System.Management.Automation/utils/GraphicalHostReflectionWrapper.cs @@ -209,7 +209,7 @@ internal object GetStaticPropertyValue(string propertyName) /// true if the is being run remotely private static bool IsInputFromRemoting(PSCmdlet parentCmdlet) { - Diagnostics.Assert(null != parentCmdlet.SessionState, "SessionState should always be available."); + Diagnostics.Assert(parentCmdlet.SessionState != null, "SessionState should always be available."); PSVariable senderInfo = parentCmdlet.SessionState.PSVariable.Get("PSSenderInfo"); return senderInfo != null; diff --git a/src/System.Management.Automation/utils/ObjectReader.cs b/src/System.Management.Automation/utils/ObjectReader.cs index 8b481ed757d..2f406d9126b 100644 --- a/src/System.Management.Automation/utils/ObjectReader.cs +++ b/src/System.Management.Automation/utils/ObjectReader.cs @@ -501,7 +501,7 @@ internal class PSDataCollectionReader public PSDataCollectionReader(PSDataCollectionStream stream) : base(stream) { - System.Management.Automation.Diagnostics.Assert(null != stream.ObjectStore, + System.Management.Automation.Diagnostics.Assert(stream.ObjectStore != null, "Stream should have a valid data store"); _enumerator = (PSDataCollectionEnumerator)stream.ObjectStore.GetEnumerator(); } @@ -661,7 +661,7 @@ internal PSDataCollectionPipelineReader(PSDataCollectionStream st String computerName, Guid runspaceId) : base(stream) { - System.Management.Automation.Diagnostics.Assert(null != stream.ObjectStore, + System.Management.Automation.Diagnostics.Assert(stream.ObjectStore != null, "Stream should have a valid data store"); _datastore = stream.ObjectStore; ComputerName = computerName; @@ -822,4 +822,4 @@ protected override void Dispose(bool disposing) #endregion IDisposable } -} \ No newline at end of file +} From 1487874c4f903a82e68765c892a55c9bf8f60952 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:34:52 +0500 Subject: [PATCH 13/27] Replace '\((null) != (\w+.\w+) ' -> '($2 != $1 ' Also removed extra curves --- .../commands/utility/write.cs | 2 +- src/System.Management.Automation/engine/MshCommandRuntime.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs index 489e5d768c3..a8e2786b750 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs @@ -337,7 +337,7 @@ protected override void ProcessRecord() TargetObject ); - if ((null != this.Exception && !String.IsNullOrEmpty(msg))) + if (this.Exception != null && !String.IsNullOrEmpty(msg)) { errorRecord.ErrorDetails = new ErrorDetails(msg); } diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 357ec023d43..c4299e11a8e 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -132,7 +132,7 @@ internal InvocationInfo MyInvocation /// internal bool IsStopping { - get { return (null != this.PipelineProcessor && this.PipelineProcessor.Stopping); } + get { return (this.PipelineProcessor != null && this.PipelineProcessor.Stopping); } } #region Write From 757fcf78a39efd18720893eeba50d45889524387 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:37:47 +0500 Subject: [PATCH 14/27] Replace '\((null) != (\w+.\w+\[\w+.\w+\])' -> '($2 != $1' --- .../FormatAndOutput/common/FormatViewGenerator_List.cs | 2 +- .../FormatAndOutput/common/FormatViewGenerator_Table.cs | 2 +- .../FormatAndOutput/common/Utilities/MshParameterAssociation.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs index 227b75be241..3b64244b493 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_List.cs @@ -45,7 +45,7 @@ internal override void PrepareForRemoteObjects(PSObject so) Diagnostics.Assert(so != null, "so cannot be null"); // make sure computername property exists. - Diagnostics.Assert(null != so.Properties[RemotingConstants.ComputerNameNoteProperty], + Diagnostics.Assert(so.Properties[RemotingConstants.ComputerNameNoteProperty] != null, "PrepareForRemoteObjects cannot be called when the object does not contain ComputerName property."); if ((dataBaseInfo != null) && (dataBaseInfo.view != null) && (dataBaseInfo.view.mainControl != null)) diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs index d8d6a7f9d06..6e42947703e 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs @@ -85,7 +85,7 @@ internal override void PrepareForRemoteObjects(PSObject so) Diagnostics.Assert(so != null, "so cannot be null"); // make sure computername property exists. - Diagnostics.Assert(null != so.Properties[RemotingConstants.ComputerNameNoteProperty], + Diagnostics.Assert(so.Properties[RemotingConstants.ComputerNameNoteProperty] != null, "PrepareForRemoteObjects cannot be called when the object does not contain ComputerName property."); if ((dataBaseInfo != null) && (dataBaseInfo.view != null) && (dataBaseInfo.view.mainControl != null)) diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs index b40efda2f1c..9d4a62d56ae 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs @@ -199,7 +199,7 @@ internal static void HandleComputerNameProperties(PSObject so, List In this case we want to show // PSComputerName - if ((null != so.Properties[RemotingConstants.ComputerNameNoteProperty]) && + if ((so.Properties[RemotingConstants.ComputerNameNoteProperty] != null) && (!PSObjectHelper.ShouldShowComputerNameProperty(so))) { foreach (MshResolvedExpressionParameterAssociation cpProp in activeAssociationList) From 93890adb1365ed52aaf81a2a11665af7f3b38cbe Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:41:34 +0500 Subject: [PATCH 15/27] Replace '\b(null) != (\w+.\w+)' -> $2 != $1 --- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 4 ++-- .../commands/utility/compare-object.cs | 2 +- src/System.Management.Automation/engine/pipeline.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 91a921b26f8..4d7748758a7 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 @@ -1367,9 +1367,9 @@ protected override void ProcessRecord() // if the request contains an authorization header and PreserveAuthorizationOnRedirect is not set, // it needs to be stripped on the first redirect. - bool keepAuthorization = null != WebSession + bool keepAuthorization = WebSession != null && - null != WebSession.Headers + WebSession.Headers != null && PreserveAuthorizationOnRedirect.IsPresent && diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs index de57416611b..a70ac3f91dc 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs @@ -164,7 +164,7 @@ private void Process(OrderByPropertyEntry differenceEntry) // Return // 2005/07/19 Switched order of referenceEntry and differenceEntry // so that we cast differenceEntry to the type of referenceEntry. - if (referenceEntry != null && null != differenceEntry && + if (referenceEntry != null && differenceEntry != null && 0 == _comparer.Compare(referenceEntry, differenceEntry)) { EmitMatch(referenceEntry); diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index 6757080ae97..fe9b6b64d2a 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -1384,7 +1384,7 @@ internal bool RecordFailure(Exception e, InternalCommand command) // before hitting the error, therefore we check whether // firstTerminatingError is PipelineStoppedException. else if ((!(_firstTerminatingError.SourceException is PipelineStoppedException)) - && null != command && command.Context != null) + && command != null && command.Context != null) { Exception ex = e; while ((ex is TargetInvocationException || ex is CmdletInvocationException) From 658c33bb3b8f0a5ed1cb64dd8c9d8f5afbdfb5bc Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:51:27 +0500 Subject: [PATCH 16/27] Replace '\((null) == (\w+)\)' -> '($2 == $1)' --- .../commands/management/Process.cs | 10 ++-- .../commands/management/Service.cs | 12 ++--- .../OutGridView/OutWindowProxy.cs | 10 ++-- .../FormatAndOutput/out-file/Out-File.cs | 6 +-- .../commands/utility/GetUnique.cs | 6 +-- .../utility/ImplicitRemotingCommands.cs | 2 +- .../ShowCommand/ShowCommandCommandInfo.cs | 6 +-- .../ShowCommand/ShowCommandModuleInfo.cs | 6 +-- .../ShowCommand/ShowCommandParameterInfo.cs | 6 +-- .../ShowCommandParameterSetInfo.cs | 6 +-- .../ShowCommand/ShowCommandParameterType.cs | 6 +-- .../Common/InvokeRestMethodCommand.Common.cs | 6 +-- .../Common/WebRequestPSCmdlet.Common.cs | 14 ++--- .../Common/WebResponseObject.Common.cs | 2 +- .../InvokeWebRequestCommand.CoreClr.cs | 2 +- .../utility/WebCmdlet/StreamHelper.cs | 4 +- .../utility/WebCmdlet/WebRequestSession.cs | 2 +- .../commands/utility/Write-Object.cs | 2 +- .../commands/utility/write.cs | 2 +- .../LocalAccounts/LocalGroup.cs | 2 +- .../LocalAccounts/LocalUser.cs | 2 +- .../ConfigProvider.cs | 36 ++++++------- src/Microsoft.WSMan.Management/CredSSP.cs | 8 +-- .../CoreCLR/CorePsPlatform.cs | 6 +-- .../common/DisplayDatabase/FormatTable.cs | 2 +- .../common/DisplayDatabase/typeDataQuery.cs | 6 +-- .../common/Utilities/MshObjectUtil.cs | 2 +- .../other/ciminstancetypeadapter.cs | 14 ++--- .../engine/CmdletParameterBinderController.cs | 2 +- .../engine/CodeMethods.cs | 4 +- .../engine/CompiledCommandParameter.cs | 2 +- .../engine/EnumExpressionEvaluator.cs | 2 +- .../engine/ErrorPackage.cs | 16 +++--- .../engine/ExecutionContext.cs | 20 +++---- .../engine/ExtendedTypeSystemException.cs | 2 +- .../engine/ExtraAdapter.cs | 2 +- .../engine/ManagementObjectAdapter.cs | 2 +- .../engine/MshCommandRuntime.cs | 14 ++--- .../engine/MshMemberInfo.cs | 4 +- .../engine/MshObject.cs | 4 +- .../engine/MshSecurityException.cs | 2 +- .../engine/NativeCommandProcessor.cs | 2 +- .../engine/PSConfiguration.cs | 2 +- .../engine/ParameterBinderBase.cs | 20 +++---- .../engine/ProxyCommand.cs | 18 +++---- .../engine/PseudoParameterBinder.cs | 2 +- .../engine/TypeMetadata.cs | 4 +- .../engine/TypeTable.cs | 4 +- .../engine/debugger/Breakpoint.cs | 2 +- .../engine/hostifaces/AsyncResult.cs | 4 +- .../hostifaces/InternalHostUserInterface.cs | 2 +- .../hostifaces/NativeCultureResolver.cs | 12 ++--- .../engine/hostifaces/PSCommand.cs | 16 +++--- .../engine/hostifaces/PSDataCollection.cs | 8 +-- .../engine/hostifaces/PowerShell.cs | 38 ++++++------- .../engine/hostifaces/RunspacePool.cs | 8 +-- .../engine/hostifaces/RunspacePoolInternal.cs | 18 +++---- .../engine/hostifaces/pipelinebase.cs | 2 +- .../engine/lang/parserutils.cs | 2 +- .../engine/pipeline.cs | 16 +++--- .../engine/regex.cs | 2 +- .../engine/remoting/client/Job.cs | 16 +++--- .../client/RemoteRunspacePoolInternal.cs | 10 ++-- .../engine/remoting/client/remotepipeline.cs | 2 +- .../remoting/commands/CustomShellCommands.cs | 4 +- .../commands/NewPSSessionConfigurationFile.cs | 2 +- .../engine/remoting/common/DispatchTable.cs | 2 +- .../remoting/common/RunspaceConnectionInfo.cs | 2 +- .../WireDataFormat/RemoteSessionCapability.cs | 2 +- .../engine/remoting/common/fragmentor.cs | 4 +- .../engine/remoting/common/throttlemanager.cs | 2 +- .../fanin/InitialSessionStateProvider.cs | 4 +- .../fanin/OutOfProcTransportManager.cs | 6 +-- .../remoting/fanin/PriorityCollection.cs | 4 +- .../engine/remoting/fanin/WSManPlugin.cs | 54 +++++++++---------- .../remoting/fanin/WSManPluginFacade.cs | 2 +- .../remoting/fanin/WSManPluginShellSession.cs | 8 +-- .../fanin/WSManPluginTransportManager.cs | 2 +- .../remoting/fanin/WSManTransportManager.cs | 6 +-- .../remoting/server/serverremotesession.cs | 2 +- .../engine/runtime/Binding/Binders.cs | 2 +- .../engine/serialization.cs | 2 +- .../help/BaseCommandHelpInfo.cs | 8 +-- .../help/CabinetNativeApi.cs | 4 +- .../help/CommandHelpProvider.cs | 6 +-- .../help/HelpCommands.cs | 4 +- .../help/MamlCommandHelpInfo.cs | 2 +- .../help/ProviderHelpInfo.cs | 6 +-- .../help/ProviderHelpProvider.cs | 2 +- .../namespaces/ProviderBase.cs | 2 +- .../namespaces/SafeTransactionHandle.cs | 2 +- .../namespaces/TransactedRegistryKey.cs | 2 +- .../config/MshSnapinLoadException.cs | 2 +- .../utils/CommandDiscoveryExceptions.cs | 2 +- .../utils/CryptoUtils.cs | 4 +- .../utils/ExecutionExceptions.cs | 16 +++--- .../utils/MshArgumentException.cs | 2 +- .../utils/MshArgumentNullException.cs | 2 +- .../utils/MshArgumentOutOfRangeException.cs | 2 +- .../utils/MshInvalidOperationException.cs | 2 +- .../utils/MshNotImplementedException.cs | 2 +- .../utils/MshNotSupportedException.cs | 2 +- .../utils/MshObjectDisposedException.cs | 2 +- .../utils/ObjectReader.cs | 8 +-- .../utils/ObjectStream.cs | 26 ++++----- .../utils/PsUtils.cs | 2 +- .../utils/RuntimeException.cs | 14 ++--- .../utils/SessionStateExceptions.cs | 10 ++-- 108 files changed, 360 insertions(+), 360 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index b5666c6af95..ad91a1d6218 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -170,7 +170,7 @@ private static int ProcessComparison(Process x, Process y) /// private void RetrieveMatchingProcessesByProcessName() { - if (null == processNames) + if (processNames == null) { _matchingProcesses = new List(AllProcesses); return; @@ -211,7 +211,7 @@ private void RetrieveMatchingProcessesByProcessName() /// private void RetrieveMatchingProcessesById() { - if (null == processIds) + if (processIds == null) { Diagnostics.Assert(false, "null processIds"); throw PSTraceSource.NewInvalidOperationException(); @@ -246,7 +246,7 @@ private void RetrieveMatchingProcessesById() /// private void RetrieveProcessesByInput() { - if (null == InputObject) + if (InputObject == null) { Diagnostics.Assert(false, "null InputObject"); throw PSTraceSource.NewInvalidOperationException(); @@ -271,7 +271,7 @@ internal Process[] AllProcesses { get { - if (null == _allProcesses) + if (_allProcesses == null) { List processes = new List(); processes.AddRange(Process.GetProcesses()); @@ -347,7 +347,7 @@ internal void WriteNonTerminatingError( string message = StringUtil.Format(resourceId, processName, processId, - (null == innerException) ? "" : innerException.Message); + (innerException == null) ? "" : innerException.Message); ProcessCommandException exception = new ProcessCommandException(message, innerException); exception.ProcessName = processName; diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 5cc527ad692..9b3dd1052f7 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -103,7 +103,7 @@ internal void WriteNonTerminatingError( string message = StringUtil.Format(errorMessage, serviceName, displayName, - (null == innerException) ? String.Empty : innerException.Message); + (innerException == null) ? String.Empty : innerException.Message); var exception = new ServiceCommandException(message, innerException); exception.ServiceName = serviceName; @@ -261,7 +261,7 @@ internal ServiceController[] AllServices { get { - if (null == _allServices) + if (_allServices == null) { _allServices = ServiceController.GetServices(); } @@ -339,7 +339,7 @@ private List MatchingServicesByServiceName() { List matchingServices = new List(); - if (null == serviceNames) + if (serviceNames == null) { foreach (ServiceController service in AllServices) { @@ -399,7 +399,7 @@ private List MatchingServicesByServiceName() private List MatchingServicesByDisplayName() { List matchingServices = new List(); - if (null == DisplayName) + if (DisplayName == null) { Diagnostics.Assert(false, "null DisplayName"); throw PSTraceSource.NewInvalidOperationException(); @@ -439,7 +439,7 @@ private List MatchingServicesByDisplayName() private List MatchingServicesByInput() { List matchingServices = new List(); - if (null == InputObject) + if (InputObject == null) { Diagnostics.Assert(false, "null InputObject"); throw PSTraceSource.NewInvalidOperationException(); @@ -493,7 +493,7 @@ private void IncludeExcludeAdd( /// private bool Matches(ServiceController service, string[] matchList) { - if (null == matchList) + if (matchList == null) throw PSTraceSource.NewArgumentNullException("matchList"); string serviceID = (selectionMode == SelectionMode.DisplayName) ? service.DisplayName diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs index adcf5f0c127..d2740b45390 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs @@ -56,15 +56,15 @@ internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCo /// An array of types to add. internal void AddColumns(string[] propertyNames, string[] displayNames, Type[] types) { - if (null == propertyNames) + if (propertyNames == null) { throw new ArgumentNullException("propertyNames"); } - if (null == displayNames) + if (displayNames == null) { throw new ArgumentNullException("displayNames"); } - if (null == types) + if (types == null) { throw new ArgumentNullException("types"); } @@ -173,7 +173,7 @@ private void AddExtraProperties(PSObject staleObject, PSObject liveObject) /// internal void AddItem(PSObject livePSObject) { - if (null == livePSObject) + if (livePSObject == null) { throw new ArgumentNullException("livePSObject"); } @@ -199,7 +199,7 @@ internal void AddItem(PSObject livePSObject) /// internal void AddHeteroViewItem(PSObject livePSObject) { - if (null == livePSObject) + if (livePSObject == null) { throw new ArgumentNullException("livePSObject"); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs index 276ea74dc5c..1ec5748358c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs @@ -166,7 +166,7 @@ protected override void BeginProcessing() // cleanup code will be called in IDisposable.Dispose() outInner.LineOutput = InstantiateLineOutputInterface(); - if (null == _sw) + if (_sw == null) { return; } @@ -226,7 +226,7 @@ private LineOutput InstantiateLineOutputInterface() protected override void ProcessRecord() { _processRecordExecuted = true; - if (null == _sw) + if (_sw == null) { return; } @@ -253,7 +253,7 @@ protected override void EndProcessing() return; } - if (null == _sw) + if (_sw == null) { return; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetUnique.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetUnique.cs index d3cedd9a83e..38948659e3c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetUnique.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetUnique.cs @@ -57,7 +57,7 @@ public SwitchParameter OnType protected override void ProcessRecord() { bool isUnique = true; - if (null == _lastObject) + if (_lastObject == null) { // always write first object, but return nothing // on "MSH> get-unique" @@ -71,7 +71,7 @@ protected override void ProcessRecord() else if (AsString) { string inputString = InputObject.ToString(); - if (null == _lastObjectAsString) + if (_lastObjectAsString == null) { _lastObjectAsString = _lastObject.ToString(); } @@ -89,7 +89,7 @@ protected override void ProcessRecord() } else // compare as objects { - if (null == _comparer) + if (_comparer == null) { _comparer = new ObjectCommandComparer( true, // ascending (doesn't matter) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs index f9394ffcebf..82bcc6e74ae 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs @@ -2536,7 +2536,7 @@ private string GenerateNewRunspaceExpression() private string GenerateConnectionStringForNewRunspace() { WSManConnectionInfo connectionInfo = _remoteRunspaceInfo.Runspace.ConnectionInfo as WSManConnectionInfo; - if (null == connectionInfo) + if (connectionInfo == null) { VMConnectionInfo vmConnectionInfo = _remoteRunspaceInfo.Runspace.ConnectionInfo as VMConnectionInfo; if (vmConnectionInfo != null) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs index fc02201d3fa..a86bd31916a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs @@ -22,7 +22,7 @@ public class ShowCommandCommandInfo /// public ShowCommandCommandInfo(CommandInfo other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -71,7 +71,7 @@ public ShowCommandCommandInfo(CommandInfo other) /// public ShowCommandCommandInfo(PSObject other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -146,4 +146,4 @@ internal static IEnumerable GetObjectEnumerable(System.Collections.IEnum /// public ICollection ParameterSets { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs index 9f9d663ef9e..eb413152f93 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs @@ -20,7 +20,7 @@ public class ShowCommandModuleInfo /// public ShowCommandModuleInfo(PSModuleInfo other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -37,7 +37,7 @@ public ShowCommandModuleInfo(PSModuleInfo other) /// public ShowCommandModuleInfo(PSObject other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -50,4 +50,4 @@ public ShowCommandModuleInfo(PSObject other) /// public string Name { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs index c9eed0a7d12..8c6e69a3ee6 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs @@ -22,7 +22,7 @@ public class ShowCommandParameterInfo /// public ShowCommandParameterInfo(CommandParameterInfo other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -50,7 +50,7 @@ public ShowCommandParameterInfo(CommandParameterInfo other) /// public ShowCommandParameterInfo(PSObject other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -103,4 +103,4 @@ public ShowCommandParameterInfo(PSObject other) /// public int Position { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs index 3b572bfd94e..4b26e58eb69 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs @@ -22,7 +22,7 @@ public class ShowCommandParameterSetInfo /// public ShowCommandParameterSetInfo(CommandParameterSetInfo other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -41,7 +41,7 @@ public ShowCommandParameterSetInfo(CommandParameterSetInfo other) /// public ShowCommandParameterSetInfo(PSObject other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -67,4 +67,4 @@ public ShowCommandParameterSetInfo(PSObject other) /// public ICollection Parameters { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs index a8769d2c9c4..85c2a94846a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs @@ -21,7 +21,7 @@ public class ShowCommandParameterType /// public ShowCommandParameterType(Type other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -51,7 +51,7 @@ public ShowCommandParameterType(Type other) /// public ShowCommandParameterType(PSObject other) { - if (null == other) + if (other == null) { throw new ArgumentNullException("other"); } @@ -152,4 +152,4 @@ public bool IsSwitch /// public ArrayList EnumValues { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs index 7ba656a2607..3a098965d6d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs @@ -177,7 +177,7 @@ private bool TryConvertToJson(string json, out object obj, ref Exception exRef) ErrorRecord error; obj = JsonObject.ConvertFromJson(json, out error); - if (null == obj) + if (obj == null) { // This ensures that a null returned by ConvertFromJson() is the actual JSON null literal. // if not, the ArgumentException will be caught. @@ -365,7 +365,7 @@ public partial class InvokeRestMethodCommand : WebRequestPSCmdlet /// internal override void ProcessResponse(HttpResponseMessage response) { - if (null == response) { throw new ArgumentNullException("response"); } + if (response == null) { throw new ArgumentNullException("response"); } using (BufferingStreamReader responseStream = new BufferingStreamReader(StreamHelper.GetResponseStream(response))) { @@ -449,7 +449,7 @@ internal override void ProcessResponse(HttpResponseMessage response) private RestReturnType CheckReturnType(HttpResponseMessage response) { - if (null == response) { throw new ArgumentNullException("response"); } + if (response == null) { throw new ArgumentNullException("response"); } RestReturnType rt = RestReturnType.Detect; string contentType = ContentHelper.GetContentType(response); 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 4d7748758a7..43bc09329e3 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 @@ -389,13 +389,13 @@ internal virtual void ValidateParameters() "WebCmdletAuthenticationTokenConflictException"); ThrowTerminatingError(error); } - if ((Authentication == WebAuthenticationType.Basic) && (null == Credential)) + if ((Authentication == WebAuthenticationType.Basic) && (Credential == null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.AuthenticationCredentialNotSupplied, "WebCmdletAuthenticationCredentialNotSuppliedException"); ThrowTerminatingError(error); } - if ((Authentication == WebAuthenticationType.OAuth || Authentication == WebAuthenticationType.Bearer) && (null == Token)) + if ((Authentication == WebAuthenticationType.OAuth || Authentication == WebAuthenticationType.Bearer) && (Token == null)) { ErrorRecord error = GetValidationError(WebCmdletStrings.AuthenticationTokenNotSupplied, "WebCmdletAuthenticationTokenNotSuppliedException"); @@ -429,7 +429,7 @@ internal virtual void ValidateParameters() "WebCmdletProxyCredentialConflictException"); ThrowTerminatingError(error); } - else if ((null == Proxy) && ((ProxyCredential != null) || ProxyUseDefaultCredentials)) + else if ((Proxy == null) && ((ProxyCredential != null) || ProxyUseDefaultCredentials)) { ErrorRecord error = GetValidationError(WebCmdletStrings.ProxyUriNotSupplied, "WebCmdletProxyUriNotSuppliedException"); @@ -534,7 +534,7 @@ internal virtual void ValidateParameters() internal virtual void PrepareSession() { // make sure we have a valid WebRequestSession object to work with - if (null == WebSession) + if (WebSession == null) { WebSession = new WebRequestSession(); } @@ -694,7 +694,7 @@ private Uri PrepareUri(Uri uri) private Uri CheckProtocol(Uri uri) { - if (null == uri) { throw new ArgumentNullException("uri"); } + if (uri == null) { throw new ArgumentNullException("uri"); } if (!uri.IsAbsoluteUri) { @@ -1112,7 +1112,7 @@ internal virtual HttpRequestMessage GetRequest(Uri uri) internal virtual void FillRequestStream(HttpRequestMessage request) { - if (null == request) { throw new ArgumentNullException("request"); } + if (request == null) { throw new ArgumentNullException("request"); } // set the content type if (ContentType != null) @@ -1752,7 +1752,7 @@ internal void ParseLinkHeader(HttpResponseMessage response, System.Uri requestUr /// If true, collection types in will be enumerated. If false, collections will be treated as single value. private void AddMultipartContent(object fieldName, object fieldValue, MultipartFormDataContent formData, bool enumerate) { - if (null == formData) + if (formData == null) { throw new ArgumentNullException("formDate"); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs index 686c26331cc..2ec7c3d4f10 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs @@ -179,7 +179,7 @@ private void InitializeRawContent(HttpResponseMessage baseResponse) private void SetResponse(HttpResponseMessage response, Stream contentStream) { - if (null == response) { throw new ArgumentNullException("response"); } + if (response == null) { throw new ArgumentNullException("response"); } BaseResponse = response; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs index 82a7ba0dc51..d946c4e600d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs @@ -31,7 +31,7 @@ public InvokeWebRequestCommand() : base() /// internal override void ProcessResponse(HttpResponseMessage response) { - if (null == response) { throw new ArgumentNullException("response"); } + if (response == null) { throw new ArgumentNullException("response"); } Stream responseStream = StreamHelper.GetResponseStream(response); if (ShouldWriteToPipeline) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs index 0164141d737..10e7f4229a8 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs @@ -437,7 +437,7 @@ internal static bool TryGetEncoding(string characterSet, out Encoding encoding) internal static string DecodeStream(Stream stream, ref Encoding encoding) { bool isDefaultEncoding = false; - if (null == encoding) + if (encoding == null) { // Use the default encoding if one wasn't provided encoding = ContentHelper.GetDefaultEncoding(); @@ -469,7 +469,7 @@ internal static string DecodeStream(Stream stream, ref Encoding encoding) internal static Byte[] EncodeToBytes(String str, Encoding encoding) { - if (null == encoding) + if (encoding == null) { // just use the default encoding if one wasn't provided encoding = ContentHelper.GetDefaultEncoding(); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs index 43809cd39c7..07c3522ef10 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs @@ -94,7 +94,7 @@ public WebRequestSession() /// The certificate to be added. internal void AddCertificate(X509Certificate certificate) { - if (null == Certificates) + if (Certificates == null) { Certificates = new X509CertificateCollection(); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write-Object.cs index a525ee6e3bc..8d5e6bd1b39 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write-Object.cs @@ -43,7 +43,7 @@ public SwitchParameter NoEnumerate /// protected override void ProcessRecord() { - if (null == _inputObjects) + if (_inputObjects == null) { WriteObject(_inputObjects); return; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs index a8e2786b750..ba35fea6bea 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs @@ -321,7 +321,7 @@ protected override void ProcessRecord() { Exception e = this.Exception; string msg = Message; - if (null == e) + if (e == null) { e = new WriteErrorException(msg); } diff --git a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs index eb544986332..10dbe2ecf37 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs +++ b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs @@ -70,7 +70,7 @@ public override string ToString() /// public LocalGroup Clone() { - if (null == this) + if (this == null) { throw new NullReferenceException(); } diff --git a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs index 12e8832bf0e..3addf87c11f 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs +++ b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs @@ -135,7 +135,7 @@ public override string ToString() /// public LocalUser Clone() { - if (null == this) + if (this == null) { throw new NullReferenceException(); } diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 20e8ce27179..5de09e63974 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -520,7 +520,7 @@ WsMan Config Can be divided in to Four Fixed Regions to Check Whether it has Chi strPathCheck = strPathCheck + WSManStringLiterals.containerSecurity + WSManStringLiterals.DefaultPathSeparator; if (path.Contains(strPathCheck + WSManStringLiterals.containerSecurity + "_")) { - if (null == arrSecurities) + if (arrSecurities == null) { return false; } @@ -640,7 +640,7 @@ protected override void GetItem(string path) strPathChk = strPathChk + WSManStringLiterals.containerPlugin + WSManStringLiterals.DefaultPathSeparator; string filter = uri + "?Name=" + currentpluginname; XmlDocument CurrentPluginXML = GetResourceValue(sessionobj, filter, null); - if (null == CurrentPluginXML) + if (CurrentPluginXML == null) { return; } @@ -666,7 +666,7 @@ protected override void GetItem(string path) strPathChk = strPathChk + currentpluginname + WSManStringLiterals.DefaultPathSeparator; if (path.Contains(strPathChk + WSManStringLiterals.containerResources)) { - if (null == arrResources) + if (arrResources == null) { return; } @@ -717,7 +717,7 @@ protected override void GetItem(string path) strPathChk = strPathChk + sResourceDirName + WSManStringLiterals.DefaultPathSeparator; if (path.Contains(strPathChk + WSManStringLiterals.containerSecurity)) { - if (null == arrSecurity) + if (arrSecurity == null) { return; } @@ -848,7 +848,7 @@ protected override void GetItem(string path) protected override void SetItem(string path, object value) { - if (null == value) + if (value == null) { throw new ArgumentException(helper.GetResourceMsgFromResourcetext("value")); } @@ -1050,7 +1050,7 @@ protected override void SetItem(string path, object value) { if (path.EndsWith(strPathChk + sResourceDirName, StringComparison.OrdinalIgnoreCase)) { - if (null == arrResources) + if (arrResources == null) { return; } @@ -1095,7 +1095,7 @@ protected override void SetItem(string path, object value) return; } - if (null == arrSecurity) + if (arrSecurity == null) { return; } @@ -1535,7 +1535,7 @@ WsMan Config Can be divided in to Four Fixed Regions to Check Whether Item is Co strPathCheck = strPathCheck + WSManStringLiterals.containerSecurity + WSManStringLiterals.DefaultPathSeparator; if (path.Contains(strPathCheck + WSManStringLiterals.containerSecurity + "_")) { - if (null == arrSecurities) + if (arrSecurities == null) { return false; } @@ -2127,7 +2127,7 @@ private void NewItemPluginOrPluginChild(object sessionobj, string path, string h } // Construct the Uri from Resource_XXXX resource dir. PSObject resourceDirProperties = GetItemValue(strPathChk); - if ((null == resourceDirProperties) || (null == resourceDirProperties.Properties["ResourceUri"])) + if ((resourceDirProperties == null) || (null == resourceDirProperties.Properties["ResourceUri"])) { string message = helper.FormatResourceMsgFromResourcetext("ResourceURIMissingInResourceDir", "ResourceUri", strPathChk); @@ -3374,7 +3374,7 @@ private PSObject GetItemValue(string path) // Example resource dir: WSMan:\localhost\Plugin\someplugin\Resources\Resource_67830040 string filter = uri + "?Name=" + currentpluginname; XmlDocument CurrentPluginXML = GetResourceValue(sessionobj, filter, null); - if (null == CurrentPluginXML) + if (CurrentPluginXML == null) { return null; } @@ -3387,7 +3387,7 @@ private PSObject GetItemValue(string path) // We support only retrieving Resource_XXX dir properties only. // other directory support can be added as needed. - if (null == arrResources) + if (arrResources == null) { return null; } @@ -3848,7 +3848,7 @@ private bool CheckValidContainerOrPath(string path) return true; } strpathChk = strpathChk + WSManStringLiterals.DefaultPathSeparator + sResourceDirName + WSManStringLiterals.DefaultPathSeparator + WSManStringLiterals.containerSecurity + WSManStringLiterals.DefaultPathSeparator; - if (null == arrSecurities) + if (arrSecurities == null) { return false; } @@ -3925,7 +3925,7 @@ private bool ItemExistListenerOrClientCertificate(object sessionobj, string Reso { return true; } - if (null == outxml) + if (outxml == null) { return false; } @@ -4132,7 +4132,7 @@ private void GetChildItemsOrNames(string path, ProviderMethods methodname, bool { string filter = uri + "?Name=" + currentpluginname; XmlDocument CurrentPluginXML = GetResourceValue(sessionobj, filter, null); - if (null == CurrentPluginXML) + if (CurrentPluginXML == null) { return; } @@ -4233,7 +4233,7 @@ private void GetChildItemsOrNames(string path, ProviderMethods methodname, bool sResourceDirName = path.Substring(strPathchk.Length, path.IndexOf(WSManStringLiterals.DefaultPathSeparator, strPathchk.Length) - (strPathchk.Length)); } - if (null == arrResources) + if (arrResources == null) { return; } @@ -4315,7 +4315,7 @@ private void GetChildItemsOrNames(string path, ProviderMethods methodname, bool } else if (path.EndsWith(host + WSManStringLiterals.DefaultPathSeparator + WSManStringLiterals.containerPlugin + WSManStringLiterals.DefaultPathSeparator + currentpluginname + WSManStringLiterals.DefaultPathSeparator + WSManStringLiterals.containerInitParameters, StringComparison.OrdinalIgnoreCase)) { - if (null == arrInitParams) + if (arrInitParams == null) { return; } @@ -4569,7 +4569,7 @@ private void ProcessCertMappingObjects(XmlDocument xmlCerts, out Hashtable Certc Hashtable lCache = new Hashtable(); Hashtable kCache = new Hashtable(); XmlNodeList xmlnodesCerts = xmlCerts.GetElementsByTagName("cfg:" + "CertMapping"); - if (null == xmlnodesCerts) + if (xmlnodesCerts == null) { Certcache = null; Keyscache = null; @@ -4623,7 +4623,7 @@ private void ProcessListenerObjects(XmlDocument xmlListeners, out Hashtable list Hashtable lCache = new Hashtable(); Hashtable kCache = new Hashtable(); XmlNodeList xmlnodesListeners = xmlListeners.GetElementsByTagName("cfg:" + WSManStringLiterals.containerListener); - if (null == xmlnodesListeners) + if (xmlnodesListeners == null) { listenercache = null; Keyscache = null; diff --git a/src/Microsoft.WSMan.Management/CredSSP.cs b/src/Microsoft.WSMan.Management/CredSSP.cs index 5112eee6026..b1b804f6f82 100644 --- a/src/Microsoft.WSMan.Management/CredSSP.cs +++ b/src/Microsoft.WSMan.Management/CredSSP.cs @@ -114,7 +114,7 @@ private void DisableClientSideSettings() { WSManHelper helper = new WSManHelper(this); IWSManSession m_SessionObj = CreateWSManSession(); - if (null == m_SessionObj) + if (m_SessionObj == null) { return; } @@ -180,7 +180,7 @@ private void DisableServerSideSettings() { WSManHelper helper = new WSManHelper(this); IWSManSession m_SessionObj = CreateWSManSession(); - if (null == m_SessionObj) + if (m_SessionObj == null) { return; } @@ -549,7 +549,7 @@ private void EnableClientSideSettings() } IWSManSession m_SessionObj = CreateWSManSession(); - if (null == m_SessionObj) + if (m_SessionObj == null) { return; } @@ -630,7 +630,7 @@ private void EnableServerSideSettings() } IWSManSession m_SessionObj = CreateWSManSession(); - if (null == m_SessionObj) + if (m_SessionObj == null) { return; } diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index 543645b4c56..52d7433a906 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -206,7 +206,7 @@ internal static class CommonEnvVariableNames /// internal static void RemoveTemporaryDirectory() { - if (null == _tempDirectory) + if (_tempDirectory == null) { return; } @@ -267,7 +267,7 @@ public static string SelectProductNameForDirectory(Platform.XDG_Type dirpath) string xdgdatahome = System.Environment.GetEnvironmentVariable("XDG_DATA_HOME"); string xdgcachehome = System.Environment.GetEnvironmentVariable("XDG_CACHE_HOME"); string envHome = System.Environment.GetEnvironmentVariable(CommonEnvVariableNames.Home); - if (null == envHome) + if (envHome == null) { envHome = GetTemporaryDirectory(); } @@ -426,7 +426,7 @@ private static string InternalGetFolderPath(System.Environment.SpecialFolder fol string folderPath = null; #if UNIX string envHome = System.Environment.GetEnvironmentVariable(Platform.CommonEnvVariableNames.Home); - if (null == envHome) + if (envHome == null) { envHome = Platform.GetTemporaryDirectory(); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs index 63803b15134..9c6e2489371 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs @@ -250,7 +250,7 @@ public void PrependFormatData(IEnumerable formatData) /// internal FormatTable(IEnumerable formatFiles, AuthorizationManager authorizationManager, PSHost host) { - if (null == formatFiles) + if (formatFiles == null) { throw PSTraceSource.NewArgumentNullException("formatFiles"); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs index d120f462d03..f4192dc9eed 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs @@ -382,7 +382,7 @@ internal static ViewDefinition GetOutOfBandView(MshExpressionFactory expressionF // 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 (null == result) + if (result == null) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (typesWithoutPrefix != null) @@ -454,7 +454,7 @@ private static ViewDefinition GetView(MshExpressionFactory expressionFactory, Ty // 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 (null == result) + if (result == null) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (typesWithoutPrefix != null) @@ -544,7 +544,7 @@ private static ViewDefinition GetDefaultView(MshExpressionFactory expressionFact // 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 (null == result) + if (result == null) { Collection typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames); if (typesWithoutPrefix != null) diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs index 8867980c84a..e0e46004143 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs @@ -435,7 +435,7 @@ private static PSMemberSet MaskDeserializedAndGetStandardMembers(PSObject so) Diagnostics.Assert(so != null, "Shell Object to process cannot be null"); var typeNames = so.InternalTypeNames; Collection typeNamesWithoutDeserializedPrefix = Deserializer.MaskDeserializationPrefix(typeNames); - if (null == typeNamesWithoutDeserializedPrefix) + if (typeNamesWithoutDeserializedPrefix == null) { return null; } diff --git a/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs b/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs index 9eabf7e9075..1369cb5017a 100644 --- a/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs +++ b/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs @@ -63,7 +63,7 @@ public override System.Collections.ObjectModel.Collection Get { // baseObject should never be null CimInstance cimInstance = baseObject as CimInstance; - if (null == cimInstance) + if (cimInstance == null) { string msg = string.Format(CultureInfo.InvariantCulture, CimInstanceTypeAdapterResources.BaseObjectNotCimInstance, @@ -110,7 +110,7 @@ public override PSAdaptedProperty GetProperty(object baseObject, string property // baseObject should never be null CimInstance cimInstance = baseObject as CimInstance; - if (null == cimInstance) + if (cimInstance == null) { string msg = string.Format(CultureInfo.InvariantCulture, CimInstanceTypeAdapterResources.BaseObjectNotCimInstance, @@ -160,7 +160,7 @@ internal static string CimTypeToTypeNameDisplayString(CimType cimType) /// public override string GetPropertyTypeName(PSAdaptedProperty adaptedProperty) { - if (null == adaptedProperty) + if (adaptedProperty == null) { throw new ArgumentNullException("adaptedProperty"); } @@ -186,7 +186,7 @@ public override string GetPropertyTypeName(PSAdaptedProperty adaptedProperty) /// public override object GetPropertyValue(PSAdaptedProperty adaptedProperty) { - if (null == adaptedProperty) + if (adaptedProperty == null) { throw new ArgumentNullException("adaptedProperty"); } @@ -250,7 +250,7 @@ private List GetInheritanceChain(CimInstance cimInstance) public override Collection GetTypeNameHierarchy(object baseObject) { var cimInstance = baseObject as CimInstance; - if (null == cimInstance) + if (cimInstance == null) { throw new ArgumentNullException("baseObject"); } @@ -323,7 +323,7 @@ public override bool IsSettable(PSAdaptedProperty adaptedProperty) return writeQualifierValue; */ - if (null == adaptedProperty) + if (adaptedProperty == null) { return false; } @@ -346,7 +346,7 @@ public override bool IsSettable(PSAdaptedProperty adaptedProperty) /// public override void SetPropertyValue(PSAdaptedProperty adaptedProperty, object value) { - if (null == adaptedProperty) + if (adaptedProperty == null) { throw new ArgumentNullException("adaptedProperty"); } diff --git a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs index 3b07a8a80d4..3ca610169d0 100644 --- a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs +++ b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs @@ -4464,7 +4464,7 @@ public DefaultParameterDictionary() public DefaultParameterDictionary(IDictionary dictionary) : this() { - if (null == dictionary) + if (dictionary == null) { throw PSTraceSource.NewArgumentNullException("dictionary"); } diff --git a/src/System.Management.Automation/engine/CodeMethods.cs b/src/System.Management.Automation/engine/CodeMethods.cs index 3585a6af238..eebdc5a7138 100644 --- a/src/System.Management.Automation/engine/CodeMethods.cs +++ b/src/System.Management.Automation/engine/CodeMethods.cs @@ -63,7 +63,7 @@ public static class AdapterCodeMethods [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "integer")] public static Int64 ConvertLargeIntegerToInt64(PSObject deInstance, PSObject largeIntegerInstance) { - if (null == largeIntegerInstance) + if (largeIntegerInstance == null) { throw PSTraceSource.NewArgumentException("largeIntegerInstance"); } @@ -107,7 +107,7 @@ public static Int64 ConvertLargeIntegerToInt64(PSObject deInstance, PSObject lar [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dn", Justification = "DN represents valid prefix w.r.t Active Directory.")] public static string ConvertDNWithBinaryToString(PSObject deInstance, PSObject dnWithBinaryInstance) { - if (null == dnWithBinaryInstance) + if (dnWithBinaryInstance == null) { throw PSTraceSource.NewArgumentException("dnWithBinaryInstance"); } diff --git a/src/System.Management.Automation/engine/CompiledCommandParameter.cs b/src/System.Management.Automation/engine/CompiledCommandParameter.cs index bfaafef8703..97422f46d4a 100644 --- a/src/System.Management.Automation/engine/CompiledCommandParameter.cs +++ b/src/System.Management.Automation/engine/CompiledCommandParameter.cs @@ -437,7 +437,7 @@ private void ProcessAttribute( ref string[] aliases) { // NTRAID#Windows Out Of Band Releases-926374-2005/12/22-JonN - if (null == attribute) + if (attribute == null) return; CompiledAttributes.Add(attribute); diff --git a/src/System.Management.Automation/engine/EnumExpressionEvaluator.cs b/src/System.Management.Automation/engine/EnumExpressionEvaluator.cs index 68de01a994a..3ff3ce88b66 100644 --- a/src/System.Management.Automation/engine/EnumExpressionEvaluator.cs +++ b/src/System.Management.Automation/engine/EnumExpressionEvaluator.cs @@ -66,7 +66,7 @@ public FlagsExpression(object[] expression) _underType = Enum.GetUnderlyingType(typeof(T)); - if (null == expression) + if (expression == null) { throw InterpreterError.NewInterpreterException(null, typeof(ArgumentNullException), null, "EmptyInputString", EnumExpressionEvaluatorStrings.EmptyInputString); diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index 5bada71cfb7..2ef97649093 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -214,7 +214,7 @@ public class ErrorCategoryInfo #region ctor internal ErrorCategoryInfo(ErrorRecord errorRecord) { - if (null == errorRecord) + if (errorRecord == null) throw new ArgumentNullException("errorRecord"); _errorRecord = errorRecord; } @@ -801,7 +801,7 @@ private string BuildMessage( string resourceId, params object[] args) { - if (null == cmdlet) + if (cmdlet == null) throw PSTraceSource.NewArgumentNullException("cmdlet"); if (String.IsNullOrEmpty(baseName)) @@ -834,7 +834,7 @@ private string BuildMessage( string resourceId, params object[] args) { - if (null == resourceSupplier) + if (resourceSupplier == null) throw PSTraceSource.NewArgumentNullException("resourceSupplier"); if (String.IsNullOrEmpty(baseName)) @@ -867,7 +867,7 @@ private string BuildMessage( string resourceId, params object[] args) { - if (null == assembly) + if (assembly == null) throw PSTraceSource.NewArgumentNullException("assembly"); if (String.IsNullOrEmpty(baseName)) @@ -986,7 +986,7 @@ public ErrorRecord( ErrorCategory errorCategory, object targetObject) { - if (null == exception) + if (exception == null) throw PSTraceSource.NewArgumentNullException("exception"); if (errorId == null) @@ -1658,16 +1658,16 @@ internal static string NotNull(string s) private string GetInvocationTypeName() { InvocationInfo invocationInfo = this.InvocationInfo; - if (null == invocationInfo) + if (invocationInfo == null) return ""; CommandInfo commandInfo = invocationInfo.MyCommand; - if (null == commandInfo) + if (commandInfo == null) return ""; IScriptCommandInfo scriptInfo = commandInfo as IScriptCommandInfo; if (scriptInfo != null) return commandInfo.Name; CmdletInfo cmdletInfo = commandInfo as CmdletInfo; - if (null == cmdletInfo) + if (cmdletInfo == null) return ""; return cmdletInfo.ImplementingType.FullName; } diff --git a/src/System.Management.Automation/engine/ExecutionContext.cs b/src/System.Management.Automation/engine/ExecutionContext.cs index 0c5d27cc02b..63bb8e6f223 100644 --- a/src/System.Management.Automation/engine/ExecutionContext.cs +++ b/src/System.Management.Automation/engine/ExecutionContext.cs @@ -742,7 +742,7 @@ internal void AppendDollarError(object obj) object old = this.DollarErrorVariable; ArrayList arraylist = old as ArrayList; - if (null == arraylist) + if (arraylist == null) { Diagnostics.Assert(false, "$error should be a global constant ArrayList"); return; @@ -1257,7 +1257,7 @@ internal static Assembly LoadAssembly(string name, string filename, out Exceptio } } - // If the assembly is loaded, we ignore error as it may come from the filepath loading. + // If the assembly is loaded, we ignore error as it may come from the filepath loading. if (loadedAssembly != null) { error = null; @@ -1284,9 +1284,9 @@ internal void ReportEngineStartupError(string resourceString, params object[] ar else { PSHost host = EngineHostInterface; - if (null == host) return; + if (host == null) return; PSHostUserInterface ui = host.UI; - if (null == ui) return; + if (ui == null) return; ui.WriteErrorLine( StringUtil.Format(resourceString, arguments)); } @@ -1314,9 +1314,9 @@ internal void ReportEngineStartupError(string error) else { PSHost host = EngineHostInterface; - if (null == host) return; + if (host == null) return; PSHostUserInterface ui = host.UI; - if (null == ui) return; + if (ui == null) return; ui.WriteErrorLine(error); } } @@ -1349,9 +1349,9 @@ internal void ReportEngineStartupError(Exception e) else { PSHost host = EngineHostInterface; - if (null == host) return; + if (host == null) return; PSHostUserInterface ui = host.UI; - if (null == ui) return; + if (ui == null) return; ui.WriteErrorLine(e.Message); } } @@ -1377,9 +1377,9 @@ internal void ReportEngineStartupError(ErrorRecord errorRecord) else { PSHost host = EngineHostInterface; - if (null == host) return; + if (host == null) return; PSHostUserInterface ui = host.UI; - if (null == ui) return; + if (ui == null) return; ui.WriteErrorLine(errorRecord.ToString()); } } diff --git a/src/System.Management.Automation/engine/ExtendedTypeSystemException.cs b/src/System.Management.Automation/engine/ExtendedTypeSystemException.cs index c5c226a79de..855e1bd3248 100644 --- a/src/System.Management.Automation/engine/ExtendedTypeSystemException.cs +++ b/src/System.Management.Automation/engine/ExtendedTypeSystemException.cs @@ -591,7 +591,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/engine/ExtraAdapter.cs b/src/System.Management.Automation/engine/ExtraAdapter.cs index 9b92a533443..b8c18566615 100644 --- a/src/System.Management.Automation/engine/ExtraAdapter.cs +++ b/src/System.Management.Automation/engine/ExtraAdapter.cs @@ -62,7 +62,7 @@ protected override T GetMember(object obj, string memberName) object invokeGetValue = entry.InvokeGet(memberName); // if entry.Properties[memberName] returns empty value and invokeGet non-empty // value..take invokeGet's value. This will fix bug Windows Bug 121188. - if ((null == collection) || ((null == collection.Value) && (invokeGetValue != null))) + if ((collection == null) || ((null == collection.Value) && (invokeGetValue != null))) { valueToTake = invokeGetValue; } diff --git a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs index 2f9382c4063..50bd92532c8 100644 --- a/src/System.Management.Automation/engine/ManagementObjectAdapter.cs +++ b/src/System.Management.Automation/engine/ManagementObjectAdapter.cs @@ -519,7 +519,7 @@ private static ManagementClass CreateClassFrmObject(ManagementBaseObject mgmtBas ManagementClass mgmtClass = mgmtBaseObject as ManagementClass; // try to use the actual object sent to this method..otherwise construct one - if (null == mgmtClass) + if (mgmtClass == null) { mgmtClass = new ManagementClass(mgmtBaseObject.ClassPath); diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index c4299e11a8e..afebab30843 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -1398,7 +1398,7 @@ private bool CanShouldProcessAutoConfirm() { // retrieve ConfirmImpact from commandInfo CommandMetadata commandMetadata = _commandInfo.CommandMetadata; - if (null == commandMetadata) + if (commandMetadata == null) { Dbg.Assert(false, "Expected CommandMetadata"); return true; @@ -2024,7 +2024,7 @@ public PSTransactionContext CurrentPSTransaction public void ThrowTerminatingError(ErrorRecord errorRecord) { ThrowIfStopping(); - if (null == errorRecord) + if (errorRecord == null) { throw PSTraceSource.NewArgumentNullException("errorRecord"); } @@ -2278,7 +2278,7 @@ private class AllowWrite : IDisposable /// internal AllowWrite(InternalCommand permittedToWrite, bool permittedToWriteToPipeline) { - if (null == permittedToWrite) + if (permittedToWrite == null) throw PSTraceSource.NewArgumentNullException("permittedToWrite"); MshCommandRuntime mcr = permittedToWrite.commandRuntime as MshCommandRuntime; if (mcr == null) @@ -2328,7 +2328,7 @@ public void Dispose() /// PipelineStoppedException public Exception ManageException(Exception e) { - if (null == e) + if (e == null) throw PSTraceSource.NewArgumentNullException("e"); if (PipelineProcessor != null) @@ -2501,7 +2501,7 @@ internal void SetupVariable(VariableStreamKind streamKind, string variableName, variableName = variableName.Substring(1); object oldValue = PSObject.Base(_state.PSVariable.GetValue(variableName)); varList = oldValue as IList; - if (null == varList) + if (varList == null) { varList = new ArrayList(); @@ -2585,7 +2585,7 @@ internal void _WriteObjectSkipAllowCheck(object sendToPipeline) internal void _WriteObjectsSkipAllowCheck(object sendToPipeline) { IEnumerable enumerable = LanguagePrimitives.GetEnumerable(sendToPipeline); - if (null == enumerable) + if (enumerable == null) { _WriteObjectSkipAllowCheck(sendToPipeline); return; @@ -2707,7 +2707,7 @@ private void DoWriteError(object obj) KeyValuePair pair = (KeyValuePair)obj; ErrorRecord errorRecord = pair.Key; ActionPreference preference = pair.Value; - if (null == errorRecord) + if (errorRecord == null) { throw PSTraceSource.NewArgumentNullException("errorRecord"); } diff --git a/src/System.Management.Automation/engine/MshMemberInfo.cs b/src/System.Management.Automation/engine/MshMemberInfo.cs index 02a4ae4a4d0..129dec76a84 100644 --- a/src/System.Management.Automation/engine/MshMemberInfo.cs +++ b/src/System.Management.Automation/engine/MshMemberInfo.cs @@ -3354,11 +3354,11 @@ internal override PSMemberInfoInternalCollection InternalMembers } // cache "psbase" and "psobject" - if (null == internalMembers) + if (internalMembers == null) { lock (_syncObject) { - if (null == internalMembers) + if (internalMembers == null) { internalMembers = new PSMemberInfoInternalCollection(); diff --git a/src/System.Management.Automation/engine/MshObject.cs b/src/System.Management.Automation/engine/MshObject.cs index 6ffa53ecf31..9bf2576efc2 100644 --- a/src/System.Management.Automation/engine/MshObject.cs +++ b/src/System.Management.Automation/engine/MshObject.cs @@ -631,11 +631,11 @@ private AdapterSet InternalAdapterSet { get { - if (null == _adapterSet) + if (_adapterSet == null) { lock (_lockObject) { - if (null == _adapterSet) + if (_adapterSet == null) { _adapterSet = GetMappedAdapter(_immediateBaseObject, GetTypeTable()); } diff --git a/src/System.Management.Automation/engine/MshSecurityException.cs b/src/System.Management.Automation/engine/MshSecurityException.cs index 3a33abe5830..27069dcd2c3 100644 --- a/src/System.Management.Automation/engine/MshSecurityException.cs +++ b/src/System.Management.Automation/engine/MshSecurityException.cs @@ -93,7 +93,7 @@ public override ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 8968fa74c03..3556ce00316 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -1278,7 +1278,7 @@ private void CalculateIORedirection(out bool redirectOutput, out bool redirectEr if (_runStandAlone) { - if (null == s_supportScreenScrape) + if (s_supportScreenScrape == null) { try { diff --git a/src/System.Management.Automation/engine/PSConfiguration.cs b/src/System.Management.Automation/engine/PSConfiguration.cs index 73028fb128f..18d7814a2ff 100644 --- a/src/System.Management.Automation/engine/PSConfiguration.cs +++ b/src/System.Management.Automation/engine/PSConfiguration.cs @@ -407,7 +407,7 @@ private void UpdateValueInFile(ConfigScope scope, string key, T value, bool a jsonObject = (JObject) JToken.ReadFrom(jsonReader); JProperty propertyToModify = jsonObject.Property(key); - if (null == propertyToModify) + if (propertyToModify == null) { // The property doesn't exist, so add it if (addValue) diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index 6ebd923b8ed..42d4519ea51 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -1497,7 +1497,7 @@ private object EncodeCollection( bindingTracer.WriteLine( "Binding collection parameter {0}: argument type [{1}], parameter type [{2}], collection type {3}, element type [{4}], {5}", parameterName, - (null == currentValue) ? "null" : currentValue.GetType().Name, + (currentValue == null) ? "null" : currentValue.GetType().Name, toType, collectionTypeInformation.ParameterCollectionType, collectionTypeInformation.ElementType, @@ -1615,7 +1615,7 @@ private object EncodeCollection( "ArgumentException matching Add(T) for type {0}: {1}", toType.FullName, e.Message); getMethodError = e; } - if (null == addMethod) + if (addMethod == null) { ParameterBindingException bindingException = new ParameterBindingException( @@ -1727,7 +1727,7 @@ private object EncodeCollection( { bindingTracer.WriteLine( "COERCE collection element from type {0} to type {1}", - (null == valueElement) ? "null" : valueElement.GetType().Name, + (valueElement == null) ? "null" : valueElement.GetType().Name, collectionElementType); // Coerce the element to the appropriate type. @@ -1752,7 +1752,7 @@ private object EncodeCollection( { bindingTracer.WriteLine( "COERCION REQUIRED: Did not attempt to coerce collection element from type {0} to type {1}", - (null == valueElement) ? "null" : valueElement.GetType().Name, + (valueElement == null) ? "null" : valueElement.GetType().Name, collectionElementType); coercionRequired = true; @@ -1769,7 +1769,7 @@ private object EncodeCollection( { bindingTracer.WriteLine( "Adding element of type {0} to array position {1}", - (null == currentValueElement) ? "null" : currentValueElement.GetType().Name, + (currentValueElement == null) ? "null" : currentValueElement.GetType().Name, arrayIndex); resultAsIList[arrayIndex++] = currentValueElement; } @@ -1777,14 +1777,14 @@ private object EncodeCollection( { bindingTracer.WriteLine( "Adding element of type {0} via IList.Add", - (null == currentValueElement) ? "null" : currentValueElement.GetType().Name); + (currentValueElement == null) ? "null" : currentValueElement.GetType().Name); resultAsIList.Add(currentValueElement); } else { bindingTracer.WriteLine( "Adding element of type {0} via ICollection::Add()", - (null == currentValueElement) ? "null" : currentValueElement.GetType().Name); + (currentValueElement == null) ? "null" : currentValueElement.GetType().Name); addMethod.Invoke(resultCollection, new object[1] { currentValueElement }); } } @@ -1866,7 +1866,7 @@ private object EncodeCollection( { bindingTracer.WriteLine( "Adding scalar element of type {0} to array position {1}", - (null == currentValue) ? "null" : currentValue.GetType().Name, + (currentValue == null) ? "null" : currentValue.GetType().Name, 0); resultAsIList[0] = currentValue; } @@ -1874,14 +1874,14 @@ private object EncodeCollection( { bindingTracer.WriteLine( "Adding scalar element of type {0} via IList.Add", - (null == currentValue) ? "null" : currentValue.GetType().Name); + (currentValue == null) ? "null" : currentValue.GetType().Name); resultAsIList.Add(currentValue); } else { bindingTracer.WriteLine( "Adding scalar element of type {0} via ICollection::Add()", - (null == currentValue) ? "null" : currentValue.GetType().Name); + (currentValue == null) ? "null" : currentValue.GetType().Name); addMethod.Invoke(resultCollection, new object[1] { currentValue }); } } diff --git a/src/System.Management.Automation/engine/ProxyCommand.cs b/src/System.Management.Automation/engine/ProxyCommand.cs index 8d36b4f9d6b..dc63df3ade3 100644 --- a/src/System.Management.Automation/engine/ProxyCommand.cs +++ b/src/System.Management.Automation/engine/ProxyCommand.cs @@ -39,7 +39,7 @@ private ProxyCommand() /// public static string Create(CommandMetadata commandMetadata) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -65,7 +65,7 @@ public static string Create(CommandMetadata commandMetadata) /// public static string Create(CommandMetadata commandMetadata, string helpComment) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -95,7 +95,7 @@ public static string Create(CommandMetadata commandMetadata, string helpComment) /// public static string Create(CommandMetadata commandMetadata, string helpComment, bool generateDynamicParameters) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -118,7 +118,7 @@ public static string Create(CommandMetadata commandMetadata, string helpComment, /// public static string GetCmdletBindingAttribute(CommandMetadata commandMetadata) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -143,7 +143,7 @@ public static string GetCmdletBindingAttribute(CommandMetadata commandMetadata) [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] public static string GetParamBlock(CommandMetadata commandMetadata) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -167,7 +167,7 @@ public static string GetParamBlock(CommandMetadata commandMetadata) /// public static string GetBegin(CommandMetadata commandMetadata) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -190,7 +190,7 @@ public static string GetBegin(CommandMetadata commandMetadata) /// public static string GetProcess(CommandMetadata commandMetadata) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -213,7 +213,7 @@ public static string GetProcess(CommandMetadata commandMetadata) /// public static string GetDynamicParam(CommandMetadata commandMetadata) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } @@ -236,7 +236,7 @@ public static string GetDynamicParam(CommandMetadata commandMetadata) /// public static string GetEnd(CommandMetadata commandMetadata) { - if (null == commandMetadata) + if (commandMetadata == null) { throw PSTraceSource.NewArgumentNullException("commandMetaData"); } diff --git a/src/System.Management.Automation/engine/PseudoParameterBinder.cs b/src/System.Management.Automation/engine/PseudoParameterBinder.cs index e089b74543f..ccbcc19d7db 100644 --- a/src/System.Management.Automation/engine/PseudoParameterBinder.cs +++ b/src/System.Management.Automation/engine/PseudoParameterBinder.cs @@ -41,7 +41,7 @@ internal RuntimeDefinedParameterBinder( { string key = pair.Key; RuntimeDefinedParameter pp = pair.Value; - string ppName = (null == pp) ? null : pp.Name; + string ppName = (pp == null) ? null : pp.Name; if (null == pp || key != ppName) { ParameterBindingException bindingException = diff --git a/src/System.Management.Automation/engine/TypeMetadata.cs b/src/System.Management.Automation/engine/TypeMetadata.cs index 1fe444cb165..5a1a14bfc51 100644 --- a/src/System.Management.Automation/engine/TypeMetadata.cs +++ b/src/System.Management.Automation/engine/TypeMetadata.cs @@ -612,7 +612,7 @@ public bool SwitchParameter /// public static Dictionary GetParameterMetadata(Type type) { - if (null == type) + if (type == null) { throw PSTraceSource.NewArgumentNullException("type"); } @@ -1310,7 +1310,7 @@ private void ConstructCompiledParametersUsingRuntimeDefinedParameters( // Create the compiled parameter and add it to the bindable parameters collection // NTRAID#Windows Out Of Band Releases-926374-2005/12/22-JonN - if (null == parameterDefinition) + if (parameterDefinition == null) continue; CompiledCommandParameter parameter = new CompiledCommandParameter(parameterDefinition, processingDynamicParameters); diff --git a/src/System.Management.Automation/engine/TypeTable.cs b/src/System.Management.Automation/engine/TypeTable.cs index 2b327c2fb7f..b447bc2928f 100644 --- a/src/System.Management.Automation/engine/TypeTable.cs +++ b/src/System.Management.Automation/engine/TypeTable.cs @@ -2429,7 +2429,7 @@ public sealed class PropertySetData : TypeMemberData /// public PropertySetData(IEnumerable referencedProperties) { - if (null == referencedProperties) + if (referencedProperties == null) { throw PSTraceSource.NewArgumentNullException("referencedProperties"); } @@ -3464,7 +3464,7 @@ public static List GetDefaultTypeFiles() /// internal TypeTable(IEnumerable typeFiles, AuthorizationManager authorizationManager, PSHost host) { - if (null == typeFiles) + if (typeFiles == null) { throw PSTraceSource.NewArgumentNullException("typeFiles"); } diff --git a/src/System.Management.Automation/engine/debugger/Breakpoint.cs b/src/System.Management.Automation/engine/debugger/Breakpoint.cs index 734e0057174..ae76ffa677d 100644 --- a/src/System.Management.Automation/engine/debugger/Breakpoint.cs +++ b/src/System.Management.Automation/engine/debugger/Breakpoint.cs @@ -83,7 +83,7 @@ internal Breakpoint(string script, ScriptBlock action, int id) internal BreakpointAction Trigger() { ++HitCount; - if (null == Action) + if (Action == null) { return BreakpointAction.Break; } diff --git a/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs b/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs index da42d3f8ab3..4b4664b0c9c 100644 --- a/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs +++ b/src/System.Management.Automation/engine/hostifaces/AsyncResult.cs @@ -80,11 +80,11 @@ public WaitHandle AsyncWaitHandle { get { - if (null == _completedWaitHandle) + if (_completedWaitHandle == null) { lock (SyncObject) { - if (null == _completedWaitHandle) + if (_completedWaitHandle == null) { _completedWaitHandle = new ManualResetEvent(IsCompleted); } diff --git a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs index 4a601e3d27d..0a16b97631b 100644 --- a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs @@ -913,7 +913,7 @@ public Collection PromptForChoice(string caption, Collection result = null; try { - if (null == hostForMultipleChoices) + if (hostForMultipleChoices == null) { // host did not implement this new interface.. // so work with V1 host API to get the behavior.. diff --git a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs index 6a79b5b9f86..18d29fff5d4 100644 --- a/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs +++ b/src/System.Management.Automation/engine/hostifaces/NativeCultureResolver.cs @@ -112,11 +112,11 @@ private VistaCultureInfo ImmediateParent { get { - if (null == _parentCI) + if (_parentCI == null) { lock (_syncObject) { - if (null == _parentCI) + if (_parentCI == null) { string parentCulture = base.Parent.Name; // remove the parentCulture from the m_fallbacks list. @@ -177,11 +177,11 @@ internal static CultureInfo UICulture { get { - if (null == s_uiCulture) + if (s_uiCulture == null) { lock (s_syncObject) { - if (null == s_uiCulture) + if (s_uiCulture == null) { s_uiCulture = GetUICulture(); } @@ -196,11 +196,11 @@ internal static CultureInfo Culture { get { - if (null == s_culture) + if (s_culture == null) { lock (s_syncObject) { - if (null == s_culture) + if (s_culture == null) { s_culture = GetCulture(); } diff --git a/src/System.Management.Automation/engine/hostifaces/PSCommand.cs b/src/System.Management.Automation/engine/hostifaces/PSCommand.cs index b259dc23c58..de2c360dd39 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSCommand.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSCommand.cs @@ -86,7 +86,7 @@ internal PSCommand(Command command) /// public PSCommand AddCommand(string command) { - if (null == command) + if (command == null) { throw PSTraceSource.NewArgumentNullException("cmdlet"); } @@ -129,7 +129,7 @@ public PSCommand AddCommand(string command) /// public PSCommand AddCommand(string cmdlet, bool useLocalScope) { - if (null == cmdlet) + if (cmdlet == null) { throw PSTraceSource.NewArgumentNullException("cmdlet"); } @@ -170,7 +170,7 @@ public PSCommand AddCommand(string cmdlet, bool useLocalScope) /// public PSCommand AddScript(string script) { - if (null == script) + if (script == null) { throw PSTraceSource.NewArgumentNullException("script"); } @@ -214,7 +214,7 @@ public PSCommand AddScript(string script) /// public PSCommand AddScript(string script, bool useLocalScope) { - if (null == script) + if (script == null) { throw PSTraceSource.NewArgumentNullException("script"); } @@ -251,7 +251,7 @@ public PSCommand AddScript(string script, bool useLocalScope) /// public PSCommand AddCommand(Command command) { - if (null == command) + if (command == null) { throw PSTraceSource.NewArgumentNullException("command"); } @@ -296,7 +296,7 @@ public PSCommand AddCommand(Command command) /// public PSCommand AddParameter(string parameterName, object value) { - if (null == _currentCommand) + if (_currentCommand == null) { throw PSTraceSource.NewInvalidOperationException(PSCommandStrings.ParameterRequiresCommand, new object[] { "PSCommand" }); @@ -336,7 +336,7 @@ public PSCommand AddParameter(string parameterName, object value) /// public PSCommand AddParameter(string parameterName) { - if (null == _currentCommand) + if (_currentCommand == null) { throw PSTraceSource.NewInvalidOperationException(PSCommandStrings.ParameterRequiresCommand, new object[] { "PSCommand" }); @@ -377,7 +377,7 @@ public PSCommand AddParameter(string parameterName) /// public PSCommand AddArgument(object value) { - if (null == _currentCommand) + if (_currentCommand == null) { throw PSTraceSource.NewInvalidOperationException(PSCommandStrings.ParameterRequiresCommand, new object[] { "PSCommand" }); diff --git a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs index 611bab902e5..8590531fa8a 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs @@ -1308,11 +1308,11 @@ internal WaitHandle WaitHandle { get { - if (null == _readWaitHandle) + if (_readWaitHandle == null) { lock (SyncObject) { - if (null == _readWaitHandle) + if (_readWaitHandle == null) { // Create the handle signaled if there are objects in the buffer // or the buffer has been closed. @@ -1498,7 +1498,7 @@ internal void InternalAdd(Guid psInstanceId, T item) /// internal void InternalAddRange(Guid psInstanceId, ICollection collection) { - if (null == collection) + if (collection == null) { throw PSTraceSource.NewArgumentNullException("collection"); } @@ -1612,7 +1612,7 @@ private int InternalIndexOf(T item) /// private static void VerifyValueType(object value) { - if (null == value) + if (value == null) { if (typeof(T).IsValueType) { diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index bfe8a92c93d..ccd092de157 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -355,7 +355,7 @@ public PSHost Host } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Host"); } @@ -1424,7 +1424,7 @@ public PSCommand Commands set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Command"); } @@ -1466,7 +1466,7 @@ internal PSDataCollection ErrorBuffer set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Error"); } @@ -1500,7 +1500,7 @@ internal PSDataCollection ProgressBuffer set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Progress"); } @@ -1533,7 +1533,7 @@ internal PSDataCollection VerboseBuffer set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Verbose"); } @@ -1566,7 +1566,7 @@ internal PSDataCollection DebugBuffer set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Debug"); } @@ -1602,7 +1602,7 @@ internal PSDataCollection WarningBuffer set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Warning"); } @@ -1638,7 +1638,7 @@ internal PSDataCollection InformationBuffer set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Information"); } @@ -2695,7 +2695,7 @@ public void Invoke(IEnumerable input, IList output) /// public void Invoke(IEnumerable input, IList output, PSInvocationSettings settings) { - if (null == output) + if (output == null) { throw PSTraceSource.NewArgumentNullException("output"); } @@ -2769,7 +2769,7 @@ public void Invoke(IEnumerable input, IList output, PSInvocationSettings s /// public void Invoke(PSDataCollection input, PSDataCollection output, PSInvocationSettings settings) { - if (null == output) + if (output == null) { throw PSTraceSource.NewArgumentNullException("output"); } @@ -2998,7 +2998,7 @@ public IAsyncResult BeginInvoke(PSDataCollection input, /// public IAsyncResult BeginInvoke(PSDataCollection input, PSDataCollection output, PSInvocationSettings settings, AsyncCallback callback, object state) { - if (null == output) + if (output == null) { throw PSTraceSource.NewArgumentNullException("output"); } @@ -3390,14 +3390,14 @@ public PSDataCollection EndInvoke(IAsyncResult asyncResult) { _commandInvokedSynchronously = true; - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } PowerShellAsyncResult psAsyncResult = asyncResult as PowerShellAsyncResult; - if ((null == psAsyncResult) || + if ((psAsyncResult == null) || (psAsyncResult.OwnerId != InstanceId) || (psAsyncResult.IsAssociatedWithAsyncInvoke != true)) { @@ -3491,14 +3491,14 @@ public IAsyncResult BeginStop(AsyncCallback callback, object state) /// public void EndStop(IAsyncResult asyncResult) { - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } PowerShellAsyncResult psAsyncResult = asyncResult as PowerShellAsyncResult; - if ((null == psAsyncResult) || + if ((psAsyncResult == null) || (psAsyncResult.OwnerId != InstanceId) || (psAsyncResult.IsAssociatedWithAsyncInvoke != false)) { @@ -4679,7 +4679,7 @@ private void Prepare(PSDataCollection input, PSDataColl lock (_syncObject) { - if ((null == _psCommand) || (null == _psCommand.Commands) || (0 == _psCommand.Commands.Count)) + if ((_psCommand == null) || (null == _psCommand.Commands) || (0 == _psCommand.Commands.Count)) { throw PSTraceSource.NewInvalidOperationException(PowerShellStrings.NoCommandToInvoke); } @@ -5092,7 +5092,7 @@ internal void CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, bool isSync) { // Set the host for this local runspace if user specified one. LocalRunspace rs = rsToUse as LocalRunspace; - if (null == rs) + if (rs == null) { lock (_shell._syncObject) { @@ -5351,7 +5351,7 @@ internal void InternalClearSuppressExceptions() _outputStream.Close(); _errorStream.Close(); - if (null == CurrentlyRunningPipeline) + if (CurrentlyRunningPipeline == null) { return; } @@ -5360,7 +5360,7 @@ internal void InternalClearSuppressExceptions() // and pipeline.dispose will not change powershell instances state CurrentlyRunningPipeline.StateChanged -= _shell.PipelineStateChanged; - if ((null == GetRunspaceAsyncResult) && (null == _shell._rsConnection)) + if ((GetRunspaceAsyncResult == null) && (null == _shell._rsConnection)) { // user did not supply a runspace..Invoke* method created // a new runspace..so close it. diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs index c5274140507..9e9abe3a72c 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs @@ -738,7 +738,7 @@ public event EventHandler StateChanged { lock (_syncObject) { - bool firstEntry = (null == InternalStateChanged); + bool firstEntry = (InternalStateChanged == null); InternalStateChanged += value; if (firstEntry) { @@ -756,7 +756,7 @@ public event EventHandler StateChanged lock (_syncObject) { InternalStateChanged -= value; - if (null == InternalStateChanged) + if (InternalStateChanged == null) { _internalPool.StateChanged -= new EventHandler(OnStateChanged); @@ -853,7 +853,7 @@ internal event EventHandler RunspaceCreated { lock (_syncObject) { - bool firstEntry = (null == InternalRunspaceCreated); + bool firstEntry = (InternalRunspaceCreated == null); InternalRunspaceCreated += value; if (firstEntry) { @@ -870,7 +870,7 @@ internal event EventHandler RunspaceCreated lock (_syncObject) { InternalRunspaceCreated -= value; - if (null == InternalRunspaceCreated) + if (InternalRunspaceCreated == null) { _internalPool.RunspaceCreated -= OnRunspaceCreated; } diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs index 40a3157b446..328c4a8f419 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs @@ -617,14 +617,14 @@ public IAsyncResult BeginOpen(AsyncCallback callback, object state) /// public void EndOpen(IAsyncResult asyncResult) { - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } RunspacePoolAsyncResult rsAsyncResult = asyncResult as RunspacePoolAsyncResult; - if ((null == rsAsyncResult) || + if ((rsAsyncResult == null) || (rsAsyncResult.OwnerId != instanceId) || (!rsAsyncResult.IsAssociatedWithAsyncOpen)) { @@ -684,14 +684,14 @@ public virtual IAsyncResult BeginClose(AsyncCallback callback, object state) /// public virtual void EndClose(IAsyncResult asyncResult) { - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } RunspacePoolAsyncResult rsAsyncResult = asyncResult as RunspacePoolAsyncResult; - if ((null == rsAsyncResult) || + if ((rsAsyncResult == null) || (rsAsyncResult.OwnerId != instanceId) || (rsAsyncResult.IsAssociatedWithAsyncOpen)) { @@ -753,7 +753,7 @@ public Runspace GetRunspace() /// public void ReleaseRunspace(Runspace runspace) { - if (null == runspace) + if (runspace == null) { throw PSTraceSource.NewArgumentNullException("runspace"); } @@ -893,7 +893,7 @@ internal IAsyncResult BeginGetRunspace( /// internal void CancelGetRunspace(IAsyncResult asyncResult) { - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } @@ -901,7 +901,7 @@ internal void CancelGetRunspace(IAsyncResult asyncResult) GetRunspaceAsyncResult grsAsyncResult = asyncResult as GetRunspaceAsyncResult; - if ((null == grsAsyncResult) || (grsAsyncResult.OwnerId != instanceId)) + if ((grsAsyncResult == null) || (grsAsyncResult.OwnerId != instanceId)) { throw PSTraceSource.NewArgumentException("asyncResult", RunspacePoolStrings.AsyncResultNotOwned, @@ -932,7 +932,7 @@ internal void CancelGetRunspace(IAsyncResult asyncResult) /// internal Runspace EndGetRunspace(IAsyncResult asyncResult) { - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } @@ -940,7 +940,7 @@ internal Runspace EndGetRunspace(IAsyncResult asyncResult) GetRunspaceAsyncResult grsAsyncResult = asyncResult as GetRunspaceAsyncResult; - if ((null == grsAsyncResult) || (grsAsyncResult.OwnerId != instanceId)) + if ((grsAsyncResult == null) || (grsAsyncResult.OwnerId != instanceId)) { throw PSTraceSource.NewArgumentException("asyncResult", RunspacePoolStrings.AsyncResultNotOwned, diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs index ac7ac91f43f..8d0e4213f16 100644 --- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs +++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs @@ -126,7 +126,7 @@ protected PipelineBase(PipelineBase pipeline) : this(pipeline.Runspace, null, false, pipeline.IsNested) { // NTRAID#Windows Out Of Band Releases-915851-2005/09/13 - if (null == pipeline) + if (pipeline == null) { throw PSTraceSource.NewArgumentNullException("pipeline"); } diff --git a/src/System.Management.Automation/engine/lang/parserutils.cs b/src/System.Management.Automation/engine/lang/parserutils.cs index 50e22f3f00f..953af425442 100644 --- a/src/System.Management.Automation/engine/lang/parserutils.cs +++ b/src/System.Management.Automation/engine/lang/parserutils.cs @@ -1868,7 +1868,7 @@ private static RuntimeException NewBackupInterpreterException( Exception innerException) { string message; - if (null == innerException) + if (innerException == null) { // there is no reason this string lookup should fail message = StringUtil.Format(ParserStrings.BackupParserMessage, errorId); diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index fe9b6b64d2a..ce5cc877e96 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -313,11 +313,11 @@ internal void AddRedirectionPipe(PipelineProcessor pipelineProcessor) /// internal int AddCommand(CommandProcessorBase commandProcessor, int readFromCommand, bool readErrorQueue) { - if (null == commandProcessor) + if (commandProcessor == null) { throw PSTraceSource.NewArgumentNullException("commandProcessor"); } - if (null == _commands) + if (_commands == null) { // "_commands == null" throw PSTraceSource.NewInvalidOperationException(); @@ -366,7 +366,7 @@ internal int AddCommand(CommandProcessorBase commandProcessor, int readFromComma } Pipe UpstreamPipe = (readErrorQueue) ? prevcommandProcessor.CommandRuntime.ErrorOutputPipe : prevcommandProcessor.CommandRuntime.OutputPipe; - if (null == UpstreamPipe) + if (UpstreamPipe == null) { // "PipelineProcessor.AddCommand(): UpstreamPipe == null" throw PSTraceSource.NewInvalidOperationException(); @@ -585,7 +585,7 @@ private void DoCompleteCore(CommandProcessorBase commandRequestingUpstreamComman { CommandProcessorBase commandProcessor = _commands[i]; - if (null == commandProcessor) + if (commandProcessor == null) { // "null command " + i throw PSTraceSource.NewInvalidOperationException(); @@ -779,7 +779,7 @@ internal void Stop() // Retain copy of _commands in case Dispose() is called List commands = _commands; - if (null == commands) + if (commands == null) return; // Call StopProcessing() for all the commands. @@ -787,7 +787,7 @@ internal void Stop() { CommandProcessorBase commandProcessor = commands[i]; - if (null == commandProcessor) + if (commandProcessor == null) { throw PSTraceSource.NewInvalidOperationException(); } @@ -990,7 +990,7 @@ private void Start(bool incomingStream) for (int i = 0; i < _commands.Count; i++) { CommandProcessorBase commandProcessor = _commands[i]; - if (null == commandProcessor) + if (commandProcessor == null) { // "null command " + i throw PSTraceSource.NewInvalidOperationException(); @@ -1374,7 +1374,7 @@ internal bool RecordFailure(Exception e, InternalCommand command) bool wasStopping = false; lock (_stopReasonLock) { - if (null == _firstTerminatingError) + if (_firstTerminatingError == null) { _firstTerminatingError = ExceptionDispatchInfo.Capture(e); } diff --git a/src/System.Management.Automation/engine/regex.cs b/src/System.Management.Automation/engine/regex.cs index 67a69770f53..a8039ab2415 100644 --- a/src/System.Management.Automation/engine/regex.cs +++ b/src/System.Management.Automation/engine/regex.cs @@ -407,7 +407,7 @@ public class WildcardPatternException : RuntimeException internal WildcardPatternException(ErrorRecord errorRecord) : base(RetrieveMessage(errorRecord)) { - if (null == errorRecord) + if (errorRecord == null) { throw new ArgumentNullException("errorRecord"); } diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 491e62c8e8c..b3b1f22ea3f 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -684,7 +684,7 @@ internal PSDataCollection Results } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Results"); } @@ -1073,7 +1073,7 @@ public PSDataCollection Output } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Output"); } @@ -1107,7 +1107,7 @@ public PSDataCollection Error } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Error"); } @@ -1141,7 +1141,7 @@ public PSDataCollection Progress } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Progress"); } @@ -1172,7 +1172,7 @@ public PSDataCollection Verbose } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Verbose"); } @@ -1206,7 +1206,7 @@ public PSDataCollection Debug } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Debug"); } @@ -1239,7 +1239,7 @@ public PSDataCollection Warning } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Warning"); } @@ -1273,7 +1273,7 @@ public PSDataCollection Information } set { - if (null == value) + if (value == null) { throw PSTraceSource.NewArgumentNullException("Information"); } diff --git a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs index 700404720a8..6a570b194c1 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs @@ -585,7 +585,7 @@ internal void HandleStateInfoReceived(object sender, // if closeAsyncResult is null, BeginClose is not called. That means // we are getting close event from server, in this case release the // local resources - if (null == _closeAsyncResult) + if (_closeAsyncResult == null) { // Close the local resources. DataStructureHandler.CloseRunspacePoolAsync(); @@ -1066,14 +1066,14 @@ public override IAsyncResult BeginDisconnect(AsyncCallback callback, object stat /// IAsyncResult object. public override void EndDisconnect(IAsyncResult asyncResult) { - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } RunspacePoolAsyncResult rsAsyncResult = asyncResult as RunspacePoolAsyncResult; - if ((null == rsAsyncResult) || + if ((rsAsyncResult == null) || (rsAsyncResult.OwnerId != instanceId) || (rsAsyncResult.IsAssociatedWithAsyncOpen)) { @@ -1176,14 +1176,14 @@ public override IAsyncResult BeginConnect(AsyncCallback callback, object state) /// IAsyncResult object. public override void EndConnect(IAsyncResult asyncResult) { - if (null == asyncResult) + if (asyncResult == null) { throw PSTraceSource.NewArgumentNullException("asyncResult"); } RunspacePoolAsyncResult rsAsyncResult = asyncResult as RunspacePoolAsyncResult; - if ((null == rsAsyncResult) || + if ((rsAsyncResult == null) || (rsAsyncResult.OwnerId != instanceId) || (rsAsyncResult.IsAssociatedWithAsyncOpen)) { diff --git a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs index 5971e768237..09567e20f68 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs @@ -170,7 +170,7 @@ private RemotePipeline(RemotePipeline pipeline) : // NTRAID#Windows Out Of Band Releases-915851-2005/09/13 // the above comment copied from RemotePipelineBase which // originally copied it from PipelineBase - if (null == pipeline) + if (pipeline == null) { throw PSTraceSource.NewArgumentNullException("pipeline"); } diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 11dc1a60967..e28e93effb1 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -2288,7 +2288,7 @@ public string SecurityDescriptorSddl CommonSecurityDescriptor c = new CommonSecurityDescriptor(false, false, value); // this will never be the case..as constructor either constructs or throws. // this is used here to avoid FxCop violation. - if (null == c) + if (c == null) { throw new NotSupportedException(); } @@ -4407,7 +4407,7 @@ public string SecurityDescriptorSddl CommonSecurityDescriptor c = new CommonSecurityDescriptor(false, false, value); // this will never be the case..as constructor either constructs or throws. // this is used here to avoid FxCop violation. - if (null == c) + if (c == null) { throw new NotSupportedException(); } diff --git a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs index fdda2b96e35..158c81c1c35 100644 --- a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs +++ b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs @@ -2011,7 +2011,7 @@ internal static string CombineHashTableOrStringArray(object[] values, StreamWrit else { Hashtable hashVal = values[i] as Hashtable; - if (null == hashVal) + if (hashVal == null) { string message = StringUtil.Format(RemotingErrorIdStrings.DISCTypeMustBeStringOrHashtableArray, ConfigFileConstants.ModulesToImport); diff --git a/src/System.Management.Automation/engine/remoting/common/DispatchTable.cs b/src/System.Management.Automation/engine/remoting/common/DispatchTable.cs index 3a97495d8bd..0942647967e 100644 --- a/src/System.Management.Automation/engine/remoting/common/DispatchTable.cs +++ b/src/System.Management.Automation/engine/remoting/common/DispatchTable.cs @@ -103,7 +103,7 @@ internal T GetResponse(long callId, T defaultValue) // return caller specified value in case there is no response // from remote end. - if (null == remoteHostResponse) + if (remoteHostResponse == null) { return defaultValue; } diff --git a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs index 70d9d0b3d58..8bd945b62d5 100644 --- a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs +++ b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs @@ -1127,7 +1127,7 @@ internal static T ExtractPropertyAsWsManConnectionInfo(RunspaceConnectionInfo string property, T defaultValue) { WSManConnectionInfo wsCI = rsCI as WSManConnectionInfo; - if (null == wsCI) + if (wsCI == null) { return defaultValue; } diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs index 72248e77ca5..1bcee10332c 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs @@ -95,7 +95,7 @@ internal static RemoteSessionCapability CreateServerCapability() /// internal static byte[] GetCurrentTimeZoneInByteFormat() { - if (null == _timeZoneInByteFormat) + if (_timeZoneInByteFormat == null) { Exception e = null; try diff --git a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs index 33863bb2846..156189866fe 100644 --- a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs +++ b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs @@ -691,7 +691,7 @@ public override int Read(byte[] buffer, int offset, int count) while (dataWritten < count) { - if (null == _readStream) + if (_readStream == null) { if (_queuedStreams.Count > 0) { @@ -779,7 +779,7 @@ private void WriteCurrentFragmentAndReset() return; } - if (null == _writeStream) + if (_writeStream == null) { _writeStream = new MemoryStream(_fragmentSize); s_trace.WriteLine("Created write stream: {0}", _writeStream.GetHashCode()); diff --git a/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs b/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs index df0c8ba9299..82830417b32 100644 --- a/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs +++ b/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs @@ -724,7 +724,7 @@ internal event EventHandler EventHandler { add { - bool firstEntry = (null == InternalEvent); + bool firstEntry = (InternalEvent == null); InternalEvent += value; diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs index b0ca9f5da7e..0cfcd3681a3 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs @@ -540,7 +540,7 @@ private static Type LoadAndAnalyzeAssembly(string shellId, string applicationBas assemblyName, shellId); assembly = LoadSsnStateProviderAssembly(applicationBase, assemblyName); - if (null == assembly) + if (assembly == null) { throw PSTraceSource.NewArgumentException("assemblyName", RemotingErrorIdStrings.UnableToLoadAssembly, assemblyName, ConfigurationDataFromXML.INITPARAMETERSTOKEN); @@ -557,7 +557,7 @@ private static Type LoadAndAnalyzeAssembly(string shellId, string applicationBas typeToLoad, shellId); Type type = assembly.GetType(typeToLoad, true, true); - if (null == type) + if (type == null) { throw PSTraceSource.NewArgumentException("typeToLoad", RemotingErrorIdStrings.UnableToLoadType, typeToLoad, ConfigurationDataFromXML.INITPARAMETERSTOKEN); diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index 06f318488b5..d3f3d0bcb5b 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -519,7 +519,7 @@ internal override void CloseAsync() // will know that we are closing. isClosed = true; - if (null == stdInWriter) + if (stdInWriter == null) { // this will happen if CloseAsync() is called // before ConnectAsync()..in which case we @@ -835,7 +835,7 @@ private void OnCommandCreationPacketReceived(Guid psGuid) private void OnCommandCreationAckReceived(Guid psGuid) { OutOfProcessClientCommandTransportManager cmdTM = GetCommandTransportManager(psGuid); - if (null == cmdTM) + if (cmdTM == null) { throw new PSRemotingTransportException(PSRemotingErrorId.IPCUnknownCommandGuid, RemotingErrorIdStrings.IPCUnknownCommandGuid, @@ -1084,7 +1084,7 @@ private void OnErrorDataReceived(object sender, DataReceivedEventArgs e) private void KillServerProcess() { - if (null == _serverProcess) + if (_serverProcess == null) { // this can happen if Dispose is called before ConnectAsync() return; diff --git a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs index 5d476d89f52..c2287563c8c 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/PriorityCollection.cs @@ -222,13 +222,13 @@ internal byte[] ReadOrRegisterCallback(OnDataAvailableCallback callback, result = _dataToBeSent[(int)DataPriorityType.PromptResponse].ReadOrRegisterCallback(_onSendCollectionDataAvailable); priorityType = DataPriorityType.PromptResponse; - if (null == result) + if (result == null) { result = _dataToBeSent[(int)DataPriorityType.Default].ReadOrRegisterCallback(_onSendCollectionDataAvailable); priorityType = DataPriorityType.Default; } // no data to return..so register the callback. - if (null == result) + if (result == null) { // register callback. _onDataAvailableCallback = callback; diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index b055e25b07b..9447b34194b 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -187,7 +187,7 @@ internal void CreateShell( WSManNativeApi.WSManShellStartupInfo_UnToMan startupInfo, WSManNativeApi.WSManData_UnToMan inboundShellInformation) { - if (null == requestDetails) + if (requestDetails == null) { // Nothing can be done because requestDetails are required to report operation complete PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete, @@ -216,7 +216,7 @@ internal void CreateShell( return; } - if (null == startupInfo) + if (startupInfo == null) { ReportOperationComplete( requestDetails, @@ -292,7 +292,7 @@ internal void CreateShell( extraInfo, serverTransportMgr); - if (null == remoteShellSession) + if (remoteShellSession == null) { WSManPluginInstance.ReportWSManOperationComplete( requestDetails, @@ -301,7 +301,7 @@ internal void CreateShell( } context = new WSManPluginOperationShutdownContext(pluginContext, requestDetails.unmanagedHandle, IntPtr.Zero, false); - if (null == context) + if (context == null) { ReportOperationComplete(requestDetails, WSManPluginErrorCodes.OutOfMemory); return; @@ -463,7 +463,7 @@ internal void CloseShellOperation( context.isReceiveOperation.ToString()); WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(context.shellContext); - if (null == mgdShellSession) + if (mgdShellSession == null) { // this should never be the case. this will protect the service. //Dbg.Assert(false, "context.shellContext not matched"); @@ -491,7 +491,7 @@ internal void CloseCommandOperation( context.isReceiveOperation.ToString()); WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(context.shellContext); - if (null == mgdShellSession) + if (mgdShellSession == null) { // this should never be the case. this will protect the service. //Dbg.Assert(false, "context.shellContext not matched"); @@ -594,7 +594,7 @@ private bool validateIncomingContexts( IntPtr shellContext, string inputFunctionName) { - if (null == requestDetails) + if (requestDetails == null) { // Nothing can be done because requestDetails are required to report operation complete PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete, @@ -654,7 +654,7 @@ internal void CreateCommand( ((IntPtr)shellContext).ToString(), requestDetails.ToString()); WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext); - if (null == mgdShellSession) + if (mgdShellSession == null) { ReportOperationComplete( requestDetails, @@ -672,7 +672,7 @@ internal void StopCommand( IntPtr shellContext, IntPtr commandContext) { - if (null == requestDetails) + if (requestDetails == null) { // Nothing can be done because requestDetails are required to report operation complete PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete, @@ -698,7 +698,7 @@ internal void StopCommand( requestDetails.ToString()); WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext); - if (null == mgdShellSession) + if (mgdShellSession == null) { ReportOperationComplete( requestDetails, @@ -709,7 +709,7 @@ internal void StopCommand( } WSManPluginCommandSession mgdCommandSession = mgdShellSession.GetCommandSession(commandContext); - if (null == mgdCommandSession) + if (mgdCommandSession == null) { ReportOperationComplete( requestDetails, @@ -763,7 +763,7 @@ internal void ConnectShellOrCommand( ((IntPtr)shellContext).ToString(), ((IntPtr)commandContext).ToString(), ((IntPtr)requestDetails).ToString());*/ WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext); - if (null == mgdShellSession) + if (mgdShellSession == null) { ReportOperationComplete( requestDetails, @@ -781,7 +781,7 @@ internal void ConnectShellOrCommand( // this connect is on a command WSManPluginCommandSession mgdCmdSession = mgdShellSession.GetCommandSession(commandContext); - if (null == mgdCmdSession) + if (mgdCmdSession == null) { ReportOperationComplete( requestDetails, @@ -824,7 +824,7 @@ internal void SendOneItemToShellOrCommand( ((IntPtr)shellContext).ToString(), ((IntPtr)commandContext).ToString(), requestDetails.ToString()); WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext); - if (null == mgdShellSession) + if (mgdShellSession == null) { ReportOperationComplete( requestDetails, @@ -844,7 +844,7 @@ internal void SendOneItemToShellOrCommand( // the data is destined for command. WSManPluginCommandSession mgdCmdSession = mgdShellSession.GetCommandSession(commandContext); - if (null == mgdCmdSession) + if (mgdCmdSession == null) { ReportOperationComplete( requestDetails, @@ -890,7 +890,7 @@ internal void EnableShellOrCommandToSendDataToClient( requestDetails.ToString()); WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext); - if (null == mgdShellSession) + if (mgdShellSession == null) { ReportOperationComplete( requestDetails, @@ -902,7 +902,7 @@ internal void EnableShellOrCommandToSendDataToClient( } WSManPluginOperationShutdownContext ctxtToReport = new WSManPluginOperationShutdownContext(pluginContext, shellContext, IntPtr.Zero, true); - if (null == ctxtToReport) + if (ctxtToReport == null) { ReportOperationComplete(requestDetails, WSManPluginErrorCodes.OutOfMemory); return; @@ -922,7 +922,7 @@ internal void EnableShellOrCommandToSendDataToClient( ctxtToReport.commandContext = commandContext; WSManPluginCommandSession mgdCmdSession = mgdShellSession.GetCommandSession(commandContext); - if (null == mgdCmdSession) + if (mgdCmdSession == null) { ReportOperationComplete( requestDetails, @@ -1134,12 +1134,12 @@ internal static void PerformWSManPluginShell( { WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { lock (s_activePlugins) { pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { // create a new plugin WSManPluginInstance mgdPlugin = new WSManPluginInstance(); @@ -1167,7 +1167,7 @@ internal static void PerformWSManPluginCommand( { WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { ReportOperationComplete( requestDetails, @@ -1194,7 +1194,7 @@ internal static void PerformWSManPluginConnect( { WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { ReportOperationComplete( requestDetails, @@ -1222,7 +1222,7 @@ internal static void PerformWSManPluginSend( { WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { ReportOperationComplete( requestDetails, @@ -1249,7 +1249,7 @@ internal static void PerformWSManPluginReceive( { WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { ReportOperationComplete( requestDetails, @@ -1298,7 +1298,7 @@ internal static void PerformWSManPluginSignal( // we got crtl_c (stop) message from client. so stop powershell WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { ReportOperationComplete( request, @@ -1327,7 +1327,7 @@ internal static void PerformCloseOperation( { WSManPluginInstance pluginToUse = GetFromActivePlugins(context.pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { return; } @@ -1353,7 +1353,7 @@ internal static void PerformShutdown( { WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext); - if (null == pluginToUse) + if (pluginToUse == null) { return; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs index f3869cd59b6..674ada943ba 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs @@ -750,7 +750,7 @@ public static void PSPluginOperationShutdownCallback( object operationContext, bool timedOut) { - if (null == operationContext) + if (operationContext == null) { return; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index a969837ddda..d3c364d69c8 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -144,7 +144,7 @@ internal void SendOneItemToSession( return; } - if (null == inboundData) + if (inboundData == null) { // no data is supplied..just ignore. WSManPluginInstance.ReportOperationComplete( @@ -202,7 +202,7 @@ internal bool EnableSessionToSendDataToClient( return false; } - if ((null == streamSet) || + if ((streamSet == null) || (1 != streamSet.streamIDsCount)) { // only "stdout" is the supported output stream. @@ -442,7 +442,7 @@ internal override void ExecuteConnect( int flags, // in WSManNativeApi.WSManData_UnToMan inboundConnectInformation) // in optional { - if (null == inboundConnectInformation) + if (inboundConnectInformation == null) { WSManPluginInstance.ReportOperationComplete( requestDetails, @@ -564,7 +564,7 @@ internal void CloseCommandOperation( WSManPluginOperationShutdownContext context) { WSManPluginCommandSession mgdCmdSession = GetCommandSession(context.commandContext); - if (null == mgdCmdSession) + if (mgdCmdSession == null) { // this should never be the case. this will protect the service. return; diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs index 4a7fd90209d..f4e18e382a2 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs @@ -343,7 +343,7 @@ internal bool EnableTransportManagerSendDataToClient( _shutDownContext, -1, // INFINITE true); // TODO: Do I need to worry not being able to set missing WT_TRANSFER_IMPERSONATION? - if (null == _registeredShutDownWaitHandle) + if (_registeredShutDownWaitHandle == null) { isRegisterWaitForSingleObjectSucceeded = false; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index 8c7fe460288..3ddc748b066 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -911,7 +911,7 @@ internal override void ConnectAsync() ReceivedDataCollection.PrepareForStreamConnect(); // additional content with connect shell call. Negotiation and connect related messages // should be included in payload - if (null == _openContent) + if (_openContent == null) { DataPriorityType additionalDataType; byte[] additionalData = dataToBeSent.ReadOrRegisterCallback(null, out additionalDataType); @@ -1065,7 +1065,7 @@ internal override void CreateAsync() // additional content with create shell call. Piggy back first fragment from // the dataToBeSent buffer. - if (null == _openContent) + if (_openContent == null) { DataPriorityType additionalDataType; byte[] additionalData = dataToBeSent.ReadOrRegisterCallback(null, out additionalDataType); @@ -1470,7 +1470,7 @@ private void Initialize(Uri connectionUri, WSManConnectionInfo connectionInfo) { result = WSManNativeApi.WSManCreateSession(WSManAPIData.WSManAPIHandle, connectionStr, 0, authCredentials.GetMarshalledObject(), - (null == proxyInfo) ? IntPtr.Zero : (IntPtr)proxyInfo, + (proxyInfo == null) ? IntPtr.Zero : (IntPtr)proxyInfo, ref _wsManSessionHandle); } finally diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs index 0958797cf49..1fae7b22662 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs @@ -798,7 +798,7 @@ private void HandleCreateRunspacePool(object sender, RemoteDataEventArgs createR rsSessionStateToUse = _sessionConfigProvider.GetInitialSessionState(_senderInfo); } - if (null == rsSessionStateToUse) + if (rsSessionStateToUse == null) { throw PSTraceSource.NewInvalidOperationException(RemotingErrorIdStrings.InitialSessionStateNull, _configProviderId); } diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index 7836000a6c2..0bdaf0d2209 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -5519,7 +5519,7 @@ internal PSMemberInfo GetPSMemberInfo(DynamicMetaObject target, if (alias != null) { aliasConversionType = alias.ConversionType; - if (null == aliasRestrictions) + if (aliasRestrictions == null) { aliasRestrictions = new List(); } diff --git a/src/System.Management.Automation/engine/serialization.cs b/src/System.Management.Automation/engine/serialization.cs index 0e9a97b1fe1..ae44a42f528 100644 --- a/src/System.Management.Automation/engine/serialization.cs +++ b/src/System.Management.Automation/engine/serialization.cs @@ -3499,7 +3499,7 @@ internal object ReadOneObject(out string streamName) bool isKnownPrimitiveType; object result = ReadOneDeserializedObject(out streamName, out isKnownPrimitiveType); - if (null == result) + if (result == null) { return null; } diff --git a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs index 6c14a7da62f..a1ffa5f2113 100644 --- a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs @@ -219,7 +219,7 @@ internal Uri LookupUriFromCommandInfo() } ExecutionContext context = LocalPipeline.GetExecutionContextFromTLS(); - if (null == context) + if (context == null) { return null; } @@ -356,12 +356,12 @@ internal override bool MatchPatternInContent(WildcardPattern pattern) string synopsis = Synopsis; string detailedDescription = DetailedDescription; - if (null == synopsis) + if (synopsis == null) { synopsis = string.Empty; } - if (null == detailedDescription) + if (detailedDescription == null) { detailedDescription = string.Empty; } @@ -464,7 +464,7 @@ internal string DetailedDescription } PSObject descriptionObject = PSObject.AsPSObject(descriptionItem); - if ((null == descriptionObject) || + if ((descriptionObject == null) || (null == descriptionObject.Properties["Text"]) || (null == descriptionObject.Properties["Text"].Value)) { diff --git a/src/System.Management.Automation/help/CabinetNativeApi.cs b/src/System.Management.Automation/help/CabinetNativeApi.cs index be6022df4ed..d4e33013ab0 100644 --- a/src/System.Management.Automation/help/CabinetNativeApi.cs +++ b/src/System.Management.Automation/help/CabinetNativeApi.cs @@ -242,7 +242,7 @@ internal static IntPtr FdiOpen(string filename, int oflag, int pmode) { FileStream stream = new FileStream(filename, mode, access, share); - if (null == stream) + if (stream == null) { return new IntPtr(-1); } @@ -320,7 +320,7 @@ internal static int FdiClose(IntPtr fp) GCHandle handle = GCHandle.FromIntPtr(fp); FileStream stream = (FileStream)handle.Target; - if (null == stream) + if (stream == null) { return -1; } diff --git a/src/System.Management.Automation/help/CommandHelpProvider.cs b/src/System.Management.Automation/help/CommandHelpProvider.cs index 01a633e8ffd..06006ced73c 100644 --- a/src/System.Management.Automation/help/CommandHelpProvider.cs +++ b/src/System.Management.Automation/help/CommandHelpProvider.cs @@ -222,7 +222,7 @@ private HelpInfo GetHelpInfo(CommandInfo commandInfo, bool reportErrors, bool se { result = GetFromCommandCache(cmdletInfo.ModuleName, cmdletInfo.Name, cmdletInfo.HelpCategory); - if (null == result) + if (result == null) { // Try load the help file specified by CmdletInfo.HelpFile property helpFile = FindHelpFile(cmdletInfo); @@ -352,7 +352,7 @@ private HelpInfo GetHelpInfo(CommandInfo commandInfo, bool reportErrors, bool se } // If the above fails to get help, construct an HelpInfo object using the syntax and definition of the command - if (null == result) + if (result == null) { if (commandInfo.CommandType == CommandTypes.ExternalScript || commandInfo.CommandType == CommandTypes.Script) @@ -807,7 +807,7 @@ private HelpInfo GetFromCommandCache(string helpFileIdentifier, CommandInfo comm { Debug.Assert(commandInfo != null, "commandInfo cannot be null"); HelpInfo result = GetFromCommandCache(helpFileIdentifier, commandInfo.Name, commandInfo.HelpCategory); - if (null == result) + if (result == null) { // check if the command is prefixed and try retrieving help by removing the prefix if ((commandInfo.Module != null) && (!string.IsNullOrEmpty(commandInfo.Prefix))) diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index e50d31e59cf..e77e92dcb61 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -731,14 +731,14 @@ private static bool DoesCurrentRunspaceIncludeCoreHelpCmdlet() [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings")] public static string GetHelpUri(PSObject commandInfoPSObject) { - if (null == commandInfoPSObject) + if (commandInfoPSObject == null) { return string.Empty; } CommandInfo cmdInfo = PSObject.Base(commandInfoPSObject) as CommandInfo; // GetHelpUri helper method is expected to be used only by System.Management.Automation.CommandInfo // objects from types.ps1xml - if ((null == cmdInfo) || (string.IsNullOrEmpty(cmdInfo.Name))) + if ((cmdInfo == null) || (string.IsNullOrEmpty(cmdInfo.Name))) { return string.Empty; } diff --git a/src/System.Management.Automation/help/MamlCommandHelpInfo.cs b/src/System.Management.Automation/help/MamlCommandHelpInfo.cs index 825b840125f..91f9221230d 100644 --- a/src/System.Management.Automation/help/MamlCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/MamlCommandHelpInfo.cs @@ -338,7 +338,7 @@ private string ExtractTextForHelpProperty(PSObject psObject, string propertyName /// private string ExtractText(PSObject psObject) { - if (null == psObject) + if (psObject == null) { return string.Empty; } diff --git a/src/System.Management.Automation/help/ProviderHelpInfo.cs b/src/System.Management.Automation/help/ProviderHelpInfo.cs index c48743091aa..7c0a99de23d 100644 --- a/src/System.Management.Automation/help/ProviderHelpInfo.cs +++ b/src/System.Management.Automation/help/ProviderHelpInfo.cs @@ -110,7 +110,7 @@ internal string DetailedDescription foreach (object descriptionItem in descriptionItems) { PSObject descriptionObject = PSObject.AsPSObject(descriptionItem); - if ((null == descriptionObject) || + if ((descriptionObject == null) || (null == descriptionObject.Properties["Text"]) || (null == descriptionObject.Properties["Text"].Value)) { @@ -169,12 +169,12 @@ internal override bool MatchPatternInContent(WildcardPattern pattern) string synopsis = Synopsis; string detailedDescription = DetailedDescription; - if (null == synopsis) + if (synopsis == null) { synopsis = string.Empty; } - if (null == detailedDescription) + if (detailedDescription == null) { detailedDescription = string.Empty; } diff --git a/src/System.Management.Automation/help/ProviderHelpProvider.cs b/src/System.Management.Automation/help/ProviderHelpProvider.cs index 2f0330dee26..46d01aca00f 100644 --- a/src/System.Management.Automation/help/ProviderHelpProvider.cs +++ b/src/System.Management.Automation/help/ProviderHelpProvider.cs @@ -298,7 +298,7 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool PSSnapinQualifiedName snapinQualifiedNameForPattern = PSSnapinQualifiedName.GetInstance(pattern); - if (null == snapinQualifiedNameForPattern) + if (snapinQualifiedNameForPattern == null) { yield break; } diff --git a/src/System.Management.Automation/namespaces/ProviderBase.cs b/src/System.Management.Automation/namespaces/ProviderBase.cs index 7fb34e4bf3b..6b1eb143908 100644 --- a/src/System.Management.Automation/namespaces/ProviderBase.cs +++ b/src/System.Management.Automation/namespaces/ProviderBase.cs @@ -1577,7 +1577,7 @@ public void ThrowTerminatingError(ErrorRecord errorRecord) { using (PSTransactionManager.GetEngineProtectionScope()) { - if (null == errorRecord) + if (errorRecord == null) { throw PSTraceSource.NewArgumentNullException("errorRecord"); } diff --git a/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs b/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs index 023ddf55d5c..d26d3ce3642 100644 --- a/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs +++ b/src/System.Management.Automation/namespaces/SafeTransactionHandle.cs @@ -52,7 +52,7 @@ internal static SafeTransactionHandle Create(Transaction managedTransaction) IDtcTransaction dtcTransaction = TransactionInterop.GetDtcTransaction(managedTransaction); IKernelTransaction ktmInterface = dtcTransaction as IKernelTransaction; - if (null == ktmInterface) + if (ktmInterface == null) { throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions); } diff --git a/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs b/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs index 151149af58f..6b1eeb2cf85 100644 --- a/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs +++ b/src/System.Management.Automation/namespaces/TransactedRegistryKey.cs @@ -2042,7 +2042,7 @@ private static void ValidateKeyRights(int rights) private void VerifyTransaction() { // Require a transaction. This will throw for "Base" keys because they aren't associated with a transaction. - if (null == _myTransaction) + if (_myTransaction == null) { throw new InvalidOperationException(RegistryProviderStrings.InvalidOperation_NotAssociatedWithTransaction); } diff --git a/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs b/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs index e3eacff3643..45c399fa261 100644 --- a/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs +++ b/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs @@ -132,7 +132,7 @@ public override ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _isErrorRecordOriginallyNull = true; _errorRecord = new ErrorRecord( diff --git a/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs b/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs index 7b8949b00fe..938f57185a4 100644 --- a/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs +++ b/src/System.Management.Automation/utils/CommandDiscoveryExceptions.cs @@ -135,7 +135,7 @@ public override ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/CryptoUtils.cs b/src/System.Management.Automation/utils/CryptoUtils.cs index 448b3f08c9e..5a36308b3ad 100644 --- a/src/System.Management.Automation/utils/CryptoUtils.cs +++ b/src/System.Management.Automation/utils/CryptoUtils.cs @@ -873,7 +873,7 @@ protected void Dispose(bool disposing) // since otherwise, these are just references // to the static members - if (null == s_hStaticRSAKey) + if (s_hStaticRSAKey == null) { if (_hRSAKey != null) { @@ -885,7 +885,7 @@ protected void Dispose(bool disposing) } } - if (null == s_hStaticProv) + if (s_hStaticProv == null) { if (_hProv != null) { diff --git a/src/System.Management.Automation/utils/ExecutionExceptions.cs b/src/System.Management.Automation/utils/ExecutionExceptions.cs index 1cdde0bc30f..3f269222bd2 100644 --- a/src/System.Management.Automation/utils/ExecutionExceptions.cs +++ b/src/System.Management.Automation/utils/ExecutionExceptions.cs @@ -31,7 +31,7 @@ public class CmdletInvocationException : RuntimeException internal CmdletInvocationException(ErrorRecord errorRecord) : base(RetrieveMessage(errorRecord), RetrieveException(errorRecord)) { - if (null == errorRecord) + if (errorRecord == null) { throw new ArgumentNullException("errorRecord"); } @@ -55,7 +55,7 @@ internal CmdletInvocationException(Exception innerException, InvocationInfo invocationInfo) : base(RetrieveMessage(innerException), innerException) { - if (null == innerException) + if (innerException == null) { throw new ArgumentNullException("innerException"); } @@ -161,7 +161,7 @@ public override ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), @@ -202,7 +202,7 @@ internal CmdletProviderInvocationException( InvocationInfo myInvocation) : base(GetInnerException(innerException), myInvocation) { - if (null == innerException) + if (innerException == null) { throw new ArgumentNullException("innerException"); } @@ -281,7 +281,7 @@ public ProviderInfo ProviderInfo { get { - return (null == _providerInvocationException) + return (_providerInvocationException == null) ? null : _providerInvocationException.ProviderInfo; } @@ -465,7 +465,7 @@ public ActionPreferenceStopException() internal ActionPreferenceStopException(ErrorRecord error) : this(RetrieveMessage(error)) { - if (null == error) + if (error == null) { throw new ArgumentNullException("error"); } @@ -888,7 +888,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), @@ -996,7 +996,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/MshArgumentException.cs b/src/System.Management.Automation/utils/MshArgumentException.cs index 25b643df1fb..6a4ca577973 100644 --- a/src/System.Management.Automation/utils/MshArgumentException.cs +++ b/src/System.Management.Automation/utils/MshArgumentException.cs @@ -123,7 +123,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/MshArgumentNullException.cs b/src/System.Management.Automation/utils/MshArgumentNullException.cs index a1bafc6a2fc..14092bc2e5b 100644 --- a/src/System.Management.Automation/utils/MshArgumentNullException.cs +++ b/src/System.Management.Automation/utils/MshArgumentNullException.cs @@ -121,7 +121,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/MshArgumentOutOfRangeException.cs b/src/System.Management.Automation/utils/MshArgumentOutOfRangeException.cs index 5389bb60f6b..199d230b9e6 100644 --- a/src/System.Management.Automation/utils/MshArgumentOutOfRangeException.cs +++ b/src/System.Management.Automation/utils/MshArgumentOutOfRangeException.cs @@ -119,7 +119,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/MshInvalidOperationException.cs b/src/System.Management.Automation/utils/MshInvalidOperationException.cs index 46a1ce7684a..2ef68b5fbcc 100644 --- a/src/System.Management.Automation/utils/MshInvalidOperationException.cs +++ b/src/System.Management.Automation/utils/MshInvalidOperationException.cs @@ -117,7 +117,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/MshNotImplementedException.cs b/src/System.Management.Automation/utils/MshNotImplementedException.cs index d27afc36b67..9ba08eea797 100644 --- a/src/System.Management.Automation/utils/MshNotImplementedException.cs +++ b/src/System.Management.Automation/utils/MshNotImplementedException.cs @@ -100,7 +100,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/MshNotSupportedException.cs b/src/System.Management.Automation/utils/MshNotSupportedException.cs index bb2641b31c8..271e45eaca3 100644 --- a/src/System.Management.Automation/utils/MshNotSupportedException.cs +++ b/src/System.Management.Automation/utils/MshNotSupportedException.cs @@ -100,7 +100,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/MshObjectDisposedException.cs b/src/System.Management.Automation/utils/MshObjectDisposedException.cs index 73fabe371dd..70f375eba1b 100644 --- a/src/System.Management.Automation/utils/MshObjectDisposedException.cs +++ b/src/System.Management.Automation/utils/MshObjectDisposedException.cs @@ -106,7 +106,7 @@ public ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), diff --git a/src/System.Management.Automation/utils/ObjectReader.cs b/src/System.Management.Automation/utils/ObjectReader.cs index 2f406d9126b..99e5aef43ce 100644 --- a/src/System.Management.Automation/utils/ObjectReader.cs +++ b/src/System.Management.Automation/utils/ObjectReader.cs @@ -44,7 +44,7 @@ public override event EventHandler DataReady { lock (_monitorObject) { - bool firstRegistrant = (null == InternalDataReady); + bool firstRegistrant = (InternalDataReady == null); InternalDataReady += value; if (firstRegistrant) { @@ -57,7 +57,7 @@ public override event EventHandler DataReady lock (_monitorObject) { InternalDataReady -= value; - if (null == InternalDataReady) + if (InternalDataReady == null) { _stream.DataReady -= new EventHandler(this.OnDataReady); } @@ -449,7 +449,7 @@ protected override void Dispose(bool disposing) #region Private private static PSObject MakePSObject(object o) { - if (null == o) + if (o == null) return null; return PSObject.AsPSObject(o); @@ -462,7 +462,7 @@ private static PSObject MakePSObject(object o) private static Collection MakePSObjectCollection( Collection coll) { - if (null == coll) + if (coll == null) return null; Collection retval = new Collection(); foreach (object o in coll) diff --git a/src/System.Management.Automation/utils/ObjectStream.cs b/src/System.Management.Automation/utils/ObjectStream.cs index e3389b4be80..fcb677931e7 100644 --- a/src/System.Management.Automation/utils/ObjectStream.cs +++ b/src/System.Management.Automation/utils/ObjectStream.cs @@ -1333,7 +1333,7 @@ internal override int Write(object obj, bool enumerateCollection) { enumerable = LanguagePrimitives.GetEnumerable(obj); } - if (null == enumerable) + if (enumerable == null) a.Add(obj); else { @@ -1561,7 +1561,7 @@ internal sealed class PSDataCollectionStream : ObjectStreamBase /// internal PSDataCollectionStream(Guid psInstanceId, PSDataCollection storeToUse) { - if (null == storeToUse) + if (storeToUse == null) { throw PSTraceSource.NewArgumentNullException("storeToUse"); } @@ -1661,11 +1661,11 @@ internal override PipelineReader ObjectReader { get { - if (null == _objectReader) + if (_objectReader == null) { lock (_syncObject) { - if (null == _objectReader) + if (_objectReader == null) { _objectReader = new PSDataCollectionReader(this); } @@ -1686,11 +1686,11 @@ internal override PipelineReader ObjectReader /// the object that this stream writes belongs to internal PipelineReader GetObjectReaderForPipeline(String computerName, Guid runspaceId) { - if (null == _objectReaderForPipeline) + if (_objectReaderForPipeline == null) { lock (_syncObject) { - if (null == _objectReaderForPipeline) + if (_objectReaderForPipeline == null) { _objectReaderForPipeline = new PSDataCollectionPipelineReader(this, computerName, runspaceId); @@ -1708,11 +1708,11 @@ internal override PipelineReader PSObjectReader { get { - if (null == _psobjectReader) + if (_psobjectReader == null) { lock (_syncObject) { - if (null == _psobjectReader) + if (_psobjectReader == null) { _psobjectReader = new PSDataCollectionReader(this); } @@ -1733,11 +1733,11 @@ internal override PipelineReader PSObjectReader /// the object that this stream writes belongs to internal PipelineReader GetPSObjectReaderForPipeline(String computerName, Guid runspaceId) { - if (null == _psobjectReaderForPipeline) + if (_psobjectReaderForPipeline == null) { lock (_syncObject) { - if (null == _psobjectReaderForPipeline) + if (_psobjectReaderForPipeline == null) { _psobjectReaderForPipeline = new PSDataCollectionPipelineReader(this, computerName, runspaceId); @@ -1759,11 +1759,11 @@ internal override PipelineWriter ObjectWriter { get { - if (null == _writer) + if (_writer == null) { lock (_syncObject) { - if (null == _writer) + if (_writer == null) { _writer = new PSDataCollectionWriter(this) as PipelineWriter; } @@ -1822,7 +1822,7 @@ internal override int Write(object obj, bool enumerateCollection) { enumerable = LanguagePrimitives.GetEnumerable(obj); } - if (null == enumerable) + if (enumerable == null) { objectsToAdd.Add((T)LanguagePrimitives.ConvertTo(obj, typeof(T), Globalization.CultureInfo.InvariantCulture)); diff --git a/src/System.Management.Automation/utils/PsUtils.cs b/src/System.Management.Automation/utils/PsUtils.cs index 63727f75f6a..3fe10bacba2 100644 --- a/src/System.Management.Automation/utils/PsUtils.cs +++ b/src/System.Management.Automation/utils/PsUtils.cs @@ -545,7 +545,7 @@ internal static string StringToBase64String(string input) { // NTRAID#Windows Out Of Band Releases-926471-2005/12/27-JonN // shell crashes if you pass an empty script block to a native command - if (null == input) + if (input == null) { throw PSTraceSource.NewArgumentNullException("input"); } diff --git a/src/System.Management.Automation/utils/RuntimeException.cs b/src/System.Management.Automation/utils/RuntimeException.cs index 37c04fa34cd..46af0c5b196 100644 --- a/src/System.Management.Automation/utils/RuntimeException.cs +++ b/src/System.Management.Automation/utils/RuntimeException.cs @@ -153,7 +153,7 @@ public virtual ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), @@ -222,7 +222,7 @@ internal void SetTargetObject(object targetObject) #region Internal internal static string RetrieveMessage(ErrorRecord errorRecord) { - if (null == errorRecord) + if (errorRecord == null) return ""; if (errorRecord.ErrorDetails != null && !String.IsNullOrEmpty(errorRecord.ErrorDetails.Message)) @@ -236,17 +236,17 @@ internal static string RetrieveMessage(ErrorRecord errorRecord) internal static string RetrieveMessage(Exception e) { - if (null == e) + if (e == null) return ""; IContainsErrorRecord icer = e as IContainsErrorRecord; - if (null == icer) + if (icer == null) return e.Message; ErrorRecord er = icer.ErrorRecord; - if (null == er) + if (er == null) return e.Message; ErrorDetails ed = er.ErrorDetails; - if (null == ed) + if (ed == null) return e.Message; string detailsMessage = ed.Message; return (String.IsNullOrEmpty(detailsMessage)) ? e.Message : detailsMessage; @@ -254,7 +254,7 @@ internal static string RetrieveMessage(Exception e) internal static Exception RetrieveException(ErrorRecord errorRecord) { - if (null == errorRecord) + if (errorRecord == null) return null; return errorRecord.Exception; } diff --git a/src/System.Management.Automation/utils/SessionStateExceptions.cs b/src/System.Management.Automation/utils/SessionStateExceptions.cs index 5cc700b5f8b..b7786638f3c 100644 --- a/src/System.Management.Automation/utils/SessionStateExceptions.cs +++ b/src/System.Management.Automation/utils/SessionStateExceptions.cs @@ -103,7 +103,7 @@ internal ProviderInvocationException(ProviderInfo provider, ErrorRecord errorRec : base(RuntimeException.RetrieveMessage(errorRecord), RuntimeException.RetrieveException(errorRecord)) { - if (null == errorRecord) + if (errorRecord == null) { throw new ArgumentNullException("errorRecord"); } @@ -256,7 +256,7 @@ public override ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), @@ -279,7 +279,7 @@ private static string RetrieveMessage( string path, Exception innerException) { - if (null == innerException) + if (innerException == null) { Diagnostics.Assert(false, "ProviderInvocationException.RetrieveMessage needs innerException"); @@ -291,7 +291,7 @@ private static string RetrieveMessage( "ProviderInvocationException.RetrieveMessage needs errorId"); return RuntimeException.RetrieveMessage(innerException); } - if (null == provider) + if (provider == null) { Diagnostics.Assert(false, "ProviderInvocationException.RetrieveMessage needs provider"); @@ -517,7 +517,7 @@ public override ErrorRecord ErrorRecord { get { - if (null == _errorRecord) + if (_errorRecord == null) { _errorRecord = new ErrorRecord( new ParentContainsErrorRecordException(this), From 9b71fb65aed526829d9e4a7018471d2163eebb95 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:54:49 +0500 Subject: [PATCH 17/27] Replace '\((null) == (\w+.\w+)\)' -> '($2 == $1)' --- .../commands/utility/write.cs | 2 +- src/System.Management.Automation/engine/ExtraAdapter.cs | 2 +- .../engine/hostifaces/PowerShell.cs | 4 ++-- .../engine/remoting/fanin/InitialSessionStateProvider.cs | 4 ++-- .../engine/remoting/fanin/WSManPlugin.cs | 6 +++--- .../engine/remoting/fanin/WSManPluginShellSession.cs | 2 +- src/System.Management.Automation/utils/RuntimeException.cs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs index ba35fea6bea..974b7868170 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs @@ -346,7 +346,7 @@ protected override void ProcessRecord() string recact = RecommendedAction; if (!String.IsNullOrEmpty(recact)) { - if (null == errorRecord.ErrorDetails) + if (errorRecord.ErrorDetails == null) { errorRecord.ErrorDetails = new ErrorDetails(errorRecord.ToString()); } diff --git a/src/System.Management.Automation/engine/ExtraAdapter.cs b/src/System.Management.Automation/engine/ExtraAdapter.cs index b8c18566615..a7b3ab7e349 100644 --- a/src/System.Management.Automation/engine/ExtraAdapter.cs +++ b/src/System.Management.Automation/engine/ExtraAdapter.cs @@ -62,7 +62,7 @@ protected override T GetMember(object obj, string memberName) object invokeGetValue = entry.InvokeGet(memberName); // if entry.Properties[memberName] returns empty value and invokeGet non-empty // value..take invokeGet's value. This will fix bug Windows Bug 121188. - if ((collection == null) || ((null == collection.Value) && (invokeGetValue != null))) + if ((collection == null) || ((collection.Value == null) && (invokeGetValue != null))) { valueToTake = invokeGetValue; } diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index ccd092de157..0559f993e81 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -4679,7 +4679,7 @@ private void Prepare(PSDataCollection input, PSDataColl lock (_syncObject) { - if ((_psCommand == null) || (null == _psCommand.Commands) || (0 == _psCommand.Commands.Count)) + if ((_psCommand == null) || (_psCommand.Commands == null) || (0 == _psCommand.Commands.Count)) { throw PSTraceSource.NewInvalidOperationException(PowerShellStrings.NoCommandToInvoke); } @@ -5360,7 +5360,7 @@ internal void InternalClearSuppressExceptions() // and pipeline.dispose will not change powershell instances state CurrentlyRunningPipeline.StateChanged -= _shell.PipelineStateChanged; - if ((GetRunspaceAsyncResult == null) && (null == _shell._rsConnection)) + if ((GetRunspaceAsyncResult == null) && (_shell._rsConnection == null)) { // user did not supply a runspace..Invoke* method created // a new runspace..so close it. diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs index 0cfcd3681a3..3ca6353adc7 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs @@ -287,12 +287,12 @@ internal static ConfigurationDataFromXML Create(string initializationParameters) } // assign defaults after parsing the xml content. - if (null == result.MaxReceivedObjectSizeMB) + if (result.MaxReceivedObjectSizeMB == null) { result.MaxReceivedObjectSizeMB = BaseTransportManager.MaximumReceivedObjectSize; } - if (null == result.MaxReceivedCommandSizeMB) + if (result.MaxReceivedCommandSizeMB == null) { result.MaxReceivedCommandSizeMB = BaseTransportManager.MaximumReceivedDataSize; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index 9447b34194b..27aa366dd3b 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -203,8 +203,8 @@ internal void CreateShell( return; } - if ((null == requestDetails.senderDetails) || - (null == requestDetails.operationInfo)) + if ((requestDetails.senderDetails == null) || + (requestDetails.operationInfo == null)) { ReportOperationComplete( requestDetails, @@ -404,7 +404,7 @@ internal void CreateShell( context, -1, // INFINITE true); // TODO: Do I need to worry not being able to set missing WT_TRANSFER_IMPERSONATION? - if (null == mgdShellSession.registeredShutDownWaitHandle) + if (mgdShellSession.registeredShutDownWaitHandle == null) { isRegisterWaitForSingleObjectSucceeded = false; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index d3c364d69c8..55194c8e7f9 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -273,7 +273,7 @@ internal void ReportContext() shutDownContext, -1, // INFINITE true); // TODO: Do I need to worry not being able to set missing WT_TRANSFER_IMPERSONATION? - if (null == this.registeredShutDownWaitHandle) + if (this.registeredShutDownWaitHandle == null) { isRegisterWaitForSingleObjectFailed = true; registeredShutdownNotification = 0; diff --git a/src/System.Management.Automation/utils/RuntimeException.cs b/src/System.Management.Automation/utils/RuntimeException.cs index 46af0c5b196..b71852966c6 100644 --- a/src/System.Management.Automation/utils/RuntimeException.cs +++ b/src/System.Management.Automation/utils/RuntimeException.cs @@ -229,7 +229,7 @@ internal static string RetrieveMessage(ErrorRecord errorRecord) { return errorRecord.ErrorDetails.Message; } - if (null == errorRecord.Exception) + if (errorRecord.Exception == null) return ""; return errorRecord.Exception.Message; } From 9bbc5ba23fe702f55c395dda87fd2c1e48122a4f Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 15:56:47 +0500 Subject: [PATCH 18/27] Replace '\((null) == (\w+) ' -> '($2 == $1 ' --- .../WebCmdlet/Common/WebResponseObject.Common.cs | 2 +- .../commands/utility/compare-object.cs | 6 +++--- src/Microsoft.WSMan.Management/ConfigProvider.cs | 8 ++++---- .../engine/InternalCommands.cs | 2 +- .../engine/MshCommandRuntime.cs | 16 ++++++++-------- .../engine/PseudoParameterBinder.cs | 2 +- .../engine/debugger/debugger.cs | 2 +- .../engine/lang/parserutils.cs | 4 ++-- .../engine/parser/TypeResolver.cs | 2 +- .../engine/pipeline.cs | 10 +++++----- .../remoting/fanin/BaseTransportManager.cs | 2 +- .../help/CommandHelpProvider.cs | 6 +++--- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs index 2ec7c3d4f10..a1f4850ca84 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs @@ -53,7 +53,7 @@ public MemoryStream RawContentStream /// public long RawContentLength { - get { return (null == RawContentStream ? -1 : RawContentStream.Length); } + get { return (RawContentStream == null ? -1 : RawContentStream.Length); } } /// diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs index a70ac3f91dc..2cfb236216c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs @@ -272,7 +272,7 @@ private OrderByPropertyEntry MatchAndRemove( OrderByPropertyEntry match, List list) { - if (null == match || null == list) + if (match == null || null == list) return null; Diagnostics.Assert(_comparer != null, "null comparer"); for (int i = 0; i < list.Count; i++) @@ -319,7 +319,7 @@ private void Emit(OrderByPropertyEntry entry, string sideIndicator) else { mshobj = new PSObject(); - if (null == Property || 0 == Property.Length) + if (Property == null || 0 == Property.Length) { PSNoteProperty inputNote = new PSNoteProperty( InputObjectPropertyName, entry.inputObject); @@ -404,7 +404,7 @@ protected override void ProcessRecord() return; } - if (null == _comparer && 0 < DifferenceObject.Length) + if (_comparer == null && 0 < DifferenceObject.Length) { InitComparer(); } diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 5de09e63974..32be760c83c 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -1511,7 +1511,7 @@ WsMan Config Can be divided in to Four Fixed Regions to Check Whether Item is Co return true; } - if (null == arrResources || arrResources.Count == 0) + if (arrResources == null || arrResources.Count == 0) { return false; } @@ -2770,7 +2770,7 @@ private XmlDocument FindResourceValue(object sessionobj, string ResourceURI, Has XmlDocument outval = null; if (ResourceURI.Contains(WSManStringLiterals.containerListener) || ResourceURI.Contains(WSManStringLiterals.containerPlugin) || ResourceURI.Contains(WSManStringLiterals.containerCertMapping)) { - if (null == cmdlinevalues || cmdlinevalues.Count == 0) + if (cmdlinevalues == null || cmdlinevalues.Count == 0) { outval = EnumerateResourceValue(sessionobj, ResourceURI); } @@ -3596,7 +3596,7 @@ private void GetChildItemOrNamesForListenerOrCertMapping(XmlDocument xmlResource } else { return; } - if (null == Objcache || null == Keyscache) + if (Objcache == null || null == Keyscache) { return; } @@ -3661,7 +3661,7 @@ private void GetItemListenerOrCertMapping(string path, XmlDocument xmlResource, } else { return; } - if (null == Objcache || null == Keyscache) + if (Objcache == null || null == Keyscache) { return; } diff --git a/src/System.Management.Automation/engine/InternalCommands.cs b/src/System.Management.Automation/engine/InternalCommands.cs index ea04bee4091..76943a001ba 100644 --- a/src/System.Management.Automation/engine/InternalCommands.cs +++ b/src/System.Management.Automation/engine/InternalCommands.cs @@ -692,7 +692,7 @@ private bool BlockMethodInLanguageMode(Object inputObject) internal static ErrorRecord GenerateNameParameterError(string paraName, string resourceString, string errorId, object target, params object[] args) { string message; - if (null == args || 0 == args.Length) + if (args == null || 0 == args.Length) { // Don't format in case the string contains literal curly braces message = resourceString; diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index afebab30843..6f7179bc31c 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -174,7 +174,7 @@ public void WriteObject(object sendToPipeline) #else if (UseSecurityContextRun) { - if (null == PipelineProcessor || null == PipelineProcessor.SecurityContext) + if (PipelineProcessor == null || null == PipelineProcessor.SecurityContext) throw PSTraceSource.NewInvalidOperationException(PipelineStrings.WriteNotPermitted); ContextCallback delegateCallback = new ContextCallback(DoWriteObject); @@ -252,7 +252,7 @@ public void WriteObject(object sendToPipeline, bool enumerateCollection) #else if (UseSecurityContextRun) { - if (null == PipelineProcessor || null == PipelineProcessor.SecurityContext) + if (PipelineProcessor == null || null == PipelineProcessor.SecurityContext) throw PSTraceSource.NewInvalidOperationException(PipelineStrings.WriteNotPermitted); ContextCallback delegateCallback = new ContextCallback(DoWriteObjects); @@ -393,7 +393,7 @@ internal void WriteProgress( throw PSTraceSource.NewArgumentNullException("progressRecord"); } - if (null == Host || null == Host.UI) + if (Host == null || null == Host.UI) { Diagnostics.Assert(false, "No host in CommandBase.WriteProgress()"); throw PSTraceSource.NewInvalidOperationException(); @@ -499,7 +499,7 @@ internal void WriteDebug(DebugRecord record, bool overrideInquire = false) // // If no pipe, write directly to host. // - if (null == Host || null == Host.UI) + if (Host == null || null == Host.UI) { Diagnostics.Assert(false, "No host in CommandBase.WriteDebug()"); throw PSTraceSource.NewInvalidOperationException(); @@ -590,7 +590,7 @@ internal void WriteVerbose(VerboseRecord record, bool overrideInquire = false) // // If no pipe, write directly to host. // - if (null == Host || null == Host.UI) + if (Host == null || null == Host.UI) { Diagnostics.Assert(false, "No host in CommandBase.WriteVerbose()"); throw PSTraceSource.NewInvalidOperationException(); @@ -681,7 +681,7 @@ internal void WriteWarning(WarningRecord record, bool overrideInquire = false) // // If no pipe, write directly to host. // - if (null == Host || null == Host.UI) + if (Host == null || null == Host.UI) { Diagnostics.Assert(false, "No host in CommandBase.WriteWarning()"); throw PSTraceSource.NewInvalidOperationException(); @@ -746,7 +746,7 @@ internal void WriteInformation(InformationRecord record, bool overrideInquire = // // If no pipe, write directly to host. // - if (null == Host || null == Host.UI) + if (Host == null || null == Host.UI) { Diagnostics.Assert(false, "No host in CommandBase.WriteVerbose()"); throw PSTraceSource.NewInvalidOperationException(); @@ -2669,7 +2669,7 @@ internal void WriteError(ErrorRecord errorRecord, bool overrideInquire) #else if (UseSecurityContextRun) { - if (null == PipelineProcessor || null == PipelineProcessor.SecurityContext) + if (PipelineProcessor == null || null == PipelineProcessor.SecurityContext) throw PSTraceSource.NewInvalidOperationException(PipelineStrings.WriteNotPermitted); ContextCallback delegateCallback = new ContextCallback(DoWriteError); diff --git a/src/System.Management.Automation/engine/PseudoParameterBinder.cs b/src/System.Management.Automation/engine/PseudoParameterBinder.cs index ccbcc19d7db..63bb77fcc6c 100644 --- a/src/System.Management.Automation/engine/PseudoParameterBinder.cs +++ b/src/System.Management.Automation/engine/PseudoParameterBinder.cs @@ -42,7 +42,7 @@ internal RuntimeDefinedParameterBinder( string key = pair.Key; RuntimeDefinedParameter pp = pair.Value; string ppName = (pp == null) ? null : pp.Name; - if (null == pp || key != ppName) + if (pp == null || key != ppName) { ParameterBindingException bindingException = new ParameterBindingException( diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index c124d6d4425..77a82f82dd5 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -3916,7 +3916,7 @@ internal void Trace(string messageId, string resourceString, params object[] arg ActionPreference pref = ActionPreference.Continue; string message; - if (null == args || 0 == args.Length) + if (args == null || 0 == args.Length) { // Don't format in case the string contains literal curly braces message = resourceString; diff --git a/src/System.Management.Automation/engine/lang/parserutils.cs b/src/System.Management.Automation/engine/lang/parserutils.cs index 953af425442..4e769392ae1 100644 --- a/src/System.Management.Automation/engine/lang/parserutils.cs +++ b/src/System.Management.Automation/engine/lang/parserutils.cs @@ -1769,7 +1769,7 @@ internal static RuntimeException NewInterpreterExceptionWithInnerException(objec try { string message; - if (null == args || 0 == args.Length) + if (args == null || 0 == args.Length) { // Don't format in case the string contains literal curly braces message = resourceString; @@ -1928,7 +1928,7 @@ internal static void Trace(ExecutionContext context, int level, string messageId if (context.PSDebugTraceLevel > level) { string message; - if (null == args || 0 == args.Length) + if (args == null || 0 == args.Length) { // Don't format in case the string contains literal curly braces message = resourceString; diff --git a/src/System.Management.Automation/engine/parser/TypeResolver.cs b/src/System.Management.Automation/engine/parser/TypeResolver.cs index f52d84d6da2..d8f35163eae 100644 --- a/src/System.Management.Automation/engine/parser/TypeResolver.cs +++ b/src/System.Management.Automation/engine/parser/TypeResolver.cs @@ -875,7 +875,7 @@ internal static string FindBuiltinAccelerator(Type type, string expectedKey = nu { // Taking attributes as special case. In this case, we only want to return the // accelerator. - if (null == expectedKey || typeof(Attribute).IsAssignableFrom(type)) + if (expectedKey == null || typeof(Attribute).IsAssignableFrom(type)) { foreach (KeyValuePair entry in builtinTypeAccelerators) { diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index ce5cc877e96..e76c7bb50a5 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -359,7 +359,7 @@ internal int AddCommand(CommandProcessorBase commandProcessor, int readFromComma else { CommandProcessorBase prevcommandProcessor = _commands[readFromCommand - 1] as CommandProcessorBase; - if (null == prevcommandProcessor || null == prevcommandProcessor.CommandRuntime) + if (prevcommandProcessor == null || null == prevcommandProcessor.CommandRuntime) { // "PipelineProcessor.AddCommand(): previous request object == null" throw PSTraceSource.NewInvalidOperationException(); @@ -390,7 +390,7 @@ internal int AddCommand(CommandProcessorBase commandProcessor, int readFromComma for (int i = 0; i < _commands.Count; i++) { prevcommandProcessor = _commands[i]; - if (null == prevcommandProcessor || null == prevcommandProcessor.CommandRuntime) + if (prevcommandProcessor == null || null == prevcommandProcessor.CommandRuntime) { // "PipelineProcessor.AddCommand(): previous request object == null" throw PSTraceSource.NewInvalidOperationException(); @@ -928,7 +928,7 @@ private void Start(bool incomingStream) if (_executionStarted) return; - if (null == _commands || 0 == _commands.Count) + if (_commands == null || 0 == _commands.Count) { throw PSTraceSource.NewInvalidOperationException( PipelineStrings.PipelineExecuteRequiresAtLeastOneCommand); @@ -966,7 +966,7 @@ private void Start(bool incomingStream) // output is not yet claimed SetExternalErrorOutput(); - if (null == ExternalInput && !incomingStream) + if (ExternalInput == null && !incomingStream) { // no upstream cmdlet from the first command firstcommandProcessor.CommandRuntime.IsClosed = true; @@ -1082,7 +1082,7 @@ private void SetupParameterVariables() for (int i = 0; i < _commands.Count; i++) { CommandProcessorBase commandProcessor = _commands[i]; - if (null == commandProcessor || null == commandProcessor.CommandRuntime) + if (commandProcessor == null || null == commandProcessor.CommandRuntime) { // "null command " + i throw PSTraceSource.NewInvalidOperationException(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs index df0373a911d..e6dfb0601b5 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs @@ -1516,7 +1516,7 @@ internal static class ServerOperationHelpers /// The extracted tag converted from a base-64 string. internal static System.Byte[] ExtractEncodedXmlElement(String xmlBuffer, String xmlTag) { - if (null == xmlBuffer || null == xmlTag) + if (xmlBuffer == null || null == xmlTag) return new System.Byte[1]; // the inboundShellInformation is in Xml format as per the SOAP WSMan spec. diff --git a/src/System.Management.Automation/help/CommandHelpProvider.cs b/src/System.Management.Automation/help/CommandHelpProvider.cs index 06006ced73c..33b2bb87b06 100644 --- a/src/System.Management.Automation/help/CommandHelpProvider.cs +++ b/src/System.Management.Automation/help/CommandHelpProvider.cs @@ -248,7 +248,7 @@ private HelpInfo GetHelpInfo(CommandInfo commandInfo, bool reportErrors, bool se } // For scripts, try to retrieve the help from the file specified by .ExternalHelp directive - if (null == result && isScriptCommand) + if (result == null && isScriptCommand) { ScriptBlock sb = null; try @@ -309,7 +309,7 @@ private HelpInfo GetHelpInfo(CommandInfo commandInfo, bool reportErrors, bool se // in the appropriate UI culture subfolder of ModuleBase, and retrieve help // If still not able to get help, try search for a file called -Help.xml // under the ModuleBase and the NestedModule's directory, and retrieve help - if (null == result && !InternalTestHooks.BypassOnlineHelpRetrieval) + if (result == null && !InternalTestHooks.BypassOnlineHelpRetrieval) { // Get the name and ModuleBase directory of the command's module // and the nested module that implements the command @@ -329,7 +329,7 @@ private HelpInfo GetHelpInfo(CommandInfo commandInfo, bool reportErrors, bool se result = GetHelpInfoFromHelpFile(commandInfo, helpFileToFind, searchPaths, reportErrors, out helpFile); } - if (null == result && !String.IsNullOrEmpty(nestedModulePath)) + if (result == null && !String.IsNullOrEmpty(nestedModulePath)) { // Search for -Help.xml under both ModuleBase and NestedModule's directory searchPaths.Add(Path.GetDirectoryName(nestedModulePath)); From 9763bd65725ccc1534fa0b4241d6dc48a890594f Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 16:02:03 +0500 Subject: [PATCH 19/27] Replace 'if \((null) == (\w+.\w+)' -> 'if ($2 == $1' --- .../commands/management/Service.cs | 4 ++-- .../engine/MshCommandRuntime.cs | 4 ++-- .../engine/pipeline.cs | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 9b3dd1052f7..54e117cdd7b 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -846,7 +846,7 @@ internal bool DoStartService(ServiceController serviceController) catch (InvalidOperationException e) { Win32Exception eInner = e.InnerException as Win32Exception; - if (null == eInner + if (eInner == null || NativeMethods.ERROR_SERVICE_ALREADY_RUNNING != eInner.NativeErrorCode) { exception = e; @@ -962,7 +962,7 @@ internal List DoStopService(ServiceController serviceControll { Win32Exception eInner = e.InnerException as Win32Exception; - if (null == eInner + if (eInner == null || NativeMethods.ERROR_SERVICE_NOT_ACTIVE != eInner.NativeErrorCode) { exception = e; diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 6f7179bc31c..965b0787ea1 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2244,7 +2244,7 @@ internal void ThrowIfStopping() /// internal void ThrowIfWriteNotPermitted(bool needsToWriteToPipeline) { - if (null == this.PipelineProcessor + if (this.PipelineProcessor == null || _thisCommand != this.PipelineProcessor._permittedToWrite || needsToWriteToPipeline && !this.PipelineProcessor._permittedToWriteToPipeline || Thread.CurrentThread != this.PipelineProcessor._permittedToWriteThread @@ -2430,7 +2430,7 @@ private void AppendDollarError(object obj) { if (obj is Exception) { - if (null == this.PipelineProcessor || !this.PipelineProcessor.TopLevel) + if (this.PipelineProcessor == null || !this.PipelineProcessor.TopLevel) return; // not outermost scope } diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index e76c7bb50a5..4158f47f7b0 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -935,7 +935,7 @@ private void Start(bool incomingStream) } CommandProcessorBase firstcommandProcessor = _commands[0]; - if (null == firstcommandProcessor + if (firstcommandProcessor == null || null == firstcommandProcessor.CommandRuntime) { throw PSTraceSource.NewInvalidOperationException( @@ -950,7 +950,7 @@ private void Start(bool incomingStream) // add ExternalSuccessOutput to the last command CommandProcessorBase LastCommandProcessor = _commands[_commands.Count - 1]; - if (null == LastCommandProcessor + if (LastCommandProcessor == null || null == LastCommandProcessor.CommandRuntime) { // "PipelineProcessor.Start(): LastCommandProcessor == null" @@ -1125,7 +1125,7 @@ private void Inject(object input, bool enumerate) { // Add any input to the first command. CommandProcessorBase firstcommandProcessor = _commands[0]; - if (null == firstcommandProcessor + if (firstcommandProcessor == null || null == firstcommandProcessor.CommandRuntime) { throw PSTraceSource.NewInvalidOperationException( @@ -1177,7 +1177,7 @@ private Array RetrieveResults() for (int i = 0; i < _commands.Count; i++) { CommandProcessorBase commandProcessor = _commands[i]; - if (null == commandProcessor + if (commandProcessor == null || null == commandProcessor.CommandRuntime) { // "null command or request or ErrorOutputPipe " + i @@ -1200,7 +1200,7 @@ private Array RetrieveResults() return MshCommandRuntime.StaticEmptyArray; CommandProcessorBase LastCommandProcessor = _commands[_commands.Count - 1]; - if (null == LastCommandProcessor + if (LastCommandProcessor == null || null == LastCommandProcessor.CommandRuntime) { // "PipelineProcessor.RetrieveResults(): LastCommandProcessor == null" @@ -1230,7 +1230,7 @@ internal void LinkPipelineSuccessOutput(Pipe pipeToUse) Dbg.Assert(pipeToUse != null, "Caller should verify pipeToUse != null"); CommandProcessorBase LastCommandProcessor = _commands[_commands.Count - 1]; - if (null == LastCommandProcessor + if (LastCommandProcessor == null || null == LastCommandProcessor.CommandRuntime) { // "PipelineProcessor.RetrieveResults(): LastCommandProcessor == null" @@ -1248,7 +1248,7 @@ internal void LinkPipelineErrorOutput(Pipe pipeToUse) for (int i = 0; i < _commands.Count; i++) { CommandProcessorBase commandProcessor = _commands[i]; - if (null == commandProcessor + if (commandProcessor == null || null == commandProcessor.CommandRuntime) { // "null command or request or ErrorOutputPipe " + i From 68efdaf7e37d28ec5d5a37f4039d5409a5b8a384 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 16:03:46 +0500 Subject: [PATCH 20/27] Replace '\b(null) == (\w+)\)' -> '$2 == $1)' --- .../commands/utility/compare-object.cs | 2 +- src/Microsoft.WSMan.Management/ConfigProvider.cs | 4 ++-- .../engine/remoting/fanin/BaseTransportManager.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs index 2cfb236216c..0fdfcb5f20b 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/compare-object.cs @@ -272,7 +272,7 @@ private OrderByPropertyEntry MatchAndRemove( OrderByPropertyEntry match, List list) { - if (match == null || null == list) + if (match == null || list == null) return null; Diagnostics.Assert(_comparer != null, "null comparer"); for (int i = 0; i < list.Count; i++) diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 32be760c83c..5864aa6fb2e 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -3596,7 +3596,7 @@ private void GetChildItemOrNamesForListenerOrCertMapping(XmlDocument xmlResource } else { return; } - if (Objcache == null || null == Keyscache) + if (Objcache == null || Keyscache == null) { return; } @@ -3661,7 +3661,7 @@ private void GetItemListenerOrCertMapping(string path, XmlDocument xmlResource, } else { return; } - if (Objcache == null || null == Keyscache) + if (Objcache == null || Keyscache == null) { return; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs index e6dfb0601b5..909a5cb129d 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs @@ -1516,7 +1516,7 @@ internal static class ServerOperationHelpers /// The extracted tag converted from a base-64 string. internal static System.Byte[] ExtractEncodedXmlElement(String xmlBuffer, String xmlTag) { - if (xmlBuffer == null || null == xmlTag) + if (xmlBuffer == null || xmlTag == null) return new System.Byte[1]; // the inboundShellInformation is in Xml format as per the SOAP WSMan spec. From f188b4037b1481f433f704fb4e6bb81b128f5369 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 16:06:23 +0500 Subject: [PATCH 21/27] Replace '\b(null) == (\w+.\w+)\)' -> '$2 == $1)' --- .../engine/MshCommandRuntime.cs | 16 +++++++-------- .../engine/pipeline.cs | 20 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 965b0787ea1..4fa769428b1 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -174,7 +174,7 @@ public void WriteObject(object sendToPipeline) #else if (UseSecurityContextRun) { - if (PipelineProcessor == null || null == PipelineProcessor.SecurityContext) + if (PipelineProcessor == null || PipelineProcessor.SecurityContext == null) throw PSTraceSource.NewInvalidOperationException(PipelineStrings.WriteNotPermitted); ContextCallback delegateCallback = new ContextCallback(DoWriteObject); @@ -252,7 +252,7 @@ public void WriteObject(object sendToPipeline, bool enumerateCollection) #else if (UseSecurityContextRun) { - if (PipelineProcessor == null || null == PipelineProcessor.SecurityContext) + if (PipelineProcessor == null || PipelineProcessor.SecurityContext == null) throw PSTraceSource.NewInvalidOperationException(PipelineStrings.WriteNotPermitted); ContextCallback delegateCallback = new ContextCallback(DoWriteObjects); @@ -393,7 +393,7 @@ internal void WriteProgress( throw PSTraceSource.NewArgumentNullException("progressRecord"); } - if (Host == null || null == Host.UI) + if (Host == null || Host.UI == null) { Diagnostics.Assert(false, "No host in CommandBase.WriteProgress()"); throw PSTraceSource.NewInvalidOperationException(); @@ -499,7 +499,7 @@ internal void WriteDebug(DebugRecord record, bool overrideInquire = false) // // If no pipe, write directly to host. // - if (Host == null || null == Host.UI) + if (Host == null || Host.UI == null) { Diagnostics.Assert(false, "No host in CommandBase.WriteDebug()"); throw PSTraceSource.NewInvalidOperationException(); @@ -590,7 +590,7 @@ internal void WriteVerbose(VerboseRecord record, bool overrideInquire = false) // // If no pipe, write directly to host. // - if (Host == null || null == Host.UI) + if (Host == null || Host.UI == null) { Diagnostics.Assert(false, "No host in CommandBase.WriteVerbose()"); throw PSTraceSource.NewInvalidOperationException(); @@ -681,7 +681,7 @@ internal void WriteWarning(WarningRecord record, bool overrideInquire = false) // // If no pipe, write directly to host. // - if (Host == null || null == Host.UI) + if (Host == null || Host.UI == null) { Diagnostics.Assert(false, "No host in CommandBase.WriteWarning()"); throw PSTraceSource.NewInvalidOperationException(); @@ -746,7 +746,7 @@ internal void WriteInformation(InformationRecord record, bool overrideInquire = // // If no pipe, write directly to host. // - if (Host == null || null == Host.UI) + if (Host == null || Host.UI == null) { Diagnostics.Assert(false, "No host in CommandBase.WriteVerbose()"); throw PSTraceSource.NewInvalidOperationException(); @@ -2669,7 +2669,7 @@ internal void WriteError(ErrorRecord errorRecord, bool overrideInquire) #else if (UseSecurityContextRun) { - if (PipelineProcessor == null || null == PipelineProcessor.SecurityContext) + if (PipelineProcessor == null || PipelineProcessor.SecurityContext == null) throw PSTraceSource.NewInvalidOperationException(PipelineStrings.WriteNotPermitted); ContextCallback delegateCallback = new ContextCallback(DoWriteError); diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index 4158f47f7b0..c5920f94a46 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -359,7 +359,7 @@ internal int AddCommand(CommandProcessorBase commandProcessor, int readFromComma else { CommandProcessorBase prevcommandProcessor = _commands[readFromCommand - 1] as CommandProcessorBase; - if (prevcommandProcessor == null || null == prevcommandProcessor.CommandRuntime) + if (prevcommandProcessor == null || prevcommandProcessor.CommandRuntime == null) { // "PipelineProcessor.AddCommand(): previous request object == null" throw PSTraceSource.NewInvalidOperationException(); @@ -390,7 +390,7 @@ internal int AddCommand(CommandProcessorBase commandProcessor, int readFromComma for (int i = 0; i < _commands.Count; i++) { prevcommandProcessor = _commands[i]; - if (prevcommandProcessor == null || null == prevcommandProcessor.CommandRuntime) + if (prevcommandProcessor == null || prevcommandProcessor.CommandRuntime == null) { // "PipelineProcessor.AddCommand(): previous request object == null" throw PSTraceSource.NewInvalidOperationException(); @@ -936,7 +936,7 @@ private void Start(bool incomingStream) CommandProcessorBase firstcommandProcessor = _commands[0]; if (firstcommandProcessor == null - || null == firstcommandProcessor.CommandRuntime) + || firstcommandProcessor.CommandRuntime == null) { throw PSTraceSource.NewInvalidOperationException( PipelineStrings.PipelineExecuteRequiresAtLeastOneCommand); @@ -951,7 +951,7 @@ private void Start(bool incomingStream) // add ExternalSuccessOutput to the last command CommandProcessorBase LastCommandProcessor = _commands[_commands.Count - 1]; if (LastCommandProcessor == null - || null == LastCommandProcessor.CommandRuntime) + || LastCommandProcessor.CommandRuntime == null) { // "PipelineProcessor.Start(): LastCommandProcessor == null" throw PSTraceSource.NewInvalidOperationException(); @@ -1082,7 +1082,7 @@ private void SetupParameterVariables() for (int i = 0; i < _commands.Count; i++) { CommandProcessorBase commandProcessor = _commands[i]; - if (commandProcessor == null || null == commandProcessor.CommandRuntime) + if (commandProcessor == null || commandProcessor.CommandRuntime == null) { // "null command " + i throw PSTraceSource.NewInvalidOperationException(); @@ -1126,7 +1126,7 @@ private void Inject(object input, bool enumerate) // Add any input to the first command. CommandProcessorBase firstcommandProcessor = _commands[0]; if (firstcommandProcessor == null - || null == firstcommandProcessor.CommandRuntime) + || firstcommandProcessor.CommandRuntime == null) { throw PSTraceSource.NewInvalidOperationException( PipelineStrings.PipelineExecuteRequiresAtLeastOneCommand); @@ -1178,7 +1178,7 @@ private Array RetrieveResults() { CommandProcessorBase commandProcessor = _commands[i]; if (commandProcessor == null - || null == commandProcessor.CommandRuntime) + || commandProcessor.CommandRuntime == null) { // "null command or request or ErrorOutputPipe " + i throw PSTraceSource.NewInvalidOperationException(); @@ -1201,7 +1201,7 @@ private Array RetrieveResults() CommandProcessorBase LastCommandProcessor = _commands[_commands.Count - 1]; if (LastCommandProcessor == null - || null == LastCommandProcessor.CommandRuntime) + || LastCommandProcessor.CommandRuntime == null) { // "PipelineProcessor.RetrieveResults(): LastCommandProcessor == null" throw PSTraceSource.NewInvalidOperationException(); @@ -1231,7 +1231,7 @@ internal void LinkPipelineSuccessOutput(Pipe pipeToUse) CommandProcessorBase LastCommandProcessor = _commands[_commands.Count - 1]; if (LastCommandProcessor == null - || null == LastCommandProcessor.CommandRuntime) + || LastCommandProcessor.CommandRuntime == null) { // "PipelineProcessor.RetrieveResults(): LastCommandProcessor == null" throw PSTraceSource.NewInvalidOperationException(); @@ -1249,7 +1249,7 @@ internal void LinkPipelineErrorOutput(Pipe pipeToUse) { CommandProcessorBase commandProcessor = _commands[i]; if (commandProcessor == null - || null == commandProcessor.CommandRuntime) + || commandProcessor.CommandRuntime == null) { // "null command or request or ErrorOutputPipe " + i throw PSTraceSource.NewInvalidOperationException(); From 6d95c4bb3ada994f6602f32646a398dee035de0a Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 16:12:47 +0500 Subject: [PATCH 22/27] Replace '\((null) == (\w+.\w+\["\w+"].\w+)' -> '($2 == $1' --- src/System.Management.Automation/help/BaseCommandHelpInfo.cs | 2 +- src/System.Management.Automation/help/ProviderHelpInfo.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs index a1ffa5f2113..5967a14e904 100644 --- a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs @@ -466,7 +466,7 @@ internal string DetailedDescription PSObject descriptionObject = PSObject.AsPSObject(descriptionItem); if ((descriptionObject == null) || (null == descriptionObject.Properties["Text"]) || - (null == descriptionObject.Properties["Text"].Value)) + (descriptionObject.Properties["Text"].Value == null)) { continue; } diff --git a/src/System.Management.Automation/help/ProviderHelpInfo.cs b/src/System.Management.Automation/help/ProviderHelpInfo.cs index 7c0a99de23d..564dcaed292 100644 --- a/src/System.Management.Automation/help/ProviderHelpInfo.cs +++ b/src/System.Management.Automation/help/ProviderHelpInfo.cs @@ -112,7 +112,7 @@ internal string DetailedDescription PSObject descriptionObject = PSObject.AsPSObject(descriptionItem); if ((descriptionObject == null) || (null == descriptionObject.Properties["Text"]) || - (null == descriptionObject.Properties["Text"].Value)) + (descriptionObject.Properties["Text"].Value == null)) { continue; } From 98b27a217cf522c924f796904622d425f37b3655 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 16:14:31 +0500 Subject: [PATCH 23/27] Replace '\((null) == (\w+.\w+\["\w+"])' -> '($2 == $1' --- src/Microsoft.WSMan.Management/ConfigProvider.cs | 2 +- src/System.Management.Automation/help/BaseCommandHelpInfo.cs | 2 +- src/System.Management.Automation/help/ProviderHelpInfo.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 5864aa6fb2e..1feccf5b6c6 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -2127,7 +2127,7 @@ private void NewItemPluginOrPluginChild(object sessionobj, string path, string h } // Construct the Uri from Resource_XXXX resource dir. PSObject resourceDirProperties = GetItemValue(strPathChk); - if ((resourceDirProperties == null) || (null == resourceDirProperties.Properties["ResourceUri"])) + if ((resourceDirProperties == null) || (resourceDirProperties.Properties["ResourceUri"] == null)) { string message = helper.FormatResourceMsgFromResourcetext("ResourceURIMissingInResourceDir", "ResourceUri", strPathChk); diff --git a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs index 5967a14e904..6d5ca18449b 100644 --- a/src/System.Management.Automation/help/BaseCommandHelpInfo.cs +++ b/src/System.Management.Automation/help/BaseCommandHelpInfo.cs @@ -465,7 +465,7 @@ internal string DetailedDescription PSObject descriptionObject = PSObject.AsPSObject(descriptionItem); if ((descriptionObject == null) || - (null == descriptionObject.Properties["Text"]) || + (descriptionObject.Properties["Text"] == null) || (descriptionObject.Properties["Text"].Value == null)) { continue; diff --git a/src/System.Management.Automation/help/ProviderHelpInfo.cs b/src/System.Management.Automation/help/ProviderHelpInfo.cs index 564dcaed292..17b161db4db 100644 --- a/src/System.Management.Automation/help/ProviderHelpInfo.cs +++ b/src/System.Management.Automation/help/ProviderHelpInfo.cs @@ -111,7 +111,7 @@ internal string DetailedDescription { PSObject descriptionObject = PSObject.AsPSObject(descriptionItem); if ((descriptionObject == null) || - (null == descriptionObject.Properties["Text"]) || + (descriptionObject.Properties["Text"] == null) || (descriptionObject.Properties["Text"].Value == null)) { continue; From eab49d4cd6950c1d238ee41de5225aabaae27ae1 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 28 May 2018 18:42:52 +0500 Subject: [PATCH 24/27] [Feature] From e9cbab661555e36d3d1b4cbee3b9a48acef4770c Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 25 Jun 2018 13:07:48 -0700 Subject: [PATCH 25/27] Remove the awkward wrong code. --- .../LocalAccounts/LocalGroup.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs index 10dbe2ecf37..51c9bd38c2c 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs +++ b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalGroup.cs @@ -70,10 +70,6 @@ public override string ToString() /// public LocalGroup Clone() { - if (this == null) - { - throw new NullReferenceException(); - } return new LocalGroup(this); } #endregion Public Methods From 7506a033f61a4554a7cb3d97b702010e0f475c49 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 25 Jun 2018 13:12:32 -0700 Subject: [PATCH 26/27] Remove the wrong code. --- .../LocalAccounts/LocalUser.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs index 3addf87c11f..35a0059057b 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs +++ b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/LocalUser.cs @@ -135,10 +135,6 @@ public override string ToString() /// public LocalUser Clone() { - if (this == null) - { - throw new NullReferenceException(); - } return new LocalUser(this); } #endregion Public Methods From 052c215200e004b5314eccf8f8082f1d77cdca58 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 25 Jun 2018 13:28:18 -0700 Subject: [PATCH 27/27] Update one more similar case. --- src/System.Management.Automation/engine/debugger/debugger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index a78e2e6e4e0..a3be0cdebbf 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -3916,7 +3916,7 @@ internal void Trace(string messageId, string resourceString, params object[] arg ActionPreference pref = ActionPreference.Continue; string message; - if (args == null || 0 == args.Length) + if (args == null || args.Length == 0) { // Don't format in case the string contains literal curly braces message = resourceString;