From 872730ab305d37f67179db8ca778d1cd22984e67 Mon Sep 17 00:00:00 2001 From: Pavel Koneski Date: Mon, 11 Dec 2023 06:12:51 -0800 Subject: [PATCH] Avoid ToLoverInvariant in string comparisons (CA1862) (#279) * Avoid ToLoverInvariant in string comparisons (CA1862) * Use OdrinalIgnoreCase iso InvariantCultureIgnoreCase --- Src/Microsoft.Dynamic/DebugOptions.cs | 2 +- Src/Microsoft.Dynamic/Generation/AssemblyGen.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Microsoft.Dynamic/DebugOptions.cs b/Src/Microsoft.Dynamic/DebugOptions.cs index a0c8b32c..bbfda4d6 100644 --- a/Src/Microsoft.Dynamic/DebugOptions.cs +++ b/Src/Microsoft.Dynamic/DebugOptions.cs @@ -19,7 +19,7 @@ internal static class DebugOptions { private static bool ReadOption(string name) { string envVar = ReadString(name); - return envVar != null && envVar.ToLowerInvariant() == "true"; + return "true".Equals(envVar, StringComparison.OrdinalIgnoreCase); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "name")] diff --git a/Src/Microsoft.Dynamic/Generation/AssemblyGen.cs b/Src/Microsoft.Dynamic/Generation/AssemblyGen.cs index 694fe6f1..1055f3b6 100644 --- a/Src/Microsoft.Dynamic/Generation/AssemblyGen.cs +++ b/Src/Microsoft.Dynamic/Generation/AssemblyGen.cs @@ -283,7 +283,8 @@ private static void CopyDirectory(string to, string from) { string toFile = Path.Combine(to, fi.Name); FileInfo toInfo = new FileInfo(toFile); - if (fi.Extension.ToLowerInvariant() == ".dll" || fi.Extension.ToLowerInvariant() == ".exe") { + if (fi.Extension.Equals(".dll", StringComparison.OrdinalIgnoreCase) + || fi.Extension.Equals(".exe", StringComparison.OrdinalIgnoreCase)) { if (!File.Exists(toFile) || toInfo.CreationTime != fi.CreationTime) { try { File.Copy(filename, toFile, true);