[Plugin.Program] Enable analyzer and fix warnings (#17000)

This commit is contained in:
CleanCodeDeveloper 2022-03-14 16:46:34 +01:00 committed by GitHub
parent 79b2cdca7b
commit 66619ca059
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 3 deletions

View File

@ -14,6 +14,8 @@
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Platforms>x64</Platforms>
<NeutralLanguage>en-US</NeutralLanguage>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

View File

@ -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)

View File

@ -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);
}

View File

@ -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)