From 66619ca0593a01629336108f1cb3dc2cdd8ff5b6 Mon Sep 17 00:00:00 2001 From: CleanCodeDeveloper <16760760+CleanCodeDeveloper@users.noreply.github.com> Date: Mon, 14 Mar 2022 16:46:34 +0100 Subject: [PATCH] [Plugin.Program] Enable analyzer and fix warnings (#17000) --- .../Microsoft.Plugin.Program.csproj | 2 ++ .../Plugins/Microsoft.Plugin.Program/Programs/UWP.cs | 1 + .../Microsoft.Plugin.Program/Programs/UWPApplication.cs | 6 +++--- .../Storage/Win32ProgramRepository.cs | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj index 306b5714da..46f74b7505 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj @@ -14,6 +14,8 @@ false x64 en-US + true + Recommended diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs index 62582e5f9e..3d5cd9258b 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs @@ -188,6 +188,7 @@ namespace Microsoft.Plugin.Program.Programs return FamilyName; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using CurrentCultureIgnoreCase since this is used with FamilyName")] public override bool Equals(object obj) { if (obj is UWP uwp) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWPApplication.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWPApplication.cs index de67536e28..31a7816c7b 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWPApplication.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWPApplication.cs @@ -350,7 +350,7 @@ namespace Microsoft.Plugin.Program.Programs } else { - ProgramLogger.Exception($"Can't load null or empty result pri {sourceFallback} in uwp location {Package.Location}", new NullReferenceException(), GetType(), Package.Location); + ProgramLogger.Exception($"Can't load null or empty result pri {sourceFallback} in uwp location {Package.Location}", new ArgumentNullException(null), GetType(), Package.Location); return string.Empty; } @@ -377,7 +377,7 @@ namespace Microsoft.Plugin.Program.Programs } else { - ProgramLogger.Exception($"Can't load null or empty result pri {source} in uwp location {Package.Location}", new NullReferenceException(), GetType(), Package.Location); + ProgramLogger.Exception($"Can't load null or empty result pri {source} in uwp location {Package.Location}", new ArgumentNullException(null), GetType(), Package.Location); return string.Empty; } @@ -595,7 +595,7 @@ namespace Microsoft.Plugin.Program.Programs bool isLogoUriSet; // Using Ordinal since this is used internally with uri - if (uri.Contains("\\", StringComparison.Ordinal)) + if (uri.Contains('\\', StringComparison.Ordinal)) { path = Path.Combine(Package.Location, uri); } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs index 691a449a71..0fb3fad8df 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs @@ -182,6 +182,7 @@ namespace Microsoft.Plugin.Program.Storage } // When a URL application is deleted, we can no longer get the HashCode directly from the path because the FullPath a Url app is the URL obtained from reading the file + [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using CurrentCultureIgnoreCase since application names could be dependent on currentculture See: https://github.com/microsoft/PowerToys/pull/5847/files#r468245190")] private Win32Program GetAppWithSameNameAndExecutable(string name, string executableName) { foreach (Win32Program app in Items)