Free, open-source Windows optimization tool for performance, privacy, and simplicity.
C# csharpdebloatdotnetgamingopen-sourceoptimizationoptimizeroptimizerduckperformanceprivacytweakertweakswindowswinui
chore: formatted files
fatDucka9be0054b0e6
diff --git a/optimizerDuck.Test/Services/RegistryWatcherTests.cs b/optimizerDuck.Test/Services/RegistryWatcherTests.csindex e887594..7177a1b 100644--- a/optimizerDuck.Test/Services/RegistryWatcherTests.cs+++ b/optimizerDuck.Test/Services/RegistryWatcherTests.cs@@ -150,8 +150,10 @@ public class RegistryWatcherTests : IDisposablewatcher.RegistryKeyChanged += (_, path) =>{- if (path == pathA) tcsA.TrySetResult(path!);- if (path == pathB) tcsB.TrySetResult(path!);+ if (path == pathA)+ tcsA.TrySetResult(path!);+ if (path == pathB)+ tcsB.TrySetResult(path!);};watcher.Watch(pathA);diff --git a/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.cs b/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.csindex e8c567e..f52d5fb 100644--- a/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.cs+++ b/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.cs@@ -20,7 +20,12 @@ public class EqualityToVisibilityConverter : IValueConverterreturn value.Equals(parameter) ? True : False;}- public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)+ public object ConvertBack(+ object? value,+ Type targetType,+ object? parameter,+ CultureInfo culture+ ){throw new NotSupportedException();}diff --git a/optimizerDuck/Common/Extensions/CustomizePageRegistryExtensions.cs b/optimizerDuck/Common/Extensions/CustomizePageRegistryExtensions.csindex 824c8ad..e02fab8 100644--- a/optimizerDuck/Common/Extensions/CustomizePageRegistryExtensions.cs+++ b/optimizerDuck/Common/Extensions/CustomizePageRegistryExtensions.cs@@ -28,7 +28,11 @@ public static class CustomizePageRegistryExtensions}}- private static object CreatePage(IServiceProvider serviceProvider, Type categoryType, Type pageType)+ private static object CreatePage(+ IServiceProvider serviceProvider,+ Type categoryType,+ Type pageType+ ){var registry = serviceProvider.GetRequiredService<CustomizeRegistry>();var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();diff --git a/optimizerDuck/Common/Helpers/SystemRefreshService.cs b/optimizerDuck/Common/Helpers/SystemRefreshService.csindex 41b8507..cfda467 100644--- a/optimizerDuck/Common/Helpers/SystemRefreshService.cs+++ b/optimizerDuck/Common/Helpers/SystemRefreshService.cs@@ -21,7 +21,12 @@ internal static class SystemRefreshService);[DllImport("shell32.dll", CharSet = CharSet.Auto)]- private static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);+ private static extern void SHChangeNotify(+ uint wEventId,+ uint uFlags,+ IntPtr dwItem1,+ IntPtr dwItem2+ );private static readonly IntPtr HWND_BROADCAST = new(0xffff);private const uint WM_SETTINGCHANGE = 0x001A;@@ -61,13 +66,15 @@ internal static class SystemRefreshService/// </summary>public static void RestartExplorer(){- Process.Start(new ProcessStartInfo- {- FileName = "cmd.exe",- Arguments = "/c taskkill /f /im explorer.exe && start explorer.exe",- CreateNoWindow = true,- UseShellExecute = false,- });+ Process.Start(+ new ProcessStartInfo+ {+ FileName = "cmd.exe",+ Arguments = "/c taskkill /f /im explorer.exe && start explorer.exe",+ CreateNoWindow = true,+ UseShellExecute = false,+ }+ );}/// <summary>@@ -77,13 +84,15 @@ internal static class SystemRefreshService{return Task.Run(() =>{- Process.Start(new ProcessStartInfo- {- FileName = "cmd.exe",- Arguments = "/c taskkill /f /im explorer.exe && start explorer.exe",- CreateNoWindow = true,- UseShellExecute = false,- });+ Process.Start(+ new ProcessStartInfo+ {+ FileName = "cmd.exe",+ Arguments = "/c taskkill /f /im explorer.exe && start explorer.exe",+ CreateNoWindow = true,+ UseShellExecute = false,+ }+ );});}}diff --git a/optimizerDuck/Domain/Customize/Categories/Gaming.cs b/optimizerDuck/Domain/Customize/Categories/Gaming.csindex 40204bf..b6769f3 100644--- a/optimizerDuck/Domain/Customize/Categories/Gaming.cs+++ b/optimizerDuck/Domain/Customize/Categories/Gaming.cs@@ -172,9 +172,7 @@ public class Gaming : ICustomizeCategoryreturn Task.Run(() =>{// Mouse acceleration is ON if any of the values are non-zero- var mouseSpeed = RegistryService.Read<string>(- new RegistryItem(Path, "MouseSpeed")- );+ var mouseSpeed = RegistryService.Read<string>(new RegistryItem(Path, "MouseSpeed"));var threshold1 = RegistryService.Read<string>(new RegistryItem(Path, "MouseThreshold1"));diff --git a/optimizerDuck/Domain/Customize/Categories/Preferences.cs b/optimizerDuck/Domain/Customize/Categories/Preferences.csindex f47e31b..722c19d 100644--- a/optimizerDuck/Domain/Customize/Categories/Preferences.cs+++ b/optimizerDuck/Domain/Customize/Categories/Preferences.cs@@ -27,7 +27,10 @@ public class Preferences : ICustomizeCategorypublic CustomizeOrder Order { get; init; } = CustomizeOrder.UserExperience;public ObservableCollection<ICustomizeSetting> Features { get; init; } = [];- [CustomizeSetting(Section = nameof(Sections.Taskbar), Icon = SymbolRegular.TextAlignDistributedEvenly24)]+ [CustomizeSetting(+ Section = nameof(Sections.Taskbar),+ Icon = SymbolRegular.TextAlignDistributedEvenly24+ )]public class TaskbarAlignment : BaseCustomizeSetting{private const string RegPath =@@ -38,10 +41,7 @@ public class Preferences : ICustomizeCategorypublic override CustomizeControlType ControlType => CustomizeControlType.Dropdown;public override IReadOnlyList<SettingOption>? Options =>- [- Option("Center", 1),- Option("Left", 0),- ];+ [Option("Center", 1), Option("Left", 0)];public override object? CurrentValue =>RegistryService.Read<object>(new RegistryItem(RegPath, RegName));diff --git a/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.cs b/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.csindex e0e085e..a0083ff 100644--- a/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.cs+++ b/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.cs@@ -13,13 +13,17 @@ public abstract class BaseCustomizeSetting : ICustomizeSettingprivate CustomizeSettingAttribute? _meta;private CustomizeSettingAttribute Meta =>- _meta ??= GetType().GetCustomAttribute<CustomizeSettingAttribute>()- ?? throw new InvalidOperationException($"{GetType().Name} is missing [CustomizeSetting] attribute");+ _meta ??=+ GetType().GetCustomAttribute<CustomizeSettingAttribute>()+ ?? throw new InvalidOperationException(+ $"{GetType().Name} is missing [CustomizeSetting] attribute"+ );public Type? OwnerType { get; set; }public string OwnerKey =>- OwnerType?.Name ?? throw new InvalidOperationException($"{GetType().Name} has no owner assigned");+ OwnerType?.Name+ ?? throw new InvalidOperationException($"{GetType().Name} has no owner assigned");public string FeatureKey => GetType().Name;public SymbolRegular Icon => Meta.Icon;diff --git a/optimizerDuck/Domain/Customize/Models/SettingOption.cs b/optimizerDuck/Domain/Customize/Models/SettingOption.csindex 44fd6ad..d1ad9a0 100644--- a/optimizerDuck/Domain/Customize/Models/SettingOption.cs+++ b/optimizerDuck/Domain/Customize/Models/SettingOption.cs@@ -1,6 +1,3 @@namespace optimizerDuck.Domain.Customize.Models;-public sealed record SettingOption(- string DisplayName,- object Value-);+public sealed record SettingOption(string DisplayName, object Value);diff --git a/optimizerDuck/Domain/Execution/ExecutionScope.cs b/optimizerDuck/Domain/Execution/ExecutionScope.csindex 5712a1b..986333b 100644--- a/optimizerDuck/Domain/Execution/ExecutionScope.cs+++ b/optimizerDuck/Domain/Execution/ExecutionScope.cs@@ -311,8 +311,10 @@ public sealed class ExecutionScope : IDisposablepublic ApplyResult ToApplyResult(){var result = ToResult();- return result.Status is OptimizationSuccessResult.Success- or OptimizationSuccessResult.PartialSuccess+ return+ result.Status+ is OptimizationSuccessResult.Success+ or OptimizationSuccessResult.PartialSuccess? ApplyResult.True(): ApplyResult.False(result.Message);}@@ -348,10 +350,7 @@ public sealed class ExecutionScope : IDisposableOptimizationName,failedSteps.Count),- _ => string.Format(- Translations.Optimization_Apply_Error_Unknown,- OptimizationName- ),+ _ => string.Format(Translations.Optimization_Apply_Error_Unknown, OptimizationName),},FailedSteps = failedSteps,};diff --git a/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.cs b/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.csindex cedbfde..0bd57eb 100644--- a/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.cs+++ b/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.cs@@ -141,9 +141,7 @@ public class PowerManagement : IOptimizationCategory[Optimization(Id = "EE71E993-EE41-4449-8856-84B09B2B0C46",Risk = OptimizationRisk.Safe,- Tags = OptimizationTags.Latency- | OptimizationTags.Performance- | OptimizationTags.Power+ Tags = OptimizationTags.Latency | OptimizationTags.Performance | OptimizationTags.Power)]public class InstallOptimizerDuckPowerPlan : BaseOptimization{@@ -168,11 +166,23 @@ public class PowerManagement : IOptimizationCategoryvar previousPlanGuid = match.Groups[1].Value;context.Logger.LogInformation("Current active power plan: {Guid}", previousPlanGuid);- var powerPlanPath = Path.Combine(Shared.AssetsDirectory, "PowerPlans", "optimizerDuck.pow");- if (!EmbeddedResourceHelper.TryExtract("PowerPlans.optimizerDuck.pow", powerPlanPath, true))+ var powerPlanPath = Path.Combine(+ Shared.AssetsDirectory,+ "PowerPlans",+ "optimizerDuck.pow"+ );+ if (+ !EmbeddedResourceHelper.TryExtract(+ "PowerPlans.optimizerDuck.pow",+ powerPlanPath,+ true+ )+ ){context.Logger.LogError("Failed to extract embedded power plan");- return ApplyResult.False("Failed to extract optimizerDuck power plan from resources.");+ return ApplyResult.False(+ "Failed to extract optimizerDuck power plan from resources."+ );}context.Logger.LogInformation("Extracted power plan to {Path}", powerPlanPath);diff --git a/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.cs b/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.csindex 8676efd..abe090c 100644--- a/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.cs+++ b/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.cs@@ -232,7 +232,6 @@ public class SecurityAndPrivacy : IOptimizationCategoryOptimizationContext context){-// @formatter:offRegistryService.Write(new RegistryItem(diff --git a/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs b/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.csindex 5fa9607..8ae1435 100644--- a/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs+++ b/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs@@ -77,10 +77,7 @@ public class RegistryRevertStep : IRevertStepTranslations.Revert_Registry_Description_RestoreKey,Path),- _ => string.Format(- Translations.Revert_Registry_Description_RevertUnknown,- Path- ),+ _ => string.Format(Translations.Revert_Registry_Description_RevertUnknown, Path),};/// <inheritdoc />diff --git a/optimizerDuck/Services/Revert/RevertManager.cs b/optimizerDuck/Services/Revert/RevertManager.csindex 7334c9e..73cf0cf 100644--- a/optimizerDuck/Services/Revert/RevertManager.cs+++ b/optimizerDuck/Services/Revert/RevertManager.cs@@ -323,9 +323,7 @@ public class RevertManager(ILogger<RevertManager> _logger, ILoggerFactory _loggeif (Guid.TryParse(fileName, out var id))return id;}- catch- {- }+ catch { }return null;}@@ -401,7 +399,11 @@ public class RevertManager(ILogger<RevertManager> _logger, ILoggerFactory _logge{if (stepData!.Index <= 0){- _logger.LogWarning("Skipping step with invalid index {Index} in revert data for {Id}", stepData.Index, id);+ _logger.LogWarning(+ "Skipping step with invalid index {Index} in revert data for {Id}",+ stepData.Index,+ id+ );continue;}diff --git a/optimizerDuck/Services/System/RegistryWatcher.cs b/optimizerDuck/Services/System/RegistryWatcher.csindex 7994fd3..011b52a 100644--- a/optimizerDuck/Services/System/RegistryWatcher.cs+++ b/optimizerDuck/Services/System/RegistryWatcher.cs@@ -15,7 +15,9 @@ internal sealed class RegistryWatcher(ILogger<RegistryWatcher> logger) : IRegist{public event EventHandler<string>? RegistryKeyChanged;- private readonly ConcurrentDictionary<string, PathWatcher> _watchers = new(StringComparer.OrdinalIgnoreCase);+ private readonly ConcurrentDictionary<string, PathWatcher> _watchers = new(+ StringComparer.OrdinalIgnoreCase+ );private bool _disposed;public void Watch(string registryPath)@@ -116,16 +118,23 @@ internal sealed class RegistryWatcher(ILogger<RegistryWatcher> logger) : IRegistreturn;var (hive, subKey) = ParseRegistryPath(_path);- var error = NativeMethods.RegOpenKeyEx(hive, subKey, 0, NativeMethods.KEY_NOTIFY, out _hKey);+ var error = NativeMethods.RegOpenKeyEx(+ hive,+ subKey,+ 0,+ NativeMethods.KEY_NOTIFY,+ out _hKey+ );if (error == 0 && _hKey != IntPtr.Zero){_event = new AutoResetEvent(false);-+NativeMethods.RegNotifyChangeKeyValue(_hKey,false,- NativeMethods.REG_NOTIFY_CHANGE_LAST_SET | NativeMethods.REG_NOTIFY_CHANGE_NAME,+ NativeMethods.REG_NOTIFY_CHANGE_LAST_SET+ | NativeMethods.REG_NOTIFY_CHANGE_NAME,_event.SafeWaitHandle.DangerousGetHandle(),true);@@ -146,7 +155,11 @@ internal sealed class RegistryWatcher(ILogger<RegistryWatcher> logger) : IRegist}catch (Exception ex){- _logger.LogWarning(ex, "RegistryWatcher: Failed to watch {Path}, retrying", _path);+ _logger.LogWarning(+ ex,+ "RegistryWatcher: Failed to watch {Path}, retrying",+ _path+ );try{await Task.Delay(1000, token);@@ -225,9 +238,10 @@ internal sealed class RegistryWatcher(ILogger<RegistryWatcher> logger) : IRegistprivate static (IntPtr hive, string subKey) ParseRegistryPath(string path){var firstBackslash = path.IndexOf('\\');- var root = firstBackslash > 0- ? path[..firstBackslash].ToUpperInvariant()- : path.ToUpperInvariant();+ var root =+ firstBackslash > 0+ ? path[..firstBackslash].ToUpperInvariant()+ : path.ToUpperInvariant();// Strip trailing colon for compatibility with RegistryService format (e.g. "HKLM:", "HKCU:")if (root.EndsWith(":"))@@ -242,7 +256,7 @@ internal sealed class RegistryWatcher(ILogger<RegistryWatcher> logger) : IRegist"HKEY_CLASSES_ROOT" or "HKCR" => NativeMethods.HKEY_CLASSES_ROOT,"HKEY_USERS" or "HKU" => NativeMethods.HKEY_USERS,"HKEY_CURRENT_CONFIG" or "HKCC" => NativeMethods.HKEY_CURRENT_CONFIG,- _ => throw new ArgumentException($"Unknown registry hive: {root}", nameof(path))+ _ => throw new ArgumentException($"Unknown registry hive: {root}", nameof(path)),};return (hive, subKey);diff --git a/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs b/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.csindex d518c73..6a0b392 100644--- a/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs+++ b/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs@@ -141,12 +141,12 @@ public static class SmoothScrollBehavior{for (var i = _attachedScrolls.Count - 1; i >= 0; i--){- if (_attachedScrolls[i].TryGetTarget(out var sv)- && _stateTable.TryGetValue(sv, out var state))+ if (+ _attachedScrolls[i].TryGetTarget(out var sv)+ && _stateTable.TryGetValue(sv, out var state)+ ){- sv.CanContentScroll = _globalEnabled- ? false- : state.PreviousCanContentScroll;+ sv.CanContentScroll = _globalEnabled ? false : state.PreviousCanContentScroll;}else{diff --git a/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.cs b/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.csindex 1ea6639..fffc8c4 100644--- a/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.cs+++ b/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.cs@@ -138,7 +138,11 @@ public partial class CustomizeItemViewModel(}catch (Exception ex){- _logger.LogWarning(ex, "RegistryWatcher: failed to refresh state for {Setting}", setting.Name);+ _logger.LogWarning(+ ex,+ "RegistryWatcher: failed to refresh state for {Setting}",+ setting.Name+ );}});}@@ -207,9 +211,7 @@ public partial class CustomizeItemViewModel(QueueApplyValue(value);}- catch (TaskCanceledException)- {- }+ catch (TaskCanceledException) { }}private async Task ProcessPendingValuesAsync()@@ -247,7 +249,7 @@ public partial class CustomizeItemViewModel(}IsEnabled = await setting.GetStateWithRetryAsync();-+if (ControlType != CustomizeControlType.Toggle){CurrentValue = setting.CurrentValue;diff --git a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.csindex 7f65728..4808bc0 100644--- a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs+++ b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs@@ -98,7 +98,6 @@ public partial class OptimizationCategoryViewModel : ViewModel[ObservableProperty]private int _selectedSortByIndex; // 0=Risk & Status, 1=Name, 2=Risk, 3=Status-#endregion#region Filter & Searchdiff --git a/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.csindex 207de16..cb0b9a7 100644--- a/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.cs+++ b/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.cs@@ -9,9 +9,9 @@ using CommunityToolkit.Mvvm.Input;using Microsoft.Extensions.Logging;using optimizerDuck.Common.Helpers;using optimizerDuck.Domain.Abstractions;-using optimizerDuck.Services;using optimizerDuck.Domain.Customize.Models;using optimizerDuck.Resources.Languages;+using optimizerDuck.Services;using optimizerDuck.UI.ViewModels.Customize;using Wpf.Ui.Appearance;using Wpf.Ui.Controls;@@ -23,7 +23,10 @@ public partial class CustomizeCategoryViewModel : ViewModel#region Cache & Constantsprivate static readonly HttpClient httpClient = new() { Timeout = TimeSpan.FromSeconds(5) };- private static readonly ConcurrentDictionary<string, (string Content, DateTime FetchedAt)> _sourceCache = new();+ private static readonly ConcurrentDictionary<+ string,+ (string Content, DateTime FetchedAt)+ > _sourceCache = new();private static readonly TimeSpan SourceCacheTtl = TimeSpan.FromMinutes(5);#endregion@@ -173,7 +176,10 @@ public partial class CustomizeCategoryViewModel : ViewModelif (itemViewModel is null)return;- if (itemViewModel.Setting is not BaseCustomizeSetting baseSetting || baseSetting.OwnerType == null)+ if (+ itemViewModel.Setting is not BaseCustomizeSetting baseSetting+ || baseSetting.OwnerType == null+ )return;var fileName = baseSetting.OwnerType.Name;@@ -184,10 +190,14 @@ public partial class CustomizeCategoryViewModel : ViewModeltry{- var rawUrl = $"https://raw.githubusercontent.com/itsfatduck/optimizerDuck/master/{relativePath}";+ var rawUrl =+ $"https://raw.githubusercontent.com/itsfatduck/optimizerDuck/master/{relativePath}";string source;- if (_sourceCache.TryGetValue(rawUrl, out var cached) && DateTime.UtcNow - cached.FetchedAt < SourceCacheTtl)+ if (+ _sourceCache.TryGetValue(rawUrl, out var cached)+ && DateTime.UtcNow - cached.FetchedAt < SourceCacheTtl+ ){source = cached.Content;}@@ -200,7 +210,13 @@ public partial class CustomizeCategoryViewModel : ViewModelvar lines = source.Split('\n');for (var i = 0; i < lines.Length; i++){- if (lines[i].Contains($"class {className} : {nameof(BaseCustomizeSetting)}", StringComparison.OrdinalIgnoreCase))+ if (+ lines[i]+ .Contains(+ $"class {className} : {nameof(BaseCustomizeSetting)}",+ StringComparison.OrdinalIgnoreCase+ )+ ){url += $"#L{i + 1}";break;@@ -209,7 +225,9 @@ public partial class CustomizeCategoryViewModel : ViewModel}catch (Exception ex){- System.Diagnostics.Debug.WriteLine($"Could not fetch source to find line number for {className}: {ex.Message}");+ System.Diagnostics.Debug.WriteLine(+ $"Could not fetch source to find line number for {className}: {ex.Message}"+ );}try@@ -218,7 +236,9 @@ public partial class CustomizeCategoryViewModel : ViewModel}catch (Exception ex){- System.Diagnostics.Debug.WriteLine($"Failed to open GitHub URL: {url}. Error: {ex.Message}");+ System.Diagnostics.Debug.WriteLine(+ $"Failed to open GitHub URL: {url}. Error: {ex.Message}"+ );}}}