[PTRun][VSCodeWorkspaces] Enable analyzer and fix warning (#16897)

* [Community.PowerToys.Run.Plugin.VSCodeWorkspaces] Enable analyzer and fix warnings

* fix CA1824: Mark assemblies with NeutralResourcesLanguageAttribute
This commit is contained in:
CleanCodeDeveloper 2022-03-10 11:37:14 +01:00 committed by GitHub
parent ffdb5d44d7
commit ba525f068b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

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

View File

@ -149,8 +149,8 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
} }
// intersect the title with the query // intersect the title with the query
var intersection = Convert.ToInt32(x.Title.ToLowerInvariant().Intersect(query.Search.ToLowerInvariant()).Count() * query.Search.Count()); var intersection = Convert.ToInt32(x.Title.ToLowerInvariant().Intersect(query.Search.ToLowerInvariant()).Count() * query.Search.Length);
var differenceWithQuery = Convert.ToInt32((x.Title.Count() - intersection) * query.Search.Count() * 0.7); var differenceWithQuery = Convert.ToInt32((x.Title.Length - intersection) * query.Search.Length * 0.7);
x.Score = x.Score - differenceWithQuery + intersection; x.Score = x.Score - differenceWithQuery + intersection;
// if is a remote machine give it 12 extra points // if is a remote machine give it 12 extra points

View File

@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
@ -15,7 +16,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
if (WindowsPath.IsMatch(path)) if (WindowsPath.IsMatch(path))
{ {
string windowsPath = path.Replace("/", "\\"); string windowsPath = path.Replace("/", "\\");
return $"{windowsPath[0]}".ToUpper() + windowsPath.Remove(0, 1); return $"{windowsPath[0]}".ToUpperInvariant() + windowsPath.Remove(0, 1);
} }
else else
{ {

View File

@ -75,7 +75,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
{ {
var files = Directory.GetFiles(path); var files = Directory.GetFiles(path);
var iconPath = Path.GetDirectoryName(path); var iconPath = Path.GetDirectoryName(path);
files = files.Where(x => (x.Contains("code") || x.Contains("VSCodium")) && !x.EndsWith(".cmd")).ToArray(); files = files.Where(x => (x.Contains("code") || x.Contains("VSCodium")) && !x.EndsWith(".cmd", StringComparison.OrdinalIgnoreCase)).ToArray();
if (files.Length > 0) if (files.Length > 0)
{ {
@ -87,22 +87,22 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
ExecutablePath = file, ExecutablePath = file,
}; };
if (file.EndsWith("code")) if (file.EndsWith("code", StringComparison.OrdinalIgnoreCase))
{ {
version = "Code"; version = "Code";
instance.VSCodeVersion = VSCodeVersion.Stable; instance.VSCodeVersion = VSCodeVersion.Stable;
} }
else if (file.EndsWith("code-insiders")) else if (file.EndsWith("code-insiders", StringComparison.OrdinalIgnoreCase))
{ {
version = "Code - Insiders"; version = "Code - Insiders";
instance.VSCodeVersion = VSCodeVersion.Insiders; instance.VSCodeVersion = VSCodeVersion.Insiders;
} }
else if (file.EndsWith("code-exploration")) else if (file.EndsWith("code-exploration", StringComparison.OrdinalIgnoreCase))
{ {
version = "Code - Exploration"; version = "Code - Exploration";
instance.VSCodeVersion = VSCodeVersion.Exploration; instance.VSCodeVersion = VSCodeVersion.Exploration;
} }
else if (file.EndsWith("VSCodium")) else if (file.EndsWith("VSCodium", StringComparison.OrdinalIgnoreCase))
{ {
version = "VSCodium"; version = "VSCodium";
instance.VSCodeVersion = VSCodeVersion.Stable; // ? instance.VSCodeVersion = VSCodeVersion.Stable; // ?