From ba525f068bd1a1979d330e1c54f12f4ec9d3021f Mon Sep 17 00:00:00 2001
From: CleanCodeDeveloper
<16760760+CleanCodeDeveloper@users.noreply.github.com>
Date: Thu, 10 Mar 2022 11:37:14 +0100
Subject: [PATCH] [PTRun][VSCodeWorkspaces] Enable analyzer and fix warning
(#16897)
* [Community.PowerToys.Run.Plugin.VSCodeWorkspaces] Enable analyzer and fix warnings
* fix CA1824: Mark assemblies with NeutralResourcesLanguageAttribute
---
...munity.PowerToys.Run.Plugin.VSCodeWorkspaces.csproj | 3 +++
.../Main.cs | 4 ++--
.../SystemPath.cs | 3 ++-
.../VSCodeHelper/VSCodeInstances.cs | 10 +++++-----
4 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Community.PowerToys.Run.Plugin.VSCodeWorkspaces.csproj b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Community.PowerToys.Run.Plugin.VSCodeWorkspaces.csproj
index 34c06b79ba..8f87adac14 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Community.PowerToys.Run.Plugin.VSCodeWorkspaces.csproj
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Community.PowerToys.Run.Plugin.VSCodeWorkspaces.csproj
@@ -12,6 +12,9 @@
false
false
x64
+ true
+ Recommended
+ en-US
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs
index 6f5ae4902e..3627bbd07a 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/Main.cs
@@ -149,8 +149,8 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
}
// intersect the title with the query
- var intersection = Convert.ToInt32(x.Title.ToLowerInvariant().Intersect(query.Search.ToLowerInvariant()).Count() * query.Search.Count());
- var differenceWithQuery = Convert.ToInt32((x.Title.Count() - intersection) * query.Search.Count() * 0.7);
+ var intersection = Convert.ToInt32(x.Title.ToLowerInvariant().Intersect(query.Search.ToLowerInvariant()).Count() * query.Search.Length);
+ var differenceWithQuery = Convert.ToInt32((x.Title.Length - intersection) * query.Search.Length * 0.7);
x.Score = x.Score - differenceWithQuery + intersection;
// if is a remote machine give it 12 extra points
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SystemPath.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SystemPath.cs
index 3a2f1c6acc..938c9cb0e8 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SystemPath.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SystemPath.cs
@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Globalization;
using System.Text.RegularExpressions;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
@@ -15,7 +16,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
if (WindowsPath.IsMatch(path))
{
string windowsPath = path.Replace("/", "\\");
- return $"{windowsPath[0]}".ToUpper() + windowsPath.Remove(0, 1);
+ return $"{windowsPath[0]}".ToUpperInvariant() + windowsPath.Remove(0, 1);
}
else
{
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs
index 6001a6a825..0c8a235d34 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstances.cs
@@ -75,7 +75,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
{
var files = Directory.GetFiles(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)
{
@@ -87,22 +87,22 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
ExecutablePath = file,
};
- if (file.EndsWith("code"))
+ if (file.EndsWith("code", StringComparison.OrdinalIgnoreCase))
{
version = "Code";
instance.VSCodeVersion = VSCodeVersion.Stable;
}
- else if (file.EndsWith("code-insiders"))
+ else if (file.EndsWith("code-insiders", StringComparison.OrdinalIgnoreCase))
{
version = "Code - Insiders";
instance.VSCodeVersion = VSCodeVersion.Insiders;
}
- else if (file.EndsWith("code-exploration"))
+ else if (file.EndsWith("code-exploration", StringComparison.OrdinalIgnoreCase))
{
version = "Code - Exploration";
instance.VSCodeVersion = VSCodeVersion.Exploration;
}
- else if (file.EndsWith("VSCodium"))
+ else if (file.EndsWith("VSCodium", StringComparison.OrdinalIgnoreCase))
{
version = "VSCodium";
instance.VSCodeVersion = VSCodeVersion.Stable; // ?