From ae2667b1887b61f913cca6c78eb27016e63634bd Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sat, 23 Jun 2018 10:20:29 -0400 Subject: [PATCH] Change string.Compare(...) == 0 occurrences to string.Equals(...) (dotnet/coreclr#18616) Commit migrated from https://github.com/dotnet/coreclr/commit/e1a6bdb037e1a79ad7009fb81eecfd6bd1bbfe65 --- .../src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs | 2 +- .../src/System/Reflection/Emit/ModuleBuilder.cs | 2 +- .../System.Private.CoreLib/src/System/Resources/ResourceManager.cs | 4 ++-- .../src/System/Diagnostics/Tracing/EventSource.cs | 2 +- src/libraries/System.Private.CoreLib/src/System/StringComparer.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs index 3e4da5c..e6351a3 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs @@ -181,7 +181,7 @@ namespace System.Diagnostics string ns = t.Namespace; if (ns == null) break; - if (string.Compare(ns, PackageName, StringComparison.Ordinal) != 0) + if (!string.Equals(ns, PackageName, StringComparison.Ordinal)) break; } iRetVal++; diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs index 62c6f26..bb61fe0 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs @@ -219,7 +219,7 @@ namespace System.Reflection.Emit { foreach (string name in m_TypeBuilderDict.Keys) { - if (string.Compare(name, strTypeName, (StringComparison.OrdinalIgnoreCase)) == 0) + if (string.Equals(name, strTypeName, StringComparison.OrdinalIgnoreCase)) return m_TypeBuilderDict[name]; } } diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs index c7548b6..6294f09 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs @@ -680,11 +680,11 @@ namespace System.Resources // case insensitive AssemblyName an1 = new AssemblyName(asmTypeName1.Substring(comma)); - if (string.Compare(an1.Name, asmName2.Name, StringComparison.OrdinalIgnoreCase) != 0) + if (!string.Equals(an1.Name, asmName2.Name, StringComparison.OrdinalIgnoreCase)) return false; // to match IsMscorlib() in VM - if (string.Compare(an1.Name, System.CoreLib.Name, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(an1.Name, System.CoreLib.Name, StringComparison.OrdinalIgnoreCase)) return true; diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index 59fb59e..72f2bde 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -3254,7 +3254,7 @@ namespace System.Diagnostics.Tracing { // If the first parameter is (case insensitive) 'relatedActivityId' then skip it. if (args.Length > 0 && args[0].ParameterType == typeof(Guid) && - string.Compare(args[0].Name, "relatedActivityId", StringComparison.OrdinalIgnoreCase) == 0) + string.Equals(args[0].Name, "relatedActivityId", StringComparison.OrdinalIgnoreCase)) { var newargs = new ParameterInfo[args.Length - 1]; Array.Copy(args, 1, newargs, 0, args.Length - 1); diff --git a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs index cb2d32f..9a209a4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs @@ -293,7 +293,7 @@ namespace System { return false; } - return (string.Compare(x, y, StringComparison.OrdinalIgnoreCase) == 0); + return string.Equals(x, y, StringComparison.OrdinalIgnoreCase); } return x.Equals(y); } -- 2.7.4