mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
.NET 8 Upgrade Silenced Errors Fix (#30469)
* [Dev][Build] .NET 8 Upgrade Silenced errors first fix. * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1859 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1854. * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1860 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1861 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1862 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1863 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1864 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1865 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA2208 * [Dev][Build] .NET 8 Upgrade Silenced errors. CS9191 * [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check * [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check * [Dev][Build] .NET 8 Upgrade Silenced errors. - CompositeFormat variables used more than once in the same file were assigned to a single variable. - GetProcessesByName logic fix. - String comparion fix. - ArgumentOutOfRangeException message change. * [Dev][Build] .NET 8 Upgrade Silenced errors. - Null check added. - static readonly CompositeFormat added for all fields.
This commit is contained in:
@@ -93,9 +93,9 @@ namespace PowerAccent.Core
|
||||
// All
|
||||
private static string[] GetDefaultLetterKeyALL(LetterKey letter)
|
||||
{
|
||||
if (!_allLanguagesCache.ContainsKey(letter))
|
||||
if (!_allLanguagesCache.TryGetValue(letter, out string[] cachedValue))
|
||||
{
|
||||
_allLanguagesCache[letter] = GetDefaultLetterKeyCA(letter)
|
||||
cachedValue = GetDefaultLetterKeyCA(letter)
|
||||
.Union(GetDefaultLetterKeyCUR(letter))
|
||||
.Union(GetDefaultLetterKeyCY(letter))
|
||||
.Union(GetDefaultLetterKeyCZ(letter))
|
||||
@@ -129,9 +129,11 @@ namespace PowerAccent.Core
|
||||
.Union(GetDefaultLetterKeyTK(letter))
|
||||
.Union(GetDefaultLetterKeyAllLanguagesOnly(letter))
|
||||
.ToArray();
|
||||
|
||||
_allLanguagesCache[letter] = cachedValue;
|
||||
}
|
||||
|
||||
return _allLanguagesCache[letter];
|
||||
return cachedValue;
|
||||
}
|
||||
|
||||
// Contains all characters that should be shown in all languages but currently don't belong to any of the single languages available for that letter.
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace PowerAccent.Core.Services;
|
||||
public class SettingsService
|
||||
{
|
||||
private const string PowerAccentModuleName = "QuickAccent";
|
||||
private readonly ISettingsUtils _settingsUtils;
|
||||
private readonly SettingsUtils _settingsUtils;
|
||||
private readonly IFileSystemWatcher _watcher;
|
||||
private readonly object _loadingSettingsLock = new object();
|
||||
private KeyboardListener _keyboardListener;
|
||||
@@ -28,6 +28,11 @@ public class SettingsService
|
||||
_watcher = Helper.GetFileWatcher(PowerAccentModuleName, "settings.json", () => { ReadSettings(); });
|
||||
}
|
||||
|
||||
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true,
|
||||
};
|
||||
|
||||
private void ReadSettings()
|
||||
{
|
||||
// TODO this IO call should by Async, update GetFileWatcher helper to support async
|
||||
@@ -40,10 +45,7 @@ public class SettingsService
|
||||
{
|
||||
Logger.LogInfo("QuickAccent settings.json was missing, creating a new one");
|
||||
var defaultSettings = new PowerAccentSettings();
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true,
|
||||
};
|
||||
var options = _serializerOptions;
|
||||
|
||||
_settingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), PowerAccentModuleName);
|
||||
}
|
||||
|
||||
@@ -34,16 +34,15 @@ 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))
|
||||
if (_characterUsageCounters.TryGetValue(character, out uint currentCount))
|
||||
{
|
||||
_characterUsageCounters[character]++;
|
||||
_characterUsageCounters[character] = currentCount + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_characterUsageCounters.Add(character, 1);
|
||||
_characterUsageCounters[character] = 1;
|
||||
}
|
||||
|
||||
_characterUsageTimestamp[character] = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
|
||||
Reference in New Issue
Block a user