[Build] Upgraded NetAnalyzers to 7.0.1 (#24792)

* upgraded NetAnalyzers to 7.0.1

* fix spellcheck

* Microsoft.CodeAnalysis.NetAnalyzers 7.0.1

* rebase and fix
This commit is contained in:
Davide Giacometti
2023-03-16 15:51:31 +01:00
committed by GitHub
parent 5492b4ae62
commit 5cbe9dd911
61 changed files with 124 additions and 107 deletions

View File

@@ -62,7 +62,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
return new Result
{
ContextData = result,
Title = result.ToString(),
Title = result.ToString(null),
IcoPath = _icon_path,
Score = 300,
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.copy_to_clipboard, result.QuantityInfo.Name),

View File

@@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
{
internal class SystemPath
internal sealed class SystemPath
{
private static readonly Regex WindowsPath = new Regex(@"^([a-zA-Z]:)", RegexOptions.Compiled);

View File

@@ -439,9 +439,9 @@ namespace Microsoft.Plugin.Program.Programs
paths.Add(path);
}
if (_scaleFactors.ContainsKey(Package.Version))
if (_scaleFactors.TryGetValue(Package.Version, out List<int> factors))
{
foreach (var factor in _scaleFactors[Package.Version])
foreach (var factor in factors)
{
if (highContrast)
{

View File

@@ -17,7 +17,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components
/// <summary>
/// This class represents the informations for a network connection/interface
/// </summary>
internal class NetworkConnectionProperties
internal sealed class NetworkConnectionProperties
{
/// <summary>
/// Gets the name of the adapter

View File

@@ -4,7 +4,7 @@
namespace Microsoft.PowerToys.Run.Plugin.System.Components
{
internal class SystemPluginContext
internal sealed class SystemPluginContext
{
/// <summary>
/// Gets or sets the type of the result

View File

@@ -9,7 +9,7 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsSettings
/// <summary>
/// A windows setting
/// </summary>
internal class WindowsSetting
internal sealed class WindowsSetting
{
/// <summary>
/// Initializes a new instance of the <see cref="WindowsSetting"/> class.

View File

@@ -10,7 +10,7 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsSettings
/// <summary>
/// A class that contain all possible windows settings
/// </summary>
internal class WindowsSettings
internal sealed class WindowsSettings
{
/// <summary>
/// Initializes a new instance of the <see cref="WindowsSettings"/> class with an empty settings list.

View File

@@ -9,7 +9,7 @@ using System.Windows.Controls;
namespace PowerLauncher
{
public class CustomSearchBox : TextBox
public sealed class CustomSearchBox : TextBox
{
public List<UIElement> ControlledElements { get; } = new List<UIElement>();
@@ -18,7 +18,7 @@ namespace PowerLauncher
return new AutoSuggestTextBoxAutomationPeer(this);
}
internal class AutoSuggestTextBoxAutomationPeer : TextBoxAutomationPeer
internal sealed class AutoSuggestTextBoxAutomationPeer : TextBoxAutomationPeer
{
public AutoSuggestTextBoxAutomationPeer(CustomSearchBox owner)
: base(owner)

View File

@@ -7,7 +7,7 @@ using Wox.Plugin;
namespace PowerLauncher.Helper
{
internal class KeyboardHelper
internal sealed class KeyboardHelper
{
public static SpecialKeyState CheckModifiers()
{

View File

@@ -17,7 +17,7 @@ using Wox.Plugin.Logger;
namespace PowerLauncher
{
internal partial class ReportWindow
internal sealed partial class ReportWindow
{
private static readonly IFileSystem FileSystem = new FileSystem();
private static readonly IFile File = FileSystem.File;

View File

@@ -269,9 +269,9 @@ namespace PowerLauncher
var defaultOptions = defaultAdditionalOptions.ToDictionary(x => x.Key);
foreach (var option in additionalOptions)
{
if (option.Key != null && defaultOptions.ContainsKey(option.Key))
if (option.Key != null && defaultOptions.TryGetValue(option.Key, out PluginAdditionalOption defaultOption))
{
defaultOptions[option.Key].Value = option.Value;
defaultOption.Value = option.Value;
}
}

View File

@@ -154,9 +154,7 @@ namespace Wox.Infrastructure.Hotkey
if (CharKey != Key.None)
{
text += _specialSymbolDictionary.ContainsKey(CharKey)
? _specialSymbolDictionary[CharKey]
: CharKey.ToString();
text += _specialSymbolDictionary.TryGetValue(CharKey, out string value) ? value : CharKey.ToString();
}
else if (!string.IsNullOrEmpty(text))
{

View File

@@ -34,12 +34,7 @@ namespace Wox.Infrastructure.Image
enc.Frames.Add(bitmapFrame);
enc.Save(outStream);
var byteArray = outStream.GetBuffer();
using (var sha1 = SHA1.Create())
{
var hash = Convert.ToBase64String(sha1.ComputeHash(byteArray));
return hash;
}
return Convert.ToBase64String(SHA1.HashData(byteArray));
}
}
catch (System.Exception e)

View File

@@ -25,9 +25,9 @@ namespace Wox.Plugin.Common
public string GetLocalizedName(string path)
{
// Checking cache if path is already localized
if (_localizationCache.ContainsKey(path.ToLowerInvariant()))
if (_localizationCache.TryGetValue(path.ToLowerInvariant(), out string value))
{
return _localizationCache[path.ToLowerInvariant()];
return value;
}
Guid shellItemType = ShellItemTypeConstants.ShellItemGuid;

View File

@@ -39,11 +39,7 @@ namespace Wox.Plugin
throw new ArgumentNullException(nameof(result));
}
var key = result.ToString();
if (Records.ContainsKey(result.ToString()))
{
Records.Remove(result.ToString());
}
Records.Remove(result.ToString());
}
public void Add(Result result)

View File

@@ -14,7 +14,7 @@ namespace Wox.Test
public class WoxTest
{
// A Dummy class to test that OnPropertyChanged() is called while we set the variable
private class DummyTestClass : BaseModel
private sealed class DummyTestClass : BaseModel
{
public bool IsFunctionCalled { get; set; }