From 9aba45f18c6cd4e9faf1abee1aaa6d3aac4fbe4e Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 6 Jul 2020 17:51:24 +0100 Subject: [PATCH] Use null check with pattern-matching instead of object.ReferenceEquals (#13065) --- src/ResGen/Program.cs | 2 +- .../engine/Modules/PSModuleInfo.cs | 2 +- src/System.Management.Automation/engine/MshMemberInfo.cs | 2 +- src/System.Management.Automation/engine/PSVersionInfo.cs | 4 ++-- .../utils/tracing/SysLogProvider.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ResGen/Program.cs b/src/ResGen/Program.cs index 6e25d9239e..3359226a99 100644 --- a/src/ResGen/Program.cs +++ b/src/ResGen/Program.cs @@ -147,7 +147,7 @@ using System.Reflection; [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] {4} static global::System.Resources.ResourceManager ResourceManager {{ get {{ - if (object.ReferenceEquals(resourceMan, null)) {{ + if (resourceMan is null) {{ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(""{1}.resources.{5}{3}"", typeof({0}).Assembly); resourceMan = temp; }} diff --git a/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs b/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs index 15e2495e4f..033382a565 100644 --- a/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs +++ b/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs @@ -1606,7 +1606,7 @@ namespace System.Management.Automation if (object.ReferenceEquals(x, y)) return true; // Check whether any of the compared objects is null. - if (object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null)) + if (x is null || y is null) return false; bool result = string.Equals(x.Name, y.Name, StringComparison.OrdinalIgnoreCase) && diff --git a/src/System.Management.Automation/engine/MshMemberInfo.cs b/src/System.Management.Automation/engine/MshMemberInfo.cs index f60aa8f6f3..451048e201 100644 --- a/src/System.Management.Automation/engine/MshMemberInfo.cs +++ b/src/System.Management.Automation/engine/MshMemberInfo.cs @@ -1946,7 +1946,7 @@ namespace System.Management.Automation public bool Equals(PSMethodInvocationConstraints other) { - if (ReferenceEquals(null, other)) + if (other is null) { return false; } diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 1378f0f0c5..09f9829c28 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -907,9 +907,9 @@ namespace System.Management.Automation /// public static bool operator ==(SemanticVersion v1, SemanticVersion v2) { - if (object.ReferenceEquals(v1, null)) + if (v1 is null) { - return object.ReferenceEquals(v2, null); + return v2 is null; } return v1.Equals(v2); diff --git a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs index f3a899acb7..54bd39a38a 100755 --- a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs +++ b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs @@ -200,7 +200,7 @@ namespace System.Management.Automation.Tracing { get { - if (object.ReferenceEquals(_resourceManager, null)) + if (_resourceManager is null) { _resourceManager = new global::System.Resources.ResourceManager("System.Management.Automation.resources.EventResource", typeof(EventResource).Assembly); }