Free, open-source Windows optimization tool for performance, privacy, and simplicity.
C# csharpdebloatdotnetgamingopen-sourceoptimizationoptimizeroptimizerduckperformanceprivacytweakertweakswindowswinui
refactor(xml-docs): add XML documentation for services, models
fatDuck583b30dd7547
diff --git a/optimizerDuck/Core/Models/Bloatware/AppXPackage.cs b/optimizerDuck/Core/Models/Bloatware/AppXPackage.csindex 8ed4034..09db097 100644--- a/optimizerDuck/Core/Models/Bloatware/AppXPackage.cs+++ b/optimizerDuck/Core/Models/Bloatware/AppXPackage.cs@@ -5,6 +5,9 @@ using Wpf.Ui.Controls;namespace optimizerDuck.Core.Models.Bloatware;+/// <summary>+/// Specifies the risk level of removing a bloatware app.+/// </summary>public enum AppRisk{Safe,@@ -12,18 +15,48 @@ public enum AppRiskUnknown}+/// <summary>+/// Represents an AppX package (UWP app) that can be removed.+/// </summary>public partial class AppXPackage : ObservableObject{+ /// <summary>+ /// Indicates whether this package is selected for removal.+ /// </summary>[ObservableProperty] private bool _isSelected;+ /// <summary>+ /// Path to the package's logo image.+ /// </summary>public string? LogoImage { get; set; }+ /// <summary>+ /// Display name of the app.+ /// </summary>public required string Name { get; init; }+ /// <summary>+ /// The full package name.+ /// </summary>public required string PackageFullName { get; init; }+ /// <summary>+ /// The publisher of the app.+ /// </summary>public required string Publisher { get; init; }+ /// <summary>+ /// The version of the app.+ /// </summary>public required string Version { get; init; }+ /// <summary>+ /// The installation location of the app.+ /// </summary>public required string InstallLocation { get; init; }+ /// <summary>+ /// The risk level of removing this app.+ /// </summary>public AppRisk Risk { get; init; }+ /// <summary>+ /// Gets the visual representation of the risk level for UI display.+ /// </summary>public RiskVisual RiskVisual => Risk switch{AppRisk.Safe => new RiskVisual@@ -43,5 +76,8 @@ public partial class AppXPackage : ObservableObject}};+ /// <summary>+ /// Indicates whether the risk should be visible in the UI.+ /// </summary>public bool ShouldVisibleRisk => Risk != AppRisk.Unknown;}\ No newline at end of filediff --git a/optimizerDuck/Core/Models/Cleanup/CleanupItem.cs b/optimizerDuck/Core/Models/Cleanup/CleanupItem.csindex ff63a33..8c58044 100644--- a/optimizerDuck/Core/Models/Cleanup/CleanupItem.cs+++ b/optimizerDuck/Core/Models/Cleanup/CleanupItem.cs@@ -3,19 +3,55 @@ using Wpf.Ui.Controls;namespace optimizerDuck.Core.Models.Cleanup;+/// <summary>+/// Represents a disk cleanup item (e.g., temp files, Windows Update cache).+/// </summary>public partial class CleanupItem : ObservableObject{+ /// <summary>+ /// The number of files in this cleanup item.+ /// </summary>[ObservableProperty] private long _fileCount;+ /// <summary>+ /// Indicates whether cleanup is in progress.+ /// </summary>[ObservableProperty] private bool _isCleaning;+ /// <summary>+ /// Indicates whether this item has been scanned.+ /// </summary>[ObservableProperty] private bool _isScanned;+ /// <summary>+ /// Indicates whether scanning is in progress.+ /// </summary>[ObservableProperty] private bool _isScanning;+ /// <summary>+ /// Indicates whether this item is selected for cleanup.+ /// </summary>[ObservableProperty] private bool _isSelected = true;+ /// <summary>+ /// The size of files in bytes.+ /// </summary>[ObservableProperty] private long _sizeBytes;+ /// <summary>+ /// Unique identifier for this cleanup item.+ /// </summary>public required string Id { get; init; }+ /// <summary>+ /// Display name of the cleanup item.+ /// </summary>public required string Name { get; init; }+ /// <summary>+ /// Description of what this cleanup item contains.+ /// </summary>public required string Description { get; init; }+ /// <summary>+ /// The file path or folder to clean.+ /// </summary>public required string Path { get; init; }+ /// <summary>+ /// The icon to display in the UI.+ /// </summary>public required SymbolRegular Icon { get; init; }/// <summary>@@ -23,6 +59,9 @@ public partial class CleanupItem : ObservableObject/// </summary>public bool IsCommand { get; init; }+ /// <summary>+ /// Gets the human-readable size string (e.g., "1.5 GB").+ /// </summary>public string FormattedSize => FormatBytes(SizeBytes);partial void OnSizeBytesChanged(long value)@@ -30,6 +69,9 @@ public partial class CleanupItem : ObservableObjectOnPropertyChanged(nameof(FormattedSize));}+ /// <summary>+ /// Formats bytes into a human-readable string.+ /// </summary>public static string FormatBytes(long bytes){return bytes switchdiff --git a/optimizerDuck/Core/Models/Config/AppSettings.cs b/optimizerDuck/Core/Models/Config/AppSettings.csindex 4f7e09a..df56fe1 100644--- a/optimizerDuck/Core/Models/Config/AppSettings.cs+++ b/optimizerDuck/Core/Models/Config/AppSettings.cs@@ -1,24 +1,57 @@namespace optimizerDuck.Core.Models.Config;+/// <summary>+/// Application settings that can be persisted to disk.+/// </summary>public sealed class AppSettings{+ /// <summary>+ /// General application settings.+ /// </summary>public AppOptions App { get; set; } = new();+ /// <summary>+ /// Optimization-related settings.+ /// </summary>public OptimizeOptions Optimize { get; set; } = new();+ /// <summary>+ /// Bloatware removal settings.+ /// </summary>public BloatwareOptions Bloatware { get; set; } = new();+ /// <summary>+ /// General application options.+ /// </summary>public sealed class AppOptions{+ /// <summary>+ /// The UI language code (e.g., "en-US").+ /// </summary>public string Language { get; set; } = "en-US";+ /// <summary>+ /// The UI theme (e.g., "Dark").+ /// </summary>public string Theme { get; set; } = "Dark";}+ /// <summary>+ /// Optimization-related options.+ /// </summary>public sealed class OptimizeOptions{+ /// <summary>+ /// Timeout in milliseconds for shell command execution.+ /// </summary>public int ShellTimeoutMs { get; set; } = 120000;}+ /// <summary>+ /// Bloatware removal options.+ /// </summary>public sealed class BloatwareOptions{+ /// <summary>+ /// Whether to remove provisioned AppX packages.+ /// </summary>public bool RemoveProvisioned { get; set; } = true;}}\ No newline at end of filediff --git a/optimizerDuck/Core/Models/Optimization/ApplyResult.cs b/optimizerDuck/Core/Models/Optimization/ApplyResult.csindex e2ac27e..06e7f2c 100644--- a/optimizerDuck/Core/Models/Optimization/ApplyResult.cs+++ b/optimizerDuck/Core/Models/Optimization/ApplyResult.cs@@ -1,12 +1,21 @@namespace optimizerDuck.Core.Models.Optimization;+/// <summary>+/// Represents the result of applying a single optimization step.+/// </summary>public readonly record struct ApplyResult(string? Message){+ /// <summary>+ /// Creates a successful result.+ /// </summary>public static ApplyResult True(){return new ApplyResult(null);}+ /// <summary>+ /// Creates a failed result with an error message.+ /// </summary>public static ApplyResult False(string message){return new ApplyResult(message);diff --git a/optimizerDuck/Core/Models/Optimization/OperationStepResult.cs b/optimizerDuck/Core/Models/Optimization/OperationStepResult.csindex 83e1d63..d90f38b 100644--- a/optimizerDuck/Core/Models/Optimization/OperationStepResult.cs+++ b/optimizerDuck/Core/Models/Optimization/OperationStepResult.cs@@ -1,11 +1,32 @@namespace optimizerDuck.Core.Models.Optimization;+/// <summary>+/// Represents the result of a single operation step within an optimization.+/// </summary>public record OperationStepResult{+ /// <summary>+ /// The zero-based index of this step in the execution order.+ /// </summary>public int Index { get; init; }+ /// <summary>+ /// The name of the step.+ /// </summary>public string Name { get; init; } = string.Empty;+ /// <summary>+ /// A description of what this step does.+ /// </summary>public string Description { get; init; } = string.Empty;+ /// <summary>+ /// Indicates whether the step completed successfully.+ /// </summary>public bool Success { get; init; }+ /// <summary>+ /// The error message if the step failed.+ /// </summary>public string? Error { get; init; }+ /// <summary>+ /// An optional action to retry this step.+ /// </summary>public Func<Task<bool>>? RetryAction { get; init; }}\ No newline at end of filediff --git a/optimizerDuck/Core/Models/Optimization/OptimizationContext.cs b/optimizerDuck/Core/Models/Optimization/OptimizationContext.csindex ee62f06..5bf4078 100644--- a/optimizerDuck/Core/Models/Optimization/OptimizationContext.cs+++ b/optimizerDuck/Core/Models/Optimization/OptimizationContext.cs@@ -3,6 +3,9 @@ using optimizerDuck.Services;namespace optimizerDuck.Core.Models.Optimization;+/// <summary>+/// Provides context information for optimization execution.+/// </summary>public record OptimizationContext(ILogger Logger,SystemSnapshot Snapshot,diff --git a/optimizerDuck/Core/Models/Optimization/OptimizationResult.cs b/optimizerDuck/Core/Models/Optimization/OptimizationResult.csindex 26e2248..f8414f3 100644--- a/optimizerDuck/Core/Models/Optimization/OptimizationResult.cs+++ b/optimizerDuck/Core/Models/Optimization/OptimizationResult.cs@@ -2,10 +2,25 @@ using optimizerDuck.Core.Models.UI;namespace optimizerDuck.Core.Models.Optimization;+/// <summary>+/// Represents the result of an optimization apply operation.+/// </summary>public record OptimizationResult{+ /// <summary>+ /// The status of the operation (Success, PartialSuccess, or Failed).+ /// </summary>public OptimizationSuccessResult Status { get; init; }+ /// <summary>+ /// A message describing the result.+ /// </summary>public string Message { get; init; } = string.Empty;+ /// <summary>+ /// The exception that occurred, if any.+ /// </summary>public Exception? Exception { get; init; }+ /// <summary>+ /// List of steps that failed during the operation.+ /// </summary>public List<OperationStepResult> FailedSteps { get; init; } = [];}\ No newline at end of filediff --git a/optimizerDuck/Core/Models/Revert/RevertData.cs b/optimizerDuck/Core/Models/Revert/RevertData.csindex 10bb763..5f59a98 100644--- a/optimizerDuck/Core/Models/Revert/RevertData.cs+++ b/optimizerDuck/Core/Models/Revert/RevertData.cs@@ -2,16 +2,40 @@ using Newtonsoft.Json.Linq;namespace optimizerDuck.Core.Models.Revert;+/// <summary>+/// Represents a single revert step stored in JSON.+/// </summary>public class RevertStepData{+ /// <summary>+ /// The type of the revert step (e.g., "Registry", "Service", "Shell").+ /// </summary>public string Type { get; set; } = string.Empty;+ /// <summary>+ /// The serialized data for the step.+ /// </summary>public JObject Data { get; set; } = new();}+/// <summary>+/// Represents the persisted revert data for an optimization.+/// </summary>public class RevertData{+ /// <summary>+ /// The unique identifier of the optimization.+ /// </summary>public Guid OptimizationId { get; set; }+ /// <summary>+ /// The name of the optimization.+ /// </summary>public string OptimizationName { get; set; } = string.Empty;+ /// <summary>+ /// When the optimization was applied.+ /// </summary>public DateTime AppliedAt { get; set; }+ /// <summary>+ /// The list of revert steps.+ /// </summary>public List<RevertStepData> Steps { get; set; } = new();}\ No newline at end of filediff --git a/optimizerDuck/Core/Models/Revert/RevertResult.cs b/optimizerDuck/Core/Models/Revert/RevertResult.csindex 6a49b74..51551ac 100644--- a/optimizerDuck/Core/Models/Revert/RevertResult.cs+++ b/optimizerDuck/Core/Models/Revert/RevertResult.cs@@ -2,11 +2,26 @@ using optimizerDuck.Core.Models.Optimization;namespace optimizerDuck.Core.Models.Revert;+/// <summary>+/// Represents the result of a revert operation.+/// </summary>public class RevertResult{+ /// <summary>+ /// Indicates whether the revert was successful.+ /// </summary>public bool Success { get; set; }+ /// <summary>+ /// A message describing the result.+ /// </summary>public string Message { get; set; } = string.Empty;+ /// <summary>+ /// The exception that occurred, if any.+ /// </summary>public Exception? Exception { get; set; }+ /// <summary>+ /// Details of any steps that failed during revert.+ /// </summary>public List<OperationStepResult> FailedStepDetails { get; set; } = [];}\ No newline at end of filediff --git a/optimizerDuck/Core/Models/ScheduledTask/ScheduledTaskModel.cs b/optimizerDuck/Core/Models/ScheduledTask/ScheduledTaskModel.csindex 2012ec0..fe9f601 100644--- a/optimizerDuck/Core/Models/ScheduledTask/ScheduledTaskModel.cs+++ b/optimizerDuck/Core/Models/ScheduledTask/ScheduledTaskModel.cs@@ -4,48 +4,136 @@ using CommunityToolkit.Mvvm.ComponentModel;namespace optimizerDuck.Core.Models.ScheduledTask;+/// <summary>+/// Represents a Windows Scheduled Task.+/// </summary>public partial class ScheduledTaskModel : ObservableObject{+ /// <summary>+ /// Indicates whether the task is enabled.+ /// </summary>[ObservableProperty] private bool _isEnabled;+ /// <summary>+ /// The current state of the task (e.g., "Ready", "Running", "Disabled").+ /// </summary>[ObservableProperty] private string _state = string.Empty;+ /// <summary>+ /// The logo image of the task's executable.+ /// </summary>[ObservableProperty] private ImageSource? _logoImage;+ /// <summary>+ /// The name of the task.+ /// </summary>public required string Name { get; init; }+ /// <summary>+ /// The folder path of the task.+ /// </summary>public required string Path { get; init; }+ /// <summary>+ /// The full path to the task.+ /// </summary>public required string FullPath { get; init; }+ /// <summary>+ /// Description of the task.+ /// </summary>public string? Description { get; init; }+ /// <summary>+ /// The author of the task.+ /// </summary>public string? Author { get; init; }+ /// <summary>+ /// Summary of when the task triggers.+ /// </summary>public string TriggerSummary { get; init; } = string.Empty;+ /// <summary>+ /// Summary of the task's action.+ /// </summary>public string ActionSummary { get; init; } = string.Empty;- /// <summary>Individual trigger type strings for badge display (e.g. "At log on", "At startup", "Daily at 09:00").</summary>+ /// <summary>+ /// Individual trigger type strings for badge display (e.g. "At log on", "At startup", "Daily at 09:00").+ /// </summary>public ObservableCollection<string> TriggerTypes { get; init; } = [];+ /// <summary>+ /// The last time the task ran.+ /// </summary>public DateTime? LastRunTime { get; init; }+ /// <summary>+ /// The next scheduled run time.+ /// </summary>public DateTime? NextRunTime { get; init; }+ /// <summary>+ /// The result code of the last run.+ /// </summary>public int? LastRunResult { get; init; }+ /// <summary>+ /// Indicates whether this is a Microsoft system task.+ /// </summary>public bool IsMicrosoftTask => Path.StartsWith(@"\Microsoft\", StringComparison.OrdinalIgnoreCase);+ /// <summary>+ /// Indicates whether the task has a logon trigger.+ /// </summary>public bool HasLogonTrigger { get; init; }+ /// <summary>+ /// Indicates whether the task has a boot trigger.+ /// </summary>public bool HasBootTrigger { get; init; }// New expanded creation properties+ /// <summary>+ /// The executable path for the task's action.+ /// </summary>public string ExecutablePath { get; init; } = string.Empty;+ /// <summary>+ /// Arguments passed to the executable.+ /// </summary>public string Arguments { get; init; } = string.Empty;+ /// <summary>+ /// Indicates whether the task has an idle trigger.+ /// </summary>public bool HasIdleTrigger { get; init; }+ /// <summary>+ /// Indicates whether the task has a registration trigger.+ /// </summary>public bool HasRegistrationTrigger { get; init; }+ /// <summary>+ /// Indicates whether the task has a daily trigger.+ /// </summary>public bool HasDailyTrigger { get; init; }+ /// <summary>+ /// The time of day for daily triggers.+ /// </summary>public TimeSpan DailyTriggerTime { get; init; }+ /// <summary>+ /// Indicates whether the task runs with highest privileges.+ /// </summary>public bool RunWithHighestPrivileges { get; init; }+ /// <summary>+ /// Indicates whether the task is hidden.+ /// </summary>public bool Hidden { get; init; }// Computed state helpers for UI binding+ /// <summary>+ /// Indicates whether the task is currently running.+ /// </summary>public bool IsRunning => State.Equals("Running", StringComparison.OrdinalIgnoreCase);+ /// <summary>+ /// Indicates whether the task is ready to run.+ /// </summary>public bool IsReady => State.Equals("Ready", StringComparison.OrdinalIgnoreCase);+ /// <summary>+ /// Indicates whether the task is in a disabled state.+ /// </summary>public bool IsDisabledState => State.Equals("Disabled", StringComparison.OrdinalIgnoreCase);- /// <summary>Notifies UI that computed state properties have changed.</summary>+ /// <summary>+ /// Notifies UI that computed state properties have changed.+ /// </summary>public void NotifyStateChanged(){OnPropertyChanged(nameof(IsRunning));diff --git a/optimizerDuck/Core/Models/StartupManager/StartupApp.cs b/optimizerDuck/Core/Models/StartupManager/StartupApp.csindex 1e2a229..f1bbfcc 100644--- a/optimizerDuck/Core/Models/StartupManager/StartupApp.cs+++ b/optimizerDuck/Core/Models/StartupManager/StartupApp.cs@@ -4,6 +4,9 @@ using CommunityToolkit.Mvvm.ComponentModel;namespace optimizerDuck.Core.Models.StartupManager;+/// <summary>+/// Specifies the location of a startup application.+/// </summary>public enum StartupAppLocation{RegistryHKCURun,@@ -14,19 +17,49 @@ public enum StartupAppLocationCommonStartupFolder}+/// <summary>+/// Represents an application that runs at Windows startup.+/// </summary>public partial class StartupApp : ObservableObject{+ /// <summary>+ /// Indicates whether this startup entry is enabled.+ /// </summary>[ObservableProperty] private bool _isEnabled;+ /// <summary>+ /// The logo image of the application.+ /// </summary>[ObservableProperty] private ImageSource? _logoImage;+ /// <summary>+ /// The display name of the startup application.+ /// </summary>public required string Name { get; init; }+ /// <summary>+ /// The publisher or company name.+ /// </summary>[ObservableProperty] private string _publisher = string.Empty;+ /// <summary>+ /// The command that runs the application.+ /// </summary>[ObservableProperty] private string _command = string.Empty;+ /// <summary>+ /// Where this startup entry is located.+ /// </summary>public required StartupAppLocation Location { get; init; }+ /// <summary>+ /// The registry key path or folder path.+ /// </summary>public required string PathOrKey { get; init; }+ /// <summary>+ /// The original value name (registry) or file name (folder).+ /// </summary>[ObservableProperty] private string _originalValueNameOrFileName = string.Empty;private string? _filePath;+ /// <summary>+ /// The actual file path of the executable.+ /// </summary>public string? FilePath{get => _filePath;@@ -39,8 +72,14 @@ public partial class StartupApp : ObservableObject}}+ /// <summary>+ /// Indicates whether the file location can be opened.+ /// </summary>public bool CanOpenLocation => !string.IsNullOrEmpty(FilePath) && File.Exists(FilePath);+ /// <summary>+ /// Gets a human-readable string for the location.+ /// </summary>public string LocationDisplay => Location switch{StartupAppLocation.RegistryHKCURun => "Registry (Current User)",diff --git a/optimizerDuck/Core/Models/StartupManager/StartupTask.cs b/optimizerDuck/Core/Models/StartupManager/StartupTask.csindex 673b8c6..e6afedc 100644--- a/optimizerDuck/Core/Models/StartupManager/StartupTask.cs+++ b/optimizerDuck/Core/Models/StartupManager/StartupTask.cs@@ -3,16 +3,47 @@ using CommunityToolkit.Mvvm.ComponentModel;namespace optimizerDuck.Core.Models.StartupManager;+/// <summary>+/// Represents a scheduled task that runs at startup.+/// </summary>public partial class StartupTask : ObservableObject{+ /// <summary>+ /// Indicates whether the task is enabled.+ /// </summary>[ObservableProperty] private bool _isEnabled;+ /// <summary>+ /// The logo image of the task's executable.+ /// </summary>[ObservableProperty] private ImageSource? _logoImage;+ /// <summary>+ /// The name of the scheduled task.+ /// </summary>public required string TaskName { get; init; }+ /// <summary>+ /// The path to the task in Task Scheduler.+ /// </summary>public required string TaskPath { get; init; }+ /// <summary>+ /// Description of the task.+ /// </summary>public string? Description { get; init; }+ /// <summary>+ /// Summary of when the task triggers.+ /// </summary>public string? TriggerSummary { get; init; }+ /// <summary>+ /// The types of triggers (e.g., "At logon", "At startup").+ /// </summary>public List<string> TriggerTypes { get; init; } = [];+ /// <summary>+ /// Summary of what the task does.+ /// </summary>public string? ActionSummary { get; init; }++ /// <summary>+ /// Indicates whether this is a Microsoft system task.+ /// </summary>public bool IsMicrosoftTask => TaskPath.StartsWith(@"\Microsoft\", StringComparison.OrdinalIgnoreCase);}\ No newline at end of filediff --git a/optimizerDuck/Core/Models/UI/OptimizationRisk.cs b/optimizerDuck/Core/Models/UI/OptimizationRisk.csindex be4b68e..28252ec 100644--- a/optimizerDuck/Core/Models/UI/OptimizationRisk.cs+++ b/optimizerDuck/Core/Models/UI/OptimizationRisk.cs@@ -1,5 +1,8 @@namespace optimizerDuck.Core.Models.UI;+/// <summary>+/// Specifies the risk level associated with an optimization.+/// </summary>public enum OptimizationRisk{Safe,diff --git a/optimizerDuck/Core/Models/UI/OptimizationState.cs b/optimizerDuck/Core/Models/UI/OptimizationState.csindex 01e7044..03457af 100644--- a/optimizerDuck/Core/Models/UI/OptimizationState.cs+++ b/optimizerDuck/Core/Models/UI/OptimizationState.cs@@ -5,6 +5,10 @@ using optimizerDuck.Resources.Languages;namespace optimizerDuck.Core.Models.UI;+/// <summary>+/// Tracks the applied state and timing of an optimization.+/// Provides relative time display (e.g., "Applied 5 minutes ago").+/// </summary>public partial class OptimizationState : ObservableObject{private static readonly DispatcherTimer _globalTimer;diff --git a/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.cs b/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.csindex 3524055..6b9f6cf 100644--- a/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.cs+++ b/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.cs@@ -1,5 +1,8 @@namespace optimizerDuck.Core.Models.UI;+/// <summary>+/// Indicates the result status of an optimization apply or revert operation.+/// </summary>public enum OptimizationSuccessResult{Success,diff --git a/optimizerDuck/Core/Models/UI/ProcessingProgress.cs b/optimizerDuck/Core/Models/UI/ProcessingProgress.csindex 4a4cb42..c4ad3be 100644--- a/optimizerDuck/Core/Models/UI/ProcessingProgress.cs+++ b/optimizerDuck/Core/Models/UI/ProcessingProgress.cs@@ -1,9 +1,24 @@namespace optimizerDuck.Core.Models.UI;+/// <summary>+/// Represents the progress of a long-running operation (e.g., optimization, cleanup).+/// </summary>public record ProcessingProgress{+ /// <summary>+ /// A message describing the current operation state.+ /// </summary>public string Message { get; init; } = string.Empty;+ /// <summary>+ /// Indicates whether the progress is indeterminate (unknown total).+ /// </summary>public bool IsIndeterminate { get; init; } = true;+ /// <summary>+ /// The current progress value.+ /// </summary>public int Value { get; init; }+ /// <summary>+ /// The total number of steps or items.+ /// </summary>public int Total { get; init; }}\ No newline at end of filediff --git a/optimizerDuck/Services/BloatwareService.cs b/optimizerDuck/Services/BloatwareService.csindex cc46cbc..c9f1866 100644--- a/optimizerDuck/Services/BloatwareService.cs+++ b/optimizerDuck/Services/BloatwareService.cs@@ -13,8 +13,15 @@ using JsonSerializer = System.Text.Json.JsonSerializer;namespace optimizerDuck.Services;+/// <summary>+/// Provides services for discovering and removing AppX bloatware packages.+/// </summary>public class BloatwareService(ILogger<BloatwareService> logger, IOptionsMonitor<AppSettings> appOptionsMonitor){+ /// <summary>+ /// Gets all removable AppX packages on the system.+ /// </summary>+ /// <returns>A list of AppX packages with their risk levels.</returns>public async Task<List<AppXPackage>> GetAppXPackagesAsync(){try@@ -84,6 +91,10 @@ public class BloatwareService(ILogger<BloatwareService> logger, IOptionsMonitor<}}+ /// <summary>+ /// Removes an AppX package from the system.+ /// </summary>+ /// <param name="appXPackage">The package to remove.</param>public async Task RemoveAppXPackage(AppXPackage appXPackage){using var tracker = ServiceTracker.Begin(logger);diff --git a/optimizerDuck/Services/DiskCleanupService.cs b/optimizerDuck/Services/DiskCleanupService.csindex 0d13265..0157533 100644--- a/optimizerDuck/Services/DiskCleanupService.cs+++ b/optimizerDuck/Services/DiskCleanupService.cs@@ -7,8 +7,15 @@ using Wpf.Ui.Controls;namespace optimizerDuck.Services;+/// <summary>+/// Provides services for cleaning up disk space (temp files, caches, etc.).+/// </summary>public class DiskCleanupService(ILogger<DiskCleanupService> logger){+ /// <summary>+ /// Gets the available cleanup items.+ /// </summary>+ /// <returns>A list of cleanup items.</returns>public static List<CleanupItem> GetCleanupItems(){var windowsDir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);@@ -76,6 +83,10 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)];}+ /// <summary>+ /// Scans a cleanup item to calculate its size and file count.+ /// </summary>+ /// <param name="item">The cleanup item to scan.</param>public async Task ScanAsync(CleanupItem item){item.IsScanning = true;@@ -132,11 +143,20 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)}}+ /// <summary>+ /// Scans all cleanup items in parallel.+ /// </summary>+ /// <param name="items">The items to scan.</param>public async Task ScanAllAsync(IEnumerable<CleanupItem> items){await Task.WhenAll(items.Select(ScanAsync));}+ /// <summary>+ /// Cleans a single cleanup item.+ /// </summary>+ /// <param name="item">The item to clean.</param>+ /// <returns>The number of bytes freed.</returns>public async Task<long> CleanAsync(CleanupItem item){item.IsCleaning = true;@@ -172,6 +192,11 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)return freedBytes;}+ /// <summary>+ /// Cleans all selected items.+ /// </summary>+ /// <param name="items">The items to clean.</param>+ /// <returns>The total number of bytes freed.</returns>public async Task<long> CleanSelectedAsync(IEnumerable<CleanupItem> items){long totalFreed = 0;diff --git a/optimizerDuck/Services/Managers/ConfigManager.cs b/optimizerDuck/Services/Managers/ConfigManager.csindex b97655c..4910088 100644--- a/optimizerDuck/Services/Managers/ConfigManager.cs+++ b/optimizerDuck/Services/Managers/ConfigManager.cs@@ -7,18 +7,39 @@ using optimizerDuck.Common.Helpers;namespace optimizerDuck.Services.Managers;+/// <summary>+ /// Manages application configuration settings stored in appsettings.json.+ /// </summary>public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager> logger){+ /// <summary>+ /// The path to the configuration file.+ /// </summary>private readonly string _configPath = Path.Combine(Shared.RootDirectory, "appsettings.json");++ /// <summary>+ /// Semaphore for thread-safe access to configuration data.+ /// </summary>private readonly SemaphoreSlim _lock = new(1, 1);++ /// <summary>+ /// Cached configuration data.+ /// </summary>private JObject _cache = new();+ /// <summary>+ /// Initializes the configuration manager by loading settings from disk.+ /// </summary>public async Task InitializeAsync(){_cache = await LoadConfigAsync();}-+ /// <summary>+ /// Sets a configuration value by key.+ /// </summary>+ /// <param name="key">The configuration key (e.g., "App:Language").</param>+ /// <param name="value">The value to set.</param>public async Task SetAsync(string key, string value){await _lock.WaitAsync();@@ -39,6 +60,10 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>}}+ /// <summary>+ /// Removes a configuration value by key.+ /// </summary>+ /// <param name="key">The configuration key to remove.</param>public async Task RemoveAsync(string key){await _lock.WaitAsync();@@ -63,11 +88,19 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>}}+ /// <summary>+ /// Removes a configuration value by key (synchronous wrapper).+ /// </summary>+ /// <param name="key">The configuration key to remove.</param>public void Remove(string key){_ = RemoveAsync(key);}+ /// <summary>+ /// Loads configuration from disk.+ /// </summary>+ /// <returns>The loaded configuration as a JObject.</returns>private async Task<JObject> LoadConfigAsync(){try@@ -90,6 +123,9 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>}}+ /// <summary>+ /// Saves the current configuration to disk.+ /// </summary>private async Task SaveConfigAsync(){await File.WriteAllTextAsync(@@ -99,6 +135,12 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>(configuration as IConfigurationRoot)?.Reload();}+ /// <summary>+ /// Gets a token by key (case-insensitive).+ /// </summary>+ /// <param name="obj">The JObject to search.</param>+ /// <param name="key">The key to find.</param>+ /// <returns>The matching token, or null if not found.</returns>private static JToken? GetTokenIgnoreCase(JObject obj, string key){var prop = obj.Properties()@@ -106,6 +148,12 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>return prop?.Value;}+ /// <summary>+ /// Gets or creates an object by key (case-insensitive).+ /// </summary>+ /// <param name="current">The current JObject.</param>+ /// <param name="key">The key to find or create.</param>+ /// <returns>The existing or newly created JObject.</returns>private static JObject GetOrCreateObjectIgnoreCase(JObject current, string key){JProperty? first = null;@@ -135,6 +183,12 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>return created;}+ /// <summary>+ /// Sets a value by key (case-insensitive).+ /// </summary>+ /// <param name="current">The current JObject.</param>+ /// <param name="key">The key to set.</param>+ /// <param name="value">The value to set.</param>private static void SetValueIgnoreCase(JObject current, string key, string value){// Remove all case-insensitive matches@@ -150,6 +204,11 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>current[key] = value;}+ /// <summary>+ /// Removes a value by key (case-insensitive).+ /// </summary>+ /// <param name="current">The current JObject.</param>+ /// <param name="key">The key to remove.</param>private static void RemoveIgnoreCase(JObject current, string key){var toRemove = new List<string>();@@ -160,6 +219,9 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>foreach (var name in toRemove) current.Remove(name);}+ /// <summary>+ /// Validates and ensures the config file exists and is valid JSON.+ /// </summary>public static void ValidateConfig(){var configPath = Path.Combine(Shared.RootDirectory, "appsettings.json");diff --git a/optimizerDuck/Services/Managers/LanguageManager.cs b/optimizerDuck/Services/Managers/LanguageManager.csindex 488389d..8ba2db8 100644--- a/optimizerDuck/Services/Managers/LanguageManager.cs+++ b/optimizerDuck/Services/Managers/LanguageManager.cs@@ -3,15 +3,33 @@ using optimizerDuck.Resources.Languages;namespace optimizerDuck.Services.Managers;+/// <summary>+ /// Provides localization and culture management for the application.+ /// </summary>public class Loc{+ /// <summary>+ /// Gets the singleton instance of the localization manager.+ /// </summary>public static Loc Instance { get; } = new();+ /// <summary>+ /// Gets the current culture information.+ /// </summary>public static CultureInfo CurrentCulture => Translations.Culture;+ /// <summary>+ /// Gets the localized string for the specified key.+ /// </summary>+ /// <param name="key">The resource key to look up.</param>+ /// <returns>The localized string or the key itself if not found.</returns>public string this[string key] =>Translations.ResourceManager.GetString(key, Translations.Culture) ?? key;+ /// <summary>+ /// Changes the current culture for localization.+ /// </summary>+ /// <param name="culture">The new culture to apply.</param>public void ChangeCulture(CultureInfo culture){Translations.Culture = culture;diff --git a/optimizerDuck/Services/Managers/RevertManager.cs b/optimizerDuck/Services/Managers/RevertManager.csindex a64e4ff..9711ba1 100644--- a/optimizerDuck/Services/Managers/RevertManager.cs+++ b/optimizerDuck/Services/Managers/RevertManager.cs@@ -11,12 +11,26 @@ using optimizerDuck.Resources.Languages;namespace optimizerDuck.Services.Managers;+/// <summary>+ /// Manages revert functionality for optimizations, allowing users to undo changes.+ /// </summary>public class RevertManager(ILogger<RevertManager> logger){+ /// <summary>+ /// Async local storage for the current revert context.+ /// </summary>private static readonly AsyncLocal<RevertContext?> _current = new();+ /// <summary>+ /// Gets the current revert context for the active async operation.+ /// </summary>public static RevertContext? Current => _current.Value;+ /// <summary>+ /// Begins recording revert steps for the specified optimization.+ /// </summary>+ /// <param name="optimization">The optimization being performed.</param>+ /// <returns>The created revert context.</returns>public RevertContext BeginRecording(IOptimization optimization){var context = new RevertContext(optimization, logger, this);@@ -24,6 +38,10 @@ public class RevertManager(ILogger<RevertManager> logger)return context;}+ /// <summary>+ /// Records a revert step to the current context.+ /// </summary>+ /// <param name="step">The revert step to record.</param>public static void Record(IRevertStep step){Current?.AddStep(step);diff --git a/optimizerDuck/Services/OptimizationService.cs b/optimizerDuck/Services/OptimizationService.csindex 6cca690..012706c 100644--- a/optimizerDuck/Services/OptimizationService.cs+++ b/optimizerDuck/Services/OptimizationService.cs@@ -17,6 +17,9 @@ using Wpf.Ui.Controls;namespace optimizerDuck.Services;+/// <summary>+/// Provides services for applying and reverting optimizations.+/// </summary>public class OptimizationService(RevertManager revertManager,ILoggerFactory loggerFactory,@@ -29,8 +32,18 @@ public class OptimizationService(private static readonly object _cacheLock = new();private readonly ILogger _logger = logger;+ /// <summary>+ /// Indicates whether a system restore point was requested before applying optimizations.+ /// </summary>public bool WasRequestedRestorePoint { get; set; } = false;+ /// <summary>+ /// Creates a Windows system restore point.+ /// </summary>+ /// <returns>+ /// A task that completes with a <see cref="RestorePointResult"/> indicating success,+ /// failure, or if the frequency limit was reached.+ /// </returns>public async Task<RestorePointResult> CreateRestorePointAsync(){var dialogViewModel = new ProcessingViewModel();@@ -137,6 +150,12 @@ public class OptimizationService(#region Main Methods+ /// <summary>+ /// Applies an optimization to the system.+ /// </summary>+ /// <param name="optimization">The optimization to apply.</param>+ /// <param name="progress">A progress reporter for UI updates.</param>+ /// <returns>A task that completes with the optimization result.</returns>public async Task<OptimizationResult> ApplyAsync(IOptimization optimization,IProgress<ProcessingProgress> progress){@@ -279,6 +298,12 @@ public class OptimizationService(}}+ /// <summary>+ /// Reverts a previously applied optimization.+ /// </summary>+ /// <param name="optimization">The optimization to revert.</param>+ /// <param name="progress">A progress reporter for UI updates (optional).</param>+ /// <returns>A task that completes with the revert result.</returns>public async Task<RevertResult> RevertAsync(IOptimization optimization,IProgress<ProcessingProgress>? progress = null){@@ -323,11 +348,20 @@ public class OptimizationService(#region Helpers+ /// <summary>+ /// Checks whether an optimization has been applied.+ /// </summary>+ /// <param name="optimizationId">The unique identifier of the optimization.</param>+ /// <returns>True if the optimization was applied; otherwise, false.</returns>public static Task<bool> IsAppliedAsync(Guid optimizationId){return RevertManager.IsAppliedAsync(optimizationId);}+ /// <summary>+ /// Updates the applied state for a collection of optimizations.+ /// </summary>+ /// <param name="optimizations">The optimizations to update.</param>public static async Task UpdateOptimizationStateAsync(params IOptimization[] optimizations){var optimizationIds = optimizations.Select(o => o.Id).ToArray();@@ -379,11 +413,22 @@ public class OptimizationService(}}+ /// <summary>+ /// Updates the applied state for a collection of optimizations.+ /// </summary>+ /// <param name="optimizations">The optimizations to update.</param>public static async Task UpdateOptimizationStateAsync(IEnumerable<IOptimization> optimizations){await UpdateOptimizationStateAsync(optimizations.ToArray());}+ /// <summary>+ /// Retries failed optimization steps.+ /// </summary>+ /// <param name="failedSteps">The steps that previously failed.</param>+ /// <param name="reverseOrder">Whether to execute steps in reverse order.</param>+ /// <param name="progress">A progress reporter for UI updates (optional).</param>+ /// <returns>A list of steps that still failed after retry.</returns>public static async Task<List<OperationStepResult>> RetryFailedStepsAsync(IReadOnlyList<OperationStepResult> failedSteps,bool reverseOrder,diff --git a/optimizerDuck/Services/SystemInfoService.cs b/optimizerDuck/Services/SystemInfoService.csindex 93c9b8e..363e6f2 100644--- a/optimizerDuck/Services/SystemInfoService.cs+++ b/optimizerDuck/Services/SystemInfoService.cs@@ -13,6 +13,9 @@ namespace optimizerDuck.Services;// MODELS (Immutable Records)// ============================================================================+/// <summary>+/// Specifies the GPU vendor manufacturer.+/// </summary>public enum GpuVendor{Unknown,@@ -21,6 +24,9 @@ public enum GpuVendorIntel}+/// <summary>+/// Represents information about a GPU.+/// </summary>public sealed record GpuInfo(string Name,string DriverVersion,@@ -40,6 +46,9 @@ public sealed record GpuInfo(}}+/// <summary>+/// Represents information about the CPU.+/// </summary>public sealed record CpuInfo(string Name,string Manufacturer,@@ -57,6 +66,9 @@ public sealed record CpuInfo(Translations.Common_Unknown, Translations.Common_Unknown, 0, 0, 0, 0, 0, 0);}+/// <summary>+/// Represents information about a disk volume.+/// </summary>public sealed record DiskVolume(string Letter,bool SystemDrive,@@ -73,6 +85,9 @@ public sealed record DiskVolume(string? Model);+/// <summary>+/// Represents information about all disk volumes.+/// </summary>public sealed record DiskInfo(IReadOnlyList<DiskVolume> Volumes)@@ -80,6 +95,9 @@ public sealed record DiskInfo(public static readonly DiskInfo Unknown = new([]);}+/// <summary>+/// Represents a physical RAM module.+/// </summary>public sealed record RamModule(double CapacityGB,string SpeedMHz,@@ -88,6 +106,9 @@ public sealed record RamModule(string DeviceLocator);+/// <summary>+/// Represents information about RAM.+/// </summary>public sealed record RamInfo(double TotalGB,long TotalMB,@@ -101,6 +122,9 @@ public sealed record RamInfo(public static readonly RamInfo Unknown = new(0, 0, 0, 0, 0, 0, []);}+/// <summary>+/// Represents information about the operating system.+/// </summary>public sealed record OsInfo(string Name,string Version,@@ -118,6 +142,9 @@ public sealed record OsInfo(Translations.Common_Unknown, Translations.Common_Unknown);}+/// <summary>+/// Represents information about the system BIOS.+/// </summary>public sealed record BiosInfo(string Manufacturer,string Version,@@ -130,6 +157,9 @@ public sealed record BiosInfo(Translations.Common_Unknown, Translations.Common_Unknown, Translations.Common_Unknown);}+/// <summary>+/// Represents a complete snapshot of the system's hardware and software information.+/// </summary>public sealed record SystemSnapshot(CpuInfo Cpu,RamInfo Ram,@@ -191,6 +221,13 @@ internal static class WmiHelper}}+ /// <summary>+ /// Gets an string property from a ManagementObject with fallback.+ /// </summary>+ /// <param name="mo">The ManagementObject to query.</param>+ /// <param name="property">The property name to retrieve.</param>+ /// <param name="fallback">The fallback value if property is null or missing.</param>+ /// <returns>The property value or fallback.</returns>public static string GetString(ManagementObject mo, string property, string? fallback = null){fallback ??= Translations.Common_Unknown;@@ -210,6 +247,13 @@ internal static class WmiHelper}}+ /// <summary>+ /// Gets an integer property from a ManagementObject with fallback.+ /// </summary>+ /// <param name="mo">The ManagementObject to query.</param>+ /// <param name="property">The property name to retrieve.</param>+ /// <param name="fallback">The fallback value if property is null or missing.</param>+ /// <returns>The property value or fallback.</returns>public static int GetInt(ManagementObject mo, string property, int fallback = 0){try@@ -223,6 +267,13 @@ internal static class WmiHelper}}+ /// <summary>+ /// Gets a long integer property from a ManagementObject with fallback.+ /// </summary>+ /// <param name="mo">The ManagementObject to query.</param>+ /// <param name="property">The property name to retrieve.</param>+ /// <param name="fallback">The fallback value if property is null or missing.</param>+ /// <returns>The property value or fallback.</returns>public static long GetLong(ManagementObject mo, string property, long fallback = 0){try@@ -848,6 +899,7 @@ internal static class DxgiHelper// Microsoft Basic Render Driver identifiersprivate const uint MICROSOFT_VENDOR_ID = 0x1414;+private const uint BASIC_RENDER_DEVICE_ID = 0x8C;private static readonly Guid IID_IDXGIFactory1 = new("770aae78-f26f-4dba-a829-253c83d1b387");@@ -880,13 +932,18 @@ internal static class DxgiHelper{// IDXGIObject (4 methods)void SetPrivateData([In] ref Guid Name, uint DataSize, IntPtr pData);+void SetPrivateDataInterface([In] ref Guid Name, [MarshalAs(UnmanagedType.IUnknown)] object pUnknown);+void GetPrivateData([In] ref Guid Name, ref uint pDataSize, IntPtr pData);+void GetParent([In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppParent);// IDXGIFactory (4 methods)void EnumAdapters(uint Adapter, [MarshalAs(UnmanagedType.IUnknown)] out object ppAdapter);+void MakeWindowAssociation(IntPtr WindowHandle, uint Flags);+void GetWindowAssociation(out IntPtr pWindowHandle);void CreateSwapChain(@@ -910,13 +967,18 @@ internal static class DxgiHelper{// IDXGIObject (4 methods)void SetPrivateData([In] ref Guid Name, uint DataSize, IntPtr pData);+void SetPrivateDataInterface([In] ref Guid Name, [MarshalAs(UnmanagedType.IUnknown)] object pUnknown);+void GetPrivateData([In] ref Guid Name, ref uint pDataSize, IntPtr pData);+void GetParent([In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppParent);// IDXGIAdapter (3 methods)void EnumOutputs(uint Output, [MarshalAs(UnmanagedType.IUnknown)] out object ppOutput);+void GetDesc(out DXGI_ADAPTER_DESC pDesc);+int CheckInterfaceSupport([In] ref Guid InterfaceName, out long pUMDVersion);// IDXGIAdapter1 (1 method)@@ -1008,7 +1070,7 @@ internal static class GpuProvidertry{- for (uint i = 0;; i++)+ for (uint i = 0; ; i++){var hr = factory.EnumAdapters1(i, out var adapter);if (hr != 0 || adapter == null) break; // DXGI_ERROR_NOT_FOUND@@ -1373,6 +1435,7 @@ public sealed class SystemInfoService// Cache CPU, OS, BIOS info (doesn't change at runtime)private CpuInfo? _cachedCpu;+private IReadOnlyList<GpuInfo>? _cachedGpus;private OsInfo? _cachedOs;