Skip to content

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

docs: refactor documentation comments across various ViewModels for clarity and consistency

fatDuckd8f652c3b14e
diff --git a/AGENTS.md b/AGENTS.md
index ed47ed2..df0dca2 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -15,6 +15,10 @@
- `dotnet run --project optimizerDuck/optimizerDuck.csproj` — run locally (needs admin).
- `publish.bat portable` or `publish.bat single --skip-tests` — create release artifacts.
- `csharpier format .` — format all code with CSharpier (`csharpier check .` to verify without writing).
+ - Invoke it as `csharpier`, never `dotnet csharpier`: it is a global tool, and `dotnet csharpier` fails with
+ "command not found", which reads like the tool is missing when it is not.
+ - The editor runs CSharpier on file change here, so a file you touch can come back with unrelated code lines
+ reflowed into the house style. That is the formatter, not your edit.
## Project Structure
- `optimizerDuck/` — WPF app (single project, no sub-projects):
diff --git a/optimizerDuck.Test/Domain/Customize/BaseCustomizeSettingTests.cs b/optimizerDuck.Test/Domain/Customize/BaseCustomizeSettingTests.cs
index 0275a77..1fa00b5 100644
--- a/optimizerDuck.Test/Domain/Customize/BaseCustomizeSettingTests.cs
+++ b/optimizerDuck.Test/Domain/Customize/BaseCustomizeSettingTests.cs
@@ -46,7 +46,7 @@ public class BaseCustomizeSettingTests : IDisposable
private sealed class EmptyTogglesSetting : BaseCustomizeSetting
{
- // No overrides: base GetStateAsync reads empty toggles → returns false
+ // No overrides, so the base GetStateAsync reads empty toggles and returns false.
}
private sealed class OscillatingStateSetting : BaseCustomizeSetting
@@ -134,16 +134,13 @@ public class BaseCustomizeSettingTests : IDisposable
{
var setting = new TestCustomizeSetting { OwnerType = typeof(TestCustomizeSetting) };
- // Initially should be false (value doesn't exist)
var initialState = await setting.GetStateAsync();
Assert.False(initialState);
- // Enable
Assert.True((await setting.ApplyAsync(true, NewCall())).Ok);
var enabledState = await setting.GetStateAsync();
Assert.True(enabledState);
- // Disable
Assert.True((await setting.ApplyAsync(false, NewCall())).Ok);
var disabledState = await setting.GetStateAsync();
Assert.False(disabledState);
@@ -154,7 +151,6 @@ public class BaseCustomizeSettingTests : IDisposable
{
var setting = new TestCustomizeSetting { OwnerType = typeof(TestCustomizeSetting) };
- // Perform multiple rapid toggles
for (int i = 0; i < 10; i++)
{
Assert.True((await setting.ApplyAsync(true, NewCall())).Ok);
@@ -170,7 +166,6 @@ public class BaseCustomizeSettingTests : IDisposable
Assert.Equal(0, disabledValue);
}
- // Final state should be disabled
var finalState = await setting.GetStateAsync();
Assert.False(finalState);
}
@@ -204,14 +199,14 @@ public class BaseCustomizeSettingTests : IDisposable
var result = await setting.GetStateWithRetryAsync(maxRetries: 5, delayMs: 10);
- // 5 reads with alternating values: T, F, T, F, T → never converges → returns last (true)
+ // Five alternating reads never converge, so the last one (true) is returned.
Assert.True(result);
}
[Fact]
public async Task GetStateWithRetryAsync_WithNoToggles_ReturnsFalse()
{
- // Empty toggles → base GetStateAsync returns false
+ // Empty toggles, so the base GetStateAsync returns false.
var setting = new EmptyTogglesSetting();
var result = await setting.GetStateWithRetryAsync(maxRetries: 2, delayMs: 10);
@@ -276,7 +271,7 @@ public class BaseCustomizeSettingTests : IDisposable
[Fact]
public void WatchedRegistryPaths_WhenNoToggles_ReturnsEmpty()
{
- // StableStateSetting has no toggles overrides → empty
+ // StableStateSetting declares no toggles, so the path list is empty.
ICustomizeSetting setting = new StableStateSetting();
var paths = setting.WatchedRegistryPaths;
@@ -403,8 +398,7 @@ public class BaseCustomizeSettingTests : IDisposable
{
var setting = new DefaultScopeSetting { OwnerType = typeof(DefaultScopeSetting) };
- // With RefreshScope = None, the base ApplyAsync must skip
- // ExecutePostActionAsync entirely. We confirm the gate behaviour:
+ // With RefreshScope = None the base ApplyAsync skips ExecutePostActionAsync;
// NeedsPostAction is false, so no refresh runs.
Assert.False(GetNeedsPostAction(setting));
Assert.True((await setting.ApplyAsync(false, NewCall())).Ok); // must not throw
@@ -413,9 +407,8 @@ public class BaseCustomizeSettingTests : IDisposable
[Fact]
public async Task ApplyAsync_WhenRefreshScopeIsSet_RunsWithoutThrowing()
{
- // Smoke test: every declared scope variant must produce a working
- // ApplyAsync that touches the registry and runs the refresh pipeline
- // without exceptions on a real Windows host.
+ // Every declared scope variant must produce a working ApplyAsync that touches
+ // the registry and runs the refresh pipeline on a real Windows host.
var settings = new BaseCustomizeSetting[]
{
new DefaultExplorerScopeSetting { OwnerType = typeof(DefaultExplorerScopeSetting) },
@@ -522,7 +515,7 @@ public class BaseCustomizeSettingTests : IDisposable
[Fact]
public void RegistryToggle_GetState_ReturnsTrueWhenKeyAbsentAndNullInOnValues()
{
- // Key doesn't exist → value is null
+ // The key is absent, so the value is null, which is one of the OnValues.
var toggle = new RegistryToggle
{
Path = TestKeyPath,
@@ -573,7 +566,6 @@ public class BaseCustomizeSettingTests : IDisposable
[Fact]
public void RegistryToggle_SetState_DeletesKeyWhenFirstValueIsNull()
{
- // First write a value
RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "NullSetTest", 1));
var toggle = new RegistryToggle
@@ -595,7 +587,6 @@ public class BaseCustomizeSettingTests : IDisposable
[Fact]
public void RegistryToggle_GetState_MatchesMultipleOnValues()
{
- // Value 1 → ON
RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "MultiOnTest", 1));
var toggle = new RegistryToggle
{
@@ -606,7 +597,6 @@ public class BaseCustomizeSettingTests : IDisposable
};
Assert.True(toggle.GetState());
- // Value 2 → also ON
RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "MultiOnTest", 2));
Assert.True(toggle.GetState());
@@ -785,9 +775,8 @@ public class BaseCustomizeSettingTests : IDisposable
[Fact]
public void Options_MissingValue_AddsCustomFallbackWithSentinel()
{
- // Even when the registry value is missing entirely, the ComboBox must never
- // render empty: a synthetic fallback (with a stable non-null sentinel value so
- // WPF can select it) is appended, labeled distinctly from "Custom".
+ // A missing registry value must not leave the ComboBox empty: a synthetic
+ // fallback with a stable non-null sentinel (so WPF can select it) is appended.
var setting = new TestDropdownSetting { OwnerType = typeof(TestDropdownSetting) };
RegistryService.DeleteValue(NewCall(), new RegistryItem(TestKeyPath, "DropdownTest"));
@@ -810,8 +799,8 @@ public class BaseCustomizeSettingTests : IDisposable
[Fact]
public async Task ApplyAsync_MissingValueSentinel_IsSafeNoOp()
{
- // The sentinel must never leak into the registry: applying it resolves against
- // declared Options (where it never exists), so nothing is written and it throws.
+ // The sentinel must never reach the registry: it matches no declared option, so
+ // the apply writes nothing.
var setting = new TestDropdownSetting { OwnerType = typeof(TestDropdownSetting) };
RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "DropdownTest", 1));
@@ -857,9 +846,9 @@ public class BaseCustomizeSettingTests : IDisposable
{
var setting = new TestMultiBindingDropdown { OwnerType = typeof(TestMultiBindingDropdown) };
- // Key A = 1 (matches "On" primary) but Key B = 0 → mixed state. It must not be
- // reported as the declared "On" option; a "Custom" fallback with a distinct identity
- // is selected instead (a duplicate value would make SelectedValuePath ambiguous).
+ // Key A matches "On" but Key B does not, so the state is mixed. A "Custom" fallback
+ // with a distinct identity is selected, because a duplicate value would make
+ // SelectedValuePath ambiguous.
RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "Key1", 1));
RegistryService.Write(
NewCall(),
@@ -970,7 +959,7 @@ public class BaseCustomizeSettingTests : IDisposable
{
var setting = new TestNotSetOptionDropdown { OwnerType = typeof(TestNotSetOptionDropdown) };
- // Not set → apply declared "On" → value written → apply "NotSet" → deleted again.
+ // Absent, then written by "On", then deleted again by "NotSet".
RegistryService.DeleteValue(NewCall(), new RegistryItem(TestKeyPath, "NotSetOptionTest"));
Assert.Equal("notset", setting.CurrentValue);
@@ -1043,7 +1032,7 @@ public class BaseCustomizeSettingTests : IDisposable
{
var setting = new TestMultiBindingDropdown { OwnerType = typeof(TestMultiBindingDropdown) };
- // Both keys = 1 → option "On" matches
+ // Both keys hold 1, so the option "On" matches.
RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "Key1", 1));
RegistryService.Write(
NewCall(),
@@ -1051,8 +1040,8 @@ public class BaseCustomizeSettingTests : IDisposable
);
Assert.Equal(1, setting.CurrentValue);
- // Key A = 1, Key B = 0 → mixed state: the "Custom" fallback is selected instead of
- // the declared "On" option, and applying it must not write anything.
+ // Key A is 1 and Key B is 0, so the state is mixed: the "Custom" fallback is
+ // selected and applying it must not write anything.
RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "Key1", 1));
RegistryService.Write(
NewCall(),
@@ -1132,7 +1121,6 @@ public class BaseCustomizeSettingTests : IDisposable
{
var setting = new TestMatchMissingDropdown { OwnerType = typeof(TestMatchMissingDropdown) };
- // Ensure key is deleted (absent)
RegistryService.DeleteValue(NewCall(), new RegistryItem(TestKeyPath, "AlignTestKey"));
// Must match "Center" (value 1) without creating synthetic "Not set" fallback
@@ -1170,7 +1158,7 @@ public class BaseCustomizeSettingTests : IDisposable
OwnerType = typeof(TestMultiBindingWithDefaultDropdown),
};
- // Both absent -> matches Always (0)
+ // Both keys absent, so the option "Always" matches.
RegistryService.DeleteValue(NewCall(), new RegistryItem(TestKeyPath, "Glom1"));
RegistryService.DeleteValue(
NewCall(),
@@ -1179,7 +1167,7 @@ public class BaseCustomizeSettingTests : IDisposable
Assert.Equal(0, setting.CurrentValue);
- // Apply Never (2) -> writes both keys
+ // Applying "Never" writes both keys.
Assert.True((await setting.ApplyAsync(2, NewCall())).Ok);
Assert.Equal(2, setting.CurrentValue);
Assert.Equal(2, RegistryService.Read<int>(new RegistryItem(TestKeyPath, "Glom1")));
diff --git a/optimizerDuck.Test/Domain/Execution/ChangeDetailTests.cs b/optimizerDuck.Test/Domain/Execution/ChangeDetailTests.cs
index 45c63f0..7c8bdbf 100644
--- a/optimizerDuck.Test/Domain/Execution/ChangeDetailTests.cs
+++ b/optimizerDuck.Test/Domain/Execution/ChangeDetailTests.cs
@@ -10,8 +10,9 @@ using optimizerDuck.Test.TestDoubles;
namespace optimizerDuck.Test.Domain.Execution;
/// <summary>
-/// The typed facts of a step: how long they live, what the kinds that move between two values
-/// say they do, and how they survive the record file, including one written by an earlier build.
+/// The typed facts of a step: how long they live, what the kinds that move between
+/// two values say they do, and how they survive the record file, including one
+/// written by an earlier build.
/// </summary>
public class ChangeDetailTests
{
@@ -42,7 +43,8 @@ public class ChangeDetailTests
[Fact]
public void EveryKindDeclaresAnOperationCodeAndTheFileKeepsTheOnesItAlreadyHad()
{
- // The codes are the wire format, so decoding has to keep matching the names old records carry.
+ // The codes are the wire format, so decoding has to keep matching the names
+ // old records carry.
var codes = EveryOperationDetail.Items.Select(detail => detail.Operation).Order().ToList();
Assert.Equal(
@@ -147,7 +149,7 @@ public class ChangeDetailTests
Assert.Null(hibernation.PreviousPresent);
Assert.False(hibernation.NewPresent);
- // A field the operation has no meaning for is dropped rather than shown.
+ // A field the operation has no meaning for is dropped from the row.
var service = Assert.IsType<ServiceStartupDetail>(
ChangeDetailCodec.Decode(record.Steps[2])
);
diff --git a/optimizerDuck.Test/Domain/Revert/Steps/HibernationRevertStepTests.cs b/optimizerDuck.Test/Domain/Revert/Steps/HibernationRevertStepTests.cs
index 40e50c0..751c660 100644
--- a/optimizerDuck.Test/Domain/Revert/Steps/HibernationRevertStepTests.cs
+++ b/optimizerDuck.Test/Domain/Revert/Steps/HibernationRevertStepTests.cs
@@ -48,8 +48,8 @@ public class HibernationRevertStepTests
[Fact]
public async Task ExecuteAsync_UnknownState_ChangesNothingAndSucceeds()
{
- // The optimisation's own default is no longer "assume it was present": an unknown state
- // restores nothing, so a revert cannot create a hibernation file that never existed.
+ // An unknown state restores nothing, so a revert cannot create a hibernation file
+ // that never existed.
var before = HibernationService.IsHibernationFilePresent();
var step = new HibernationRevertStep { WasPresent = null };
diff --git a/optimizerDuck.Test/Domain/Revert/Steps/RevertStepSerializationTests.cs b/optimizerDuck.Test/Domain/Revert/Steps/RevertStepSerializationTests.cs
index 7b85b38..6e1df6c 100644
--- a/optimizerDuck.Test/Domain/Revert/Steps/RevertStepSerializationTests.cs
+++ b/optimizerDuck.Test/Domain/Revert/Steps/RevertStepSerializationTests.cs
@@ -41,9 +41,8 @@ public class RevertStepSerializationTests
[Fact]
public void HibernationRevertStep_MissingFlag_MeansUnknown()
{
- // Deliberate reversal: the old fail-safe assumed hibernation was present, so a revert
- // committed a hibernation file that may never have existed. Unknown now restores nothing
- // and says so. HibernationRevertStepTests covers the three states in full.
+ // An unknown state restores nothing, so a revert cannot create a hibernation file
+ // that never existed.
var restored = HibernationRevertStep.FromData(new JObject());
Assert.Null(restored.WasPresent);
diff --git a/optimizerDuck.Test/Domain/Revert/Steps/ScheduledTaskRevertStepTests.cs b/optimizerDuck.Test/Domain/Revert/Steps/ScheduledTaskRevertStepTests.cs
index 8a80b7b..99f84b4 100644
--- a/optimizerDuck.Test/Domain/Revert/Steps/ScheduledTaskRevertStepTests.cs
+++ b/optimizerDuck.Test/Domain/Revert/Steps/ScheduledTaskRevertStepTests.cs
@@ -11,8 +11,7 @@ public class ScheduledTaskRevertStepTests
[Fact]
public async Task ExecuteAsync_WithMissingTask_SucceedsBecauseThereIsNothingToRestore()
{
- // Deliberate reversal: a missing task used to fail inside the provider before the step's
- // own check ran. The provider now reports it as nothing to change, so the step reaches the
+ // The provider reports a missing task as nothing to change, so the step reaches the
// branch it was written for: a task that no longer exists has nothing to restore.
var step = new ScheduledTaskRevertStep
{
diff --git a/optimizerDuck.Test/Domain/UI/ChangeDetailPresentationTests.cs b/optimizerDuck.Test/Domain/UI/ChangeDetailPresentationTests.cs
index 4673c01..be54ab9 100644
--- a/optimizerDuck.Test/Domain/UI/ChangeDetailPresentationTests.cs
+++ b/optimizerDuck.Test/Domain/UI/ChangeDetailPresentationTests.cs
@@ -56,7 +56,8 @@ public class ChangeDetailPresentationTests
[MemberData(nameof(EveryOperationDetail.All), MemberType = typeof(EveryOperationDetail))]
public void EveryKeyARowCanShowResolvesToText(ChangeDetail detail)
{
- // The module names its resource keys as literals, so a typo would reach the UI as a raw key.
+ // The module names its resource keys as literals, so a typo would reach the UI
+ // as a raw key.
foreach (
var operation in new[] { ChangeRecordOperation.Apply, ChangeRecordOperation.Revert }
)
diff --git a/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.cs b/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.cs
index cbf5f1e..1c8e630 100644
--- a/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.cs
+++ b/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.cs
@@ -16,10 +16,6 @@ using Wpf.Ui;
namespace optimizerDuck.Test.Services;
-/// <summary>
-/// Comprehensive tests for apply and revert operations covering all scenarios.
-/// These tests ensure safe operation without affecting the actual machine.
-/// </summary>
public class ApplyRevertComprehensiveTests
{
#region Apply Success Scenarios
@@ -87,7 +83,6 @@ public class ApplyRevertComprehensiveTests
Assert.Equal(optimization.Id, data!.OptimizationId);
Assert.Equal(3, data.Steps.Length);
- // Verify all steps are present and in correct order
Assert.NotNull(data.Steps[0]);
Assert.NotNull(data.Steps[1]);
Assert.NotNull(data.Steps[2]);
@@ -95,7 +90,6 @@ public class ApplyRevertComprehensiveTests
Assert.Equal("Shell", data.Steps[1]!.Type);
Assert.Equal("Shell", data.Steps[2]!.Type);
- // Verify revert commands are correct
Assert.Equal(
"sc config TestService start= auto",
data.Steps[0]!.Data[nameof(ShellRevertStep.Command)]?.ToString()
@@ -245,7 +239,6 @@ public class ApplyRevertComprehensiveTests
// Compact layout: only the 3 successful steps persist, in order.
Assert.Equal(3, data!.Steps.Length);
- // Verify commands are in execution order
Assert.Equal(
"exit 11",
data.Steps[0]!.Data[nameof(ShellRevertStep.Command)]?.ToString()
@@ -331,7 +324,6 @@ public class ApplyRevertComprehensiveTests
{
Directory.CreateDirectory(Shared.RevertDirectory);
- // Create revert data with 3 successful steps
var payload = new RevertData
{
OptimizationId = optimization.Id,
@@ -457,7 +449,6 @@ public class ApplyRevertComprehensiveTests
{
Directory.CreateDirectory(Shared.RevertDirectory);
- // Create revert data with ordered steps
var payload = new RevertData
{
OptimizationId = optimization.Id,
@@ -510,8 +501,6 @@ public class ApplyRevertComprehensiveTests
var result = await manager.RevertAsync(optimization);
Assert.True(result.Success);
- // Steps should execute in reverse order: 3, 2, 1
- // This is verified by the revert manager implementation
}
finally
{
@@ -533,7 +522,6 @@ public class ApplyRevertComprehensiveTests
{
Directory.CreateDirectory(Shared.RevertDirectory);
- // Create revert data with gaps (null steps from failed apply steps)
var payload = new RevertData
{
OptimizationId = optimization.Id,
@@ -660,7 +648,6 @@ public class ApplyRevertComprehensiveTests
Assert.Null(updatedData!.Steps[0]); // Step 1 succeeded and was removed
Assert.NotNull(updatedData.Steps[1]); // Step 2 failed and is preserved
- // Failed step should have retry action
Assert.NotNull(result.FailedSteps[0].Retry);
}
finally
@@ -790,14 +777,11 @@ public class ApplyRevertComprehensiveTests
Assert.False(result.Success);
Assert.True(File.Exists(revertPath)); // Preserved because step 2 failed
- // Retry the failed step - note: retry will also fail because it's still "exit 1"
var failedStep = result.FailedSteps.FirstOrDefault();
Assert.NotNull(failedStep);
Assert.NotNull(failedStep.Retry);
- // Retry will fail because the command is still "exit 1"
- // This is expected behavior - retry just re-executes the same command
- // ExecuteAsync throws exception on failure, so we need to catch it
+ // Retry re-executes the same command, so it fails again and reports as a throw.
var exception = await Record.ExceptionAsync(async () =>
{
await failedStep.Retry!(new OpCall { Logger = NullLogger.Instance });
@@ -845,7 +829,6 @@ public class ApplyRevertComprehensiveTests
try
{
- // Phase 1: Apply
var service = CreateService();
var progress = new Progress<ProcessingProgress>(_ => { });
@@ -857,7 +840,6 @@ public class ApplyRevertComprehensiveTests
Assert.NotNull(data);
Assert.Equal(2, data!.Steps.Length);
- // Phase 2: Revert
var revertResult = await service.RevertAsync(optimization, progress);
Assert.True(revertResult.Success);
Assert.False(File.Exists(revertPath));
@@ -899,7 +881,6 @@ public class ApplyRevertComprehensiveTests
try
{
- // Phase 1: Apply with partial success
var service = CreateService();
var progress = new Progress<ProcessingProgress>(_ => { });
@@ -914,7 +895,6 @@ public class ApplyRevertComprehensiveTests
Assert.NotNull(data.Steps[0]);
Assert.NotNull(data.Steps[1]);
- // Phase 2: Revert should only revert steps 1 and 3
var revertResult = await service.RevertAsync(optimization, progress);
Assert.True(revertResult.Success);
Assert.False(File.Exists(revertPath));
@@ -979,11 +959,9 @@ public class ApplyRevertComprehensiveTests
var service = CreateService();
var progress = new Progress<ProcessingProgress>(_ => { });
- // Phase 1: Apply with failure
var applyResult = await service.ApplyAsync(optimization, progress);
Assert.Equal(OptimizationSuccessResult.PartialSuccess, applyResult.Status);
- // Phase 2: Retry failed steps
var retryResult = await OptimizationService.RetryFailedStepsWithResultsAsync(
applyResult.FailedSteps,
false,
@@ -994,7 +972,6 @@ public class ApplyRevertComprehensiveTests
Assert.Single(retryResult.RecoveredSteps);
Assert.Equal(2, retryResult.RecoveredSteps[0].Index);
- // Phase 3: Append the recovered step
var revertManager = new RevertManager(
NullLogger<RevertManager>.Instance,
TestShell.New(),
@@ -1007,12 +984,10 @@ public class ApplyRevertComprehensiveTests
retryResult.RecoveredSteps[0].Revert!
);
- // Verify complete revert data
var data = await RevertManager.GetRevertDataAsync(optimization.Id);
Assert.NotNull(data);
Assert.Equal(3, data!.Steps.Length);
- // All steps should now have "exit 0" commands
Assert.Equal(
"exit 0",
data.Steps[0]!.Data[nameof(ShellRevertStep.Command)]?.ToString()
@@ -1026,7 +1001,6 @@ public class ApplyRevertComprehensiveTests
data.Steps[2]!.Data[nameof(ShellRevertStep.Command)]?.ToString()
);
- // Phase 4: Revert all steps successfully
var revertResult = await service.RevertAsync(optimization, progress);
Assert.True(revertResult.Success);
Assert.False(File.Exists(revertPath));
@@ -1234,8 +1208,8 @@ public class ApplyRevertComprehensiveTests
{
await RunInStaThreadAsync(async () =>
{
- // A provider that records only skips and returns ToApplyResult() must not be
- // reported as a failure, which was the case before the classification changed.
+ // A provider that records only skips and returns ToApplyResult() is nothing
+ // to do, not a failure.
var optimization = new TestOptimization
{
Id = Guid.NewGuid(),
diff --git a/optimizerDuck.Test/Services/Managers/RevertManagerTests.cs b/optimizerDuck.Test/Services/Managers/RevertManagerTests.cs
index ea53774..63fff47 100644
--- a/optimizerDuck.Test/Services/Managers/RevertManagerTests.cs
+++ b/optimizerDuck.Test/Services/Managers/RevertManagerTests.cs
@@ -67,10 +67,8 @@ public class RevertManagerTests
[Fact]
public async Task IsAppliedAsync_WithInvalidJson_CountsAsApplied()
{
- // Deliberate reversal: a file that exists but cannot be parsed still means the item was
- // applied once. Reporting it as untouched invited a fresh apply, which then wrote over
- // the only copy of the backup. The payload is parked by the next save instead, which
- // RevertIntegrityTests covers.
+ // A file that exists but cannot be parsed still counts as applied: treating it as
+ // untouched would invite a fresh apply over the only copy of the backup.
var id = Guid.NewGuid();
var path = Path.Combine(Shared.RevertDirectory, id + ".json");
var cancellationToken = TestContext.Current.CancellationToken;
@@ -376,8 +374,7 @@ public class RevertManagerTests
[Fact]
public async Task SaveRevertDataAsync_DuplicatePayload_BothEntriesPersist()
{
- // Regression: payload-based dedupe once dropped the second of two
- // identical executions, losing revert coverage.
+ // Two identical executions both persist: dropping one would lose revert coverage.
var id = Guid.NewGuid();
var path = Path.Combine(Shared.RevertDirectory, id + ".json");
var manager = new RevertManager(
@@ -779,8 +776,8 @@ public class RevertIntegrityTests
[Fact]
public async Task SaveRevertDataAsync_FailedChangeWithCompensation_IsStillPersisted()
{
- // A step that was refused after it had already changed something still needs its
- // previous state recorded, so the writer no longer requires a success flag.
+ // A step refused after it had already changed something still needs its previous
+ // state recorded, so the writer cannot require a success flag.
var id = Guid.NewGuid();
var changes = new ChangeSet();
changes.Add(
diff --git a/optimizerDuck.Test/Services/OptimizationExecutionContextTests.cs b/optimizerDuck.Test/Services/OptimizationExecutionContextTests.cs
index 55c600a..f772c72 100644
--- a/optimizerDuck.Test/Services/OptimizationExecutionContextTests.cs
+++ b/optimizerDuck.Test/Services/OptimizationExecutionContextTests.cs
@@ -106,9 +106,9 @@ public class ChangeSetTests
[Fact]
public void ToApplyResult_Empty_ReturnsSuccess()
{
- // Deliberate reversal: an item can legitimately match nothing on this machine, so a run
- // that recorded no step at all is nothing to do rather than a failure. A provider that
- // changed something without recording it is caught by the compensation guard instead.
+ // An item can legitimately match nothing on this machine, so a run that recorded
+ // no step at all is nothing to do, not a failure. A provider that changed
+ // something without recording it is caught by the compensation guard instead.
var changes = new ChangeSet();
var result = changes.ToApplyResult();
@@ -159,6 +159,7 @@ public class ChangeSetTests
Assert.Equal(100, changes.Changes.Count);
Assert.Equal(100, changes.Changes.Select(c => c.Index).Distinct().Count());
}
+
[Fact]
public void AddSkip_RecordsSuccessfulSkipWithoutCompensation()
{
@@ -229,6 +230,7 @@ public class MockRevertStep : IRevertStep
{
return new MockRevertStep();
}
+
[Fact]
public void AddNotApplicable_RecordsStepWithoutCompensation()
{
diff --git a/optimizerDuck.Test/Services/OptimizationServiceIntegrationTests.cs b/optimizerDuck.Test/Services/OptimizationServiceIntegrationTests.cs
index 66ef3ad..d0a7a62 100644
--- a/optimizerDuck.Test/Services/OptimizationServiceIntegrationTests.cs
+++ b/optimizerDuck.Test/Services/OptimizationServiceIntegrationTests.cs
@@ -77,7 +77,6 @@ public class OptimizationServiceIntegrationTests : IDisposable
public Task<bool> ExecuteAsync(RevertContext _, ILogger logger)
{
- // Simulate revert operation
return Task.FromResult(true);
}
@@ -131,12 +130,14 @@ public class OptimizationServiceIntegrationTests : IDisposable
// Clean up only test files created by this class
foreach (var id in _testOptimizationIds)
{
- foreach (var path in new[]
- {
- Path.Combine(Shared.RevertDirectory, id + ".json"),
- ChangeRecordStore.PathFor(id),
- ChangeRecordStore.PathFor(id) + ".tmp",
- })
+ foreach (
+ var path in new[]
+ {
+ Path.Combine(Shared.RevertDirectory, id + ".json"),
+ ChangeRecordStore.PathFor(id),
+ ChangeRecordStore.PathFor(id) + ".tmp",
+ }
+ )
{
try
{
@@ -188,7 +189,6 @@ public class OptimizationServiceIntegrationTests : IDisposable
Assert.Equal(OptimizationSuccessResult.Success, result.Status);
- // Verify revert data was saved
var revertData = await RevertManager.GetRevertDataAsync(optimization.Id);
Assert.NotNull(revertData);
Assert.Equal(2, revertData.Steps.Count(s => s != null)); // 2 successful steps
@@ -206,7 +206,6 @@ public class OptimizationServiceIntegrationTests : IDisposable
// These optimizations have never been applied, so no revert data exists
await OptimizationService.UpdateOptimizationStateAsync(optimizations);
- // All should be marked as not applied
Assert.False(optimizations[0].State.IsApplied);
Assert.False(optimizations[1].State.IsApplied);
}
@@ -235,7 +234,6 @@ public class OptimizationServiceIntegrationTests : IDisposable
null
);
- // Should succeed on retry
Assert.Empty(recoveredSteps);
}
@@ -263,9 +261,9 @@ public class OptimizationServiceIntegrationTests : IDisposable
null
);
- // Should remain failed
Assert.Single(remainingFailed);
}
+
[Fact]
public async Task ApplyAsync_WritesAReportOfWhatItDid()
{
@@ -341,6 +339,7 @@ public class OptimizationServiceIntegrationTests : IDisposable
Assert.Single(record.Steps);
Assert.Equal(ChangeKind.Skip, record.Steps[0].Kind);
}
+
[Fact]
public async Task RevertAsync_MarksTheRecordAsARevert()
{
diff --git a/optimizerDuck.Test/Services/OptimizationServices/RegistryServiceTests.cs b/optimizerDuck.Test/Services/OptimizationServices/RegistryServiceTests.cs
index f25a9f1..ee5b3c4 100644
--- a/optimizerDuck.Test/Services/OptimizationServices/RegistryServiceTests.cs
+++ b/optimizerDuck.Test/Services/OptimizationServices/RegistryServiceTests.cs
@@ -21,7 +21,6 @@ public class RegistryServiceTests : IDisposable
public RegistryServiceTests()
{
- // Ensure clean state
CleanupTestKey();
}
@@ -214,13 +213,8 @@ public class RegistryServiceTests : IDisposable
[Fact]
public async Task DeleteSubKeyTree_CreatesRecursiveBackupAndRestoresCorrectly()
{
- // 1. Setup a complex tree structure
- // A
- // |- Value1: "Data1"
- // |- Value2 (Default): "DefaultData"
- // |- B
- // |- Value3: 42 (DWORD)
- // |- C
+ // Tree A holds Value1 "Data1", the default "DefaultData", and subkey B, which
+ // holds Value3 (DWORD 42) and C. Deleting A must restore all of it.
var keyPathA = $@"{BaseTestKey}\A";
var keyPathB = $@"{keyPathA}\B";
var keyPathC = $@"{keyPathB}\C";
@@ -237,25 +231,19 @@ public class RegistryServiceTests : IDisposable
var ck = RegistryService.CreateSubKey(NewCall(), new RegistryItem(keyPathC));
Assert.True(ck.Ok, ck.Error);
- // 2. Perform the deletion of tree A
var delete = RegistryService.DeleteSubKeyTree(NewCall(), new RegistryItem(keyPathA));
Assert.True(delete.Ok, delete.Error);
- // Verify keys are gone
Assert.False(RegistryService.KeyExists(new RegistryItem(keyPathA)));
- // 3. Obtain the revert step generated out of the deleted tree
var revertStep = delete.Revert;
Assert.NotNull(revertStep);
Assert.Equal("Registry", revertStep.Type);
- // 4. Act: Execute the Revert Step
Assert.True(await revertStep.ExecuteAsync(TestShell.Context(), NullLogger.Instance));
- // 5. Assert: Verify the tree structure is perfectly restored
Assert.True(RegistryService.KeyExists(new RegistryItem(keyPathC))); // C exists, implies A and B exist
- // Check values
var value1 = RegistryService.Read<string>(new RegistryItem(keyPathA, "Value1"));
Assert.Equal("Data1", value1);
@@ -272,18 +260,14 @@ public class RegistryServiceTests : IDisposable
var keyPathA = $@"{BaseTestKey}\CreateTest_A";
var keyPathB = $@"{keyPathA}\B";
- // Create the deep subkey
var create = RegistryService.CreateSubKey(NewCall(), new RegistryItem(keyPathB));
Assert.True(create.Ok, create.Error);
Assert.True(RegistryService.KeyExists(new RegistryItem(keyPathB)));
- // Obtain revert step
Assert.NotNull(create.Revert);
- // Execute revert
Assert.True(await create.Revert.ExecuteAsync(TestShell.Context(), NullLogger.Instance));
- // Verify that B and A were cleaned up since they were empty
Assert.False(RegistryService.KeyExists(new RegistryItem(keyPathB)));
Assert.False(RegistryService.KeyExists(new RegistryItem(keyPathA)));
}
@@ -291,12 +275,12 @@ public class RegistryServiceTests : IDisposable
[Fact]
public async Task MultiStepRegistryOperation_PartialFailure_RollbackRestoresOriginalState()
{
- // Test scenario: Multiple registry writes where one fails
+ // Multiple registry writes, one of which fails, rolled back through the steps
+ // each write recorded.
var key1 = $@"{BaseTestKey}\MultiStepTest1";
var key2 = $@"{BaseTestKey}\MultiStepTest2";
var key3 = $@"{BaseTestKey}\MultiStepTest3";
- // Write initial values
var i1 = RegistryService.Write(NewCall(), new RegistryItem(key1, "Value", "Initial1"));
Assert.True(i1.Ok, i1.Error);
var i2 = RegistryService.Write(NewCall(), new RegistryItem(key2, "Value", "Initial2"));
@@ -308,7 +292,6 @@ public class RegistryServiceTests : IDisposable
var changes = new ChangeSet();
OpCall NewTrackedCall() => new() { Changes = changes, Logger = NullLogger.Instance };
- // Perform multi-step operation
var u1 = RegistryService.Write(
NewTrackedCall(),
new RegistryItem(key1, "Value", "Updated1")
@@ -320,22 +303,16 @@ public class RegistryServiceTests : IDisposable
);
Assert.True(u2.Ok, u2.Error);
- // Simulate a failure by not writing to key3
- // In real scenario, this would be caught by transaction logic
-
- // Get all revert steps
var revertSteps = changes
.SuccessfulSteps.Where(c => c.Revert != null)
.Select(c => c.Revert!)
.ToList();
- // Revert all steps in reverse order
foreach (var step in revertSteps.AsEnumerable().Reverse())
{
Assert.True(await step.ExecuteAsync(TestShell.Context(), NullLogger.Instance));
}
- // Verify original state is restored
Assert.Equal("Initial1", RegistryService.Read<string>(new RegistryItem(key1, "Value")));
Assert.Equal("Initial2", RegistryService.Read<string>(new RegistryItem(key2, "Value")));
Assert.Equal("Initial3", RegistryService.Read<string>(new RegistryItem(key3, "Value")));
@@ -344,7 +321,7 @@ public class RegistryServiceTests : IDisposable
[Fact]
public async Task ConcurrentRegistryOperations_DoesNotCauseCorruption()
{
- // Test scenario: Concurrent writes to different keys
+ // Concurrent writes to different keys.
var tasks = new List<Task>();
const int concurrentOps = 10;
@@ -372,7 +349,6 @@ public class RegistryServiceTests : IDisposable
await Task.WhenAll(tasks);
- // Verify all writes succeeded
for (int i = 0; i < concurrentOps; i++)
{
var key = $@"{BaseTestKey}\ConcurrentTest{i}";
@@ -387,7 +363,6 @@ public class RegistryServiceTests : IDisposable
{
var key = $@"{BaseTestKey}\TypeConversionTest";
- // Test different value types
var dw = RegistryService.Write(
NewCall(),
new RegistryItem(key, "DWordValue", 42, RegistryValueKind.DWord)
@@ -425,7 +400,6 @@ public class RegistryServiceTests : IDisposable
[Fact]
public async Task RevertStepWithSubSteps_ExecutesInCorrectOrder()
{
- // Test that nested revert steps execute in the correct order
var key1 = $@"{BaseTestKey}\SubStepTest\Key1";
var key2 = $@"{BaseTestKey}\SubStepTest\Key2";
@@ -438,7 +412,6 @@ public class RegistryServiceTests : IDisposable
var changes = new ChangeSet();
OpCall NewTrackedCall() => new() { Changes = changes, Logger = NullLogger.Instance };
- // Perform operations
var m1 = RegistryService.Write(
NewTrackedCall(),
new RegistryItem(key1, "Value", "Modified1")
@@ -450,7 +423,6 @@ public class RegistryServiceTests : IDisposable
);
Assert.True(m2.Ok, m2.Error);
- // Revert in reverse order (LIFO)
var revertSteps = changes
.SuccessfulSteps.Where(c => c.Revert != null)
.Select(c => c.Revert!)
@@ -464,7 +436,6 @@ public class RegistryServiceTests : IDisposable
Assert.True(await step.ExecuteAsync(TestShell.Context(), NullLogger.Instance));
}
- // Verify state is restored
Assert.Equal("Original1", RegistryService.Read<string>(new RegistryItem(key1, "Value")));
Assert.Equal("Original2", RegistryService.Read<string>(new RegistryItem(key2, "Value")));
}
@@ -475,11 +446,9 @@ public class RegistryServiceTests : IDisposable
var emptyKeyPath = $@"{BaseTestKey}\CleanupTest\EmptyKey";
var nonEmptyKeyPath = $@"{BaseTestKey}\CleanupTest\NonEmptyKey";
- // Create empty key
var ce = RegistryService.CreateSubKey(NewCall(), new RegistryItem(emptyKeyPath));
Assert.True(ce.Ok, ce.Error);
- // Create non-empty key
var cn = RegistryService.CreateSubKey(NewCall(), new RegistryItem(nonEmptyKeyPath));
Assert.True(cn.Ok, cn.Error);
var wn = RegistryService.Write(
@@ -488,13 +457,10 @@ public class RegistryServiceTests : IDisposable
);
Assert.True(wn.Ok, wn.Error);
- // Cleanup
RegistryService.CleanupEmptyKeys(new[] { emptyKeyPath, nonEmptyKeyPath });
- // Empty key should be removed
Assert.False(RegistryService.KeyExists(new RegistryItem(emptyKeyPath)));
- // Non-empty key should remain
Assert.True(RegistryService.KeyExists(new RegistryItem(nonEmptyKeyPath)));
Assert.Equal(
"SomeValue",
diff --git a/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.cs b/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.cs
index dd3fbf7..29cbceb 100644
--- a/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.cs
+++ b/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.cs
@@ -31,13 +31,9 @@ public class ServiceProcessServiceTests
[Fact]
public void BuildWriteErrorDetail_WithAThrowAfterTheWrite_NamesTheThrow()
{
- // The interop itself threw after the start type was written: the throw text is the only
- // honest reason, so it is reported instead of the error code.
- var detail = ServiceProcessService.BuildWriteErrorDetail(
- true,
- 5,
- "LoadLibrary failed"
- );
+ // The interop threw after the start type was written, so the throw text is the
+ // only honest reason to report.
+ var detail = ServiceProcessService.BuildWriteErrorDetail(true, 5, "LoadLibrary failed");
Assert.Contains("LoadLibrary failed", detail);
Assert.Contains("after the start type was written", detail);
@@ -78,15 +74,12 @@ public class ServiceProcessServiceTests
}
// =============================================
- // Contract fixture: read mapping against registry ground truth.
- // Independent of the mechanism: the expected value comes from
- // HKLM\SYSTEM\CurrentControlSet\Services, where Windows stores Start (2 auto / 3 manual /
- // 4 disabled) and the DelayedAutoStart flag. Driver entries are included on purpose - the
- // Service Control Manager reports their start type without the TYPE/START_TYPE ambiguity that
- // sc.exe output had. Boot (0) and system (1) starts are excluded: they are outside the app's
- // ServiceStartupType domain, and the registry is not authoritative for them (55 uninstalled
- // driver entries on this machine report DEMAND_START through the SCM, and sc.exe - which also
- // reads the SCM - reported exactly the same before this conversion).
+ // Contract fixture: the expected value comes from
+ // HKLM\SYSTEM\CurrentControlSet\Services, where Windows stores Start (2 auto, 3 manual,
+ // 4 disabled) and the DelayedAutoStart flag. Driver entries are included: the Service
+ // Control Manager reports their start type without the TYPE/START_TYPE ambiguity of
+ // sc.exe output. Boot (0) and system (1) starts fall outside the app's
+ // ServiceStartupType domain, and the registry is not authoritative for them.
// =============================================
private const int PerTypeSampleLimit = 8;
@@ -353,10 +346,8 @@ public class ServiceProcessServiceTests
await EnsureTestServiceAsync();
try
{
- // Automatic runs first because the scratch service is created without a delayed
- // flag; whether sc.exe (or a later SCM write) clears that flag when moving back to
- // plain automatic is a real behaviour worth pinning separately, and this order
- // does not depend on the answer.
+ // Automatic runs first because the scratch service is created without the
+ // delayed flag, so the order does not depend on how a later write treats it.
var previousType = ServiceStartupType.Manual;
foreach (
@@ -413,9 +404,8 @@ public class ServiceProcessServiceTests
new ServiceItem(TestServiceName, ServiceStartupType.Disabled)
);
- // Windows protects this service. That is a refusal, not a failure: the call reports
- // success for the batch, records no revert step, and the step says Windows refused
- // rather than that the machine already matched.
+ // Windows protects this service, so the call is refused, not failed: it reports
+ // success for the batch and records no revert step.
Assert.True(result.Ok, result.Error);
var change = Assert.Single(call.Changes.Changes);
Assert.Equal(ChangeKind.Refused, change.Kind);
diff --git a/optimizerDuck.Test/Services/SystemRestoreServiceTests.cs b/optimizerDuck.Test/Services/SystemRestoreServiceTests.cs
index 8af6c8f..8fbf9c5 100644
--- a/optimizerDuck.Test/Services/SystemRestoreServiceTests.cs
+++ b/optimizerDuck.Test/Services/SystemRestoreServiceTests.cs
@@ -4,11 +4,10 @@ using optimizerDuck.Services.System;
namespace optimizerDuck.Test.Services;
/// <summary>
-/// System Restore decisions with hand-doubled results. Classification takes status codes only
-/// (never message text, which is localizable) and the throttle takes the documented setting plus
-/// the newest existing point. The live create/enable round trip needs elevation, so the virtual
-/// members are driven through a hand-written double - the same seam a restore-point manager tool
-/// would use.
+/// System Restore decisions with hand-doubled results. Classification takes status codes
+/// only (never message text, which is localizable) and the throttle takes the documented
+/// setting plus the newest existing point. The live create/enable round trip needs
+/// elevation, so the virtual members are driven through a hand-written double.
/// </summary>
public class SystemRestoreServiceTests
{
@@ -126,7 +125,10 @@ public class SystemRestoreServiceTests
var service = new FakeSystemRestoreService
{
FrequencyMinutes = 0,
- Points = [new SystemRestoreService.RestorePointInfo(7, 12, "just now", Now.AddSeconds(-30))],
+ Points =
+ [
+ new SystemRestoreService.RestorePointInfo(7, 12, "just now", Now.AddSeconds(-30)),
+ ],
};
Assert.False(service.IsWithinCreationThrottle(Now));
diff --git a/optimizerDuck.Test/TestCulture.cs b/optimizerDuck.Test/TestCulture.cs
index 5b9589e..bd2d4c5 100644
--- a/optimizerDuck.Test/TestCulture.cs
+++ b/optimizerDuck.Test/TestCulture.cs
@@ -3,10 +3,9 @@ using System.Runtime.CompilerServices;
using optimizerDuck.Resources.Languages;
using Xunit;
-// The suite exercises the real registry, the real filesystem, real child processes, and
-// process-wide statics (notably Loc.Instance's culture and ReflectionHelper's cache).
-// Running test classes in parallel makes those shared statics race: a culture change in
-// one class flips the localized text another class is asserting on. Serialize instead.
+// The suite touches the real registry, filesystem and child processes, and shares
+// process-wide statics (Loc.Instance's culture, ReflectionHelper's cache). Parallel
+// test classes race on those, so the assembly runs serialized.
[assembly: CollectionBehavior(DisableTestParallelization = true)]
namespace optimizerDuck.Test;
diff --git a/optimizerDuck.Test/TestDoubles/TestShell.cs b/optimizerDuck.Test/TestDoubles/TestShell.cs
index badaf77..d63bb34 100644
--- a/optimizerDuck.Test/TestDoubles/TestShell.cs
+++ b/optimizerDuck.Test/TestDoubles/TestShell.cs
@@ -6,7 +6,9 @@ using optimizerDuck.Services.System.Primitives;
namespace optimizerDuck.Test.TestDoubles;
-/// <summary>Builds a <see cref="ShellService"/> with a fixed timeout for tests that need one.</summary>
+/// <summary>
+/// Builds a <see cref="ShellService"/> with a fixed timeout for tests that need one.
+/// </summary>
internal static class TestShell
{
public const int TimeoutMs = 120_000;
diff --git a/optimizerDuck.Test/UI/ViewModels/ChangeRecordRowShapeTests.cs b/optimizerDuck.Test/UI/ViewModels/ChangeRecordRowShapeTests.cs
index 0791630..cfafb87 100644
--- a/optimizerDuck.Test/UI/ViewModels/ChangeRecordRowShapeTests.cs
+++ b/optimizerDuck.Test/UI/ViewModels/ChangeRecordRowShapeTests.cs
@@ -37,7 +37,8 @@ public class ChangeRecordRowShapeTests
}
);
- // "Not applicable" on its own says nothing, so the row carries the reason in the UI language.
+ // "Not applicable" alone says nothing, so the row carries the reason in the UI
+ // language.
Assert.Contains(
step.Fields,
field => field.Value == Loc.Instance["Optimizer.Details.Reason.ServiceNotFound"]
@@ -58,7 +59,7 @@ public class ChangeRecordRowShapeTests
}
);
- // A code the UI cannot word is left out rather than shown raw.
+ // A code the UI cannot word is left out of the row.
Assert.DoesNotContain(step.Fields, field => field.Value == "something.new");
}
diff --git a/optimizerDuck/App.xaml.cs b/optimizerDuck/App.xaml.cs
index 9c09120..d86e22b 100644
--- a/optimizerDuck/App.xaml.cs
+++ b/optimizerDuck/App.xaml.cs
@@ -40,7 +40,6 @@ public class ScopeBlockTextFormatter : ITextFormatter
{
public void Format(LogEvent logEvent, TextWriter output)
{
- // build prefix
var timestamp = $"{logEvent.Timestamp:yyyy-MM-dd HH:mm:ss}";
var ctx = logEvent.Properties.TryGetValue("SourceContext", out var sourceContext)
? sourceContext is ScalarValue { Value: string s }
@@ -61,10 +60,8 @@ public class ScopeBlockTextFormatter : ITextFormatter
//var prefix = $"{timestamp} | {ctx,-67} | {levelText,-7} | "; // byebye 67 char SourceContext truncation, we have a new design now...
var prefix = $"{timestamp} | {ctx, -35} | {levelText, -7} | ";
- // print message
output.WriteLine(prefix + RenderWithoutQuotes(logEvent));
- // print property
foreach (var kvp in logEvent.Properties)
{
if (kvp.Key == "SourceContext")
@@ -100,10 +97,8 @@ public class ScopeBlockTextFormatter : ITextFormatter
)
{
if (value is ScalarValue { Value: string s })
- // write string without quotes
output.Write(s);
else
- // use default rendering for other types
pt.Render(logEvent.Properties, output);
}
else
@@ -221,7 +216,6 @@ public partial class App : Application
}
catch
{
- // what you expect
}
}
}
@@ -311,7 +305,6 @@ public partial class App : Application
private async Task OnStartupAsync(StartupEventArgs e)
{
- // Create the required directories if they don't exist
Directory.CreateDirectory(Shared.RootDirectory);
Directory.CreateDirectory(Shared.ResourcesDirectory);
Directory.CreateDirectory(Shared.DownloadsDirectory);
diff --git a/optimizerDuck/Common/Converters/BooleanConverter.cs b/optimizerDuck/Common/Converters/BooleanConverter.cs
index 00f9bfc..27d8509 100644
--- a/optimizerDuck/Common/Converters/BooleanConverter.cs
+++ b/optimizerDuck/Common/Converters/BooleanConverter.cs
@@ -7,7 +7,6 @@ namespace optimizerDuck.Common.Converters;
// Posted by Atif Aziz, modified by community. See post 'Timeline' for change history
// Retrieved 2026-01-21, License - CC BY-SA 2.5
-/// <summary>Maps a <see cref="bool"/> to one of two configured values of type <typeparamref name="T"/>.</summary>
public class BooleanConverter<T>(T trueValue, T falseValue) : IValueConverter
{
public T True { get; set; } = trueValue;
diff --git a/optimizerDuck/Common/Converters/BooleanToVisibilityConverter.cs b/optimizerDuck/Common/Converters/BooleanToVisibilityConverter.cs
index 8894202..584d7f3 100644
--- a/optimizerDuck/Common/Converters/BooleanToVisibilityConverter.cs
+++ b/optimizerDuck/Common/Converters/BooleanToVisibilityConverter.cs
@@ -2,6 +2,5 @@
namespace optimizerDuck.Common.Converters;
-/// <summary>Converts <c>true</c> to <see cref="Visibility.Visible"/> and <c>false</c> to <see cref="Visibility.Collapsed"/>.</summary>
public sealed class BooleanToVisibilityConverter()
: BooleanConverter<Visibility>(Visibility.Visible, Visibility.Collapsed);
diff --git a/optimizerDuck/Common/Converters/DeviceKindConverter.cs b/optimizerDuck/Common/Converters/DeviceKindConverter.cs
index 47dbf8c..4d6cdfd 100644
--- a/optimizerDuck/Common/Converters/DeviceKindConverter.cs
+++ b/optimizerDuck/Common/Converters/DeviceKindConverter.cs
@@ -5,7 +5,7 @@ using optimizerDuck.Services.System;
namespace optimizerDuck.Common.Converters;
-/// <summary>Converts a <see cref="DeviceKind"/> to its localized display text.</summary>
+/// <summary>Localizes a DeviceKind; unrecognized kinds fall back to Common.Unknown.</summary>
public class DeviceKindConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Converters/EmptyWhileNotLoadingConverter.cs b/optimizerDuck/Common/Converters/EmptyWhileNotLoadingConverter.cs
index aa80046..80c20f8 100644
--- a/optimizerDuck/Common/Converters/EmptyWhileNotLoadingConverter.cs
+++ b/optimizerDuck/Common/Converters/EmptyWhileNotLoadingConverter.cs
@@ -4,7 +4,7 @@ using System.Windows.Data;
namespace optimizerDuck.Common.Converters;
-/// <summary>Shows an empty-state message when the item count is zero and nothing is loading.</summary>
+/// <summary>Visible for a zero item count while not loading; otherwise Collapsed.</summary>
public class EmptyWhileNotLoadingConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Converters/EnumDisplayConverter.cs b/optimizerDuck/Common/Converters/EnumDisplayConverter.cs
index a907bbd..7c4ffb0 100644
--- a/optimizerDuck/Common/Converters/EnumDisplayConverter.cs
+++ b/optimizerDuck/Common/Converters/EnumDisplayConverter.cs
@@ -5,10 +5,9 @@ using optimizerDuck.Services.Configuration;
namespace optimizerDuck.Common.Converters;
/// <summary>
-/// Displays any system-info enum via resource key <c>Enum.{Type}.{Value}</c>.
-/// <see cref="Enum.Unknown"/>-style values and null map to <c>Common.Unknown</c>;
-/// a missing resource falls back to the raw value name (never a raw key).
-/// Re-evaluates on language change through the normal binding refresh.
+/// Displays a system-info enum through the resource key <c>Enum.{Type}.{Value}</c>. An
+/// <c>Unknown</c> value and a null map to <c>Common.Unknown</c>, and a missing resource falls
+/// back to the raw value name, not the key. Re-evaluates on language change.
/// </summary>
public class EnumDisplayConverter : IValueConverter
{
diff --git a/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.cs b/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.cs
index d2d5e79..f52d5fb 100644
--- a/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.cs
+++ b/optimizerDuck/Common/Converters/EqualityToVisibilityConverter.cs
@@ -4,7 +4,6 @@ using System.Windows.Data;
namespace optimizerDuck.Common.Converters;
-/// <summary>Shows or hides a control based on whether the value equals the converter parameter.</summary>
public class EqualityToVisibilityConverter : IValueConverter
{
public Visibility True { get; set; } = Visibility.Visible;
diff --git a/optimizerDuck/Common/Converters/InverseBooleanConverter.cs b/optimizerDuck/Common/Converters/InverseBooleanConverter.cs
index faf5912..8dfe0b1 100644
--- a/optimizerDuck/Common/Converters/InverseBooleanConverter.cs
+++ b/optimizerDuck/Common/Converters/InverseBooleanConverter.cs
@@ -1,4 +1,3 @@
namespace optimizerDuck.Common.Converters;
-/// <summary>Inverts a <see cref="bool"/>: <c>true</c> becomes <c>false</c> and vice versa.</summary>
public sealed class InverseBooleanConverter() : BooleanConverter<bool>(false, true);
diff --git a/optimizerDuck/Common/Converters/InverseBooleanToVisibilityConverter.cs b/optimizerDuck/Common/Converters/InverseBooleanToVisibilityConverter.cs
index ece0276..3a9478a 100644
--- a/optimizerDuck/Common/Converters/InverseBooleanToVisibilityConverter.cs
+++ b/optimizerDuck/Common/Converters/InverseBooleanToVisibilityConverter.cs
@@ -2,6 +2,5 @@
namespace optimizerDuck.Common.Converters;
-/// <summary>Converts <c>true</c> to <see cref="Visibility.Collapsed"/> and <c>false</c> to <see cref="Visibility.Visible"/>.</summary>
public sealed class InverseBooleanToVisibilityConverter()
: BooleanConverter<Visibility>(Visibility.Collapsed, Visibility.Visible);
diff --git a/optimizerDuck/Common/Converters/MBToGBConverter.cs b/optimizerDuck/Common/Converters/MBToGBConverter.cs
index 378bda0..5b534f3 100644
--- a/optimizerDuck/Common/Converters/MBToGBConverter.cs
+++ b/optimizerDuck/Common/Converters/MBToGBConverter.cs
@@ -4,7 +4,7 @@ using optimizerDuck.Services.Configuration;
namespace optimizerDuck.Common.Converters;
-/// <summary>Converts a megabyte value to a formatted gigabyte string, else localized Unknown.</summary>
+/// <summary>Formats a positive megabyte count as a GB string; anything else is Unknown.</summary>
public class MBToGBConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Converters/NumericComparisonToVisibilityConverter.cs b/optimizerDuck/Common/Converters/NumericComparisonToVisibilityConverter.cs
index d9568a6..220498b 100644
--- a/optimizerDuck/Common/Converters/NumericComparisonToVisibilityConverter.cs
+++ b/optimizerDuck/Common/Converters/NumericComparisonToVisibilityConverter.cs
@@ -4,7 +4,6 @@ using System.Windows.Data;
namespace optimizerDuck.Common.Converters;
-/// <summary>Comparison operators supported by <see cref="NumericComparisonToVisibilityConverter"/>.</summary>
public enum NumericComparisonType
{
GreaterThan,
diff --git a/optimizerDuck/Common/Converters/ObjectToNullableDoubleConverter.cs b/optimizerDuck/Common/Converters/ObjectToNullableDoubleConverter.cs
index ab0994b..8be2af7 100644
--- a/optimizerDuck/Common/Converters/ObjectToNullableDoubleConverter.cs
+++ b/optimizerDuck/Common/Converters/ObjectToNullableDoubleConverter.cs
@@ -4,6 +4,10 @@ using System.Windows.Data;
namespace optimizerDuck.Common.Converters;
+/// <summary>
+/// Converts numeric input to a nullable double; the "Int" ConvertBack parameter is matched
+/// ordinally, ignoring case, and unparsable values yield UnsetValue.
+/// </summary>
public sealed class ObjectToNullableDoubleConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Converters/ProgressBarValueToBrushConverter.cs b/optimizerDuck/Common/Converters/ProgressBarValueToBrushConverter.cs
index 3e89b1f..aa9cbbb 100644
--- a/optimizerDuck/Common/Converters/ProgressBarValueToBrushConverter.cs
+++ b/optimizerDuck/Common/Converters/ProgressBarValueToBrushConverter.cs
@@ -5,7 +5,7 @@ using optimizerDuck.Common.Helpers;
namespace optimizerDuck.Common.Converters;
-/// <summary>Maps a progress percentage to a theme brush: green under 50%, yellow under 80%, red above.</summary>
+/// <summary>Maps a progress percentage to green below 50%, yellow below 80%, red above.</summary>
public class ProgressBarValueToBrushConverter : IValueConverter
{
private static readonly SolidColorBrush DefaultBrush = new(Color.FromArgb(0x0, 0x0, 0x0, 0x0));
diff --git a/optimizerDuck/Common/Converters/RecommendationForegroundConverter.cs b/optimizerDuck/Common/Converters/RecommendationForegroundConverter.cs
index e07bf9e..d02876d 100644
--- a/optimizerDuck/Common/Converters/RecommendationForegroundConverter.cs
+++ b/optimizerDuck/Common/Converters/RecommendationForegroundConverter.cs
@@ -8,7 +8,6 @@ using Wpf.Ui.Appearance;
namespace optimizerDuck.Common.Converters;
-/// <summary>Provides theme-aware text brushes for converter use.</summary>
public static class ThemeBrushes
{
public static Brush Primary =>
@@ -21,7 +20,10 @@ public static class ThemeBrushes
ThemeResource.Get<Brush>("TextFillColorSecondaryBrush") ?? Brushes.Gray;
}
-/// <summary>Picks a foreground brush for a recommendation state based on the current app theme.</summary>
+/// <summary>
+/// Maps a recommendation state to a foreground brush; Depends follows the current theme,
+/// and any missing or unrecognized input falls back to Primary.
+/// </summary>
public class RecommendationForegroundConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Converters/ThemeConverterBase.cs b/optimizerDuck/Common/Converters/ThemeConverterBase.cs
index 0039e72..62a588d 100644
--- a/optimizerDuck/Common/Converters/ThemeConverterBase.cs
+++ b/optimizerDuck/Common/Converters/ThemeConverterBase.cs
@@ -4,7 +4,7 @@ using Wpf.Ui.Appearance;
namespace optimizerDuck.Common.Converters;
-/// <summary>Base class for converters that map an <see cref="ApplicationTheme"/> to a value.</summary>
+/// <summary>Maps an ApplicationTheme via ConvertTheme; else returns GetDefault().</summary>
public abstract class ThemeConverterBase<T> : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Converters/ThemeToGitHubIconConverter.cs b/optimizerDuck/Common/Converters/ThemeToGitHubIconConverter.cs
index 5743b58..26f9637 100644
--- a/optimizerDuck/Common/Converters/ThemeToGitHubIconConverter.cs
+++ b/optimizerDuck/Common/Converters/ThemeToGitHubIconConverter.cs
@@ -3,7 +3,6 @@ using Wpf.Ui.Appearance;
namespace optimizerDuck.Common.Converters;
-/// <summary>Returns the GitHub logo image that matches the current theme.</summary>
public sealed class ThemeToGitHubIconConverter : ThemeConverterBase<BitmapImage>
{
protected override BitmapImage ConvertTheme(ApplicationTheme theme, object parameter)
diff --git a/optimizerDuck/Common/Converters/ThemeToIndexConverter.cs b/optimizerDuck/Common/Converters/ThemeToIndexConverter.cs
index dee40b1..fe58b2f 100644
--- a/optimizerDuck/Common/Converters/ThemeToIndexConverter.cs
+++ b/optimizerDuck/Common/Converters/ThemeToIndexConverter.cs
@@ -4,7 +4,7 @@ using Wpf.Ui.Appearance;
namespace optimizerDuck.Common.Converters;
-/// <summary>Maps an <see cref="ApplicationTheme"/> to a 0-2 index (for tab selection) and back.</summary>
+/// <summary>Maps a theme to a 0-2 index and back; unknown values fall back to Light.</summary>
public sealed class ThemeToIndexConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Converters/ValueConditionToVisibilityConverter.cs b/optimizerDuck/Common/Converters/ValueConditionToVisibilityConverter.cs
index de68611..b827939 100644
--- a/optimizerDuck/Common/Converters/ValueConditionToVisibilityConverter.cs
+++ b/optimizerDuck/Common/Converters/ValueConditionToVisibilityConverter.cs
@@ -4,7 +4,6 @@ using System.Windows.Data;
namespace optimizerDuck.Common.Converters;
-/// <summary>Value checks supported by <see cref="ValueConditionToVisibilityConverter"/>.</summary>
public enum ValueConditionType
{
IsNull,
diff --git a/optimizerDuck/Common/Extensions/LanguageExtensions.cs b/optimizerDuck/Common/Extensions/LanguageExtensions.cs
index 88f6881..965130e 100644
--- a/optimizerDuck/Common/Extensions/LanguageExtensions.cs
+++ b/optimizerDuck/Common/Extensions/LanguageExtensions.cs
@@ -6,7 +6,8 @@ using optimizerDuck.Services.Configuration;
namespace optimizerDuck.Common.Extensions;
/// <summary>
-/// maybe i will add change language runtime support later
+/// Supplies a localized string to a XAML binding from <see cref="Loc" />, resolving the key
+/// at bind time and appending any binding arguments into its format placeholders.
/// </summary>
public class LocExtension : MarkupExtension
{
@@ -104,6 +105,10 @@ public class LocExtension : MarkupExtension
}
}
+/// <summary>
+/// Resolves a localized format string from <see cref="Loc" /> and formats it with the binding
+/// arguments: the first value is <see cref="Loc" />, the converter parameter is the key.
+/// </summary>
public class LocDynamicConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object? parameter, CultureInfo culture)
diff --git a/optimizerDuck/Common/Extensions/LocalizedObject.cs b/optimizerDuck/Common/Extensions/LocalizedObject.cs
index 9057854..cafb1a4 100644
--- a/optimizerDuck/Common/Extensions/LocalizedObject.cs
+++ b/optimizerDuck/Common/Extensions/LocalizedObject.cs
@@ -25,7 +25,8 @@ namespace optimizerDuck.Common.Extensions;
/// Conventions:
/// <list type="bullet">
/// <item>
-/// Localized expression-bodied properties: <c>public string Name =&gt; Loc.Instance["X.Y.Name"];</c>.
+/// Localized expression-bodied properties, for example
+/// <c>public string Name =&gt; Loc.Instance["X.Y.Name"];</c>.
/// The binding re-evaluates the getter on culture change automatically.
/// </item>
/// <item>
diff --git a/optimizerDuck/Common/Extensions/OptimizationPageRegistryExtensions.cs b/optimizerDuck/Common/Extensions/OptimizationPageRegistryExtensions.cs
index 9f6e37e..e7e6206 100644
--- a/optimizerDuck/Common/Extensions/OptimizationPageRegistryExtensions.cs
+++ b/optimizerDuck/Common/Extensions/OptimizationPageRegistryExtensions.cs
@@ -58,7 +58,9 @@ internal static class CategoryPageFactory
}
}
-/// <summary>Registers the optimize-category pages discovered on <see cref="IOptimizationCategory"/>.</summary>
+/// <summary>
+/// Registers the optimize-category pages discovered on <see cref="IOptimizationCategory"/>.
+/// </summary>
public static class OptimizationPageRegistryExtensions
{
public static void AddAllOptimizationPages(this IServiceCollection services)
@@ -86,7 +88,9 @@ public static class OptimizationPageRegistryExtensions
}
}
-/// <summary>Registers the customize-category pages discovered on <see cref="ICustomizeCategory"/>.</summary>
+/// <summary>
+/// Registers the customize-category pages discovered on <see cref="ICustomizeCategory"/>.
+/// </summary>
public static class CustomizePageRegistryExtensions
{
public static void AddAllCustomizeCategoryPages(this IServiceCollection services)
diff --git a/optimizerDuck/Common/Helpers/CategoryDiscovery.cs b/optimizerDuck/Common/Helpers/CategoryDiscovery.cs
index d966e92..5169447 100644
--- a/optimizerDuck/Common/Helpers/CategoryDiscovery.cs
+++ b/optimizerDuck/Common/Helpers/CategoryDiscovery.cs
@@ -11,10 +11,12 @@ public static class CategoryDiscovery
{
/// <summary>
/// Builds one instance per discovered category type, populating the collection
- /// property named <paramref name="itemsPropertyName"/> with its nested items.
+ /// property named <paramref name="itemsPropertyName" /> with its nested items.
/// Categories that contain no items are skipped.
/// </summary>
- /// <param name="itemsPropertyName">The public collection property to fill (e.g. <c>Optimizations</c>).</param>
+ /// <param name="itemsPropertyName">
+ /// The public collection property to fill, for example <c>Optimizations</c>.
+ /// </param>
/// <param name="buildItems">Builds the nested items for a category type.</param>
/// <param name="orderBy">Sort key applied to the resulting categories.</param>
public static TCategory[] Discover<TCategory, TItem>(
@@ -47,7 +49,7 @@ public static class CategoryDiscovery
}
/// <summary>
- /// Instantiates every public nested class assignable to <typeparamref name="TItem"/>.
+ /// Instantiates every public nested class assignable to <typeparamref name="TItem" />.
/// </summary>
/// <param name="category">The category type whose nested types are scanned.</param>
/// <param name="init">Optional callback invoked with each item and its owning category.</param>
@@ -73,7 +75,7 @@ public static class CategoryDiscovery
/// <summary>
/// Assigns the built items to the category's collection property, adapting a
- /// <see cref="List{T}"/> to whatever collection type the property declares.
+ /// <see cref="List{T}" /> to whatever collection type the property declares.
/// </summary>
private static void PopulateItems<TCategory, TItem>(
TCategory instance,
diff --git a/optimizerDuck/Common/Helpers/EmbeddedResourceHelper.cs b/optimizerDuck/Common/Helpers/EmbeddedResourceHelper.cs
index 6bbf97b..c74e368 100644
--- a/optimizerDuck/Common/Helpers/EmbeddedResourceHelper.cs
+++ b/optimizerDuck/Common/Helpers/EmbeddedResourceHelper.cs
@@ -4,7 +4,7 @@ using System.Reflection;
namespace optimizerDuck.Common.Helpers;
/// <summary>
-/// Helper class for extracting embedded resources from the optimizerDuck.Resources.Embedded namespace.
+/// Extracts embedded resources from the optimizerDuck.Resources.Embedded namespace.
/// </summary>
public static class EmbeddedResourceHelper
{
@@ -13,10 +13,14 @@ public static class EmbeddedResourceHelper
/// <summary>
/// Extracts an embedded resource to the specified output path.
/// </summary>
- /// <param name="relativePath">Relative path within the Embedded namespace (e.g., "Icons/blank.ico").</param>
+ /// <param name="relativePath">
+ /// Relative path inside the Embedded namespace, for example "Icons/blank.ico".
+ /// </param>
/// <param name="outputPath">Full path where the resource will be extracted.</param>
/// <param name="overwrite">Whether to overwrite the file if it already exists.</param>
- /// <returns>True if extraction succeeded, false otherwise.</returns>
+ /// <returns>
+ /// <see langword="true" /> if extraction succeeded; otherwise <see langword="false" />.
+ /// </returns>
public static bool TryExtract(string relativePath, string outputPath, bool overwrite = false)
{
if (string.IsNullOrWhiteSpace(relativePath) || string.IsNullOrWhiteSpace(outputPath))
@@ -32,26 +36,22 @@ public static class EmbeddedResourceHelper
var assembly = Assembly.GetExecutingAssembly();
- // Check if the resource exists
if (!ResourceExists(assembly, fullResourceName))
{
return false;
}
- // Create output directory if it doesn't exist
var outputDirectory = Path.GetDirectoryName(outputPath);
if (!string.IsNullOrEmpty(outputDirectory) && !Directory.Exists(outputDirectory))
{
Directory.CreateDirectory(outputDirectory);
}
- // Skip extraction if file exists and overwrite is disabled
if (File.Exists(outputPath) && !overwrite)
{
return true;
}
- // Extract the resource
using var stream = assembly.GetManifestResourceStream(fullResourceName);
if (stream == null)
{
@@ -80,7 +80,9 @@ public static class EmbeddedResourceHelper
/// Checks if an embedded resource exists.
/// </summary>
/// <param name="relativePath">Relative path within the Embedded namespace.</param>
- /// <returns>True if the resource exists, false otherwise.</returns>
+ /// <returns>
+ /// <see langword="true" /> if the resource exists; otherwise <see langword="false" />.
+ /// </returns>
public static bool Exists(string relativePath)
{
if (string.IsNullOrWhiteSpace(relativePath))
diff --git a/optimizerDuck/Common/Helpers/GitHubSourceHelper.cs b/optimizerDuck/Common/Helpers/GitHubSourceHelper.cs
index 84ac4a4..c230b69 100644
--- a/optimizerDuck/Common/Helpers/GitHubSourceHelper.cs
+++ b/optimizerDuck/Common/Helpers/GitHubSourceHelper.cs
@@ -34,21 +34,32 @@ public static class GitHubSourceHelper
private static readonly HttpClient HttpClient = CreateClient();
- /// <summary>Raw file contents keyed by ref/path; tag refs are immutable, so entries never expire.</summary>
+ /// <summary>
+ /// Raw file contents keyed by ref and path. Tag refs are immutable, so entries never
+ /// expire.
+ /// </summary>
private static readonly ConcurrentDictionary<string, Lazy<Task<string>>> SourceCache = new();
- /// <summary>Tags known missing upstream; skips one wasted probe per view until the app restarts.</summary>
+ /// <summary>
+ /// Tags known missing upstream; skips one wasted probe per view until the app restarts.
+ /// </summary>
private static readonly ConcurrentDictionary<string, byte> MissingTagCache = new();
/// <summary>
/// Opens the GitHub source file for the given type at the class definition line,
/// viewed at the release tag matching the running application version.
/// </summary>
- /// <param name="ownerType">The type that owns the source file (e.g., the category class).</param>
+ /// <param name="ownerType">
+ /// The type that owns the source file, for example the category class.
+ /// </param>
/// <param name="className">The class name to find within the source file.</param>
- /// <param name="baseClassPattern">Optional base class pattern to search for (e.g., "BaseCustomizeSetting").</param>
+ /// <param name="baseClassPattern">
+ /// Optional base class pattern to search for, for example "BaseCustomizeSetting".
+ /// </param>
/// <param name="logger">Optional logger for diagnostic output.</param>
- /// <param name="snackbarService">Optional snackbar service for user-facing error notifications.</param>
+ /// <param name="snackbarService">
+ /// Optional snackbar service for user-facing error notifications.
+ /// </param>
public static async Task OpenSourceOnGitHubAsync(
Type ownerType,
string className,
@@ -88,7 +99,9 @@ public static class GitHubSourceHelper
}
}
- /// <summary>Maps the running file version to its release tag (e.g., "2.26.2" -> "v2.26.2").</summary>
+ /// <summary>
+ /// Maps the running file version to its release tag, for example "2.26.2" to "v2.26.2".
+ /// </summary>
internal static string? GetTagForVersion(string? FileVersion)
{
if (!Version.TryParse(FileVersion, out var version))
diff --git a/optimizerDuck/Common/Helpers/Shared.cs b/optimizerDuck/Common/Helpers/Shared.cs
index f8e4c01..4db8550 100644
--- a/optimizerDuck/Common/Helpers/Shared.cs
+++ b/optimizerDuck/Common/Helpers/Shared.cs
@@ -3,8 +3,12 @@ using System.IO;
namespace optimizerDuck.Common.Helpers;
+/// <summary>
+/// Constants, links, install paths and the AppX package sets used by the bloatware scan.
+/// </summary>
public static class Shared
{
+ /// <summary>The ASCII-art logo shown in the startup log banner.</summary>
public const string RawLogo = """
_ _ _ _____ _
| | (_) (_) | __ \ | |
@@ -16,36 +20,57 @@ public static class Shared
|_|
""";
+ /// <summary>The invite link to the project's Discord server.</summary>
public const string DiscordInviteURL = "https://discord.gg/tDUBDCYw9Q";
+
+ /// <summary>The project documentation site.</summary>
public const string WebsiteURL = "https://optimizerduck.vercel.app/";
+
+ /// <summary>The project's GitHub repository.</summary>
public const string GitHubRepoURL = "https://github.com/itsfatduck/optimizerDuck";
+
+ /// <summary>The community page on the documentation site.</summary>
public const string CommunityURL = "https://optimizerduck.vercel.app/docs/community";
+
+ /// <summary>The contribution guide on the documentation site.</summary>
public const string ContributeURL = "https://optimizerduck.vercel.app/docs/contribute/overview";
+ /// <summary>The third-party notices file on GitHub.</summary>
public const string AcknowledgementsURL =
"https://github.com/itsfatduck/optimizerDuck/blob/master/THIRD-PARTY-NOTICES.md";
+ /// <summary>The name given to the restore point created before an apply.</summary>
public const string RestorePointName = "optimizerDuck Restore Point";
+ /// <summary>The download URL of the bundled optimizerDuck power plan.</summary>
public const string PowerPlanUrl =
"https://github.com/itsfatduck/optimizerDuck/raw/refs/heads/master/optimizerDuck.Resources/optimizerDuck.pow";
+ /// <summary>The GUID the bundled power plan is installed under.</summary>
public const string PowerPlanGUID = "8ae61178-2c55-43f2-afb2-f83725823657";
+ /// <summary>The full path of the running executable.</summary>
public static readonly string ExePath = Environment.ProcessPath!;
+
+ /// <summary>The directory that contains the running executable.</summary>
public static readonly string ExeDir = Path.GetDirectoryName(ExePath)!;
+
+ /// <summary>The file name of the running executable.</summary>
public static readonly string ExeName = Path.GetFileName(ExePath);
+
+ /// <summary>The file version of the running executable.</summary>
public static readonly string FileVersion = FileVersionInfo
.GetVersionInfo(ExePath)
.FileVersion!;
+ /// <summary>AppX package names the bloatware scan marks as safe to remove.</summary>
public static readonly HashSet<string> SafeApps = new()
{
// Bing / MSN / News
"Microsoft.BingWeather",
"Microsoft.BingNews",
- "Microsoft.News", // Microsoft News
- "MicrosoftStart", // Microsoft Start (Win11 22H2+)
+ "Microsoft.News",
+ "MicrosoftStart",
"Microsoft.BingFinance",
"Microsoft.BingSports",
"Microsoft.BingFoodAndDrink",
@@ -70,7 +95,7 @@ public static class Shared
"Microsoft.Office.OneNote",
"Microsoft.Office.Sway",
"Microsoft.MicrosoftJournal",
- "Microsoft.MicrosoftPowerBIForWindows", // Power BI
+ "Microsoft.MicrosoftPowerBIForWindows",
// Social & Wallet (Legacy)
"Microsoft.Wallet",
"Microsoft.MSWallet",
@@ -79,7 +104,7 @@ public static class Shared
"Microsoft.MixedReality.Portal",
"Microsoft.Print3D",
"Microsoft.3DBuilder",
- "Microsoft.Paint3D", // Paint 3D (Win10 only)
+ "Microsoft.Paint3D",
// Multimedia & Entertainment
"Microsoft.ZuneVideo",
"Microsoft.WindowsSoundRecorder",
@@ -137,12 +162,13 @@ public static class Shared
"DolbyLaboratories.DolbyAccess", // OEM audio app
};
+ /// <summary>AppX package names the bloatware scan marks as risky to remove.</summary>
public static readonly HashSet<string> CautionApps = new()
{
// Core Utilities (default handlers for common file types)
"Microsoft.WindowsCalculator",
"Microsoft.WindowsPhotos",
- "Microsoft.MSPaint", // Classic Paint (Win10)
+ "Microsoft.MSPaint",
"Microsoft.Paint",
"Microsoft.WindowsNotepad",
"Microsoft.WindowsCamera",
@@ -228,23 +254,32 @@ public static class Shared
"CyberLinkMediaSuiteEssentials", // OEM media suite
};
+ /// <summary>The per-user data directory under LocalApplicationData.</summary>
public static string RootDirectory =>
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"optimizerDuck"
);
+ /// <summary>The directory that holds downloaded and bundled resources.</summary>
public static string ResourcesDirectory => Path.Combine(RootDirectory, "Resources");
+
+ /// <summary>The directory that holds downloaded resources.</summary>
public static string DownloadsDirectory => Path.Combine(ResourcesDirectory, "Downloads");
+
+ /// <summary>The directory that holds bundled assets.</summary>
public static string AssetsDirectory => Path.Combine(ResourcesDirectory, "Assets");
+
+ /// <summary>The directory that holds one revert file per applied item.</summary>
public static string RevertDirectory => Path.Combine(RootDirectory, "Revert");
/// <summary>
- /// Where what an apply did is recorded, one file per item. Separate from the revert data
- /// so that a report outlives the revert file it describes.
+ /// Where what an apply did is recorded, one file per item. Separate from the revert data,
+ /// so a report outlives the revert file it describes.
/// </summary>
public static string HistoryDirectory => Path.Combine(RootDirectory, "History");
+ /// <summary>Gets a value that indicates whether the OS is Windows 11 or later.</summary>
public static bool IsWindows11OrGreater =>
OperatingSystem.IsWindowsVersionAtLeast(10, 0, 22000);
}
diff --git a/optimizerDuck/Common/Helpers/UiThread.cs b/optimizerDuck/Common/Helpers/UiThread.cs
index 54f5c66..a45d598 100644
--- a/optimizerDuck/Common/Helpers/UiThread.cs
+++ b/optimizerDuck/Common/Helpers/UiThread.cs
@@ -4,16 +4,15 @@ using System.Windows.Threading;
namespace optimizerDuck.Common.Helpers;
/// <summary>
-/// Marshals work to the WPF UI thread, degrading gracefully to inline execution when
-/// no <see cref="Application"/> exists (e.g. unit tests or headless hosts). Use this
-/// instead of touching <c>Application.Current.Dispatcher</c> directly so background
-/// threads never need to null-check the application instance.
+/// Marshals work to the WPF UI thread, degrading to inline execution when no
+/// <see cref="Application" /> exists, as in unit tests or headless hosts. Callers reach the
+/// dispatcher through this type, so a background thread never null-checks the application.
/// </summary>
public static class UiThread
{
/// <summary>
- /// Runs <paramref name="action"/> on the UI thread. When already on the UI thread,
- /// or when no <see cref="Application"/> exists, the action runs inline.
+ /// Runs <paramref name="action" /> on the UI thread. When already on the UI thread,
+ /// or when no <see cref="Application" /> exists, the action runs inline.
/// </summary>
public static Task InvokeAsync(
Action action,
@@ -30,8 +29,8 @@ public static class UiThread
}
/// <summary>
- /// Runs <paramref name="action"/> on the UI thread and awaits its completion. When
- /// already on the UI thread, or when no <see cref="Application"/> exists, the
+ /// Runs <paramref name="action" /> on the UI thread and awaits its completion. When
+ /// already on the UI thread, or when no <see cref="Application" /> exists, the
/// action runs inline.
/// </summary>
public static Task InvokeAsync(
diff --git a/optimizerDuck/Domain/Abstractions/ICustomizeSetting.cs b/optimizerDuck/Domain/Abstractions/ICustomizeSetting.cs
index e1641f7..e312c9d 100644
--- a/optimizerDuck/Domain/Abstractions/ICustomizeSetting.cs
+++ b/optimizerDuck/Domain/Abstractions/ICustomizeSetting.cs
@@ -24,7 +24,7 @@ public interface ICustomizeSetting
string FeatureKey { get; }
/// <summary>
- /// Gets the compatibility condition type (implementing <see cref="ICondition"/>)
+ /// Gets the compatibility condition type (implementing <see cref="ICondition" />)
/// that determines whether this setting is supported on the current system.
/// </summary>
Type? ConditionType { get; }
@@ -48,12 +48,12 @@ public interface ICustomizeSetting
/// <summary>
/// Reads state until two consecutive reads agree or retries run out. Use after
- /// <see cref="ApplyAsync"/> to let the registry settle.
+ /// <see cref="ApplyAsync" /> to let the registry settle.
/// </summary>
Task<bool> GetStateWithRetryAsync(int maxRetries = 3, int delayMs = 80);
/// <summary>
- /// Applies the value, recording every write into <paramref name="call"/>
+ /// Applies the value, recording every write into <paramref name="call" />
/// for change tracking and revert. The first failure wins the return,
/// but all writes are still attempted.
/// </summary>
@@ -65,6 +65,8 @@ public interface ICustomizeSetting
/// </summary>
IReadOnlyList<string> WatchedRegistryPaths { get; }
- /// <summary>Returns the setting's recommendation, or <c>null</c> when none exists.</summary>
+ /// <summary>
+ /// Returns the setting's recommendation, or <see langword="null" /> when none exists.
+ /// </summary>
CustomizeRecommendationResult? GetRecommendation();
}
diff --git a/optimizerDuck/Domain/Abstractions/IOptimization.cs b/optimizerDuck/Domain/Abstractions/IOptimization.cs
index 66a7fcb..9b15935 100644
--- a/optimizerDuck/Domain/Abstractions/IOptimization.cs
+++ b/optimizerDuck/Domain/Abstractions/IOptimization.cs
@@ -10,14 +10,8 @@ namespace optimizerDuck.Domain.Abstractions;
/// </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>
@@ -35,27 +29,19 @@ public interface IOptimization
/// </summary>
string ShortDescription { get; }
- /// <summary>
- /// The current applied state and timing information.
- /// </summary>
OptimizationState State { get; set; }
/// <summary>
- /// The compatibility condition type (implementing <see cref="ICondition"/>)
- /// that determines whether this optimization is supported on the current system,
- /// or <c>null</c> when it is always available.
+ /// The <see cref="ICondition" /> implementation that must hold on the current system,
+ /// or <see langword="null" /> when the optimization is always available.
/// </summary>
Type? ConditionType { get; }
- /// <summary>Gets or sets the evaluated compatibility result.</summary>
ConditionResult ConditionResult { 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>
+ /// <returns>The result of the apply operation.</returns>
Task<ApplyResult> ApplyAsync(
IProgress<ProcessingProgress> progress,
OptimizationContext context
diff --git a/optimizerDuck/Domain/Abstractions/IOptimizationCategory.cs b/optimizerDuck/Domain/Abstractions/IOptimizationCategory.cs
index 417ee73..65d2466 100644
--- a/optimizerDuck/Domain/Abstractions/IOptimizationCategory.cs
+++ b/optimizerDuck/Domain/Abstractions/IOptimizationCategory.cs
@@ -13,13 +13,7 @@ public interface IOptimizationCategory
/// </summary>
public string Name { get; }
- /// <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; }
}
diff --git a/optimizerDuck/Domain/Abstractions/IRevertStep.cs b/optimizerDuck/Domain/Abstractions/IRevertStep.cs
index a787c0c..72056b3 100644
--- a/optimizerDuck/Domain/Abstractions/IRevertStep.cs
+++ b/optimizerDuck/Domain/Abstractions/IRevertStep.cs
@@ -25,7 +25,9 @@ public interface IRevertStep
/// </summary>
/// <param name="context">Shell, power service, and logger for this revert.</param>
/// <param name="logger">The logger to record provider and shell operations.</param>
- /// <returns><c>true</c> if the revert succeeded; otherwise, <c>false</c>.</returns>
+ /// <returns>
+ /// <see langword="true" /> if the revert succeeded; otherwise <see langword="false" />.
+ /// </returns>
Task<bool> ExecuteAsync(RevertContext context, ILogger logger);
/// <summary>
diff --git a/optimizerDuck/Domain/Abstractions/IWindow.cs b/optimizerDuck/Domain/Abstractions/IWindow.cs
index b47a2ee..9b6e6af 100644
--- a/optimizerDuck/Domain/Abstractions/IWindow.cs
+++ b/optimizerDuck/Domain/Abstractions/IWindow.cs
@@ -12,8 +12,5 @@ public interface IWindow
/// </summary>
event RoutedEventHandler Loaded;
- /// <summary>
- /// Shows the window.
- /// </summary>
void Show();
}
diff --git a/optimizerDuck/Domain/Abstractions/RevertContext.cs b/optimizerDuck/Domain/Abstractions/RevertContext.cs
index ee033a0..b02724d 100644
--- a/optimizerDuck/Domain/Abstractions/RevertContext.cs
+++ b/optimizerDuck/Domain/Abstractions/RevertContext.cs
@@ -5,8 +5,7 @@ using optimizerDuck.Services.System.Primitives;
namespace optimizerDuck.Domain.Abstractions;
/// <summary>
-/// Explicit per-revert execution context: every capability a revert step
-/// needs travels as a parameter instead of hiding behind service locators.
+/// Per-revert execution context carrying every capability a revert step needs.
/// </summary>
public sealed class RevertContext
{
diff --git a/optimizerDuck/Domain/Attributes/CustomizeSettingAttribute.cs b/optimizerDuck/Domain/Attributes/CustomizeSettingAttribute.cs
index cbbc7ef..7557c18 100644
--- a/optimizerDuck/Domain/Attributes/CustomizeSettingAttribute.cs
+++ b/optimizerDuck/Domain/Attributes/CustomizeSettingAttribute.cs
@@ -11,9 +11,8 @@ public sealed class CustomizeSettingAttribute : Attribute
public RecommendationState Recommendation { get; init; } = RecommendationState.None;
/// <summary>
- /// The compatibility condition type (implementing <see cref="ICondition"/>)
- /// that determines whether this setting is supported on the current system.
- /// When <c>null</c>, the setting is always available.
+ /// The <see cref="ICondition" /> implementation that must hold on the current system.
+ /// When <see langword="null" />, the setting is always available.
/// </summary>
public Type? Condition { get; init; }
diff --git a/optimizerDuck/Domain/Attributes/OptimizationAttribute.cs b/optimizerDuck/Domain/Attributes/OptimizationAttribute.cs
index eff992c..82177ee 100644
--- a/optimizerDuck/Domain/Attributes/OptimizationAttribute.cs
+++ b/optimizerDuck/Domain/Attributes/OptimizationAttribute.cs
@@ -13,9 +13,6 @@ public sealed class OptimizationAttribute : Attribute
/// </summary>
public required string Id { get; init; }
- /// <summary>
- /// The risk level associated with applying this optimization.
- /// </summary>
public required OptimizationRisk Risk { get; init; }
/// <summary>
@@ -24,9 +21,8 @@ public sealed class OptimizationAttribute : Attribute
public required OptimizationTags Tags { get; init; }
/// <summary>
- /// The compatibility condition type (implementing <see cref="ICondition"/>)
- /// that determines whether this optimization is supported on the current system.
- /// When <c>null</c>, the optimization is always available.
+ /// The <see cref="ICondition" /> implementation that must hold on the current system.
+ /// When <see langword="null" />, the optimization is always available.
/// </summary>
public Type? Condition { get; init; }
}
diff --git a/optimizerDuck/Domain/Attributes/OptimizationCategoryAttribute.cs b/optimizerDuck/Domain/Attributes/OptimizationCategoryAttribute.cs
index 44f27fb..f7c94b4 100644
--- a/optimizerDuck/Domain/Attributes/OptimizationCategoryAttribute.cs
+++ b/optimizerDuck/Domain/Attributes/OptimizationCategoryAttribute.cs
@@ -8,8 +8,5 @@
[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;
}
diff --git a/optimizerDuck/Domain/Conditions/BuiltIn/CpuBrandCondition.cs b/optimizerDuck/Domain/Conditions/BuiltIn/CpuBrandCondition.cs
index 19bea9d..894013f 100644
--- a/optimizerDuck/Domain/Conditions/BuiltIn/CpuBrandCondition.cs
+++ b/optimizerDuck/Domain/Conditions/BuiltIn/CpuBrandCondition.cs
@@ -7,13 +7,12 @@ namespace optimizerDuck.Domain.Conditions;
/// <summary>Base condition that requires the CPU to belong to a specific brand.</summary>
public abstract class CpuBrandCondition : ConditionBase
{
- /// <summary>The required CPU vendor.</summary>
protected abstract CpuVendor RequiredVendor { get; }
- /// <summary>Strongly-typed localized failure title.</summary>
+ /// <summary>Supplies the localized failure title.</summary>
protected abstract Func<string> Title { get; }
- /// <summary>Strongly-typed localized failure description.</summary>
+ /// <summary>Supplies the localized failure description.</summary>
protected abstract Func<string> Description { get; }
public override ConditionResult Evaluate(SystemInfo snapshot)
diff --git a/optimizerDuck/Domain/Conditions/BuiltIn/GpuBrandCondition.cs b/optimizerDuck/Domain/Conditions/BuiltIn/GpuBrandCondition.cs
index e53d9ef..c62f1e1 100644
--- a/optimizerDuck/Domain/Conditions/BuiltIn/GpuBrandCondition.cs
+++ b/optimizerDuck/Domain/Conditions/BuiltIn/GpuBrandCondition.cs
@@ -7,13 +7,12 @@ namespace optimizerDuck.Domain.Conditions;
/// <summary>Base condition that requires at least one GPU from a specific vendor.</summary>
public abstract class GpuBrandCondition : ConditionBase
{
- /// <summary>The required GPU vendor.</summary>
protected abstract GpuVendor RequiredVendor { get; }
- /// <summary>Strongly-typed localized failure title.</summary>
+ /// <summary>Supplies the localized failure title.</summary>
protected abstract Func<string> Title { get; }
- /// <summary>Strongly-typed localized failure description.</summary>
+ /// <summary>Supplies the localized failure description.</summary>
protected abstract Func<string> Description { get; }
public override ConditionResult Evaluate(SystemInfo snapshot)
diff --git a/optimizerDuck/Domain/Conditions/BuiltIn/MinimumRamCondition.cs b/optimizerDuck/Domain/Conditions/BuiltIn/MinimumRamCondition.cs
index fbd8986..b377254 100644
--- a/optimizerDuck/Domain/Conditions/BuiltIn/MinimumRamCondition.cs
+++ b/optimizerDuck/Domain/Conditions/BuiltIn/MinimumRamCondition.cs
@@ -7,13 +7,12 @@ namespace optimizerDuck.Domain.Conditions;
/// <summary>Base condition that requires a minimum amount of installed RAM.</summary>
public abstract class MinimumRamCondition : ConditionBase
{
- /// <summary>The minimum required RAM in gigabytes.</summary>
protected abstract double MinimumGb { get; }
- /// <summary>Strongly-typed localized failure title.</summary>
+ /// <summary>Supplies the localized failure title.</summary>
protected abstract Func<string> Title { get; }
- /// <summary>Strongly-typed localized failure description.</summary>
+ /// <summary>Supplies the localized failure description.</summary>
protected abstract Func<string> Description { get; }
public override ConditionResult Evaluate(SystemInfo snapshot) =>
diff --git a/optimizerDuck/Domain/Conditions/BuiltIn/RecallInstalledCondition.cs b/optimizerDuck/Domain/Conditions/BuiltIn/RecallInstalledCondition.cs
index 6225d7f..07bd686 100644
--- a/optimizerDuck/Domain/Conditions/BuiltIn/RecallInstalledCondition.cs
+++ b/optimizerDuck/Domain/Conditions/BuiltIn/RecallInstalledCondition.cs
@@ -6,10 +6,9 @@ using optimizerDuck.Services.System;
namespace optimizerDuck.Domain.Conditions;
/// <summary>
-/// Requires Windows Recall (AI Explorer) to actually be present on the machine.
-/// Recall ships with the Windows AI shell components, which are only installed on
-/// Windows 11 24H2+ systems that have the feature: a build check alone would mark
-/// a plain 24H2 machine as supported even though Recall does not exist there.
+/// Requires Windows Recall (AI Explorer) to be present on the machine. Recall ships with the
+/// Windows AI shell components, installed only on Windows 11 24H2+ systems that have the
+/// feature, so a build check alone would mark a plain 24H2 machine as supported.
/// </summary>
public sealed class RecallInstalledCondition : ConditionBase
{
diff --git a/optimizerDuck/Domain/Conditions/BuiltIn/RegistryKeyExistsCondition.cs b/optimizerDuck/Domain/Conditions/BuiltIn/RegistryKeyExistsCondition.cs
index 876a4ea..1b101e2 100644
--- a/optimizerDuck/Domain/Conditions/BuiltIn/RegistryKeyExistsCondition.cs
+++ b/optimizerDuck/Domain/Conditions/BuiltIn/RegistryKeyExistsCondition.cs
@@ -12,13 +12,12 @@ namespace optimizerDuck.Domain.Conditions;
/// </summary>
public abstract class RegistryKeyExistsCondition : ConditionBase
{
- /// <summary>The registry key that must exist.</summary>
protected abstract RegistryItem RegistryItem { get; }
- /// <summary>Strongly-typed localized failure title.</summary>
+ /// <summary>Supplies the localized failure title.</summary>
protected abstract Func<string> Title { get; }
- /// <summary>Strongly-typed localized failure description.</summary>
+ /// <summary>Supplies the localized failure description.</summary>
protected abstract Func<string> Description { get; }
public override ConditionResult Evaluate(SystemInfo snapshot)
diff --git a/optimizerDuck/Domain/Conditions/BuiltIn/ServiceExistsCondition.cs b/optimizerDuck/Domain/Conditions/BuiltIn/ServiceExistsCondition.cs
index 5fb1692..191c8fb 100644
--- a/optimizerDuck/Domain/Conditions/BuiltIn/ServiceExistsCondition.cs
+++ b/optimizerDuck/Domain/Conditions/BuiltIn/ServiceExistsCondition.cs
@@ -11,13 +11,12 @@ namespace optimizerDuck.Domain.Conditions;
/// </summary>
public abstract class ServiceExistsCondition : ConditionBase
{
- /// <summary>The name of the required service.</summary>
protected abstract string ServiceName { get; }
- /// <summary>Strongly-typed localized failure title.</summary>
+ /// <summary>Supplies the localized failure title.</summary>
protected abstract Func<string> Title { get; }
- /// <summary>Strongly-typed localized failure description.</summary>
+ /// <summary>Supplies the localized failure description.</summary>
protected abstract Func<string> Description { get; }
public override ConditionResult Evaluate(SystemInfo snapshot)
diff --git a/optimizerDuck/Domain/Conditions/BuiltIn/Windows11_24H2OrGreaterCondition.cs b/optimizerDuck/Domain/Conditions/BuiltIn/Windows11_24H2OrGreaterCondition.cs
index d17b04e..a407182 100644
--- a/optimizerDuck/Domain/Conditions/BuiltIn/Windows11_24H2OrGreaterCondition.cs
+++ b/optimizerDuck/Domain/Conditions/BuiltIn/Windows11_24H2OrGreaterCondition.cs
@@ -5,8 +5,7 @@ using optimizerDuck.Services.System;
namespace optimizerDuck.Domain.Conditions;
/// <summary>
-/// Requires Windows 11 24H2 (build 26100) or later. Used to gate AI features
-/// that only exist on 24H2 and newer builds.
+/// Requires Windows 11 24H2 (build 26100) or later.
/// </summary>
public sealed class Windows11_24H2OrGreaterCondition : ConditionBase
{
diff --git a/optimizerDuck/Domain/Conditions/ConditionBase.cs b/optimizerDuck/Domain/Conditions/ConditionBase.cs
index 03fbdc0..64c75bd 100644
--- a/optimizerDuck/Domain/Conditions/ConditionBase.cs
+++ b/optimizerDuck/Domain/Conditions/ConditionBase.cs
@@ -3,7 +3,7 @@ using optimizerDuck.Services.System;
namespace optimizerDuck.Domain.Conditions;
/// <summary>
-/// Base class for conditions. Provides helpers shared by condition implementations.
+/// Provides helpers shared by condition implementations.
/// </summary>
public abstract class ConditionBase : ICondition
{
diff --git a/optimizerDuck/Domain/Conditions/ConditionResult.cs b/optimizerDuck/Domain/Conditions/ConditionResult.cs
index 592a454..3e4f33f 100644
--- a/optimizerDuck/Domain/Conditions/ConditionResult.cs
+++ b/optimizerDuck/Domain/Conditions/ConditionResult.cs
@@ -18,8 +18,12 @@ public sealed class ConditionResult
/// title/description providers.
/// </summary>
/// <param name="state">The outcome state of the check.</param>
- /// <param name="titleProvider">Provider for the condition title, or <c>null</c>.</param>
- /// <param name="descriptionProvider">Provider for the condition explanation, or <c>null</c>.</param>
+ /// <param name="titleProvider">
+ /// Provider for the condition title, or <see langword="null" />.
+ /// </param>
+ /// <param name="descriptionProvider">
+ /// Provider for the condition explanation, or <see langword="null" />.
+ /// </param>
public ConditionResult(
ConditionState state,
Func<string>? titleProvider = null,
@@ -34,7 +38,7 @@ public sealed class ConditionResult
/// <summary>A convenience result representing a fully supported item.</summary>
public static readonly ConditionResult Available = new(ConditionState.Available);
- /// <summary>Creates an "unsupported" result with the given localized title/description.</summary>
+ /// <summary>Creates an unsupported result with the given localized text.</summary>
public static ConditionResult Unsupported(Func<string> title, Func<string> description) =>
new(ConditionState.Unsupported, title, description);
@@ -52,21 +56,21 @@ public sealed class ConditionResult
/// <summary>Gets the outcome state of the check.</summary>
public ConditionState State { get; }
- /// <summary>Gets the provider for the condition title, or <c>null</c>.</summary>
+ /// <summary>Gets the provider for the condition title, or <see langword="null" />.</summary>
public Func<string>? TitleProvider { get; }
- /// <summary>Gets the provider for the condition explanation, or <c>null</c>.</summary>
+ /// <summary>Gets the condition explanation provider, or <see langword="null" />.</summary>
public Func<string>? DescriptionProvider { get; }
/// <summary>
/// Gets whether this result should block the item by default. Only
- /// <see cref="ConditionState.Unsupported"/> blocks.
+ /// <see cref="ConditionState.Unsupported" /> blocks.
/// </summary>
public bool IsBlocking => State is ConditionState.Unsupported;
- /// <summary>Gets the localized title for this result, or <c>null</c>.</summary>
+ /// <summary>Gets the localized title for this result, or <see langword="null" />.</summary>
public string? Title => TitleProvider?.Invoke();
- /// <summary>Gets the localized description for this result, or <c>null</c>.</summary>
+ /// <summary>Gets the localized description, or <see langword="null" />.</summary>
public string? Description => DescriptionProvider?.Invoke();
}
diff --git a/optimizerDuck/Domain/Conditions/ConditionValidation.cs b/optimizerDuck/Domain/Conditions/ConditionValidation.cs
index ffba9fe..1d02925 100644
--- a/optimizerDuck/Domain/Conditions/ConditionValidation.cs
+++ b/optimizerDuck/Domain/Conditions/ConditionValidation.cs
@@ -7,13 +7,15 @@ namespace optimizerDuck.Domain.Conditions;
public static class ConditionValidation
{
/// <summary>
- /// Ensures <paramref name="conditionType"/> either is <c>null</c> or is a concrete
- /// <see cref="ICondition"/> with a public parameterless constructor.
+ /// Ensures <paramref name="conditionType" /> either is <see langword="null" /> or is a
+ /// concrete <see cref="ICondition" /> with a public parameterless constructor.
/// </summary>
- /// <param name="conditionType">The condition type declared in an attribute, or <c>null</c>.</param>
+ /// <param name="conditionType">
+ /// The condition type declared in an attribute, or <see langword="null" />.
+ /// </param>
/// <param name="ownerName">The owning item's display name, used in the error message.</param>
/// <exception cref="InvalidOperationException">
- /// Thrown when the type does not implement <see cref="ICondition"/> or has no
+ /// Thrown when the type does not implement <see cref="ICondition" /> or has no
/// parameterless constructor.
/// </exception>
public static void Validate(Type? conditionType, string ownerName)
diff --git a/optimizerDuck/Domain/Conditions/ICondition.cs b/optimizerDuck/Domain/Conditions/ICondition.cs
index 876dece..84c6e93 100644
--- a/optimizerDuck/Domain/Conditions/ICondition.cs
+++ b/optimizerDuck/Domain/Conditions/ICondition.cs
@@ -9,6 +9,5 @@ namespace optimizerDuck.Domain.Conditions;
/// </summary>
public interface ICondition
{
- /// <summary>Evaluates the condition against the system snapshot.</summary>
ConditionResult Evaluate(SystemInfo snapshot);
}
diff --git a/optimizerDuck/Domain/Configuration/AppSettings.cs b/optimizerDuck/Domain/Configuration/AppSettings.cs
index 8ccc5d5..cd9d3da 100644
--- a/optimizerDuck/Domain/Configuration/AppSettings.cs
+++ b/optimizerDuck/Domain/Configuration/AppSettings.cs
@@ -7,24 +7,12 @@ namespace optimizerDuck.Domain.Configuration;
/// </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>
@@ -37,20 +25,11 @@ public sealed class AppSettings
/// </summary>
public ApplicationTheme Theme { get; set; } = ApplicationTheme.Dark;
- /// <summary>
- /// Whether the user has accepted the legal terms.
- /// </summary>
public bool LegalAccepted { get; set; } = false;
}
- /// <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>
@@ -64,9 +43,6 @@ public sealed class AppSettings
public bool SmoothScrolling { get; set; } = false;
}
- /// <summary>
- /// Bloatware removal options.
- /// </summary>
public sealed class BloatwareOptions
{
/// <summary>
diff --git a/optimizerDuck/Domain/Customize/Categories/Desktop.cs b/optimizerDuck/Domain/Customize/Categories/Desktop.cs
index 7bc07ff..e4b2f83 100644
--- a/optimizerDuck/Domain/Customize/Categories/Desktop.cs
+++ b/optimizerDuck/Domain/Customize/Categories/Desktop.cs
@@ -207,7 +207,8 @@ public class Desktop : LocalizedObject, ICustomizeCategory
}
else
{
- // extract the blank icon to the app resources folder, then set the registry value to point to it
+ // extract the blank icon to the app resources folder, then point the
+ // registry value at it
var outputPath = System.IO.Path.Combine(
Shared.AssetsDirectory,
nameof(Desktop),
@@ -215,7 +216,8 @@ public class Desktop : LocalizedObject, ICustomizeCategory
);
EmbeddedResourceHelper.TryExtract("Icons.blank.ico", outputPath);
- // set the registry value to point to the blank icon, which effectively hides the shortcut arrow overlay
+ // point the registry value at the blank icon, which hides the
+ // shortcut arrow overlay
result = RegistryService.Write(call, new RegistryItem(Path, "29", outputPath));
}
diff --git a/optimizerDuck/Domain/Customize/Categories/Gaming.cs b/optimizerDuck/Domain/Customize/Categories/Gaming.cs
index 7b6f52c..c974059 100644
--- a/optimizerDuck/Domain/Customize/Categories/Gaming.cs
+++ b/optimizerDuck/Domain/Customize/Categories/Gaming.cs
@@ -192,7 +192,6 @@ public class Gaming : LocalizedObject, ICustomizeCategory
new RegistryItem(Path, "MouseThreshold2")
);
- // Check if any value is non-zero (acceleration enabled)
var isNonZero =
(int.TryParse(mouseSpeed, out var speed) && speed != 0)
|| (int.TryParse(threshold1, out var t1) && t1 != 0)
diff --git a/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.cs b/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.cs
index 7f62d39..103bdb2 100644
--- a/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.cs
+++ b/optimizerDuck/Domain/Customize/Models/BaseCustomizeSetting.cs
@@ -51,7 +51,7 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
/// <summary>
/// Gets the compatibility condition type declared in the
/// <see cref="CustomizeSettingAttribute"/> (implementing <see cref="ICondition"/>),
- /// or <c>null</c> when the setting is always available.
+ /// or <see langword="null" /> when the setting is always available.
/// </summary>
public Type? ConditionType => Meta.Condition;
@@ -71,7 +71,7 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
/// <summary>
/// For Dropdown settings: the matched option's value, the raw registry value when
/// out of scope, or <see cref="MissingValueSentinel"/> when the value is missing.
- /// Never interpret <c>null</c> as "unset" for Dropdown settings; use
+ /// Never interpret <see langword="null" /> as "unset" for Dropdown settings; use
/// <see cref="MissingValueSentinel"/> instead.
/// </summary>
public virtual object? CurrentValue
@@ -149,7 +149,7 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
/// </summary>
internal static readonly object MissingValueSentinel = new();
- /// <summary>Creates the fallback option: "Not set" when the value is missing, else "Custom".</summary>
+ /// <summary>Fallback option label: "Not set" when missing, else "Custom".</summary>
private static SettingOption CreateCustomOption(object value) =>
new(
ReferenceEquals(value, MissingValueSentinel)
@@ -170,8 +170,8 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
protected virtual IReadOnlyList<SettingOption>? GetOptions() => null;
/// <summary>
- /// Reads the current registry state. For toggles: <c>true</c> when all required
- /// toggles are on, <c>false</c> otherwise.
+ /// Reads the current registry state. For toggles: <see langword="true" /> when all required
+ /// toggles are on, <see langword="false" /> otherwise.
/// </summary>
public virtual Task<bool> GetStateAsync()
{
@@ -225,7 +225,7 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
/// </summary>
/// <param name="value">The value to apply. The synthetic "Custom"/"Not set" fallback
/// value is a safe no-op.</param>
- /// <param name="call">The explicit per-operation call context (change collector, logger, cancellation).</param>
+ /// <param name="call">Per-operation call context (collector, logger, cancellation).</param>
/// <returns>The first failure, or success when every write succeeded.</returns>
public virtual async Task<OpResult> ApplyAsync(object? value, OpCall call)
{
@@ -233,8 +233,6 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
if (value is bool isOn)
{
- // Attempt every toggle even after a failure; the first failure
- // wins the return while partial application stays recorded.
foreach (var toggle in RegistryToggles)
{
try
@@ -267,7 +265,6 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
.Select(b => new RegistryItem(b.Path, b.Name))
.ToArray();
- // All bindings are attempted; the first failure wins the return.
var results = new List<OpResult>();
if (toDelete.Length > 0)
results.Add(RegistryService.DeleteValue(call, toDelete));
@@ -291,7 +288,6 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
protected virtual IReadOnlyList<string> GetWatchedRegistryPaths()
{
- // From RegistryToggles
var fromToggles = RegistryToggles.Select(t => t.Path);
// From ALL Dropdown option bindings (not just primary)
@@ -308,7 +304,7 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
/// <summary>
/// Whether the setting requires a Windows refresh after <see cref="ApplyAsync"/>.
- /// Defaults to <c>false</c>; auto-derived from <see cref="RefreshScope"/> but
+ /// Defaults to <see langword="false" />; auto-derived from <see cref="RefreshScope"/> but
/// can be overridden for custom behaviour.
/// </summary>
protected virtual bool NeedsPostAction => RefreshScope != CustomizeRefreshScope.None;
@@ -432,7 +428,7 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
/// <summary>
/// Returns the recommendation declared in the <see cref="CustomizeSettingAttribute"/>,
- /// or <c>null</c> when the setting has none.
+ /// or <see langword="null" /> when the setting has none.
/// </summary>
public virtual CustomizeRecommendationResult? GetRecommendation()
{
@@ -535,7 +531,6 @@ public abstract partial class BaseCustomizeSetting : LocalizedObject, ICustomize
private static object? ReadPrimaryRawValue(IReadOnlyList<SettingOption> options)
{
- // Read from the primary binding of the first option that has bindings
foreach (var option in options)
{
if (option.PrimaryBinding is not { } binding)
diff --git a/optimizerDuck/Domain/Customize/Models/CustomizeRefreshScope.cs b/optimizerDuck/Domain/Customize/Models/CustomizeRefreshScope.cs
index e543d38..2f7983b 100644
--- a/optimizerDuck/Domain/Customize/Models/CustomizeRefreshScope.cs
+++ b/optimizerDuck/Domain/Customize/Models/CustomizeRefreshScope.cs
@@ -40,6 +40,7 @@ public enum CustomizeRefreshScope
/// <summary>
/// Toggles desktop icon visibility by reading the current <c>HideIcons</c>
/// registry value and sending <c>WM_COMMAND 0x7402</c> to the desktop's
+ /// <c>SysListView32</c>.
/// </summary>
DesktopIconCache = 1 << 6,
diff --git a/optimizerDuck/Domain/Customize/Models/RecommendationState.cs b/optimizerDuck/Domain/Customize/Models/RecommendationState.cs
index 31d9f16..55f55c0 100644
--- a/optimizerDuck/Domain/Customize/Models/RecommendationState.cs
+++ b/optimizerDuck/Domain/Customize/Models/RecommendationState.cs
@@ -17,6 +17,6 @@ public enum RecommendationState
/// <summary>The setting is experimental and may cause unexpected behavior.</summary>
Experimental,
- /// <summary>The recommendation depends on other factors (e.g., hardware or user preference).</summary>
+ /// <summary>Depends on other factors (e.g. hardware or user preference).</summary>
Depends,
}
diff --git a/optimizerDuck/Domain/Customize/Models/RegistryBinding.cs b/optimizerDuck/Domain/Customize/Models/RegistryBinding.cs
index 83ec837..f8b316f 100644
--- a/optimizerDuck/Domain/Customize/Models/RegistryBinding.cs
+++ b/optimizerDuck/Domain/Customize/Models/RegistryBinding.cs
@@ -5,7 +5,8 @@ namespace optimizerDuck.Domain.Customize.Models;
/// <summary>
/// Binds a <see cref="SettingOption" /> to one or more registry values.
-/// Used by <see cref="BaseCustomizeSetting" /> to auto-read/write registry for Dropdown settings.
+/// Used by <see cref="BaseCustomizeSetting" /> to auto-read/write registry
+/// for Dropdown settings.
/// Supports matching multiple accepted values (e.g. 1 or null for default values).
/// </summary>
public record RegistryBinding(
diff --git a/optimizerDuck/Domain/Customize/Models/RegistryToggle.cs b/optimizerDuck/Domain/Customize/Models/RegistryToggle.cs
index d015ed0..6066b21 100644
--- a/optimizerDuck/Domain/Customize/Models/RegistryToggle.cs
+++ b/optimizerDuck/Domain/Customize/Models/RegistryToggle.cs
@@ -8,7 +8,7 @@ namespace optimizerDuck.Domain.Customize.Models;
/// <summary>
/// Represents a single registry key-value pair that can be toggled on or off.
/// <see cref="OnValues" /> and <see cref="OffValues" /> support multiple values
-/// (e.g. <c>null</c> means "key absent").
+/// (e.g. <see langword="null" /> means "key absent").
/// </summary>
public class RegistryToggle
{
@@ -20,14 +20,14 @@ public class RegistryToggle
/// <summary>
/// Gets the list of values that represent the "on" state.
- /// <c>null</c> in the list means "key absent = on".
+ /// <see langword="null" /> in the list means "key absent = on".
/// Default is <c>[1]</c>.
/// </summary>
public IReadOnlyList<object?> OnValues { get; init; } = [1];
/// <summary>
/// Gets the list of values that represent the "off" state.
- /// <c>null</c> in the list means "key absent = off".
+ /// <see langword="null" /> in the list means "key absent = off".
/// Default is <c>[0]</c>.
/// </summary>
public IReadOnlyList<object?> OffValues { get; init; } = [0];
@@ -39,17 +39,17 @@ public class RegistryToggle
public object? DefaultValue { get; init; } = 0;
/// <summary>
- /// Gets a value that indicates whether this toggle is optional (non-required for state detection).
- /// Default is <see langword="false"/>.
+ /// Gets whether this toggle is optional (not required for state detection).
+ /// Default is <see langword="false" />.
/// </summary>
public bool IsOptional { get; init; } = false;
- /// <summary>Gets the registry value type. Default is <see cref="RegistryValueKind.DWord"/>.</summary>
+ /// <summary>Gets the value kind. Default is <see cref="RegistryValueKind.DWord" />.</summary>
public RegistryValueKind ValueKind { get; init; } = RegistryValueKind.DWord;
/// <summary>
- /// Reads the registry and returns whether the toggle is currently on.
- /// Returns <see langword="true" /> if the registry value matches any value in <see cref="OnValues" />.
+ /// Reads the registry and returns whether the toggle is currently on. The result is
+ /// <see langword="true" /> when the value matches any entry in <see cref="OnValues" />.
/// </summary>
public bool GetState()
{
@@ -59,8 +59,8 @@ public class RegistryToggle
/// <summary>
/// Writes the on/off state to the registry, recording the change into
- /// <paramref name="call"/>. The first value in the target list is the
- /// primary value written; a leading <c>null</c> deletes the value.
+ /// <paramref name="call" />. The first value in the target list is the
+ /// primary value written; a leading <see langword="null" /> deletes the value.
/// </summary>
/// <returns>The provider result; a failed write is returned, not thrown.</returns>
public OpResult SetState(bool isOn, OpCall call)
@@ -103,7 +103,6 @@ public class RegistryToggle
{
try
{
- // Try direct type comparison first
if (a.GetType() == b.GetType())
{
return a.Equals(b);
@@ -132,7 +131,6 @@ public class RegistryToggle
return Convert.ToInt64(a) == Convert.ToInt64(b);
}
- // For floating point, compare as double
if (
(typeA == typeof(float) || typeA == typeof(double) || typeA == typeof(decimal))
&& (
@@ -145,7 +143,6 @@ public class RegistryToggle
return Convert.ToDouble(a) == Convert.ToDouble(b);
}
- // Fallback to decimal comparison for other convertible types
var da = Convert.ToDecimal(a);
var db = Convert.ToDecimal(b);
return da == db;
@@ -156,7 +153,6 @@ public class RegistryToggle
}
}
- // String comparison - use ordinal for case-sensitive, ordinal ignore case for case-insensitive
var strA = a.ToString();
var strB = b.ToString();
return strA != null && strB != null && strA.Equals(strB, StringComparison.Ordinal);
diff --git a/optimizerDuck/Domain/Customize/Models/SettingOption.cs b/optimizerDuck/Domain/Customize/Models/SettingOption.cs
index 2a40528..b43f8b0 100644
--- a/optimizerDuck/Domain/Customize/Models/SettingOption.cs
+++ b/optimizerDuck/Domain/Customize/Models/SettingOption.cs
@@ -7,7 +7,7 @@ public sealed record SettingOption(
)
{
/// <summary>
- /// The first binding in the list, or <c>null</c>. Used by the base class for
+ /// The first binding in the list, or <see langword="null" />. Used by the base class for
/// single-key auto-read/write.
/// </summary>
public RegistryBinding? PrimaryBinding => Bindings is { Count: > 0 } ? Bindings[0] : null;
diff --git a/optimizerDuck/Domain/Execution/ChangeDetail.cs b/optimizerDuck/Domain/Execution/ChangeDetail.cs
index dbda7db..60105f7 100644
--- a/optimizerDuck/Domain/Execution/ChangeDetail.cs
+++ b/optimizerDuck/Domain/Execution/ChangeDetail.cs
@@ -3,15 +3,14 @@ using optimizerDuck.Domain.Optimizations.Models.Services;
namespace optimizerDuck.Domain.Execution;
/// <summary>
-/// The structured facts of one recorded step, as the kind of operation it actually is: one
-/// record per operation, each carrying only the fields that operation has. A provider cannot
-/// record a value name on a service step, and the view words a row from the kind it holds
-/// instead of looking the operation up by name. Providers fill the record for their operation;
-/// a step without a detail keeps its log description on screen.
+/// The structured facts of one recorded step, as the kind of operation it is. Each record
+/// carries only the fields that operation has, and the UI words a row from the kind it holds.
/// </summary>
public abstract record ChangeDetail
{
- /// <summary>Stable operation name, for example <c>registry.write</c>. The UI localizes it.</summary>
+ /// <summary>
+ /// Stable operation name, for example <c>registry.write</c>. The UI localizes it.
+ /// </summary>
public abstract string Operation { get; }
/// <summary>
@@ -66,7 +65,7 @@ public sealed record RegistryValueRemoveDetail : ChangeDetail
/// <summary>The kind of data removed, for example a registry value kind.</summary>
public string? ValueType { get; init; }
- /// <summary>What the value held before it was removed. Null if it held nothing readable.</summary>
+ /// <summary>What the value held before removal. Null if it held nothing readable.</summary>
public string? PreviousValue { get; init; }
public override bool HasValuePair => true;
@@ -115,10 +114,10 @@ public sealed record ScheduledTaskEnableDetail : ChangeDetail
/// <summary>The full path of the task.</summary>
public required string TaskPath { get; init; }
- /// <summary>Whether the task was enabled before the step. Null when that was not read.</summary>
+ /// <summary>Whether the task was enabled before the step. Null when unread.</summary>
public bool? PreviousEnabled { get; init; }
- /// <summary>Whether the task is enabled after the step. Null when the step wrote nothing.</summary>
+ /// <summary>Whether the task is enabled after the step. Null when it wrote nothing.</summary>
public bool? NewEnabled { get; init; }
public override bool HasValuePair => true;
@@ -132,10 +131,10 @@ public sealed record ScheduledTaskDisableDetail : ChangeDetail
/// <summary>The full path of the task.</summary>
public required string TaskPath { get; init; }
- /// <summary>Whether the task was enabled before the step. Null when that was not read.</summary>
+ /// <summary>Whether the task was enabled before the step. Null when unread.</summary>
public bool? PreviousEnabled { get; init; }
- /// <summary>Whether the task is enabled after the step. Null when the step wrote nothing.</summary>
+ /// <summary>Whether the task is enabled after the step. Null when it wrote nothing.</summary>
public bool? NewEnabled { get; init; }
public override bool HasValuePair => true;
diff --git a/optimizerDuck/Domain/Execution/ChangeDetailCodec.cs b/optimizerDuck/Domain/Execution/ChangeDetailCodec.cs
index b06476c..76068fa 100644
--- a/optimizerDuck/Domain/Execution/ChangeDetailCodec.cs
+++ b/optimizerDuck/Domain/Execution/ChangeDetailCodec.cs
@@ -21,8 +21,8 @@ public static class ChangeDetailCodec
/// <summary>
/// The step as the record file stores the facts of a detail, or the step with no facts when
- /// the provider recorded none. The detail fields are written from the kind the step is, so a
- /// field that operation has no meaning for stays empty.
+ /// the provider recorded none. The detail fields are written from the kind the step is,
+ /// so a field that operation has no meaning for stays empty.
/// </summary>
public static ChangeRecordStep WithDetail(this ChangeRecordStep step, ChangeDetail? detail)
{
@@ -30,7 +30,7 @@ public static class ChangeDetailCodec
return step;
// What every kind of step stores the same way: what it did, why it wrote nothing, and
- // whether it moved between two values. Each kind below adds the facts only it has.
+ // whether it moved between two values.
var stored = step with
{
Operation = detail.Operation,
@@ -106,13 +106,12 @@ public static class ChangeDetailCodec
/// <summary>
/// The facts of a stored step, as the kind of operation it is, or <see langword="null" />
- /// for an operation this build does not know: that row falls back to the English description
- /// the log uses, and nothing else in the record changes. A stored value the operation has no
- /// meaning for is ignored rather than shown.
+ /// for an operation this build does not know: that row falls back to the English
+ /// description the log uses, and nothing else in the record changes. A stored value the
+ /// operation has no meaning for is ignored rather than shown.
/// </summary>
public static ChangeDetail? Decode(ChangeRecordStep step)
{
- // Every kind carries the reason, so the switch below only has to say what the operation is.
return step.Operation switch
{
"registry.write" => new RegistryValueWriteDetail
@@ -205,7 +204,9 @@ public static class ChangeDetailCodec
};
}
- /// <summary>The word the record file uses for a state, or null when the state is unknown.</summary>
+ /// <summary>
+ /// The word the record file uses for a state, or null when the state is unknown.
+ /// </summary>
private static string? StateWord(bool? state) =>
state switch
{
diff --git a/optimizerDuck/Domain/Execution/ChangeRecord.cs b/optimizerDuck/Domain/Execution/ChangeRecord.cs
index fd41d9f..ae242ea 100644
--- a/optimizerDuck/Domain/Execution/ChangeRecord.cs
+++ b/optimizerDuck/Domain/Execution/ChangeRecord.cs
@@ -16,20 +16,20 @@ public sealed record ChangeRecord
public string OptimizationKey { get; init; } = string.Empty;
- /// <summary>The item's stable English name, so an old record does not carry an old language.</summary>
+ /// <summary>The item's stable English name, so a record carries no stale language.</summary>
public string LogName { get; init; } = string.Empty;
public DateTime AppliedAt { get; init; }
- /// <summary>When the run started, and how long it took, so the record says what it cost.</summary>
+ /// <summary>When the run started, and how long it took, so the record shows its cost.</summary>
public DateTime? StartedAt { get; init; }
public long? ElapsedMs { get; init; }
- /// <summary>The build that wrote this record, so a report states which one produced it.</summary>
+ /// <summary>The build that wrote this record, so a report names what produced it.</summary>
public string? AppVersion { get; init; }
- /// <summary>The Windows version the run happened on, for the same reason.</summary>
+ /// <summary>The Windows version the run happened on.</summary>
public string? WindowsVersion { get; init; }
/// <summary>Which run this record describes: the last apply, or the revert of it.</summary>
@@ -82,7 +82,9 @@ public sealed record ChangeRecord
};
}
- /// <summary>Captures one finished apply. The record is a copy: nothing here is live state.</summary>
+ /// <summary>
+ /// Captures one finished apply. The record is a copy: nothing here is live state.
+ /// </summary>
public static ChangeRecord From(ChangeSet changes, IOptimization item, string outcome)
{
ArgumentNullException.ThrowIfNull(changes);
@@ -103,10 +105,10 @@ public sealed record ChangeRecord
}
/// <summary>
- /// The same record as a retry leaves it: a step the retry took further takes the outcome the
- /// retry reached and counts one more attempt, and a step the retry did not touch keeps what
- /// it had. What the retry wrote is what the record then says, so the history shows a step
- /// that needed a second attempt instead of only that it once failed.
+ /// The same record as a retry leaves it: a step the retry took further takes the
+ /// outcome the retry reached and counts one more attempt, and a step the retry did
+ /// not touch keeps what it had. What the retry wrote is what the record then says,
+ /// so the history shows a step that needed a second attempt, not one that once failed.
/// </summary>
/// <param name="recovered">The steps the retry recovered.</param>
/// <param name="stillFailed">The steps that failed again.</param>
@@ -137,8 +139,8 @@ public sealed record ChangeRecord
}
/// <summary>
- /// One recorded step as the file stores it. The facts of the operation go through the codec,
- /// which is the only thing that knows how a detail is laid out.
+ /// One recorded step as the file stores it. The facts of the operation go through the
+ /// codec, which is the only thing that knows how a detail is laid out.
/// </summary>
internal static ChangeRecordStep StepOf(Change change) =>
new ChangeRecordStep
@@ -156,7 +158,7 @@ public sealed record ChangeRecord
}.WithDetail(change.Detail);
}
-/// <summary>One step of a recorded apply, with the reason it wrote nothing when it did not.</summary>
+/// <summary>One step of a recorded apply, carrying the reason it wrote nothing.</summary>
public sealed record ChangeRecordStep
{
/// <summary>
diff --git a/optimizerDuck/Domain/Execution/ChangeSet.cs b/optimizerDuck/Domain/Execution/ChangeSet.cs
index eee0e99..ea8d0c2 100644
--- a/optimizerDuck/Domain/Execution/ChangeSet.cs
+++ b/optimizerDuck/Domain/Execution/ChangeSet.cs
@@ -34,7 +34,7 @@ public sealed class ChangeSet
}
}
- /// <summary>Only the successful changes.</summary>
+ /// <summary>Gets the steps that succeeded, in execution order.</summary>
public IReadOnlyList<Change> SuccessfulSteps
{
get
@@ -44,7 +44,7 @@ public sealed class ChangeSet
}
}
- /// <summary>Only the failed changes.</summary>
+ /// <summary>Gets the steps that failed, in execution order.</summary>
public IReadOnlyList<Change> FailedSteps
{
get
@@ -54,7 +54,7 @@ public sealed class ChangeSet
}
}
- /// <summary>Whether at least one change succeeded.</summary>
+ /// <summary>Gets a value that indicates whether any step succeeded.</summary>
public bool HasSuccessfulSteps
{
get
@@ -64,7 +64,7 @@ public sealed class ChangeSet
}
}
- /// <summary>Whether at least one change failed.</summary>
+ /// <summary>Gets a value that indicates whether any step failed.</summary>
public bool HasFailedSteps
{
get
@@ -75,7 +75,7 @@ public sealed class ChangeSet
}
/// <summary>
- /// Whether any step actually modified the system. Skips and irreversible actions
+ /// Whether any step modified the system. Skips and irreversible actions
/// did not leave something to undo, so they do not count as applied changes. A step that
/// modified the system and then failed still counts, because it carries the compensation
/// for what it changed, and dropping it here would leave that work unrevertible.
@@ -209,27 +209,36 @@ public sealed class ChangeSet
/// </summary>
public sealed record Change
{
+ /// <summary>Gets the name of the operation that recorded the step.</summary>
public string Name { get; init; } = string.Empty;
+ /// <summary>Gets the one-line description of what the step did, always in English.</summary>
public string Description { get; init; } = string.Empty;
+ /// <summary>Gets the 1-based execution order, reused as the step's revert-file index.</summary>
public int Index { get; init; }
+ /// <summary>Gets a value that indicates whether the step succeeded.</summary>
public bool Ok { get; init; }
/// <summary>What the step did, which decides whether compensation data is expected.</summary>
public ChangeKind Kind { get; init; } = ChangeKind.Change;
+ /// <summary>
+ /// Gets the compensation step that undoes this step, when it changed something.
+ /// </summary>
public IRevertStep? Revert { get; init; }
/// <summary>
- /// The structured facts of this step, for a UI that speaks the user's language. The log
- /// keeps using <see cref="Description" />, which is always English.
+ /// The structured facts of this step. The log keeps using <see cref="Description" />,
+ /// which is always English.
/// </summary>
public ChangeDetail? Detail { get; init; }
+ /// <summary>Gets the message that explains the failure, when the step failed.</summary>
public string? Error { get; init; }
+ /// <summary>Gets the diagnostic detail of the failure, when one was captured.</summary>
public string? ErrorDetail { get; init; }
/// <summary>
@@ -255,6 +264,7 @@ public sealed record Change
/// </summary>
public int Attempt { get; init; } = 1;
+ /// <summary>Gets the action that retries the step, when a retry can help.</summary>
public Func<OpCall, Task<OpResult>>? Retry { get; init; }
}
diff --git a/optimizerDuck/Domain/Execution/OpCall.cs b/optimizerDuck/Domain/Execution/OpCall.cs
index 42674e3..6c36c75 100644
--- a/optimizerDuck/Domain/Execution/OpCall.cs
+++ b/optimizerDuck/Domain/Execution/OpCall.cs
@@ -3,14 +3,16 @@ using Microsoft.Extensions.Logging;
namespace optimizerDuck.Domain.Execution;
/// <summary>
-/// Explicit per-operation call context: every dependency a provider needs
-/// (change collector, logger, cancellation) travels as a parameter.
+/// Explicit per-operation call context: every dependency travels as a parameter.
/// </summary>
public class OpCall
{
+ /// <summary>Gets the collector this operation records its changes into.</summary>
public ChangeSet Changes { get; init; } = new();
+ /// <summary>Gets the logger the operation writes its diagnostics to.</summary>
public required ILogger Logger { get; init; }
+ /// <summary>Gets the token that cancels the operation.</summary>
public CancellationToken CancellationToken { get; init; }
}
diff --git a/optimizerDuck/Domain/Execution/OpResult.cs b/optimizerDuck/Domain/Execution/OpResult.cs
index 455b41c..4dfee10 100644
--- a/optimizerDuck/Domain/Execution/OpResult.cs
+++ b/optimizerDuck/Domain/Execution/OpResult.cs
@@ -3,8 +3,7 @@ using optimizerDuck.Domain.Abstractions;
namespace optimizerDuck.Domain.Execution;
/// <summary>
-/// The result of a single provider operation. Errors flow here
-/// instead of ambient error state.
+/// The result of a single provider operation. Errors travel in the result, not ambient state.
/// </summary>
public sealed record OpResult(
bool Ok,
@@ -13,11 +12,18 @@ public sealed record OpResult(
string? ErrorDetail = null
)
{
+ /// <summary>Creates a result that reports the operation succeeded.</summary>
+ /// <param name="revert">The compensation step that undoes the change, when one exists.</param>
+ /// <returns>A result that reports success and carries the compensation step.</returns>
public static OpResult Success(IRevertStep? revert = null)
{
return new OpResult(true, revert);
}
+ /// <summary>Creates a result that reports the operation failed.</summary>
+ /// <param name="error">The message that explains the failure.</param>
+ /// <param name="errorDetail">Diagnostic detail for the failure, when one was captured.</param>
+ /// <returns>A result that reports failure with the given messages.</returns>
public static OpResult Fail(string error, string? errorDetail = null)
{
return new OpResult(false, null, error, errorDetail);
diff --git a/optimizerDuck/Domain/Optimizations/Categories/Gpu.cs b/optimizerDuck/Domain/Optimizations/Categories/Gpu.cs
index b81a4e0..af4cab4 100644
--- a/optimizerDuck/Domain/Optimizations/Categories/Gpu.cs
+++ b/optimizerDuck/Domain/Optimizations/Categories/Gpu.cs
@@ -65,31 +65,31 @@ public class Gpu : LocalizedObject, IOptimizationCategory
public ObservableCollection<IOptimization> Optimizations { get; init; } = [];
/// <summary>
- /// Attempts to parse a WMI <c>DeviceID</c> (e.g., "VideoController1") into a zero-based registry index
- /// used in the Display Class registry path (e.g., "0000", "0001").
+ /// Parses a WMI <c>DeviceID</c> such as "VideoController1" into the zero-based registry
+ /// index used in the Display Class registry path (for example "0000", "0001").
/// </summary>
/// <remarks>
/// <para>
- /// Windows stores display adapter settings under:
- /// <c>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\XXXX</c>
- /// where <c>XXXX</c> is a 4-digit zero-padded index (e.g., <c>0000</c>).
+ /// Windows stores display adapter settings under the Display Class key
+ /// <c>{4d36e968-e325-11ce-bfc1-08002be10318}\XXXX</c>, where <c>XXXX</c> is a
+ /// 4-digit zero-padded index, for example <c>0000</c>.
/// </para>
/// <para>
- /// The <see cref="Win32_VideoController" /> WMI class provides a <c>DeviceID</c> property in the format:
- /// <c>"VideoController1"</c>, <c>"VideoController2"</c>, etc. This method converts:
+ /// The <see cref="Win32_VideoController" /> WMI class provides a <c>DeviceID</c>
+ /// property, for example <c>"VideoController1"</c>:
/// <list type="bullet">
/// <item>
- /// <description><c>"VideoController1"</c> → index <c>0</c> → registry subkey <c>"0000"</c></description>
+ /// <description><c>"VideoController1"</c> is index <c>0</c>.</description>
/// </item>
/// <item>
- /// <description><c>"VideoController2"</c> → index <c>1</c> → registry subkey <c>"0001"</c></description>
+ /// <description><c>"VideoController2"</c> is index <c>1</c>.</description>
/// </item>
/// </list>
/// </para>
/// <para>
- /// This mapping is <strong>required</strong> because the order of GPUs in <see cref="SystemInfo.Gpus" />
- /// does <strong>not</strong> guarantee alignment with registry index order. Using array index (0, 1, 2...)
- /// leads to applying tweaks to the wrong GPU (e.g., iGPU instead of dGPU).
+ /// The mapping is required: the order of GPUs in <see cref="SystemInfo.Gpus" />
+ /// need not match the registry index order, and using the array index would apply
+ /// tweaks to the wrong GPU, for example the integrated one instead of the discrete.
/// </para>
/// </remarks>
/// <param name="deviceId">
@@ -97,29 +97,24 @@ public class Gpu : LocalizedObject, IOptimizationCategory
/// <c>"VideoControllerN"</c> where <c>N</c> is a positive integer starting from 1.
/// </param>
/// <param name="index">
- /// When the method returns <c>true</c>, contains the zero-based index suitable for formatting with
- /// <c>:D4</c> (e.g., <c>0</c> → <c>"0000"</c>). When <c>false</c>, the value is <c>-1</c>.
+ /// On <see langword="true" />, the zero-based index to format with <c>:D4</c>, for example
+ /// <c>0</c> as <c>"0000"</c>. On <see langword="false" />, <c>-1</c>.
/// </param>
/// <returns>
- /// <c>true</c> if <paramref name="deviceId" /> is valid and successfully parsed; otherwise, <c>false</c>.
+ /// <see langword="true" /> if <paramref name="deviceId" /> is valid and parsed;
+ /// otherwise <see langword="false" />.
/// </returns>
/// <example>
/// <code>
/// string deviceId = "VideoController1";
/// if (TryParseDeviceIdToIndex(deviceId, out int index))
/// {
- /// string regPath = $@"HKLM\...\{{4d36e968-...\}}\{index:D4}"; // → "0000"
+ /// string regPath = $@"HKLM\...\{{4d36e968-...\}}\{index:D4}"; // gives "0000"
/// Console.WriteLine($"Apply tweak to GPU at registry index: {index:D4}");
/// }
/// </code>
/// </example>
- /// <exception cref="ArgumentNullException">
- /// Returns false instead of throwing when <paramref name="deviceId" /> is null or whitespace.
- /// </exception>
/// <seealso cref="GpuInfo.DeviceId" />
- /// <seealso href="https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-videocontroller">
- /// Win32_VideoController WMI class
- /// </seealso>
public static bool TryParseDeviceIdToIndex(string? deviceId, out int index)
{
index = -1;
@@ -134,7 +129,7 @@ public class Gpu : LocalizedObject, IOptimizationCategory
if (!int.TryParse(numberPart, out var deviceNumber) || deviceNumber <= 0)
return false;
- index = deviceNumber - 1; // convert to zero-based index
+ index = deviceNumber - 1;
return true;
}
diff --git a/optimizerDuck/Domain/Optimizations/Categories/Performance.cs b/optimizerDuck/Domain/Optimizations/Categories/Performance.cs
index 549da88..0d3371e 100644
--- a/optimizerDuck/Domain/Optimizations/Categories/Performance.cs
+++ b/optimizerDuck/Domain/Optimizations/Categories/Performance.cs
@@ -161,7 +161,7 @@ public class Performance : LocalizedObject, IOptimizationCategory
const string systemProfileKey =
@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile";
- // Parent SystemProfile settings (NoLazyMode, AlwaysOn, NetworkThrottlingIndex, SystemResponsiveness)
+ // Parent SystemProfile settings
RegistryService.Write(
context,
new RegistryItem(systemProfileKey, "NoLazyMode", 1),
@@ -180,7 +180,7 @@ public class Performance : LocalizedObject, IOptimizationCategory
) // minimum possible value (Values below 10 and above 100 are clamped to 20.)
);
- // Games task scheduling (Priority, Scheduling Category, SFIO Priority, GPU Priority)
+ // Games task scheduling
RegistryService.Write(
context,
new RegistryItem($@"{systemProfileKey}\Tasks\Games", "Priority", 2),
diff --git a/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.cs b/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.cs
index 922e7c4..6ef470f 100644
--- a/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.cs
+++ b/optimizerDuck/Domain/Optimizations/Categories/PowerManagement.cs
@@ -232,8 +232,7 @@ public class PowerManagement : LocalizedObject, IOptimizationCategory
return OpResult.Success(revertStep);
}
- // Null means the WMI query itself failed (class unavailable or the write was refused),
- // which is the one case the old exit-code check also treated as a failure.
+ // Null means the WMI query itself failed (class unavailable or the write was refused).
var error = ServiceStrings.UsbPowerErrorChangeFailed;
call.Logger.LogWarning("[USB][FAIL] WMI write refused or unavailable");
call.Changes.Add(
diff --git a/optimizerDuck/Domain/Optimizations/Models/ApplyResult.cs b/optimizerDuck/Domain/Optimizations/Models/ApplyResult.cs
index 1653ea2..76b1b21 100644
--- a/optimizerDuck/Domain/Optimizations/Models/ApplyResult.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/ApplyResult.cs
@@ -6,7 +6,7 @@ namespace optimizerDuck.Domain.Optimizations.Models;
public readonly record struct ApplyResult
{
/// <summary>
- /// The error message if the step failed; <c>null</c> if successful.
+ /// The error message if the step failed; <see langword="null" /> if successful.
/// </summary>
public string? ErrorMessage { get; init; }
diff --git a/optimizerDuck/Domain/Optimizations/Models/BaseOptimization.cs b/optimizerDuck/Domain/Optimizations/Models/BaseOptimization.cs
index 0bec08b..a50653d 100644
--- a/optimizerDuck/Domain/Optimizations/Models/BaseOptimization.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/BaseOptimization.cs
@@ -16,9 +16,9 @@ using OptimizationState = optimizerDuck.Domain.UI.OptimizationState;
namespace optimizerDuck.Domain.Optimizations.Models;
/// <summary>
-/// Base class for all optimizations. Subclasses implement <see cref="ApplyAsync"/> and are
-/// decorated with <see cref="OptimizationAttribute"/> to provide metadata. The category
-/// (<see cref="OwnerType"/>) is assigned automatically during reflection-based discovery.
+/// Base class for all optimizations. Subclasses implement <see cref="ApplyAsync" /> and are
+/// decorated with <see cref="OptimizationAttribute" /> to provide metadata. The category
+/// (<see cref="OwnerType" />) is assigned automatically during reflection-based discovery.
/// </summary>
public abstract partial class BaseOptimization : LocalizedObject, IOptimization
{
@@ -44,7 +44,9 @@ public abstract partial class BaseOptimization : LocalizedObject, IOptimization
/// </summary>
public Type? OwnerType { get; internal set; }
- /// <exception cref="InvalidOperationException">Thrown when <see cref="OwnerType"/> has not been assigned.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// Thrown when <see cref="OwnerType" /> has not been assigned.
+ /// </exception>
public string OwnerKey =>
OwnerType?.Name
?? throw new InvalidOperationException($"{GetType().Name} has no owner assigned");
@@ -53,10 +55,11 @@ public abstract partial class BaseOptimization : LocalizedObject, IOptimization
#region Identification
- /// <summary>Gets the unique identifier for this optimization, parsed from the <see cref="OptimizationAttribute.Id"/>.</summary>
+ /// <summary>
+ /// Gets the unique identifier declared in <see cref="OptimizationAttribute.Id" />.
+ /// </summary>
public Guid Id => Guid.Parse(Meta.Id);
- /// <summary>Gets the risk level associated with this optimization.</summary>
public OptimizationRisk Risk => Meta.Risk;
/// <summary>Gets the unique key used for localization and identification.</summary>
@@ -66,7 +69,9 @@ public abstract partial class BaseOptimization : LocalizedObject, IOptimization
#region Presentation
- /// <summary>Gets the visual representation (icon and localized text) of the risk level.</summary>
+ /// <summary>
+ /// Gets the visual representation (icon and localized text) of the risk level.
+ /// </summary>
public RiskVisual RiskVisual =>
Risk switch
{
@@ -92,12 +97,12 @@ public abstract partial class BaseOptimization : LocalizedObject, IOptimization
},
};
- /// <summary>Gets the collection of tag displays for the UI, derived from <see cref="OptimizationTags"/>.</summary>
+ /// <summary>Gets the tag displays derived from <see cref="OptimizationTags" />.</summary>
public IEnumerable<OptimizationTagDisplay> TagDisplays => Meta.Tags.ToDisplays();
private OptimizationState _state = new();
- /// <summary>Gets or sets the current applied state and timing information for this optimization.</summary>
+ /// <summary>Gets or sets the applied state and timing for this optimization.</summary>
public OptimizationState State
{
get => _state;
@@ -145,10 +150,10 @@ public abstract partial class BaseOptimization : LocalizedObject, IOptimization
/// <summary>Gets the localized short description of what this optimization does.</summary>
public string ShortDescription => Loc.Instance[$"{Prefix}.ShortDescription"];
- /// <summary>English name for log (always English).</summary>
+ /// <summary>Gets the English name written to the log.</summary>
public string LogName => Loc.Invariant[$"Optimizer.{OwnerKey}.{OptimizationKey}.Name"];
- /// <summary>English short description for log (always English).</summary>
+ /// <summary>Gets the English short description written to the log.</summary>
public string LogShortDescription =>
Loc.Invariant[$"Optimizer.{OwnerKey}.{OptimizationKey}.ShortDescription"];
@@ -157,8 +162,9 @@ public abstract partial class BaseOptimization : LocalizedObject, IOptimization
#region Condition
/// <summary>
- /// Gets the compatibility condition type declared in the <see cref="OptimizationAttribute"/>
- /// (implementing <see cref="ICondition"/>), or <c>null</c> when always available.
+ /// Gets the compatibility condition type declared in the
+ /// <see cref="OptimizationAttribute" /> (implementing <see cref="ICondition" />), or
+ /// <see langword="null" /> when always available.
/// </summary>
public Type? ConditionType => Meta.Condition;
diff --git a/optimizerDuck/Domain/Optimizations/Models/Bloatware/AppXPackage.cs b/optimizerDuck/Domain/Optimizations/Models/Bloatware/AppXPackage.cs
index 26439b2..814c31a 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Bloatware/AppXPackage.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Bloatware/AppXPackage.cs
@@ -20,55 +20,28 @@ public enum AppRisk
/// Represents an AppX package (UWP app) that can be removed.
/// </summary>
/// <remarks>
-/// Derives from <see cref="LocalizedObject" /> so the computed <see cref="RiskVisual" />
-/// binding re-resolves when the UI language changes at runtime.
+/// Deriving from <see cref="LocalizedObject" /> makes <see cref="RiskVisual" /> re-resolve
+/// when the UI language changes at runtime.
/// </remarks>
public partial class AppXPackage : LocalizedObject
{
- /// <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
{
@@ -89,8 +62,5 @@ public partial class AppXPackage : LocalizedObject
},
};
- /// <summary>
- /// Indicates whether the risk should be visible in the UI.
- /// </summary>
public bool ShouldVisibleRisk => Risk != AppRisk.Unknown;
}
diff --git a/optimizerDuck/Domain/Optimizations/Models/Cleanup/CleanupItem.cs b/optimizerDuck/Domain/Optimizations/Models/Cleanup/CleanupItem.cs
index bb1f78f..0b97883 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Cleanup/CleanupItem.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Cleanup/CleanupItem.cs
@@ -9,83 +9,48 @@ namespace optimizerDuck.Domain.Optimizations.Models.Cleanup;
/// Represents a disk cleanup item (e.g., temp files, Windows Update cache).
public partial class CleanupItem : LocalizedObject
{
- /// <summary>
- /// The number of files in this cleanup item.
- /// </summary>
[ObservableProperty]
private long _fileCount;
- /// <summary>
- /// Indicates whether cleanup is in progress.
- /// </summary>
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ShowActions))]
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]
[NotifyPropertyChangedFor(nameof(ShowActions))]
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]
[NotifyPropertyChangedFor(nameof(ShowActions))]
private long _sizeBytes;
- /// <summary>
- /// Unique identifier for this cleanup item.
- /// </summary>
public required string Id { get; init; }
/// <summary>
- /// Display name of the cleanup item. Returns the localized string for the
- /// current culture by looking up the resource key set at construction time.
+ /// Gets the display name resolved from <see cref="NameKey" /> for the current culture.
/// </summary>
public string Name => Loc.Instance[NameKey];
/// <summary>
- /// Description of what this cleanup item contains. Returns the localized string
- /// for the current culture by looking up the resource key set at construction time.
+ /// Gets the description resolved from <see cref="DescriptionKey" /> for the
+ /// current culture.
/// </summary>
public string Description => Loc.Instance[DescriptionKey];
- /// <summary>
- /// Resource key used to localize <see cref="Name" />. Set at construction time so
- /// that the localized value can be re-resolved whenever the UI language changes.
- /// </summary>
+ /// <summary>Resource key that localizes <see cref="Name" />.</summary>
public string NameKey { get; init; } = string.Empty;
- /// <summary>
- /// Resource key used to localize <see cref="Description" />. Set at construction
- /// time so that the localized value can be re-resolved whenever the UI language
- /// changes.
- /// </summary>
+ /// <summary>Resource key that localizes <see cref="Description" />.</summary>
public string DescriptionKey { get; init; } = string.Empty;
- /// <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>
@@ -93,19 +58,10 @@ public partial class CleanupItem : LocalizedObject
/// </summary>
public bool IsCommand { get; init; }
- /// <summary>
- /// Whether the folder exists and can be opened.
- /// </summary>
public bool CanOpenFolder => !IsCommand && System.IO.Directory.Exists(Path);
- /// <summary>
- /// Whether to show the action controls (SplitButton) instead of progress rings.
- /// </summary>
public bool ShowActions => SizeBytes > 0 && !IsScanning && !IsCleaning;
- /// <summary>
- /// Gets the human-readable size string (e.g., "1.5 GB").
- /// </summary>
public string FormattedSize => FormatBytes(SizeBytes);
partial void OnSizeBytesChanged(long value)
@@ -113,9 +69,6 @@ public partial class CleanupItem : LocalizedObject
OnPropertyChanged(nameof(FormattedSize));
}
- /// <summary>
- /// Formats bytes into a human-readable string.
- /// </summary>
public static string FormatBytes(long bytes)
{
return bytes switch
diff --git a/optimizerDuck/Domain/Optimizations/Models/OptimizationContext.cs b/optimizerDuck/Domain/Optimizations/Models/OptimizationContext.cs
index 0e2b876..1050c71 100644
--- a/optimizerDuck/Domain/Optimizations/Models/OptimizationContext.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/OptimizationContext.cs
@@ -13,9 +13,6 @@ namespace optimizerDuck.Domain.Optimizations.Models;
/// </summary>
public class OptimizationContext : OpCall
{
- /// <summary>
- /// Gets a snapshot of the current system hardware and software information.
- /// </summary>
public required SystemInfo Snapshot { get; init; }
/// <summary>
diff --git a/optimizerDuck/Domain/Optimizations/Models/OptimizationResult.cs b/optimizerDuck/Domain/Optimizations/Models/OptimizationResult.cs
index 2114ac7..e7efc5c 100644
--- a/optimizerDuck/Domain/Optimizations/Models/OptimizationResult.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/OptimizationResult.cs
@@ -3,30 +3,14 @@ using optimizerDuck.Domain.UI;
namespace optimizerDuck.Domain.Optimizations.Models;
-/// <summary>
-/// Represents the result of an optimization apply operation.
-/// Includes the overall status, a human-readable message, and details
-/// about any steps that failed.
-/// </summary>
public record OptimizationResult
{
- /// <summary>
- /// Gets the status of the operation (Success, PartialSuccess, or Failed).
- /// </summary>
+ /// <summary>Overall outcome: Success, PartialSuccess, or Failed.</summary>
public OptimizationSuccessResult Status { get; init; }
- /// <summary>
- /// Gets a human-readable message describing the result.
- /// </summary>
public string Message { get; init; } = string.Empty;
- /// <summary>
- /// Gets the exception that occurred, if any, during the apply operation.
- /// </summary>
public Exception? Exception { get; init; }
- /// <summary>
- /// Gets the list of steps that failed during the operation.
- /// </summary>
public List<Change> FailedSteps { get; init; } = [];
}
diff --git a/optimizerDuck/Domain/Optimizations/Models/Power/PowerPlanModels.cs b/optimizerDuck/Domain/Optimizations/Models/Power/PowerPlanModels.cs
index c02ce62..bb0d3b0 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Power/PowerPlanModels.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Power/PowerPlanModels.cs
@@ -28,7 +28,7 @@ public sealed record PowerSettingGroup
public string? Description { get; init; }
}
-/// <summary>Which mains/battery value a call targets. No magic 0/1 at call sites.</summary>
+/// <summary>Which mains/battery value a call targets.</summary>
public enum PowerSource
{
Ac,
@@ -36,10 +36,9 @@ public enum PowerSource
}
/// <summary>
-/// How much Windows tells us about a setting's shape. <c>Unknown</c> means
-/// Windows exposed no usable metadata: values stay raw numbers, nothing is
-/// invented. There is deliberately no per-setting enum type: most settings
-/// are plain DWORD indexes whose friendly names live elsewhere or nowhere.
+/// How much Windows tells us about a setting's shape. <see cref="Unknown" /> means
+/// Windows exposed no usable metadata, so values stay raw numbers and nothing is
+/// invented.
/// </summary>
public enum PowerValueKind
{
diff --git a/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskModel.cs b/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskModel.cs
index 799a5ca..685dc79 100644
--- a/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskModel.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskModel.cs
@@ -10,28 +10,21 @@ namespace optimizerDuck.Domain.Optimizations.Models.ScheduledTask;
/// </summary>
public partial class ScheduledTaskModel : LocalizedObject
{
- /// <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 current state of the task (e.g., "Ready", "Running", "Disabled").
+ /// The raw Windows state, e.g. "Ready", "Running" or "Disabled".
/// </summary>
[ObservableProperty]
private string _state = string.Empty;
/// <summary>
- /// The localized state label for UI display. Raw Windows states ("Ready",
- /// "Running", ...) are mapped through translations; unknown values are shown
- /// as-is. Computed so it re-resolves when the UI language changes.
+ /// The localized state label. Raw Windows states ("Ready", "Running", ...) are
+ /// mapped through translations and unknown values are shown as-is.
/// </summary>
public string StateDisplay =>
State?.ToLowerInvariant() switch
@@ -43,29 +36,14 @@ public partial class ScheduledTaskModel : LocalizedObject
_ => State ?? string.Empty,
};
- /// <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>
@@ -85,102 +63,44 @@ public partial class ScheduledTaskModel : LocalizedObject
/// </summary>
public string TriggerSummary => string.Join("; ", TriggerInfos.Select(t => t.Detail));
- /// <summary>
- /// Summary of the task's action.
- /// </summary>
public string ActionSummary { get; init; } = string.Empty;
- /// <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 the 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>Raises change notifications for the computed state properties.</summary>
public void NotifyStateChanged()
{
OnPropertyChanged(nameof(IsRunning));
diff --git a/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskTriggerInfo.cs b/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskTriggerInfo.cs
index 351854a..3dd22fe 100644
--- a/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskTriggerInfo.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/ScheduledTask/ScheduledTaskTriggerInfo.cs
@@ -4,9 +4,9 @@ using optimizerDuck.Services.Configuration;
namespace optimizerDuck.Domain.Optimizations.Models.ScheduledTask;
/// <summary>
-/// Display data for one scheduled-task trigger: a localized label plus a narrated
-/// detail with the trigger's own data. Falls back to raw library text only when no
-/// localization fits; appends the repetition schedule when present.
+/// Display data for one scheduled-task trigger: a localized label plus a detail
+/// built from the trigger's own data. Falls back to raw library text only when no
+/// localization fits, and appends the repetition schedule when present.
/// </summary>
public sealed record ScheduledTaskTriggerInfo(
string LabelKey,
diff --git a/optimizerDuck/Domain/Optimizations/Models/Services/RegistryItem.cs b/optimizerDuck/Domain/Optimizations/Models/Services/RegistryItem.cs
index b98d811..a69f2ef 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Services/RegistryItem.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Services/RegistryItem.cs
@@ -13,7 +13,7 @@ public record struct RegistryItem
public readonly RegistryValueKind Kind;
/// <summary>
- /// The registry value name, or <c>null</c> to target the key itself.
+ /// The registry value name, or <see langword="null" /> to target the key itself.
/// </summary>
public readonly string? Name;
@@ -23,7 +23,7 @@ public record struct RegistryItem
public readonly string Path;
/// <summary>
- /// The registry value data, or <c>null</c> if not applicable.
+ /// The registry value data, or <see langword="null" /> if not applicable.
/// </summary>
public readonly object? Value;
@@ -57,7 +57,7 @@ public record struct RegistryItem
}
/// <summary>
- /// Initializes a new <see cref="RegistryItem" /> for a named value without data (used for deletion or reading).
+ /// Initializes a new <see cref="RegistryItem" /> for a named value with no data.
/// </summary>
/// <param name="path">The registry key path.</param>
/// <param name="name">The value name to target.</param>
@@ -70,8 +70,7 @@ public record struct RegistryItem
}
/// <summary>
- /// Initializes a new <see cref="RegistryItem" /> for a key path without a specific value (used for key-level
- /// operations).
+ /// Initializes a new <see cref="RegistryItem" /> for a key path with no value.
/// </summary>
/// <param name="path">The registry key path.</param>
public RegistryItem(string path)
diff --git a/optimizerDuck/Domain/Optimizations/Models/Services/RegistryValues.cs b/optimizerDuck/Domain/Optimizations/Models/Services/RegistryValues.cs
index cdff586..554e6b6 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Services/RegistryValues.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Services/RegistryValues.cs
@@ -3,9 +3,7 @@ using Microsoft.Win32;
namespace optimizerDuck.Domain.Optimizations.Models.Services;
/// <summary>
-/// Shared registry value equality. Single source of truth replacing the
-/// three private <c>ValuesEqual</c> copies (legacy provider, revert step,
-/// Windows capability).
+/// Compares registry values using the semantics of their <see cref="RegistryValueKind" />.
/// </summary>
public static class RegistryValues
{
diff --git a/optimizerDuck/Domain/Optimizations/Models/Services/ServiceItem.cs b/optimizerDuck/Domain/Optimizations/Models/Services/ServiceItem.cs
index 58a6301..44bbf0b 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Services/ServiceItem.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Services/ServiceItem.cs
@@ -7,11 +7,6 @@ namespace optimizerDuck.Domain.Optimizations.Models.Services;
/// </summary>
public readonly record struct ServiceItem
{
- /// <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)
{
@@ -24,8 +19,5 @@ public readonly record struct ServiceItem
/// </summary>
public required string Name { get; init; }
- /// <summary>
- /// The desired startup type for the service.
- /// </summary>
public required ServiceStartupType StartupType { get; init; }
}
diff --git a/optimizerDuck/Domain/Optimizations/Models/Services/ShellPolicy.cs b/optimizerDuck/Domain/Optimizations/Models/Services/ShellPolicy.cs
index 8736c76..ad4b078 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Services/ShellPolicy.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Services/ShellPolicy.cs
@@ -7,13 +7,13 @@ namespace optimizerDuck.Domain.Optimizations.Models.Services;
/// <summary>Defines success criteria and error reporting for shell command execution.</summary>
public sealed class ShellPolicy
{
- /// <summary>Default policy: exit code 0 means success; error text is taken from stderr or the exit code.</summary>
+ /// <summary>
+ /// Default policy: exit code 0 is success; error text comes from stderr or the exit code.
+ /// </summary>
public static readonly ShellPolicy Default = new();
- /// <summary>Gets or sets a function that determines whether a shell result indicates success.</summary>
public Func<ShellResult, bool> IsSuccess { get; init; } = r => r.ExitCode == 0;
- /// <summary>Gets or sets a function that produces an error message from a failed shell result.</summary>
public Func<ShellResult, string?> ErrorFactory { get; init; } =
r =>
r.ExitCode == -1 ? Loc.Instance["Service.Shell.Error.TimedOut"]
@@ -21,10 +21,13 @@ public sealed class ShellPolicy
? Loc.Instance["Service.Shell.Error.ExitCode", r.ExitCode]
: r.Stderr;
- /// <summary>Creates a policy with a custom success function and optional error factory.</summary>
- /// <param name="isSuccess">A function that determines whether a result is successful.</param>
- /// <param name="errorFactory">An optional function that produces an error message from a failed result. Defaults to the default error factory.</param>
- /// <returns>A new <see cref="ShellPolicy"/> instance.</returns>
+ /// <summary>
+ /// Creates a policy with a custom success function and optional error factory.
+ /// </summary>
+ /// <param name="isSuccess">Determines whether a result is successful.</param>
+ /// <param name="errorFactory">
+ /// Produces an error message from a failed result; null uses the default factory.
+ /// </param>
public static ShellPolicy From(
Func<ShellResult, bool> isSuccess,
Func<ShellResult, string?>? errorFactory = null
@@ -39,15 +42,15 @@ public sealed class ShellPolicy
/// <summary>Creates a policy that treats specific exit codes as success.</summary>
/// <param name="okExitCodes">The exit codes considered successful.</param>
- /// <returns>A new <see cref="ShellPolicy"/> instance.</returns>
public static ShellPolicy SuccessExitCodes(params int[] okExitCodes)
{
return From(r => okExitCodes.Contains(r.ExitCode));
}
- /// <summary>Creates a policy that treats exit codes from 0 to <paramref name="maxOk"/> as success.</summary>
+ /// <summary>
+ /// Creates a policy that treats exit codes from 0 to <paramref name="maxOk" /> as success.
+ /// </summary>
/// <param name="maxOk">The maximum exit code considered successful (inclusive).</param>
- /// <returns>A new <see cref="ShellPolicy"/> instance.</returns>
public static ShellPolicy SuccessExitCodeRange(int maxOk)
{
return From(r => r.ExitCode >= 0 && r.ExitCode <= maxOk);
diff --git a/optimizerDuck/Domain/Optimizations/Models/Services/ShellResult.cs b/optimizerDuck/Domain/Optimizations/Models/Services/ShellResult.cs
index 9b81354..5355393 100644
--- a/optimizerDuck/Domain/Optimizations/Models/Services/ShellResult.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/Services/ShellResult.cs
@@ -1,23 +1,11 @@
namespace optimizerDuck.Domain.Optimizations.Models.Services;
-/// <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>
@@ -26,8 +14,5 @@ public record ShellResult
/// </summary>
public required int ExitCode { get; init; }
- /// <summary>
- /// The total wall-clock duration of the command execution.
- /// </summary>
public required TimeSpan Duration { get; init; }
}
diff --git a/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupApp.cs b/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupApp.cs
index e7009af..fe8abbf 100644
--- a/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupApp.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupApp.cs
@@ -34,23 +34,14 @@ public enum StartupAppLocation
/// </summary>
public partial class StartupApp : LocalizedObject
{
- /// <summary>
- /// The command that runs the application.
- /// </summary>
[ObservableProperty]
private string _command = string.Empty;
private string? _filePath;
- /// <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;
@@ -60,30 +51,15 @@ public partial class StartupApp : LocalizedObject
[ObservableProperty]
private string _originalValueNameOrFileName = string.Empty;
- /// <summary>
- /// The publisher or company name.
- /// </summary>
[ObservableProperty]
private string _publisher = string.Empty;
- /// <summary>
- /// The display name of the startup application.
- /// </summary>
public required string Name { get; init; }
- /// <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 actual file path of the executable.
- /// </summary>
public string? FilePath
{
get => _filePath;
@@ -94,14 +70,8 @@ public partial class StartupApp : LocalizedObject
}
}
- /// <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 =>
LocationDisplayKeys.TryGetValue(Location, out var key) ? Loc.Instance[key] : PathOrKey;
diff --git a/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupTask.cs b/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupTask.cs
index fbc0d16..4eea592 100644
--- a/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupTask.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/StartupManager/StartupTask.cs
@@ -11,31 +11,16 @@ namespace optimizerDuck.Domain.Optimizations.Models.StartupManager;
/// </summary>
public partial class StartupTask : LocalizedObject
{
- /// <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>
@@ -48,19 +33,10 @@ public partial class StartupTask : LocalizedObject
/// </summary>
public IReadOnlyList<string> TriggerTypes => TriggerInfos.Select(t => t.Label).ToList();
- /// <summary>
- /// Localized summary of when the task triggers.
- /// </summary>
public string TriggerSummary => string.Join("; ", TriggerInfos.Select(t => t.Detail));
- /// <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);
diff --git a/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs b/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs
index 4e04ed7..f7857a8 100644
--- a/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs
+++ b/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs
@@ -17,17 +17,19 @@ namespace optimizerDuck.Domain.Revert.Steps;
public class RegistryRevertStep : IRevertStep
{
/// <summary>
- /// Gets the action to perform (e.g., restore previous value, delete value, restore key tree).
+ /// Gets the action to perform (e.g., restore previous value, delete value,
+ /// restore key tree).
/// </summary>
public RevertAction Action { get; init; }
/// <summary>
- /// Gets the registry key path (e.g., <c>HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer</c>).
+ /// Gets the registry key path, for example
+ /// <c>HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer</c>.
/// </summary>
public string Path { get; init; } = string.Empty;
/// <summary>
- /// Gets the registry value name, or <see langword="null"/> for the default value.
+ /// Gets the registry value name, or <see langword="null" /> for the default value.
/// </summary>
public string? Name { get; init; }
@@ -43,7 +45,8 @@ public class RegistryRevertStep : IRevertStep
public IReadOnlyList<RegistryRevertStep>? SubSteps { get; init; }
/// <summary>
- /// Gets the original registry value to restore, or <see langword="null"/> if the value did not exist.
+ /// Gets the original registry value to restore, or <see langword="null" /> if
+ /// the value did not exist.
/// </summary>
public object? Value { get; init; }
@@ -114,7 +117,6 @@ public class RegistryRevertStep : IRevertStep
// Read-back verify for the local value actions.
VerifyRestore(opCall);
- // Cleanup empty subkeys if they were created during apply
if (CreatedSubKeys?.Count > 0)
RegistryService.CleanupEmptyKeys(CreatedSubKeys, opCall.Logger);
@@ -132,7 +134,6 @@ public class RegistryRevertStep : IRevertStep
[nameof(Kind)] = Kind.ToString(),
};
- // Save created subkeys list
if (CreatedSubKeys?.Count > 0)
obj[nameof(CreatedSubKeys)] = new JArray(CreatedSubKeys);
@@ -144,7 +145,8 @@ public class RegistryRevertStep : IRevertStep
obj[nameof(SubSteps)] = subArray;
}
- // Serialize Value based on Kind to ensure deterministic JSON and avoid JValue rendering issues
+ // Serialize Value based on Kind to ensure deterministic JSON and avoid
+ // JValue rendering issues
if (Value == null)
{
obj[nameof(Value)] = null;
@@ -222,7 +224,6 @@ public class RegistryRevertStep : IRevertStep
break;
}
- // Load created subkeys list
List<string>? createdSubKeys = null;
if (data[nameof(CreatedSubKeys)] is JArray subKeysArray)
createdSubKeys = subKeysArray.ToObject<List<string>>();
@@ -363,6 +364,9 @@ public enum RevertAction
/// <summary>The key existed before; recreate it during revert (limited to root).</summary>
RestoreKey,
- /// <summary>The key tree existed before; recreate the entire tree including values sequentially.</summary>
+ /// <summary>
+ /// The key tree existed before; recreate the entire tree including values
+ /// sequentially.
+ /// </summary>
RestoreKeyTree,
}
diff --git a/optimizerDuck/Domain/Revert/Steps/ScheduledTaskRevertStep.cs b/optimizerDuck/Domain/Revert/Steps/ScheduledTaskRevertStep.cs
index 861708f..dcea3d6 100644
--- a/optimizerDuck/Domain/Revert/Steps/ScheduledTaskRevertStep.cs
+++ b/optimizerDuck/Domain/Revert/Steps/ScheduledTaskRevertStep.cs
@@ -10,7 +10,8 @@ using optimizerDuck.Services.System.Primitives;
namespace optimizerDuck.Domain.Revert.Steps;
/// <summary>
-/// Represents a revert step that restores a scheduled task to its original enabled/disabled state.
+/// Represents a revert step that restores a scheduled task to its original
+/// enabled/disabled state.
/// </summary>
public class ScheduledTaskRevertStep : IRevertStep
{
@@ -20,7 +21,8 @@ public class ScheduledTaskRevertStep : IRevertStep
public string FullPath { get; set; } = string.Empty;
/// <summary>
- /// Gets or sets a value that indicates whether the task was originally enabled before the optimization.
+ /// Gets or sets a value that indicates whether the task was originally enabled
+ /// before the optimization.
/// </summary>
public bool OriginalEnabled { get; set; }
diff --git a/optimizerDuck/Domain/Revert/Steps/ShellRevertStep.cs b/optimizerDuck/Domain/Revert/Steps/ShellRevertStep.cs
index dadd479..177f5d5 100644
--- a/optimizerDuck/Domain/Revert/Steps/ShellRevertStep.cs
+++ b/optimizerDuck/Domain/Revert/Steps/ShellRevertStep.cs
@@ -15,7 +15,8 @@ namespace optimizerDuck.Domain.Revert.Steps;
public class ShellRevertStep : IRevertStep
{
/// <summary>
- /// Gets or sets the type of shell to use for execution (<see cref="ShellType.CMD"/> or <see cref="ShellType.PowerShell"/>).
+ /// Gets or sets the type of shell to use for execution
+ /// (<see cref="ShellType.CMD" /> or <see cref="ShellType.PowerShell" />).
/// </summary>
public ShellType ShellType { get; set; }
diff --git a/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs b/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs
index 65bbf5e..3c4b724 100644
--- a/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs
+++ b/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs
@@ -13,7 +13,8 @@ namespace optimizerDuck.Domain.Revert.Steps;
public class UsbPowerRevertStep : IRevertStep
{
/// <summary>
- /// Represents a single USB device instance and its original <c>MSPower_DeviceEnable</c> state.
+ /// Represents a single USB device instance and its original
+ /// <c>MSPower_DeviceEnable</c> state.
/// </summary>
public sealed class DeviceState
{
diff --git a/optimizerDuck/Domain/UI/ChangeDetailPresentation.cs b/optimizerDuck/Domain/UI/ChangeDetailPresentation.cs
index 9ac1a22..f38d9b2 100644
--- a/optimizerDuck/Domain/UI/ChangeDetailPresentation.cs
+++ b/optimizerDuck/Domain/UI/ChangeDetailPresentation.cs
@@ -11,9 +11,12 @@ namespace optimizerDuck.Domain.UI;
/// resource key of its own, so a word such as a startup type follows the UI language.
/// </summary>
/// <param name="LabelKey">The resource key of the chip's label.</param>
-/// <param name="Icon">The chip's icon.</param>
-/// <param name="Value">The chip's value, or the key of its text when <paramref name="ValueIsKey" />.</param>
-/// <param name="ValueIsKey">Whether the value names a resource key rather than being shown as it is.</param>
+/// <param name="Value">
+/// The chip's value, or the key of its text when <paramref name="ValueIsKey" />.
+/// </param>
+/// <param name="ValueIsKey">
+/// Whether the value is a resource key to resolve, not the text itself.
+/// </param>
public sealed record DetailChip(
string LabelKey,
SymbolRegular Icon,
@@ -51,7 +54,7 @@ public static class ChangeDetailPresentation
/// build does not know produces an empty row, which leaves the row on the log description.
/// </summary>
/// <param name="detail">The facts of the step, or null when it recorded none.</param>
- /// <param name="kind">What the step did, which decides whether it is phrased as an action.</param>
+ /// <param name="kind">What the step did, which decides its phrasing.</param>
/// <param name="operation">Which run the row belongs to, an apply or a revert.</param>
public static ChangeDetailRow For(
ChangeDetail? detail,
@@ -396,8 +399,8 @@ public static class ChangeDetailPresentation
};
/// <summary>
- /// The sentence for a reason a provider recorded. A reason the UI does not know yet is left
- /// out rather than shown as a code.
+ /// The sentence for a reason a provider recorded. A reason the UI does not know yet is
+ /// left out, not shown as a code.
/// </summary>
private static string? ReasonKey(string? reason) =>
reason switch
@@ -411,7 +414,9 @@ public static class ChangeDetailPresentation
_ => null,
};
- /// <summary>The two values a step moved between, which a revert reads the other way round.</summary>
+ /// <summary>
+ /// The two values a step moved between, which a revert reads the other way round.
+ /// </summary>
private sealed record DetailPair(
string? Previous,
bool PreviousIsKey,
diff --git a/optimizerDuck/Domain/UI/ChangeKindPresentation.cs b/optimizerDuck/Domain/UI/ChangeKindPresentation.cs
index bd2efcd..93b9660 100644
--- a/optimizerDuck/Domain/UI/ChangeKindPresentation.cs
+++ b/optimizerDuck/Domain/UI/ChangeKindPresentation.cs
@@ -5,8 +5,7 @@ namespace optimizerDuck.Domain.UI;
/// <summary>
/// How the record presents one kind of recorded step: an icon and the resource key of its
-/// label. The key is carried rather than the resolved text so the mapping stays testable
-/// and the label follows the UI language.
+/// label. The key travels rather than the resolved text, so the label follows the UI language.
/// </summary>
public sealed record ChangeKindDisplay
{
diff --git a/optimizerDuck/Domain/UI/LanguageOption.cs b/optimizerDuck/Domain/UI/LanguageOption.cs
index 5304040..5cfb0e9 100644
--- a/optimizerDuck/Domain/UI/LanguageOption.cs
+++ b/optimizerDuck/Domain/UI/LanguageOption.cs
@@ -12,8 +12,5 @@ public record LanguageOption
/// </summary>
public required string DisplayName { get; init; }
- /// <summary>
- /// The <see cref="CultureInfo" /> associated with this language option.
- /// </summary>
public required CultureInfo Culture { get; init; }
}
diff --git a/optimizerDuck/Domain/UI/OptimizationCategoryOrder.cs b/optimizerDuck/Domain/UI/OptimizationCategoryOrder.cs
index 534c38c..e42c237 100644
--- a/optimizerDuck/Domain/UI/OptimizationCategoryOrder.cs
+++ b/optimizerDuck/Domain/UI/OptimizationCategoryOrder.cs
@@ -5,24 +5,17 @@
/// </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,
- /// <summary>AI-related optimizations.</summary>
AI,
}
diff --git a/optimizerDuck/Domain/UI/OptimizationState.cs b/optimizerDuck/Domain/UI/OptimizationState.cs
index 2674c74..66e5f7b 100644
--- a/optimizerDuck/Domain/UI/OptimizationState.cs
+++ b/optimizerDuck/Domain/UI/OptimizationState.cs
@@ -7,7 +7,6 @@ namespace optimizerDuck.Domain.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
{
@@ -41,15 +40,9 @@ public partial class OptimizationState : ObservableObject
}
}
- /// <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;
@@ -60,20 +53,18 @@ public partial class OptimizationState : ObservableObject
[ObservableProperty]
private bool isAlreadyOptimal;
- /// <summary>
- /// A human-readable relative time string (e.g., "5 minutes ago").
- /// </summary>
+ /// <summary>The relative time text, for example "5 minutes ago".</summary>
[ObservableProperty]
private string? relativeTime = string.Empty;
/// <summary>
/// One line describing what the last recorded apply did, read from the record when there
- /// is one. Empty when nothing is known, so the badge keeps its plain form.
+ /// is one. Empty when nothing is known.
/// </summary>
[ObservableProperty]
private string appliedSummary = string.Empty;
- /// <summary>The tooltip of the applied badge: what the run did, and what a click does.</summary>
+ /// <summary>The applied badge tooltip: what the run did, and what a click does.</summary>
public string AppliedTooltip =>
string.IsNullOrEmpty(AppliedSummary)
? Loc.Instance["Optimizer.UI.State.Applied.Tooltip.NoSummary"]
@@ -81,9 +72,6 @@ public partial class OptimizationState : ObservableObject
partial void OnAppliedSummaryChanged(string value) => OnPropertyChanged(nameof(AppliedTooltip));
- /// <summary>
- /// The risk level of the optimization.
- /// </summary>
[ObservableProperty]
private OptimizationRisk risk;
@@ -101,11 +89,9 @@ public partial class OptimizationState : ObservableObject
if (_globalTimer != null)
return;
- // Defer timer creation to avoid accessing dispatcher during static init.
- // NOTE: This type lives in Domain/UI but owns a DispatcherTimer (WPF). Ideally
- // move to optimizerDuck.UI or Common. We route
- // through the dispatcher indirection rather than hard-referencing UI assemblies
- // from pure domain logic.
+ // Defer timer creation to avoid accessing the dispatcher during static init. The
+ // dispatcher is reached through Application.Current so Domain keeps no hard reference
+ // to the UI.
var dispatcher = System.Windows.Application.Current?.Dispatcher;
if (dispatcher is null)
return; // headless/tests, no timer needed
@@ -136,7 +122,6 @@ public partial class OptimizationState : ObservableObject
else
_instances.RemoveAt(i);
- // Stop the timer when no live instances remain
if (_instances.Count == 0 && _globalTimer != null)
{
_globalTimer.Stop();
diff --git a/optimizerDuck/Domain/UI/OptimizationSuccessResult.cs b/optimizerDuck/Domain/UI/OptimizationSuccessResult.cs
index a2a33f1..cf152fb 100644
--- a/optimizerDuck/Domain/UI/OptimizationSuccessResult.cs
+++ b/optimizerDuck/Domain/UI/OptimizationSuccessResult.cs
@@ -5,13 +5,11 @@
/// </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,
/// <summary>
diff --git a/optimizerDuck/Domain/UI/OptimizationTags.cs b/optimizerDuck/Domain/UI/OptimizationTags.cs
index 546aa57..05a864a 100644
--- a/optimizerDuck/Domain/UI/OptimizationTags.cs
+++ b/optimizerDuck/Domain/UI/OptimizationTags.cs
@@ -48,21 +48,20 @@ public enum OptimizationTags
}
/// <summary>
-/// Provides extension methods to convert <see cref="OptimizationTags" /> to display-friendly representations.
+/// Converts <see cref="OptimizationTags" /> to display-friendly representations.
/// </summary>
public static class OptimizationTagsToDisplay
{
extension(OptimizationTags tags)
{
/// <summary>
- /// Explains what a tag means, so a chip on a card never has to be guessed at. One
- /// key per tag value, named after the flag.
+ /// Explains what a tag means. One key per tag value, named after the flag.
/// </summary>
public string ToExplanation() => Loc.Instance[$"Optimizer.UI.Tags.{tags}.Tooltip"];
/// <summary>
- /// Converts the tag flags into a sequence of display-friendly representations.
+ /// Converts the tag flags into their display representations.
/// </summary>
- /// <returns>An enumerable of <see cref="OptimizationTagDisplay" /> for each set flag.</returns>
+ /// <returns>One <see cref="OptimizationTagDisplay" /> for each set flag.</returns>
public IEnumerable<OptimizationTagDisplay> ToDisplays()
{
foreach (var flag in Enum.GetValues<OptimizationTags>())
@@ -75,9 +74,6 @@ public static class OptimizationTagsToDisplay
}
}
- /// <summary>
- /// Converts a single tag flag to its display representation.
- /// </summary>
private OptimizationTagDisplay ToDisplay()
{
return tags switch
@@ -198,20 +194,14 @@ public static class OptimizationTagsToDisplay
}
/// <summary>
-/// Represents the UI display data for an optimization tag.
+/// UI display data for an optimization tag.
/// </summary>
public readonly record struct OptimizationTagDisplay
{
/// <summary>What this tag means, shown as the tooltip of the chip.</summary>
public string Description { get; init; }
- /// <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; }
}
diff --git a/optimizerDuck/Domain/UI/ProcessingProgress.cs b/optimizerDuck/Domain/UI/ProcessingProgress.cs
index 077408e..d3238d7 100644
--- a/optimizerDuck/Domain/UI/ProcessingProgress.cs
+++ b/optimizerDuck/Domain/UI/ProcessingProgress.cs
@@ -1,27 +1,16 @@
namespace optimizerDuck.Domain.UI;
/// <summary>
-/// Represents the progress of a long-running operation (e.g., optimization, cleanup).
+/// Progress of a long-running operation.
/// </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>
+ /// <summary>Indeterminate progress has no known total.</summary>
public bool IsIndeterminate { get; init; } = false;
- /// <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; }
}
diff --git a/optimizerDuck/Domain/UI/RiskVisual.cs b/optimizerDuck/Domain/UI/RiskVisual.cs
index cda378c..96f4517 100644
--- a/optimizerDuck/Domain/UI/RiskVisual.cs
+++ b/optimizerDuck/Domain/UI/RiskVisual.cs
@@ -3,17 +3,11 @@
namespace optimizerDuck.Domain.UI;
/// <summary>
-/// Represents the visual display data for a risk level in the UI.
+/// 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; }
}
diff --git a/optimizerDuck/Domain/UI/SupportedLanguages.cs b/optimizerDuck/Domain/UI/SupportedLanguages.cs
index 5b58ead..64b3658 100644
--- a/optimizerDuck/Domain/UI/SupportedLanguages.cs
+++ b/optimizerDuck/Domain/UI/SupportedLanguages.cs
@@ -2,7 +2,7 @@ using System.Globalization;
namespace optimizerDuck.Domain.UI;
-/// <summary>Single source of truth for supported UI languages. Easy to extend.</summary>
+/// <summary>Single source of truth for supported UI languages.</summary>
public static class SupportedLanguages
{
public static IReadOnlyList<LanguageOption> All { get; } =
diff --git a/optimizerDuck/Services/Conditions/ConditionEvaluator.cs b/optimizerDuck/Services/Conditions/ConditionEvaluator.cs
index 2472f46..2bce9e0 100644
--- a/optimizerDuck/Services/Conditions/ConditionEvaluator.cs
+++ b/optimizerDuck/Services/Conditions/ConditionEvaluator.cs
@@ -24,7 +24,9 @@ public static class ConditionEvaluator
/// Evaluates the condition declared by <paramref name="conditionType"/>, or returns
/// <see cref="ConditionResult.Available"/> when there is no condition. Never throws.
/// </summary>
- /// <param name="conditionType">The condition type declared in an attribute, or <c>null</c>.</param>
+ /// <param name="conditionType">
+ /// The condition type declared in an attribute, or <see langword="null" />.
+ /// </param>
/// <param name="snapshot">The current system snapshot to evaluate against.</param>
/// <param name="logger">Logger for evaluation diagnostics.</param>
public static ConditionResult Evaluate(Type? conditionType, SystemInfo snapshot, ILogger logger)
@@ -32,9 +34,7 @@ public static class ConditionEvaluator
if (conditionType is null)
return ConditionResult.Available;
- // Fail open: an unpopulated snapshot means hardware detection has not finished (or
- // failed), so never hide an item based on incomplete data. Callers re-evaluate once
- // a real snapshot is available.
+ // Fail open: an unpopulated snapshot means hardware detection has not finished or failed.
if (snapshot.IsUnknown)
return ConditionResult.Available;
diff --git a/optimizerDuck/Services/Configuration/ConfigManager.cs b/optimizerDuck/Services/Configuration/ConfigManager.cs
index 4d939d3..edc8159 100644
--- a/optimizerDuck/Services/Configuration/ConfigManager.cs
+++ b/optimizerDuck/Services/Configuration/ConfigManager.cs
@@ -14,19 +14,10 @@ namespace optimizerDuck.Services.Configuration;
/// </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>
@@ -38,7 +29,8 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
}
/// <summary>
- /// Ensures all default configuration keys exist. Adds missing keys with default values and logs them.
+ /// Ensures all default configuration keys exist. Adds missing keys with default values and
+ /// logs them.
/// </summary>
public async Task EnsureDefaultsAsync()
{
@@ -68,7 +60,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
if (value == null)
continue;
- // Check both flat key and nested object format
var existsFlat = GetTokenIgnoreCase(_cache, key) != null;
var existsNested = CheckNestedExists(
_cache,
@@ -78,7 +69,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
if (!existsFlat && !existsNested)
{
- // Add as nested object format (proper structure)
EnsureNestedValue(
_cache,
prop.Name,
@@ -94,7 +84,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
if (addedKeys.Count > 0)
{
- // Clean up any duplicate flat keys that may have been added previously
CleanupDuplicateKeys(_cache);
await SaveConfigAsync().ConfigureAwait(false);
logger.LogInformation(
@@ -110,9 +99,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
}
}
- /// <summary>
- /// Checks if a nested key exists in the config.
- /// </summary>
private static bool CheckNestedExists(JObject root, string section, string key)
{
var sectionToken = GetTokenIgnoreCase(root, section);
@@ -121,9 +107,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
return GetTokenIgnoreCase(sectionObj, key) != null;
}
- /// <summary>
- /// Ensures a nested value exists in the config.
- /// </summary>
private static void EnsureNestedValue(JObject root, string section, string key, string value)
{
var sectionObj = GetOrCreateObjectIgnoreCase(root, section);
@@ -153,7 +136,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
var sectionToken = GetTokenIgnoreCase(root, prop.Name);
if (sectionToken is JObject)
{
- // If nested format exists, mark flat key for removal
if (GetTokenIgnoreCase(root, flatKey) != null)
flatKeysToRemove.Add(flatKey);
}
@@ -170,7 +152,8 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
/// </summary>
/// <typeparam name="T">The type of the property being updated.</typeparam>
/// <param name="property">
- /// An expression that identifies the configuration property to update, such as <c>x => x.App.Language</c>.
+ /// An expression that identifies the configuration property to update, such as
+ /// <c>x => x.App.Language</c>.
/// </param>
/// <param name="value">The value to assign to the specified configuration property.</param>
/// <example>
@@ -377,7 +360,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
/// <param name="value">The value to set.</param>
private static void SetValueIgnoreCase(JObject current, string key, string value)
{
- // Remove all case-insensitive matches
var toRemove = current
.Properties()
.Where(p => string.Equals(p.Name, key, StringComparison.OrdinalIgnoreCase))
@@ -387,7 +369,6 @@ public class ConfigManager(IConfiguration configuration, ILogger<ConfigManager>
foreach (var name in toRemove)
current.Remove(name);
- // Add with correct casing
current[key] = value;
}
diff --git a/optimizerDuck/Services/Configuration/LanguageManager.cs b/optimizerDuck/Services/Configuration/LanguageManager.cs
index 40e4d99..a7c06d3 100644
--- a/optimizerDuck/Services/Configuration/LanguageManager.cs
+++ b/optimizerDuck/Services/Configuration/LanguageManager.cs
@@ -51,7 +51,9 @@ public class Loc : INotifyPropertyChanged
/// <summary>Occurs when language changes. ViewModels refresh cached text here.</summary>
public event EventHandler<LanguageChangedEventArgs>? LanguageChanged;
- /// <summary>Subscribe without keeping object alive. Use for ViewModels that can be closed.</summary>
+ /// <summary>
+ /// Subscribe without keeping object alive. Use for ViewModels that can be closed.
+ /// </summary>
public static void AddWeakLanguageChangedHandler(
EventHandler<LanguageChangedEventArgs> handler
) =>
diff --git a/optimizerDuck/Services/Customize/CustomizationExecutor.cs b/optimizerDuck/Services/Customize/CustomizationExecutor.cs
index ad9ee15..20cdcae 100644
--- a/optimizerDuck/Services/Customize/CustomizationExecutor.cs
+++ b/optimizerDuck/Services/Customize/CustomizationExecutor.cs
@@ -3,8 +3,8 @@ using Microsoft.Extensions.Logging;
namespace optimizerDuck.Services.Customize;
/// <summary>
-/// Lightweight executor for customization actions.
-/// Provides debouncing and sequential serialization without leaking threading locks into ViewModels.
+/// Serializes customization writes behind a debounce, so a burst of setting changes
+/// applies only the last value.
/// </summary>
public sealed class CustomizationExecutor(ILogger<CustomizationExecutor>? logger = null)
: IDisposable
@@ -15,9 +15,7 @@ public sealed class CustomizationExecutor(ILogger<CustomizationExecutor>? logger
private bool _isApplying;
private CancellationTokenSource? _debounceCts;
- /// <summary>
- /// Gets whether a customization action is currently being applied.
- /// </summary>
+ /// <summary>Gets a value that indicates whether a queued value is being applied.</summary>
public bool IsApplying
{
get
@@ -28,7 +26,7 @@ public sealed class CustomizationExecutor(ILogger<CustomizationExecutor>? logger
}
/// <summary>
- /// Applies the value after a debounce period, serializing calls sequentially.
+ /// Applies a value once the debounce elapses, one queued apply at a time.
/// </summary>
public async Task ApplyWithDebounceAsync(
object? value,
@@ -95,7 +93,7 @@ public sealed class CustomizationExecutor(ILogger<CustomizationExecutor>? logger
}
catch (Exception ex)
{
- // Fire-and-forget, so log here instead of throwing.
+ // Fire-and-forget: a throw would go unobserved, so failures are logged.
logger?.LogError(ex, "Customization apply failed.");
}
}
diff --git a/optimizerDuck/Services/Customize/CustomizeRegistry.cs b/optimizerDuck/Services/Customize/CustomizeRegistry.cs
index 909f7ad..2db6762 100644
--- a/optimizerDuck/Services/Customize/CustomizeRegistry.cs
+++ b/optimizerDuck/Services/Customize/CustomizeRegistry.cs
@@ -19,10 +19,13 @@ public class CustomizeRegistry
_logger = logger;
}
- /// <summary>Gets the registered customize categories. Each category contains its child customize settings. Populated after calling <see cref="RegisterCategories"/> or via preloading.</summary>
+ /// <summary>Gets the customize categories discovered by preloading.</summary>
public ICustomizeCategory[] Categories { get; private set; } = [];
- /// <summary>Gets a value that indicates whether the customize categories have been fully discovered.</summary>
+ /// <summary>
+ /// Gets a value that indicates whether the customize categories have been fully
+ /// discovered.
+ /// </summary>
public bool IsPreloaded { get; private set; }
/// <summary>
@@ -48,7 +51,7 @@ public class CustomizeRegistry
private Task? _preloadTask;
- /// <summary>Discovers all customize setting categories and their child settings via reflection, then populates <see cref="Categories"/>.</summary>
+ /// <summary>Discovers the customize categories and their settings by reflection.</summary>
public async Task PreloadCategoriesAsync()
{
// Run reflection work on background thread to avoid blocking startup
@@ -87,8 +90,8 @@ public class CustomizeRegistry
IsPreloaded = true;
}
- /// <summary>Builds the navigation items for the UI from the registered categories.</summary>
- /// <returns>A sequence of <see cref="NavigationViewItem"/> instances mapped to customize pages.</returns>
+ /// <summary>Builds a navigation item for each registered category.</summary>
+ /// <returns>The items, each mapped to its customize page.</returns>
public IEnumerable<NavigationViewItem> GetNavigationItems()
{
if (Categories.Length == 0 && !IsPreloaded)
diff --git a/optimizerDuck/Services/History/ChangeRecordStore.cs b/optimizerDuck/Services/History/ChangeRecordStore.cs
index ff1c028..d9ea112 100644
--- a/optimizerDuck/Services/History/ChangeRecordStore.cs
+++ b/optimizerDuck/Services/History/ChangeRecordStore.cs
@@ -8,19 +8,18 @@ using optimizerDuck.Domain.Execution;
namespace optimizerDuck.Services.History;
/// <summary>
-/// Stores what one apply did, one file per item, so the details view can show it again after
-/// the app restarts. It writes outside the revert data on purpose: a revert deletes its own
-/// file, and what a run did should stay readable afterwards.
+/// Stores what one apply did, one file per item, so the record survives a restart. It is
+/// kept outside the revert data: a revert deletes its own file, while what a run did stays
+/// readable afterwards.
/// </summary>
public static class ChangeRecordStore
{
- /// <summary>The file this item's most recent apply is recorded in.</summary>
+ /// <summary>Returns the file this item's most recent apply is recorded in.</summary>
public static string PathFor(Guid id) => Path.Combine(Shared.HistoryDirectory, $"{id}.json");
/// <summary>
/// Writes a record, replacing the item's previous one. Best effort: a record that cannot
- /// be written is logged and never changes the outcome of the apply, so callers do not
- /// have to guard the call.
+ /// be written is logged and never changes the outcome of the apply.
/// </summary>
public static void TryWrite(ChangeRecord record, ILogger? logger = null)
{
@@ -29,9 +28,8 @@ public static class ChangeRecordStore
var path = PathFor(record.Id);
Directory.CreateDirectory(Shared.HistoryDirectory);
- // Atomic like the revert files: a torn report would be worse than no report. No file
- // lock is needed because an item is applied through one command at a time, and the
- // replace makes a partial write impossible.
+ // Atomic like the revert files: a torn report is worse than no report. No lock is
+ // needed because an item is applied through one command at a time.
var tempPath = path + ".tmp";
File.WriteAllText(
tempPath,
diff --git a/optimizerDuck/Services/Optimization/OptimizationRegistry.cs b/optimizerDuck/Services/Optimization/OptimizationRegistry.cs
index 918219a..fbdc6c5 100644
--- a/optimizerDuck/Services/Optimization/OptimizationRegistry.cs
+++ b/optimizerDuck/Services/Optimization/OptimizationRegistry.cs
@@ -12,10 +12,13 @@ public class OptimizationRegistry(ILoggerFactory loggerFactory)
{
private readonly ILogger _logger = loggerFactory.CreateLogger<OptimizationRegistry>();
- /// <summary>Gets or sets the discovered optimization categories after preloading. Each category contains its child optimizations.</summary>
+ /// <summary>Gets or sets the optimization categories discovered by preloading.</summary>
public IOptimizationCategory[] OptimizationCategories { get; set; } = [];
- /// <summary>Gets a value that indicates whether the optimizations have been fully discovered and their applied states loaded.</summary>
+ /// <summary>
+ /// Gets a value that indicates whether the optimizations have been fully discovered and
+ /// their applied states loaded.
+ /// </summary>
public bool IsPreloaded { get; private set; }
/// <summary>
@@ -41,7 +44,10 @@ public class OptimizationRegistry(ILoggerFactory loggerFactory)
private Task? _preloadTask;
- /// <summary>Discovers all optimization categories and their optimizations via reflection, then loads the applied state from revert data on disk.</summary>
+ /// <summary>
+ /// Discovers the optimization categories by reflection and loads the applied state of
+ /// their optimizations from revert data on disk.
+ /// </summary>
public async Task PreloadOptimizationsAsync()
{
var seenIds = new HashSet<Guid>();
@@ -84,7 +90,9 @@ public class OptimizationRegistry(ILoggerFactory loggerFactory)
IsPreloaded = true;
}
- /// <summary>Gets a category by its runtime type. Categories must have been preloaded first.</summary>
+ /// <summary>
+ /// Gets the category with the given runtime type, which must have been preloaded.
+ /// </summary>
/// <param name="type">The runtime type of the category to retrieve.</param>
/// <returns>The matching <see cref="IOptimizationCategory"/> instance.</returns>
public IOptimizationCategory GetCategory(Type type)
diff --git a/optimizerDuck/Services/Optimization/OptimizationService.cs b/optimizerDuck/Services/Optimization/OptimizationService.cs
index b5a0f87..3d2b5fa 100644
--- a/optimizerDuck/Services/Optimization/OptimizationService.cs
+++ b/optimizerDuck/Services/Optimization/OptimizationService.cs
@@ -23,6 +23,10 @@ using Wpf.Ui.Controls;
namespace optimizerDuck.Services.Optimization;
+/// <summary>
+/// Runs the apply and revert paths of an optimization: it builds each item's execution
+/// context, drives the provider, persists revert data and writes the record of the run.
+/// </summary>
public class OptimizationService(
RevertManager revertManager,
ILoggerFactory loggerFactory,
@@ -58,7 +62,10 @@ public class OptimizationService(
};
}
- /// <summary>Gets or sets a value that indicates whether a system restore point was created before applying optimizations.</summary>
+ /// <summary>
+ /// Gets or sets a value that indicates whether a system restore point was created before
+ /// applying optimizations.
+ /// </summary>
public bool WasRequestedRestorePoint { get; set; } = false;
/// <summary>
@@ -67,12 +74,16 @@ public class OptimizationService(
/// reports protection as disabled.
/// <para>
/// This is a UI orchestration method: it must be awaited from the UI thread and it keeps
- /// that thread for itself, because it shows, updates and hides a <see cref="ContentDialog"/>.
- /// Only the native calls are pushed onto the thread pool, so a slow service call never
+ /// that thread for itself, because it shows, updates and hides a
+ /// <see cref="ContentDialog" />. Only the native calls are pushed onto the thread pool, so
+ /// a slow service call never
/// blocks the interface.
/// </para>
/// </summary>
- /// <returns>A <see cref="RestorePointResult"/> indicating success, failure, or frequency-limit reached.</returns>
+ /// <returns>
+ /// A <see cref="RestorePointResult"/> indicating success, failure, or frequency-limit
+ /// reached.
+ /// </returns>
public async Task<RestorePointResult> CreateRestorePointAsync()
{
var dialogViewModel = new ProcessingViewModel();
@@ -183,11 +194,17 @@ public class OptimizationService(
}
}
- /// <summary>Applies the specified optimization, captures revert steps into an execution scope, and persists revert data on any successful steps.</summary>
+ /// <summary>
+ /// Applies the specified optimization, captures revert steps into an execution scope, and
+ /// persists revert data on any successful steps.
+ /// </summary>
/// <param name="optimization">The optimization to apply.</param>
/// <param name="progress">An <see cref="IProgress{T}"/> to report application progress.</param>
/// <param name="cancellationToken">A token to cancel the operation.</param>
- /// <returns>An <see cref="OptimizationResult"/> describing the outcome, including partial-success or failure details.</returns>
+ /// <returns>
+ /// An <see cref="OptimizationResult"/> describing the outcome, including partial-success or
+ /// failure details.
+ /// </returns>
public async Task<OptimizationResult> ApplyAsync(
IOptimization optimization,
IProgress<ProcessingProgress> progress,
@@ -384,9 +401,14 @@ public class OptimizationService(
};
}
- /// <summary>Reverts the specified optimization using stored revert data from a previous apply operation.</summary>
+ /// <summary>
+ /// Reverts the specified optimization using stored revert data from a previous apply
+ /// operation.
+ /// </summary>
/// <param name="optimization">The optimization to revert.</param>
- /// <param name="progress">An optional <see cref="IProgress{T}"/> to report revert progress.</param>
+ /// <param name="progress">
+ /// An optional <see cref="IProgress{T}"/> to report revert progress.
+ /// </param>
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>A <see cref="RevertResult"/> describing the outcome.</returns>
public async Task<RevertResult> RevertAsync(
@@ -429,7 +451,8 @@ public class OptimizationService(
}
/// <summary>
- /// Marks the item's record as reverted, keeping the steps that were undone with their before
+ /// Marks the item's record as reverted, keeping the steps that were undone with their
+ /// before
/// and after swapped. The revert file that described them is gone once the revert worked,
/// so the record is the only place left to see what changed back. The steps that wrote
/// nothing are dropped: nothing was recorded for them, so nothing was undone on their
@@ -447,7 +470,10 @@ public class OptimizationService(
ChangeRecordStore.TryWrite(record.Reverted(DateTime.Now), logger);
}
- /// <summary>Updates the applied state of the specified optimizations by scanning revert data files on disk. An optimization is considered applied when its revert JSON file exists.</summary>
+ /// <summary>
+ /// Updates the applied state of the specified optimizations by scanning revert data
+ /// files on disk. An optimization is considered applied when its revert JSON file exists.
+ /// </summary>
/// <param name="optimizations">The optimizations whose state to update.</param>
public static async Task UpdateOptimizationStateAsync(params IOptimization[] optimizations)
{
@@ -480,18 +506,29 @@ public class OptimizationService(
}
}
- /// <summary>Updates the applied state of the specified optimizations by scanning revert data files on disk.</summary>
+ /// <summary>
+ /// Updates the applied state of the specified optimizations by scanning revert data
+ /// files on disk.
+ /// </summary>
/// <param name="optimizations">The optimizations whose state to update.</param>
public static Task UpdateOptimizationStateAsync(IEnumerable<IOptimization> optimizations)
{
return UpdateOptimizationStateAsync(optimizations.ToArray());
}
- /// <summary>Retries the specified failed operation steps, optionally in reverse order. Automatically persists recovered revert steps if a <see cref="RevertManager"/> is provided.</summary>
+ /// <summary>
+ /// Retries the specified failed operation steps, optionally in reverse order. Automatically
+ /// persists recovered revert steps if a <see cref="RevertManager"/> is provided.
+ /// </summary>
/// <param name="failedSteps">The steps that failed and should be retried.</param>
- /// <param name="reverseOrder">If <see langword="true"/>, retries steps in descending index order (useful for revert operations).</param>
+ /// <param name="reverseOrder">
+ /// If <see langword="true"/>, retries steps in descending index order (useful for revert
+ /// operations).
+ /// </param>
/// <param name="logger">The logger for retry diagnostics.</param>
- /// <param name="revertManager">Optional revert manager to persist recovered revert steps.</param>
+ /// <param name="revertManager">
+ /// Optional revert manager to persist recovered revert steps.
+ /// </param>
/// <param name="optimizationId">The optimization ID for revert step persistence.</param>
/// <param name="optimizationKey">The optimization key for revert step persistence.</param>
/// <param name="progress">An optional progress reporter.</param>
@@ -520,15 +557,26 @@ public class OptimizationService(
).FailedSteps;
}
- /// <summary>Retries failed operation steps and returns both recovered and remaining failed steps for detailed inspection. Automatically persists recovered revert steps if a <see cref="RevertManager"/> is provided.</summary>
+ /// <summary>
+ /// Retries failed operation steps and returns both recovered and remaining failed steps for
+ /// detailed inspection. Automatically persists recovered revert steps if a
+ /// <see cref="RevertManager"/> is provided.
+ /// </summary>
/// <param name="failedSteps">The steps that failed and should be retried.</param>
- /// <param name="reverseOrder">If <see langword="true"/>, retries steps in descending index order.</param>
+ /// <param name="reverseOrder">
+ /// If <see langword="true"/>, retries steps in descending index order.
+ /// </param>
/// <param name="logger">The logger for retry diagnostics.</param>
- /// <param name="revertManager">Optional revert manager to persist recovered revert steps.</param>
+ /// <param name="revertManager">
+ /// Optional revert manager to persist recovered revert steps.
+ /// </param>
/// <param name="optimizationId">The optimization ID for revert step persistence.</param>
/// <param name="optimizationKey">The optimization key for revert step persistence.</param>
/// <param name="progress">An optional progress reporter.</param>
- /// <returns>A <see cref="RetryFailedStepsResult"/> containing both recovered and remaining failed steps.</returns>
+ /// <returns>
+ /// A <see cref="RetryFailedStepsResult"/> containing both recovered and remaining failed
+ /// steps.
+ /// </returns>
public static async Task<RetryFailedStepsResult> RetryFailedStepsWithResultsAsync(
IReadOnlyList<Change> failedSteps,
bool reverseOrder,
@@ -736,7 +784,8 @@ public class OptimizationService(
changes,
optimization.Id,
optimization.OptimizationKey,
- // CancellationToken.None: persist partial work even when the operation was cancelled.
+ // CancellationToken.None: persist partial work even when the operation was
+ // cancelled.
CancellationToken.None
)
.ConfigureAwait(false);
@@ -756,7 +805,10 @@ public class OptimizationService(
}
}
- /// <summary>Deletes all files in the downloads directory. Silently skips files that cannot be deleted.</summary>
+ /// <summary>
+ /// Deletes all files in the downloads directory. Silently skips files that cannot be
+ /// deleted.
+ /// </summary>
/// <param name="logger">The logger for deletion errors.</param>
public static void ClearDownloads(ILogger logger)
{
@@ -777,17 +829,21 @@ public class OptimizationService(
/// <summary>Represents the result of a system restore point creation attempt.</summary>
public enum RestorePointResult
{
- /// <summary>The restore point was created successfully.</summary>
Success,
- /// <summary>The restore point creation failed.</summary>
Failed,
- /// <summary>The creation was skipped because a restore point was already created within the frequency limit (24 hours).</summary>
+ /// <summary>
+ /// The creation was skipped because a restore point was already created within the
+ /// frequency limit (24 hours).
+ /// </summary>
FrequencyLimitReached,
}
-/// <summary>Represents the result of retrying failed operation steps, separating recovered steps from those that remain failed.</summary>
+/// <summary>
+/// Represents the result of retrying failed operation steps, separating recovered steps from
+/// those that remain failed.
+/// </summary>
/// <param name="FailedSteps">The steps that remain failed after retry.</param>
/// <param name="RecoveredSteps">The steps that succeeded on retry.</param>
public sealed record RetryFailedStepsResult(List<Change> FailedSteps, List<Change> RecoveredSteps);
diff --git a/optimizerDuck/Services/Optimization/OptimizationValidation.cs b/optimizerDuck/Services/Optimization/OptimizationValidation.cs
index 86da532..2361367 100644
--- a/optimizerDuck/Services/Optimization/OptimizationValidation.cs
+++ b/optimizerDuck/Services/Optimization/OptimizationValidation.cs
@@ -3,9 +3,9 @@ using optimizerDuck.Domain.Optimizations.Models;
namespace optimizerDuck.Services.Optimization;
/// <summary>
-/// Fail-fast discovery validation: malformed or duplicated optimization
-/// IDs surface at startup with the offending class named, instead of a
-/// <c>FormatException</c> on first UI render.
+/// Fail-fast discovery validation: a malformed or duplicated optimization ID surfaces at
+/// startup with the offending class named, rather than as a
+/// <see cref="FormatException" /> when the ID is first read.
/// </summary>
public static class OptimizationValidation
{
diff --git a/optimizerDuck/Services/Revert/RevertManager.cs b/optimizerDuck/Services/Revert/RevertManager.cs
index cdd104f..464bb47 100644
--- a/optimizerDuck/Services/Revert/RevertManager.cs
+++ b/optimizerDuck/Services/Revert/RevertManager.cs
@@ -19,6 +19,10 @@ using optimizerDuck.Services.System.Primitives;
namespace optimizerDuck.Services.Revert;
+/// <summary>
+/// Atomic, file-based persistence of revert data: one JSON file per applied item, written
+/// through a temporary file and a replace so a crash cannot leave a half-written file.
+/// </summary>
public class RevertManager(
ILogger<RevertManager> _logger,
ShellService _shell,
@@ -32,7 +36,9 @@ public class RevertManager(
private static readonly Lazy<Dictionary<string, Func<JObject, IRevertStep>>> _stepRegistry =
new(BuildStepRegistry);
- /// <summary>Per item file locks. Visible to the test assembly so a stuck lock can be simulated.</summary>
+ /// <summary>
+ /// Per item file locks. Visible to the test assembly so a stuck lock can be simulated.
+ /// </summary>
internal static readonly ConcurrentDictionary<Guid, SemaphoreSlim> FileLocks = new();
private readonly TimeSpan _fileLockTimeout = TimeSpan.FromSeconds(FileLockTimeoutSeconds);
@@ -51,8 +57,10 @@ public class RevertManager(
}
/// <summary>
- /// Persists revert steps from a <see cref="ChangeSet"/>. Appends every successful change as a new entry with a fresh index. No payload-based dedupe: two executions of the same command are two real executions; dropping either loses revert coverage.
- /// Reverting extra entries is harmless (LIFO ends at the original backup).
+ /// Persists revert steps from a <see cref="ChangeSet"/>. Appends every successful change
+ /// as a new entry with a fresh index. No payload-based dedupe: two executions of the same
+ /// command are two real executions, so dropping either loses revert coverage. Indexes are
+ /// never reused, and reverting an extra entry is harmless because revert runs LIFO.
/// </summary>
public async Task SaveRevertDataAsync(
ChangeSet changes,
@@ -64,10 +72,7 @@ public class RevertManager(
// Compensation is persisted whenever it exists, whether the step reported success or a
// partial failure: a step that was refused after it had already changed something still
// needs its previous state recorded.
- var incoming = changes
- .Changes.Where(c => c.Revert != null)
- .OrderBy(c => c.Index)
- .ToList();
+ var incoming = changes.Changes.Where(c => c.Revert != null).OrderBy(c => c.Index).ToList();
// A step that modified the system must carry the data needed to undo it. The filter
// above drops entries without compensation, so a Change arriving here without one is a
@@ -104,12 +109,6 @@ public class RevertManager(
data.OptimizationName = name;
- // Every incoming change appends its own entry with a fresh index.
- // No payload-based dedupe: two executions of the same command are
- // two real executions, and dropping either loses revert coverage.
- // Reverting extra entries is harmless (LIFO ends at the original
- // backup); dropping one silently is not. Indexes are never reused
- // so on-disk entries stay stable across saves.
var nextIndex =
data.Steps.Where(s => s != null).Select(s => s!.Index).DefaultIfEmpty(0).Max() + 1;
var merged = data.Steps.Where(s => s != null).Cast<RevertStepData>().ToList();
@@ -488,7 +487,9 @@ public class RevertManager(
return null;
}
- /// <summary>The newest parked copy of an unreadable revert file, or null when there is none.</summary>
+ /// <summary>
+ /// The newest parked copy of an unreadable revert file, or null when there is none.
+ /// </summary>
private static string? FindParkedFile(string path)
{
var directory = Path.GetDirectoryName(path);
@@ -502,7 +503,9 @@ public class RevertManager(
return matches.OrderBy(static m => m, StringComparer.Ordinal).Last();
}
- /// <summary>Moves an unreadable revert file aside, keeping its bytes, and returns the new path.</summary>
+ /// <summary>
+ /// Moves an unreadable revert file aside, keeping its bytes, and returns the new path.
+ /// </summary>
private string ParkUnreadable(string path)
{
var stamp = _time.GetUtcNow().ToString("yyyyMMddHHmmss");
@@ -540,7 +543,8 @@ public class RevertManager(
if (data == null)
return null;
- // Validate the file is within the expected revert directory (path traversal guard)
+ // Validate the file is within the expected revert directory
+ // (path traversal guard)
var resolvedPath = Path.GetFullPath(path);
var revertDir = Path.GetFullPath(Shared.RevertDirectory);
if (!revertDir.EndsWith(Path.DirectorySeparatorChar))
@@ -582,7 +586,6 @@ public class RevertManager(
);
return null;
}
- // Validate schema version
if (data.SchemaVersion != SchemaVersion)
{
LogCorruptRevertFile(
diff --git a/optimizerDuck/Services/System/CrossPageEventBus.cs b/optimizerDuck/Services/System/CrossPageEventBus.cs
index 9768501..87ecda5 100644
--- a/optimizerDuck/Services/System/CrossPageEventBus.cs
+++ b/optimizerDuck/Services/System/CrossPageEventBus.cs
@@ -4,12 +4,14 @@ namespace optimizerDuck.Services.System;
/// Provides a thread-safe event bus for signaling cross-page data changes.
/// </summary>
/// <remarks>
-/// When one ViewModel modifies data that another page displays, call <see cref="NotifyDataChanged{T}"/>
-/// with the appropriate event type. The target ViewModel checks for pending changes in
+/// When one ViewModel modifies data that another page displays, call
+/// <see cref="NotifyDataChanged{T}"/> with the appropriate event type.
+/// The target ViewModel checks for pending changes in
/// <c>OnNavigatedToAsync</c> via <see cref="HasPendingRefresh{T}"/> to reload stale data.
/// <para>
/// Internally uses a <see cref="HashSet{T}"/> of <see cref="Type"/> keys behind a lock.
-/// All type safety is enforced at compile time via the <see cref="ICrossPageEvent"/> constraint.
+/// All type safety is enforced at compile time via the
+/// <see cref="ICrossPageEvent"/> constraint.
/// </para>
/// </remarks>
public static class CrossPageEventBus
@@ -38,10 +40,10 @@ public static class CrossPageEventBus
/// </summary>
/// <typeparam name="T">An event type that implements <see cref="ICrossPageEvent"/>.</typeparam>
/// <returns>
- /// <see langword="true"/> if a refresh was pending; otherwise <see langword="false"/>.
+ /// <see langword="true" /> if a refresh was pending; otherwise <see langword="false" />.
/// </returns>
/// <remarks>
- /// This method removes the notification so subsequent calls return <see langword="false"/>
+ /// This method removes the notification so subsequent calls return <see langword="false" />
/// until a new <see cref="NotifyDataChanged{T}"/> call arrives.
/// </remarks>
public static bool HasPendingRefresh<T>()
diff --git a/optimizerDuck/Services/System/CrossPageEvents.cs b/optimizerDuck/Services/System/CrossPageEvents.cs
index 2522a73..d2fd5c9 100644
--- a/optimizerDuck/Services/System/CrossPageEvents.cs
+++ b/optimizerDuck/Services/System/CrossPageEvents.cs
@@ -15,8 +15,10 @@ public interface ICrossPageEvent;
/// Signals that scheduled tasks were added, removed, or toggled.
/// </summary>
/// <remarks>
-/// Fired by <see cref="optimizerDuck.UI.ViewModels.Pages.ScheduledTasksViewModel"/> after toggling a task.
-/// Consumed by <see cref="optimizerDuck.UI.ViewModels.Pages.StartupManagerViewModel"/> to reload its Tasks section.
+/// Fired by <see cref="optimizerDuck.UI.ViewModels.Pages.ScheduledTasksViewModel"/>
+/// after toggling a task.
+/// Consumed by <see cref="optimizerDuck.UI.ViewModels.Pages.StartupManagerViewModel"/>
+/// to reload its Tasks section.
/// </remarks>
public readonly record struct ScheduledTasksChanged : ICrossPageEvent;
@@ -24,8 +26,10 @@ public readonly record struct ScheduledTasksChanged : ICrossPageEvent;
/// Signals that startup apps or tasks were added, removed, or toggled.
/// </summary>
/// <remarks>
-/// Fired by <see cref="optimizerDuck.UI.ViewModels.Pages.StartupManagerViewModel"/> after toggling a startup task.
-/// Consumed by <see cref="optimizerDuck.UI.ViewModels.Pages.ScheduledTasksViewModel"/> to reload all tasks.
+/// Fired by <see cref="optimizerDuck.UI.ViewModels.Pages.StartupManagerViewModel"/>
+/// after toggling a startup task.
+/// Consumed by <see cref="optimizerDuck.UI.ViewModels.Pages.ScheduledTasksViewModel"/>
+/// to reload all tasks.
/// </remarks>
public readonly record struct StartupAppsChanged : ICrossPageEvent;
@@ -33,8 +37,11 @@ public readonly record struct StartupAppsChanged : ICrossPageEvent;
/// Signals that bloatware packages were removed or may have changed externally.
/// </summary>
/// <remarks>
-/// Fired by <see cref="optimizerDuck.UI.ViewModels.Pages.BloatwareViewModel"/> after removing packages.
-/// Consumed by <see cref="optimizerDuck.UI.ViewModels.Pages.StartupManagerViewModel"/> (reloads tasks)
-/// and <see cref="optimizerDuck.UI.ViewModels.Pages.BloatwareViewModel"/> (full refresh on re-navigation).
+/// Fired by <see cref="optimizerDuck.UI.ViewModels.Pages.BloatwareViewModel"/>
+/// after removing packages.
+/// Consumed by <see cref="optimizerDuck.UI.ViewModels.Pages.StartupManagerViewModel"/>
+/// (reloads tasks) and
+/// <see cref="optimizerDuck.UI.ViewModels.Pages.BloatwareViewModel"/> (full refresh on
+/// re-navigation).
/// </remarks>
public readonly record struct BloatwareChanged : ICrossPageEvent;
diff --git a/optimizerDuck/Services/System/PowerPlanService.cs b/optimizerDuck/Services/System/PowerPlanService.cs
index 53151ec..d226234 100644
--- a/optimizerDuck/Services/System/PowerPlanService.cs
+++ b/optimizerDuck/Services/System/PowerPlanService.cs
@@ -9,22 +9,20 @@ using optimizerDuck.Services.System.Primitives;
namespace optimizerDuck.Services.System;
-/// Power scheme operations over powrprof (no child processes).
-/// Single owner of every power P/Invoke in the app.
-/// Fast Win32 calls run synchronously on the caller thread; only the
-/// file-I/O-bound import is async. Reads take ids only; mutating paths take
-/// an optional <see cref="ILogger"/> (default null), return <see cref="OpResult"/>
-/// with native diagnostics, and record nothing: revert recording lives at the
-/// optimization edge (see PowerPlanChanges), so tools reuse the same core.
-/// Import semantics: a non-empty <c>destinationId</c> pre-seeds the GUID**
-/// slot so Windows imports under it (replacing any scheme with the same
-/// GUID, same as <c>powercfg /import file guid</c>); an empty GUID passes
-/// NULL and Windows allocates one, returned to the caller.
-/// Hibernate (<c>powercfg /h</c>) is intentionally NOT here: it disables the
-/// hibernation feature and deletes hiberfil.sys, and no supported native
-/// power-scheme API covers that. It stays a documented shell exception in
-/// <c>DisableHibernateAndFastStartup</c>.
+/// <summary>
+/// Power scheme operations over powrprof, with no child processes. Single owner of every
+/// power P/Invoke in the app. Fast Win32 calls run synchronously on the caller thread; only
+/// the file-I/O-bound import is async. Reads take ids only; mutating paths take an optional
+/// <see cref="ILogger"/> (default null), return <see cref="OpResult"/> with native
+/// diagnostics, and record nothing: revert recording lives at the optimization edge (see
+/// PowerPlanChanges), so tools reuse the same core.
/// </summary>
+/// <remarks>
+/// Import semantics: a non-empty <c>destinationId</c> pre-seeds the GUID slot so Windows
+/// imports under it (replacing any scheme with the same GUID, same as
+/// <c>powercfg /import file guid</c>); an empty GUID passes NULL and Windows allocates one,
+/// returned to the caller.
+/// </remarks>
[SupportedOSPlatform("windows")]
// Virtual members are a hand-double seam for tests (no mocking libraries).
public class PowerPlanService
@@ -37,11 +35,15 @@ public class PowerPlanService
private readonly ILogger<PowerPlanService> _logger;
+ /// <summary>Initializes a new instance of the <see cref="PowerPlanService" /> class.</summary>
+ /// <param name="logger">The logger used for interop diagnostics.</param>
public PowerPlanService(ILogger<PowerPlanService> logger)
{
_logger = logger;
}
+ /// <summary>Reads the GUID of the currently active power scheme.</summary>
+ /// <returns>The active scheme id, or <see langword="null" /> when the call fails.</returns>
public virtual Guid? GetActiveSchemeId()
{
IntPtr ptr = IntPtr.Zero;
@@ -63,6 +65,10 @@ public class PowerPlanService
}
}
+ /// <summary>
+ /// Lists every power scheme on the machine, each marked whether it is active.
+ /// </summary>
+ /// <returns>The power schemes, empty when enumeration fails.</returns>
public IReadOnlyList<PowerScheme> ListSchemes()
{
var schemes = new List<PowerScheme>();
@@ -79,6 +85,9 @@ public class PowerPlanService
return schemes;
}
+ /// <summary>Reads one power scheme by id, including its name and description.</summary>
+ /// <param name="schemeId">The id of the scheme to read.</param>
+ /// <returns>The scheme, or <see langword="null" /> when no scheme has that id.</returns>
public PowerScheme? GetScheme(Guid schemeId)
{
var id = schemeId;
@@ -95,6 +104,12 @@ public class PowerPlanService
};
}
+ /// <summary>Checks whether a power scheme with the given id exists on this machine.</summary>
+ /// <param name="schemeId">The id of the scheme to test.</param>
+ /// <returns>
+ /// <see langword="true" /> when a scheme with that id exists; otherwise,
+ /// <see langword="false" />.
+ /// </returns>
public bool SchemeExists(Guid schemeId)
{
// No direct 'exists' API: a friendly-name read succeeds only for
@@ -109,6 +124,9 @@ public class PowerPlanService
}
}
+ /// <summary>Reads the friendly name of a power scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to read.</param>
+ /// <returns>The name, or <see langword="null" /> when the read fails.</returns>
public string? GetSchemeName(Guid schemeId)
{
try
@@ -122,6 +140,11 @@ public class PowerPlanService
}
}
+ /// <summary>Reads the description of a power scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to read.</param>
+ /// <returns>
+ /// The description, or <see langword="null" /> when the read fails or none is set.
+ /// </returns>
public string? GetSchemeDescription(Guid schemeId)
{
try
@@ -135,6 +158,9 @@ public class PowerPlanService
}
}
+ /// <summary>Lists the setting subgroups inside a power scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to read.</param>
+ /// <returns>The subgroups, empty when enumeration fails.</returns>
public IReadOnlyList<PowerSettingGroup> ListGroups(Guid schemeId)
{
var groups = new List<PowerSettingGroup>();
@@ -161,6 +187,10 @@ public class PowerPlanService
return groups;
}
+ /// <summary>Lists the settings inside a subgroup of a power scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to read.</param>
+ /// <param name="subgroupId">The id of the subgroup to read.</param>
+ /// <returns>The settings, empty when enumeration fails.</returns>
public IReadOnlyList<PowerSetting> ListSettings(Guid schemeId, Guid subgroupId)
{
var settings = new List<PowerSetting>();
@@ -185,6 +215,11 @@ public class PowerPlanService
return settings;
}
+ /// <summary>Reads one power setting inside a scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to read.</param>
+ /// <param name="subgroupId">The id of the subgroup to read.</param>
+ /// <param name="settingId">The id of the setting to read.</param>
+ /// <returns>The setting, or <see langword="null" /> when the read fails.</returns>
public PowerSetting? GetSetting(Guid schemeId, Guid subgroupId, Guid settingId)
{
try
@@ -204,6 +239,14 @@ public class PowerPlanService
}
}
+ /// <summary>
+ /// Reads the AC or DC value of one power setting as the raw number Windows stores.
+ /// </summary>
+ /// <param name="schemeId">The id of the scheme to read.</param>
+ /// <param name="subgroupId">The id of the subgroup to read.</param>
+ /// <param name="settingId">The id of the setting to read.</param>
+ /// <param name="source">One of the enumeration values that selects the AC or DC value.</param>
+ /// <returns>The raw value, or <see langword="null" /> when the read fails.</returns>
public uint? GetSettingValue(Guid schemeId, Guid subgroupId, Guid settingId, PowerSource source)
{
try
@@ -224,6 +267,24 @@ public class PowerPlanService
}
}
+ /// <summary>
+ /// Writes the AC and DC values of a power setting. Reads both previous values first and
+ /// refuses to write when either is unreadable, then returns them for the caller to record.
+ /// </summary>
+ /// <param name="schemeId">The id of the scheme to write.</param>
+ /// <param name="subgroupId">The id of the subgroup to write.</param>
+ /// <param name="settingId">The id of the setting to write.</param>
+ /// <param name="acValue">
+ /// The AC value to write, or <see langword="null" /> to leave it unchanged.
+ /// </param>
+ /// <param name="dcValue">
+ /// The DC value to write, or <see langword="null" /> to leave it unchanged.
+ /// </param>
+ /// <param name="logger">An optional logger for write diagnostics.</param>
+ /// <returns>
+ /// The outcome and the previous AC/DC values read before the write, both null when none
+ /// could be read.
+ /// </returns>
public virtual SettingWriteResult SetSetting(
Guid schemeId,
Guid subgroupId,
@@ -284,6 +345,16 @@ public class PowerPlanService
return new SettingWriteResult(OpResult.Success(), prevAc, prevDc);
}
+ /// <summary>
+ /// Activates a power scheme, remembering the previously active id for the caller to record.
+ /// </summary>
+ /// <param name="schemeId">The id of the scheme to activate.</param>
+ /// <param name="logger">An optional logger for activation diagnostics.</param>
+ /// <returns>
+ /// The outcome and the previously active scheme id, or <see langword="null" /> when it
+ /// could
+ /// not be read.
+ /// </returns>
public virtual ActivationResult SetActiveScheme(Guid schemeId, ILogger? logger = null)
{
var previous = GetActiveSchemeId();
@@ -338,6 +409,10 @@ public class PowerPlanService
return new ActivationResult(OpResult.Success(), previous);
}
+ /// <summary>Deletes a power scheme. Refuses to delete the active scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to delete.</param>
+ /// <param name="logger">An optional logger for deletion diagnostics.</param>
+ /// <returns>The outcome. A deleted scheme carries no revert step.</returns>
public virtual OpResult DeleteScheme(Guid schemeId, ILogger? logger = null)
{
var name = GetSchemeName(schemeId) ?? schemeId.ToString();
@@ -390,6 +465,16 @@ public class PowerPlanService
return OpResult.Success();
}
+ /// <summary>Imports a power scheme from a file, optionally under a given GUID.</summary>
+ /// <param name="filePath">The path of the file to import.</param>
+ /// <param name="destinationId">
+ /// The GUID to import under, or <see cref="Guid.Empty" /> to let Windows allocate one.
+ /// </param>
+ /// <param name="logger">An optional logger for import diagnostics.</param>
+ /// <param name="ct">The token that cancels the import.</param>
+ /// <returns>
+ /// The outcome and the imported scheme id, which is <see langword="null" /> on failure.
+ /// </returns>
public virtual async Task<SchemeRefResult> ImportSchemeAsync(
string filePath,
Guid destinationId,
@@ -511,6 +596,12 @@ public class PowerPlanService
return new InstallResult(OpResult.Success(), import.SchemeId, previous);
}
+ /// <summary>Copies an existing power scheme under a new GUID allocated by Windows.</summary>
+ /// <param name="sourceId">The id of the scheme to copy.</param>
+ /// <param name="logger">An optional logger for duplication diagnostics.</param>
+ /// <returns>
+ /// The outcome and the new scheme id, which is <see langword="null" /> on failure.
+ /// </returns>
public virtual SchemeRefResult DuplicateScheme(Guid sourceId, ILogger? logger = null)
{
IntPtr ppGuid = IntPtr.Zero;
@@ -564,6 +655,11 @@ public class PowerPlanService
}
}
+ /// <summary>Sets the friendly name of a power scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to rename.</param>
+ /// <param name="name">The new name.</param>
+ /// <param name="logger">An optional logger for write diagnostics.</param>
+ /// <returns>A result that reports success or the native failure.</returns>
public OpResult SetSchemeName(Guid schemeId, string name, ILogger? logger = null)
{
var bytes = Encoding.Unicode.GetBytes(name + '\0');
@@ -596,6 +692,11 @@ public class PowerPlanService
}
}
+ /// <summary>Sets the description of a power scheme.</summary>
+ /// <param name="schemeId">The id of the scheme to update.</param>
+ /// <param name="descriptionText">The new description.</param>
+ /// <param name="logger">An optional logger for write diagnostics.</param>
+ /// <returns>A result that reports success or the native failure.</returns>
public OpResult SetSchemeDescription(
Guid schemeId,
string descriptionText,
diff --git a/optimizerDuck/Services/System/Primitives/HibernationService.cs b/optimizerDuck/Services/System/Primitives/HibernationService.cs
index 1e63450..ea1e4c4 100644
--- a/optimizerDuck/Services/System/Primitives/HibernationService.cs
+++ b/optimizerDuck/Services/System/Primitives/HibernationService.cs
@@ -31,7 +31,9 @@ public static class HibernationService
private const uint StatusSuccess = 0;
- /// <summary>Result of a hibernation file commit/removal request, with the raw NTSTATUS.</summary>
+ /// <summary>
+ /// Result of a hibernation file commit/removal request, with the raw NTSTATUS.
+ /// </summary>
/// <param name="Succeeded">Whether the callback reported STATUS_SUCCESS.</param>
/// <param name="NativeStatus">The NTSTATUS value, so callers can log the real code.</param>
/// <param name="ExceptionText">Throw text when the interop itself failed, else null.</param>
diff --git a/optimizerDuck/Services/System/Primitives/PowerPlanChanges.cs b/optimizerDuck/Services/System/Primitives/PowerPlanChanges.cs
index 594cd16..67d253e 100644
--- a/optimizerDuck/Services/System/Primitives/PowerPlanChanges.cs
+++ b/optimizerDuck/Services/System/Primitives/PowerPlanChanges.cs
@@ -5,10 +5,8 @@ using optimizerDuck.Domain.Revert.Steps;
namespace optimizerDuck.Services.System.Primitives;
/// <summary>
-/// Optimization-edge recorder for lean <see cref="PowerPlanService"/> results:
-/// the single place turning a finished native call into a <see cref="Change"/>
-/// with revert step and retry. Categories call here, never hand-roll steps.
-/// Tools call the service directly and skip this entirely.
+/// Records the optimization edge for lean <see cref="PowerPlanService"/> results: turns a
+/// finished native call into a <see cref="Change"/> with revert step and retry.
/// </summary>
public static class PowerPlanChanges
{
@@ -88,9 +86,8 @@ public static class PowerPlanChanges
.ConfigureAwait(false);
if (!install.Result.Ok || install.InstalledId is null || install.PreviousId is null)
{
- // The import can have landed even when the activation failed, so the scheme Windows
- // reports is recorded whenever it is known: a revert then removes the plan this run
- // added instead of leaving it behind. Without an id there is nothing to point at.
+ // The import can land even when activation fails, so the installed scheme is recorded
+ // whenever Windows reports it; a revert then removes the plan this run added.
PowerPlanRevertStep? orphan = null;
string? orphanName = null;
if (install.InstalledId is not null)
@@ -167,10 +164,9 @@ public static class PowerPlanChanges
var prevAc = write.PreviousAcValue;
var prevDc = write.PreviousDcValue;
- // Both values were read before any write, and the mains value may already have been
- // written when the battery write failed, so the compensation is recorded whenever the
- // values are known, whether the step succeeded or not. Restoring a value that was never
- // written is a no-op, and keeping the entry is what lets a retry end at the true original.
+ // Both values are read before any write; the mains value may already be written when the
+ // battery write fails, so the compensation is recorded even on failure. Restoring a value
+ // that was never written is a no-op, and the entry lets a retry end at the original.
PowerSettingRevertStep? step = null;
string? previousPair = null;
if (prevAc is not null && prevDc is not null)
diff --git a/optimizerDuck/Services/System/Primitives/ProcessRunner.cs b/optimizerDuck/Services/System/Primitives/ProcessRunner.cs
index 3f30077..d2525e8 100644
--- a/optimizerDuck/Services/System/Primitives/ProcessRunner.cs
+++ b/optimizerDuck/Services/System/Primitives/ProcessRunner.cs
@@ -9,7 +9,9 @@ namespace optimizerDuck.Services.System.Primitives;
/// <summary>
/// The captured output of a single child-process execution.
/// </summary>
-/// <param name="ExitCode">The process exit code; <c>-1</c> on timeout, <c>-2</c> on exception.</param>
+/// <param name="ExitCode">
+/// The process exit code; <c>-1</c> on timeout, <c>-2</c> on exception.
+/// </param>
/// <param name="Stdout">Raw captured standard output (not CLIXML-parsed).</param>
/// <param name="Stderr">Raw captured standard error (not CLIXML-parsed).</param>
/// <param name="TimedOut">Whether the process was killed because the shell timeout elapsed.</param>
@@ -58,7 +60,9 @@ public sealed class ProcessRunner
_logger = logger;
}
- /// <summary>Starts a process, captures stdout/stderr, and enforces the live shell timeout.</summary>
+ /// <summary>
+ /// Starts a process, captures stdout/stderr, and enforces the live shell timeout.
+ /// </summary>
public async Task<ProcessResult> RunAsync(
string fileName,
string arguments,
diff --git a/optimizerDuck/Services/System/Primitives/RecycleBinService.cs b/optimizerDuck/Services/System/Primitives/RecycleBinService.cs
index 3960718..32a254f 100644
--- a/optimizerDuck/Services/System/Primitives/RecycleBinService.cs
+++ b/optimizerDuck/Services/System/Primitives/RecycleBinService.cs
@@ -20,7 +20,9 @@ public static class RecycleBinService
internal const uint ShrbNoSound = 0x00000004;
internal const uint SuppressionFlags = ShrbNoConfirmation | ShrbNoProgressUi | ShrbNoSound;
- /// <summary>Totals for one Recycle Bin scope: bytes and item count as the shell reports them.</summary>
+ /// <summary>
+ /// Totals for one Recycle Bin scope: bytes and item count as the shell reports them.
+ /// </summary>
public sealed record RecycleBinTotals(long SizeBytes, long ItemCount);
/// <summary>
diff --git a/optimizerDuck/Services/System/Primitives/RegistryService.cs b/optimizerDuck/Services/System/Primitives/RegistryService.cs
index 658ff8c..f709aac 100644
--- a/optimizerDuck/Services/System/Primitives/RegistryService.cs
+++ b/optimizerDuck/Services/System/Primitives/RegistryService.cs
@@ -10,6 +10,11 @@ using optimizerDuck.Domain.Revert.Steps;
namespace optimizerDuck.Services.System.Primitives;
+/// <summary>
+/// Registry reads and writes built on Microsoft.Win32, where every write records the previous
+/// value for revert. Stateless and static: callers pass an <see cref="OpCall" /> that receives
+/// the recorded changes.
+/// </summary>
public static class RegistryService
{
private static readonly Dictionary<string, RegistryKey> RootKeysMap = new(
@@ -187,9 +192,14 @@ public static class RegistryService
/// <summary>Determines whether the specified registry key path exists.</summary>
/// <param name="item">The registry path to check.</param>
- /// <param name="logger">Optional logger; <c>null</c> means silent.</param>
- /// <returns><see langword="true" /> if the key exists; otherwise, <see langword="false" />.</returns>
- /// <remarks>A failed query (access denied, unknown root) is reported as "does not exist". Use <see cref="TryKeyExists" /> when that distinction matters.</remarks>
+ /// <param name="logger">Optional logger; <see langword="null" /> means silent.</param>
+ /// <returns>
+ /// <see langword="true" /> if the key exists; otherwise, <see langword="false" />.
+ /// </returns>
+ /// <remarks>
+ /// A failed query (access denied, unknown root) is reported as "does not exist". Use
+ /// <see cref="TryKeyExists" /> when that distinction matters.
+ /// </remarks>
public static bool KeyExists(RegistryItem item, ILogger? logger = null)
{
return WithKey<bool>(item, key => true, logger, out _, out _, out _);
@@ -199,8 +209,12 @@ public static class RegistryService
/// Determines whether the specified registry key exists, distinguishing an absent key
/// from a failed query.
/// </summary>
- /// <param name="exists">Whether the key exists; only meaningful on <c>true</c> return.</param>
- /// <returns><c>false</c> when the query itself failed; absence must not be assumed then.</returns>
+ /// <param name="exists">
+ /// Whether the key exists; only meaningful on <see langword="true" /> return.
+ /// </param>
+ /// <returns>
+ /// <see langword="false" /> when the query itself failed; absence must not be assumed then.
+ /// </returns>
public static bool TryKeyExists(RegistryItem item, out bool exists, ILogger? logger = null)
{
exists = false;
@@ -238,8 +252,12 @@ public static class RegistryService
/// <summary>
/// Reads a raw registry value, distinguishing an absent value from a failed read.
/// </summary>
- /// <param name="value">The raw value, or <c>null</c> when absent or unreadable.</param>
- /// <returns><c>false</c> when the read itself failed; a failed read is not "absent".</returns>
+ /// <param name="value">
+ /// The raw value, or <see langword="null" /> when absent or unreadable.
+ /// </param>
+ /// <returns>
+ /// <see langword="false" /> when the read itself failed; a failed read is not "absent".
+ /// </returns>
public static bool TryReadValue(RegistryItem item, out object? value, ILogger? logger = null)
{
value = null;
@@ -288,8 +306,11 @@ public static class RegistryService
/// <summary>Reads a registry value and converts it to the specified type.</summary>
/// <typeparam name="T">The target type to convert the value to.</typeparam>
/// <param name="item">The registry path and value name to read.</param>
- /// <param name="logger">Optional logger; <c>null</c> means silent.</param>
- /// <returns>The converted value, or the default of <typeparamref name="T" /> if the value is missing or conversion fails.</returns>
+ /// <param name="logger">Optional logger; <see langword="null" /> means silent.</param>
+ /// <returns>
+ /// The converted value, or the default of <typeparamref name="T" /> if the value is missing
+ /// or conversion fails.
+ /// </returns>
public static T? Read<T>(RegistryItem item, ILogger? logger = null)
{
return WithKey(
@@ -762,7 +783,9 @@ public static class RegistryService
}
}
- /// <summary>Deletes an entire registry key tree, backing up all values and subkeys for revert.</summary>
+ /// <summary>
+ /// Deletes an entire registry key tree, backing up all values and subkeys for revert.
+ /// </summary>
/// <param name="call">The call context carrying the change collector and logger.</param>
/// <param name="item">The registry path of the key tree to delete.</param>
/// <returns>The operation result, carrying the revert step on success.</returns>
@@ -957,7 +980,9 @@ public static class RegistryService
/// <summary>Writes multiple distinct registry values, recording one change per item.</summary>
/// <param name="call">The shared call context for all items.</param>
- /// <param name="items">The registry items to write. All are attempted; the first failure is returned.</param>
+ /// <param name="items">
+ /// The registry items to write. All are attempted; the first failure is returned.
+ /// </param>
public static OpResult Write(OpCall call, params RegistryItem[] items)
{
ArgumentNullException.ThrowIfNull(call);
@@ -969,7 +994,9 @@ public static class RegistryService
/// <summary>Deletes multiple distinct registry values, recording one change per item.</summary>
/// <param name="call">The shared call context for all items.</param>
- /// <param name="items">The registry items to delete. All are attempted; the first failure is returned.</param>
+ /// <param name="items">
+ /// The registry items to delete. All are attempted; the first failure is returned.
+ /// </param>
public static OpResult DeleteValue(OpCall call, params RegistryItem[] items)
{
ArgumentNullException.ThrowIfNull(call);
@@ -980,11 +1007,8 @@ public static class RegistryService
);
}
- #region Helpers
-
private static T? ConvertRegistryValue<T>(object value)
{
- // Fast path
if (value is T t)
return t;
@@ -1024,7 +1048,6 @@ public static class RegistryService
return (T)Enum.ToObject(targetType, num!);
}
- // Numeric/string common conversions
var converted = Convert.ChangeType(value, targetType, CultureInfo.InvariantCulture);
return (T)converted!;
}
@@ -1066,7 +1089,6 @@ public static class RegistryService
);
}
- // dispose old key if we opened it
if (ownsCurrent)
current.Dispose();
@@ -1092,10 +1114,9 @@ public static class RegistryService
/// subkeys). Sorts by path depth descending so child keys are deleted before parents.
/// </remarks>
/// <param name="createdSubKeys">The list of registry key paths that were created.</param>
- /// <param name="logger">Optional logger; <c>null</c> means silent.</param>
+ /// <param name="logger">Optional logger; <see langword="null" /> means silent.</param>
public static void CleanupEmptyKeys(IEnumerable<string> createdSubKeys, ILogger? logger = null)
{
- // Sort by path length descending to delete deepest keys first
var sortedKeys = createdSubKeys
.Where(k => !string.IsNullOrWhiteSpace(k))
.Distinct(StringComparer.OrdinalIgnoreCase)
@@ -1108,17 +1129,13 @@ public static class RegistryService
if (!TryParsePath(fullPath, logger, out var root, out var subPath))
continue;
- // Check if the key still exists and is empty
using var key = root.OpenSubKey(subPath, false);
if (key == null)
- // Key already deleted, skip
continue;
- // Only delete if the key is completely empty (no values, no subkeys)
if (key is { SubKeyCount: 0, ValueCount: 0 })
{
- // Get parent path and key name
var idx = subPath.LastIndexOf('\\');
var parentPath = idx > 0 ? subPath[..idx] : string.Empty;
var keyName = idx > 0 ? subPath[(idx + 1)..] : subPath;
@@ -1137,7 +1154,6 @@ public static class RegistryService
}
else
{
- // Key is not empty, don't delete it
logger?.LogDebug(
"Skipped cleanup of registry key {Path} (has {SubKeyCount} subkeys and {ValueCount} values)",
fullPath,
@@ -1160,11 +1176,15 @@ public static class RegistryService
}
}
+ #region Helpers
+
internal const string RegistryReasonValueAbsent = "registry.valueAbsent";
internal const string RegistryReasonKeyExists = "registry.keyExists";
internal const string RegistryReasonKeyAbsent = "registry.keyAbsent";
- /// <summary>A value as it is shown to the user, never localized. Nothing to show stays null.</summary>
+ /// <summary>
+ /// A value as it is shown to the user, never localized. Nothing to show stays null.
+ /// </summary>
private static string? DescribeValue(object? value) =>
value switch
{
diff --git a/optimizerDuck/Services/System/Primitives/ScheduledTaskService.cs b/optimizerDuck/Services/System/Primitives/ScheduledTaskService.cs
index 4ad4b7d..aabf14d 100644
--- a/optimizerDuck/Services/System/Primitives/ScheduledTaskService.cs
+++ b/optimizerDuck/Services/System/Primitives/ScheduledTaskService.cs
@@ -13,6 +13,10 @@ using Task = Microsoft.Win32.TaskScheduler.Task;
namespace optimizerDuck.Services.System.Primitives;
+/// <summary>
+/// Scheduled task state read and changed through the Task Scheduler library. Stateless and
+/// static: callers pass an <see cref="OpCall" /> that receives the recorded changes.
+/// </summary>
public static class ScheduledTaskService
{
/// <summary>
@@ -42,8 +46,12 @@ public static class ScheduledTaskService
}
}
- /// <summary>Disables a scheduled task, recording the change into <paramref name="call"/>.</summary>
- /// <param name="call">The explicit call context: change collector, logger and cancellation token.</param>
+ /// <summary>
+ /// Disables a scheduled task, recording the change into <paramref name="call"/>.
+ /// </summary>
+ /// <param name="call">
+ /// The explicit call context: change collector, logger and cancellation token.
+ /// </param>
/// <param name="fullPath">The full path of the task to disable.</param>
/// <returns>The outcome of the disable request.</returns>
public static OpResult DisableTask(OpCall call, string fullPath)
@@ -89,11 +97,7 @@ public static class ScheduledTaskService
fullPath,
"disabled"
),
- new ScheduledTaskDisableDetail
- {
- TaskPath = fullPath,
- PreviousEnabled = false,
- }
+ new ScheduledTaskDisableDetail { TaskPath = fullPath, PreviousEnabled = false }
);
return OpResult.Success();
}
@@ -159,8 +163,12 @@ public static class ScheduledTaskService
}
}
- /// <summary>Enables a scheduled task, recording the change into <paramref name="call"/>.</summary>
- /// <param name="call">The explicit call context: change collector, logger and cancellation token.</param>
+ /// <summary>
+ /// Enables a scheduled task, recording the change into <paramref name="call"/>.
+ /// </summary>
+ /// <param name="call">
+ /// The explicit call context: change collector, logger and cancellation token.
+ /// </param>
/// <param name="fullPath">The full path of the task to enable.</param>
/// <returns>The outcome of the enable request.</returns>
public static OpResult EnableTask(OpCall call, string fullPath)
@@ -206,11 +214,7 @@ public static class ScheduledTaskService
fullPath,
"enabled"
),
- new ScheduledTaskEnableDetail
- {
- TaskPath = fullPath,
- PreviousEnabled = true,
- }
+ new ScheduledTaskEnableDetail { TaskPath = fullPath, PreviousEnabled = true }
);
return OpResult.Success();
}
@@ -277,7 +281,6 @@ public static class ScheduledTaskService
}
/// <summary>Retrieves all scheduled tasks from the system, including icon extraction.</summary>
- /// <returns>A list of all scheduled tasks.</returns>
public static List<ScheduledTaskModel> GetAllTasks(ILogger? logger = null)
{
var results = new List<ScheduledTaskModel>();
@@ -286,7 +289,6 @@ public static class ScheduledTaskService
using var ts = new TaskService();
CollectTasks(ts.RootFolder, results, logger);
- // Extract icons from task commands
Parallel.ForEach(
results,
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount },
@@ -318,7 +320,9 @@ public static class ScheduledTaskService
/// <summary>Runs a scheduled task immediately.</summary>
/// <param name="call">Optional call context used for change recording and logging.</param>
/// <param name="fullPath">The full path of the task to run.</param>
- /// <returns>The outcome of the run request. No revert step: starting a task is not reversible.</returns>
+ /// <returns>
+ /// The outcome of the run request. No revert step: starting a task is not reversible.
+ /// </returns>
public static OpResult RunTask(OpCall? call, string fullPath)
{
var description = ServiceStrings.Format("Run scheduled task: {0}", fullPath);
@@ -358,7 +362,9 @@ public static class ScheduledTaskService
/// <summary>Stops a running scheduled task.</summary>
/// <param name="call">Optional call context used for change recording and logging.</param>
/// <param name="fullPath">The full path of the task to stop.</param>
- /// <returns>The outcome of the stop request. No revert step: stopping a task is not reversible.</returns>
+ /// <returns>
+ /// The outcome of the stop request. No revert step: stopping a task is not reversible.
+ /// </returns>
public static OpResult StopTask(OpCall? call, string fullPath)
{
var description = ServiceStrings.Format("Stop scheduled task: {0}", fullPath);
@@ -398,7 +404,10 @@ public static class ScheduledTaskService
/// <summary>Gets the current state string of a task.</summary>
/// <param name="fullPath">The full path of the task.</param>
/// <param name="logger">Optional logger used only for logging.</param>
- /// <returns>The task state string, or <see langword="null" /> if the task is not found or an error occurs.</returns>
+ /// <returns>
+ /// The task state string, or <see langword="null" /> if the task is not found or an error
+ /// occurs.
+ /// </returns>
public static string? GetTaskState(string fullPath, ILogger? logger = null)
{
try
@@ -458,7 +467,10 @@ public static class ScheduledTaskService
}
}
- /// <summary>Registers a new scheduled task from a model definition. Overwrites any existing task with the same name.</summary>
+ /// <summary>
+ /// Registers a new scheduled task from a model definition. Overwrites any existing task
+ /// with the same name.
+ /// </summary>
/// <param name="call">Optional call context used for change recording and logging.</param>
/// <param name="folderPath">The target folder path (e.g. <c>\MyApp</c>).</param>
/// <param name="model">The task definition model.</param>
@@ -486,7 +498,6 @@ public static class ScheduledTaskService
if (model.RunWithHighestPrivileges)
td.Principal.RunLevel = TaskRunLevel.Highest;
- // Handle Action Execution accurately
if (!string.IsNullOrWhiteSpace(model.ExecutablePath))
{
var action = new ExecAction(model.ExecutablePath);
@@ -494,7 +505,7 @@ public static class ScheduledTaskService
action.Arguments = model.Arguments;
td.Actions.Add(action);
}
- else if (!string.IsNullOrWhiteSpace(model.ActionSummary)) // Fallback if still populated via old approach
+ else if (!string.IsNullOrWhiteSpace(model.ActionSummary))
{
var parts = model.ActionSummary.Trim();
var spaceIdx = parts.IndexOf(' ');
@@ -504,7 +515,6 @@ public static class ScheduledTaskService
td.Actions.Add(new ExecAction(parts));
}
- // Add triggers based on model flags
if (model.HasLogonTrigger)
td.Triggers.Add(new LogonTrigger());
if (model.HasBootTrigger)
@@ -518,7 +528,6 @@ public static class ScheduledTaskService
new DailyTrigger { StartBoundary = DateTime.Today + model.DailyTriggerTime }
);
- // Ensure folder exists
var folder = ts.RootFolder;
if (!string.IsNullOrWhiteSpace(folderPath) && folderPath != "\\")
try
@@ -565,8 +574,6 @@ public static class ScheduledTaskService
}
}
- #region Helpers
-
private static void CollectTasks(
TaskFolder folder,
List<ScheduledTaskModel> results,
@@ -827,6 +834,5 @@ public static class ScheduledTaskService
};
}
- #endregion Helpers
internal const string TaskReasonNotFound = "task.notFound";
}
diff --git a/optimizerDuck/Services/System/Primitives/ServiceProcessService.cs b/optimizerDuck/Services/System/Primitives/ServiceProcessService.cs
index 5fd7bf4..93d5f1e 100644
--- a/optimizerDuck/Services/System/Primitives/ServiceProcessService.cs
+++ b/optimizerDuck/Services/System/Primitives/ServiceProcessService.cs
@@ -9,6 +9,11 @@ using optimizerDuck.Domain.Revert.Steps;
namespace optimizerDuck.Services.System.Primitives;
+/// <summary>
+/// Windows service startup types read and written through the Service Control Manager, with no
+/// child process. Stateless and static: callers pass an <see cref="OpCall" /> that receives the
+/// recorded changes.
+/// </summary>
public static class ServiceProcessService
{
private const int ErrorServiceDoesNotExist = 1060;
@@ -16,10 +21,10 @@ public static class ServiceProcessService
private const int ErrorAccessDenied = 5;
/// <summary>
- /// Retrieves the current startup type of a Windows service from the Service Control Manager.
+ /// Retrieves the startup type of a Windows service from the Service Control Manager.
/// </summary>
/// <param name="serviceName">The internal service name.</param>
- /// <param name="logger">Optional logger used only for logging.</param>
+ /// <param name="logger">An optional logger for query warnings.</param>
/// <returns>
/// A tuple. <c>StartupType</c> is the type Windows reports (null for boot and system starts,
/// which have no <see cref="ServiceStartupType"/> value). <c>NotFound</c> is
@@ -44,10 +49,12 @@ public static class ServiceProcessService
}
/// <summary>
- /// Changes the startup type of a single Windows service through the Service Control Manager.
+ /// Changes the startup type of one Windows service through the Service Control Manager.
/// Records the change into <paramref name="call"/>.
/// </summary>
- /// <param name="call">The explicit call context: change collector, logger and cancellation token.</param>
+ /// <param name="call">
+ /// The explicit call context: change collector, logger and cancellation token.
+ /// </param>
/// <param name="item">The service item with the target startup type.</param>
/// <returns>The outcome of the change request.</returns>
public static async Task<OpResult> ChangeServiceStartupTypeAsync(OpCall call, ServiceItem item)
@@ -206,9 +213,8 @@ public static class ServiceProcessService
);
}
- // A delayed auto start flag that Windows refuses still leaves the start type
- // written, so the recorded step carries the previous one and a revert can put it
- // back even though the outcome is a failure.
+ // Windows can refuse the delayed auto start flag after the start type is written, so
+ // the recorded step carries the previous type and a revert can put it back.
ServiceRevertStep? partialRevert = null;
if (write.StartTypeWritten)
partialRevert = new ServiceRevertStep
@@ -285,7 +291,7 @@ public static class ServiceProcessService
}
/// <summary>
- /// Maps the compat <see cref="ServiceChangeResult"/> outcome to an <see cref="OpResult"/>.
+ /// Maps a <see cref="ServiceChangeResult"/> outcome to an <see cref="OpResult"/>.
/// Success, NotFound, AlreadyConfigured and AccessDenied are informational outcomes,
/// because a refusal by Windows is not a failure; only Failed carries an error naming
/// the service.
@@ -325,7 +331,9 @@ public static class ServiceProcessService
private const uint ServiceConfigDelayedAutoStartInfo = 3;
- /// <summary>Offset of <c>dwStartType</c> in the native <c>QUERY_SERVICE_CONFIG</c> structure.</summary>
+ /// <summary>
+ /// Offset of <c>dwStartType</c> in the native <c>QUERY_SERVICE_CONFIG</c> structure.
+ /// </summary>
private const int QueryServiceConfigStartTypeOffset = 4;
/// <summary>
diff --git a/optimizerDuck/Services/System/Primitives/ServiceStrings.cs b/optimizerDuck/Services/System/Primitives/ServiceStrings.cs
index 0ec25f5..4669d03 100644
--- a/optimizerDuck/Services/System/Primitives/ServiceStrings.cs
+++ b/optimizerDuck/Services/System/Primitives/ServiceStrings.cs
@@ -3,11 +3,10 @@ using System.Globalization;
namespace optimizerDuck.Services.System.Primitives;
/// <summary>
-/// English-only provider strings: step names, step descriptions and log/error text.
-/// These are intentionally NOT in Translations.resx. Revert data, logs and recorded
-/// step names must stay in stable English regardless of UI language, so there is
-/// nothing for translators to do here. Add new entries to this class, never to
-/// the resx. Templates use {0}-style placeholders via <see cref="Format"/>.
+/// Holds the English-only provider strings: step names, step descriptions and log/error text.
+/// They are deliberately absent from Translations.resx, because revert data, logs and recorded
+/// step names must stay in stable English regardless of UI language.
+/// Templates use {0}-style placeholders via <see cref="Format"/>.
/// </summary>
public static class ServiceStrings
{
@@ -80,7 +79,7 @@ public static class ServiceStrings
public const string UsbPowerInfoNoDevices =
"No USB root hub devices on this machine (nothing to change)";
- /// <summary>Formats a template with invariant culture (same as Loc.Invariant did).</summary>
+ /// <summary>Formats a template with the invariant culture.</summary>
public static string Format(string template, params object?[] args) =>
string.Format(CultureInfo.InvariantCulture, template, args);
}
diff --git a/optimizerDuck/Services/System/Primitives/ShellMapping.cs b/optimizerDuck/Services/System/Primitives/ShellMapping.cs
index 4fce11b..5aacf50 100644
--- a/optimizerDuck/Services/System/Primitives/ShellMapping.cs
+++ b/optimizerDuck/Services/System/Primitives/ShellMapping.cs
@@ -4,9 +4,8 @@ using optimizerDuck.Domain.Optimizations.Models.Services;
namespace optimizerDuck.Services.System.Primitives;
/// <summary>
-/// Shared mapping between <see cref="ProcessResult"/> and <see cref="ShellResult"/>
-/// plus command-building helpers. Single source of truth for both legacy
-/// <c>ShellService</c> and the new <c>ShellRunner</c> capability.
+/// Shared mapping between <see cref="ProcessResult"/> and <see cref="ShellResult"/>, plus the
+/// command-building helpers used by <c>ShellService</c>.
/// </summary>
internal static class ShellMapping
{
diff --git a/optimizerDuck/Services/System/Primitives/ShellService.cs b/optimizerDuck/Services/System/Primitives/ShellService.cs
index 4f77d5f..b620fe1 100644
--- a/optimizerDuck/Services/System/Primitives/ShellService.cs
+++ b/optimizerDuck/Services/System/Primitives/ShellService.cs
@@ -9,7 +9,7 @@ using optimizerDuck.Services.Configuration;
namespace optimizerDuck.Services.System.Primitives;
/// <summary>
-/// Thin instance facade over <see cref="ProcessRunner"/>: builds the
+/// Provides a thin instance facade over <see cref="ProcessRunner"/>: builds the
/// cmd.exe / powershell.exe command lines, maps the raw
/// <see cref="ProcessResult"/> to a <see cref="ShellResult"/> for policy
/// evaluation, records a <see cref="Change"/> into the passed
@@ -172,12 +172,9 @@ public sealed class ShellService
return success ? OpResult.Success(revertStep) : OpResult.Fail(error!, errorDetail);
}
- #region Raw runs (no Change recording)
-
/// <summary>
- /// Runs a cmd.exe command without recording a <see cref="Change"/>.
- /// For non-optimization callers (UI services, revert steps, shutdown paths)
- /// that need the raw <see cref="ShellResult"/> (stdout/stderr/exit code).
+ /// Runs a cmd.exe command without recording a <see cref="Change"/> and returns
+ /// the raw <see cref="ShellResult"/> (stdout, stderr, exit code).
/// </summary>
public async Task<ShellResult> QueryCMDAsync(
string command,
@@ -200,9 +197,8 @@ public sealed class ShellService
}
/// <summary>
- /// Runs a PowerShell command without recording a <see cref="Change"/>.
- /// For non-optimization callers (UI services, revert steps, queries)
- /// that need the raw <see cref="ShellResult"/> (stdout/stderr/exit code).
+ /// Runs a PowerShell command without recording a <see cref="Change"/> and returns
+ /// the raw <see cref="ShellResult"/> (stdout, stderr, exit code).
/// </summary>
public async Task<ShellResult> QueryPowerShellAsync(
string command,
@@ -225,19 +221,18 @@ public sealed class ShellService
return result;
}
- #endregion Raw runs (no Change recording)
-
- #region Command Prompt methods
-
-
/// <summary>
/// Runs a command in the Command Prompt (cmd.exe) asynchronously.
/// </summary>
/// <param name="command">The command to execute.</param>
- /// <param name="call">The explicit per-operation call context (change collector, logger, cancellation).</param>
+ /// <param name="call">
+ /// The explicit per-operation call context (change collector, logger, cancellation).
+ /// </param>
/// <param name="revertStep">The revert step to record.</param>
/// <param name="policy">The policy to use for determining success.</param>
- /// <param name="ct">An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.</param>
+ /// <param name="ct">
+ /// An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.
+ /// </param>
/// <returns>The result of the command execution.</returns>
public Task<OpResult> CMDAsync(
string command,
@@ -261,13 +256,18 @@ public sealed class ShellService
}
/// <summary>
- /// Runs a command in the Command Prompt (cmd.exe) asynchronously with a specific revert command.
+ /// Runs a command in the Command Prompt (cmd.exe) asynchronously with a specific
+ /// revert command.
/// </summary>
/// <param name="command">The command to execute.</param>
- /// <param name="call">The explicit per-operation call context (change collector, logger, cancellation).</param>
+ /// <param name="call">
+ /// The explicit per-operation call context (change collector, logger, cancellation).
+ /// </param>
/// <param name="revertCommand">The command to execute for reverting.</param>
/// <param name="policy">The policy to use for determining success.</param>
- /// <param name="ct">An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.</param>
+ /// <param name="ct">
+ /// An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.
+ /// </param>
/// <returns>The result of the command execution.</returns>
public Task<OpResult> CMDAsync(
string command,
@@ -290,19 +290,18 @@ public sealed class ShellService
);
}
- #endregion Command Prompt methods
-
- #region PowerShell methods
-
-
/// <summary>
/// Runs a command in PowerShell asynchronously.
/// </summary>
/// <param name="command">The command to execute.</param>
- /// <param name="call">The explicit per-operation call context (change collector, logger, cancellation).</param>
+ /// <param name="call">
+ /// The explicit per-operation call context (change collector, logger, cancellation).
+ /// </param>
/// <param name="revertStep">The revert step to record.</param>
/// <param name="policy">The policy to use for determining success.</param>
- /// <param name="ct">An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.</param>
+ /// <param name="ct">
+ /// An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.
+ /// </param>
/// <returns>The result of the command execution.</returns>
public Task<OpResult> PowerShellAsync(
string command,
@@ -325,12 +324,18 @@ public sealed class ShellService
);
}
- /// <summary>Runs a command in PowerShell asynchronously with a specific revert command.</summary>
+ /// <summary>
+ /// Runs a command in PowerShell asynchronously with a specific revert command.
+ /// </summary>
/// <param name="command">The command to execute.</param>
- /// <param name="call">The explicit per-operation call context (change collector, logger, cancellation).</param>
+ /// <param name="call">
+ /// The explicit per-operation call context (change collector, logger, cancellation).
+ /// </param>
/// <param name="revertCommand">The command to execute for reverting.</param>
/// <param name="policy">The policy for determining success.</param>
- /// <param name="ct">An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.</param>
+ /// <param name="ct">
+ /// An additional cancellation token, linked with <see cref="OpCall.CancellationToken"/>.
+ /// </param>
/// <returns>The result of the command execution.</returns>
public Task<OpResult> PowerShellAsync(
string command,
@@ -382,6 +387,4 @@ public sealed class ShellService
return string.Join("\n", sections);
}
-
- #endregion PowerShell methods
}
diff --git a/optimizerDuck/Services/System/Primitives/UsbPowerService.cs b/optimizerDuck/Services/System/Primitives/UsbPowerService.cs
index b5a9973..c6bdc52 100644
--- a/optimizerDuck/Services/System/Primitives/UsbPowerService.cs
+++ b/optimizerDuck/Services/System/Primitives/UsbPowerService.cs
@@ -4,12 +4,11 @@ using System.Runtime.Versioning;
namespace optimizerDuck.Services.System.Primitives;
/// <summary>
-/// Per-device USB power management over <c>root\wmi</c>'s <c>MSPower_DeviceEnable</c>, using the
-/// in-process WMI client (via <c>WmiHelper</c>) instead of a PowerShell script.
-/// Microsoft does not document this WMI class and documents no API for the per-device "allow the
-/// computer to turn off this device" setting, so the surface underneath is unchanged - only the
-/// client is. Every operation fails open: no devices, a failed query, or a refused write never
-/// throws out of this service.
+/// Per-device USB power management over <c>root\wmi</c>'s <c>MSPower_DeviceEnable</c>, read
+/// and written through the in-process WMI client.
+/// Microsoft does not document this WMI class and documents no API for the per-device "allow
+/// the computer to turn off this device" setting. Every operation fails open: no devices, a
+/// failed query, or a refused write never throws out of this service.
/// </summary>
[SupportedOSPlatform("windows")]
public static class UsbPowerService
@@ -35,8 +34,8 @@ public static class UsbPowerService
public sealed record UsbPowerWriteResult(int ChangedCount, IReadOnlyList<string> FailedDevices);
/// <summary>
- /// Captures the current state of every USB root-hub device, which is what a revert restores.
- /// Empty when the class is unavailable, so callers treat it as "nothing to do".
+ /// Captures the current state of every USB root-hub device, which is what a revert
+ /// restores. Empty when the class is unavailable, so callers treat it as "nothing to do".
/// </summary>
public static IReadOnlyList<UsbPowerState> Capture()
{
@@ -79,10 +78,6 @@ public static class UsbPowerService
);
}
- /// <summary>
- /// Applies <paramref name="target" /> to every matching device; a null target means "leave
- /// this device alone". Devices already in the requested state are not written.
- /// </summary>
/// <summary>
/// The devices a write pass has to touch, given the states Windows reports and the
/// requested target. A null target leaves a device alone, and a device already in the
diff --git a/optimizerDuck/Services/System/RegistryWatcher.cs b/optimizerDuck/Services/System/RegistryWatcher.cs
index cf330dd..d042371 100644
--- a/optimizerDuck/Services/System/RegistryWatcher.cs
+++ b/optimizerDuck/Services/System/RegistryWatcher.cs
@@ -7,11 +7,20 @@ namespace optimizerDuck.Services.System;
/// <summary>Monitors Windows registry keys for changes using RegNotifyChangeKeyValue.</summary>
public interface IRegistryWatcher : IDisposable
{
- /// <summary>Raised when a watched registry key or its values change. The event argument is the registry path that changed.</summary>
+ /// <summary>
+ /// Raised when a watched registry key or its values change.
+ /// The event argument is the registry path that changed.
+ /// </summary>
event EventHandler<string>? RegistryKeyChanged;
- /// <summary>Starts watching the specified registry path for changes. Multiple paths can be watched simultaneously.</summary>
- /// <param name="registryPath">The full registry path (e.g., "HKCU\Software\Microsoft\Windows\CurrentVersion\Run").</param>
+ /// <summary>
+ /// Starts watching the specified registry path for changes.
+ /// Multiple paths can be watched simultaneously.
+ /// </summary>
+ /// <param name="registryPath">
+ /// The full registry path, for example
+ /// "HKCU\Software\Microsoft\Windows\CurrentVersion\Run".
+ /// </param>
void Watch(string registryPath);
/// <summary>Stops watching the specified registry path.</summary>
@@ -284,7 +293,8 @@ internal sealed class RegistryWatcher(ILogger<RegistryWatcher> logger) : IRegist
? path[..firstBackslash].ToUpperInvariant()
: path.ToUpperInvariant();
- // Strip trailing colon for compatibility with RegistryService format (e.g. "HKLM:", "HKCU:")
+ // Strip trailing colon for compatibility with the RegistryService format, for
+ // example "HKLM:", "HKCU:".
if (root.EndsWith(":"))
root = root[..^1];
diff --git a/optimizerDuck/Services/System/StreamService.cs b/optimizerDuck/Services/System/StreamService.cs
index bf5921f..174c870 100644
--- a/optimizerDuck/Services/System/StreamService.cs
+++ b/optimizerDuck/Services/System/StreamService.cs
@@ -9,13 +9,19 @@ public class StreamService(ILogger<StreamService> logger) : IDisposable
{
private HttpClient? _client;
- /// <summary>Downloads a file from the specified URL and saves it to the local downloads directory.</summary>
+ /// <summary>
+ /// Downloads a file from the specified URL and saves it to the local downloads directory.
+ /// </summary>
/// <param name="url">The URL to download from.</param>
/// <param name="fileName">The target file name (not path) to save as.</param>
- /// <returns>A <see cref="DownloadResult"/> where <c>Ok</c> indicates whether the download completed, and <c>FilePath</c> is the full local path on success.</returns>
+ /// <returns>
+ /// A <see cref="DownloadResult"/> where <c>Ok</c> indicates whether the download completed,
+ /// and <c>FilePath</c> is the full local path on success.
+ /// </returns>
/// <example>
/// <code language="csharp">
- /// var download = await streamService.TryDownloadAsync("https://example.com/file.zip", "file.zip");
+ /// var download = await streamService.TryDownloadAsync("https://example.com/file.zip",
+ /// "file.zip");
/// if (download.Ok) Console.WriteLine(download.FilePath);
/// </code>
/// </example>
diff --git a/optimizerDuck/Services/System/SystemInfo.cs b/optimizerDuck/Services/System/SystemInfo.cs
index a474e6e..e29e976 100644
--- a/optimizerDuck/Services/System/SystemInfo.cs
+++ b/optimizerDuck/Services/System/SystemInfo.cs
@@ -87,7 +87,9 @@ public enum MemoryProfileState
Disabled,
}
-/// <summary>Physical storage kind. Nvme is split out because it matters for perf expectations.</summary>
+/// <summary>
+/// Physical storage kind. Nvme is split out because it matters for performance expectations.
+/// </summary>
public enum StorageMediaType
{
Unknown,
@@ -143,7 +145,10 @@ public sealed record CpuInfo
public int? L2CacheKB { get; init; }
public int? L3CacheKB { get; init; }
- /// <summary>Null when firmware flag unreadable (Win32_Processor.VirtualizationFirmwareEnabled).</summary>
+ /// <summary>
+ /// Null when the firmware flag is unreadable
+ /// (Win32_Processor.VirtualizationFirmwareEnabled).
+ /// </summary>
public bool? VirtualizationFirmwareEnabled { get; init; }
public bool IsIntel => Vendor == CpuVendor.Intel;
diff --git a/optimizerDuck/Services/System/SystemInfoService.cs b/optimizerDuck/Services/System/SystemInfoService.cs
index ec1432e..5c213cf 100644
--- a/optimizerDuck/Services/System/SystemInfoService.cs
+++ b/optimizerDuck/Services/System/SystemInfoService.cs
@@ -12,10 +12,6 @@ using WmiEnumerationOptions = System.Management.EnumerationOptions;
namespace optimizerDuck.Services.System;
-// ============================================================================
-// WMI HELPER (connection caching, always-disposing queries)
-// ============================================================================
-
internal static class WmiHelper
{
private static readonly ConcurrentDictionary<string, ManagementScope> ScopeCache = new(
@@ -63,7 +59,8 @@ internal static class WmiHelper
ScopeCache.Clear();
}
- // static log hook (same pattern as PowerReader.Configure); per-instance wiring if a second writer appears.
+ // static log hook (same pattern as PowerReader.Configure); per-instance wiring if a
+ // second writer appears.
private static Action<string, Exception>? _onQueryFailed;
/// <summary>Wires a debug sink for failed WMI queries. Null detaches.</summary>
@@ -235,10 +232,6 @@ internal static class WmiHelper
}
}
-// ============================================================================
-// NATIVE APIS (no process spawning)
-// ============================================================================
-
internal static class NativeMemory
{
[DllImport("kernel32.dll", SetLastError = true)]
@@ -550,7 +543,10 @@ internal static class MemoryProvider
) ?? throw new InvalidOperationException("Win32_PhysicalMemory query failed.");
}
- /// <summary>SMBIOS memory-type codes (DMTF DSP0134). Unspecified = Unknown, unlisted = Other, never guessed.</summary>
+ /// <summary>
+ /// SMBIOS memory-type codes (DMTF DSP0134). Unspecified = Unknown, unlisted = Other,
+ /// never guessed.
+ /// </summary>
internal static MemoryType MapMemoryType(int? code)
{
return code switch
@@ -1090,10 +1086,6 @@ internal static class DiskProvider
}
}
-// ============================================================================
-// DXGI INTEROP (COM P/Invoke, unchanged behavior)
-// ============================================================================
-
internal static class DxgiHelper
{
public const uint DXGI_ADAPTER_FLAG_SOFTWARE = 2;
@@ -1202,10 +1194,6 @@ internal static class DxgiHelper
}
}
-// ============================================================================
-// GPU PROVIDER (DXGI + one WMI pass for driver details)
-// ============================================================================
-
internal static class GpuProvider
{
/// <summary>Physical GPUs ordered by DXGI index; empty when nothing usable found.</summary>
@@ -1490,10 +1478,6 @@ internal static class GpuProvider
);
}
-// ============================================================================
-// WINDOWS / FIRMWARE / SECURITY / POWER / RUNTIME PROVIDERS
-// ============================================================================
-
internal static class WindowsProvider
{
private static readonly Lazy<WindowsInfo> _cached = new(
@@ -1904,10 +1888,6 @@ internal static class RuntimeProvider
}
}
-// ============================================================================
-// MAIN SERVICE (public API)
-// ============================================================================
-
public sealed class SystemInfoService : IDisposable
{
private static readonly TimeSpan ScanTimeout = TimeSpan.FromSeconds(20);
diff --git a/optimizerDuck/Services/System/SystemRestoreService.cs b/optimizerDuck/Services/System/SystemRestoreService.cs
index c8d3650..742dc68 100644
--- a/optimizerDuck/Services/System/SystemRestoreService.cs
+++ b/optimizerDuck/Services/System/SystemRestoreService.cs
@@ -8,11 +8,12 @@ namespace optimizerDuck.Services.System;
/// <summary>
/// System Restore over the documented <c>SystemRestore</c> class in <c>root\default</c> - the
-/// same subsystem that backs <c>Checkpoint-Computer</c> and <c>Enable-ComputerRestore</c>, without
-/// a child process. Single owner of every System Restore WMI call in the app.
+/// same subsystem that backs <c>Checkpoint-Computer</c> and
+/// <c>Enable-ComputerRestore</c>, without a child process. Single owner of every System
+/// Restore WMI call in the app.
/// Reads take ids only; mutating calls take an optional <see cref="ILogger" /> (default null),
-/// return typed results carrying the real native status, and record nothing - so a restore-point
-/// manager tool can reuse this service exactly like a tool reuses
+/// return typed results carrying the real native status, and record nothing - so a
+/// restore-point manager tool can reuse this service exactly like a tool reuses
/// <see cref="PowerPlanService" />. Virtual members are the hand-double seam for tests, because
/// System Restore needs elevation and test hosts do not have it.
/// </summary>
@@ -36,7 +37,9 @@ public class SystemRestoreService
/// <summary>ERROR_SERVICE_DISABLED: System Restore is not enabled for the drive.</summary>
public const uint ErrorServiceDisabled = 1058;
- /// <summary>HRESULT_FROM_WIN32(ERROR_SERVICE_DISABLED), the other shape that refusal takes.</summary>
+ /// <summary>
+ /// HRESULT_FROM_WIN32(ERROR_SERVICE_DISABLED), the other shape that refusal takes.
+ /// </summary>
public const uint HrServiceDisabled = 0x80070422;
/// <summary>
@@ -51,7 +54,9 @@ public class SystemRestoreService
/// <summary>One restore point as Windows reports it.</summary>
/// <param name="SequenceNumber">The restore point's sequence number.</param>
- /// <param name="RestorePointType">The documented restore point type (12 = MODIFY_SETTINGS).</param>
+ /// <param name="RestorePointType">
+ /// The documented restore point type (12 = MODIFY_SETTINGS).
+ /// </param>
/// <param name="Description">The description the creating application supplied.</param>
/// <param name="CreationTimeUtc">When the point was created, in UTC.</param>
public sealed record RestorePointInfo(
@@ -114,7 +119,10 @@ public class SystemRestoreService
) ?? [];
}
- /// <summary>Newest restore point, or null when there is none or the list cannot be read.</summary>
+ /// <summary>
+ /// Newest restore point, or <see langword="null" /> when there is none or the list cannot
+ /// be read.
+ /// </summary>
public virtual DateTime? GetNewestRestorePointUtc()
{
DateTime? newest = null;
@@ -177,7 +185,9 @@ public class SystemRestoreService
);
}
- /// <summary>Enables System Protection for one drive, for example <c>C:</c>. Needs elevation.</summary>
+ /// <summary>
+ /// Enables System Protection for one drive, for example <c>C:</c>. Needs elevation.
+ /// </summary>
public virtual SystemRestoreResult EnableProtection(string drive)
{
return Invoke("Enable", parameters => parameters["Drive"] = drive);
diff --git a/optimizerDuck/Services/System/UpdaterService.cs b/optimizerDuck/Services/System/UpdaterService.cs
index d8f960d..649298f 100644
--- a/optimizerDuck/Services/System/UpdaterService.cs
+++ b/optimizerDuck/Services/System/UpdaterService.cs
@@ -29,7 +29,10 @@ public class UpdaterService : IDisposable
}
/// <summary>Checks the GitHub API for a newer version of the application.</summary>
- /// <returns>A tuple where <c>Result</c> is <see langword="true"/> if a newer version exists, and <c>Version</c> is the latest version string.</returns>
+ /// <returns>
+ /// A tuple where <c>Result</c> is <see langword="true" /> if a newer version exists, and
+ /// <c>Version</c> is the latest version string.
+ /// </returns>
public async Task<(bool Result, string? Version)> CheckForUpdatesAsync()
{
_logger.LogInformation(
@@ -50,10 +53,10 @@ public class UpdaterService : IDisposable
return (false, null);
}
- // "v1.1.0" -> "1.1.0"
+ // "v1.1.0" becomes "1.1.0"
var latestVersionStr = latestRelease.TagName.TrimStart('v');
- // "1.1.0-fix" -> "1.1.0"
+ // "1.1.0-fix" becomes "1.1.0"
var preReleaseSeparatorIndex = latestVersionStr.IndexOf('-');
if (preReleaseSeparatorIndex != -1)
latestVersionStr = latestVersionStr[..preReleaseSeparatorIndex];
@@ -114,7 +117,9 @@ public class UpdaterService : IDisposable
}
// Helper classes for deserializing GitHub API response
-/// <summary>Represents a GitHub release fetched from the API. Used internally for deserialization.</summary>
+/// <summary>
+/// Represents a GitHub release fetched from the API. Used internally for deserialization.
+/// </summary>
public class GitHubRelease
{
/// <summary>Gets or sets the release tag name (e.g., "v1.2.0").</summary>
diff --git a/optimizerDuck/Services/UI/BloatwareService.cs b/optimizerDuck/Services/UI/BloatwareService.cs
index 76a477d..a126d9b 100644
--- a/optimizerDuck/Services/UI/BloatwareService.cs
+++ b/optimizerDuck/Services/UI/BloatwareService.cs
@@ -137,12 +137,8 @@ public class BloatwareService(
}
/// <summary>
- /// Parses the <c>ConvertTo-Json</c> output of the AppX query. PowerShell emits a
- /// bare object for a single package and an array for several, so both shapes are
- /// accepted; deserialising only as a list silently yielded an empty result for the
- /// single-package case.
+ /// Outcome of one package removal, derived from what the removal script reported.
/// </summary>
- /// <summary>Outcome of one package removal, derived from what the removal script reported.</summary>
/// <param name="Failures">
/// One entry per refusal, empty when Windows removed the package or reported that nothing
/// was installed.
@@ -178,6 +174,10 @@ public class BloatwareService(
return new AppXRemovalResult(failures);
}
+ /// <summary>
+ /// Parses the <c>ConvertTo-Json</c> output of the AppX query. PowerShell emits a bare
+ /// object for a single package and an array for several, so both shapes are accepted.
+ /// </summary>
internal static List<AppXPackage> ParsePackages(string stdout)
{
var json = stdout.TrimStart();
@@ -246,7 +246,6 @@ public class BloatwareService(
return new AppXRemovalResult([]);
}
- // Safe string literal escaping for PowerShell
var safeName = EscapeForPowerShellLiteral(appXPackage.Name ?? string.Empty);
var safePackageFullName = EscapeForPowerShellLiteral(appXPackage.PackageFullName);
if (!AppXNameValidationRegex.IsMatch(appXPackage.Name ?? string.Empty))
@@ -386,7 +385,8 @@ public class BloatwareService(
var assetsDir = Path.Combine(installLocation, "Assets");
if (Directory.Exists(assetsDir))
{
- // Per Microsoft guidance, AppList/Square44x44 assets are a better primary app icon source than StoreLogo.
+ // Per Microsoft guidance, AppList/Square44x44 assets are a better primary app
+ // icon source than StoreLogo.
var fallbackCandidates = new[]
{
@"Assets\AppList.png",
diff --git a/optimizerDuck/Services/UI/DiskCleanupService.cs b/optimizerDuck/Services/UI/DiskCleanupService.cs
index 6cc4d51..a92a397 100644
--- a/optimizerDuck/Services/UI/DiskCleanupService.cs
+++ b/optimizerDuck/Services/UI/DiskCleanupService.cs
@@ -239,7 +239,8 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)
var dirInfo = new DirectoryInfo(path);
- // Pre-check: only filter .net path if the .net temp directory is a descendant of the scan root
+ // Pre-check: only filter .net path if the .net temp directory is a descendant of the
+ // scan root
var needsDotNetFilter =
isRecursive
&& DotNetTempPath.StartsWith(
@@ -250,7 +251,6 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)
foreach (var fileInfo in dirInfo.EnumerateFiles(searchPattern, options))
try
{
- // Skip .net temp files (only when necessary)
if (needsDotNetFilter)
{
var fullDirPath = fileInfo.DirectoryName ?? string.Empty;
@@ -267,7 +267,8 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)
continue;
}
- // .Length is already cached from EnumerateFiles under the hood (WIN32_FIND_DATA)
+ // .Length is already cached from EnumerateFiles under the hood
+ // (WIN32_FIND_DATA)
size += fileInfo.Length;
count++;
}
@@ -301,7 +302,8 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)
var dirInfo = new DirectoryInfo(path);
- // Pre-check: only filter .net path if the .net temp directory is a descendant of the scan root
+ // Pre-check: only filter .net path if the .net temp directory is a descendant of the
+ // scan root
var needsDotNetFilter =
isRecursive
&& DotNetTempPath.StartsWith(
@@ -309,7 +311,6 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)
StringComparison.OrdinalIgnoreCase
);
- // Delete files
foreach (var fileInfo in dirInfo.EnumerateFiles(searchPattern, options))
try
{
@@ -333,7 +334,6 @@ public class DiskCleanupService(ILogger<DiskCleanupService> logger)
// skip locked/inaccessible files
}
- // Clean up empty directories if recursive
if (options.RecurseSubdirectories)
{
var dirOptions = new EnumerationOptions
diff --git a/optimizerDuck/Services/UI/StartupManagerService.cs b/optimizerDuck/Services/UI/StartupManagerService.cs
index 596cfa2..3011cea 100644
--- a/optimizerDuck/Services/UI/StartupManagerService.cs
+++ b/optimizerDuck/Services/UI/StartupManagerService.cs
@@ -66,7 +66,8 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
apps
);
- // 2. Registry (32-bit view, redirected to Wow6432Node), where 32-bit installers register
+ // 2. Registry (32-bit view, redirected to Wow6432Node), where 32-bit installers
+ // register
using var hklm32 = RegistryKey.OpenBaseKey(
RegistryHive.LocalMachine,
RegistryView.Registry32
@@ -120,7 +121,8 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
}
);
- // Fill remaining packaged-app icons from the package logo PNG (apps without a win32 exe)
+ // Fill remaining packaged-app icons from the package logo PNG (apps without a
+ // win32 exe)
Parallel.ForEach(
uwpEntries.Where(e => e.App.LogoImage == null && e.LogoPath != null),
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount },
@@ -231,7 +233,6 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
try
{
- // Determine registry root key based on folder location
var rootKey =
location == StartupAppLocation.CommonStartupFolder
? Registry.LocalMachine
@@ -278,7 +279,8 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
/// <summary>
/// Enumerates packaged (UWP / MSIX) apps that declare a StartupTask in their manifest.
- /// The enable state comes from <c>HKCU\...\AppModel\SystemAppData\{FamilyName}\{TaskId}\State</c>
+ /// The enable state comes from
+ /// <c>HKCU\...\AppModel\SystemAppData\{FamilyName}\{TaskId}\State</c>
/// (0=Disabled, 1=DisabledByUser, 2=Enabled, 4=EnabledByPolicy); when no state exists yet,
/// the manifest's Enabled attribute decides.
/// </summary>
@@ -483,9 +485,13 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
return null;
}
- /// <summary>Enables or disables a startup application by writing the StartupApproved registry flag.</summary>
+ /// <summary>
+ /// Enables or disables a startup application by writing the StartupApproved registry flag.
+ /// </summary>
/// <param name="app">The startup app to toggle.</param>
- /// <param name="enable"><see langword="true"/> to enable, <see langword="false"/> to disable.</param>
+ /// <param name="enable">
+ /// <see langword="true"/> to enable, <see langword="false"/> to disable.
+ /// </param>
/// <returns>The toggle outcome.</returns>
public Task<OpResult> ToggleStartupApp(StartupApp app, bool enable)
{
@@ -531,7 +537,6 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
private static OpResult ToggleRegistryStartupApp(StartupApp app, bool enable)
{
- // Parse RootKey and SubKey from app.PathOrKey
var firstSlash = app.PathOrKey.IndexOf('\\');
if (firstSlash < 0)
return OpResult.Fail(
@@ -550,7 +555,7 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
ServiceStrings.Format(ServiceStrings.StartupAppErrorUnsupportedLocation, app.Name)
);
- // Write the flag; 32-bit entries use the dedicated Run32/RunOnce32 subkeys
+ // 32-bit entries use the dedicated Run32/RunOnce32 subkeys
var approvedSubKeyPath = GetApprovedSubKeyPath(app.Location);
using var rootKey = RegistryKey.OpenBaseKey(hive.Value, RegistryView.Default);
@@ -564,9 +569,9 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
}
/// <summary>
- /// Builds the 12-byte StartupApproved value Task Manager writes: first 4 bytes = status flag
- /// (02 enabled / 03 disabled), trailing 8 bytes = FILETIME of the change (shown as the
- /// disable date in Task Manager).
+ /// Builds the 12-byte StartupApproved value Task Manager writes: first 4 bytes = status
+ /// flag (02 enabled / 03 disabled), trailing 8 bytes = FILETIME of the change (shown as
+ /// the disable date in Task Manager).
/// </summary>
private static byte[] BuildApprovedData(bool enable)
{
@@ -636,7 +641,10 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
return OpResult.Success();
}
- /// <summary>Retrieves all startup scheduled tasks from the Windows Task Scheduler, including their enabled state and icons.</summary>
+ /// <summary>
+ /// Retrieves all startup scheduled tasks from the Windows Task Scheduler, including their
+ /// enabled state and icons.
+ /// </summary>
/// <returns>A list of <see cref="StartupTask"/> instances sorted by name.</returns>
public Task<List<StartupTask>> GetStartupTasksAsync()
{
@@ -658,7 +666,6 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
.OrderBy(t => t.TaskName)
.ToList();
- // Extract icons from task commands
Parallel.ForEach(
tasks,
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount },
@@ -679,9 +686,13 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
});
}
- /// <summary>Enables or disables a startup scheduled task using the Task Scheduler API.</summary>
+ /// <summary>
+ /// Enables or disables a startup scheduled task using the Task Scheduler API.
+ /// </summary>
/// <param name="task">The startup task to toggle.</param>
- /// <param name="enable"><see langword="true"/> to enable, <see langword="false"/> to disable.</param>
+ /// <param name="enable">
+ /// <see langword="true"/> to enable, <see langword="false"/> to disable.
+ /// </param>
/// <returns>The toggle outcome.</returns>
public Task<OpResult> ToggleStartupTask(StartupTask task, bool enable)
{
@@ -733,9 +744,15 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
});
}
- /// <summary>Extracts the associated icon from an executable path or command string. Expands environment variables and searches PATH if needed.</summary>
+ /// <summary>
+ /// Extracts the associated icon from an executable path or command string. Expands
+ /// environment variables and searches PATH if needed.
+ /// </summary>
/// <param name="command">The command or file path to extract the icon from.</param>
- /// <returns>A frozen <see cref="BitmapSource"/> suitable for cross-thread UI binding, or <see langword="null"/> if the icon cannot be extracted.</returns>
+ /// <returns>
+ /// A frozen <see cref="BitmapSource"/> suitable for cross-thread UI binding, or
+ /// <see langword="null"/> if the icon cannot be extracted.
+ /// </returns>
/// <remarks>
/// Uses <c>SHGetFileInfo</c> with <c>SHGFI_LARGEICON</c> (48x48) for higher quality icons
/// where possible, falling back to <see cref="Icon.ExtractAssociatedIcon"/> (32x32) if the
@@ -778,7 +795,6 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
{
var path = command.Trim('\"');
- // expand environment variables (e.g., %USERPROFILE%, %ProgramFiles%)
path = Environment.ExpandEnvironmentVariables(path);
var exeIdx = path.IndexOf(".exe", StringComparison.OrdinalIgnoreCase);
if (exeIdx > 0)
@@ -786,7 +802,6 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
if (!File.Exists(path))
{
- // try to see if it is in PATH
if (!path.Contains('\\') && !path.Contains('/'))
{
path = GetFullPathFromEnvironment(path);
@@ -866,7 +881,10 @@ public class StartupManagerService(ILogger<StartupManagerService> logger)
internal static extern bool DestroyIcon(IntPtr hIcon);
}
- /// <summary>Resolves a file name to its full path by searching the directories listed in the PATH environment variable.</summary>
+ /// <summary>
+ /// Resolves a file name to its full path by searching the directories listed in the PATH
+ /// environment variable.
+ /// </summary>
/// <param name="fileName">The file name (e.g., "notepad.exe") to resolve.</param>
/// <returns>The full path if found, otherwise <see langword="null"/>.</returns>
public static string? GetFullPathFromEnvironment(string fileName)
diff --git a/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs b/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs
index 6a0b392..de3eefc 100644
--- a/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs
+++ b/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs
@@ -10,9 +10,9 @@ namespace optimizerDuck.UI.Behaviors;
public static class SmoothScrollBehavior
{
/// <summary>
- /// Global toggle for smooth scrolling. When disabled, all smooth scroll
- /// processing is skipped regardless of per-element IsEnabled, and all
- /// attached ScrollViewers have their CanContentScroll restored.
+ /// Gets or sets a value that indicates whether smooth scrolling is enabled globally. When
+ /// disabled, no element scrolls smoothly and every attached ScrollViewer has its
+ /// CanContentScroll restored.
/// </summary>
private static bool _globalEnabled = true;
public static bool GlobalEnabled
diff --git a/optimizerDuck/UI/Controls/FilledNavigationViewItem.cs b/optimizerDuck/UI/Controls/FilledNavigationViewItem.cs
index ba48f54..3133a11 100644
--- a/optimizerDuck/UI/Controls/FilledNavigationViewItem.cs
+++ b/optimizerDuck/UI/Controls/FilledNavigationViewItem.cs
@@ -3,8 +3,8 @@ using Wpf.Ui.Controls;
namespace optimizerDuck.UI.Controls;
/// <summary>
-/// A custom NavigationViewItem that automatically fills its SymbolIcon when active,
-/// regardless of the NavigationViewPaneDisplayMode.
+/// Represents a NavigationViewItem that fills its SymbolIcon while active, regardless of the
+/// NavigationViewPaneDisplayMode.
/// </summary>
public class FilledNavigationViewItem : NavigationViewItem
{
diff --git a/optimizerDuck/UI/Controls/StateBadge.xaml.cs b/optimizerDuck/UI/Controls/StateBadge.xaml.cs
index 2800390..f29d8b7 100644
--- a/optimizerDuck/UI/Controls/StateBadge.xaml.cs
+++ b/optimizerDuck/UI/Controls/StateBadge.xaml.cs
@@ -7,9 +7,8 @@ using Wpf.Ui.Controls;
namespace optimizerDuck.UI.Controls;
/// <summary>
-/// The chip that reports what an item's state is, kept to the look the cards already use,
-/// but wrapped in a control that answers the mouse so it can be clicked to open the record
-/// of what the last apply did.
+/// Represents the chip that reports an item's state, as a control that answers the mouse so
+/// it can be clicked to open the record of the last apply.
/// </summary>
public partial class StateBadge : UserControl
{
@@ -78,7 +77,10 @@ public partial class StateBadge : UserControl
set => SetValue(TextProperty, value);
}
- /// <summary>Whether the chip is being pressed, which only changes how it looks.</summary>
+ /// <summary>
+ /// Gets or sets a value that indicates whether the chip is pressed, which only changes
+ /// how it looks.
+ /// </summary>
public bool IsPressed
{
get => (bool)GetValue(IsPressedProperty);
diff --git a/optimizerDuck/UI/Dialogs/LegalDialog.xaml.cs b/optimizerDuck/UI/Dialogs/LegalDialog.xaml.cs
index edee05b..ee376fd 100644
--- a/optimizerDuck/UI/Dialogs/LegalDialog.xaml.cs
+++ b/optimizerDuck/UI/Dialogs/LegalDialog.xaml.cs
@@ -29,8 +29,7 @@ namespace optimizerDuck.UI.Dialogs
return;
}
- // Fallback for design-time or direct new LegalDialog() from MainWindow
- // Try to resolve from App.Host
+ // Fall back to the container when the dialog is opened without a view model.
try
{
if (Application.Current is App app && app.AppHost != null)
@@ -42,7 +41,7 @@ namespace optimizerDuck.UI.Dialogs
}
catch
{
- // ignore for designer
+ // The designer has no application host.
}
}
}
diff --git a/optimizerDuck/UI/Dialogs/OptimizationDetailsDialog.xaml.cs b/optimizerDuck/UI/Dialogs/OptimizationDetailsDialog.xaml.cs
index 82972c2..c2584a7 100644
--- a/optimizerDuck/UI/Dialogs/OptimizationDetailsDialog.xaml.cs
+++ b/optimizerDuck/UI/Dialogs/OptimizationDetailsDialog.xaml.cs
@@ -2,9 +2,6 @@
namespace optimizerDuck.UI.Dialogs;
-/// <summary>
-/// Interaction logic for OptimizationMoreInfoDialog.xaml
-/// </summary>
public partial class OptimizationDetailsDialog : UserControl
{
public OptimizationDetailsDialog()
diff --git a/optimizerDuck/UI/Dialogs/ProcessingDialog.xaml.cs b/optimizerDuck/UI/Dialogs/ProcessingDialog.xaml.cs
index dba4ecb..0f83f99 100644
--- a/optimizerDuck/UI/Dialogs/ProcessingDialog.xaml.cs
+++ b/optimizerDuck/UI/Dialogs/ProcessingDialog.xaml.cs
@@ -7,9 +7,6 @@ using Wpf.Ui.TaskBar;
namespace optimizerDuck.UI.Dialogs;
-/// <summary>
-/// Interaction logic for ProcessingOptimizationDialog.xaml
-/// </summary>
public partial class ProcessingDialog : UserControl
{
private Window? _trackedWindow;
diff --git a/optimizerDuck/UI/Dialogs/ScheduledTaskCreateDialog.xaml.cs b/optimizerDuck/UI/Dialogs/ScheduledTaskCreateDialog.xaml.cs
index b630106..176af51 100644
--- a/optimizerDuck/UI/Dialogs/ScheduledTaskCreateDialog.xaml.cs
+++ b/optimizerDuck/UI/Dialogs/ScheduledTaskCreateDialog.xaml.cs
@@ -26,7 +26,6 @@ public partial class ScheduledTaskCreateDialog : UserControl
var fullPath = folderPath == "\\" ? $"\\{name}" : $"{folderPath}\\{name}";
- // Parse daily time
var time = TimeSpan.Zero;
if (
DailyTriggerCheck.IsChecked == true
diff --git a/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.cs b/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.cs
index 34b08b4..7edb3a0 100644
--- a/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Customize/CustomizeItemViewModel.cs
@@ -44,9 +44,7 @@ public partial class CustomizeItemViewModel(
public SymbolRegular Icon => setting.Icon;
/// <summary>
- /// Computed so grouped section headers, filters and bindings always re-resolve
- /// against the current culture, even when a parent handler rebuilds sections
- /// before this item is notified.
+ /// Gets the setting description, resolved against the current culture on every read.
/// </summary>
public string Description => setting.Description;
@@ -74,13 +72,19 @@ public partial class CustomizeItemViewModel(
public CustomizeRecommendationResult? Recommendation => setting.GetRecommendation();
public bool HasRecommendation => Recommendation != null;
- /// <summary>Gets whether this setting is unsupported on the current system.</summary>
+ /// <summary>
+ /// Gets a value that indicates whether the setting is unsupported on the current system.
+ /// </summary>
public bool IsUnsupported => ConditionResult.IsBlocking;
- /// <summary>Gets the localized condition failure title, or <c>null</c>.</summary>
+ /// <summary>
+ /// Gets the localized condition failure title, or <see langword="null" />.
+ /// </summary>
public string? ConditionTitle => ConditionResult.Title;
- /// <summary>Gets the localized condition failure description, or <c>null</c>.</summary>
+ /// <summary>
+ /// Gets the localized condition failure description, or <see langword="null" />.
+ /// </summary>
public string? ConditionDescription => ConditionResult.Description;
public string? RecommendationStateDisplay =>
@@ -107,8 +111,8 @@ public partial class CustomizeItemViewModel(
Recommendation != null ? Loc.Instance[Recommendation.ReasonTranslationKey] : null;
/// <summary>
- /// Loads the setting's current state, effective options and value, then subscribes
- /// to registry changes. Registry I/O runs on the thread pool.
+ /// Loads the setting state, options and value, then subscribes to registry changes. The
+ /// registry reads run on the thread pool.
/// </summary>
public async Task LoadStateAsync()
{
@@ -130,15 +134,12 @@ public partial class CustomizeItemViewModel(
}
catch (Exception ex)
{
- // keep state unloaded on read failure instead of showing it as off.
+ // Leave the state unloaded on a failed read, so the toggle does not read as off.
_logger.LogWarning(ex, "Failed to load customize setting {Setting}", setting.LogName());
}
}
- /// <summary>
- /// Publishes the given options only when the list actually changed, so the ComboBox
- /// isn't needlessly rebuilt.
- /// </summary>
+ /// <summary>Publishes the options only when the list of values changed.</summary>
private void UpdateOptions(IReadOnlyList<SettingOption>? options)
{
if (HasSameOptionValues(Options, options))
@@ -148,8 +149,7 @@ public partial class CustomizeItemViewModel(
}
/// <summary>
- /// Re-publishes dropdown options so their display text re-resolves in the
- /// new language. Option values are unchanged; only <c>Display</c> refreshes.
+ /// Re-publishes the options so their display text re-resolves in the new language.
/// </summary>
protected override void OnLanguageChanged(CultureInfo newCulture)
{
@@ -206,17 +206,15 @@ public partial class CustomizeItemViewModel(
if (!_watchedPaths.Contains(path))
return;
- // The watcher raises on a background thread, so run the refresh on the UI thread.
- // UiThread.InvokeAsync resolves to the Func<Task> overload (the method returns
- // Task), so the refresh task is observed rather than fire-and-forgotten. When no
- // WPF Application exists (unit tests), it runs inline instead.
+ // The watcher raises on a background thread, so the refresh is marshalled to the UI
+ // thread. UiThread.InvokeAsync resolves to the Func<Task> overload, so the refresh task
+ // is observed. Without a WPF Application (unit tests) it runs inline.
_ = UiThread.InvokeAsync(RefreshFromRegistryAsync);
}
/// <summary>
- /// Re-reads the live registry state and republishes the effective options and the
- /// selection value. Marshalled to the UI thread by <see cref="OnRegistryKeyChanged"/>
- /// when a watched key changes; also called directly from tests.
+ /// Re-reads the live registry state and republishes the options and the selection value.
+ /// Runs on the UI thread when called from <see cref="OnRegistryKeyChanged"/>.
/// </summary>
internal async Task RefreshFromRegistryAsync()
{
@@ -225,7 +223,7 @@ public partial class CustomizeItemViewModel(
if (_executor.IsApplying)
return;
- // Only the refresh bookkeeping runs on the UI thread; the reads stay off it.
+ // The property assignments run on the UI thread; the registry reads stay off it.
IsEnabled = await Task.Run(() =>
setting.GetStateWithRetryAsync(maxRetries: 4, delayMs: 80)
);
@@ -246,7 +244,8 @@ public partial class CustomizeItemViewModel(
[RelayCommand(CanExecute = nameof(CanToggle))]
private void Toggle()
{
- // the first call marks the executor busy synchronously, so a same-tick second click is ignored.
+ // The first call marks the executor busy synchronously, so a same-tick second click
+ // is ignored.
if (_executor.IsApplying)
return;
_ = _executor.ApplyWithDebounceAsync(!IsEnabled, ApplyCoreAsync, debounceMs: 0);
@@ -305,7 +304,7 @@ public partial class CustomizeItemViewModel(
CurrentValue = current;
}
- // only flag reboot when the value was actually written.
+ // Flag the reboot prompt only when the value was written.
if (applyResult.Ok && Application.Current is App app)
app.HasPendingChanges = true;
}
diff --git a/optimizerDuck/UI/ViewModels/Dialogs/ChangeRecordStepViewModel.cs b/optimizerDuck/UI/ViewModels/Dialogs/ChangeRecordStepViewModel.cs
index 10db470..45bc3a5 100644
--- a/optimizerDuck/UI/ViewModels/Dialogs/ChangeRecordStepViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Dialogs/ChangeRecordStepViewModel.cs
@@ -6,13 +6,12 @@ using Wpf.Ui.Controls;
namespace optimizerDuck.UI.ViewModels.Dialogs;
-/// <summary>One fact about a step, shown as a chip with its own icon and label.</summary>
+/// <summary>Represents one fact about a step, shown as a chip.</summary>
public sealed record RecordFieldViewModel(SymbolRegular Icon, string Label, string Value);
/// <summary>
-/// One recorded step, as the record shows it. The step keeps its English description and its
-/// values for the log; here the row is rebuilt from the structured facts so it says what the
-/// run actually did, in the UI language, and never claims more than that.
+/// Represents one recorded step, rebuilt from its structured facts so the row reads in the
+/// UI language. The step keeps the English description and values the log uses.
/// </summary>
public sealed class ChangeRecordStepViewModel
{
@@ -36,8 +35,8 @@ public sealed class ChangeRecordStepViewModel
Description = step.Description;
Detail = step.Error;
- // Only a step that changed something is phrased as an action. A step that wrote nothing
- // states what it found instead, so the row can never read as if it had written.
+ // A step that changed nothing is never phrased as an action, so the row cannot read as
+ // if it had written.
var row = ChangeDetailPresentation.For(
ChangeDetailCodec.Decode(step),
step.Kind,
@@ -49,8 +48,9 @@ public sealed class ChangeRecordStepViewModel
Fields = BuildFields(row, step);
}
- /// <summary>Builds a row straight from a step that is still in memory, for the failure list.</summary>
- /// <param name="change">The recorded step.</param>
+ /// <summary>Builds a row from a change that is still in memory.</summary>
+ /// <param name="change">The change to build a row for.</param>
+ /// <param name="operation">The run the row belongs to.</param>
public ChangeRecordStepViewModel(
Change change,
ChangeRecordOperation operation = ChangeRecordOperation.Apply
@@ -60,22 +60,25 @@ public sealed class ChangeRecordStepViewModel
ErrorDetail = change.ErrorDetail;
}
- /// <summary>The step's position in the run, for the failure list.</summary>
+ /// <summary>Gets the step's position in the run.</summary>
public int Index { get; }
- /// <summary>The raw failure text, kept for a support report.</summary>
+ /// <summary>Gets the raw failure text.</summary>
public string? ErrorDetail { get; }
- /// <summary>Whether the raw failure text is worth showing.</summary>
+ /// <summary>Gets a value that indicates whether there is raw failure text to show.</summary>
public bool HasErrorDetail => !string.IsNullOrWhiteSpace(ErrorDetail);
- /// <summary>Which run this row belongs to, which decides the wording of the step.</summary>
+ /// <summary>Gets the run this row belongs to, which decides the wording of the step.</summary>
public ChangeRecordOperation Operation { get; }
- /// <summary>The kind of step, which decides the accent colour of the row.</summary>
+ /// <summary>Gets the kind of step, which decides the accent colour of the row.</summary>
public ChangeKind Kind { get; }
- /// <summary>Whether the step succeeded, which decides whether it is shown as a failure.</summary>
+ /// <summary>
+ /// Gets a value that indicates whether the step succeeded, which decides whether it is
+ /// shown as a failure.
+ /// </summary>
public bool Ok { get; }
public SymbolRegular Icon { get; }
@@ -84,35 +87,36 @@ public sealed class ChangeRecordStepViewModel
public string Name { get; }
- /// <summary>The English description written for the log, kept as the last resort.</summary>
+ /// <summary>Gets the English description written for the log.</summary>
public string Description { get; }
/// <summary>
- /// Whether the row has nothing but the log text to show. A row that states an action or
- /// carries facts says everything it can, and the English line the log uses would only
- /// repeat it, or worse, describe work the step never did.
+ /// Gets a value that indicates whether the row has nothing but the log text to show. A
+ /// row that states an action or carries facts would only repeat the English log line.
/// </summary>
public bool ShowDescription => !HasOperation && !HasFields;
- /// <summary>What the step did, in the UI language, when the step changed something.</summary>
+ /// <summary>Gets what the step did in the UI language when it changed something.</summary>
public string? OperationLabel { get; }
public bool HasOperation => !string.IsNullOrEmpty(OperationLabel);
- /// <summary>The facts of the step: what it touched, the values around it, and how it went.</summary>
+ /// <summary>
+ /// Gets the facts of the step: what it touched, the values around it, and how it went.
+ /// </summary>
public IReadOnlyList<RecordFieldViewModel> Fields { get; }
public bool HasFields => Fields.Count > 0;
- /// <summary>The failure message, when the step failed.</summary>
+ /// <summary>Gets the failure message when the step failed.</summary>
public string? Detail { get; }
public bool HasDetail => !string.IsNullOrWhiteSpace(Detail);
/// <summary>
- /// The facts of the operation, worded for the user, followed by how the step went: when it
- /// ran, how long it took, which attempt it is and the code behind a failure. A fact the
- /// record does not carry leaves its chip out rather than showing an empty one.
+ /// Builds the facts of the operation, worded for the user, followed by how the step went:
+ /// when it ran, how long it took, which attempt it is and the code behind a failure. A
+ /// fact the record does not carry leaves no chip behind.
/// </summary>
private static List<RecordFieldViewModel> BuildFields(
ChangeDetailRow row,
@@ -167,8 +171,8 @@ public sealed class ChangeRecordStepViewModel
}
/// <summary>
- /// A duration as it is read at a glance: milliseconds while the step was quick, and seconds
- /// once it was not. Shared with the record's own facts, so a run and its steps read alike.
+ /// Formats a duration as it is read at a glance: milliseconds while the step was quick,
+ /// and seconds once it was not.
/// </summary>
internal static string DescribeDuration(long elapsedMs)
{
@@ -178,9 +182,8 @@ public sealed class ChangeRecordStepViewModel
}
/// <summary>
- /// The name a provider records is the English one the log uses. The row says the same thing
- /// in the UI language, and keeps a name it does not know yet as it is, so a new provider
- /// shows up instead of showing nothing.
+ /// Translates the English provider name a step records into the UI language, and keeps a
+ /// name it does not know yet, so a new provider still shows up.
/// </summary>
private static string ProviderName(string name)
{
diff --git a/optimizerDuck/UI/ViewModels/Dialogs/OptimizationDetailsViewModel.cs b/optimizerDuck/UI/ViewModels/Dialogs/OptimizationDetailsViewModel.cs
index 3e938dd..e43e1e0 100644
--- a/optimizerDuck/UI/ViewModels/Dialogs/OptimizationDetailsViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Dialogs/OptimizationDetailsViewModel.cs
@@ -26,17 +26,15 @@ public partial class OptimizationDetailsViewModel(
public IOptimization Optimization { get; } = optimization;
/// <summary>
- /// What the item's last apply did, straight from the record on disk. Read once: a dialog
- /// does not need to watch the file, and an item applied while it is open is reloaded by
- /// opening it again.
+ /// Holds the item's last recorded run, read once when the dialog is constructed.
/// </summary>
private readonly ChangeRecord? _record = ChangeRecordStore.TryRead(optimization.Id);
private IReadOnlyList<ChangeRecordStepViewModel>? _steps;
private IReadOnlyList<RecordFieldViewModel>? _recordFacts;
/// <summary>
- /// The steps of the recorded run, worded for the run they belong to, so a revert reads as
- /// what it put back.
+ /// Gets the steps of the recorded run, worded for the run they belong to so a revert
+ /// reads as what it put back.
/// </summary>
public IReadOnlyList<ChangeRecordStepViewModel> Steps =>
_steps ??= [
@@ -46,12 +44,12 @@ public partial class OptimizationDetailsViewModel(
)),
];
- /// <summary>Whether there is a record to show at all.</summary>
+ /// <summary>Gets a value that indicates whether a record is available to show.</summary>
public bool HasRecord => Steps.Count > 0;
/// <summary>
- /// Which run this record describes and when it ran, so the dialog says up front whether the
- /// last thing that happened to this item was an apply or a revert.
+ /// Gets a line naming the run the record describes and when it ran, so the dialog says up
+ /// front whether the item was last applied or reverted.
/// </summary>
public string RecordHeadline =>
_record switch
@@ -64,18 +62,20 @@ public partial class OptimizationDetailsViewModel(
_ => string.Empty,
};
- /// <summary>Whether the record describes a revert, which the header marks.</summary>
+ /// <summary>Gets a value that indicates whether the record describes a revert.</summary>
public bool RecordIsRevert => _record?.Operation == ChangeRecordOperation.Revert;
/// <summary>
- /// What the run itself was: the build that wrote the record and the Windows version it ran
- /// on, so a record read out of the app states its own context, and how long the run took. A
- /// record written by an earlier build carries none of these and shows no chip for them.
+ /// Gets the facts of the run itself: the build that wrote the record, the Windows version
+ /// it ran on and how long it took. A record written by an earlier build carries none of
+ /// these and shows no chip for them.
/// </summary>
public IReadOnlyList<RecordFieldViewModel> RecordFacts =>
_recordFacts ??= BuildRecordFacts(_record);
- /// <summary>Whether the record carries any fact about the run itself.</summary>
+ /// <summary>
+ /// Gets a value that indicates whether the record carries any fact about the run itself.
+ /// </summary>
public bool HasRecordFacts => RecordFacts.Count > 0;
private static IReadOnlyList<RecordFieldViewModel> BuildRecordFacts(ChangeRecord? record)
diff --git a/optimizerDuck/UI/ViewModels/Dialogs/OptimizationResultDialogViewModel.cs b/optimizerDuck/UI/ViewModels/Dialogs/OptimizationResultDialogViewModel.cs
index 8751d78..181d3f5 100644
--- a/optimizerDuck/UI/ViewModels/Dialogs/OptimizationResultDialogViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Dialogs/OptimizationResultDialogViewModel.cs
@@ -12,10 +12,9 @@ public class OptimizationResultDialogViewModel : LocalizedObject
ChangeRecordOperation operation = ChangeRecordOperation.Apply
)
{
- // The rows are built here, not in the provider: a failure list reads in the UI language,
- // and only falls back to the English text written for the log when a step carries nothing
- // else to show. The run the steps belong to decides whether they read as what was applied
- // or as what was put back.
+ // The rows are built here so a failure list reads in the UI language, falling back to the
+ // English log text only when a step carries nothing else to show. The run the steps
+ // belong to decides whether they read as applied or as put back.
FailedSteps = new ObservableCollection<ChangeRecordStepViewModel>(
failedSteps.Select(step => new ChangeRecordStepViewModel(step, operation))
);
diff --git a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.cs b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.cs
index 6427771..5286359 100644
--- a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.cs
+++ b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.cs
@@ -33,7 +33,7 @@ using TextBlock = Wpf.Ui.Controls.TextBlock;
public partial class OptimizationCategoryViewModel
{
/// <summary>
- /// Run a long-running action with a processing dialog.
+ /// Runs a long-running action with a processing dialog.
/// </summary>
private async Task<T> RunWithProcessingDialogAsync<T>(
IOptimization optimization,
@@ -61,7 +61,8 @@ public partial class OptimizationCategoryViewModel
}
/// <summary>
- /// Handle failed steps for an optimization.
+ /// Handles the failed steps of one apply or revert, offering a retry while a failed step
+ /// can still be re-run.
/// </summary>
private async Task<FailureResolutionOutcome> HandleRetryableFailuresAsync(
IOptimization optimization,
@@ -75,9 +76,9 @@ public partial class OptimizationCategoryViewModel
var remainingFailedSteps = failedSteps.OrderBy(s => s.Index).ToList();
while (remainingFailedSteps.Count > 0)
{
- // Only offer Retry when at least one failed step can actually be re-run. A
- // non-retryable failure (e.g. access denied on a Windows-protected service)
- // must not loop the dialog with a button that cannot change anything.
+ // Only offer Retry when a failed step can be re-run. A non-retryable failure
+ // (e.g. access denied on a Windows-protected service) must not loop the dialog
+ // with a button that cannot change anything.
var canRetry = remainingFailedSteps.Any(s => s.Retry != null);
var dialogViewModel = new OptimizationResultDialogViewModel(
remainingFailedSteps,
@@ -268,9 +269,6 @@ public partial class OptimizationCategoryViewModel
}
}
- /// <summary>
- /// Handles the restore point dialog.
- /// </summary>
private async Task<(bool Proceed, bool RestorePointCreated)> HandleRestorePointAsync()
{
var dialogContent = new RestorePointDialog();
@@ -382,7 +380,9 @@ public partial class OptimizationCategoryViewModel
return (true, false);
}
- /// <summary>Binds a dialog property to a localization key so it follows runtime language changes.</summary>
+ /// <summary>
+ /// Binds a dialog property to a localization key so it follows runtime language changes.
+ /// </summary>
private static void BindLocalized(ContentDialog dialog, DependencyProperty property, string key)
{
dialog.SetBinding(
diff --git a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs
index 7a036f2..dce73b3 100644
--- a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs
@@ -88,7 +88,6 @@ public partial class OptimizationCategoryViewModel : ViewModel
[ObservableProperty]
private ObservableCollection<IOptimization> _optimizations = [];
- // Search, Filter, Sort
[ObservableProperty]
private string _searchText = string.Empty;
@@ -130,7 +129,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
}
catch (OperationCanceledException)
{
- // debounced
+ // A newer keystroke cancelled the debounce delay.
}
},
token
@@ -151,9 +150,9 @@ public partial class OptimizationCategoryViewModel : ViewModel
#region Commands
/// <summary>
- /// Toggles the optimization (apply if not applied, revert if applied).
+ /// Applies the optimization when it is not applied and reverts it when it is.
/// </summary>
- /// <param name="optimization">The optimization to toggle.</param>
+ /// <param name="optimization">The optimization to apply or revert.</param>
[RelayCommand(CanExecute = nameof(CanToggleOptimization))]
private async Task ToggleOptimizationAsync(IOptimization optimization)
{
@@ -202,7 +201,6 @@ public partial class OptimizationCategoryViewModel : ViewModel
/// <summary>
/// Ensures a restore point is created before modifying system settings.
/// </summary>
- /// <returns>(canProceed, restorePointCreated).</returns>
private async Task<(bool Proceed, bool RestorePointCreated)> EnsureRestorePointAsync(
IOptimization optimization,
bool wasApplied
@@ -226,7 +224,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
/// Applies an optimization with progress reporting and retry handling.
/// </summary>
/// <param name="optimization">The optimization to apply.</param>
- /// <param name="restorePointCreated">Whether a system restore point was created beforehand.</param>
+ /// <param name="restorePointCreated">Whether a restore point was created beforehand.</param>
private async Task ApplyOptimizationAsync(IOptimization optimization, bool restorePointCreated)
{
_logger.LogInformation(
@@ -240,7 +238,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
p => _optimizationService.ApplyAsync(optimization, p)
);
- // Complete failure: can't retry
+ // A complete failure leaves nothing to retry.
if (applyResult.Status == OptimizationSuccessResult.Failed)
{
ShowOperationOutcomeSnackbar(
@@ -254,8 +252,8 @@ public partial class OptimizationCategoryViewModel : ViewModel
return;
}
- // Nothing to do changed nothing, so the card is marked for this session and the
- // pending changes prompt stays untouched.
+ // Nothing to do changes nothing: the card is marked for this session and the pending
+ // changes prompt stays untouched.
optimization.State.IsAlreadyOptimal =
applyResult.Status == OptimizationSuccessResult.NothingToDo;
@@ -308,7 +306,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
/// Reverts an optimization with progress reporting and retry handling.
/// </summary>
/// <param name="optimization">The optimization to revert.</param>
- /// <param name="restorePointCreated">Whether a system restore point was created beforehand.</param>
+ /// <param name="restorePointCreated">Whether a restore point was created beforehand.</param>
private async Task RevertOptimizationAsync(IOptimization optimization, bool restorePointCreated)
{
_logger.LogInformation(
@@ -322,7 +320,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
p => _optimizationService.RevertAsync(optimization, p)
);
- // Reverting means the machine no longer matches, whatever an earlier apply reported.
+ // The revert invalidates the applied mark, whatever the last apply reported.
optimization.State.IsAlreadyOptimal = false;
if (Application.Current is App app)
@@ -351,9 +349,6 @@ public partial class OptimizationCategoryViewModel : ViewModel
);
}
- /// <summary>
- /// Updates optimization state and notifies the UI.
- /// </summary>
private static async Task FinalizeOperationAsync(IOptimization optimization)
{
await OptimizationService.UpdateOptimizationStateAsync(optimization);
@@ -389,9 +384,8 @@ public partial class OptimizationCategoryViewModel : ViewModel
}
/// <summary>
- /// Hides the unsupported condition state for this session, returning the
- /// optimization to its normal card so the user can apply it anyway.
- /// The hide choice is not persisted.
+ /// Hides the unsupported condition state for this session, so the optimization shows its
+ /// normal card and can be applied anyway. The hide choice is not persisted.
/// </summary>
[RelayCommand]
private void HideCondition(IOptimization optimization)
@@ -444,9 +438,8 @@ public partial class OptimizationCategoryViewModel : ViewModel
{
foreach (var optimization in _category.Optimizations)
{
- // Listen to the optimization's own PropertyChanged instead of the nested
- // State instance so a replaced State (BaseOptimization re-raises the
- // change) can never orphan this subscription.
+ // Subscribing to the optimization rather than to its nested State keeps this
+ // subscription alive when BaseOptimization replaces the State instance.
if (optimization is INotifyPropertyChanged notify)
notify.PropertyChanged += OnOptimizationStateChanged;
_allOptimizations.Add(optimization);
@@ -471,9 +464,8 @@ public partial class OptimizationCategoryViewModel : ViewModel
}
/// <summary>
- /// Re-evaluates every optimization's condition and re-applies the filter when the
- /// system snapshot is refreshed (e.g. hardware changed) or the UI language changes.
- /// Marshalled to the UI thread by <see cref="UiThread"/>.
+ /// Re-evaluates every condition and re-applies the filter when the system snapshot is
+ /// refreshed.
/// </summary>
private void OnSnapshotRefreshed(object? sender, SystemInfo snapshot) =>
ReEvaluateConditions(snapshot);
@@ -500,6 +492,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
OnPropertyChanged(nameof(HasAppliedOptimizations));
}
+ /// <inheritdoc />
public override Task OnNavigatedToAsync()
{
_systemInfoService.SnapshotRefreshed += OnSnapshotRefreshed;
@@ -507,6 +500,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
return base.OnNavigatedToAsync();
}
+ /// <inheritdoc />
public override Task OnNavigatedFromAsync()
{
_systemInfoService.SnapshotRefreshed -= OnSnapshotRefreshed;
@@ -529,13 +523,12 @@ public partial class OptimizationCategoryViewModel : ViewModel
}
/// <summary>
- /// Apply current filters to the optimizations.
+ /// Applies the current search, risk filter and sort to the optimizations.
/// </summary>
private void ApplyFilter()
{
var query = _allOptimizations.AsEnumerable();
- // Search
if (!string.IsNullOrWhiteSpace(SearchText))
{
var search = SearchText.Trim();
@@ -545,7 +538,6 @@ public partial class OptimizationCategoryViewModel : ViewModel
);
}
- // Filter by risk
query = SelectedRiskFilterIndex switch
{
1 => query.Where(o => o.Risk == OptimizationRisk.Safe),
@@ -554,17 +546,15 @@ public partial class OptimizationCategoryViewModel : ViewModel
_ => query,
};
- // Hide applied and already optimal items
if (HideApplied)
query = query.Where(o => !o.State.IsApplied && !o.State.IsAlreadyOptimal);
- // Sort
query = SelectedSortByIndex switch
{
1 => query.OrderBy(o => o.Name),
2 => query.OrderBy(o => o.Risk),
- 3 => query.OrderByDescending(o => o.State.IsApplied ? 1 : 0), // Status
- _ => query.OrderBy(o => o.Risk).ThenByDescending(o => o.State.IsApplied ? 1 : 0), // Risk & Status (default)
+ 3 => query.OrderByDescending(o => o.State.IsApplied ? 1 : 0),
+ _ => query.OrderBy(o => o.Risk).ThenByDescending(o => o.State.IsApplied ? 1 : 0),
};
var filtered = query.ToList();
diff --git a/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs
index ad251ef..da7e88c 100644
--- a/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs
@@ -12,8 +12,8 @@ using optimizerDuck.Services.UI;
using optimizerDuck.UI.Dialogs;
using optimizerDuck.UI.ViewModels.Dialogs;
using Wpf.Ui;
-using Wpf.Ui.Extensions;
using Wpf.Ui.Controls;
+using Wpf.Ui.Extensions;
using AppXPackage = optimizerDuck.Domain.Optimizations.Models.Bloatware.AppXPackage;
namespace optimizerDuck.UI.ViewModels.Pages;
@@ -26,7 +26,6 @@ public partial class BloatwareViewModel : ViewModel
private readonly IContentDialogService _contentDialogService;
private readonly ILogger<BloatwareViewModel> _logger;
- // Search, Filter, Sort
[ObservableProperty]
private string _searchText = string.Empty;
@@ -91,6 +90,7 @@ public partial class BloatwareViewModel : ViewModel
ApplyFilter();
}
+ /// <inheritdoc />
public override async Task OnNavigatedToAsync()
{
await base.OnNavigatedToAsync();
@@ -118,7 +118,6 @@ public partial class BloatwareViewModel : ViewModel
{
var query = _allPackages.AsEnumerable();
- // Search
if (!string.IsNullOrWhiteSpace(SearchText))
{
var search = SearchText.Trim();
@@ -129,7 +128,6 @@ public partial class BloatwareViewModel : ViewModel
);
}
- // Filter by risk
query = SelectedRiskFilterIndex switch
{
1 => query.Where(p => p.Risk == AppRisk.Safe),
@@ -137,7 +135,6 @@ public partial class BloatwareViewModel : ViewModel
_ => query,
};
- // Sort
query = SelectedSortByIndex switch
{
0 => query.OrderBy(p => p.Name),
diff --git a/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.cs
index f967fbd..d4ac126 100644
--- a/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/CustomizeCategoryViewModel.cs
@@ -95,8 +95,7 @@ public partial class CustomizeCategoryViewModel : ViewModel
"System snapshot is unavailable; conditions fail open for this session"
);
- // Keep all collection/UI mutation on the UI thread, consistent with the
- // optimization category view model.
+ // All collection and UI mutation stays on the UI thread.
await UiThread.InvokeAsync(async () =>
{
EvaluateConditions(snapshot);
@@ -124,9 +123,8 @@ public partial class CustomizeCategoryViewModel : ViewModel
}
/// <summary>
- /// Recomputes the unsupported partition from the master settings list so settings that
- /// fail their condition are shown under the expander instead of the main category
- /// content. Idempotent: safe to call repeatedly as conditions are re-evaluated.
+ /// Recomputes the unsupported partition from the master list so settings that fail their
+ /// condition show under the expander. Idempotent: safe to call as conditions change.
/// </summary>
private void PartitionUnsupportedSettings()
{
@@ -135,8 +133,7 @@ public partial class CustomizeCategoryViewModel : ViewModel
}
/// <summary>
- /// Groups the unsupported settings into the same section structure used by the main
- /// category content, so the expander can reuse the existing card templates.
+ /// Builds the unsupported sections so the expander reuses the main card templates.
/// </summary>
private void BuildUnsupportedSections()
{
@@ -146,8 +143,8 @@ public partial class CustomizeCategoryViewModel : ViewModel
}
/// <summary>
- /// Groups settings into ordered sections, placing settings without a section under
- /// the "Other" header. Shared by the main list and the unsupported expander.
+ /// Groups settings into sections, placing settings without a section under the "Other"
+ /// header last.
/// </summary>
private static ObservableCollection<CustomizeSection> GroupIntoSections(
IEnumerable<CustomizeItemViewModel> settings
@@ -177,6 +174,7 @@ public partial class CustomizeCategoryViewModel : ViewModel
});
}
+ /// <inheritdoc />
public override Task OnNavigatedToAsync()
{
ApplicationThemeManager.Changed -= OnThemeChanged;
@@ -187,6 +185,7 @@ public partial class CustomizeCategoryViewModel : ViewModel
return base.OnNavigatedToAsync();
}
+ /// <inheritdoc />
public override Task OnNavigatedFromAsync()
{
_systemInfoService.SnapshotRefreshed -= OnSnapshotRefreshed;
@@ -195,16 +194,14 @@ public partial class CustomizeCategoryViewModel : ViewModel
}
/// <summary>
- /// Re-evaluates every condition and rebuilds the filtered/unsupported partitions
- /// when the system snapshot is refreshed (e.g. hardware changed) or the UI
- /// language changes. Marshalled to the UI thread by <see cref="UiThread"/>.
+ /// Re-evaluates every condition and rebuilds the partitions when the system snapshot is
+ /// refreshed.
/// </summary>
private void OnSnapshotRefreshed(object? sender, SystemInfo snapshot) =>
ReEvaluateConditions(snapshot);
/// <summary>
- /// Re-evaluates every condition and rebuilds the filtered/unsupported partitions
- /// when the UI language changes. Marshalled to the UI thread by <see cref="UiThread"/>.
+ /// Re-evaluates every condition and rebuilds the partitions on a language change.
/// </summary>
protected override void OnLanguageChanged(CultureInfo newCulture) =>
ReEvaluateConditions(_systemInfoService.Snapshot);
diff --git a/optimizerDuck/UI/ViewModels/Pages/CustomizeViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/CustomizeViewModel.cs
index 60971cf..7847743 100644
--- a/optimizerDuck/UI/ViewModels/Pages/CustomizeViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/CustomizeViewModel.cs
@@ -74,9 +74,8 @@ public partial class CustomizeCategoryItemViewModel : LocalizedObject
private Type? _categoryType;
/// <summary>
- /// The category whose display strings this card forwards. Set at construction
- /// time; <see cref="Name" /> and <see cref="Description" /> re-resolve on every
- /// culture change.
+ /// Gets or sets the category whose name and description this card forwards. The forwarded
+ /// strings re-resolve on every culture change.
/// </summary>
public ICustomizeCategory? Source { get; set; }
diff --git a/optimizerDuck/UI/ViewModels/Pages/DashboardViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/DashboardViewModel.cs
index f5aa950..5445800 100644
--- a/optimizerDuck/UI/ViewModels/Pages/DashboardViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/DashboardViewModel.cs
@@ -114,6 +114,7 @@ public partial class DashboardViewModel : ViewModel
ApplicationThemeManager.Changed += OnThemeChanged;
}
+ /// <inheritdoc />
public override async Task OnNavigatedToAsync()
{
await base.OnNavigatedToAsync();
@@ -125,6 +126,7 @@ public partial class DashboardViewModel : ViewModel
_updateTimer.Start();
}
+ /// <inheritdoc />
public override Task OnNavigatedFromAsync()
{
_updateTimer.Stop();
@@ -310,8 +312,8 @@ public partial class DashboardViewModel : ViewModel
}
/// <summary>
- /// 2s live tick. Runs on the UI thread and calls only the cheap cached
- /// service paths (no WMI, no Task.Run): a slow scan can never overlap ticks.
+ /// Runs on the two second tick, on the UI thread and through the cheap cached service
+ /// paths, so a slow scan can never overlap ticks.
/// </summary>
private void OnUpdateTick(object? sender, EventArgs e)
{
diff --git a/optimizerDuck/UI/ViewModels/Pages/DiskCleanupViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/DiskCleanupViewModel.cs
index 8a5e78a..5cad0ad 100644
--- a/optimizerDuck/UI/ViewModels/Pages/DiskCleanupViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/DiskCleanupViewModel.cs
@@ -35,7 +35,6 @@ public partial class DiskCleanupViewModel(
private List<CleanupItem> _originalOrder = [];
- // Sort
[ObservableProperty]
private int _selectedSortByIndex; // 0=Size, 1=Name, 2=Path
@@ -93,6 +92,7 @@ public partial class DiskCleanupViewModel(
}
}
+ /// <inheritdoc />
public override async Task OnNavigatedToAsync()
{
await base.OnNavigatedToAsync();
@@ -228,7 +228,6 @@ public partial class DiskCleanupViewModel(
var freedBytes = await diskCleanupService.CleanSelectedAsync(CleanupItems);
sw.Stop();
- // Deselect all items after successful clean
foreach (var item in CleanupItems)
item.IsSelected = false;
diff --git a/optimizerDuck/UI/ViewModels/Pages/ScheduledTasksViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/ScheduledTasksViewModel.cs
index b9772ee..a61e993 100644
--- a/optimizerDuck/UI/ViewModels/Pages/ScheduledTasksViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/ScheduledTasksViewModel.cs
@@ -56,6 +56,7 @@ public partial class ScheduledTasksViewModel : ViewModel
public bool HasResults => Tasks.Count > 0;
public bool ShowRefreshButton => IsNotLoading && HasResults;
+ /// <inheritdoc />
public override async Task OnNavigatedToAsync()
{
await base.OnNavigatedToAsync();
@@ -373,7 +374,6 @@ public partial class ScheduledTasksViewModel : ViewModel
await _contentDialogService.ShowAsync(dialog, CancellationToken.None);
}
- // Filter triggers
partial void OnSearchTextChanged(string value)
{
ApplyFilter();
@@ -440,7 +440,6 @@ public partial class ScheduledTasksViewModel : ViewModel
private void ApplyFilter()
{
- // Unsubscribe
foreach (var task in Tasks)
task.PropertyChanged -= Task_PropertyChanged;
Tasks.Clear();
diff --git a/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs
index bd1ce73..9893f87 100644
--- a/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/SettingsViewModel.cs
@@ -74,7 +74,7 @@ public partial class SettingsViewModel(
private void OnThemeChanged(ApplicationTheme currentApplicationTheme, Color systemAccent)
{
- // Update the theme if it has been changed elsewhere than in the settings.
+ // The theme may have been changed outside the settings page.
if (CurrentApplicationTheme != currentApplicationTheme)
CurrentApplicationTheme = currentApplicationTheme;
}
@@ -167,7 +167,6 @@ public partial class SettingsViewModel(
if (result == ContentDialogResult.Primary)
{
RevertManager.ClearAllRevertData(logger);
- // Refresh optimizations
await OptimizationService.UpdateOptimizationStateAsync(
optimizationRegistry.OptimizationCategories.SelectMany(c => c.Optimizations)
);
@@ -418,7 +417,7 @@ public partial class SettingsViewModel(
#endregion Property Changed
/// <summary>
- /// Fires an async task without awaiting it, but catches all exceptions
+ /// Fires an async task without awaiting it, catching every exception it throws.
/// </summary>
private async Task SafeFireAndForgetAsync(
Func<Task> taskFactory,
diff --git a/optimizerDuck/UI/ViewModels/Pages/StartupManagerViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/StartupManagerViewModel.cs
index 41a02e6..5c6d5ac 100644
--- a/optimizerDuck/UI/ViewModels/Pages/StartupManagerViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/StartupManagerViewModel.cs
@@ -70,6 +70,7 @@ public partial class StartupManagerViewModel : ViewModel
public bool HasResults => Apps.Count > 0 || Tasks.Count > 0;
public bool ShowRefreshButton => IsNotLoading && HasResults;
+ /// <inheritdoc />
public override async Task OnNavigatedToAsync()
{
await base.OnNavigatedToAsync();
@@ -182,7 +183,6 @@ public partial class StartupManagerViewModel : ViewModel
await _contentDialogService.ShowAsync(dialog, CancellationToken.None);
}
- // Apps filter triggers
partial void OnAppSearchTextChanged(string value)
{
ApplyAppFilter();
@@ -193,7 +193,6 @@ public partial class StartupManagerViewModel : ViewModel
ApplyAppFilter();
}
- // Tasks filter triggers
partial void OnTaskSearchTextChanged(string value)
{
ApplyTaskFilter();
@@ -334,7 +333,7 @@ public partial class StartupManagerViewModel : ViewModel
if (e.PropertyName != nameof(StartupApp.IsEnabled) || sender is not StartupApp app)
return;
- // rollback re-assigns IsEnabled, so guard against re-entrancy.
+ // The rollback re-assigns IsEnabled, so guard against re-entrancy.
if (!_suppressToggle.Add(app))
return;
diff --git a/optimizerDuck/UI/ViewModels/ViewModel.cs b/optimizerDuck/UI/ViewModels/ViewModel.cs
index 3d8d264..a5d8d3e 100644
--- a/optimizerDuck/UI/ViewModels/ViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/ViewModel.cs
@@ -33,7 +33,6 @@ public abstract class ViewModel : LocalizedObject, INavigationAware
/// <summary>
/// Runs one-time initialization logic the first time the page is navigated to.
/// </summary>
- /// <returns>A task that represents the asynchronous operation.</returns>
/// <remarks>
/// Override this method to load data or subscribe to events. It runs only once
/// per view model lifetime, even if the user navigates away and back.
@@ -43,7 +42,6 @@ public abstract class ViewModel : LocalizedObject, INavigationAware
/// <summary>
/// Called when the page becomes the active view.
/// </summary>
- /// <returns>A task that represents the asynchronous operation.</returns>
/// <remarks>
/// Ensures <see cref="InitializeOnceAsync"/> runs exactly once, then calls
/// <see cref="OnNavigatedTo()"/>. If initialization fails, the flag resets
@@ -72,7 +70,6 @@ public abstract class ViewModel : LocalizedObject, INavigationAware
/// <summary>
/// Called when the page is no longer the active view.
/// </summary>
- /// <returns>A task that represents the asynchronous operation.</returns>
/// <remarks>
/// Override this method to clean up resources or stop timers when leaving the page.
/// </remarks>
diff --git a/optimizerDuck/UI/ViewModels/Windows/MainWindowViewModel.cs b/optimizerDuck/UI/ViewModels/Windows/MainWindowViewModel.cs
index 70e33f6..af0e095 100644
--- a/optimizerDuck/UI/ViewModels/Windows/MainWindowViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Windows/MainWindowViewModel.cs
@@ -27,7 +27,7 @@ public partial class MainWindowViewModel : LocalizedObject
}
catch
{
- // Silently fail - link opening is a non-critical action
+ // Silently fail: opening a link is non-critical.
}
}
@@ -45,7 +45,7 @@ public partial class MainWindowViewModel : LocalizedObject
}
catch
{
- // Silently fail - link opening is a non-critical action
+ // Silently fail: opening a link is non-critical.
}
}
}