mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +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
@@ -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