mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[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:
committed by
GitHub
parent
5492b4ae62
commit
5cbe9dd911
@@ -23,7 +23,7 @@ namespace Hosts.Helpers
|
||||
return new ReplaceVisitor(searchEx, replaceEx).Visit(expression);
|
||||
}
|
||||
|
||||
internal class ReplaceVisitor : ExpressionVisitor
|
||||
internal sealed class ReplaceVisitor : ExpressionVisitor
|
||||
{
|
||||
private readonly Expression _from;
|
||||
private readonly Expression _to;
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Hosts.Helpers
|
||||
{
|
||||
internal class NativeMethods
|
||||
internal sealed class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
@@ -328,8 +328,8 @@ namespace Hosts.ViewModels
|
||||
private void FindDuplicates(string address, IEnumerable<string> hosts)
|
||||
{
|
||||
var entries = _entries.Where(e =>
|
||||
string.Equals(e.Address, address, StringComparison.InvariantCultureIgnoreCase)
|
||||
|| hosts.Intersect(e.SplittedHosts, StringComparer.InvariantCultureIgnoreCase).Any());
|
||||
string.Equals(e.Address, address, StringComparison.OrdinalIgnoreCase)
|
||||
|| hosts.Intersect(e.SplittedHosts, StringComparer.OrdinalIgnoreCase).Any());
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
@@ -353,8 +353,8 @@ namespace Hosts.ViewModels
|
||||
|
||||
var duplicate = _entries.FirstOrDefault(e => e != entry
|
||||
&& e.Type == entry.Type
|
||||
&& (string.Equals(e.Address, entry.Address, StringComparison.InvariantCultureIgnoreCase)
|
||||
|| hosts.Intersect(e.SplittedHosts, StringComparer.InvariantCultureIgnoreCase).Any())) != null;
|
||||
&& (string.Equals(e.Address, entry.Address, StringComparison.OrdinalIgnoreCase)
|
||||
|| hosts.Intersect(e.SplittedHosts, StringComparer.OrdinalIgnoreCase).Any())) != null;
|
||||
|
||||
_dispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ using BitmapDecoder = Windows.Graphics.Imaging.BitmapDecoder;
|
||||
|
||||
namespace PowerOCR;
|
||||
|
||||
internal class ImageMethods
|
||||
internal sealed class ImageMethods
|
||||
{
|
||||
internal static ImageSource GetWindowBoundsImage(Window passedWindow)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PowerOCR.Keyboard
|
||||
/// This class handles the interaction model when running from PowerToys Run.
|
||||
/// Handles activation through the event sent by the runner.
|
||||
/// </summary>
|
||||
internal class EventMonitor
|
||||
internal sealed class EventMonitor
|
||||
{
|
||||
public EventMonitor(System.Windows.Threading.Dispatcher dispatcher, System.Threading.CancellationToken exitToken)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using static PowerOCR.OSInterop;
|
||||
|
||||
namespace PowerOCR.Keyboard;
|
||||
|
||||
internal class GlobalKeyboardHook : IDisposable
|
||||
internal sealed class GlobalKeyboardHook : IDisposable
|
||||
{
|
||||
private IntPtr _windowsHookHandle;
|
||||
private IntPtr _user32LibraryHandle;
|
||||
@@ -39,7 +39,7 @@ internal class GlobalKeyboardHook : IDisposable
|
||||
|
||||
internal event EventHandler<GlobalKeyboardHookEventArgs>? KeyboardPressed;
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
public void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using static PowerOCR.OSInterop;
|
||||
|
||||
namespace PowerOCR.Keyboard;
|
||||
|
||||
internal class GlobalKeyboardHookEventArgs : HandledEventArgs
|
||||
internal sealed class GlobalKeyboardHookEventArgs : HandledEventArgs
|
||||
{
|
||||
internal GlobalKeyboardHook.KeyboardState KeyboardState { get; private set; }
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public partial class OCROverlay : Window
|
||||
|
||||
private Point GetMousePos() => PointToScreen(Mouse.GetPosition(this));
|
||||
|
||||
private Language? selectedLanguage = null;
|
||||
private Language? selectedLanguage;
|
||||
private MenuItem cancelMenuItem;
|
||||
|
||||
private System.Windows.Forms.Screen? CurrentScreen
|
||||
@@ -70,8 +70,8 @@ public partial class OCROverlay : Window
|
||||
foreach (Language language in possibleOcrLanguages)
|
||||
{
|
||||
MenuItem menuItem = new MenuItem() { Header = language.NativeName, Tag = language, IsCheckable = true };
|
||||
menuItem.IsChecked = language.DisplayName.Equals(selectedLanguageName);
|
||||
if (language.DisplayName.Equals(selectedLanguageName))
|
||||
menuItem.IsChecked = language.DisplayName.Equals(selectedLanguageName, StringComparison.Ordinal);
|
||||
if (language.DisplayName.Equals(selectedLanguageName, StringComparison.Ordinal))
|
||||
{
|
||||
selectedLanguage = language;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive.Concurrency;
|
||||
@@ -255,7 +256,7 @@ namespace Awake
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime expirationDateTime = DateTime.Parse(expireAt);
|
||||
DateTime expirationDateTime = DateTime.Parse(expireAt, CultureInfo.CurrentCulture);
|
||||
if (expirationDateTime > DateTime.Now)
|
||||
{
|
||||
// We want to have a dedicated expirable keep-awake logic instead of
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.PowerToys.Telemetry.Events;
|
||||
namespace Awake.Telemetry
|
||||
{
|
||||
[EventData]
|
||||
internal class AwakeNoKeepAwakeEvent : EventBase, IEvent
|
||||
internal sealed class AwakeNoKeepAwakeEvent : EventBase, IEvent
|
||||
{
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
|
||||
@@ -246,9 +246,7 @@ namespace ColorPicker.ViewModels
|
||||
new ColorFormatModel()
|
||||
{
|
||||
FormatName = ColorRepresentationType.HEX.ToString(),
|
||||
#pragma warning disable CA1304 // Specify CultureInfo
|
||||
Convert = (Color color) => ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HEX.ToString()).ToLower(),
|
||||
#pragma warning restore CA1304 // Specify CultureInfo
|
||||
Convert = (Color color) => ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HEX.ToString()).ToLowerInvariant(),
|
||||
});
|
||||
|
||||
_allColorRepresentations.Add(
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace FancyZonesEditor
|
||||
public abstract void Move(int delta);
|
||||
}
|
||||
|
||||
private class SnappyHelperMagnetic : SnappyHelperBase
|
||||
private sealed class SnappyHelperMagnetic : SnappyHelperBase
|
||||
{
|
||||
private List<int> magnetZoneSizes;
|
||||
private int freePosition;
|
||||
@@ -220,7 +220,7 @@ namespace FancyZonesEditor
|
||||
}
|
||||
}
|
||||
|
||||
private class SnappyHelperNonMagnetic : SnappyHelperBase
|
||||
private sealed class SnappyHelperNonMagnetic : SnappyHelperBase
|
||||
{
|
||||
public SnappyHelperNonMagnetic(IList<Int32Rect> zones, int zoneIndex, bool isX, ResizeMode mode, int screenAxisOrigin, int screenAxisSize)
|
||||
: base(zones, zoneIndex, isX, mode, screenAxisOrigin, screenAxisSize)
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Windows.Controls;
|
||||
|
||||
namespace FancyZonesEditor.Controls
|
||||
{
|
||||
internal class CustomSliderAutomationPeer : SliderAutomationPeer
|
||||
internal sealed class CustomSliderAutomationPeer : SliderAutomationPeer
|
||||
{
|
||||
private string name = string.Empty;
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace FancyZonesEditor.Utils
|
||||
}
|
||||
|
||||
// custom-layouts.json
|
||||
private class CanvasInfoWrapper
|
||||
private sealed class CanvasInfoWrapper
|
||||
{
|
||||
public struct CanvasZoneWrapper
|
||||
{
|
||||
@@ -198,7 +198,7 @@ namespace FancyZonesEditor.Utils
|
||||
}
|
||||
|
||||
// custom-layouts.json
|
||||
private class GridInfoWrapper
|
||||
private sealed class GridInfoWrapper
|
||||
{
|
||||
public int Rows { get; set; }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Windows.Interop;
|
||||
|
||||
namespace FancyZonesEditor.Utils
|
||||
{
|
||||
internal class NativeMethods
|
||||
internal sealed class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace ImageResizer.Test
|
||||
return raisedEvent;
|
||||
}
|
||||
|
||||
public class RaisedEvent<TArgs>
|
||||
public sealed class RaisedEvent<TArgs>
|
||||
{
|
||||
public RaisedEvent(object sender, TArgs args)
|
||||
{
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,7 +7,7 @@ using Wox.Plugin;
|
||||
|
||||
namespace PowerLauncher.Helper
|
||||
{
|
||||
internal class KeyboardHelper
|
||||
internal sealed class KeyboardHelper
|
||||
{
|
||||
public static SpecialKeyState CheckModifiers()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -2,9 +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;
|
||||
using PowerToys.PowerAccentKeyboardService;
|
||||
using Windows.Globalization;
|
||||
|
||||
namespace PowerAccent.Core
|
||||
{
|
||||
@@ -42,7 +40,7 @@ namespace PowerAccent.Core
|
||||
TK,
|
||||
}
|
||||
|
||||
internal class Languages
|
||||
internal sealed class Languages
|
||||
{
|
||||
public static string[] GetDefaultLetterKey(LetterKey letter, Language lang)
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace PowerAccent.Core.Tools
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1854:Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method", Justification = "False positive: https://github.com/dotnet/roslyn-analyzers/issues/6390")]
|
||||
public void IncrementUsageFrequency(string character)
|
||||
{
|
||||
if (_characterUsageCounters.ContainsKey(character))
|
||||
|
||||
@@ -17,7 +17,7 @@ public partial class Selector : Window, IDisposable, INotifyPropertyChanged
|
||||
|
||||
private Visibility _characterNameVisibility = Visibility.Visible;
|
||||
|
||||
private int _selectedIndex = 0;
|
||||
private int _selectedIndex;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace PreviewHandlerCommonUnitTests
|
||||
[TestClass]
|
||||
public class FormHandlerControlTests
|
||||
{
|
||||
private class TestFormControl : FormHandlerControl
|
||||
private sealed class TestFormControl : FormHandlerControl
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PreviewHandlerCommon.ComInterop
|
||||
/// <summary>
|
||||
/// Interop methods
|
||||
/// </summary>
|
||||
internal class NativeMethods
|
||||
internal sealed class NativeMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// Changes the parent window of the specified child window.
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Common
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetRect(Rectangle rect)
|
||||
public void SetRect(Rectangle windowBounds)
|
||||
{
|
||||
this.UpdateWindowBounds(parentHwnd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user