Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

docs: add more XML documentation

itsfatduck3e7ab63f4261
diff --git a/optimizerDuck/Core/Interfaces/IOptimization.cs b/optimizerDuck/Core/Interfaces/IOptimization.cs
index d8f379f..8310db2 100644
--- a/optimizerDuck/Core/Interfaces/IOptimization.cs
+++ b/optimizerDuck/Core/Interfaces/IOptimization.cs
@@ -4,16 +4,46 @@ using OptimizationState = optimizerDuck.Core.Models.UI.OptimizationState;
namespace optimizerDuck.Core.Interfaces;
+/// <summary>
+/// Defines a single optimization that can be applied to the system.
+/// </summary>
public interface IOptimization
{
+ /// <summary>
+ /// The unique identifier for this optimization.
+ /// </summary>
Guid Id { get; }
+
+ /// <summary>
+ /// The risk level associated with this optimization.
+ /// </summary>
OptimizationRisk Risk { get; }
+ /// <summary>
+ /// The resource key used for localization lookup.
+ /// </summary>
string OptimizationKey { get; }
+ /// <summary>
+ /// The localized display name of the optimization.
+ /// </summary>
string Name { get; }
+
+ /// <summary>
+ /// A localized short description of what this optimization does.
+ /// </summary>
string ShortDescription { get; }
+
+ /// <summary>
+ /// The current applied state and timing information.
+ /// </summary>
OptimizationState State { get; set; }
+ /// <summary>
+ /// Applies this optimization to the system.
+ /// </summary>
+ /// <param name="progress">A progress reporter for UI updates.</param>
+ /// <param name="context">The context providing logger, system snapshot, and services.</param>
+ /// <returns>A task that completes with the result of the apply operation.</returns>
Task<ApplyResult> ApplyAsync(IProgress<ProcessingProgress> progress, OptimizationContext context);
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Interfaces/IOptimizationCategory.cs b/optimizerDuck/Core/Interfaces/IOptimizationCategory.cs
index e9f5866..d4e801a 100644
--- a/optimizerDuck/Core/Interfaces/IOptimizationCategory.cs
+++ b/optimizerDuck/Core/Interfaces/IOptimizationCategory.cs
@@ -3,9 +3,23 @@ using optimizerDuck.Core.Models.UI;
namespace optimizerDuck.Core.Interfaces;
+/// <summary>
+/// Defines a category that groups related optimizations together.
+/// </summary>
public interface IOptimizationCategory
{
+ /// <summary>
+ /// The localized display name of the category.
+ /// </summary>
public string Name { get; init; }
+
+ /// <summary>
+ /// The display order of this category in the UI.
+ /// </summary>
public OptimizationCategoryOrder Order { get; init; }
+
+ /// <summary>
+ /// The collection of optimizations belonging to this category.
+ /// </summary>
public ObservableCollection<IOptimization> Optimizations { get; init; }
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Interfaces/IRevertStep.cs b/optimizerDuck/Core/Interfaces/IRevertStep.cs
index 639f012..25d1930 100644
--- a/optimizerDuck/Core/Interfaces/IRevertStep.cs
+++ b/optimizerDuck/Core/Interfaces/IRevertStep.cs
@@ -2,11 +2,25 @@ using Newtonsoft.Json.Linq;
namespace optimizerDuck.Core.Interfaces;
+/// <summary>
+/// Defines a single step that can be executed to revert an optimization.
+/// </summary>
public interface IRevertStep
{
+ /// <summary>
+ /// The type identifier for this revert step (e.g., "Registry", "Service", "Shell").
+ /// </summary>
public string Type { get; }
+ /// <summary>
+ /// Executes this revert step asynchronously.
+ /// </summary>
+ /// <returns><c>true</c> if the revert succeeded; otherwise, <c>false</c>.</returns>
Task<bool> ExecuteAsync();
+ /// <summary>
+ /// Serializes this revert step to a JSON object for persistence.
+ /// </summary>
+ /// <returns>A <see cref="JObject"/> containing the serialized step data.</returns>
JObject ToData();
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Interfaces/IWindow.cs b/optimizerDuck/Core/Interfaces/IWindow.cs
index 80b9047..d7970f6 100644
--- a/optimizerDuck/Core/Interfaces/IWindow.cs
+++ b/optimizerDuck/Core/Interfaces/IWindow.cs
@@ -2,9 +2,18 @@ using System.Windows;
namespace optimizerDuck.Core.Interfaces;
+/// <summary>
+/// Defines the contract for a window that can be shown and observed for load events.
+/// </summary>
public interface IWindow
{
+ /// <summary>
+ /// Occurs when the window has been laid out, rendered, and is ready for interaction.
+ /// </summary>
event RoutedEventHandler Loaded;
+ /// <summary>
+ /// Shows the window.
+ /// </summary>
void Show();
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Attributes/OptimizationAttribute.cs b/optimizerDuck/Core/Models/Attributes/OptimizationAttribute.cs
index e205dc2..5cb3c38 100644
--- a/optimizerDuck/Core/Models/Attributes/OptimizationAttribute.cs
+++ b/optimizerDuck/Core/Models/Attributes/OptimizationAttribute.cs
@@ -2,10 +2,24 @@
namespace optimizerDuck.Core.Models.Attributes;
+/// <summary>
+/// Marks a class as an optimization and provides metadata used for registration and display.
+/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class OptimizationAttribute : Attribute
{
+ /// <summary>
+ /// The unique identifier (GUID) for this optimization, used for tracking applied state.
+ /// </summary>
public required string Id { get; init; }
+
+ /// <summary>
+ /// The risk level associated with applying this optimization.
+ /// </summary>
public required OptimizationRisk Risk { get; init; }
+
+ /// <summary>
+ /// The tags that categorize the system areas this optimization affects.
+ /// </summary>
public required OptimizationTags Tags { get; init; }
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Attributes/OptimizationCategoryAttribute.cs b/optimizerDuck/Core/Models/Attributes/OptimizationCategoryAttribute.cs
index 4142514..e766455 100644
--- a/optimizerDuck/Core/Models/Attributes/OptimizationCategoryAttribute.cs
+++ b/optimizerDuck/Core/Models/Attributes/OptimizationCategoryAttribute.cs
@@ -1,7 +1,15 @@
namespace optimizerDuck.Core.Models.Attributes;
+/// <summary>
+/// Associates an optimization category with its corresponding UI page type
+/// for automatic page registration.
+/// </summary>
+/// <param name="pageType">The <see cref="Type"/> of the XAML page for this category.</param>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class OptimizationCategoryAttribute(Type pageType) : Attribute
{
+ /// <summary>
+ /// The type of the UI page associated with this optimization category.
+ /// </summary>
public Type PageType { get; init; } = pageType;
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Optimization/ApplyResult.cs b/optimizerDuck/Core/Models/Optimization/ApplyResult.cs
index 06e7f2c..de07dba 100644
--- a/optimizerDuck/Core/Models/Optimization/ApplyResult.cs
+++ b/optimizerDuck/Core/Models/Optimization/ApplyResult.cs
@@ -3,21 +3,29 @@ namespace optimizerDuck.Core.Models.Optimization;
/// <summary>
/// Represents the result of applying a single optimization step.
/// </summary>
-public readonly record struct ApplyResult(string? Message)
+public readonly record struct ApplyResult
{
+ /// <summary>
+ /// The error message if the step failed; <c>null</c> if successful.
+ /// </summary>
+ public string? Message { get; init; }
+
/// <summary>
/// Creates a successful result.
/// </summary>
+ /// <returns>An <see cref="ApplyResult"/> with no error message.</returns>
public static ApplyResult True()
{
- return new ApplyResult(null);
+ return new ApplyResult { Message = null };
}
/// <summary>
/// Creates a failed result with an error message.
/// </summary>
+ /// <param name="message">The error message describing the failure.</param>
+ /// <returns>An <see cref="ApplyResult"/> containing the error message.</returns>
public static ApplyResult False(string message)
{
- return new ApplyResult(message);
+ return new ApplyResult { Message = message };
}
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Optimization/OptimizationContext.cs b/optimizerDuck/Core/Models/Optimization/OptimizationContext.cs
index 5bf4078..9b318f2 100644
--- a/optimizerDuck/Core/Models/Optimization/OptimizationContext.cs
+++ b/optimizerDuck/Core/Models/Optimization/OptimizationContext.cs
@@ -6,7 +6,20 @@ namespace optimizerDuck.Core.Models.Optimization;
/// <summary>
/// Provides context information for optimization execution.
/// </summary>
-public record OptimizationContext(
- ILogger Logger,
- SystemSnapshot Snapshot,
- StreamService StreamService);
\ No newline at end of file
+public record OptimizationContext
+{
+ /// <summary>
+ /// The logger instance used to record diagnostic messages during optimization.
+ /// </summary>
+ public required ILogger Logger { get; init; }
+
+ /// <summary>
+ /// A snapshot of the current system hardware and software information.
+ /// </summary>
+ public required SystemSnapshot Snapshot { get; init; }
+
+ /// <summary>
+ /// The service used to download remote resources required by optimizations.
+ /// </summary>
+ public required StreamService StreamService { get; init; }
+}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Optimization/Services/RegistryItem.cs b/optimizerDuck/Core/Models/Optimization/Services/RegistryItem.cs
index be9c554..5c0a88b 100644
--- a/optimizerDuck/Core/Models/Optimization/Services/RegistryItem.cs
+++ b/optimizerDuck/Core/Models/Optimization/Services/RegistryItem.cs
@@ -2,13 +2,38 @@ using Microsoft.Win32;
namespace optimizerDuck.Core.Models.Optimization.Services;
+/// <summary>
+/// Represents a single registry value or key to be read, written, or deleted.
+/// </summary>
public record struct RegistryItem
{
+ /// <summary>
+ /// The registry value kind (DWord, String, etc.).
+ /// </summary>
public readonly RegistryValueKind Kind;
+
+ /// <summary>
+ /// The registry value name, or <c>null</c> to target the key itself.
+ /// </summary>
public readonly string? Name;
+
+ /// <summary>
+ /// The full registry key path (e.g., <c>HKLM\SOFTWARE\...</c>).
+ /// </summary>
public readonly string Path;
+
+ /// <summary>
+ /// The registry value data, or <c>null</c> if not applicable.
+ /// </summary>
public readonly object? Value;
+ /// <summary>
+ /// Initializes a new <see cref="RegistryItem"/> with all fields specified.
+ /// </summary>
+ /// <param name="path">The registry key path.</param>
+ /// <param name="name">The value name.</param>
+ /// <param name="value">The value data.</param>
+ /// <param name="kind">The value kind.</param>
public RegistryItem(string path, string name, object value, RegistryValueKind kind)
{
Path = path;
@@ -17,6 +42,12 @@ public record struct RegistryItem
Kind = kind;
}
+ /// <summary>
+ /// Initializes a new <see cref="RegistryItem"/> with automatic kind detection.
+ /// </summary>
+ /// <param name="path">The registry key path.</param>
+ /// <param name="name">The value name.</param>
+ /// <param name="value">The value data (kind is auto-detected from the type).</param>
public RegistryItem(string path, string name, object value)
{
Path = path;
@@ -25,6 +56,11 @@ public record struct RegistryItem
Kind = AutoDetectKind(value);
}
+ /// <summary>
+ /// Initializes a new <see cref="RegistryItem"/> for a named value without data (used for deletion).
+ /// </summary>
+ /// <param name="path">The registry key path.</param>
+ /// <param name="name">The value name to target.</param>
public RegistryItem(string path, string name)
{
Path = path;
@@ -33,6 +69,10 @@ public record struct RegistryItem
Kind = RegistryValueKind.Unknown;
}
+ /// <summary>
+ /// Initializes a new <see cref="RegistryItem"/> for a key path without a specific value (used for key-level operations).
+ /// </summary>
+ /// <param name="path">The registry key path.</param>
public RegistryItem(string path)
{
Path = path;
@@ -41,6 +81,9 @@ public record struct RegistryItem
Kind = RegistryValueKind.Unknown;
}
+ /// <summary>
+ /// Auto-detects the <see cref="RegistryValueKind"/> based on the CLR type of the value.
+ /// </summary>
private static RegistryValueKind AutoDetectKind(object? value)
{
return value switch
diff --git a/optimizerDuck/Core/Models/Optimization/Services/ServiceItem.cs b/optimizerDuck/Core/Models/Optimization/Services/ServiceItem.cs
index d59310d..20093fd 100644
--- a/optimizerDuck/Core/Models/Optimization/Services/ServiceItem.cs
+++ b/optimizerDuck/Core/Models/Optimization/Services/ServiceItem.cs
@@ -1,3 +1,31 @@
+using System.Diagnostics.CodeAnalysis;
+
namespace optimizerDuck.Core.Models.Optimization.Services;
-public readonly record struct ServiceItem(string Name, ServiceStartupType StartupType);
\ No newline at end of file
+/// <summary>
+/// Represents a Windows service to be configured with a specific startup type.
+/// </summary>
+public readonly record struct ServiceItem
+{
+ /// <summary>
+ /// The Windows service name (e.g., <c>"DiagTrack"</c>).
+ /// </summary>
+ public required string Name { get; init; }
+
+ /// <summary>
+ /// The desired startup type for the service.
+ /// </summary>
+ public required ServiceStartupType StartupType { get; init; }
+
+ /// <summary>
+ /// Initializes a new <see cref="ServiceItem"/> with the given service name and startup type.
+ /// </summary>
+ /// <param name="name">The Windows service name.</param>
+ /// <param name="startupType">The desired startup type.</param>
+ [SetsRequiredMembers]
+ public ServiceItem(string name, ServiceStartupType startupType)
+ {
+ Name = name;
+ StartupType = startupType;
+ }
+}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Optimization/Services/ServiceStartupType.cs b/optimizerDuck/Core/Models/Optimization/Services/ServiceStartupType.cs
index 7b1c2e1..fe169b6 100644
--- a/optimizerDuck/Core/Models/Optimization/Services/ServiceStartupType.cs
+++ b/optimizerDuck/Core/Models/Optimization/Services/ServiceStartupType.cs
@@ -1,9 +1,19 @@
namespace optimizerDuck.Core.Models.Optimization.Services;
+/// <summary>
+/// Specifies the startup type for a Windows service.
+/// </summary>
public enum ServiceStartupType
{
+ /// <summary>The service starts automatically at system startup.</summary>
Automatic,
+
+ /// <summary>The service starts only when explicitly started by a user or application.</summary>
Manual,
+
+ /// <summary>The service is disabled and cannot be started.</summary>
Disabled,
+
+ /// <summary>The service starts automatically after a short delay at system startup.</summary>
AutomaticDelayedStart
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Optimization/Services/ShellResult.cs b/optimizerDuck/Core/Models/Optimization/Services/ShellResult.cs
index ba15b57..a7bbe74 100644
--- a/optimizerDuck/Core/Models/Optimization/Services/ShellResult.cs
+++ b/optimizerDuck/Core/Models/Optimization/Services/ShellResult.cs
@@ -1,8 +1,33 @@
namespace optimizerDuck.Core.Models.Optimization.Services;
-public record ShellResult(
- string Command,
- string Stdout,
- string Stderr,
- int ExitCode,
- TimeSpan Duration);
\ No newline at end of file
+/// <summary>
+/// Represents the result of a shell command execution.
+/// </summary>
+public record ShellResult
+{
+ /// <summary>
+ /// The full command string that was executed.
+ /// </summary>
+ public required string Command { get; init; }
+
+ /// <summary>
+ /// The standard output captured from the process.
+ /// </summary>
+ public required string Stdout { get; init; }
+
+ /// <summary>
+ /// The standard error output captured from the process.
+ /// </summary>
+ public required string Stderr { get; init; }
+
+ /// <summary>
+ /// The process exit code. A value of <c>-1</c> indicates a timeout,
+ /// and <c>-2</c> indicates an exception during execution.
+ /// </summary>
+ public required int ExitCode { get; init; }
+
+ /// <summary>
+ /// The total wall-clock duration of the command execution.
+ /// </summary>
+ public required TimeSpan Duration { get; init; }
+}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Revert/RevertContext.cs b/optimizerDuck/Core/Models/Revert/RevertContext.cs
index adb1364..a6e8a61 100644
--- a/optimizerDuck/Core/Models/Revert/RevertContext.cs
+++ b/optimizerDuck/Core/Models/Revert/RevertContext.cs
@@ -4,6 +4,10 @@ using optimizerDuck.Services.Managers;
namespace optimizerDuck.Core.Models.Revert;
+/// <summary>
+/// Manages the recording of revert steps during an optimization apply operation.
+/// Implements <see cref="IAsyncDisposable"/> to automatically persist recorded steps on disposal.
+/// </summary>
public sealed class RevertContext : IAsyncDisposable
{
private readonly ILogger _logger;
@@ -11,6 +15,12 @@ public sealed class RevertContext : IAsyncDisposable
private readonly IOptimization _optimization;
private readonly Stack<IRevertStep> _steps = new();
+ /// <summary>
+ /// Initializes a new <see cref="RevertContext"/> for the given optimization.
+ /// </summary>
+ /// <param name="optimization">The optimization being performed.</param>
+ /// <param name="logger">The logger for diagnostic messages.</param>
+ /// <param name="manager">The revert manager responsible for persistence.</param>
internal RevertContext(IOptimization optimization, ILogger logger, RevertManager manager)
{
_optimization = optimization;
@@ -18,6 +28,9 @@ public sealed class RevertContext : IAsyncDisposable
_manager = manager;
}
+ /// <summary>
+ /// Persists recorded revert steps and clears the current context.
+ /// </summary>
public async ValueTask DisposeAsync()
{
try
@@ -36,6 +49,10 @@ public sealed class RevertContext : IAsyncDisposable
}
}
+ /// <summary>
+ /// Adds a revert step to the recording stack.
+ /// </summary>
+ /// <param name="step">The revert step to record.</param>
internal void AddStep(IRevertStep step)
{
_steps.Push(step);
diff --git a/optimizerDuck/Core/Models/Revert/RevertValidationResult.cs b/optimizerDuck/Core/Models/Revert/RevertValidationResult.cs
index 5d2c6e1..064ff8c 100644
--- a/optimizerDuck/Core/Models/Revert/RevertValidationResult.cs
+++ b/optimizerDuck/Core/Models/Revert/RevertValidationResult.cs
@@ -2,6 +2,9 @@ using optimizerDuck.Resources.Languages;
namespace optimizerDuck.Core.Models.Revert;
+/// <summary>
+/// Represents the result of validating revert data before executing a revert operation.
+/// </summary>
public class RevertValidationResult
{
private RevertValidationResult(bool valid, string message, string localizedMessage)
@@ -11,15 +14,36 @@ public class RevertValidationResult
LocalizedMessage = localizedMessage;
}
+ /// <summary>
+ /// Indicates whether the revert data passed validation.
+ /// </summary>
public bool IsValid { get; private set; }
+
+ /// <summary>
+ /// A technical message describing the validation result (English).
+ /// </summary>
public string Message { get; private set; }
+
+ /// <summary>
+ /// A localized message suitable for display to the user.
+ /// </summary>
public string LocalizedMessage { get; private set; }
+ /// <summary>
+ /// Creates a successful validation result.
+ /// </summary>
+ /// <returns>A valid <see cref="RevertValidationResult"/>.</returns>
public static RevertValidationResult Success()
{
return new RevertValidationResult(true, "Revert data is valid.", Translations.Revert_Error_InvalidData);
}
+ /// <summary>
+ /// Creates a failed validation result with a descriptive message.
+ /// </summary>
+ /// <param name="localizedMessage">The localized error message for the user.</param>
+ /// <param name="message">The technical error message.</param>
+ /// <returns>An invalid <see cref="RevertValidationResult"/>.</returns>
public static RevertValidationResult Fail(string localizedMessage, string message)
{
return new RevertValidationResult(false, message, localizedMessage);
diff --git a/optimizerDuck/Core/Models/Revert/Steps/RegistryRevertStep.cs b/optimizerDuck/Core/Models/Revert/Steps/RegistryRevertStep.cs
index 6fc11a9..5602c7d 100644
--- a/optimizerDuck/Core/Models/Revert/Steps/RegistryRevertStep.cs
+++ b/optimizerDuck/Core/Models/Revert/Steps/RegistryRevertStep.cs
@@ -6,10 +6,24 @@ using optimizerDuck.Services.OptimizationServices;
namespace optimizerDuck.Core.Models.Revert.Steps;
+/// <summary>
+/// Represents a revert step that restores or deletes a registry value.
+/// </summary>
public class RegistryRevertStep : IRevertStep
{
+ /// <summary>
+ /// The action to perform (restore previous value or delete).
+ /// </summary>
public RevertAction Action { get; init; }
+
+ /// <summary>
+ /// The registry key path.
+ /// </summary>
public string Path { get; init; } = string.Empty;
+
+ /// <summary>
+ /// The registry value name, or <c>null</c> for the default value.
+ /// </summary>
public string? Name { get; init; }
/// <summary>
@@ -17,10 +31,21 @@ public class RegistryRevertStep : IRevertStep
/// </summary>
public IReadOnlyList<string>? CreatedSubKeys { get; init; }
+
+ /// <summary>
+ /// The original registry value to restore.
+ /// </summary>
public object? Value { get; init; }
+
+ /// <summary>
+ /// The registry value kind (DWord, String, etc.).
+ /// </summary>
public RegistryValueKind Kind { get; init; }
+
+ /// <inheritdoc />
public string Type => "Registry";
+ /// <inheritdoc />
public async Task<bool> ExecuteAsync()
{
return await Task.Run(() =>
@@ -48,6 +73,8 @@ public class RegistryRevertStep : IRevertStep
}
+
+ /// <inheritdoc />
public JObject ToData()
{
var obj = new JObject
@@ -101,6 +128,11 @@ public class RegistryRevertStep : IRevertStep
return obj;
}
+ /// <summary>
+ /// Deserializes a <see cref="RegistryRevertStep"/> from JSON data.
+ /// </summary>
+ /// <param name="data">The JSON data to deserialize.</param>
+ /// <returns>A new <see cref="RegistryRevertStep"/> instance.</returns>
public static RegistryRevertStep FromData(JObject data)
{
var kind = Enum.Parse<RegistryValueKind>(data[nameof(Kind)]!.ToString());
@@ -150,8 +182,14 @@ public class RegistryRevertStep : IRevertStep
}
}
+/// <summary>
+/// Specifies the type of revert action to perform on a registry value.
+/// </summary>
public enum RevertAction
{
+ /// <summary>The value did not exist before; delete it during revert.</summary>
NoPreviousValue,
+
+ /// <summary>Restore the previously captured value.</summary>
RestorePrevious
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Revert/Steps/ServiceRevertStep.cs b/optimizerDuck/Core/Models/Revert/Steps/ServiceRevertStep.cs
index 808f18e..8d62ed0 100644
--- a/optimizerDuck/Core/Models/Revert/Steps/ServiceRevertStep.cs
+++ b/optimizerDuck/Core/Models/Revert/Steps/ServiceRevertStep.cs
@@ -5,12 +5,26 @@ using optimizerDuck.Services.OptimizationServices;
namespace optimizerDuck.Core.Models.Revert.Steps;
+/// <summary>
+/// Represents a revert step that restores a Windows service to its original startup type.
+/// </summary>
public class ServiceRevertStep : IRevertStep
{
+ /// <summary>
+ /// The name of the Windows service to restore.
+ /// </summary>
public string ServiceName { get; set; } = string.Empty;
+
+ /// <summary>
+ /// The original startup type to restore the service to.
+ /// </summary>
public ServiceStartupType OriginalStartupType { get; set; }
+
+ /// <inheritdoc />
public string Type => "Service";
+
+ /// <inheritdoc />
public async Task<bool> ExecuteAsync()
{
return await Task.Run(() => ServiceProcessService.ChangeServiceStartupType(new ServiceItem
@@ -20,6 +34,8 @@ public class ServiceRevertStep : IRevertStep
}));
}
+
+ /// <inheritdoc />
public JObject ToData()
{
return new JObject
@@ -29,6 +45,12 @@ public class ServiceRevertStep : IRevertStep
};
}
+
+ /// <summary>
+ /// Deserializes a <see cref="ServiceRevertStep"/> from JSON data.
+ /// </summary>
+ /// <param name="data">The JSON data to deserialize.</param>
+ /// <returns>A new <see cref="ServiceRevertStep"/> instance.</returns>
public static ServiceRevertStep FromData(JObject data)
{
return new ServiceRevertStep
diff --git a/optimizerDuck/Core/Models/Revert/Steps/ShellRevertStep.cs b/optimizerDuck/Core/Models/Revert/Steps/ShellRevertStep.cs
index 329d1cc..4388242 100644
--- a/optimizerDuck/Core/Models/Revert/Steps/ShellRevertStep.cs
+++ b/optimizerDuck/Core/Models/Revert/Steps/ShellRevertStep.cs
@@ -5,12 +5,25 @@ using optimizerDuck.Services.OptimizationServices;
namespace optimizerDuck.Core.Models.Revert.Steps;
+/// <summary>
+/// Represents a revert step that re-executes a shell command to undo changes.
+/// </summary>
public class ShellRevertStep : IRevertStep
{
+ /// <summary>
+ /// The type of shell to use for execution.
+ /// </summary>
public ShellType ShellType { get; set; }
+
+ /// <summary>
+ /// The command string to execute for reverting.
+ /// </summary>
public string Command { get; set; } = string.Empty;
+
+ /// <inheritdoc />
public string Type => "Shell";
+ /// <inheritdoc />
public async Task<bool> ExecuteAsync()
{
return await Task.Run(() =>
@@ -19,12 +32,13 @@ public class ShellRevertStep : IRevertStep
{
ShellType.PowerShell => ShellService.PowerShell(Command),
ShellType.CMD => ShellService.CMD(Command),
- _ => new ShellResult(Command, "", "Unknown shell type", 1, TimeSpan.Zero)
+ _ => new ShellResult {Command = Command, Stdout = "", Stderr = "Unknown shell type", ExitCode = 1, Duration = TimeSpan.Zero}
};
return result.ExitCode == 0;
});
}
+ /// <inheritdoc />
public JObject ToData()
{
return new JObject
@@ -34,6 +48,11 @@ public class ShellRevertStep : IRevertStep
};
}
+ /// <summary>
+ /// Deserializes a <see cref="ShellRevertStep"/> from JSON data.
+ /// </summary>
+ /// <param name="data">The JSON data to deserialize.</param>
+ /// <returns>A new <see cref="ShellRevertStep"/> instance.</returns>
public static ShellRevertStep FromData(JToken data)
{
return new ShellRevertStep
@@ -45,8 +64,14 @@ public class ShellRevertStep : IRevertStep
}
}
+/// <summary>
+/// Specifies the type of shell used for command execution.
+/// </summary>
public enum ShellType
{
+ /// <summary>Windows PowerShell.</summary>
PowerShell,
+
+ /// <summary>Command Prompt (cmd.exe).</summary>
CMD
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/UI/LanguageOption.cs b/optimizerDuck/Core/Models/UI/LanguageOption.cs
index 436c585..f8775c1 100644
--- a/optimizerDuck/Core/Models/UI/LanguageOption.cs
+++ b/optimizerDuck/Core/Models/UI/LanguageOption.cs
@@ -2,7 +2,18 @@ using System.Globalization;
namespace optimizerDuck.Core.Models.UI;
-public record LanguageOption(
- string DisplayName,
- CultureInfo Culture
-);
\ No newline at end of file
+/// <summary>
+/// Represents a selectable language option in the settings UI.
+/// </summary>
+public record LanguageOption
+{
+ /// <summary>
+ /// The human-readable name of the language (e.g., "English", "Tiếng Việt").
+ /// </summary>
+ public required string DisplayName { get; init; }
+
+ /// <summary>
+ /// The <see cref="CultureInfo"/> associated with this language option.
+ /// </summary>
+ public required CultureInfo Culture { get; init; }
+}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/UI/OptimizationCategoryOrder.cs b/optimizerDuck/Core/Models/UI/OptimizationCategoryOrder.cs
index 76e2c93..6d89265 100644
--- a/optimizerDuck/Core/Models/UI/OptimizationCategoryOrder.cs
+++ b/optimizerDuck/Core/Models/UI/OptimizationCategoryOrder.cs
@@ -1,11 +1,25 @@
namespace optimizerDuck.Core.Models.UI;
+/// <summary>
+/// Specifies the display order of optimization categories in the UI.
+/// </summary>
public enum OptimizationCategoryOrder
{
+ /// <summary>Performance-related optimizations.</summary>
Performance,
+
+ /// <summary>Security and privacy optimizations.</summary>
SecurityAndPrivacy,
+
+ /// <summary>GPU-specific optimizations.</summary>
Gpu,
+
+ /// <summary>Power management optimizations.</summary>
Power,
+
+ /// <summary>Bloatware removal and service management.</summary>
BloatwareAndServices,
+
+ /// <summary>User experience and visual optimizations.</summary>
UserExperience
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/UI/OptimizationRisk.cs b/optimizerDuck/Core/Models/UI/OptimizationRisk.cs
index 28252ec..1d52449 100644
--- a/optimizerDuck/Core/Models/UI/OptimizationRisk.cs
+++ b/optimizerDuck/Core/Models/UI/OptimizationRisk.cs
@@ -5,7 +5,12 @@ namespace optimizerDuck.Core.Models.UI;
/// </summary>
public enum OptimizationRisk
{
+ /// <summary>Safe to apply with no adverse effects.</summary>
Safe,
+
+ /// <summary>May cause minor side effects; recommended for experienced users.</summary>
Moderate,
+
+ /// <summary>High risk; may cause system instability or data loss. Use with caution.</summary>
Risky
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/UI/OptimizationState.cs b/optimizerDuck/Core/Models/UI/OptimizationState.cs
index 03457af..84424ca 100644
--- a/optimizerDuck/Core/Models/UI/OptimizationState.cs
+++ b/optimizerDuck/Core/Models/UI/OptimizationState.cs
@@ -16,10 +16,24 @@ public partial class OptimizationState : ObservableObject
private int _lastDisplayedSeconds = -1;
+ /// <summary>
+ /// The date and time when the optimization was applied.
+ /// </summary>
[ObservableProperty] private DateTime? appliedAt;
+
+ /// <summary>
+ /// Indicates whether the optimization is currently applied.
+ /// </summary>
[ObservableProperty] private bool isApplied;
+
+ /// <summary>
+ /// A human-readable relative time string (e.g., "5 minutes ago").
+ /// </summary>
[ObservableProperty] private string? relativeTime = string.Empty;
+ /// <summary>
+ /// The risk level of the optimization.
+ /// </summary>
[ObservableProperty] private OptimizationRisk risk;
static OptimizationState()
diff --git a/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.cs b/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.cs
index 6b9f6cf..5fac3b1 100644
--- a/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.cs
+++ b/optimizerDuck/Core/Models/UI/OptimizationSuccessResult.cs
@@ -5,7 +5,12 @@ namespace optimizerDuck.Core.Models.UI;
/// </summary>
public enum OptimizationSuccessResult
{
+ /// <summary>All steps completed successfully.</summary>
Success,
+
+ /// <summary>Some steps succeeded while others failed.</summary>
PartialSuccess,
+
+ /// <summary>The operation failed entirely.</summary>
Failed
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/UI/OptimizationTags.cs b/optimizerDuck/Core/Models/UI/OptimizationTags.cs
index ce2a9b0..52e4e86 100644
--- a/optimizerDuck/Core/Models/UI/OptimizationTags.cs
+++ b/optimizerDuck/Core/Models/UI/OptimizationTags.cs
@@ -1,8 +1,12 @@
+using System.Diagnostics.CodeAnalysis;
using optimizerDuck.Resources.Languages;
using Wpf.Ui.Controls;
namespace optimizerDuck.Core.Models.UI;
+/// <summary>
+/// Flags that categorize an optimization by the system areas it affects.
+/// </summary>
[Flags]
public enum OptimizationTags
{
@@ -39,10 +43,17 @@ public enum OptimizationTags
Latency = 1 << 15
}
+/// <summary>
+/// Provides extension methods to convert <see cref="OptimizationTags"/> to display-friendly representations.
+/// </summary>
public static class OptimizationTagsToDisplay
{
extension(OptimizationTags tags)
{
+ /// <summary>
+ /// Converts the tag flags into a sequence of display-friendly representations.
+ /// </summary>
+ /// <returns>An enumerable of <see cref="OptimizationTagDisplay"/> for each set flag.</returns>
public IEnumerable<OptimizationTagDisplay> ToDisplays()
{
foreach (var flag in Enum.GetValues<OptimizationTags>())
@@ -55,73 +66,108 @@ public static class OptimizationTagsToDisplay
}
}
+ /// <summary>
+ /// Converts a single tag flag to its display representation.
+ /// </summary>
private OptimizationTagDisplay ToDisplay()
{
return tags switch
{
- OptimizationTags.Ram => new OptimizationTagDisplay(
- SymbolRegular.Memory16,
- Translations.Optimizer_UI_Tags_Ram),
-
- OptimizationTags.Disk => new OptimizationTagDisplay(
- SymbolRegular.HardDrive20,
- Translations.Optimizer_UI_Tags_Disk),
-
- OptimizationTags.Latency => new OptimizationTagDisplay(
- SymbolRegular.Clock24,
- Translations.Optimizer_UI_Tags_Latency),
-
- OptimizationTags.Visual => new OptimizationTagDisplay(
- SymbolRegular.VideoClip24,
- Translations.Optimizer_UI_Tags_Visual),
-
- OptimizationTags.Display => new OptimizationTagDisplay(
- SymbolRegular.VideoClip24,
- Translations.Optimizer_UI_Tags_Display),
-
- OptimizationTags.Network => new OptimizationTagDisplay(
- SymbolRegular.NetworkAdapter16,
- Translations.Optimizer_UI_Tags_Network),
-
- OptimizationTags.Performance => new OptimizationTagDisplay(
- SymbolRegular.Gauge24,
- Translations.Optimizer_UI_Tags_Performance),
-
- OptimizationTags.Privacy => new OptimizationTagDisplay(
- SymbolRegular.LockOpen24,
- Translations.Optimizer_UI_Tags_Privacy),
-
- OptimizationTags.Audio => new OptimizationTagDisplay(
- SymbolRegular.Headphones24,
- Translations.Optimizer_UI_Tags_Audio),
-
- OptimizationTags.System => new OptimizationTagDisplay(
- SymbolRegular.Desktop24,
- Translations.Optimizer_UI_Tags_System),
-
- OptimizationTags.Security => new OptimizationTagDisplay(
- SymbolRegular.LockClosed24,
- Translations.Optimizer_UI_Tags_Security),
-
- OptimizationTags.NetworkRequired => new OptimizationTagDisplay(
- SymbolRegular.Wifi120,
- Translations.Optimizer_UI_Tags_NetworkRequired),
-
- OptimizationTags.Nvidia => new OptimizationTagDisplay(
- SymbolRegular.VideoClip24,
- Translations.Optimizer_UI_Tags_Nvidia),
-
- OptimizationTags.Amd => new OptimizationTagDisplay(
- SymbolRegular.VideoClip24,
- Translations.Optimizer_UI_Tags_Amd),
-
- OptimizationTags.Intel => new OptimizationTagDisplay(
- SymbolRegular.VideoClip24,
- Translations.Optimizer_UI_Tags_Intel),
-
- OptimizationTags.Power => new OptimizationTagDisplay(
- SymbolRegular.BatteryCharge24,
- Translations.Optimizer_UI_Tags_Power),
+ OptimizationTags.Ram => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.Memory16,
+ Display = Translations.Optimizer_UI_Tags_Ram
+ },
+
+ OptimizationTags.Disk => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.HardDrive20,
+ Display = Translations.Optimizer_UI_Tags_Disk
+ },
+
+ OptimizationTags.Latency => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.Clock24,
+ Display = Translations.Optimizer_UI_Tags_Latency
+ },
+
+ OptimizationTags.Visual => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.VideoClip24,
+ Display = Translations.Optimizer_UI_Tags_Visual
+ },
+
+ OptimizationTags.Display => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.VideoClip24,
+ Display = Translations.Optimizer_UI_Tags_Display
+ },
+
+ OptimizationTags.Network => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.NetworkAdapter16,
+ Display = Translations.Optimizer_UI_Tags_Network
+ },
+
+ OptimizationTags.Performance => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.Gauge24,
+ Display = Translations.Optimizer_UI_Tags_Performance
+ },
+
+ OptimizationTags.Privacy => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.LockOpen24,
+ Display = Translations.Optimizer_UI_Tags_Privacy
+ },
+
+ OptimizationTags.Audio => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.Headphones24,
+ Display = Translations.Optimizer_UI_Tags_Audio
+ },
+
+ OptimizationTags.System => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.Desktop24,
+ Display = Translations.Optimizer_UI_Tags_System
+ },
+
+ OptimizationTags.Security => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.LockClosed24,
+ Display = Translations.Optimizer_UI_Tags_Security
+ },
+
+ OptimizationTags.NetworkRequired => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.Wifi120,
+ Display = Translations.Optimizer_UI_Tags_NetworkRequired
+ },
+
+ OptimizationTags.Nvidia => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.VideoClip24,
+ Display = Translations.Optimizer_UI_Tags_Nvidia
+ },
+
+ OptimizationTags.Amd => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.VideoClip24,
+ Display = Translations.Optimizer_UI_Tags_Amd
+ },
+
+ OptimizationTags.Intel => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.VideoClip24,
+ Display = Translations.Optimizer_UI_Tags_Intel
+ },
+
+ OptimizationTags.Power => new OptimizationTagDisplay
+ {
+ Icon = SymbolRegular.BatteryCharge24,
+ Display = Translations.Optimizer_UI_Tags_Power
+ },
_ => throw new ArgumentOutOfRangeException(nameof(tags))
};
@@ -129,4 +175,18 @@ public static class OptimizationTagsToDisplay
}
}
-public readonly record struct OptimizationTagDisplay(SymbolRegular Icon, string Display);
\ No newline at end of file
+/// <summary>
+/// Represents the UI display data for an optimization tag.
+/// </summary>
+public readonly record struct OptimizationTagDisplay
+{
+ /// <summary>
+ /// The icon symbol to display.
+ /// </summary>
+ public required SymbolRegular Icon { get; init; }
+
+ /// <summary>
+ /// The localized display text for the tag.
+ /// </summary>
+ public required string Display { get; init; }
+}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/UI/RiskVisual.cs b/optimizerDuck/Core/Models/UI/RiskVisual.cs
index 836b5c9..e9e6e27 100644
--- a/optimizerDuck/Core/Models/UI/RiskVisual.cs
+++ b/optimizerDuck/Core/Models/UI/RiskVisual.cs
@@ -2,8 +2,18 @@ using Wpf.Ui.Controls;
namespace optimizerDuck.Core.Models.UI;
+/// <summary>
+/// Represents the visual display data for a risk level in the UI.
+/// </summary>
public class RiskVisual
{
+ /// <summary>
+ /// The localized display text for the risk level.
+ /// </summary>
public string Display { get; init; } = string.Empty;
+
+ /// <summary>
+ /// The icon symbol to display for the risk level.
+ /// </summary>
public SymbolRegular Icon { get; init; }
}
\ No newline at end of file
diff --git a/optimizerDuck/Services/OptimizationService.cs b/optimizerDuck/Services/OptimizationService.cs
index 012706c..4ef7b56 100644
--- a/optimizerDuck/Services/OptimizationService.cs
+++ b/optimizerDuck/Services/OptimizationService.cs
@@ -180,7 +180,12 @@ public class OptimizationService(
var applyResult = await Task.Run(async () =>
await optimization.ApplyAsync(progress,
- new OptimizationContext(optimizationLogger, systemInfoService.Snapshot, streamService)));
+ new OptimizationContext
+ {
+ Logger = optimizationLogger,
+ Snapshot = systemInfoService.Snapshot,
+ StreamService = streamService
+ }));
if (!string.IsNullOrWhiteSpace(applyResult.Message)) // Optimization failed
{
diff --git a/optimizerDuck/Services/OptimizationServices/ShellService.cs b/optimizerDuck/Services/OptimizationServices/ShellService.cs
index 1661612..d3881df 100644
--- a/optimizerDuck/Services/OptimizationServices/ShellService.cs
+++ b/optimizerDuck/Services/OptimizationServices/ShellService.cs
@@ -137,12 +137,14 @@ public static class ShellService
var stdout = stdoutBuilder.ToString().Trim();
var stderr = stderrBuilder.ToString().ParseCliXml().Trim();
- var result = new ShellResult(
- fullCommandForUser,
- stdout,
- stderr,
- timedOut ? -1 : process.ExitCode, // use -1 error code for timed out
- duration);
+ var result = new ShellResult
+ {
+ Command = fullCommandForUser,
+ Stdout = stdout,
+ Stderr = stderr,
+ ExitCode = timedOut ? -1 : process.ExitCode, // use -1 error code for timed out
+ Duration = duration
+ };
var success = policy.IsSuccess(result);
@@ -183,12 +185,14 @@ public static class ShellService
}
catch (Exception ex)
{
- var result = new ShellResult(
- fullCommandForUser,
- string.Empty,
- ex.Message,
- -2,
- TimeSpan.Zero);
+ var result = new ShellResult
+ {
+ Command = fullCommandForUser,
+ Stdout = string.Empty,
+ Stderr = ex.Message,
+ ExitCode = -2,
+ Duration = TimeSpan.Zero
+ };
ServiceTracker.Track(serviceName, false);
ServiceTracker.LogError(ex, "[{Service}][FAIL][EXCEPTION] {Command}", serviceName, fullCommandForUser);
@@ -290,12 +294,14 @@ public static class ShellService
var stdout = stdoutBuilder.ToString().Trim();
var stderr = stderrBuilder.ToString().ParseCliXml().Trim();
- var result = new ShellResult(
- fullCommandForUser,
- stdout,
- stderr,
- timedOut ? -1 : process.ExitCode,
- sw.Elapsed);
+ var result = new ShellResult
+ {
+ Command = fullCommandForUser,
+ Stdout = stdout,
+ Stderr = stderr,
+ ExitCode = timedOut ? -1 : process.ExitCode,
+ Duration = sw.Elapsed
+ };
var success = policy.IsSuccess(result);
@@ -334,12 +340,14 @@ public static class ShellService
}
catch (Exception ex)
{
- var result = new ShellResult(
- fullCommandForUser,
- string.Empty,
- ex.Message,
- -2,
- TimeSpan.Zero);
+ var result = new ShellResult
+ {
+ Command = fullCommandForUser,
+ Stdout = string.Empty,
+ Stderr = ex.Message,
+ ExitCode = -2,
+ Duration = TimeSpan.Zero
+ };
ServiceTracker.Track(serviceName, false);
ServiceTracker.LogError(ex, "[{Service}][FAIL][EXCEPTION] {Command}", serviceName, fullCommandForUser);
@@ -357,11 +365,26 @@ public static class ShellService
#region Command Prompt methods
+ /// <summary>
+ /// Runs a command in the Command Prompt (cmd.exe).
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertStep">The revert step to record.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <returns>The result of the command execution.</returns>
public static ShellResult CMD(string command, ShellRevertStep? revertStep = null, ShellPolicy? policy = null)
{
return Run("cmd.exe", "/c", command, nameof(CMD), revertStep, policy);
}
+ /// <summary>
+ /// Runs a command in the Command Prompt (cmd.exe) asynchronously.
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertStep">The revert step to record.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <param name="ct">The cancellation token.</param>
+ /// <returns>The result of the command execution.</returns>
public static Task<ShellResult> CMDAsync(
string command,
ShellRevertStep? revertStep = null,
@@ -378,6 +401,13 @@ public static class ShellService
ct);
}
+ /// <summary>
+ /// Runs a command in the Command Prompt (cmd.exe) with a specific revert command.
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertCommand">The command to execute for reverting.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <returns>The result of the command execution.</returns>
public static ShellResult CMD(string command, string revertCommand, ShellPolicy? policy = null)
{
return CMD(command, new ShellRevertStep
@@ -387,6 +417,13 @@ public static class ShellService
}, policy);
}
+ /// <summary>
+ /// Runs a command in the Command Prompt (cmd.exe) with a specific revert command.
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertCommand">The command to execute for reverting.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <returns>The result of the command execution.</returns>
public static ShellResult CMD(string command, Func<string> revertCommand, ShellPolicy? policy = null)
{
return CMD(command, new ShellRevertStep
@@ -400,6 +437,13 @@ public static class ShellService
#region PowerShell methods
+ /// <summary>
+ /// Runs a command in PowerShell.
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertStep">The revert step to record.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <returns>The result of the command execution.</returns>
public static ShellResult PowerShell(string command, ShellRevertStep? revertStep = null, ShellPolicy? policy = null)
{
command =
@@ -415,6 +459,14 @@ public static class ShellService
policy);
}
+ /// <summary>
+ /// Runs a command in PowerShell asynchronously.
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertStep">The revert step to record.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <param name="ct">The cancellation token.</param>
+ /// <returns>The result of the command execution.</returns>
public static Task<ShellResult> PowerShellAsync(
string command,
ShellRevertStep? revertStep = null,
@@ -434,6 +486,13 @@ public static class ShellService
policy, ct);
}
+ /// <summary>
+ /// Runs a command in PowerShell with a specific revert command.
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertCommand">The command to execute for reverting.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <returns>The result of the command execution.</returns>
public static ShellResult PowerShell(string command, string revertCommand, ShellPolicy? policy = null)
{
return PowerShell(command, new ShellRevertStep
@@ -443,6 +502,13 @@ public static class ShellService
}, policy);
}
+ /// <summary>
+ /// Runs a command in PowerShell with a specific revert command.
+ /// </summary>
+ /// <param name="command">The command to execute.</param>
+ /// <param name="revertCommand">The command to execute for reverting.</param>
+ /// <param name="policy">The policy to use for determining success.</param>
+ /// <returns>The result of the command execution.</returns>
public static ShellResult PowerShell(string command, Func<string> revertCommand, ShellPolicy? policy = null)
{
return PowerShell(command, new ShellRevertStep
diff --git a/optimizerDuck/Services/SystemInfoService.cs b/optimizerDuck/Services/SystemInfoService.cs
index 363e6f2..46f87b8 100644
--- a/optimizerDuck/Services/SystemInfoService.cs
+++ b/optimizerDuck/Services/SystemInfoService.cs
@@ -18,27 +18,65 @@ namespace optimizerDuck.Services;
/// </summary>
public enum GpuVendor
{
+ /// <summary>Unknown or unrecognized GPU vendor.</summary>
Unknown,
+
+ /// <summary>NVIDIA Corporation.</summary>
NVIDIA,
+
+ /// <summary>Advanced Micro Devices (AMD).</summary>
AMD,
+
+ /// <summary>Intel Corporation.</summary>
Intel
}
/// <summary>
/// Represents information about a GPU.
/// </summary>
-public sealed record GpuInfo(
- string Name,
- string DriverVersion,
- GpuVendor Vendor,
- int? MemoryMB,
- string? DeviceId,
- string? PnpDeviceId
-)
+public sealed record GpuInfo
{
- public static readonly GpuInfo Unknown = new(Translations.Common_Unknown, Translations.Common_Unknown,
- GpuVendor.Unknown, null, null, null);
+ /// <summary>
+ /// The display name of the GPU (e.g., "NVIDIA GeForce RTX 4090").
+ /// </summary>
+ public required string Name { get; init; }
+
+ /// <summary>
+ /// The driver version string.
+ /// </summary>
+ public required string DriverVersion { get; init; }
+ /// <summary>
+ /// The GPU vendor manufacturer.
+ /// </summary>
+ public required GpuVendor Vendor { get; init; }
+
+ /// <summary>
+ /// The dedicated video memory in megabytes, or <c>null</c> if unknown.
+ /// </summary>
+ public int? MemoryMB { get; init; }
+
+ /// <summary>
+ /// The PnP device ID from WMI, or <c>null</c> if unavailable.
+ /// </summary>
+ public string? DeviceId { get; init; }
+
+ /// <summary>
+ /// The Plug and Play device ID, or <c>null</c> if unavailable.
+ /// </summary>
+ public string? PnpDeviceId { get; init; }
+
+ /// <summary>
+ /// A sentinel value representing an unknown GPU.
+ /// </summary>
+ public static readonly GpuInfo Unknown = new()
+ {
+ Name = Translations.Common_Unknown,
+ DriverVersion = Translations.Common_Unknown,
+ Vendor = GpuVendor.Unknown
+ };
+
+ /// <inheritdoc />
public override string ToString()
{
return
@@ -49,136 +87,397 @@ public sealed record GpuInfo(
/// <summary>
/// Represents information about the CPU.
/// </summary>
-public sealed record CpuInfo(
- string Name,
- string Manufacturer,
- string Vendor,
- string Architecture,
- int Cores,
- int Threads,
- int MaxClockMHz,
- int CurrentClockMHz,
- int L2CacheKB,
- int L3CacheKB
-)
+public sealed record CpuInfo
{
- public static readonly CpuInfo Unknown = new(Translations.Common_Unknown, Translations.Common_Unknown,
- Translations.Common_Unknown, Translations.Common_Unknown, 0, 0, 0, 0, 0, 0);
+ /// <summary>
+ /// The processor display name (e.g., "Intel Core i9-13900K").
+ /// </summary>
+ public required string Name { get; init; }
+
+ /// <summary>
+ /// The manufacturer identifier (e.g., "GenuineIntel").
+ /// </summary>
+ public required string Manufacturer { get; init; }
+
+ /// <summary>
+ /// The detected vendor string (e.g., "Intel", "AMD").
+ /// </summary>
+ public required string Vendor { get; init; }
+
+ /// <summary>
+ /// The processor architecture (e.g., "64-bit").
+ /// </summary>
+ public required string Architecture { get; init; }
+
+ /// <summary>
+ /// The number of physical cores.
+ /// </summary>
+ public required int Cores { get; init; }
+
+ /// <summary>
+ /// The number of logical threads.
+ /// </summary>
+ public required int Threads { get; init; }
+
+ /// <summary>
+ /// The maximum clock speed in MHz.
+ /// </summary>
+ public required int MaxClockMHz { get; init; }
+
+ /// <summary>
+ /// The current clock speed in MHz.
+ /// </summary>
+ public required int CurrentClockMHz { get; init; }
+
+ /// <summary>
+ /// The L2 cache size in kilobytes.
+ /// </summary>
+ public required int L2CacheKB { get; init; }
+
+ /// <summary>
+ /// The L3 cache size in kilobytes.
+ /// </summary>
+ public required int L3CacheKB { get; init; }
+
+ /// <summary>
+ /// A sentinel value representing an unknown CPU.
+ /// </summary>
+ public static readonly CpuInfo Unknown = new()
+ {
+ Name = Translations.Common_Unknown,
+ Manufacturer = Translations.Common_Unknown,
+ Vendor = Translations.Common_Unknown,
+ Architecture = Translations.Common_Unknown,
+ Cores = 0,
+ Threads = 0,
+ MaxClockMHz = 0,
+ CurrentClockMHz = 0,
+ L2CacheKB = 0,
+ L3CacheKB = 0
+ };
}
/// <summary>
/// Represents information about a disk volume.
/// </summary>
-public sealed record DiskVolume(
- string Letter,
- bool SystemDrive,
- string FileSystem,
- string DriveType,
- string Label,
- double TotalSizeGB,
- double FreeSpaceGB,
- double UsedSpaceGB,
- double UsedPercent,
- string MediaType, // SSD, HDD, or Unknown
- bool IsRemovable,
- string? SerialNumber,
- string? Model
-);
+public sealed record DiskVolume
+{
+ /// <summary>
+ /// The drive letter (e.g., "C:").
+ /// </summary>
+ public required string DriveLetter { get; init; }
+
+ /// <summary>
+ /// Indicates whether this is the Windows system drive.
+ /// </summary>
+ public required bool IsSystemDrive { get; init; }
+
+ /// <summary>
+ /// The file system format (e.g., "NTFS").
+ /// </summary>
+ public required string DriveFormat { get; init; }
+
+ /// <summary>
+ /// The drive type (e.g., "Fixed", "Removable").
+ /// </summary>
+ public required string DriveType { get; init; }
+
+ /// <summary>
+ /// The volume label.
+ /// </summary>
+ public required string VolumeLabel { get; init; }
+
+ /// <summary>
+ /// The total disk size in gigabytes.
+ /// </summary>
+ public required double TotalSizeGB { get; init; }
+
+ /// <summary>
+ /// The available free space in gigabytes.
+ /// </summary>
+ public required double AvailableSizeGB { get; init; }
+
+ /// <summary>
+ /// The used space in gigabytes.
+ /// </summary>
+ public required double UsedSizeGB { get; init; }
+
+ /// <summary>
+ /// The percentage of disk space used.
+ /// </summary>
+ public required double UsedPercent { get; init; }
+
+ /// <summary>
+ /// The storage media type: "SSD", "HDD", or "Unknown".
+ /// </summary>
+ public required string MediaType { get; init; }
+
+ /// <summary>
+ /// Indicates whether the drive is removable (e.g., USB).
+ /// </summary>
+ public required bool IsRemovable { get; init; }
+
+ /// <summary>
+ /// The disk serial number, or <c>null</c> if unavailable.
+ /// </summary>
+ public string? SerialNumber { get; init; }
+
+ /// <summary>
+ /// The disk model name, or <c>null</c> if unavailable.
+ /// </summary>
+ public string? Model { get; init; }
+}
/// <summary>
/// Represents information about all disk volumes.
/// </summary>
-public sealed record DiskInfo(
- IReadOnlyList<DiskVolume> Volumes
-)
+public sealed record DiskInfo
{
- public static readonly DiskInfo Unknown = new([]);
+ /// <summary>
+ /// The list of detected disk volumes.
+ /// </summary>
+ public required IReadOnlyList<DiskVolume> Volumes { get; init; }
+
+ /// <summary>
+ /// A sentinel value representing unknown disk information.
+ /// </summary>
+ public static readonly DiskInfo Unknown = new() { Volumes = [] };
}
/// <summary>
/// Represents a physical RAM module.
/// </summary>
-public sealed record RamModule(
- double CapacityGB,
- string SpeedMHz,
- string Manufacturer,
- string PartNumber,
- string DeviceLocator
-);
+public sealed record RamModule
+{
+ /// <summary>
+ /// The module capacity in gigabytes.
+ /// </summary>
+ public required double CapacityGB { get; init; }
+
+ /// <summary>
+ /// The memory speed in MHz.
+ /// </summary>
+ public required string SpeedMHz { get; init; }
+
+ /// <summary>
+ /// The module manufacturer.
+ /// </summary>
+ public required string Manufacturer { get; init; }
+
+ /// <summary>
+ /// The module part number.
+ /// </summary>
+ public required string PartNumber { get; init; }
+
+ /// <summary>
+ /// The physical slot or device locator string.
+ /// </summary>
+ public required string DeviceLocator { get; init; }
+}
/// <summary>
/// Represents information about RAM.
/// </summary>
-public sealed record RamInfo(
- double TotalGB,
- long TotalMB,
- long TotalKB,
- double AvailableGB,
- double UsedPercent,
- double UsedGB,
- IReadOnlyList<RamModule> Modules
-)
+public sealed record RamInfo
{
- public static readonly RamInfo Unknown = new(0, 0, 0, 0, 0, 0, []);
+ /// <summary>
+ /// The total installed RAM in gigabytes.
+ /// </summary>
+ public required double TotalGB { get; init; }
+
+ /// <summary>
+ /// The total installed RAM in megabytes.
+ /// </summary>
+ public required long TotalMB { get; init; }
+
+ /// <summary>
+ /// The total installed RAM in kilobytes.
+ /// </summary>
+ public required long TotalKB { get; init; }
+
+ /// <summary>
+ /// The available (free) RAM in gigabytes.
+ /// </summary>
+ public required double AvailableGB { get; init; }
+
+ /// <summary>
+ /// The percentage of RAM currently in use.
+ /// </summary>
+ public required double UsedPercent { get; init; }
+
+ /// <summary>
+ /// The amount of RAM currently in use in gigabytes.
+ /// </summary>
+ public required double UsedGB { get; init; }
+
+ /// <summary>
+ /// The list of physical RAM modules.
+ /// </summary>
+ public required IReadOnlyList<RamModule> Modules { get; init; }
+
+ /// <summary>
+ /// A sentinel value representing unknown RAM information.
+ /// </summary>
+ public static readonly RamInfo Unknown = new() { TotalGB = 0, TotalMB = 0, TotalKB = 0, AvailableGB = 0, UsedPercent = 0, UsedGB = 0, Modules = [] };
}
/// <summary>
/// Represents information about the operating system.
/// </summary>
-public sealed record OsInfo(
- string Name,
- string Version,
- string BuildNumber,
- string Edition,
- string Architecture,
- string DeviceType,
- string InstallDate,
- string LastBoot
-)
+public sealed record OsInfo
{
- public static readonly OsInfo Unknown = new(Translations.Common_Unknown, Translations.Common_Unknown,
- Translations.Common_Unknown, Translations.Common_Unknown, Translations.Common_Unknown,
- Translations.Common_Unknown,
- Translations.Common_Unknown, Translations.Common_Unknown);
+ /// <summary>
+ /// The OS name (e.g., "Microsoft Windows 11 Pro").
+ /// </summary>
+ public required string Name { get; init; }
+
+ /// <summary>
+ /// The OS version string.
+ /// </summary>
+ public required string Version { get; init; }
+
+ /// <summary>
+ /// The OS build number.
+ /// </summary>
+ public required string BuildNumber { get; init; }
+
+ /// <summary>
+ /// The OS edition (e.g., "Pro", "Home").
+ /// </summary>
+ public required string Edition { get; init; }
+
+ /// <summary>
+ /// The OS architecture (e.g., "64-bit").
+ /// </summary>
+ public required string Architecture { get; init; }
+
+ /// <summary>
+ /// The device type inferred from chassis information (e.g., "Desktop", "Laptop").
+ /// </summary>
+ public required string DeviceType { get; init; }
+
+ /// <summary>
+ /// The OS install date.
+ /// </summary>
+ public required string InstallDate { get; init; }
+
+ /// <summary>
+ /// The last boot-up time.
+ /// </summary>
+ public required string LastBootUpTime { get; init; }
+
+ /// <summary>
+ /// A sentinel value representing unknown OS information.
+ /// </summary>
+ public static readonly OsInfo Unknown = new()
+ {
+ Name = Translations.Common_Unknown,
+ Version = Translations.Common_Unknown,
+ BuildNumber = Translations.Common_Unknown,
+ Edition = Translations.Common_Unknown,
+ Architecture = Translations.Common_Unknown,
+ DeviceType = Translations.Common_Unknown,
+ InstallDate = Translations.Common_Unknown,
+ LastBootUpTime = Translations.Common_Unknown
+ };
}
/// <summary>
/// Represents information about the system BIOS.
/// </summary>
-public sealed record BiosInfo(
- string Manufacturer,
- string Version,
- string ReleaseDate,
- string SmbiosVersion,
- string SerialNumber
-)
+public sealed record BiosInfo
{
- public static readonly BiosInfo Unknown = new(Translations.Common_Unknown, Translations.Common_Unknown,
- Translations.Common_Unknown, Translations.Common_Unknown, Translations.Common_Unknown);
+ /// <summary>
+ /// The BIOS manufacturer.
+ /// </summary>
+ public required string Manufacturer { get; init; }
+
+ /// <summary>
+ /// The BIOS version string.
+ /// </summary>
+ public required string Version { get; init; }
+
+ /// <summary>
+ /// The BIOS release date.
+ /// </summary>
+ public required string ReleaseDate { get; init; }
+
+ /// <summary>
+ /// The SMBIOS version.
+ /// </summary>
+ public required string SmbiosVersion { get; init; }
+
+ /// <summary>
+ /// The system serial number.
+ /// </summary>
+ public required string SerialNumber { get; init; }
+
+ /// <summary>
+ /// A sentinel value representing unknown BIOS information.
+ /// </summary>
+ public static readonly BiosInfo Unknown = new()
+ {
+ Manufacturer = Translations.Common_Unknown,
+ Version = Translations.Common_Unknown,
+ ReleaseDate = Translations.Common_Unknown,
+ SmbiosVersion = Translations.Common_Unknown,
+ SerialNumber = 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,
- OsInfo Os,
- BiosInfo Bios,
- IReadOnlyList<GpuInfo> Gpus,
- GpuInfo? PrimaryGpu,
- DiskInfo Disk
-)
+public sealed record SystemSnapshot
{
- public static readonly SystemSnapshot Unknown = new(
- CpuInfo.Unknown,
- RamInfo.Unknown,
- OsInfo.Unknown,
- BiosInfo.Unknown,
- [],
- null,
- DiskInfo.Unknown
- );
+ /// <summary>
+ /// CPU information.
+ /// </summary>
+ public required CpuInfo Cpu { get; init; }
+
+ /// <summary>
+ /// RAM information.
+ /// </summary>
+ public required RamInfo Ram { get; init; }
+
+ /// <summary>
+ /// Operating system information.
+ /// </summary>
+ public required OsInfo Os { get; init; }
+
+ /// <summary>
+ /// BIOS information.
+ /// </summary>
+ public required BiosInfo Bios { get; init; }
+
+ /// <summary>
+ /// List of all detected GPUs.
+ /// </summary>
+ public required IReadOnlyList<GpuInfo> Gpus { get; init; }
+
+ /// <summary>
+ /// The primary GPU (typically the one with the most VRAM), or <c>null</c> if none detected.
+ /// </summary>
+ public GpuInfo? PrimaryGpu { get; init; }
+
+ /// <summary>
+ /// Disk volume information.
+ /// </summary>
+ public required DiskInfo Disk { get; init; }
+
+ /// <summary>
+ /// A sentinel value representing a completely unknown system.
+ /// </summary>
+ public static readonly SystemSnapshot Unknown = new()
+ {
+ Cpu = CpuInfo.Unknown,
+ Ram = RamInfo.Unknown,
+ Os = OsInfo.Unknown,
+ Bios = BiosInfo.Unknown,
+ Gpus = [],
+ PrimaryGpu = null,
+ Disk = DiskInfo.Unknown
+ };
}
// ============================================================================
@@ -381,8 +680,19 @@ internal static class CpuProvider
var vendor = DetectCpuVendor(manufacturer);
var architecture = Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit";
- return new CpuInfo(name, manufacturer, vendor, architecture, cores, threads, maxMHz, currentMHz, l2kb,
- l3kb);
+ return new CpuInfo
+ {
+ Name = name,
+ Manufacturer = manufacturer,
+ Vendor = vendor,
+ Architecture = architecture,
+ Cores = cores,
+ Threads = threads,
+ MaxClockMHz = maxMHz,
+ CurrentClockMHz = currentMHz,
+ L2CacheKB = l2kb,
+ L3CacheKB = l3kb
+ };
}
catch
{
@@ -412,7 +722,16 @@ internal static class RamProvider
var modules = GetPhysicalModules();
var (totalGB, totalMB, totalKB, availableGB, usedPercent, usedGB) = GetMemoryStats(modules);
- return new RamInfo(totalGB, totalMB, totalKB, availableGB, usedPercent, usedGB, modules);
+ return new RamInfo
+ {
+ TotalGB = totalGB,
+ TotalMB = totalMB,
+ TotalKB = totalKB,
+ AvailableGB = availableGB,
+ UsedPercent = usedPercent,
+ UsedGB = usedGB,
+ Modules = modules
+ };
}
catch
{
@@ -436,7 +755,14 @@ internal static class RamProvider
var partNumber = WmiHelper.GetString(mem, "PartNumber");
var deviceLocator = WmiHelper.GetString(mem, "DeviceLocator");
- modules.Add(new RamModule(Math.Round(capacityGB, 2), speed, manufacturer, partNumber, deviceLocator));
+ modules.Add(new RamModule
+ {
+ CapacityGB = Math.Round(capacityGB, 2),
+ SpeedMHz = speed,
+ Manufacturer = manufacturer,
+ PartNumber = partNumber,
+ DeviceLocator = deviceLocator
+ });
}
return modules;
@@ -697,25 +1023,26 @@ internal static class DiskProvider
// Media type priority: PhysicalDisk info > seek penalty P/Invoke > WMI fallback
var mediaType = diskInfo?.MediaType ?? DiskHelper.DetectMediaType(drive.Name);
- return new DiskVolume(
- drive.Name.TrimEnd('\\'),
- isSystemDrive,
- drive.DriveFormat,
- drive.DriveType.ToString(),
- string.IsNullOrWhiteSpace(drive.VolumeLabel) ? "Local Disk" : drive.VolumeLabel,
- ToGb(totalBytes),
- ToGb(freeBytes),
- ToGb(usedBytes),
- totalBytes > 0 ? Math.Round(usedBytes * 100.0 / totalBytes, 1) : 0,
- mediaType,
- isRemovable,
- diskInfo?.SerialNumber,
- diskInfo?.Model
- );
+ return new DiskVolume
+ {
+ DriveLetter = drive.Name.TrimEnd('\\'),
+ IsSystemDrive = isSystemDrive,
+ DriveFormat = drive.DriveFormat,
+ DriveType = drive.DriveType.ToString(),
+ VolumeLabel = string.IsNullOrWhiteSpace(drive.VolumeLabel) ? "Local Disk" : drive.VolumeLabel,
+ TotalSizeGB = ToGb(totalBytes),
+ AvailableSizeGB = ToGb(freeBytes),
+ UsedSizeGB = ToGb(usedBytes),
+ UsedPercent = totalBytes > 0 ? Math.Round(usedBytes * 100.0 / totalBytes, 1) : 0,
+ MediaType = mediaType,
+ IsRemovable = isRemovable,
+ SerialNumber = diskInfo?.SerialNumber,
+ Model = diskInfo?.Model
+ };
})
.ToList();
- return new DiskInfo(volumes);
+ return new DiskInfo { Volumes = volumes };
}
catch
{
@@ -1093,14 +1420,15 @@ internal static class GpuProvider
// Match to WMI entry for DriverVersion and DeviceID
var wmiMatch = FindWmiMatch(name, desc.VendorId, desc.DeviceId, wmiLookup);
- gpus.Add(new GpuInfo(
- name,
- wmiMatch?.DriverVersion ?? Translations.Common_Unknown,
- vendor,
- memoryMB > 0 ? memoryMB : null,
- wmiMatch?.DeviceId,
- wmiMatch?.PnpDeviceId
- ));
+ gpus.Add(new GpuInfo
+ {
+ Name = name,
+ DriverVersion = wmiMatch?.DriverVersion ?? Translations.Common_Unknown,
+ Vendor = vendor,
+ MemoryMB = memoryMB > 0 ? memoryMB : null,
+ DeviceId = wmiMatch?.DeviceId,
+ PnpDeviceId = wmiMatch?.PnpDeviceId
+ });
}
finally
{
@@ -1138,7 +1466,15 @@ internal static class GpuProvider
int? memoryMB = adapterRam > 0 ? (int)(adapterRam / (1024 * 1024)) : null;
var vendor = DetectGpuVendor(name, pnpId);
- gpus.Add(new GpuInfo(name, driver, vendor, memoryMB, deviceId, pnpId));
+ gpus.Add(new GpuInfo
+ {
+ Name = name,
+ DriverVersion = driver,
+ Vendor = vendor,
+ MemoryMB = memoryMB,
+ DeviceId = deviceId,
+ PnpDeviceId = pnpId
+ });
}
return gpus.Count > 0 ? gpus : [GpuInfo.Unknown];
@@ -1329,7 +1665,17 @@ internal static class OsProvider
if (os != null)
lastBoot = FormatWmiDateTime(WmiHelper.GetString(os, "LastBootUpTime", ""));
- return new OsInfo(name, version, buildNumber, edition, architecture, deviceType, installDate, lastBoot);
+ return new OsInfo
+ {
+ Name = name,
+ Version = version,
+ BuildNumber = buildNumber,
+ Edition = edition,
+ Architecture = architecture,
+ DeviceType = deviceType,
+ InstallDate = installDate,
+ LastBootUpTime = lastBoot
+ };
}
catch
{
@@ -1408,7 +1754,14 @@ internal static class BiosProvider
var serialNumber = WmiHelper.GetString(bios, "SerialNumber");
var releaseDate = FormatWmiDate(WmiHelper.GetString(bios, "ReleaseDate", ""));
- return new BiosInfo(manufacturer, version, releaseDate, smbiosVersion, serialNumber);
+ return new BiosInfo
+ {
+ Manufacturer = manufacturer,
+ Version = version,
+ ReleaseDate = releaseDate,
+ SmbiosVersion = smbiosVersion,
+ SerialNumber = serialNumber
+ };
}
catch
{
@@ -1472,8 +1825,16 @@ public sealed class SystemInfoService
var primaryGpu = GpuProvider.GetPrimary(_cachedGpus);
- Snapshot = new SystemSnapshot(_cachedCpu, await ramTask, _cachedOs, _cachedBios, _cachedGpus,
- primaryGpu, await diskTask);
+ Snapshot = new SystemSnapshot
+ {
+ Cpu = _cachedCpu,
+ Ram = await ramTask,
+ Os = _cachedOs,
+ Bios = _cachedBios,
+ Gpus = _cachedGpus,
+ PrimaryGpu = primaryGpu,
+ Disk = await diskTask
+ };
}
else
{
@@ -1487,8 +1848,16 @@ public sealed class SystemInfoService
var gpus = _cachedGpus!;
var primaryGpu = GpuProvider.GetPrimary(gpus);
- Snapshot = new SystemSnapshot(_cachedCpu!, await ramTask, _cachedOs!, _cachedBios!, gpus, primaryGpu,
- await diskTask);
+ Snapshot = new SystemSnapshot
+ {
+ Cpu = _cachedCpu!,
+ Ram = await ramTask,
+ Os = _cachedOs!,
+ Bios = _cachedBios!,
+ Gpus = gpus,
+ PrimaryGpu = primaryGpu,
+ Disk = await diskTask
+ };
}
return Snapshot;
@@ -1521,11 +1890,11 @@ public sealed class SystemInfoService
foreach (var volume in Snapshot.Disk.Volumes)
{
- var systemDrive = volume.SystemDrive ? " [System Drive]" : "";
+ var systemDrive = volume.IsSystemDrive ? " [System Drive]" : "";
var modelInfo = !string.IsNullOrEmpty(volume.Model) ? $" - {volume.Model}" : "";
_logger.LogInformation(
"Disk {VolumeLetter}{SystemDrive} [{MediaType}] {VolumeTotalSizeGb:F1} GB (Free: {VolumeFreeSpaceGb:F1} GB){ModelInfo}",
- volume.Letter, systemDrive, volume.MediaType, volume.TotalSizeGB, volume.FreeSpaceGB, modelInfo);
+ volume.DriveLetter, systemDrive, volume.MediaType, volume.TotalSizeGB, volume.AvailableSizeGB, modelInfo);
}
}
catch (Exception ex)
diff --git a/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs
index bbbbf15..b7cb3c5 100644
--- a/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs
@@ -47,8 +47,8 @@ public partial class SettingsViewModel(
public ObservableCollection<LanguageOption> Languages { get; } =
[
- new("English", new CultureInfo("en-US")),
- new("Tiếng Việt", new CultureInfo("vi-VN"))
+ new() { DisplayName = "English", Culture = new CultureInfo("en-US") },
+ new() { DisplayName = "Tiếng Việt", Culture = new CultureInfo("vi-VN") }
];
public override async Task OnNavigatedToAsync()
diff --git a/optimizerDuck/UI/Views/Pages/DashboardPage.xaml b/optimizerDuck/UI/Views/Pages/DashboardPage.xaml
index 5ca98e4..119b04e 100644
--- a/optimizerDuck/UI/Views/Pages/DashboardPage.xaml
+++ b/optimizerDuck/UI/Views/Pages/DashboardPage.xaml
@@ -407,7 +407,7 @@
<ui:SymbolIcon.Style>
<Style TargetType="ui:SymbolIcon">
<Style.Triggers>
- <DataTrigger Binding="{Binding SystemDrive}" Value="True">
+ <DataTrigger Binding="{Binding IsSystemDrive}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource SystemFillColorAttentionBrush}" />
</DataTrigger>
</Style.Triggers>
@@ -429,12 +429,12 @@
<ui:TextBlock
FontTypography="BodyStrong"
Margin="0,0,5,0"
- Text="{Binding Letter, StringFormat='({0})'}" />
+ Text="{Binding DriveLetter, StringFormat='({0})'}" />
<ui:TextBlock
FontTypography="Caption"
Margin="0,0,5,0"
- Text="{Binding Label}"
+ Text="{Binding VolumeLabel}"
VerticalAlignment="Center" />
<Border
@@ -443,7 +443,7 @@
Margin="0,0,4,0"
Padding="5,2"
VerticalAlignment="Center"
- Visibility="{Binding SystemDrive, Converter={StaticResource BoolToVisibilityConverter}}">
+ Visibility="{Binding IsSystemDrive, Converter={StaticResource BoolToVisibilityConverter}}">
<ui:TextBlock
FontTypography="Caption"
Foreground="Black"
@@ -477,7 +477,7 @@
CornerRadius="4"
Padding="5,2"
VerticalAlignment="Center">
- <ui:TextBlock FontTypography="Caption" Text="{Binding FileSystem}" />
+ <ui:TextBlock FontTypography="Caption" Text="{Binding DriveFormat}" />
</Border>
</StackPanel>
@@ -500,9 +500,9 @@
Appearance="Secondary"
FontTypography="Caption"
Text="{ext:Loc Dashboard.SystemInfo.Storage.DiskInfo,
- {Binding UsedSpaceGB, StringFormat='{}{0:F1}'},
+ {Binding UsedSizeGB, StringFormat='{}{0:F1}'},
{Binding TotalSizeGB, StringFormat='{}{0:F1}'},
- {Binding FreeSpaceGB, StringFormat='{}{0:F1}'}}" />
+ {Binding AvailableSizeGB, StringFormat='{}{0:F1}'}}" />
</StackPanel>
<!-- Progress Bar -->