mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01: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
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@@ -1853,6 +1853,7 @@ timeunion
|
||||
timeutil
|
||||
timezones
|
||||
Titlecase
|
||||
TKey
|
||||
TLayout
|
||||
tlb
|
||||
TMPVAR
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<PackageVersion Include="LazyCache" Version="2.4.0" />
|
||||
<PackageVersion Include="Mages" Version="2.0.1" />
|
||||
<PackageVersion Include="Markdig.Signed" Version="0.27.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.1" />
|
||||
<PackageVersion Include="Microsoft.Data.Sqlite" Version="7.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
||||
|
||||
@@ -289,7 +289,7 @@ SOFTWARE.
|
||||
- LazyCache 2.4.0
|
||||
- Mages 2.0.1
|
||||
- Markdig.Signed 0.27.0
|
||||
- Microsoft.CodeAnalysis.NetAnalyzers 7.0.0
|
||||
- Microsoft.CodeAnalysis.NetAnalyzers 7.0.1
|
||||
- Microsoft.Data.Sqlite 7.0.0
|
||||
- Microsoft.Extensions.Hosting 7.0.0
|
||||
- Microsoft.NET.Test.Sdk 17.4.1
|
||||
|
||||
@@ -2,8 +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.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
@@ -13,10 +12,10 @@ using Windows.System.Profile;
|
||||
|
||||
namespace AllExperiments
|
||||
{
|
||||
// The dependencies required to build this project are only available in the official build pipeline and are internal to Microsoft.
|
||||
// However, this project is not required to build a test version of the application.
|
||||
// The dependencies required to build this project are only available in the official build pipeline and are internal to Microsoft.
|
||||
// However, this project is not required to build a test version of the application.
|
||||
public class Experiments
|
||||
{
|
||||
{
|
||||
public enum ExperimentState
|
||||
{
|
||||
Enabled,
|
||||
@@ -25,7 +24,9 @@ namespace AllExperiments
|
||||
}
|
||||
|
||||
#pragma warning disable SA1401 // Need to use LandingPageExperiment as a static property in OobeShellPage.xaml.cs
|
||||
#pragma warning disable CA2211 // Non-constant fields should not be visible
|
||||
public static ExperimentState LandingPageExperiment = ExperimentState.NotLoaded;
|
||||
#pragma warning restore CA2211
|
||||
#pragma warning restore SA1401
|
||||
|
||||
public async Task<bool> EnableLandingPageExperimentAsync()
|
||||
@@ -87,7 +88,7 @@ namespace AllExperiments
|
||||
else
|
||||
{
|
||||
var jsonDataVersion = jsonDictionary["dataversion"].ToString();
|
||||
if (jsonDataVersion != null && int.Parse(jsonDataVersion) < dataVersion)
|
||||
if (jsonDataVersion != null && int.Parse(jsonDataVersion, CultureInfo.InvariantCulture) < dataVersion)
|
||||
{
|
||||
jsonDictionary["dataversion"] = dataVersion;
|
||||
jsonDictionary["variantassignment"] = featureFlagValue;
|
||||
|
||||
@@ -7,7 +7,7 @@ using Microsoft.VariantAssignment.Contract;
|
||||
// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
|
||||
namespace Microsoft.VariantAssignment.Client
|
||||
{
|
||||
internal partial class VariantAssignmentServiceClient<TServerResponse> : IVariantAssignmentProvider, IDisposable
|
||||
internal sealed partial class VariantAssignmentServiceClient<TServerResponse> : IVariantAssignmentProvider, IDisposable
|
||||
where TServerResponse : VariantAssignmentServiceResponse
|
||||
{
|
||||
public void Dispose()
|
||||
|
||||
@@ -31,7 +31,13 @@ namespace Microsoft.VariantAssignment.Contract
|
||||
/// <inheritdoc/>
|
||||
public IReadOnlyList<IFeatureVariable> GetFeatureVariables(IReadOnlyList<string> prefix) => Array.Empty<IFeatureVariable>();
|
||||
|
||||
void IDisposable.Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
|
||||
namespace Microsoft.VariantAssignment.Contract
|
||||
{
|
||||
internal class TreatmentAssignmentServiceResponse : VariantAssignmentServiceResponse
|
||||
internal sealed class TreatmentAssignmentServiceResponse : VariantAssignmentServiceResponse
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
|
||||
private bool FilterKeyboardEvents(KeyboardEvent ev)
|
||||
{
|
||||
#pragma warning disable CA2020 // Prevent from behavioral change
|
||||
return _filterKeyboardEvent(ev.key, (UIntPtr)ev.dwExtraInfo);
|
||||
#pragma warning restore CA2020 // Prevent from behavioral change
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
}
|
||||
}
|
||||
|
||||
private class JsonMergeHelper
|
||||
private sealed class JsonMergeHelper
|
||||
{
|
||||
// mostly from https://stackoverflow.com/questions/58694837/system-text-json-merge-two-objects
|
||||
// but with some update to prevent array item duplicates
|
||||
@@ -308,10 +308,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
var retoreFullPath = Path.Combine(appBasePath, relativePath);
|
||||
var settingsToRestoreJson = GetExportVersion(backupRetoreSettings, currentFile.Key, currentFile.Value);
|
||||
|
||||
if (currentSettingsFiles.ContainsKey(currentFile.Key))
|
||||
if (currentSettingsFiles.TryGetValue(currentFile.Key, out string value))
|
||||
{
|
||||
// we have a setting file to restore to
|
||||
var currentSettingsFileJson = GetExportVersion(backupRetoreSettings, currentFile.Key, currentSettingsFiles[currentFile.Key]);
|
||||
var currentSettingsFileJson = GetExportVersion(backupRetoreSettings, currentFile.Key, value);
|
||||
|
||||
if (JsonNormalizer.Normalize(settingsToRestoreJson) != JsonNormalizer.Normalize(currentSettingsFileJson))
|
||||
{
|
||||
@@ -659,10 +659,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
var currentSettingsFileToBackup = GetExportVersion(backupRetoreSettings, currentFile.Key, currentFile.Value);
|
||||
|
||||
var doBackup = false;
|
||||
if (lastBackupSettingsFiles.ContainsKey(currentFile.Key))
|
||||
if (lastBackupSettingsFiles.TryGetValue(currentFile.Key, out string value))
|
||||
{
|
||||
// there is a previous backup for this, get an export version of it.
|
||||
var lastSettingsFileDoc = GetExportVersion(backupRetoreSettings, currentFile.Key, lastBackupSettingsFiles[currentFile.Key]);
|
||||
var lastSettingsFileDoc = GetExportVersion(backupRetoreSettings, currentFile.Key, value);
|
||||
|
||||
// check to see if the new export version would be same as last export version.
|
||||
if (JsonNormalizer.Normalize(currentSettingsFileToBackup) != JsonNormalizer.Normalize(lastSettingsFileDoc))
|
||||
@@ -989,7 +989,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
/// Class <c>JsonNormalizer</c> is a utility class to 'normalize' a JSON file so that it can be compared to another JSON file.
|
||||
/// This really just means to fully sort it. This does not work for any JSON file where the order of the node is relevant.
|
||||
/// </summary>
|
||||
private class JsonNormalizer
|
||||
private sealed class JsonNormalizer
|
||||
{
|
||||
public static string Normalize(string json)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility
|
||||
// Using Ordinal since this is used internally for a path
|
||||
private static readonly Expression<Func<string, bool>> SettingsFilterExpression = s => s == null || s.Contains("Microsoft\\PowerToys\\settings.json", StringComparison.Ordinal);
|
||||
|
||||
internal class MockSettingsRepository<T> : ISettingsRepository<T>
|
||||
internal sealed class MockSettingsRepository<T> : ISettingsRepository<T>
|
||||
where T : ISettingsConfig, new()
|
||||
{
|
||||
private readonly ISettingsUtils _settingsUtils;
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace CommonLibTest
|
||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
}
|
||||
|
||||
private partial class TestClass : ISettingsConfig
|
||||
private sealed partial class TestClass : ISettingsConfig
|
||||
{
|
||||
public int TestInt { get; set; } = 100;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace ViewModelTests
|
||||
[TestClass]
|
||||
public class PowerLauncherViewModelTest
|
||||
{
|
||||
private class SendCallbackMock
|
||||
private sealed class SendCallbackMock
|
||||
{
|
||||
public int TimesSent { get; set; }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ using Windows.ApplicationModel.Activation;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Activation
|
||||
{
|
||||
internal class DefaultActivationHandler : ActivationHandler<IActivatedEventArgs>
|
||||
internal sealed class DefaultActivationHandler : ActivationHandler<IActivatedEventArgs>
|
||||
{
|
||||
private readonly Type navElement;
|
||||
|
||||
|
||||
@@ -163,8 +163,8 @@ namespace Microsoft.PowerToys.Settings.UI
|
||||
if (containsFlyoutPosition)
|
||||
{
|
||||
// get the flyout position arguments
|
||||
int.TryParse(cmdArgs[currentArgumentIndex++], out flyout_x);
|
||||
int.TryParse(cmdArgs[currentArgumentIndex++], out flyout_y);
|
||||
_ = int.TryParse(cmdArgs[currentArgumentIndex++], out flyout_x);
|
||||
_ = int.TryParse(cmdArgs[currentArgumentIndex++], out flyout_y);
|
||||
}
|
||||
|
||||
RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () =>
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text.Json;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
{
|
||||
internal class Utils
|
||||
internal sealed class Utils
|
||||
{
|
||||
private static string _placementPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\PowerToys\settings-placement.json");
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
|
||||
public sealed partial class OobeWhatsNew : Page
|
||||
{
|
||||
// Contains information for a release. Used to deserialize release JSON info from GitHub.
|
||||
private class PowerToysReleaseInfo
|
||||
private sealed class PowerToysReleaseInfo
|
||||
{
|
||||
[JsonPropertyName("published_at")]
|
||||
public DateTimeOffset PublishedDate { get; set; }
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Services
|
||||
{
|
||||
// For more information on understanding and extending activation flow see
|
||||
// https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/activation.md
|
||||
internal class ActivationService
|
||||
internal sealed class ActivationService
|
||||
{
|
||||
private readonly App app;
|
||||
private readonly Type defaultNavItem;
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
// skip entries with empty name or duplicated name, it should never occur
|
||||
string storedName = storedColorFormat.Key;
|
||||
if (storedName == string.Empty || ColorFormats.Count(x => x.Name.ToUpperInvariant().Equals(storedName.ToUpperInvariant(), StringComparison.Ordinal)) > 0)
|
||||
if (storedName == string.Empty || ColorFormats.Any(x => x.Name.ToUpperInvariant().Equals(storedName.ToUpperInvariant(), StringComparison.Ordinal)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public Action<FlyoutMenuItem> EnabledChangedCallback { get; set; } = null;
|
||||
public Action<FlyoutMenuItem> EnabledChangedCallback { get; set; }
|
||||
|
||||
public bool Visible
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Timers;
|
||||
@@ -9,8 +10,11 @@ using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
||||
{
|
||||
public class FlyoutViewModel
|
||||
public class FlyoutViewModel : IDisposable
|
||||
{
|
||||
private Timer _hideTimer;
|
||||
private bool _disposed;
|
||||
|
||||
public bool CanHide { get; set; }
|
||||
|
||||
private bool _windows10;
|
||||
@@ -28,29 +32,27 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
||||
}
|
||||
}
|
||||
|
||||
private Timer hideTimer;
|
||||
|
||||
public FlyoutViewModel()
|
||||
{
|
||||
CanHide = true;
|
||||
hideTimer = new Timer();
|
||||
hideTimer.Elapsed += HideTimer_Elapsed;
|
||||
hideTimer.Interval = 1000;
|
||||
hideTimer.Enabled = false;
|
||||
_hideTimer = new Timer();
|
||||
_hideTimer.Elapsed += HideTimer_Elapsed;
|
||||
_hideTimer.Interval = 1000;
|
||||
_hideTimer.Enabled = false;
|
||||
_windows10 = !Helper.Windows11();
|
||||
}
|
||||
|
||||
private void HideTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
CanHide = true;
|
||||
hideTimer.Stop();
|
||||
_hideTimer.Stop();
|
||||
}
|
||||
|
||||
internal void DisableHiding()
|
||||
{
|
||||
CanHide = false;
|
||||
hideTimer.Stop();
|
||||
hideTimer.Start();
|
||||
_hideTimer.Stop();
|
||||
_hideTimer.Start();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
@@ -59,5 +61,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_hideTimer?.Dispose();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,12 +178,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
AvailableLanguages.Clear();
|
||||
foreach (Language language in possibleOcrLanguages)
|
||||
{
|
||||
if (_powerOcrSettings.Properties.PreferredLanguage?.Equals(language.DisplayName) == true)
|
||||
if (_powerOcrSettings.Properties.PreferredLanguage?.Equals(language.DisplayName, StringComparison.Ordinal) == true)
|
||||
{
|
||||
preferredLanguageIndex = AvailableLanguages.Count;
|
||||
}
|
||||
|
||||
if (systemCulture.DisplayName.Equals(language.DisplayName) || systemCulture.Parent.DisplayName.Equals(language.DisplayName))
|
||||
if (systemCulture.DisplayName.Equals(language.DisplayName, StringComparison.Ordinal) || systemCulture.Parent.DisplayName.Equals(language.DisplayName, StringComparison.Ordinal))
|
||||
{
|
||||
systemLanguageIndex = AvailableLanguages.Count;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
string csMessage = csIpcMessage.ToJsonString();
|
||||
string outMessage = outIpcMessage.ToJsonString();
|
||||
|
||||
if (!csMessage.Equals(outMessage))
|
||||
if (!csMessage.Equals(outMessage, StringComparison.Ordinal))
|
||||
{
|
||||
Logger.LogInfo($"Saved Awake settings from Awake page.");
|
||||
_sendConfigMsg(outMessage);
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
IJsonValue whatToShowJson;
|
||||
if (json.TryGetValue("ShowYourself", out whatToShowJson))
|
||||
{
|
||||
if (whatToShowJson.ValueType == JsonValueType.String && whatToShowJson.GetString().Equals("flyout"))
|
||||
if (whatToShowJson.ValueType == JsonValueType.String && whatToShowJson.GetString().Equals("flyout", StringComparison.Ordinal))
|
||||
{
|
||||
POINT? p = null;
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
OpenFlyoutCallback(p);
|
||||
}
|
||||
else if (whatToShowJson.ValueType == JsonValueType.String && whatToShowJson.GetString().Equals("main_page"))
|
||||
else if (whatToShowJson.ValueType == JsonValueType.String && whatToShowJson.GetString().Equals("main_page", StringComparison.Ordinal))
|
||||
{
|
||||
OpenMainWindowCallback();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user