Skip to content

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

iam too old for this

itsfatduck3bc2529ff673
diff --git a/Docs/getting-started.md b/Docs/getting-started.md
index 899962c..e4b2436 100644
--- a/Docs/getting-started.md
+++ b/Docs/getting-started.md
@@ -36,9 +36,9 @@ See [Safety Guidelines](safety.md) before **applying changes**.
See [FAQ](faq.md) for answers to **common questions**.
-## Features
+## Optimizations
-See [Features](features.md) for a list of optimizerDuck's **available tweaks** (These features are not exhaustive and may change over time).
+See [Optimizations](optimizations.md) for a list of optimizerDuck's **available optimizations** (These features are not exhaustive and may change over time).
## Acknowledgments
diff --git a/Docs/optimizations.md b/Docs/optimizations.md
index dd6aeac..d2fbf39 100644
--- a/Docs/optimizations.md
+++ b/Docs/optimizations.md
@@ -2,7 +2,7 @@
<img src="../.github/assets/optimizerDuck.png" alt="optimizerDuck Banner" title="optimizerDuck" height="300"/>
-# Features
+# Optimizations
View the list of optimizerDuck's optimizations.
@@ -53,6 +53,6 @@ View the list of optimizerDuck's optimizations.
- **Debloat Microsoft Edge** — Removes unnecessary Edge features and reduces its system integration for better performance
> [!NOTE]
-> These features are not exhaustive and may change over time.
+> These optimizations are not exhaustive and may change over time.
>
> Last updated: 12/11/2025
diff --git a/README.md b/README.md
index 113693c..7b99453 100644
--- a/README.md
+++ b/README.md
@@ -6,11 +6,11 @@
**optimizerDuck is a free, open-source Windows optimization tool built for performance, privacy, and simplicity.**
-[![Latest Release](https://img.shields.io/github/release/itsfatduck/optimizerDuck?color=fed114&label=Latest%20Release)](https://github.com/itsfatduck/optimizerDuck/releases/latest)
+[![Release](https://img.shields.io/github/release/itsfatduck/optimizerDuck?color=fed114&label=Release)](https://github.com/itsfatduck/optimizerDuck/releases/latest)
[![Downloads](https://img.shields.io/github/downloads/itsfatduck/optimizerDuck/total?label=Downloads)](https://github.com/itsfatduck/optimizerDuck/releases)
[![Stars](https://img.shields.io/endpoint?url=https://api.pinstudios.net/api/badges/stars/itsfatduck/optimizerDuck)](https://github.com/itsfatduck/optimizerDuck/stargazers)
[![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-white)](./LICENSE)
-[![Discord](https://img.shields.io/discord/1091675679994675240?color=5865f2&label=Discord%20Community)](https://discord.gg/tDUBDCYw9Q)
+[![Discord](https://img.shields.io/discord/1091675679994675240?color=5865f2&label=Discord)](https://discord.gg/tDUBDCYw9Q)
<br>
[![.NET 10.0](https://img.shields.io/badge/.NET_Runtime-10.0_Latest-ef99dd)](https://dotnet.microsoft.com/en-us/download)
[![Tested OS](https://img.shields.io/badge/Tested_OS-Windows_10_and_11_x64-0078d4)](https://www.microsoft.com/en-us/software-download/)
diff --git a/optimizerDuck.Test/RegistryServiceTests.cs b/optimizerDuck.Test/RegistryServiceTests.cs
index 54aada6..48d1308 100644
--- a/optimizerDuck.Test/RegistryServiceTests.cs
+++ b/optimizerDuck.Test/RegistryServiceTests.cs
@@ -1,6 +1,7 @@
using Microsoft.Win32;
using optimizerDuck.Core.Services;
using optimizerDuck.Models;
+using optimizerDuck.UI.Logger;
namespace optimizerDuck.Test;
@@ -9,27 +10,18 @@ public class RegistryServiceTests
[Fact]
public void Read()
{
- var pathString =
- RegistryService.Read<string>(new RegistryItem(
- @"HKEY_LOCAL_MACHINE\SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedhost",
- "Path"));
- var versionString =
- RegistryService.Read<string>(new RegistryItem(
- @"HKEY_LOCAL_MACHINE\SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedhost",
- "Version"));
var binary =
RegistryService.Read<byte[]>(new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Logitech\LGHUB\Data",
"canary_machine_identifier"));
- Assert.NotNull(pathString);
- Assert.NotNull(versionString);
Assert.NotNull(binary);
}
[Fact]
public void Write_And_Read_Back_String_Value()
{
+ using var tracker = ServiceTracker.Begin();
var testKeyPath = @"HKEY_CURRENT_USER\Software\optimizerDuckTests";
var item = new RegistryItem(testKeyPath, "TestString", "hello", RegistryValueKind.String);
try
@@ -88,6 +80,7 @@ public class RegistryServiceTests
[Fact]
public void Read_Converts_Types_When_Possible()
{
+ using var tracker = ServiceTracker.Begin();
var testKeyPath = @"HKEY_CURRENT_USER\Software\optimizerDuckTests_TypeConversion";
try
{
@@ -109,6 +102,7 @@ public class RegistryServiceTests
[Fact]
public void DeleteSubKey_Removes_Entire_Tree()
{
+ using var tracker = ServiceTracker.Begin();
var basePath = @"HKEY_CURRENT_USER\Software\optimizerDuckTests_DeleteTree";
var childPath = basePath + "\\Child";
try
diff --git a/optimizerDuck/optimizerDuck.csproj b/optimizerDuck/optimizerDuck.csproj
index 20ae39f..3b5ba14 100644
--- a/optimizerDuck/optimizerDuck.csproj
+++ b/optimizerDuck/optimizerDuck.csproj
@@ -9,8 +9,8 @@
<ApplicationIcon>Logo.ico</ApplicationIcon>
<Configurations>Debug;Release</Configurations>
<ApplicationManifest>app.manifest</ApplicationManifest>
- <FileVersion>1.3.4</FileVersion>
- <Version>1.3.4</Version>
+ <FileVersion>1.3.6</FileVersion>
+ <Version>1.3.6</Version>
<AssemblyTitle>Free, open-source Windows optimization tool for performance, privacy, and simplicity.</AssemblyTitle>
<NeutralLanguage>en</NeutralLanguage>
<PlatformTarget>x64</PlatformTarget>
diff --git a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs b/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs
index ee78ff7..1e505f3 100644
--- a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs
+++ b/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs
@@ -17,7 +17,7 @@ public static class OptimizationHelper
{
private static readonly ILogger Log = Logger.CreateLogger(typeof(OptimizationHelper));
- public static List<OptimizationGroupChoice> GetTweakChoices()
+ public static List<OptimizationGroupChoice> LoadOptimizationChoices()
{
return CacheManager.GetOrCreate("optimization_choices", entry =>
{
@@ -26,49 +26,49 @@ public static class OptimizationHelper
var optimizationGroups = ReflectionHelper.FindImplementationsInLoadedAssemblies(typeof(IOptimizationGroup))
.ToArray();
- var allTweaksByGroup = optimizationGroups
+ var allOptimizationsByGroup = optimizationGroups
.Select(g => new
{
Group = (IOptimizationGroup)Activator.CreateInstance(g)!,
- Tweaks = g.GetNestedTypes(BindingFlags.Public)
- .Where(t => typeof(IOptimizationTweak).IsAssignableFrom(t))
- .Select(t => (IOptimizationTweak)Activator.CreateInstance(t)!)
+ Optimizations = g.GetNestedTypes(BindingFlags.Public)
+ .Where(t => typeof(IOptimization).IsAssignableFrom(t))
+ .Select(t => (IOptimization)Activator.CreateInstance(t)!)
.ToList()
})
.ToList();
- var allTweaks = allTweaksByGroup.SelectMany(x => x.Tweaks).ToList();
- var globalMaxNameLength = allTweaks.DefaultIfEmpty().Max(t => t?.Name?.Length ?? 0) + 1;
- var maxImpactLength = allTweaks.DefaultIfEmpty().Max(t => t?.Impact.GetDescription().Length ?? 0) + 1;
+ var allOptimizations = allOptimizationsByGroup.SelectMany(x => x.Optimizations).ToList();
+ var globalMaxNameLength = allOptimizations.DefaultIfEmpty().Max(t => t?.Name?.Length ?? 0) + 1;
+ var maxImpactLength = allOptimizations.DefaultIfEmpty().Max(t => t?.Impact.GetDescription().Length ?? 0) + 1;
var groups = new List<OptimizationGroupChoice>();
- foreach (var g in allTweaksByGroup)
+ foreach (var g in allOptimizationsByGroup)
{
- var tweaks = g.Tweaks
+ var optimizations = g.Optimizations
.OrderByDescending(t => t.EnabledByDefault)
.ThenBy(t => (int)t.Impact)
.ToList();
- if (tweaks.Count == 0) continue; // Skip empty groups
+ if (optimizations.Count == 0) continue; // Skip empty groups
- var tweakChoices = tweaks.Select(t =>
+ var optimizationChoices = optimizations.Select(t =>
{
var paddedName = t.Name.PadRight(globalMaxNameLength);
var description = $"{t.Impact.GetDescription().PadRight(maxImpactLength)}[dim]{t.Description}[/]";
- return new OptimizationTweakChoice(t, paddedName, description, t.EnabledByDefault);
+ return new OptimizationChoice(t, paddedName, description, t.EnabledByDefault);
}).ToList();
- groups.Add(new OptimizationGroupChoice(g.Group.Name, g.Group.Order, tweakChoices));
+ groups.Add(new OptimizationGroupChoice(g.Group.Name, g.Group.Order, optimizationChoices));
}
- var orderedGroups = groups.OrderBy(g => g.Priority).ToList();
+ var orderedGroups = groups.OrderBy(g => g.Order).ToList();
foreach (var g in orderedGroups)
{
- Log.LogDebug("Loaded group {Group}:", g.Name);
- foreach (var t in g.Tweaks)
- Log.LogDebug(" - {TweakName} {TweakDescription}", t.Name, Markup.Remove(t.Description));
+ Log.LogDebug("Loaded group [{Group}]:", g.Name);
+ foreach (var t in g.Optimizations)
+ Log.LogDebug(" - {OptimizationName} {OptimizationDescription}", t.Name, Markup.Remove(t.Description));
}
return orderedGroups;
diff --git a/optimizerDuck/src/Core/Helpers/StreamHelper.cs b/optimizerDuck/src/Core/Helpers/StreamHelper.cs
index a53995b..fabbb90 100644
--- a/optimizerDuck/src/Core/Helpers/StreamHelper.cs
+++ b/optimizerDuck/src/Core/Helpers/StreamHelper.cs
@@ -13,21 +13,43 @@ public static class StreamHelper
{
var filePath = Path.Combine(Defaults.ResourcesPath, fileName);
+ Log.LogInformation("Starting download from {Url} to {FilePath}", url, filePath);
+
try
{
using var client = new HttpClient();
using var response = await client.GetAsync(url).ConfigureAwait(false);
+
+ Log.LogDebug("Received HTTP {StatusCode} from {Url}", response.StatusCode, url);
+
response.EnsureSuccessStatusCode();
await using var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
await response.Content.CopyToAsync(fs).ConfigureAwait(false);
- Log.LogInformation("Downloaded file from {Url} to {FilePath}", url, filePath);
+ var length = fs.Length;
+ Log.LogInformation("Successfully downloaded {Length} bytes from {Url} to {FilePath}", length, url, filePath);
+
return (true, filePath);
}
+ catch (HttpRequestException ex)
+ {
+ Log.LogError(ex, "Network error while downloading {Url}", url);
+ return (false, null);
+ }
+ catch (IOException ex)
+ {
+ Log.LogError(ex, "File I/O error while saving {FilePath}", filePath);
+ return (false, null);
+ }
+ catch (UnauthorizedAccessException ex)
+ {
+ Log.LogError(ex, "Access denied when writing to {FilePath}", filePath);
+ return (false, null);
+ }
catch (Exception ex)
{
- Log.LogError(ex, "Failed to download file from {Url} to {FilePath}", url, filePath);
+ Log.LogError(ex, "Unexpected error downloading {Url} to {FilePath}", url, filePath);
return (false, null);
}
}
diff --git a/optimizerDuck/src/Core/Managers/OptimizationManager.cs b/optimizerDuck/src/Core/Managers/OptimizationManager.cs
index 86f09f6..16cbdd7 100644
--- a/optimizerDuck/src/Core/Managers/OptimizationManager.cs
+++ b/optimizerDuck/src/Core/Managers/OptimizationManager.cs
@@ -16,30 +16,31 @@ namespace optimizerDuck.Core.Managers;
public class OptimizationManager(SystemSnapshot systemSnapshot)
{
private static readonly ILogger Log = Logger.CreateLogger<OptimizationManager>();
- private Queue<OptimizationTweakChoice> _selectedTweaks = new();
+ private Queue<OptimizationChoice> _selectedOptimizations = new();
private SystemSnapshot _systemSnapshot = systemSnapshot;
public static Queue<AppxPackage> SelectedBloatware { get; private set; } =
- new(); // public and static for Remove Bloatware Apps tweak
+ new(); // public and static for Remove Bloatware Apps optimization
public async Task<bool> Begin()
{
- SystemHelper.Title("Select the tweaks you want to apply");
+
AnsiConsole.Clear();
AnsiConsole.Write(Defaults.Logo);
Log.LogInformation("Loading optimizations...");
- var optimizationGroups = OptimizationHelper.GetTweakChoices();
- Log.LogInformation("Loaded {GroupAmount} groups with {TweakAmount} tweaks.", optimizationGroups.Count,
- optimizationGroups.Sum(g => g.Tweaks.Count));
+ var optimizationGroups = OptimizationHelper.LoadOptimizationChoices();
+ Log.LogInformation("Loaded {GroupAmount} groups with {OptimizationAmount} optimizations.", optimizationGroups.Count,
+ optimizationGroups.Sum(g => g.Optimizations.Count));
+ SystemHelper.Title("Select the optimizations you want to apply");
try
{
using var escapeCancellableConsole = new EscapeCancellableConsole(AnsiConsole.Console);
- var promptTweakChoice = new MultiSelectionPrompt<OptimizationTweakChoice>()
- .Title("Select the tweaks you want to apply")
+ var promptOptimizationChoice = new MultiSelectionPrompt<OptimizationChoice>()
+ .Title("Select the optimizations you want to apply")
.InstructionsText(Defaults.EscapeCancellableConsoleMultiSelectionPromptInstructionsText)
.Required(true)
.HighlightStyle(Theme.Primary)
@@ -47,27 +48,28 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
.PageSize(24);
foreach (var g in optimizationGroups)
- promptTweakChoice.AddChoiceGroup(
- new OptimizationTweakChoice(null, $"[bold underline]{g.Name}[/]", string.Empty,
+ promptOptimizationChoice.AddChoiceGroup(
+ new OptimizationChoice(null, $"[bold underline]{g.Name}[/]", string.Empty,
false),
- g.Tweaks
+ g.Optimizations
);
- if (_selectedTweaks.Count == 0)
- foreach (var tweak in optimizationGroups.SelectMany(g => g.Tweaks).Where(t => t.EnabledByDefault))
- promptTweakChoice.Select(tweak);
- else
- foreach (var selectedTweak in _selectedTweaks.ToList())
- promptTweakChoice.Select(selectedTweak);
+ var optimizationsToSelect = _selectedOptimizations.Count == 0
+ ? optimizationGroups.SelectMany(g => g.Optimizations).Where(t => t.EnabledByDefault)
+ : _selectedOptimizations;
- var optimizationTweakChoices =
- await escapeCancellableConsole.PromptAsync(promptTweakChoice).ConfigureAwait(false);
+ foreach (var optimization in optimizationsToSelect)
+ {
+ promptOptimizationChoice.Select(optimization);
+ }
- _selectedTweaks = new Queue<OptimizationTweakChoice>(optimizationTweakChoices);
+ var optimizationChoices =
+ await escapeCancellableConsole.PromptAsync(promptOptimizationChoice).ConfigureAwait(false);
- if (_selectedTweaks.Any(t => t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selected
+ _selectedOptimizations = new Queue<OptimizationChoice>(optimizationChoices);
+
+ if (_selectedOptimizations.Any(t => t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selected
{
- SystemHelper.Title("Select the bloatware you want to remove");
Log.LogInformation("Getting installed bloatware apps...");
var appxClassification = OptimizationHelper.GetBloatwareChoices();
@@ -86,8 +88,9 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
);
}
+ SystemHelper.Title("Select the bloatware apps you want to remove");
var promptBloatware = new MultiSelectionPrompt<AppxPackage>()
- .Title("Select the bloatware you want to remove")
+ .Title("Select the bloatware apps you want to remove")
.InstructionsText(Defaults.EscapeCancellableConsoleMultiSelectionPromptInstructionsText)
.Required(true)
.HighlightStyle(Theme.Primary)
@@ -101,7 +104,7 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
promptBloatware.AddChoiceGroup(
new AppxPackage
{
- DisplayName = "[bold underline lightgreen]Safe Apps[/] - [lightgreen]Safe to remove[/]",
+ DisplayName = $"[bold underline {Theme.Success}]Safe Apps[/] - [{Theme.Success}]Safe to remove[/]",
Name = "",
Version = "",
InstallLocation = ""
@@ -112,7 +115,7 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
promptBloatware.AddChoiceGroup(
new AppxPackage
{
- DisplayName = "[bold underline red]Caution Apps[/] - [red]May cause issues[/]",
+ DisplayName = $"[bold underline {Theme.Error}]Caution Apps[/] - [{Theme.Error}]May cause issues[/]",
Name = "",
Version = "",
InstallLocation = ""
@@ -171,48 +174,48 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
Log.LogInformation("Refreshing system information...");
_systemSnapshot = await SystemInfoService.RefreshAsync().ConfigureAwait(false);
- Log.LogDebug("Selected tweaks ({TweakAmount}): {Tweaks}", _selectedTweaks.Count,
- string.Join(", ", _selectedTweaks.Select(t => t.Name)));
+ Log.LogDebug("Selected {OptimizationAmount} optimizations: {Optimizations}",
+ _selectedOptimizations.Count,
+ string.Join(", ", _selectedOptimizations.Select(t => t.Name)));
- if (_selectedTweaks.Any(t => t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selected
- Log.LogDebug("Selected bloatware apps ({BloatwareAmount}): {Bloatware}", SelectedBloatware.Count,
- string.Join(", ", SelectedBloatware.Select(app => $"{app.DisplayName} ({app.Version})")));
+ if (_selectedOptimizations.Any(t => t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selected
+ Log.LogDebug("Selected {BloatwareAmount} bloatware apps: {BloatwareApps}", SelectedBloatware.Count,
+ string.Join(", ", SelectedBloatware.Select(app => $"{app.DisplayName.Trim()} ({app.Version.Trim()})")));
Log.LogDebug(new string('=', 60));
- while (_selectedTweaks.TryDequeue(out var selectedTweak))
+ while (_selectedOptimizations.TryDequeue(out var selectedOptimization))
await AnsiConsole.Status()
.Spinner(Spinner.Known.Dots2)
.SpinnerStyle($"bold {Theme.Primary}")
- .StartAsyncGlobal($"Applying [{Theme.Primary}]{selectedTweak.Name}[/]...", async ctx =>
+ .StartAsyncGlobal($"Applying [{Theme.Primary}]{selectedOptimization.Name}[/]...", async ctx =>
{
try
{
- selectedTweak = selectedTweak with
+ selectedOptimization = selectedOptimization with
{
- Name = selectedTweak.Name.Trim(),
- Description = selectedTweak.Description.Trim()
+ Name = selectedOptimization.Name.Trim(),
+ Description = selectedOptimization.Description.Trim()
};
- SystemHelper.Title(selectedTweak.Name);
- ctx.Status($"Applying [{Theme.Primary}]{selectedTweak.Name}[/]...");
+ SystemHelper.Title(selectedOptimization.Name);
+ ctx.Status($"Applying [{Theme.Primary}]{selectedOptimization.Name}[/]...");
- using var scope = Log.BeginScope("Tweak: {TweakName}", selectedTweak.Name);
+ using var scope = Log.BeginScope("Optimization: {OptimizationName}", selectedOptimization.Name);
- Rule($"[bold white] {selectedTweak.Name} [/]", Theme.Success);
- Log.LogInformation("Applying {TweakName}...", selectedTweak.Name);
+ Rule($"[bold white] {selectedOptimization.Name} [/]", Theme.Success);
+ Log.LogInformation("Applying {OptimizationName}...", selectedOptimization.Name);
var stopwatch = Stopwatch.StartNew();
- await selectedTweak.Instance!.Apply(_systemSnapshot).ConfigureAwait(false);
+ await selectedOptimization.Instance!.Apply(_systemSnapshot).ConfigureAwait(false);
stopwatch.Stop();
- Log.LogDebug("Finished tweak in {Elapsed}ms", stopwatch.ElapsedMilliseconds);
+ Log.LogDebug("Applied in {Elapsed} ms", stopwatch.ElapsedMilliseconds);
}
catch (Exception e)
{
- Log.LogError(e, "[{Error}]Failed to apply tweak {TweakName}[/], skipped.", Theme.Error,
- selectedTweak.Name);
+ Log.LogError(e, "Failed to apply optimization {OptimizationName}. Skipped.", selectedOptimization.Name);
}
finally
{
@@ -225,11 +228,11 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)
Log.LogInformation($"[{Theme.Success}]Optimization completed![/]");
- PromptDialog.Warning("Restart To Apply Changes",
+ PromptDialog.Warning("Restart to Apply Changes",
$"""
- The tweaks have been applied successfully.
- Please [{Theme.Success}]restart[/] your PC so the changes can work properly.
- """,
+ The optimizations have been applied successfully.
+ Please [{Theme.Success}]restart[/] your PC for the changes to take effect.
+ """,
new PromptOption("Restart now", Theme.Success, () =>
{
Log.LogInformation("Restarting...");
diff --git a/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs b/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs
index 17fcd30..48d6158 100644
--- a/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs
+++ b/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs
@@ -11,10 +11,10 @@ namespace optimizerDuck.Core.Optimizers;
public class BloatwareAndServices : IOptimizationGroup
{
public string Name { get; } = "Bloatware & Services";
- public int Order { get; } = (int)OptimizationGroupOrder.BloatwareAndServices;
+ public OptimizationGroupOrder Order { get; } = OptimizationGroupOrder.BloatwareAndServices;
public static ILogger Log { get; } = Logger.CreateLogger<BloatwareAndServices>();
- public class RemoveBloatwareApps : IOptimizationTweak
+ public class RemoveBloatwareApps : IOptimization
{
public string Name { get; } = "Remove Bloatware Apps";
@@ -29,6 +29,7 @@ public class BloatwareAndServices : IOptimizationGroup
{
using var tracker = ServiceTracker.Begin(Log);
+
while (OptimizationManager.SelectedBloatware.TryDequeue(out var appxPackage))
{
appxPackage = appxPackage with { DisplayName = appxPackage.DisplayName.Trim(), Version = appxPackage.Version.Trim() };
@@ -66,7 +67,7 @@ public class BloatwareAndServices : IOptimizationGroup
}
}
- public class RemoveMicrosoftEdge : IOptimizationTweak
+ public class RemoveMicrosoftEdge : IOptimization
{
public string Name { get; } = "Debloat Microsoft Edge";
@@ -80,6 +81,7 @@ public class BloatwareAndServices : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
// thank you again, WinUtil
new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\EdgeUpdate", "CreateDesktopShortcutDefault", 0),
@@ -104,7 +106,7 @@ public class BloatwareAndServices : IOptimizationGroup
}
}
- public class ConfigureServices : IOptimizationTweak
+ public class ConfigureServices : IOptimization
{
public string Name { get; } = "Configure Services";
diff --git a/optimizerDuck/src/Core/Optimizers/Performance.cs b/optimizerDuck/src/Core/Optimizers/Performance.cs
index c7e54e5..55a470c 100644
--- a/optimizerDuck/src/Core/Optimizers/Performance.cs
+++ b/optimizerDuck/src/Core/Optimizers/Performance.cs
@@ -10,11 +10,11 @@ namespace optimizerDuck.Core.Optimizers;
public class Performance : IOptimizationGroup
{
- public string Name => "Performance";
- public int Order => (int)OptimizationGroupOrder.Performance;
+ public string Name { get; } = "Performance";
+ public OptimizationGroupOrder Order { get; } = OptimizationGroupOrder.Performance;
public static ILogger Log { get; } = Logger.CreateLogger<Performance>();
- public class BackgroundAppsTweak : IOptimizationTweak
+ public class BackgroundAppsOptimization : IOptimization
{
public string Name { get; } = "Disable Background Apps";
public string Description { get; } = "Stops background applications from running to free up RAM and CPU resources";
@@ -24,6 +24,7 @@ public class Performance : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
+ using var tracker = ServiceTracker.Begin(Log);
RegistryService.Write(
new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications", "GlobalUserDisabled", 1),
new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search", "BackgroundAppGlobalToggle", 0)
@@ -33,7 +34,7 @@ public class Performance : IOptimizationGroup
}
}
- public class ProcessPriorityTweak : IOptimizationTweak
+ public class ProcessPriorityOptimization : IOptimization
{
public string Name { get; } = "Optimize Process Priority";
public string Description { get; } = "Adjusts foreground app priority for better responsiveness and reduced input lag";
@@ -66,12 +67,12 @@ public class Performance : IOptimizationGroup
RegistryService.Write(
new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl", "Win32PrioritySeparation", win32Priority)
);
- Log.LogInformation("Applied process priority tweak (Win32PrioritySeparation = {Value}).", win32Priority);
+ Log.LogInformation("Applied process priority optimization (Win32PrioritySeparation = {Value}).", win32Priority);
return Task.CompletedTask;
}
}
- public class GameSchedulingTweak : IOptimizationTweak
+ public class GameSchedulingOptimization : IOptimization
{
public string Name { get; } = "Optimize Gaming Scheduling";
public string Description { get; } = "Prioritizes GPU scheduling and system resources for gaming workloads";
@@ -94,7 +95,7 @@ public class Performance : IOptimizationGroup
}
}
- public class SvcHostSplitTweak : IOptimizationTweak
+ public class SvcHostSplitOptimization : IOptimization
{
public string Name { get; } = "SvcHost Split Threshold";
public string Description { get; } = "Adjusts SvcHostSplitThresholdInKB based on total system RAM to control service isolation and improve system stability.";
@@ -121,7 +122,7 @@ public class Performance : IOptimizationGroup
- public class DisableGameBar : IOptimizationTweak
+ public class DisableGameBar : IOptimization
{
public string Name { get; } = "Disable Game Bar";
@@ -146,7 +147,7 @@ public class Performance : IOptimizationGroup
}
}
- public class GameModeTweak : IOptimizationTweak
+ public class EnableGameMode : IOptimization
{
public string Name { get; } = "Enable Game Mode";
public string Description { get; } = "Enables Windows Game Mode (Recommended on Windows 11)";
@@ -165,7 +166,7 @@ public class Performance : IOptimizationGroup
}
}
- public class DisableGameDVR : IOptimizationTweak
+ public class DisableGameDVR : IOptimization
{
public string Name { get; } = "Disable Game DVR";
@@ -191,7 +192,7 @@ public class Performance : IOptimizationGroup
}
}
- public class GpuOptimizationTweak : IOptimizationTweak
+ public class GpuOptimization : IOptimization
{
public string Name { get; } = "GPU Optimization";
@@ -203,7 +204,7 @@ public class Performance : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
- Log.LogInformation("Applying GPU tweaks for {GpuCount} GPUs...", s.Gpus.Count);
+ Log.LogInformation("Applying GPU optimizations for {GpuCount} GPUs...", s.Gpus.Count);
const string basePath =
@"HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}";
@@ -243,7 +244,7 @@ public class Performance : IOptimizationGroup
new RegistryItem(path, "DisablePowerGating", 1),
new RegistryItem(path, "DisableVceClockGating", 1)
);
- Log.LogInformation("Applied AMD GPU tweaks for {GpuName} at index {GpuIndex:D4}.", gpu.Name,
+ Log.LogInformation("Applied AMD GPU optimizations for {GpuName} at index {GpuIndex:D4}.", gpu.Name,
index);
break;
case GpuVendor.NVIDIA:
@@ -251,7 +252,7 @@ public class Performance : IOptimizationGroup
new RegistryItem(path, "DisableDynamicPstate", 1),
new RegistryItem(path, "DisableASyncPstates", 1)
);
- Log.LogInformation("Applied NVIDIA GPU tweaks for {GpuName} at index {GpuIndex:D4}.", gpu.Name,
+ Log.LogInformation("Applied NVIDIA GPU optimizations for {GpuName} at index {GpuIndex:D4}.", gpu.Name,
index);
break;
case GpuVendor.Intel:
@@ -263,7 +264,7 @@ public class Performance : IOptimizationGroup
new RegistryItem(path, "EnableCompensationForDVI", 1),
new RegistryItem(path, "Display1_DisableAsyncFlips", 1)
);
- Log.LogInformation("Applied Intel GPU tweaks for {GpuName} at index {GpuIndex:D4}.", gpu.Name,
+ Log.LogInformation("Applied Intel GPU optimizations for {GpuName} at index {GpuIndex:D4}.", gpu.Name,
index);
break;
case GpuVendor.Unknown:
diff --git a/optimizerDuck/src/Core/Optimizers/Power.cs b/optimizerDuck/src/Core/Optimizers/Power.cs
index 25223da..7bb60c1 100644
--- a/optimizerDuck/src/Core/Optimizers/Power.cs
+++ b/optimizerDuck/src/Core/Optimizers/Power.cs
@@ -11,11 +11,11 @@ namespace optimizerDuck.Core.Optimizers;
public class Power : IOptimizationGroup
{
public string Name { get; } = "Power";
- public int Order { get; } = (int)OptimizationGroupOrder.Power;
+ public OptimizationGroupOrder Order { get; } = OptimizationGroupOrder.Power;
public static ILogger Log { get; } = Logger.CreateLogger<Power>();
- public class DisableHibernateTweak : IOptimizationTweak
+ public class DisableHibernate : IOptimization
{
public string Name { get; } = "Disable Hibernate";
@@ -27,6 +27,8 @@ public class Power : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
+ using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\Power", "HibernateEnabled", 0),
new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerThrottling",
@@ -41,7 +43,7 @@ public class Power : IOptimizationGroup
}
}
- public class DisableUSBPowerSaving : IOptimizationTweak
+ public class DisableUSBPowerSaving : IOptimization
{
public string Name { get; } = "Disable USB Power Saving";
@@ -54,6 +56,7 @@ public class Power : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
//https://discord.com/channels/1298592513816530994/1359513721738629140/1359524213047824517
//from FrameSync Labs
ShellService.PowerShell("""
@@ -72,7 +75,7 @@ public class Power : IOptimizationGroup
}
- public class InstallOptimizerDuckPowerPlan : IOptimizationTweak
+ public class InstallOptimizerDuckPowerPlan : IOptimization
{
public string Name { get; } = "Install optimizerDuck Power Plan";
@@ -87,8 +90,10 @@ public class Power : IOptimizationGroup
using var tracker = ServiceTracker.Begin(Log);
var (success, powerPlanPath) =
await StreamHelper.TryDownloadAsync(Defaults.PowerPlanUrl, "optimizerDuck.pow");
- if (success && !string.IsNullOrEmpty(powerPlanPath))
+ if (success)
{
+ Log.LogInformation("Downloaded optimizerDuck power plan!");
+
// set other power plan to delete old one (to avoid import errors)
ShellService.CMD("powercfg /duplicatescheme 381b4222-f694-41f0-9685-ff5bb260df2e"); // restore Balanced
ShellService.CMD("powercfg /setactive 381b4222-f694-41f0-9685-ff5bb260df2e"); // set Balanced
@@ -106,7 +111,7 @@ public class Power : IOptimizationGroup
}
}
- public class DisablePowerSavingTweak : IOptimizationTweak
+ public class DisablePowerSaving : IOptimization
{
public string Name { get; } = "Disable Power Saving";
diff --git a/optimizerDuck/src/Core/Optimizers/SecurityAndPrivacy.cs b/optimizerDuck/src/Core/Optimizers/SecurityAndPrivacy.cs
index 0df13f4..640f1f4 100644
--- a/optimizerDuck/src/Core/Optimizers/SecurityAndPrivacy.cs
+++ b/optimizerDuck/src/Core/Optimizers/SecurityAndPrivacy.cs
@@ -8,11 +8,11 @@ namespace optimizerDuck.Core.Optimizers;
public class SecurityAndPrivacy : IOptimizationGroup
{
- public string Name => "Security & Privacy";
- public int Order => (int)OptimizationGroupOrder.SecurityAndPrivacy;
+ public string Name { get; } = "Security & Privacy";
+ public OptimizationGroupOrder Order { get; } = OptimizationGroupOrder.SecurityAndPrivacy;
public static ILogger Log { get; } = Logger.CreateLogger<SecurityAndPrivacy>();
- public class DisableUAC : IOptimizationTweak
+ public class DisableUAC : IOptimization
{
public string Name { get; } = "Disable User Account Control (UAC)";
@@ -25,6 +25,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System",
"EnableLUA", 0));
Log.LogInformation("Disabled UAC");
@@ -32,7 +33,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
}
}
- public class DisableTelemetry : IOptimizationTweak
+ public class DisableTelemetry : IOptimization
{
public string Name { get; } = "Disable Telemetry Services & Tasks";
@@ -137,7 +138,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
}
}
- public class DisableAutologger : IOptimizationTweak
+ public class DisableAutologger : IOptimization
{
public string Name { get; } = "Disable WMI AutoLogger";
@@ -150,6 +151,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\AppModel", "Start", 0),
new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\Cellcore", "Start", 0),
@@ -168,7 +170,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
return Task.CompletedTask;
}
}
- public class DisableContentDeliveryManager : IOptimizationTweak
+ public class DisableContentDeliveryManager : IOptimization
{
public string Name { get; } = "Disable Content Delivery Manager";
@@ -181,6 +183,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "ContentDeliveryAllowed", 0),
new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "OemPreInstalledAppsEnabled", 0),
@@ -198,7 +201,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
}
}
- public class DisableCortanaTweak : IOptimizationTweak
+ public class DisableCortana : IOptimization
{
public string Name { get; } = "Disable Cortana & Search AI";
@@ -228,7 +231,7 @@ public class SecurityAndPrivacy : IOptimizationGroup
}
}
- public class DisableCopilotTweak : IOptimizationTweak
+ public class DisableCopilot : IOptimization
{
public string Name { get; } = "Disable Windows Copilot";
diff --git a/optimizerDuck/src/Core/Optimizers/UserExperience.cs b/optimizerDuck/src/Core/Optimizers/UserExperience.cs
index 5618777..151ac3d 100644
--- a/optimizerDuck/src/Core/Optimizers/UserExperience.cs
+++ b/optimizerDuck/src/Core/Optimizers/UserExperience.cs
@@ -11,10 +11,10 @@ namespace optimizerDuck.Core.Optimizers;
public class UserExperience : IOptimizationGroup
{
public string Name { get; } = "User Experience";
- public int Order { get; } = (int)OptimizationGroupOrder.UserExperience;
+ public OptimizationGroupOrder Order { get; } = OptimizationGroupOrder.UserExperience;
public static ILogger Log { get; } = Logger.CreateLogger<UserExperience>();
- public class TaskbarTweak : IOptimizationTweak
+ public class TaskbarOptimization : IOptimization
{
public string Name { get; } = "Taskbar Optimization";
public string Description { get; } = "Simplifies and cleans up the Windows taskbar for better performance";
@@ -24,6 +24,7 @@ public class UserExperience : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Dsh", "AllowNewsAndInterests", 0),
new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarDa", 0),
@@ -47,7 +48,7 @@ public class UserExperience : IOptimizationGroup
}
}
- public class DarkModeTweak : IOptimizationTweak
+ public class DarkMode : IOptimization
{
public string Name { get; } = "Dark Mode";
public string Description { get; } = "Forces Windows to use dark mode for apps and system";
@@ -57,6 +58,7 @@ public class UserExperience : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 0),
new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme", 0)
@@ -66,7 +68,7 @@ public class UserExperience : IOptimizationGroup
}
}
- public class ExplorerTweak : IOptimizationTweak
+ public class ExplorerOptimization : IOptimization
{
public string Name { get; } = "Explorer Optimization";
public string Description { get; } = "Optimizes Windows Explorer visuals and usability";
@@ -76,6 +78,7 @@ public class UserExperience : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowSyncProviderNotifications", 0),
new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SystemPaneSuggestionsEnabled", 0),
@@ -96,7 +99,7 @@ public class UserExperience : IOptimizationGroup
}
- public class VisualPerformanceTweak : IOptimizationTweak
+ public class VisualPerformanceOptimization : IOptimization
{
public string Name { get; } = "Visual Performance";
public string Description { get; } = "Sets Windows visual effects for best performance";
@@ -106,6 +109,7 @@ public class UserExperience : IOptimizationGroup
public Task Apply(SystemSnapshot s)
{
using var tracker = ServiceTracker.Begin(Log);
+
RegistryService.Write(
new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting", 3),
new RegistryItem(@"HKCU\Control Panel\Desktop", "DragFullWindows", "0"),
@@ -118,7 +122,7 @@ public class UserExperience : IOptimizationGroup
- public class DisableNotifications : IOptimizationTweak
+ public class DisableNotifications : IOptimization
{
public string Name { get; } = "Disable Notifications";
@@ -145,7 +149,7 @@ public class UserExperience : IOptimizationGroup
}
}
- public class OptimizeMouse : IOptimizationTweak
+ public class OptimizeMouse : IOptimization
{
public string Name { get; } = "Optimize Mouse";
@@ -170,7 +174,7 @@ public class UserExperience : IOptimizationGroup
}
}
- public class OptimizeKeyboard : IOptimizationTweak
+ public class OptimizeKeyboard : IOptimization
{
public string Name { get; } = "Optimize Keyboard";
@@ -196,7 +200,7 @@ public class UserExperience : IOptimizationGroup
}
}
- public class InstallZwTimerResolution : IOptimizationTweak
+ public class InstallZwTimerResolution : IOptimization
{
public string Name => "Install ZwTimerResolution";
@@ -212,7 +216,7 @@ public class UserExperience : IOptimizationGroup
var (success, zwtPath) = await StreamHelper.TryDownloadAsync(Defaults.ZwtDownloadUrl, "zwtimer.exe")
.ConfigureAwait(false);
- if (success && !string.IsNullOrEmpty(zwtPath))
+ if (success)
{
Log.LogInformation("ZwTimerResolution downloaded successfully!");
/*
diff --git a/optimizerDuck/src/Core/Services/ServiceProcessService.cs b/optimizerDuck/src/Core/Services/ServiceProcessService.cs
index f4cc3bb..220f71b 100644
--- a/optimizerDuck/src/Core/Services/ServiceProcessService.cs
+++ b/optimizerDuck/src/Core/Services/ServiceProcessService.cs
@@ -22,7 +22,7 @@ public static class ServiceProcessService
if (service == null)
{
- ServiceTracker.Current?.Log.LogError("Service '{ServiceName}' not found.", item.ServiceName);
+ ServiceTracker.Current?.Log.LogError("Service {ServiceName} not found.", item.ServiceName);
ServiceTracker.Current?.Track(nameof(ChangeServiceStartupType), false);
return false;
}
@@ -51,14 +51,14 @@ public static class ServiceProcessService
}
ServiceTracker.Current?.Log.LogError(
- "Failed to change startup type for '{ServiceName}'. ReturnValue: {Result}", item.ServiceName,
+ "Failed to change startup type for {ServiceName}. ReturnValue: {Result}", item.ServiceName,
resultCode);
ServiceTracker.Current?.Track(nameof(ChangeServiceStartupType), false);
return false;
}
catch (Exception ex)
{
- ServiceTracker.Current?.Log.LogError(ex, "Failed to change startup type for '{ServiceName}'.",
+ ServiceTracker.Current?.Log.LogError(ex, "Failed to change startup type for {ServiceName}",
item.ServiceName);
ServiceTracker.Current?.Track(nameof(ChangeServiceStartupType), false);
return false;
diff --git a/optimizerDuck/src/Core/Services/SystemInfoService.cs b/optimizerDuck/src/Core/Services/SystemInfoService.cs
index d46ef78..6e1aa6f 100644
--- a/optimizerDuck/src/Core/Services/SystemInfoService.cs
+++ b/optimizerDuck/src/Core/Services/SystemInfoService.cs
@@ -383,8 +383,11 @@ public static class DiskHelper
public static bool IsSSD(string driveLetter)
{
- var path = @"\\.\" + driveLetter.TrimEnd('\\');
- var handle = CreateFile(path, GENERIC_READ,
+ var trimmedDrive = driveLetter.TrimEnd('\\');
+ if (string.IsNullOrWhiteSpace(trimmedDrive))
+ return false;
+
+ using var handle = CreateFile(@"\\.\" + trimmedDrive, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero);
@@ -399,30 +402,41 @@ public static class DiskHelper
};
var querySize = Marshal.SizeOf(query);
- var queryPtr = Marshal.AllocHGlobal(querySize);
- Marshal.StructureToPtr(query, queryPtr, false);
+ var resultSize = Marshal.SizeOf<DEVICE_SEEK_PENALTY_DESCRIPTOR>();
+
+ IntPtr queryPtr = IntPtr.Zero;
+ IntPtr resultPtr = IntPtr.Zero;
- var result = new DEVICE_SEEK_PENALTY_DESCRIPTOR();
- var resultSize = Marshal.SizeOf(result);
- var resultPtr = Marshal.AllocHGlobal(resultSize);
+ try
+ {
+ queryPtr = Marshal.AllocHGlobal(querySize);
+ Marshal.StructureToPtr(query, queryPtr, false);
- var success = DeviceIoControl(handle, IOCTL_STORAGE_QUERY_PROPERTY,
- queryPtr, (uint)querySize,
- resultPtr, (uint)resultSize,
- out _, IntPtr.Zero);
+ resultPtr = Marshal.AllocHGlobal(resultSize);
- Marshal.FreeHGlobal(queryPtr);
+ var success = DeviceIoControl(handle, IOCTL_STORAGE_QUERY_PROPERTY,
+ queryPtr, (uint)querySize,
+ resultPtr, (uint)resultSize,
+ out _, IntPtr.Zero);
- if (!success)
+ if (!success)
+ return false;
+
+ var descriptor = Marshal.PtrToStructure<DEVICE_SEEK_PENALTY_DESCRIPTOR>(resultPtr);
+ return !descriptor.IncursSeekPenalty;
+ }
+ catch
{
- Marshal.FreeHGlobal(resultPtr);
return false;
}
+ finally
+ {
+ if (queryPtr != IntPtr.Zero)
+ Marshal.FreeHGlobal(queryPtr);
- result = Marshal.PtrToStructure<DEVICE_SEEK_PENALTY_DESCRIPTOR>(resultPtr);
- Marshal.FreeHGlobal(resultPtr);
-
- return !result.IncursSeekPenalty; // false = HDD, true = SSD
+ if (resultPtr != IntPtr.Zero)
+ Marshal.FreeHGlobal(resultPtr);
+ }
}
public static bool IsSystemDrive(string driveLetter)
@@ -435,36 +449,37 @@ public static class DiskHelper
internal static class DiskProvider
{
-
-
public static DiskInfo Get()
{
try
{
- var volumes = new List<DiskVolume>();
- var drives = DriveInfo.GetDrives().Where(d => d.IsReady);
+ static double ToGb(long bytes) => Math.Round(bytes / Math.Pow(1024, 3), 2);
- foreach (var drive in drives)
- {
- var totalBytes = drive.TotalSize;
- var freeBytes = drive.AvailableFreeSpace;
- var usedBytes = totalBytes - freeBytes;
-
- double toGb(long bytes) => Math.Round(bytes / Math.Pow(1024, 3), 2);
-
- volumes.Add(new DiskVolume(
- Name: drive.Name.TrimEnd('\\'),
- SystemDrive: DiskHelper.IsSystemDrive(drive.Name),
- FileSystem: drive.DriveFormat,
- DriveType: drive.DriveType.ToString(),
- Label: drive.VolumeLabel,
- TotalSizeGB: toGb(totalBytes),
- FreeSpaceGB: toGb(freeBytes),
- UsedSpaceGB: toGb(usedBytes),
- UsedPercent: totalBytes > 0 ? Math.Round(usedBytes * 100.0 / totalBytes, 1) : 0,
- DriveTypeDescription: DiskHelper.IsSSD(drive.Name) ? "SSD" : "HDD"
- ));
- }
+ var volumes = DriveInfo.GetDrives()
+ .Where(d => d.IsReady)
+ .Select(drive =>
+ {
+ var totalBytes = drive.TotalSize;
+ var freeBytes = drive.AvailableFreeSpace;
+ var usedBytes = totalBytes - freeBytes;
+
+ var isSystemDrive = DiskHelper.IsSystemDrive(drive.Name);
+ var isSsd = DiskHelper.IsSSD(drive.Name);
+
+ return new DiskVolume(
+ Name: drive.Name.TrimEnd('\\'),
+ SystemDrive: isSystemDrive,
+ FileSystem: drive.DriveFormat,
+ DriveType: drive.DriveType.ToString(),
+ Label: drive.VolumeLabel,
+ TotalSizeGB: ToGb(totalBytes),
+ FreeSpaceGB: ToGb(freeBytes),
+ UsedSpaceGB: ToGb(usedBytes),
+ UsedPercent: totalBytes > 0 ? Math.Round(usedBytes * 100.0 / totalBytes, 1) : 0,
+ DriveTypeDescription: isSsd ? "SSD" : "HDD"
+ );
+ })
+ .ToList();
return new DiskInfo(volumes);
}
@@ -806,25 +821,25 @@ public static class SystemInfoService
// Operating System Information
var osGroup = new List<IRenderable>
{
- new Rule("Operating System Information") { Style = Theme.Primary },
- new Markup($"[{Theme.Info}]Name :[/] [bold]{s.Os.Name}[/]"),
- new Markup($"[{Theme.Info}]Version :[/] [{Theme.Success}]{s.Os.Version}[/]"),
- new Markup($"[{Theme.Info}]Build Number :[/] [{Theme.Success}]{s.Os.BuildNumber}[/]"),
- new Markup($"[{Theme.Info}]Edition :[/] [{Theme.Warning}]{s.Os.Edition}[/]"),
- new Markup($"[{Theme.Info}]Architecture :[/] [bold]{s.Os.Architecture}[/]"),
- new Markup($"[{Theme.Info}]Device Type :[/] [bold]{s.Os.DeviceType}[/]"),
- new Markup($"[{Theme.Info}]Install Date :[/] [{Theme.Success}]{s.Os.InstallDate}[/]"),
- new Markup($"[{Theme.Info}]Last Boot :[/] [{Theme.Success}]{s.Os.LastBoot}[/]")
+ new Rule("Operating System Overview") { Style = Theme.Primary },
+ new Markup($"[{Theme.Info}]Name :[/] [bold]{s.Os.Name}[/]"),
+ new Markup($"[{Theme.Info}]Version :[/] [{Theme.Success}]{s.Os.Version}[/]"),
+ new Markup($"[{Theme.Info}]Build :[/] [{Theme.Success}]{s.Os.BuildNumber}[/]"),
+ new Markup($"[{Theme.Info}]Edition :[/] [{Theme.Warning}]{s.Os.Edition}[/]"),
+ new Markup($"[{Theme.Info}]Architecture :[/] [bold]{s.Os.Architecture}[/]"),
+ new Markup($"[{Theme.Info}]Device Type :[/] [bold]{s.Os.DeviceType}[/]"),
+ new Markup($"[{Theme.Info}]Installed On :[/] [{Theme.Success}]{s.Os.InstallDate}[/]"),
+ new Markup($"[{Theme.Info}]Last Boot :[/] [{Theme.Success}]{s.Os.LastBoot}[/]")
};
// BIOS Information
var biosGroup = new List<IRenderable>
{
- new Rule("BIOS Information") { Style = Theme.Success },
- new Markup($"[{Theme.Info}]Manufacturer :[/] [bold]{Safe(s.Bios.Manufacturer)}[/]"),
- new Markup($"[{Theme.Info}]Version :[/] [{Theme.Success}]{Safe(s.Bios.Version)}[/]"),
- new Markup($"[{Theme.Info}]Release Date :[/] [{Theme.Success}]{Safe(s.Bios.ReleaseDate)}[/]"),
- new Markup($"[{Theme.Info}]SMBIOS Version :[/] [{Theme.Success}]{Safe(s.Bios.SmbiosVersion)}[/]")
+ new Rule("BIOS Details") { Style = Theme.Success },
+ new Markup($"[{Theme.Info}]Manufacturer :[/] [bold]{Safe(s.Bios.Manufacturer)}[/]"),
+ new Markup($"[{Theme.Info}]Version :[/] [{Theme.Success}]{Safe(s.Bios.Version)}[/]"),
+ new Markup($"[{Theme.Info}]Release Date :[/] [{Theme.Success}]{Safe(s.Bios.ReleaseDate)}[/]"),
+ new Markup($"[{Theme.Info}]SMBIOS Revision :[/] [{Theme.Success}]{Safe(s.Bios.SmbiosVersion)}[/]")
};
// CPU Information
@@ -836,38 +851,39 @@ public static class SystemInfoService
};
var cpuGroup = new List<IRenderable>
{
- new Rule("CPU Information") { Style = Theme.Info },
- new Markup($"[{Theme.Info}]Name :[/] [bold]{Safe(s.Cpu.Name)}[/]"),
- new Markup($"[{Theme.Info}]Vendor :[/] [{cpuVendorColor}]{Safe(s.Cpu.Vendor)}[/]"),
- new Markup($"[{Theme.Info}]Manufacturer :[/] [bold]{Safe(s.Cpu.Manufacturer)}[/]"),
- new Markup($"[{Theme.Info}]Cores :[/] [{Theme.Success}]{s.Cpu.Cores}[/]"),
- new Markup($"[{Theme.Info}]Threads :[/] [{Theme.Success}]{s.Cpu.Threads}[/]"),
- new Markup($"[{Theme.Info}]Architecture :[/] [bold]{s.Cpu.Architecture}[/]"),
- new Markup($"[{Theme.Info}]Max Clock Speed:[/] [{Theme.Warning}]{s.Cpu.MaxClockMHz}[/] [dim]MHz[/]"),
- new Markup($"[{Theme.Info}]Current Speed :[/] [{Theme.Warning}]{s.Cpu.CurrentClockMHz}[/] [dim]MHz[/]"),
- new Markup($"[{Theme.Info}]L2 Cache :[/] [{Theme.Success}]{s.Cpu.L2CacheKB}[/] [dim]KB[/]"),
- new Markup($"[{Theme.Info}]L3 Cache :[/] [{Theme.Success}]{s.Cpu.L3CacheKB}[/] [dim]KB[/]")
+ new Rule("CPU Details") { Style = Theme.Info },
+ new Markup($"[{Theme.Info}]Name :[/] [bold]{Safe(s.Cpu.Name)}[/]"),
+ new Markup($"[{Theme.Info}]Vendor :[/] [{cpuVendorColor}]{Safe(s.Cpu.Vendor)}[/]"),
+ new Markup($"[{Theme.Info}]Manufacturer :[/] [bold]{Safe(s.Cpu.Manufacturer)}[/]"),
+ new Markup($"[{Theme.Info}]Physical Cores :[/] [{Theme.Success}]{s.Cpu.Cores}[/]"),
+ new Markup($"[{Theme.Info}]Logical Threads :[/] [{Theme.Success}]{s.Cpu.Threads}[/]"),
+ new Markup($"[{Theme.Info}]Architecture :[/] [bold]{s.Cpu.Architecture}[/]"),
+ new Markup($"[{Theme.Info}]Max Clock :[/] [{Theme.Warning}]{s.Cpu.MaxClockMHz}[/] [dim]MHz[/]"),
+ new Markup($"[{Theme.Info}]Current Clock :[/] [{Theme.Warning}]{s.Cpu.CurrentClockMHz}[/] [dim]MHz[/]"),
+ new Markup($"[{Theme.Info}]L2 Cache :[/] [{Theme.Success}]{s.Cpu.L2CacheKB}[/] [dim]KB[/]"),
+ new Markup($"[{Theme.Info}]L3 Cache :[/] [{Theme.Success}]{s.Cpu.L3CacheKB}[/] [dim]KB[/]")
};
// RAM Information
var usedColor = s.Ram.UsedPercent > 80 ? Theme.Error : Theme.Warning;
var ramGroup = new List<IRenderable>
{
- new Rule("Memory Information") { Style = new Style(Color.Yellow) },
+ new Rule("Memory Overview") { Style = new Style(Color.Yellow) },
new Markup(
- $"[{Theme.Info}]Total :[/] [{Theme.Success}]{s.Ram.TotalGB:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{s.Ram.TotalMB}[/] [dim]MB)[/]"),
- new Markup($"[{Theme.Info}]Available :[/] [{Theme.Success}]{s.Ram.AvailableGB:F2}[/] [dim]GB[/]"),
- new Markup($"[{Theme.Info}]Used :[/] [{usedColor}]{s.Ram.UsedPercent:F1}%[/]"),
+ $"[{Theme.Info}]Total Installed :[/] [{Theme.Success}]{s.Ram.TotalGB:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{s.Ram.TotalMB}[/] [dim]MB)[/]")
+ ,
+ new Markup($"[{Theme.Info}]Available :[/] [{Theme.Success}]{s.Ram.AvailableGB:F2}[/] [dim]GB[/]"),
+ new Markup($"[{Theme.Info}]Current Usage :[/] [{usedColor}]{s.Ram.UsedPercent:F1}%[/]"),
new BreakdownChart()
.Width(50)
.UseValueFormatter(v => $"{v:F2} GB")
.AddItem(
- "Used GB",
+ "Used",
s.Ram.UsedGB,
Color.FromHex(Theme.Warning))
.AddItem(
- "Available GB",
+ "Available",
s.Ram.AvailableGB,
Color.FromHex(Theme.Success)),
};
@@ -875,43 +891,43 @@ public static class SystemInfoService
if (s.Ram.Modules.Count > 0)
{
ramGroup.Add(new Markup(
- $"[{Theme.Info}]Modules :[/] [{Theme.Success}]{s.Ram.Modules.Count}[/] [dim]detected[/]"));
+ $"[{Theme.Info}]Detected Modules:[/] [{Theme.Success}]{s.Ram.Modules.Count}[/]"));
for (var i = 0; i < s.Ram.Modules.Count; i++)
{
var module = s.Ram.Modules[i];
ramGroup.Add(new Markup(
- $" [{Theme.Info}]Module {i + 1} :[/] [{Theme.Success}]{module.CapacityGB:F2}[/] [dim]GB @[/] [{Theme.Warning}]{module.SpeedMHz}[/] [dim]MHz[/]"));
- ramGroup.Add(new Markup($" [dim]Manufacturer:[/] [{Theme.Info}]{Safe(module.Manufacturer)}[/]"));
- ramGroup.Add(new Markup($" [dim]Part Number :[/] [bold]{Safe(module.PartNumber)}[/]"));
- ramGroup.Add(new Markup($" [dim]Location :[/] [bold]{Safe(module.DeviceLocator)}[/]"));
+ $" [{Theme.Info}]Module {i + 1} :[/] [{Theme.Success}]{module.CapacityGB:F2}[/] [dim]GB @[/] [{Theme.Warning}]{module.SpeedMHz}[/] [dim]MHz[/]"));
+ ramGroup.Add(new Markup($" [dim]Manufacturer :[/] [{Theme.Info}]{Safe(module.Manufacturer)}[/]"));
+ ramGroup.Add(new Markup($" [dim]Part Number :[/] [bold]{Safe(module.PartNumber)}[/]"));
+ ramGroup.Add(new Markup($" [dim]Slot :[/] [bold]{Safe(module.DeviceLocator)}[/]"));
}
}
// Disk Information
var diskGroup = new List<IRenderable>
{
- new Rule("Disk Information") { Style = Theme.Info }
+ new Rule("Storage Overview") { Style = Theme.Info }
};
foreach (var volume in s.Disk.Volumes)
{
var usedDiskColor = volume.UsedPercent > 90 ? Theme.Error : Theme.Warning;
- var systemDrive = volume.SystemDrive ? $" [{Theme.Success}][[System Drive]][/]" : "";
+ var systemDrive = volume.SystemDrive ? $" [{Theme.Success}][[System Volume]][/]" : "";
diskGroup.Add(new Markup($"[{Theme.Info}]{volume.Name} [bold white]{volume.Label}[/]{systemDrive}[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Type :[/] [bold]{volume.DriveTypeDescription}[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Total Size :[/] [{Theme.Success}]{volume.TotalSizeGB:F2}[/] [dim]GB[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Used Size :[/] [{Theme.Warning}]{volume.UsedSpaceGB:F2}[/] [dim]GB[/]"));
- diskGroup.Add(new Markup($" [{Theme.Info}]Free Space :[/] [{usedDiskColor}]{volume.FreeSpaceGB:F2}[/] [dim]GB[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Media Type :[/] [bold]{volume.DriveTypeDescription}[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Total Capacity :[/] [{Theme.Success}]{volume.TotalSizeGB:F2}[/] [dim]GB[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Used Capacity :[/] [{Theme.Warning}]{volume.UsedSpaceGB:F2}[/] [dim]GB[/]"));
+ diskGroup.Add(new Markup($" [{Theme.Info}]Free Capacity :[/] [{usedDiskColor}]{volume.FreeSpaceGB:F2}[/] [dim]GB[/]"));
diskGroup.Add(new BreakdownChart()
.Width(50)
.UseValueFormatter(v => $"{v:F2} GB")
.AddItem(
- "Used GB",
+ "Used",
volume.UsedSpaceGB,
Color.FromHex(usedDiskColor))
.AddItem(
- "Available GB",
+ "Available",
volume.FreeSpaceGB,
Color.FromHex(Theme.Success)));
}
@@ -924,13 +940,14 @@ public static class SystemInfoService
{
case 0:
case 1 when s.Gpus[0] == GpuInfo.Unknown:
- gpuGroup.Add(new Rule("GPU Information") { Style = new Style(Color.Red) });
- gpuGroup.Add(new Markup($"[{Theme.Error}]No GPUs detected[/]"));
+ gpuGroup.Add(new Rule("GPU Status") { Style = new Style(Color.Red) });
+ gpuGroup.Add(new Markup($"[{Theme.Error}]No discrete GPUs were detected.[/]"));
break;
case 1:
{
- gpuGroup.Add(new Rule("GPU Information") { Style = new Style(Color.Green) });
+ gpuGroup.Add(new Rule("Graphics Adapter") { Style = new Style(Color.Green) });
var gpu = s.Gpus[0];
+
var vendorColor = gpu.Vendor switch
{
GpuVendor.NVIDIA => Theme.Success,
@@ -939,28 +956,29 @@ public static class SystemInfoService
_ => Theme.Muted
};
- gpuGroup.Add(new Markup($"[{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
- gpuGroup.Add(new Markup($"[{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
- gpuGroup.Add(new Markup($"[{Theme.Info}]Driver Version :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Driver Version :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
if (gpu.MemoryMB.HasValue)
gpuGroup.Add(new Markup(
- $"[{Theme.Info}]Memory :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]"));
+ $"[{Theme.Info}]Frame Buffer :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]")
+ );
if (!string.IsNullOrEmpty(gpu.DeviceId))
- gpuGroup.Add(new Markup($"[{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
+ gpuGroup.Add(new Markup($"[{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
if (!string.IsNullOrEmpty(gpu.PnpDeviceId))
- gpuGroup.Add(new Markup($"[{Theme.Info}]PCI Device ID :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
+ gpuGroup.Add(new Markup($"[{Theme.Info}]PCI Identifier :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
break;
}
default:
{
- gpuGroup.Add(new Rule($"GPU Information ({gpuCount} detected)") { Style = new Style(Color.Green) });
+ gpuGroup.Add(new Rule($"GPU Inventory ({gpuCount} adapters)") { Style = new Style(Color.Green) });
for (var i = 0; i < s.Gpus.Count; i++)
{
var gpu = s.Gpus[i];
- var isPrimary = s.PrimaryGpu != null && gpu.Name == s.PrimaryGpu.Name ? $" [{Theme.Primary}][[Primary]][/]" : "";
+ var isPrimary = s.PrimaryGpu != null && gpu.Name == s.PrimaryGpu.Name ? $" [{Theme.Primary}][[Primary Adapter]][/]" : "";
var vendorColor = gpu.Vendor switch
{
GpuVendor.NVIDIA => Theme.Success,
@@ -970,20 +988,19 @@ public static class SystemInfoService
};
gpuGroup.Add(new Markup($"[{Theme.Info}]GPU {i + 1}{isPrimary}:[/]"));
- gpuGroup.Add(new Markup($" [{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
- gpuGroup.Add(
- new Markup($" [{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
- gpuGroup.Add(new Markup($" [{Theme.Info}]Driver :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
+ gpuGroup.Add(new Markup($" [{Theme.Info}]Name :[/] [bold]{Safe(gpu.Name)}[/]"));
+ gpuGroup.Add(new Markup($" [{Theme.Info}]Vendor :[/] [{vendorColor}]{gpu.Vendor}[/]"));
+ gpuGroup.Add(new Markup($" [{Theme.Info}]Driver :[/] [{Theme.Warning}]{Safe(gpu.DriverVersion)}[/]"));
if (gpu.MemoryMB.HasValue)
gpuGroup.Add(new Markup(
- $" [{Theme.Info}]Memory :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]"));
+ $" [{Theme.Info}]Frame Buffer :[/] [{Theme.Success}]{gpu.MemoryMB.Value / 1024.0:F2}[/] [dim]GB[/] [dim]([/][{Theme.Success}]{gpu.MemoryMB.Value}[/] [dim]MB)[/]"));
if (!string.IsNullOrEmpty(gpu.DeviceId))
- gpuGroup.Add(new Markup($" [{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
+ gpuGroup.Add(new Markup($" [{Theme.Info}]Device ID :[/] [dim]{Safe(gpu.DeviceId)}[/]"));
if (!string.IsNullOrEmpty(gpu.PnpDeviceId))
- gpuGroup.Add(new Markup($" [{Theme.Info}]PCI Device ID:[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
+ gpuGroup.Add(new Markup($" [{Theme.Info}]PCI Identifier :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));
}
break;
@@ -1018,11 +1035,8 @@ public static class SystemInfoService
catch (Exception ex)
{
log.LogError(ex, "Failed to generate detailed system info panel.");
- PromptDialog.Exception(ex, "An error occurred while displaying system information.",
- $"""
- This is an [{Theme.Error}]unhandled exception[/] that occurred while generating the detailed system information panel.
- """
- );
+ var details = $"This is an [{Theme.Error}]unhandled exception[/] that occurred while generating the detailed system information panel.";
+ PromptDialog.Exception(ex, "An error occurred while displaying system information.", details);
return null;
}
}
diff --git a/optimizerDuck/src/Core/Services/UpdateService.cs b/optimizerDuck/src/Core/Services/UpdateService.cs
index 1101c12..27423f9 100644
--- a/optimizerDuck/src/Core/Services/UpdateService.cs
+++ b/optimizerDuck/src/Core/Services/UpdateService.cs
@@ -97,7 +97,8 @@ public class UpdateService
Would you like to download and install it now?
""",
new PromptOption("Yes", Theme.Success),
- new PromptOption("Not now", Theme.Warning, () => false)))
+ new PromptOption("Not now", Theme.Warning, () => Task.FromResult(false))
+ ))
{
await DownloadAndApplyUpdate(updateExecutableAsset);
}
@@ -117,35 +118,51 @@ public class UpdateService
{
SystemHelper.Title("Downloading Update");
var tempDownloadPath = Path.Combine(Path.GetTempPath(), asset.Name);
-
- await AnsiConsole.Progress().StartAsync(async ctx =>
+ try
{
- Log.LogInformation("Downloading update from {DownloadUrl} to {TempPath}", asset.BrowserDownloadUrl, tempDownloadPath);
- var task = ctx.AddTask($"Downloading [{Theme.Primary}]{asset.Name}[/]");
-
- using var response = await HttpClient.GetAsync(asset.BrowserDownloadUrl, HttpCompletionOption.ResponseHeadersRead);
- response.EnsureSuccessStatusCode();
+ await AnsiConsole.Progress().StartAsync(async ctx =>
+ {
+ Log.LogInformation("Downloading update from {DownloadUrl} to {TempPath}", asset.BrowserDownloadUrl, tempDownloadPath);
+ var task = ctx.AddTask($"Downloading [{Theme.Primary}]{asset.Name}[/]");
- var totalBytes = response.Content.Headers.ContentLength ?? -1L;
- task.MaxValue = totalBytes;
+ using var response = await HttpClient.GetAsync(asset.BrowserDownloadUrl, HttpCompletionOption.ResponseHeadersRead);
+ response.EnsureSuccessStatusCode();
- await using var contentStream = await response.Content.ReadAsStreamAsync();
- await using var fileStream = new FileStream(tempDownloadPath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true);
+ var totalBytes = response.Content.Headers.ContentLength ?? -1L;
+ task.MaxValue = totalBytes;
- var buffer = new byte[8192];
- long downloadedBytes = 0;
- int bytesRead;
+ await using var contentStream = await response.Content.ReadAsStreamAsync();
+ await using var fileStream = new FileStream(tempDownloadPath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true);
- while ((bytesRead = await contentStream.ReadAsync(buffer.AsMemory(0, buffer.Length))) > 0)
- {
- await fileStream.WriteAsync(buffer.AsMemory(0, bytesRead));
- downloadedBytes += bytesRead;
- task.Value = downloadedBytes;
- }
- });
+ var buffer = new byte[8192];
+ long downloadedBytes = 0;
+ int bytesRead;
- Log.LogInformation("Download complete.");
- LaunchUpdater(tempDownloadPath);
+ while ((bytesRead = await contentStream.ReadAsync(buffer.AsMemory(0, buffer.Length))) > 0)
+ {
+ await fileStream.WriteAsync(buffer.AsMemory(0, bytesRead));
+ downloadedBytes += bytesRead;
+ task.Value = downloadedBytes;
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ Log.LogError(ex, "Error downloading update: {Message}", ex.Message);
+ PromptDialog.Warning("Download Failed", $"Failed to download the update: [{Theme.Error}]{ex.Message}[/]",
+ new PromptOption("Continue anyway", Theme.Success),
+ new PromptOption("Retry", Theme.Warning, async () =>
+ {
+ await DownloadAndApplyUpdate(asset);
+ })
+ );
+ return;
+ }
+ finally
+ {
+ Log.LogInformation("Download complete.");
+ LaunchUpdater(tempDownloadPath);
+ }
}
private static void LaunchUpdater(string newExePath)
diff --git a/optimizerDuck/src/Interfaces/IOptimizationTweak.cs b/optimizerDuck/src/Interfaces/IOptimization.cs
similarity index 89%
rename from optimizerDuck/src/Interfaces/IOptimizationTweak.cs
rename to optimizerDuck/src/Interfaces/IOptimization.cs
index 1d852f1..1343313 100644
--- a/optimizerDuck/src/Interfaces/IOptimizationTweak.cs
+++ b/optimizerDuck/src/Interfaces/IOptimization.cs
@@ -3,7 +3,7 @@ using optimizerDuck.Models;
namespace optimizerDuck.Interfaces;
-public interface IOptimizationTweak
+public interface IOptimization
{
public string Name { get; }
public string Description { get; }
diff --git a/optimizerDuck/src/Interfaces/IOptimizationGroup.cs b/optimizerDuck/src/Interfaces/IOptimizationGroup.cs
index f9600ee..3307349 100644
--- a/optimizerDuck/src/Interfaces/IOptimizationGroup.cs
+++ b/optimizerDuck/src/Interfaces/IOptimizationGroup.cs
@@ -1,10 +1,11 @@
using Microsoft.Extensions.Logging;
+using optimizerDuck.Models;
namespace optimizerDuck.Interfaces;
public interface IOptimizationGroup
{
public string Name { get; }
- public int Order { get; }
+ public OptimizationGroupOrder Order { get; }
public static abstract ILogger Log { get; }
}
\ No newline at end of file
diff --git a/optimizerDuck/src/Models/OptimizationTweakChoice.cs b/optimizerDuck/src/Models/OptimizationChoice.cs
similarity index 50%
rename from optimizerDuck/src/Models/OptimizationTweakChoice.cs
rename to optimizerDuck/src/Models/OptimizationChoice.cs
index 2f9111d..d4f44c7 100644
--- a/optimizerDuck/src/Models/OptimizationTweakChoice.cs
+++ b/optimizerDuck/src/Models/OptimizationChoice.cs
@@ -2,8 +2,8 @@
namespace optimizerDuck.Models;
-public record struct OptimizationTweakChoice(
- IOptimizationTweak? Instance,
+public record struct OptimizationChoice(
+ IOptimization? Instance,
string Name,
string Description,
bool EnabledByDefault);
\ No newline at end of file
diff --git a/optimizerDuck/src/Models/OptimizationGroupChoice.cs b/optimizerDuck/src/Models/OptimizationGroupChoice.cs
index 788a759..f0b4b67 100644
--- a/optimizerDuck/src/Models/OptimizationGroupChoice.cs
+++ b/optimizerDuck/src/Models/OptimizationGroupChoice.cs
@@ -1,3 +1,3 @@
namespace optimizerDuck.Models;
-public record struct OptimizationGroupChoice(string Name, int Priority, List<OptimizationTweakChoice> Tweaks);
\ No newline at end of file
+public record struct OptimizationGroupChoice(string Name, OptimizationGroupOrder Order, List<OptimizationChoice> Optimizations);
\ No newline at end of file
diff --git a/optimizerDuck/src/UI/Components/PromptDialog.cs b/optimizerDuck/src/UI/Components/PromptDialog.cs
index bb676cf..11b473d 100644
--- a/optimizerDuck/src/UI/Components/PromptDialog.cs
+++ b/optimizerDuck/src/UI/Components/PromptDialog.cs
@@ -85,7 +85,7 @@ public class PromptDialog
let color = option.Color
select (option, key, rest, color))
{
- buttonList.Add($"[{color}][underline]{key}[/]{rest}[/]");
+ buttonList.Add($"[{color}][underline bold]{key}[/]{rest}[/]");
keyMap[key] = option.Key;
}
@@ -114,7 +114,7 @@ public class PromptDialog
GlobalStatus.Current,
Spinner.Known.SimpleDotsScrolling,
_borderColor,
- "Select an option to continue"))
+ "Select an option (press its first character)"))
{
while (true)
{