diff --git a/src/modules/colorPicker/UnitTest-ColorPickerUI/Helpers/ColorConverterTest.cs b/src/modules/colorPicker/UnitTest-ColorPickerUI/Helpers/ColorConverterTest.cs
index 4f3e729eca..10284a3f67 100644
--- a/src/modules/colorPicker/UnitTest-ColorPickerUI/Helpers/ColorConverterTest.cs
+++ b/src/modules/colorPicker/UnitTest-ColorPickerUI/Helpers/ColorConverterTest.cs
@@ -190,7 +190,7 @@ namespace Microsoft.ColorPicker.UnitTests
}
Assert.IsTrue(hexValue.Length >= 6);
-
+
var red = int.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
var green = int.Parse(hexValue.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
var blue = int.Parse(hexValue.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
@@ -287,7 +287,7 @@ namespace Microsoft.ColorPicker.UnitTests
Assert.IsTrue(hexValue.Length >= 6);
- var red = int.Parse( hexValue.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
+ var red = int.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
var green = int.Parse(hexValue.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
var blue = int.Parse(hexValue.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
@@ -322,6 +322,7 @@ namespace Microsoft.ColorPicker.UnitTests
_ = ColorHelper.ConvertToCMYKColor(color);
}
#pragma warning disable CA1031 // Do not catch general exception types
+
// intentionally trying to catch
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
diff --git a/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj b/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj
index d95394e7e8..3b353c7f80 100644
--- a/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj
+++ b/src/modules/colorPicker/UnitTest-ColorPickerUI/UnitTest-ColorPickerUI.csproj
@@ -35,6 +35,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
@@ -42,4 +46,12 @@
+
+
+ GlobalSuppressions.cs
+
+
+ StyleCop.json
+
+
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs
index 0d6dfb4274..cf09485649 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/InputInterpreterTests.cs
@@ -1,3 +1,7 @@
+// Copyright (c) Microsoft Corporation
+// 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 NUnit.Framework;
using Wox.Plugin;
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs
index aef9210a04..fb18180569 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter.UnitTest/UnitHandlerTests.cs
@@ -1,4 +1,7 @@
-using System.Globalization;
+// Copyright (c) Microsoft Corporation
+// 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.Linq;
using NUnit.Framework;
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Community.PowerToys.Run.Plugin.UnitConverter.csproj b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Community.PowerToys.Run.Plugin.UnitConverter.csproj
index fe32784f51..eee4deed87 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Community.PowerToys.Run.Plugin.UnitConverter.csproj
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Community.PowerToys.Run.Plugin.UnitConverter.csproj
@@ -26,7 +26,7 @@
MinimumRecommendedRules.ruleset4false
- false
+ true
@@ -39,6 +39,7 @@
promptMinimumRecommendedRules.ruleset4
+ true
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs
index b44aa8022b..48a7170e62 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs
@@ -1,5 +1,7 @@
-using System;
-using System.Collections.Generic;
+// Copyright (c) Microsoft Corporation
+// 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.Linq;
using System.Text.RegularExpressions;
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Main.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Main.cs
index 9d6478a10d..0b079a0bb2 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Main.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Main.cs
@@ -1,13 +1,15 @@
-using System;
+// Copyright (c) Microsoft Corporation
+// 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;
using System.Collections.Generic;
-using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
using System.Windows.Input;
using ManagedCommon;
-using UnitsNet;
using Wox.Plugin;
namespace Community.PowerToys.Run.Plugin.UnitConverter
@@ -142,7 +144,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
return Properties.Resources.plugin_description;
}
- private void OnThemeChanged(Theme _, Theme newTheme)
+ private void OnThemeChanged(Theme currentTheme, Theme newTheme)
{
UpdateIconPath(newTheme);
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitConversionResult.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitConversionResult.cs
index 7a3eb75283..75de4bdb6e 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitConversionResult.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitConversionResult.cs
@@ -1,4 +1,8 @@
-using UnitsNet;
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using UnitsNet;
namespace Community.PowerToys.Run.Plugin.UnitConverter
{
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitHandler.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitHandler.cs
index a084205dcc..06419590b1 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitHandler.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitHandler.cs
@@ -1,4 +1,8 @@
-using System;
+// Copyright (c) Microsoft Corporation
+// 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;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
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 ed2b977245..692fa2e53a 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
@@ -25,6 +25,7 @@
MinimumRecommendedRules.ruleset4false
+ true
@@ -37,6 +38,7 @@
promptMinimumRecommendedRules.ruleset4
+ true
@@ -50,10 +52,22 @@
+
+
+ GlobalSuppressions.cs
+
+
+ StyleCop.json
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
-
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 fd80a2ef71..ecfdad00fa 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
@@ -1,4 +1,8 @@
-using System;
+// Copyright (c) Microsoft Corporation
+// 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
@@ -13,7 +17,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
{
public class Main : IPlugin, IPluginI18n
{
- public PluginInitContext _context { get; private set; }
+ private PluginInitContext _context;
public string Name => GetTranslatedPluginTitle();
@@ -24,9 +28,9 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
VSCodeInstances.LoadVSCodeInstances();
}
- public readonly VSCodeWorkspacesApi _workspacesApi = new VSCodeWorkspacesApi();
+ private readonly VSCodeWorkspacesApi _workspacesApi = new VSCodeWorkspacesApi();
- public readonly VSCodeRemoteMachinesApi _machinesApi = new VSCodeRemoteMachinesApi();
+ private readonly VSCodeRemoteMachinesApi _machinesApi = new VSCodeRemoteMachinesApi();
public List Query(Query query)
{
@@ -49,12 +53,12 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
title += $" - {(a.ExtraInfo != null ? $"{a.ExtraInfo} ({typeWorkspace})" : typeWorkspace)}";
}
- var tooltip = new ToolTipData(title, $"{Resources.Workspace}{(a.TypeWorkspace != TypeWorkspace.Local ? $" {Resources.In} {typeWorkspace}" : "")}: {SystemPath.RealPath(a.RelativePath)}");
+ var tooltip = new ToolTipData(title, $"{Resources.Workspace}{(a.TypeWorkspace != TypeWorkspace.Local ? $" {Resources.In} {typeWorkspace}" : string.Empty)}: {SystemPath.RealPath(a.RelativePath)}");
results.Add(new Result
{
Title = title,
- SubTitle = $"{Resources.Workspace}{(a.TypeWorkspace != TypeWorkspace.Local ? $" {Resources.In} {typeWorkspace}" : "")}: {SystemPath.RealPath(a.RelativePath)}",
+ SubTitle = $"{Resources.Workspace}{(a.TypeWorkspace != TypeWorkspace.Local ? $" {Resources.In} {typeWorkspace}" : string.Empty)}: {SystemPath.RealPath(a.RelativePath)}",
Icon = a.VSCodeInstance.WorkspaceIcon,
ToolTipData = tooltip,
Action = c =>
@@ -67,7 +71,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
FileName = a.VSCodeInstance.ExecutablePath,
UseShellExecute = true,
Arguments = $"--folder-uri {a.Path}",
- WindowStyle = ProcessWindowStyle.Hidden
+ WindowStyle = ProcessWindowStyle.Hidden,
};
Process.Start(process);
@@ -80,13 +84,13 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
_context.API.ShowMsg(name, msg, string.Empty);
hide = false;
}
+
return hide;
},
ContextData = a,
});
});
-
// Search opened remote machines
_machinesApi.Machines.ForEach(a =>
{
@@ -128,6 +132,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
_context.API.ShowMsg(name, msg, string.Empty);
hide = false;
}
+
return hide;
},
ContextData = a,
@@ -147,20 +152,20 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
x.Score = 100;
}
- //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 differenceWithQuery = Convert.ToInt32((x.Title.Count() - intersection) * query.Search.Count() * 0.7);
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
if (x.ContextData is VSCodeRemoteMachine)
{
- x.Score = Convert.ToInt32(x.Score + intersection * 2);
+ x.Score = Convert.ToInt32(x.Score + (intersection * 2));
}
});
results = results.OrderByDescending(x => x.Score).ToList();
- if (query.Search == string.Empty || query.Search.Replace(" ", "") == string.Empty)
+ if (query.Search == string.Empty || query.Search.Replace(" ", string.Empty) == string.Empty)
{
results = results.OrderBy(x => x.Title).ToList();
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachine.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachine.cs
index db88fe1419..c4f3c13a9c 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachine.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachine.cs
@@ -1,4 +1,8 @@
-using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper
{
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachinesApi.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachinesApi.cs
index 5571c077d7..3c35220dde 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachinesApi.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RemoteMachinesHelper/VSCodeRemoteMachinesApi.cs
@@ -1,16 +1,22 @@
-using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser;
-using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
-using Newtonsoft.Json;
+// Copyright (c) Microsoft Corporation
+// 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;
using System.Collections.Generic;
using System.IO;
+using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser;
+using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
+using Newtonsoft.Json;
using Wox.Plugin.Logger;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper
{
public class VSCodeRemoteMachinesApi
{
- public VSCodeRemoteMachinesApi() { }
+ public VSCodeRemoteMachinesApi()
+ {
+ }
public List Machines
{
@@ -18,7 +24,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper
{
var results = new List();
- foreach (var vscodeInstance in VSCodeInstances.instances)
+ foreach (var vscodeInstance in VSCodeInstances.Instances)
{
// settings.json contains path of ssh_config
var vscode_settings = Path.Combine(vscodeInstance.AppData, "User\\settings.json");
@@ -40,8 +46,8 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper
var machine = new VSCodeRemoteMachine();
machine.Host = h.Host;
machine.VSCodeInstance = vscodeInstance;
- machine.HostName = h.HostName != null ? h.HostName : String.Empty;
- machine.User = h.User != null ? h.User : String.Empty;
+ machine.HostName = h.HostName != null ? h.HostName : string.Empty;
+ machine.User = h.User != null ? h.User : string.Empty;
results.Add(machine);
}
@@ -57,8 +63,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper
}
return results;
-
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/Parser.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/SshConfig.cs
similarity index 65%
rename from src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/Parser.cs
rename to src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/SshConfig.cs
index f94b7747c0..ef113c0484 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/Parser.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/SshConfig.cs
@@ -1,4 +1,8 @@
-using System.Collections.Generic;
+// Copyright (c) Microsoft Corporation
+// 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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@@ -7,8 +11,8 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
{
public class SshConfig
{
- private static readonly Regex SSH_CONFIG = new Regex(@"^(\w[\s\S]*?\w)$(?=(?:\s+^\w|\z))", RegexOptions.Multiline);
- private static readonly Regex KEY_VALUE = new Regex(@"(\w+\s\S+)", RegexOptions.Multiline);
+ private static readonly Regex _sshConfig = new Regex(@"^(\w[\s\S]*?\w)$(?=(?:\s+^\w|\z))", RegexOptions.Multiline);
+ private static readonly Regex _keyValue = new Regex(@"(\w+\s\S+)", RegexOptions.Multiline);
public static IEnumerable ParseFile(string path)
{
@@ -17,23 +21,24 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
public static IEnumerable Parse(string str)
{
-
- str = str.Replace("\r", "");
+ str = str.Replace('\r', '\0');
var list = new List();
- foreach (Match match in SSH_CONFIG.Matches(str))
+ foreach (Match match in _sshConfig.Matches(str))
{
var sshHost = new SshHost();
string content = match.Groups.Values.ToList()[0].Value;
- foreach (Match match1 in KEY_VALUE.Matches(content))
+ foreach (Match match1 in _keyValue.Matches(content))
{
var split = match1.Value.Split(" ");
var key = split[0];
var value = split[1];
sshHost.Properties[key] = value;
}
+
list.Add(sshHost);
}
+
return list;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/SshHost.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/SshHost.cs
index f062b3a39d..6a20e8f8e3 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/SshHost.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SshConfigParser/SshHost.cs
@@ -1,33 +1,39 @@
-using System.Collections.Generic;
+// Copyright (c) Microsoft Corporation
+// 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.Collections.Generic;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
{
public class SshHost
{
- public string IdentityFile
+ public string IdentityFile
{
get => this[nameof(IdentityFile)]?.ToString();
set => this[nameof(IdentityFile)] = value;
}
- public string Host
+ public string Host
{
get => this[nameof(Host)]?.ToString();
set => this[nameof(Host)] = value;
}
- public string HostName
+ public string HostName
{
get => this[nameof(HostName)]?.ToString();
set => this[nameof(HostName)] = value;
}
- public string User {
+ public string User
+ {
get => this[nameof(User)]?.ToString();
set => this[nameof(User)] = value;
}
- public string ForwardAgent {
+ public string ForwardAgent
+ {
get => this[nameof(ForwardAgent)]?.ToString();
set => this[nameof(ForwardAgent)] = value;
}
@@ -36,7 +42,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
public object this[string key]
{
- get
+ get
{
if (Properties.TryGetValue(key, out var value))
{
@@ -45,9 +51,13 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
return null;
}
- set { Properties[key] = value; }
+
+ set
+ {
+ Properties[key] = value;
+ }
}
public IEnumerable Keys => Properties.Keys;
}
-}
\ No newline at end of file
+}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RealPath.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SystemPath.cs
similarity index 62%
rename from src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RealPath.cs
rename to src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SystemPath.cs
index 04180331ab..3a2f1c6acc 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/RealPath.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/SystemPath.cs
@@ -1,9 +1,12 @@
-using System;
+// Copyright (c) Microsoft Corporation
+// 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.Text.RegularExpressions;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
{
- class SystemPath
+ internal class SystemPath
{
private static readonly Regex WindowsPath = new Regex(@"^([a-zA-Z]:)", RegexOptions.Compiled);
@@ -11,8 +14,8 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
{
if (WindowsPath.IsMatch(path))
{
- String windowsPath = path.Replace("/", "\\");
- return $"{windowsPath[0]}".ToUpper() + windowsPath.Remove(0,1);
+ string windowsPath = path.Replace("/", "\\");
+ return $"{windowsPath[0]}".ToUpper() + windowsPath.Remove(0, 1);
}
else
{
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstance.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstance.cs
index 212299dea1..b822f137b8 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstance.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/VSCodeHelper/VSCodeInstance.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) Microsoft Corporation
+// 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.Windows.Media;
using System.Windows.Media.Imaging;
@@ -8,20 +11,20 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
{
Stable = 1,
Insiders = 2,
- Exploration = 3
+ Exploration = 3,
}
public class VSCodeInstance
{
public VSCodeVersion VSCodeVersion { get; set; }
- public string ExecutablePath { get; set; } = String.Empty;
+ public string ExecutablePath { get; set; } = string.Empty;
- public string AppData { get; set; } = String.Empty;
+ public string AppData { get; set; } = string.Empty;
- public ImageSource WorkspaceIcon(){ return WorkspaceIconBitMap; }
+ public ImageSource WorkspaceIcon() => WorkspaceIconBitMap;
- public ImageSource RemoteIcon(){ return RemoteIconBitMap; }
+ public ImageSource RemoteIcon() => RemoteIconBitMap;
public BitmapImage WorkspaceIconBitMap { get; set; }
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 598089d2cd..214fbd4f25 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
@@ -1,28 +1,25 @@
-using System;
+// Copyright (c) Microsoft Corporation
+// 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
-using System.Windows;
-using System.Windows.Interop;
-using System.Windows.Media;
using System.Windows.Media.Imaging;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
{
- static class VSCodeInstances
+ public static class VSCodeInstances
{
- private static readonly string PathUserAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
-
- private static string _systemPath = String.Empty;
+ private static string _systemPath = string.Empty;
private static string _userAppDataPath = Environment.GetEnvironmentVariable("AppData");
- public static List instances = new List();
+ public static List Instances { get; set; } = new List();
private static BitmapImage Bitmap2BitmapImage(Bitmap bitmap)
{
@@ -42,15 +39,15 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
}
}
- public static Bitmap bitmapOverlayToCenter(Bitmap bitmap1, Bitmap overlayBitmap)
+ public static Bitmap BitmapOverlayToCenter(Bitmap bitmap1, Bitmap overlayBitmap)
{
int bitmap1Width = bitmap1.Width;
int bitmap1Height = bitmap1.Height;
Bitmap overlayBitmapResized = new Bitmap(overlayBitmap, new System.Drawing.Size(bitmap1Width / 2, bitmap1Height / 2));
- float marginLeft = (float)(bitmap1Width * 0.7 - overlayBitmapResized.Width * 0.5);
- float marginTop = (float)(bitmap1Height * 0.7 - overlayBitmapResized.Height * 0.5);
+ float marginLeft = (float)((bitmap1Width * 0.7) - (overlayBitmapResized.Width * 0.5));
+ float marginTop = (float)((bitmap1Height * 0.7) - (overlayBitmapResized.Height * 0.5));
Bitmap finalBitmap = new Bitmap(bitmap1Width, bitmap1Height);
using (Graphics g = Graphics.FromImage(finalBitmap))
@@ -58,6 +55,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
g.DrawImage(bitmap1, System.Drawing.Point.Empty);
g.DrawImage(overlayBitmapResized, marginLeft, marginTop);
}
+
return finalBitmap;
}
@@ -66,8 +64,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
{
if (_systemPath != Environment.GetEnvironmentVariable("PATH"))
{
-
- instances = new List();
+ Instances = new List();
_systemPath = Environment.GetEnvironmentVariable("PATH");
var paths = _systemPath.Split(";");
@@ -83,7 +80,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
if (files.Length > 0)
{
var file = files[0];
- var version = String.Empty;
+ var version = string.Empty;
var instance = new VSCodeInstance
{
@@ -106,23 +103,23 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
instance.VSCodeVersion = VSCodeVersion.Exploration;
}
- if (version != String.Empty)
+ if (version != string.Empty)
{
instance.AppData = Path.Combine(_userAppDataPath, version);
var iconVSCode = Path.Join(iconPath, $"{version}.exe");
var bitmapIconVscode = Icon.ExtractAssociatedIcon(iconVSCode).ToBitmap();
- //workspace
+ // workspace
var folderIcon = (Bitmap)System.Drawing.Image.FromFile(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "//Images//folder.png");
- instance.WorkspaceIconBitMap = Bitmap2BitmapImage(bitmapOverlayToCenter(folderIcon, bitmapIconVscode));
+ instance.WorkspaceIconBitMap = Bitmap2BitmapImage(BitmapOverlayToCenter(folderIcon, bitmapIconVscode));
- //remote
+ // remote
var monitorIcon = (Bitmap)System.Drawing.Image.FromFile(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "//Images//monitor.png");
- instance.RemoteIconBitMap = Bitmap2BitmapImage(bitmapOverlayToCenter(monitorIcon, bitmapIconVscode));
+ instance.RemoteIconBitMap = Bitmap2BitmapImage(BitmapOverlayToCenter(monitorIcon, bitmapIconVscode));
- instances.Add(instance);
+ Instances.Add(instance);
}
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/OpenedPathsList.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/OpenedPathsList.cs
new file mode 100644
index 0000000000..bbc7daa71f
--- /dev/null
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/OpenedPathsList.cs
@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft Corporation
+// 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.Collections.Generic;
+
+namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
+{
+ public class OpenedPathsList
+ {
+ public List Workspaces3 { get; set; }
+
+ public List Entries { get; set; }
+ }
+}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs
index 32c54f5a26..6978aa636e 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/ParseVSCodeUri.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) Microsoft Corporation
+// 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.Text.RegularExpressions;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
@@ -13,7 +16,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
private static readonly Regex CodespacesWorkspace = new Regex(@"^vscode-remote://vsonline\+(.+?(?=\/))(.+)$", RegexOptions.Compiled);
- public static (TypeWorkspace? TypeWorkspace, String MachineName, String Path) GetTypeWorkspace(string uri)
+ public static (TypeWorkspace? TypeWorkspace, string MachineName, string Path) GetTypeWorkspace(string uri)
{
if (LocalWorkspace.IsMatch(uri))
{
@@ -48,7 +51,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
if (match.Groups.Count > 1)
{
- return (TypeWorkspace.Codespaces, String.Empty, match.Groups[2].Value);
+ return (TypeWorkspace.Codespaces, string.Empty, match.Groups[2].Value);
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeStorageFile.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeStorageFile.cs
index c497342274..1a7c12a699 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeStorageFile.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeStorageFile.cs
@@ -1,22 +1,11 @@
-using System.Collections.Generic;
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
{
public class VSCodeStorageFile
{
- public openedPathsList openedPathsList { get; set; }
- }
-
- public class VSCodeWorkspaceEntry
- {
- public string folderUri { get; set; }
- public string label { get; set; }
- }
-
- public class openedPathsList
- {
- public List workspaces3 { get; set; }
-
- public List entries { get; set; }
+ public OpenedPathsList OpenedPathsList { get; set; }
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs
index 9690dfd85e..01aa2ea141 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspace.cs
@@ -1,4 +1,8 @@
-using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.Properties;
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.Properties;
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
@@ -38,6 +42,6 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
Codespaces = 2,
RemoteWSL = 3,
RemoteSSH = 4,
- RemoteContainers = 5
+ RemoteContainers = 5,
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceEntry.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceEntry.cs
new file mode 100644
index 0000000000..b2072d3a6b
--- /dev/null
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspaceEntry.cs
@@ -0,0 +1,13 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
+{
+ public class VSCodeWorkspaceEntry
+ {
+ public string FolderUri { get; set; }
+
+ public string Label { get; set; }
+ }
+}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs
index 04aa66bdb9..1f2e38bb11 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs
@@ -1,23 +1,29 @@
-using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
-using Newtonsoft.Json;
+// Copyright (c) Microsoft Corporation
+// 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;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Text.Json;
+using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
using Wox.Plugin.Logger;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
{
public class VSCodeWorkspacesApi
{
- public VSCodeWorkspacesApi() { }
-
- private VSCodeWorkspace parseVSCodeUri(string uri, VSCodeInstance vscodeInstance)
+ public VSCodeWorkspacesApi()
{
- if (uri != null && uri is String)
+ }
+
+ private VSCodeWorkspace ParseVSCodeUri(string uri, VSCodeInstance vscodeInstance)
+ {
+ if (uri != null && uri is string)
{
string unescapeUri = Uri.UnescapeDataString(uri);
- var typeWorkspace = ParseVSCodeUri.GetTypeWorkspace(unescapeUri);
+ var typeWorkspace = WorkspacesHelper.ParseVSCodeUri.GetTypeWorkspace(unescapeUri);
if (typeWorkspace.TypeWorkspace.HasValue)
{
var folderName = Path.GetFileName(unescapeUri);
@@ -28,7 +34,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
FolderName = folderName,
ExtraInfo = typeWorkspace.MachineName,
TypeWorkspace = typeWorkspace.TypeWorkspace.Value,
- VSCodeInstance = vscodeInstance
+ VSCodeInstance = vscodeInstance,
};
}
}
@@ -40,10 +46,9 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
{
get
{
-
var results = new List();
- foreach (var vscodeInstance in VSCodeInstances.instances)
+ foreach (var vscodeInstance in VSCodeInstances.Instances)
{
// storage.json contains opened Workspaces
var vscode_storage = Path.Combine(vscodeInstance.AppData, "storage.json");
@@ -54,16 +59,21 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
try
{
- VSCodeStorageFile vscodeStorageFile = JsonConvert.DeserializeObject(fileContent);
+ var options = new JsonSerializerOptions
+ {
+ PropertyNameCaseInsensitive = true,
+ };
+
+ VSCodeStorageFile vscodeStorageFile = JsonSerializer.Deserialize(fileContent, options);
if (vscodeStorageFile != null)
{
- //for previous versions of vscode
- if (vscodeStorageFile.openedPathsList.workspaces3 != null)
+ // for previous versions of vscode
+ if (vscodeStorageFile.OpenedPathsList.Workspaces3 != null)
{
- foreach (var workspaceUri in vscodeStorageFile.openedPathsList.workspaces3)
+ foreach (var workspaceUri in vscodeStorageFile.OpenedPathsList.Workspaces3)
{
- var uri = parseVSCodeUri(workspaceUri, vscodeInstance);
+ var uri = ParseVSCodeUri(workspaceUri, vscodeInstance);
if (uri != null)
{
results.Add(uri);
@@ -71,19 +81,18 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
}
}
- //vscode v1.55.0 or later
- if (vscodeStorageFile.openedPathsList.entries != null)
+ // vscode v1.55.0 or later
+ if (vscodeStorageFile.OpenedPathsList.Entries != null)
{
- foreach (var workspaceUri in vscodeStorageFile.openedPathsList.entries.Select(x => x.folderUri))
+ foreach (var workspaceUri in vscodeStorageFile.OpenedPathsList.Entries.Select(x => x.FolderUri))
{
- var uri = parseVSCodeUri(workspaceUri, vscodeInstance);
+ var uri = ParseVSCodeUri(workspaceUri, vscodeInstance);
if (uri != null)
{
results.Add(uri);
}
}
}
-
}
}
catch (Exception ex)
@@ -91,12 +100,9 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper
var message = $"Failed to deserialize ${vscode_storage}";
Log.Exception(message, ex, GetType());
}
-
}
-
}
-
return results;
}
}
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/stylecop.json b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/stylecop.json
new file mode 100644
index 0000000000..42fb1f8ea1
--- /dev/null
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/stylecop.json
@@ -0,0 +1,14 @@
+{
+ // ACTION REQUIRED: This file was automatically added to your project, but it
+ // will not take effect until additional steps are taken to enable it. See the
+ // following page for additional information:
+ //
+ // https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md
+
+ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
+ "settings": {
+ "documentationRules": {
+ "companyName": "PlaceholderCompany"
+ }
+ }
+}