diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index 44d7a373395..d4155c60c82 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -334,7 +334,7 @@ internal bool LoadUsingModulePath(PSModuleInfo parentModule, bool found, IEnumer foreach (string folder in Directory.EnumerateDirectories(path)) { string moduleName = Path.GetFileName(folder); - if (string.Compare(moduleName, fileBaseName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(moduleName, fileBaseName, StringComparison.OrdinalIgnoreCase)) { fileBaseName = moduleName; #endif @@ -3531,7 +3531,7 @@ private static void PropagateExportedTypesFromNestedModulesToRootModuleScope(Imp if (nestedModule != null) { var exportedTypes = nestedModule.GetExportedTypeDefinitions(); - if (exportedTypes != null && exportedTypes.Count != 0) + if (exportedTypes != null && exportedTypes.Count > 0) { foreach (var t in exportedTypes) { diff --git a/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs b/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs index 1e32436e6da..81a27f61279 100644 --- a/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs +++ b/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs @@ -217,7 +217,7 @@ private static void RegisterSubsystem(SubsystemInfo subsystemInfo, ISubsystem pr nameof(proxy)); } - if (subsystemInfo.RequiredCmdlets.Any() || subsystemInfo.RequiredFunctions.Any()) + if (subsystemInfo.RequiredCmdlets.Count > 0 || subsystemInfo.RequiredFunctions.Count > 0) { // Process 'proxy.CmdletImplementationAssembly' and 'proxy.FunctionsToDefine' // Functions are added to global scope. @@ -265,7 +265,7 @@ public static void UnregisterSubsystem(SubsystemKind kind, Guid id) private static void UnregisterSubsystem(SubsystemInfo subsystemInfo, Guid id) { - if (subsystemInfo.RequiredCmdlets.Any() || subsystemInfo.RequiredFunctions.Any()) + if (subsystemInfo.RequiredCmdlets.Count > 0 || subsystemInfo.RequiredFunctions.Count > 0) { throw new NotSupportedException("NotSupported yet: unregister subsystem that introduced new cmdlets/functions."); } diff --git a/src/System.Management.Automation/engine/parser/AstVisitor.cs b/src/System.Management.Automation/engine/parser/AstVisitor.cs index a20ea4a5ce8..45cdb438008 100644 --- a/src/System.Management.Automation/engine/parser/AstVisitor.cs +++ b/src/System.Management.Automation/engine/parser/AstVisitor.cs @@ -425,7 +425,7 @@ internal static bool Contains(Ast ast, Func predicate, bool searchNes var searcher = new AstSearcher(predicate, stopOnFirst: true, searchNestedScriptBlocks: searchNestedScriptBlocks); ast.InternalVisit(searcher); - return searcher.Results.Any(); + return searcher.Results.Count > 0; } internal static bool IsUsingDollarInput(Ast ast) diff --git a/src/System.Management.Automation/utils/EncodingUtils.cs b/src/System.Management.Automation/utils/EncodingUtils.cs index 33ff3c7f598..e9802488006 100644 --- a/src/System.Management.Automation/utils/EncodingUtils.cs +++ b/src/System.Management.Automation/utils/EncodingUtils.cs @@ -64,7 +64,7 @@ internal static Encoding Convert(Cmdlet cmdlet, string encoding) if (encodingMap.TryGetValue(encoding, out foundEncoding)) { // Write a warning if using utf7 as it is obsolete in .NET5 - if (string.Compare(encoding, Utf7, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(encoding, Utf7, StringComparison.OrdinalIgnoreCase)) { cmdlet.WriteWarning(PathUtilsStrings.Utf7EncodingObsolete); }