Free, open-source Windows optimization tool for performance, privacy, and simplicity.
C# csharpdebloatdotnetgamingopen-sourceoptimizationoptimizeroptimizerduckperformanceprivacytweakertweakswindowswinui
Cleanup Code
itsfatduck3691773e7324
diff --git a/optimizerDuck.Test/RegistryServiceTests.cs b/optimizerDuck.Test/RegistryServiceTests.csindex 48d1308..1cad50c 100644--- a/optimizerDuck.Test/RegistryServiceTests.cs+++ b/optimizerDuck.Test/RegistryServiceTests.cs@@ -10,7 +10,6 @@ public class RegistryServiceTests[Fact]public void Read(){-var binary =RegistryService.Read<byte[]>(new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Logitech\LGHUB\Data","canary_machine_identifier"));diff --git a/optimizerDuck.Test/SystemInfoServiceTests.cs b/optimizerDuck.Test/SystemInfoServiceTests.csindex b6868ee..27b2a8f 100644--- a/optimizerDuck.Test/SystemInfoServiceTests.cs+++ b/optimizerDuck.Test/SystemInfoServiceTests.cs@@ -8,6 +8,7 @@ namespace optimizerDuck.Test;public class SystemInfoServiceTests{private static readonly ILogger Log = Logger.CreateLogger<SystemInfoServiceTests>();+[Fact]public void GetDetailedPanel_WithValidSnapshot_ReturnsPanel(){@@ -155,7 +156,7 @@ public class SystemInfoServiceTests);var disk = new DiskInfo([- new DiskVolume("C:", false, "NTFS", "Fixed", "New Volume", 250.0, 250.0, 50.0, 25.0, "SSD")+ new DiskVolume("C:", false, "NTFS", "Fixed", "New Volume", 250.0, 250.0, 50.0, 25.0, "SSD")]);return new SystemSnapshot(cpu, ram, os, bios, [gpu], gpu, disk);diff --git a/optimizerDuck.Test/optimizerDuck.Test.csproj b/optimizerDuck.Test/optimizerDuck.Test.csprojindex 2222cdc..ae371f0 100644--- a/optimizerDuck.Test/optimizerDuck.Test.csproj+++ b/optimizerDuck.Test/optimizerDuck.Test.csproj@@ -13,8 +13,8 @@<PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference>- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />- <PackageReference Include="xunit" Version="2.9.3" />+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0"/>+ <PackageReference Include="xunit" Version="2.9.3"/><PackageReference Include="xunit.runner.visualstudio" Version="3.1.5"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>@@ -22,11 +22,11 @@</ItemGroup><ItemGroup>- <Using Include="Xunit" />+ <Using Include="Xunit"/></ItemGroup><ItemGroup>- <ProjectReference Include="..\optimizerDuck\optimizerDuck.csproj" />+ <ProjectReference Include="..\optimizerDuck\optimizerDuck.csproj"/></ItemGroup></Project>diff --git a/optimizerDuck/Program.cs b/optimizerDuck/Program.csindex 24e817d..17277bf 100644--- a/optimizerDuck/Program.cs+++ b/optimizerDuck/Program.cs@@ -1,4 +1,5 @@-using Microsoft.Extensions.Logging;+using System.Text;+using Microsoft.Extensions.Logging;using optimizerDuck.Core;using optimizerDuck.Core.Extensions;using optimizerDuck.Core.Helpers;@@ -8,7 +9,6 @@ using optimizerDuck.UI;using optimizerDuck.UI.Components;using optimizerDuck.UI.Logger;using Spectre.Console;-using System.Text;namespace optimizerDuck;diff --git a/optimizerDuck/Properties/PublishProfiles/FolderProfile.pubxml b/optimizerDuck/Properties/PublishProfiles/FolderProfile.pubxmlindex 3b73cd6..0955921 100644--- a/optimizerDuck/Properties/PublishProfiles/FolderProfile.pubxml+++ b/optimizerDuck/Properties/PublishProfiles/FolderProfile.pubxml@@ -1,22 +1,22 @@<?xml version="1.0" encoding="utf-8"?><!-- https://go.microsoft.com/fwlink/?LinkID=208121. --><Project>- <PropertyGroup>- <Configuration>Release</Configuration>- <Platform>x64</Platform>- <PublishDir>bin\Release\net10.0\publish\win-x64\</PublishDir>- <PublishProtocol>FileSystem</PublishProtocol>- <_TargetId>Folder</_TargetId>- <TargetFramework>net10.0</TargetFramework>- <RuntimeIdentifier>win-x64</RuntimeIdentifier>- <DebugSymbols>false</DebugSymbols>- <DebugType>none</DebugType>- <SelfContained>true</SelfContained>- <PublishSingleFile>true</PublishSingleFile>- <PublishReadyToRun>true</PublishReadyToRun>- <EnableReadyToRunCompilation>true</EnableReadyToRunCompilation>- <EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>- <PublishTrimmed>false</PublishTrimmed>- <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>- </PropertyGroup>+ <PropertyGroup>+ <Configuration>Release</Configuration>+ <Platform>x64</Platform>+ <PublishDir>bin\Release\net10.0\publish\win-x64\</PublishDir>+ <PublishProtocol>FileSystem</PublishProtocol>+ <_TargetId>Folder</_TargetId>+ <TargetFramework>net10.0</TargetFramework>+ <RuntimeIdentifier>win-x64</RuntimeIdentifier>+ <DebugSymbols>false</DebugSymbols>+ <DebugType>none</DebugType>+ <SelfContained>true</SelfContained>+ <PublishSingleFile>true</PublishSingleFile>+ <PublishReadyToRun>true</PublishReadyToRun>+ <EnableReadyToRunCompilation>true</EnableReadyToRunCompilation>+ <EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>+ <PublishTrimmed>false</PublishTrimmed>+ <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>+ </PropertyGroup></Project>\ No newline at end of filediff --git a/optimizerDuck/app.manifest b/optimizerDuck/app.manifestindex d9ba815..99ac989 100644--- a/optimizerDuck/app.manifest+++ b/optimizerDuck/app.manifest@@ -40,7 +40,7 @@<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--><!-- Windows 10 -->- <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/></application></compatibility>diff --git a/optimizerDuck/optimizerDuck.csproj b/optimizerDuck/optimizerDuck.csprojindex 74fea60..3c82ddc 100644--- a/optimizerDuck/optimizerDuck.csproj+++ b/optimizerDuck/optimizerDuck.csproj@@ -18,17 +18,17 @@</PropertyGroup><ItemGroup>- <PackageReference Include="ConsoleInk.Net" Version="0.1.6" />- <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.0" />- <PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0" />- <PackageReference Include="Microsoft.PowerShell.SDK" Version="7.5.4" />- <PackageReference Include="Newtonsoft.Json" Version="13.0.4" />- <PackageReference Include="Serilog" Version="4.3.1-dev-02387" />- <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />- <PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />- <PackageReference Include="Spectre.Console" Version="0.53.0" />- <PackageReference Include="System.Management" Version="10.0.0" />- <PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.0" />- <PackageReference Include="vertical-spectreconsolelogger" Version="0.10.1-dev.20241201.35" />+ <PackageReference Include="ConsoleInk.Net" Version="0.1.6"/>+ <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.0"/>+ <PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0"/>+ <PackageReference Include="Microsoft.PowerShell.SDK" Version="7.5.4"/>+ <PackageReference Include="Newtonsoft.Json" Version="13.0.4"/>+ <PackageReference Include="Serilog" Version="4.3.1-dev-02387"/>+ <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2"/>+ <PackageReference Include="Serilog.Sinks.File" Version="7.0.0"/>+ <PackageReference Include="Spectre.Console" Version="0.53.0"/>+ <PackageReference Include="System.Management" Version="10.0.0"/>+ <PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.0"/>+ <PackageReference Include="vertical-spectreconsolelogger" Version="0.10.1-dev.20241201.35"/></ItemGroup></Project>diff --git a/optimizerDuck/src/Core/Defaults.cs b/optimizerDuck/src/Core/Defaults.csindex f79a741..b5e826f 100644--- a/optimizerDuck/src/Core/Defaults.cs+++ b/optimizerDuck/src/Core/Defaults.cs@@ -1,14 +1,12 @@-using optimizerDuck.UI;+using System.Diagnostics;+using optimizerDuck.UI;using optimizerDuck.UI.Components;using Spectre.Console;-using System.Diagnostics;namespace optimizerDuck.Core;public static class Defaults{- public static bool IsDebug = Environment.GetCommandLineArgs().Contains("--debug");-public const string RawLogo = """_ _ _ _____ _| | (_) (_) | __ \ | |@@ -39,6 +37,7 @@ public static class Defaultspublic const string RestorePointName = "optimizerDuck Restore Point";public const string PowerPlanGUID = "946c0ca5-6ee0-4f2a-9dd7-7addbb8e60f5";+ public static bool IsDebug = Environment.GetCommandLineArgs().Contains("--debug");public static readonly Panel Logo = new(new Align(@@ -57,7 +56,7 @@ public static class Defaults// @formatter:onHorizontalAlignment.Center))- { Border = CustomBoxBorder.UnderlineBorder, Padding = new Padding(0, 1, 0, 1) };+ { Border = CustomBoxBorder.UnderlineBorder, Padding = new Padding(0, 1, 0, 1) };public static readonly string ExePath = Environment.ProcessPath!;public static readonly string ExeDir = Path.GetDirectoryName(ExePath)!;diff --git a/optimizerDuck/src/Core/Extensions/EnumExtensions.cs b/optimizerDuck/src/Core/Extensions/EnumExtensions.csindex 2cc059a..396f0b7 100644--- a/optimizerDuck/src/Core/Extensions/EnumExtensions.cs+++ b/optimizerDuck/src/Core/Extensions/EnumExtensions.cs@@ -1,23 +1,22 @@using System.ComponentModel;using System.Reflection;-namespace optimizerDuck.Core.Extensions+namespace optimizerDuck.Core.Extensions;++public static class EnumExtensions{- public static class EnumExtensions+ public static string GetDescription(this Enum value){- public static string GetDescription(this Enum value)- {- if (value == null) return string.Empty;+ if (value == null) return string.Empty;- var type = value.GetType();- var name = value.ToString();+ var type = value.GetType();+ var name = value.ToString();- var field = type.GetField(name);- if (field == null)- return name;+ var field = type.GetField(name);+ if (field == null)+ return name;- var attribute = field.GetCustomAttribute<DescriptionAttribute>(false);- return attribute?.Description ?? name;- }+ var attribute = field.GetCustomAttribute<DescriptionAttribute>(false);+ return attribute?.Description ?? name;}-}+}\ No newline at end of filediff --git a/optimizerDuck/src/Core/Extensions/TextExtensions.cs b/optimizerDuck/src/Core/Extensions/TextExtensions.csindex 8d09cc3..31599a5 100644--- a/optimizerDuck/src/Core/Extensions/TextExtensions.cs+++ b/optimizerDuck/src/Core/Extensions/TextExtensions.cs@@ -94,7 +94,7 @@ public static class TextExtensionsreturn xml;}}-+public static string EncodeBase64(this string value){if (string.IsNullOrEmpty(value))@@ -114,7 +114,7 @@ public static class TextExtensions{if (string.IsNullOrEmpty(value))return string.Empty;-+try{var bytes = Convert.FromBase64String(value);diff --git a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs b/optimizerDuck/src/Core/Helpers/OptimizationHelper.csindex 08fcb75..6699b39 100644--- a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs+++ b/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs@@ -1,4 +1,5 @@-using Microsoft.Extensions.Caching.Memory;+using System.Reflection;+using Microsoft.Extensions.Caching.Memory;using Microsoft.Extensions.Logging;using Newtonsoft.Json;using optimizerDuck.Core.Extensions;@@ -9,7 +10,6 @@ using optimizerDuck.Models;using optimizerDuck.UI;using optimizerDuck.UI.Logger;using Spectre.Console;-using System.Reflection;namespace optimizerDuck.Core.Helpers;@@ -23,7 +23,8 @@ public static class OptimizationHelper{entry.Priority = CacheItemPriority.NeverRemove;- var optimizationCategories = ReflectionHelper.FindImplementationsInLoadedAssemblies(typeof(IOptimizationCategory))+ var optimizationCategories = ReflectionHelper+ .FindImplementationsInLoadedAssemblies(typeof(IOptimizationCategory)).ToArray();var allOptimizationsByCategory = optimizationCategories@@ -39,7 +40,8 @@ public static class OptimizationHelpervar allOptimizations = allOptimizationsByCategory.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 maxImpactLength =+ allOptimizations.DefaultIfEmpty().Max(t => t?.Impact.GetDescription().Length ?? 0) + 1;var categories = new List<OptimizationCategoryChoice>();@@ -68,7 +70,8 @@ public static class OptimizationHelper{Log.LogDebug("Loaded category [{Category}]:", g.Name);foreach (var t in g.Optimizations)- Log.LogDebug(" - {OptimizationName} {OptimizationDescription}", t.Name, Markup.Remove(t.Description));+ Log.LogDebug(" - {OptimizationName} {OptimizationDescription}", t.Name,+ Markup.Remove(t.Description));}return orderedCategories;@@ -96,14 +99,14 @@ public static class OptimizationHelper}return $false} | Select-Object Name, Version, InstallLocation-+$cautionInstalled = $installedApps | Where-Object {foreach ($s in $cautionApps) {if ($_.Name.ToLower() -like "*$($s.ToLower())*") { return $true }}return $false} | Select-Object Name, Version, InstallLocation-+# create the JSON object$result = [PSCustomObject]@{SafeApps = @($safeInstalled | ForEach-Object {@@ -162,7 +165,10 @@ public static class OptimizationHelper{return app with{- DisplayName = Defaults.SAFE_APPS.TryGetValue(app.Name, out var dn) ? dn : app.Name // get display name or fallback to app name+ DisplayName =+ Defaults.SAFE_APPS.TryGetValue(app.Name, out var dn)+ ? dn+ : app.Name // get display name or fallback to app name};}).OrderBy(x => x.DisplayName)diff --git a/optimizerDuck/src/Core/Helpers/ReflectionHelper.cs b/optimizerDuck/src/Core/Helpers/ReflectionHelper.csindex 8c49d73..264dad0 100644--- a/optimizerDuck/src/Core/Helpers/ReflectionHelper.cs+++ b/optimizerDuck/src/Core/Helpers/ReflectionHelper.cs@@ -32,7 +32,8 @@ public static class ReflectionHelperentry.SlidingExpiration = TimeSpan.FromMinutes(5);return AppDomain.CurrentDomain.GetAssemblies().SelectMany(SafeGetTypes)- .Where(t => t != interfaceType && t is { IsClass: true, IsAbstract: false } && interfaceType.IsAssignableFrom(t))+ .Where(t => t != interfaceType && t is { IsClass: true, IsAbstract: false } &&+ interfaceType.IsAssignableFrom(t)).ToList();});}diff --git a/optimizerDuck/src/Core/Helpers/RequirementChecker.cs b/optimizerDuck/src/Core/Helpers/RequirementChecker.csindex a6eef42..44918d9 100644--- a/optimizerDuck/src/Core/Helpers/RequirementChecker.cs+++ b/optimizerDuck/src/Core/Helpers/RequirementChecker.cs@@ -1,11 +1,11 @@-using Microsoft.Extensions.Logging;+using System.ComponentModel;+using System.Diagnostics;+using System.Security.Principal;+using Microsoft.Extensions.Logging;using optimizerDuck.Core.Services;using optimizerDuck.UI;using optimizerDuck.UI.Components;using optimizerDuck.UI.Logger;-using System.ComponentModel;-using System.Diagnostics;-using System.Security.Principal;namespace optimizerDuck.Core.Helpers;@@ -29,9 +29,9 @@ public static class RequirementCheckerPromptDialog.Warning("Untested Operating System","""- This optimizer has not been tested on non-Windows operating systems.- You may continue at your own risk, but some features may not work as expected.- """,+ This optimizer has not been tested on non-Windows operating systems.+ You may continue at your own risk, but some features may not work as expected.+ """,new PromptOption("Exit", Theme.Error, () => Environment.Exit(1)),new PromptOption("Continue anyway", Theme.Warning));@@ -44,10 +44,10 @@ public static class RequirementCheckerPromptDialog.Warning("Untested Windows Version",$"""- Your Windows version [{Theme.Error}]{s.Os.Version}[/] has not been tested with this optimizer.- It is recommended to use Windows 10 or later.- [{Theme.WarningMuted}]You may continue anyway, but some features may not behave as expected.[/]- """,+ Your Windows version [{Theme.Error}]{s.Os.Version}[/] has not been tested with this optimizer.+ It is recommended to use Windows 10 or later.+ [{Theme.WarningMuted}]You may continue anyway, but some features may not behave as expected.[/]+ """,new PromptOption("Exit", Theme.Error, () => Environment.Exit(1)),new PromptOption("Continue anyway", Theme.Warning));@@ -60,10 +60,10 @@ public static class RequirementCheckerPromptDialog.Warning("Untested Operating System Architecture",$"""- Your system architecture [{Theme.Error}]{s.Os.Architecture}[/] has not been tested.- This optimizer is designed for 64-bit Windows systems.- [{Theme.WarningMuted}]You may continue anyway, but some features may not work properly.[/]- """,+ Your system architecture [{Theme.Error}]{s.Os.Architecture}[/] has not been tested.+ This optimizer is designed for 64-bit Windows systems.+ [{Theme.WarningMuted}]You may continue anyway, but some features may not work properly.[/]+ """,new PromptOption("Exit", Theme.Error, () => Environment.Exit(1)),new PromptOption("Continue anyway", Theme.Warning));diff --git a/optimizerDuck/src/Core/Helpers/StreamHelper.cs b/optimizerDuck/src/Core/Helpers/StreamHelper.csindex fabbb90..6474d18 100644--- a/optimizerDuck/src/Core/Helpers/StreamHelper.cs+++ b/optimizerDuck/src/Core/Helpers/StreamHelper.cs@@ -28,7 +28,8 @@ public static class StreamHelperawait response.Content.CopyToAsync(fs).ConfigureAwait(false);var length = fs.Length;- Log.LogInformation("Successfully downloaded {Length} bytes from {Url} to {FilePath}", length, url, filePath);+ Log.LogInformation("Successfully downloaded {Length} bytes from {Url} to {FilePath}", length, url,+ filePath);return (true, filePath);}diff --git a/optimizerDuck/src/Core/Helpers/SystemHelper.cs b/optimizerDuck/src/Core/Helpers/SystemHelper.csindex f7f3956..484c17e 100644--- a/optimizerDuck/src/Core/Helpers/SystemHelper.cs+++ b/optimizerDuck/src/Core/Helpers/SystemHelper.cs@@ -1,9 +1,9 @@-using Microsoft.Extensions.Logging;+using System.Diagnostics;+using Microsoft.Extensions.Logging;using Newtonsoft.Json;using optimizerDuck.Core.Services;using optimizerDuck.UI;using optimizerDuck.UI.Logger;-using System.Diagnostics;namespace optimizerDuck.Core.Helpers;@@ -46,11 +46,11 @@ public static class SystemHelpertry{var result = ShellService.PowerShell($$"""- @{- SelfPath = (Get-MpPreference).ExclusionPath -contains "{{exePath}}";- RootPath = (Get-MpPreference).ExclusionPath -contains "{{rootPath}}"- } | ConvertTo-Json- """);+ @{+ SelfPath = (Get-MpPreference).ExclusionPath -contains "{{exePath}}";+ RootPath = (Get-MpPreference).ExclusionPath -contains "{{rootPath}}"+ } | ConvertTo-Json+ """);var exclusions = JsonConvert.DeserializeObject<Dictionary<string, bool>>(result.Stdout);var missingPaths = new List<string>();if (exclusions != null && exclusions.TryGetValue("SelfPath", out var selfPathExcluded) && !selfPathExcluded)@@ -64,6 +64,7 @@ public static class SystemHelperLog.LogWarning("Path not excluded: {RootPath}", rootPath);missingPaths.Add(rootPath);}+return missingPaths;}catch (Exception ex)diff --git a/optimizerDuck/src/Core/Helpers/SystemProtectionHelper.cs b/optimizerDuck/src/Core/Helpers/SystemProtectionHelper.csindex 10b5795..e5cf40c 100644--- a/optimizerDuck/src/Core/Helpers/SystemProtectionHelper.cs+++ b/optimizerDuck/src/Core/Helpers/SystemProtectionHelper.cs@@ -53,8 +53,9 @@ public static class SystemProtectionHelpernew PromptOption("Skip", Theme.Error));}else+ {Log.LogInformation($"[{Theme.Success}]A restore point [{Theme.Primary}]{Defaults.RestorePointName}[/] created successfully.[/]");-+ }}}\ No newline at end of filediff --git a/optimizerDuck/src/Core/Managers/OptimizationManager.cs b/optimizerDuck/src/Core/Managers/OptimizationManager.csindex 925f019..761908f 100644--- a/optimizerDuck/src/Core/Managers/OptimizationManager.cs+++ b/optimizerDuck/src/Core/Managers/OptimizationManager.cs@@ -1,4 +1,5 @@-using Microsoft.Extensions.Logging;+using System.Diagnostics;+using Microsoft.Extensions.Logging;using optimizerDuck.Core.Extensions;using optimizerDuck.Core.Helpers;using optimizerDuck.Core.Optimizers;@@ -8,7 +9,6 @@ using optimizerDuck.UI;using optimizerDuck.UI.Components;using optimizerDuck.UI.Logger;using Spectre.Console;-using System.Diagnostics;using ILogger = Microsoft.Extensions.Logging.ILogger;namespace optimizerDuck.Core.Managers;@@ -25,14 +25,14 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)public async Task<bool> Begin(){-AnsiConsole.Clear();AnsiConsole.Write(Defaults.Logo);Log.LogInformation("Loading optimizations...");var optimizationCategories = OptimizationHelper.LoadOptimizationChoices();- Log.LogInformation("Loaded {CategoriesAmount} categories with {OptimizationAmount} optimizations.", optimizationCategories.Count,+ Log.LogInformation("Loaded {CategoriesAmount} categories with {OptimizationAmount} optimizations.",+ optimizationCategories.Count,optimizationCategories.Sum(g => g.Optimizations.Count));SystemHelper.Title("Select the optimizations you want to apply");@@ -55,27 +55,24 @@ public class OptimizationManager(SystemSnapshot systemSnapshot));var optimizationsToSelect = _selectedOptimizations.Count == 0- ? optimizationCategories.SelectMany(g => g.Optimizations).Where(t => t.EnabledByDefault)- : _selectedOptimizations;+ ? optimizationCategories.SelectMany(g => g.Optimizations).Where(t => t.EnabledByDefault)+ : _selectedOptimizations;- foreach (var optimization in optimizationsToSelect)- {- promptOptimizationChoice.Select(optimization);- }+ foreach (var optimization in optimizationsToSelect) promptOptimizationChoice.Select(optimization);var optimizationChoices =await escapeCancellableConsole.PromptAsync(promptOptimizationChoice).ConfigureAwait(false);_selectedOptimizations = new Queue<OptimizationChoice>(optimizationChoices);- if (_selectedOptimizations.Any(t => t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selected+ if (_selectedOptimizations.Any(t =>+ t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selected{Log.LogInformation("Getting installed bloatware apps...");var appxClassification = OptimizationHelper.GetBloatwareChoices();if (appxClassification.SafeApps.Count == 0 && appxClassification.CautionApps.Count == 0)- {return PromptDialog.Warning("No Bloatware Detected",$"""@@ -86,7 +83,6 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)new PromptOption("Continue", Theme.Success, () => true),new PromptOption("Back", Theme.Warning, () => false));- }SystemHelper.Title("Select the bloatware apps you want to remove");var promptBloatware = new MultiSelectionPrompt<AppxPackage>()@@ -104,7 +100,8 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)promptBloatware.AddChoiceGroup(new AppxPackage{- DisplayName = $"[bold underline {Theme.Success}]Safe Apps[/] - [{Theme.Success}]Safe to remove[/]",+ DisplayName =+ $"[bold underline {Theme.Success}]Safe Apps[/] - [{Theme.Success}]Safe to remove[/]",Name = "",Version = "",InstallLocation = ""@@ -115,7 +112,8 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)promptBloatware.AddChoiceGroup(new AppxPackage{- DisplayName = $"[bold underline {Theme.Error}]Caution Apps[/] - [{Theme.Error}]May cause issues[/]",+ DisplayName =+ $"[bold underline {Theme.Error}]Caution Apps[/] - [{Theme.Error}]May cause issues[/]",Name = "",Version = "",InstallLocation = ""@@ -175,10 +173,11 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)_systemSnapshot = await SystemInfoService.RefreshAsync().ConfigureAwait(false);Log.LogDebug("Selected {OptimizationAmount} optimizations: {Optimizations}",- _selectedOptimizations.Count,- string.Join(", ", _selectedOptimizations.Select(t => t.Name)));+ _selectedOptimizations.Count,+ string.Join(", ", _selectedOptimizations.Select(t => t.Name)));- if (_selectedOptimizations.Any(t => t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selected+ if (_selectedOptimizations.Any(t =>+ t.Instance is BloatwareAndServices.RemoveBloatwareApps)) // if Bloatware selection is selectedLog.LogDebug("Selected {BloatwareAmount} bloatware apps: {BloatwareApps}", SelectedBloatware.Count,string.Join(", ", SelectedBloatware.Select(app => $"{app.DisplayName.Trim()} ({app.Version.Trim()})")));@@ -190,7 +189,6 @@ public class OptimizationManager(SystemSnapshot systemSnapshot).StartAsyncGlobal("Initializing Optimization", async ctx =>{while (_selectedOptimizations.TryDequeue(out var selectedOptimization))- {try{cancellationToken.ThrowIfCancellationRequested();@@ -202,7 +200,8 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)};SystemHelper.Title(selectedOptimization.Name);- ctx.Status($"Applying [{Theme.Primary}]{selectedOptimization.Name}[/]... [{Theme.Muted}][[Press [{Theme.Error}]CTRL + C[/] to cancel the optimization]][/]");+ ctx.Status(+ $"Applying [{Theme.Primary}]{selectedOptimization.Name}[/]... [{Theme.Muted}][[Press [{Theme.Error}]CTRL + C[/] to cancel the optimization]][/]");using var scope = Log.BeginScope("Optimization: {OptimizationName}", selectedOptimization.Name);@@ -212,7 +211,8 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)var stopwatch = Stopwatch.StartNew();- await selectedOptimization.Instance!.Apply(_systemSnapshot, cancellationToken).ConfigureAwait(false);+ await selectedOptimization.Instance!.Apply(_systemSnapshot, cancellationToken)+ .ConfigureAwait(false);//await Task.Delay(5000, cancellationToken);stopwatch.Stop();@@ -224,14 +224,13 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)}catch (Exception e){- Log.LogError(e, "Failed to apply optimization {OptimizationName}. Skipped.", selectedOptimization.Name);+ Log.LogError(e, "Failed to apply optimization {OptimizationName}. Skipped.",+ selectedOptimization.Name);}finally{Log.LogDebug(new string('=', 60));}- }-});if (cancellationToken.IsCancellationRequested)@@ -255,9 +254,9 @@ public class OptimizationManager(SystemSnapshot systemSnapshot)PromptDialog.Warning("Restart to Apply Changes",$"""- The optimizations have been applied successfully.- Please [{Theme.Success}]restart[/] your PC for the changes to take effect.- """,+ 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.csindex 9dd9b66..7f60981 100644--- a/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs+++ b/optimizerDuck/src/Core/Optimizers/BloatwareAndServices.cs@@ -34,17 +34,21 @@ public class BloatwareAndServices : IOptimizationCategorywhile (OptimizationManager.SelectedBloatware.TryDequeue(out var appxPackage)){t.ThrowIfCancellationRequested();- appxPackage = appxPackage with { DisplayName = appxPackage.DisplayName.Trim(), Version = appxPackage.Version.Trim() };- Log.LogInformation($"Removing bloatware app: [{Theme.Primary}]{appxPackage.DisplayName}[/] [{Theme.Success}]{appxPackage.Version}[/] ([dim]{appxPackage.Name}[/])");+ appxPackage = appxPackage with+ {+ DisplayName = appxPackage.DisplayName.Trim(), Version = appxPackage.Version.Trim()+ };+ Log.LogInformation(+ $"Removing bloatware app: [{Theme.Primary}]{appxPackage.DisplayName}[/] [{Theme.Success}]{appxPackage.Version}[/] ([dim]{appxPackage.Name}[/])");ShellService.PowerShell($$"""- $packages = Get-AppxPackage -AllUsers | Where-Object { $_.Name -eq "{{appxPackage.Name}}" }- Write-Output "Found $($packages.Count) packages for {{appxPackage.Name}}"- foreach ($pkg in $packages) {- Write-Output "Removing $($pkg.PackageFullName)"- Remove-AppxPackage -Package $pkg.PackageFullName -AllUsers- }- """);+ $packages = Get-AppxPackage -AllUsers | Where-Object { $_.Name -eq "{{appxPackage.Name}}" }+ Write-Output "Found $($packages.Count) packages for {{appxPackage.Name}}"+ foreach ($pkg in $packages) {+ Write-Output "Removing $($pkg.PackageFullName)"+ Remove-AppxPackage -Package $pkg.PackageFullName -AllUsers+ }+ """);}Log.LogInformation("Bloatware apps have been removed.");@@ -402,14 +406,16 @@ public class BloatwareAndServices : IOptimizationCategory);Log.LogInformation("Services have been configured.");- var hasSystemSSD = s.Disk.Volumes.Any(volume => volume is { SystemDrive: true, DriveTypeDescription: "SSD" });+ var hasSystemSSD =+ s.Disk.Volumes.Any(volume => volume is { SystemDrive: true, DriveTypeDescription: "SSD" });ServiceProcessService.ChangeServiceStartupType(hasSystemSSD // Enable SysMain on SSD? new ServiceItem("SysMain", ServiceStartupType.Automatic): new ServiceItem("SysMain", ServiceStartupType.Disabled));- Log.LogDebug("System drive is {Type}, SysMain will be {Status}.", hasSystemSSD ? "SSD" : "HDD", hasSystemSSD ? "enabled" : "disabled");+ Log.LogDebug("System drive is {Type}, SysMain will be {Status}.", hasSystemSSD ? "SSD" : "HDD",+ hasSystemSSD ? "enabled" : "disabled");return Task.CompletedTask;}diff --git a/optimizerDuck/src/Core/Optimizers/Performance.cs b/optimizerDuck/src/Core/Optimizers/Performance.csindex fd21b57..ce096ad 100644--- a/optimizerDuck/src/Core/Optimizers/Performance.cs+++ b/optimizerDuck/src/Core/Optimizers/Performance.cs@@ -17,7 +17,10 @@ public class Performance : IOptimizationCategorypublic 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";++ public string Description { get; } =+ "Stops background applications from running to free up RAM and CPU resources";+public bool EnabledByDefault { get; } = true;public OptimizationImpact Impact { get; } = OptimizationImpact.Minimal;@@ -28,8 +31,10 @@ public class Performance : IOptimizationCategoryusing 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)+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications",+ "GlobalUserDisabled", 1),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search", "BackgroundAppGlobalToggle",+ 0));Log.LogInformation("Disabled background applications.");return Task.CompletedTask;@@ -39,7 +44,10 @@ public class Performance : IOptimizationCategorypublic 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";++ public string Description { get; } =+ "Adjusts foreground app priority for better responsiveness and reduced input lag";+public bool EnabledByDefault { get; } = true;public OptimizationImpact Impact { get; } = OptimizationImpact.Significant;@@ -72,9 +80,11 @@ public class Performance : IOptimizationCategoryRegistryService.Write(- new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl", "Win32PrioritySeparation", win32Priority)+ new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl", "Win32PrioritySeparation",+ win32Priority));- Log.LogInformation("Applied process priority optimization (Win32PrioritySeparation = {Value}).", win32Priority);+ Log.LogInformation("Applied process priority optimization (Win32PrioritySeparation = {Value}).",+ win32Priority);return Task.CompletedTask;}}@@ -92,12 +102,22 @@ public class Performance : IOptimizationCategoryusing var tracker = ServiceTracker.Begin(Log);RegistryService.Write(- new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "Priority", 2),- new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "Scheduling Category", "High"),- new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "SFIO Priority", "High"),- new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "GPU Priority", 8),- new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", unchecked((int)0xFFFFFFFF), RegistryValueKind.DWord),- new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "SystemResponsiveness", 10),+ new RegistryItem(+ @"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games",+ "Priority", 2),+ new RegistryItem(+ @"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games",+ "Scheduling Category", "High"),+ new RegistryItem(+ @"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games",+ "SFIO Priority", "High"),+ new RegistryItem(+ @"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games",+ "GPU Priority", 8),+ new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile",+ "NetworkThrottlingIndex", unchecked((int)0xFFFFFFFF), RegistryValueKind.DWord),+ new RegistryItem(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile",+ "SystemResponsiveness", 10),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers", "HwSchMode", 2));Log.LogInformation("Optimized gaming scheduling and priority.");@@ -108,7 +128,10 @@ public class Performance : IOptimizationCategorypublic 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.";++ public string Description { get; } =+ "Adjusts SvcHostSplitThresholdInKB based on total system RAM to control service isolation and improve system stability.";+public bool EnabledByDefault { get; } = true;public OptimizationImpact Impact { get; } = OptimizationImpact.Significant;@@ -122,8 +145,10 @@ public class Performance : IOptimizationCategoryLog.LogInformation("Invalid RAM value: {RamTotalKB}. Skipping...", s.Ram.TotalKB);return Task.CompletedTask;}+RegistryService.Write(- new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control", "SvcHostSplitThresholdInKB", s.Ram.TotalKB, RegistryValueKind.DWord)+ new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control", "SvcHostSplitThresholdInKB", s.Ram.TotalKB,+ RegistryValueKind.DWord));Log.LogInformation("Set SvcHostSplitThresholdInKB to {Value}.", s.Ram.TotalKB);return Task.CompletedTask;@@ -131,8 +156,6 @@ public class Performance : IOptimizationCategory}--public class DisableGameBar : IOptimization{public string Name { get; } = "Disable Game Bar";@@ -212,7 +235,8 @@ public class Performance : IOptimizationCategory{public string Name { get; } = "GPU Optimization";- public string Description { get; } = "Optimizes GPU driver settings to disable unnecessary features and improve stability & performance";+ public string Description { get; } =+ "Optimizes GPU driver settings to disable unnecessary features and improve stability & performance";public bool EnabledByDefault { get; } = true;public OptimizationImpact Impact { get; } = OptimizationImpact.Significant;@@ -262,7 +286,8 @@ public class Performance : IOptimizationCategorynew RegistryItem(path, "DisablePowerGating", 1),new RegistryItem(path, "DisableVceClockGating", 1));- Log.LogInformation("Applied AMD GPU optimizations 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:@@ -270,7 +295,8 @@ public class Performance : IOptimizationCategorynew RegistryItem(path, "DisableDynamicPstate", 1),new RegistryItem(path, "DisableASyncPstates", 1));- Log.LogInformation("Applied NVIDIA GPU optimizations 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:@@ -282,7 +308,8 @@ public class Performance : IOptimizationCategorynew RegistryItem(path, "EnableCompensationForDVI", 1),new RegistryItem(path, "Display1_DisableAsyncFlips", 1));- Log.LogInformation("Applied Intel GPU optimizations 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/SecurityAndPrivacy.cs b/optimizerDuck/src/Core/Optimizers/SecurityAndPrivacy.csindex e1361d7..006f7d7 100644--- a/optimizerDuck/src/Core/Optimizers/SecurityAndPrivacy.cs+++ b/optimizerDuck/src/Core/Optimizers/SecurityAndPrivacy.cs@@ -159,21 +159,25 @@ public class SecurityAndPrivacy : IOptimizationCategoryRegistryService.Write(new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\AppModel", "Start", 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\Cellcore", "Start", 0),- new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\CloudExperienceHostOobe", "Start", 0),+ new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\CloudExperienceHostOobe",+ "Start", 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\DataMarket", "Start", 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\DefenderApiLogger", "Start", 0),- new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\DefenderAuditLogger", "Start", 0),+ new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\DefenderAuditLogger", "Start",+ 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\DiagLog", "Start", 0),- new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\Diagtrack-Listener", "Start", 0),+ new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\Diagtrack-Listener", "Start",+ 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\LwtNetLog", "Start", 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\SQMLogger", "Start", 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\WdiContextLog", "Start", 0),new RegistryItem(@"HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\WiFiSession", "Start", 0)- );+ );Log.LogInformation("Disabled Autologger services.");return Task.CompletedTask;}}+public class DisableContentDeliveryManager : IOptimization{public string Name { get; } = "Disable Content Delivery Manager";@@ -190,17 +194,27 @@ public class SecurityAndPrivacy : IOptimizationCategoryusing 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),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "PreInstalledAppsEnabled", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "PreInstalledAppsEverEnabled", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SilentInstalledAppsEnabled", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SubscribedContent-338387Enabled", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SubscribedContent-338388Enabled", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SubscribedContent-338389Enabled", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SubscribedContent-353698Enabled", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SystemPaneSuggestionsEnabled", 0)- );+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "ContentDeliveryAllowed", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "OemPreInstalledAppsEnabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "PreInstalledAppsEnabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "PreInstalledAppsEverEnabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "SilentInstalledAppsEnabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "SubscribedContent-338387Enabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "SubscribedContent-338388Enabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "SubscribedContent-338389Enabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "SubscribedContent-353698Enabled", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "SystemPaneSuggestionsEnabled", 0)+ );Log.LogInformation("Disabled Content Delivery Manager.");return Task.CompletedTask;}@@ -224,9 +238,12 @@ public class SecurityAndPrivacy : IOptimizationCategoryRegistryService.Write(new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", 0),new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCloudSearch", 0),- new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortanaAboveLock", 0),- new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowSearchToUseLocation", 0),- new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "ConnectedSearchUseWeb", 0),+ new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortanaAboveLock",+ 0),+ new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowSearchToUseLocation",+ 0),+ new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "ConnectedSearchUseWeb",+ 0),new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search","ConnectedSearchUseWebOverMeteredConnections", 0),new RegistryItem(@"HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "DisableWebSearch", 1)@@ -253,14 +270,23 @@ public class SecurityAndPrivacy : IOptimizationCategoryusing var tracker = ServiceTracker.Begin(Log);RegistryService.Write(- new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsCopilot", "TurnOffWindowsCopilot", 1),- new RegistryItem(@"HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\WindowsCopilot", "TurnOffWindowsCopilot", 1),- new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowCopilotButton", 0),- new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Shell\Copilot", "IsCopilotAvailable", 0),- new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Shell\Copilot", "CopilotDisabledReason", "IsEnabledForGeographicRegionFailed"),- new RegistryItem(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsCopilot", "AllowCopilotRuntime", 0),- new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked", "{CB3B0003-8088-4EDE-8769-8B354AB2FF8C}", ""),- new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Shell\Copilot\BingChat", "IsUserEligible", 0)+ new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsCopilot",+ "TurnOffWindowsCopilot", 1),+ new RegistryItem(@"HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\WindowsCopilot",+ "TurnOffWindowsCopilot", 1),+ new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced",+ "ShowCopilotButton", 0),+ new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Shell\Copilot", "IsCopilotAvailable",+ 0),+ new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Shell\Copilot",+ "CopilotDisabledReason", "IsEnabledForGeographicRegionFailed"),+ new RegistryItem(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsCopilot",+ "AllowCopilotRuntime", 0),+ new RegistryItem(+ @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked",+ "{CB3B0003-8088-4EDE-8769-8B354AB2FF8C}", ""),+ new RegistryItem(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Shell\Copilot\BingChat",+ "IsUserEligible", 0));Log.LogInformation("Windows Copilot disabled.");diff --git a/optimizerDuck/src/Core/Optimizers/UserExperience.cs b/optimizerDuck/src/Core/Optimizers/UserExperience.csindex 655625e..5c74180 100644--- a/optimizerDuck/src/Core/Optimizers/UserExperience.cs+++ b/optimizerDuck/src/Core/Optimizers/UserExperience.cs@@ -31,18 +31,27 @@ public class UserExperience : IOptimizationCategorynew RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarDa", 0),new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarMn", 0),new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Search", "SearchboxTaskbarMode", 0),- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDeveloperSettings", "TaskbarEndTask", 1),+ new RegistryItem(+ @"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDeveloperSettings",+ "TaskbarEndTask", 1),new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", 0),new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Search", "CortanaConsent", 0),new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Search", "CortanaConsent2", 0),- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Search", "BackgroundAppGlobalToggle", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowTaskViewButton", 0),- new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People", "PeopleBand", 0),- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "HideSCAMeetNow", 1),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Search", "BackgroundAppGlobalToggle",+ 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced",+ "ShowTaskViewButton", 0),+ new RegistryItem(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People",+ "PeopleBand", 0),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "HideSCAMeetNow",+ 1),new RegistryItem(@"HKCU\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds", "EnableFeeds", 0),- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Feeds", "ShellFeedsTaskbarViewMode", 2),- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewShadow", 0),- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarAnimations", 0)+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Feeds", "ShellFeedsTaskbarViewMode",+ 2),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ListviewShadow",+ 0),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced",+ "TaskbarAnimations", 0));Log.LogInformation("Taskbar cleaned up and simplified.");return Task.CompletedTask;@@ -62,8 +71,10 @@ public class UserExperience : IOptimizationCategoryusing 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)+ 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));Log.LogInformation("Switched to dark mode.");return Task.CompletedTask;@@ -83,17 +94,24 @@ public class UserExperience : IOptimizationCategoryusing 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),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced",+ "ShowSyncProviderNotifications", 0),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",+ "SystemPaneSuggestionsEnabled", 0),new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", 0),new RegistryItem(@"HKCU\Software\Microsoft\Windows\DWM", "EnableAeroPeek", 0),new RegistryItem(@"HKCU\Control Panel\Desktop\WindowMetrics", "MinAnimate", "0"),- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency", 0),- new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", 1),- new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize", "StartupDelayInMSec", 0),- new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowSecondsInSystemClock", 1),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",+ "EnableTransparency", 0),+ new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced",+ "Hidden", 1),+ new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize",+ "StartupDelayInMSec", 0),+ new RegistryItem(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced",+ "ShowSecondsInSystemClock", 1),new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowInfoTip", 0),- new RegistryItem(@"HKCU\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32", ""), // old Win10 context menu+ new RegistryItem(@"HKCU\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32",+ ""), // old Win10 context menunew RegistryItem(@"HKCU\Control Panel\Desktop", "MenuShowDelay", "0"));Log.LogInformation("Explorer visuals optimized.");@@ -115,9 +133,11 @@ public class UserExperience : IOptimizationCategoryusing var tracker = ServiceTracker.Begin(Log);RegistryService.Write(- new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting", 3),+ new RegistryItem(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects",+ "VisualFXSetting", 3),new RegistryItem(@"HKCU\Control Panel\Desktop", "DragFullWindows", "0"),- new RegistryItem(@"HKCU\Control Panel\Desktop", "UserPreferencesMask", new byte[] { 144, 18, 3, 128, 16, 0, 0, 0 }, RegistryValueKind.Binary)+ new RegistryItem(@"HKCU\Control Panel\Desktop", "UserPreferencesMask",+ new byte[] { 144, 18, 3, 128, 16, 0, 0, 0 }, RegistryValueKind.Binary));Log.LogInformation("Visual performance set to best.");return Task.CompletedTask;@@ -125,7 +145,6 @@ public class UserExperience : IOptimizationCategory}-public class DisableNotifications : IOptimization{public string Name { get; } = "Disable Notifications";diff --git a/optimizerDuck/src/Core/Services/RegistryService.cs b/optimizerDuck/src/Core/Services/RegistryService.csindex d30329d..d618719 100644--- a/optimizerDuck/src/Core/Services/RegistryService.cs+++ b/optimizerDuck/src/Core/Services/RegistryService.cs@@ -1,8 +1,8 @@-using Microsoft.Extensions.Logging;+using System.Diagnostics.CodeAnalysis;+using Microsoft.Extensions.Logging;using Microsoft.Win32;using optimizerDuck.Models;using optimizerDuck.UI.Logger;-using System.Diagnostics.CodeAnalysis;namespace optimizerDuck.Core.Services;diff --git a/optimizerDuck/src/Core/Services/ServiceProcessService.cs b/optimizerDuck/src/Core/Services/ServiceProcessService.csindex 220f71b..dfa0bb7 100644--- a/optimizerDuck/src/Core/Services/ServiceProcessService.cs+++ b/optimizerDuck/src/Core/Services/ServiceProcessService.cs@@ -1,7 +1,7 @@-using Microsoft.Extensions.Logging;+using System.Management;+using Microsoft.Extensions.Logging;using optimizerDuck.Models;using optimizerDuck.UI.Logger;-using System.Management;namespace optimizerDuck.Core.Services;diff --git a/optimizerDuck/src/Core/Services/ShellService.cs b/optimizerDuck/src/Core/Services/ShellService.csindex f33d769..263bf22 100644--- a/optimizerDuck/src/Core/Services/ShellService.cs+++ b/optimizerDuck/src/Core/Services/ShellService.cs@@ -1,9 +1,9 @@-using Microsoft.Extensions.Logging;+using System.Diagnostics;+using System.Text;+using Microsoft.Extensions.Logging;using optimizerDuck.Core.Extensions;using optimizerDuck.UI.Logger;using Spectre.Console;-using System.Diagnostics;-using System.Text;namespace optimizerDuck.Core.Services;@@ -74,7 +74,8 @@ public static class ShellService| Stderr: {Stderr}| ExitCode: {ProcessExitCode}| Duration: {TimeSpan}- """, fullCommandForUser, stdoutDisplay, stderrDisplay, process.ExitCode, ServiceTracker.FormatTime(duration));+ """, fullCommandForUser, stdoutDisplay, stderrDisplay, process.ExitCode,+ ServiceTracker.FormatTime(duration));return new ShellResult($"{fileName} {arguments} {command}",diff --git a/optimizerDuck/src/Core/Services/SystemInfoService.cs b/optimizerDuck/src/Core/Services/SystemInfoService.csindex 6e1aa6f..377b146 100644--- a/optimizerDuck/src/Core/Services/SystemInfoService.cs+++ b/optimizerDuck/src/Core/Services/SystemInfoService.cs@@ -1,11 +1,11 @@-using Microsoft.Extensions.Logging;+using System.Management;+using System.Runtime.InteropServices;+using Microsoft.Extensions.Logging;using Microsoft.Win32.SafeHandles;using optimizerDuck.UI;using optimizerDuck.UI.Components;using Spectre.Console;using Spectre.Console.Rendering;-using System.Management;-using System.Runtime.InteropServices;namespace optimizerDuck.Core.Services;@@ -32,8 +32,11 @@ public sealed record GpuInfo({public static readonly GpuInfo Unknown = new("Unknown", "Unknown", GpuVendor.Unknown, null, null, null);- public override string ToString() =>- $"GPU: {Name}, Driver: {DriverVersion}, Vendor: {Vendor}, Memory: {MemoryMB} MB, DeviceId: {DeviceId}, PnpDeviceId: {PnpDeviceId}";+ public override string ToString()+ {+ return+ $"GPU: {Name}, Driver: {DriverVersion}, Vendor: {Vendor}, Memory: {MemoryMB} MB, DeviceId: {DeviceId}, PnpDeviceId: {PnpDeviceId}";+ }}public sealed record CpuInfo(@@ -71,6 +74,7 @@ public sealed record DiskInfo({public static readonly DiskInfo Unknown = new([]);}+public sealed record RamModule(double CapacityGB,string SpeedMHz,@@ -288,8 +292,9 @@ internal static class RamProviderreturn modules;}- private static (double totalGB, long totalMB, long totalKB, double availableGB, double usedPercent, double usedGB) GetMemoryStats(- List<RamModule> modules)+ private static (double totalGB, long totalMB, long totalKB, double availableGB, double usedPercent, double usedGB)+ GetMemoryStats(+ List<RamModule> modules){var totalGB = modules.Sum(m => m.CapacityGB);@@ -333,8 +338,15 @@ internal static class RamProviderpublic static class DiskHelper{+ private const uint FILE_SHARE_READ = 0x00000001;+ private const uint FILE_SHARE_WRITE = 0x00000002;+ private const uint OPEN_EXISTING = 3;+ private const uint FILE_ATTRIBUTE_NORMAL = 0x80;+ private const uint GENERIC_READ = 0x80000000;+ private const uint IOCTL_STORAGE_QUERY_PROPERTY = 0x2D1400;+[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]- static extern SafeFileHandle CreateFile(+ private static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode,IntPtr lpSecurityAttributes, uint dwCreationDisposition,uint dwFlagsAndAttributes, IntPtr hTemplateFile);@@ -346,41 +358,6 @@ public static class DiskHelperIntPtr lpOutBuffer, uint nOutBufferSize,out uint lpBytesReturned, IntPtr lpOverlapped);- const uint FILE_SHARE_READ = 0x00000001;- const uint FILE_SHARE_WRITE = 0x00000002;- const uint OPEN_EXISTING = 3;- const uint FILE_ATTRIBUTE_NORMAL = 0x80;- const uint GENERIC_READ = 0x80000000;- const uint IOCTL_STORAGE_QUERY_PROPERTY = 0x2D1400;-- private enum STORAGE_PROPERTY_ID- {- StorageDeviceSeekPenaltyProperty = 7- }-- private enum STORAGE_QUERY_TYPE- {- PropertyStandardQuery = 0- }-- [StructLayout(LayoutKind.Sequential)]- private struct STORAGE_PROPERTY_QUERY- {- public STORAGE_PROPERTY_ID PropertyId;- public STORAGE_QUERY_TYPE QueryType;- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]- public byte[] AdditionalParameters;- }-- [StructLayout(LayoutKind.Sequential)]- private struct DEVICE_SEEK_PENALTY_DESCRIPTOR- {- public uint Version;- public uint Size;- [MarshalAs(UnmanagedType.U1)]- public bool IncursSeekPenalty;- }-public static bool IsSSD(string driveLetter){var trimmedDrive = driveLetter.TrimEnd('\\');@@ -404,8 +381,8 @@ public static class DiskHelpervar querySize = Marshal.SizeOf(query);var resultSize = Marshal.SizeOf<DEVICE_SEEK_PENALTY_DESCRIPTOR>();- IntPtr queryPtr = IntPtr.Zero;- IntPtr resultPtr = IntPtr.Zero;+ var queryPtr = IntPtr.Zero;+ var resultPtr = IntPtr.Zero;try{@@ -445,6 +422,34 @@ public static class DiskHelperreturn string.Equals(systemDrive, driveLetter.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase);}++ private enum STORAGE_PROPERTY_ID+ {+ StorageDeviceSeekPenaltyProperty = 7+ }++ private enum STORAGE_QUERY_TYPE+ {+ PropertyStandardQuery = 0+ }++ [StructLayout(LayoutKind.Sequential)]+ private struct STORAGE_PROPERTY_QUERY+ {+ public STORAGE_PROPERTY_ID PropertyId;+ public STORAGE_QUERY_TYPE QueryType;++ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]+ public byte[] AdditionalParameters;+ }++ [StructLayout(LayoutKind.Sequential)]+ private struct DEVICE_SEEK_PENALTY_DESCRIPTOR+ {+ public uint Version;+ public uint Size;+ [MarshalAs(UnmanagedType.U1)] public bool IncursSeekPenalty;+ }}internal static class DiskProvider@@ -453,7 +458,10 @@ internal static class DiskProvider{try{- static double ToGb(long bytes) => Math.Round(bytes / Math.Pow(1024, 3), 2);+ static double ToGb(long bytes)+ {+ return Math.Round(bytes / Math.Pow(1024, 3), 2);+ }var volumes = DriveInfo.GetDrives().Where(d => d.IsReady)@@ -467,16 +475,16 @@ internal static class DiskProvidervar 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"+ drive.Name.TrimEnd('\\'),+ isSystemDrive,+ drive.DriveFormat,+ drive.DriveType.ToString(),+ drive.VolumeLabel,+ ToGb(totalBytes),+ ToGb(freeBytes),+ ToGb(usedBytes),+ totalBytes > 0 ? Math.Round(usedBytes * 100.0 / totalBytes, 1) : 0,+ isSsd ? "SSD" : "HDD");}).ToList();@@ -638,7 +646,6 @@ internal static class OsProviderprivate static string MapChassisType(IEnumerable<ushort> types){foreach (var type in types)- {switch (type){case 8 or 9 or 10 or 11 or 14 or 30 or 31 or 32:@@ -646,7 +653,6 @@ internal static class OsProvidercase >= 1 and <= 7 or 12 or 13 or >= 15 and <= 29 or >= 33 and <= 36:return "Desktop";}- }return "Unknown";}@@ -758,7 +764,8 @@ public static class SystemInfoServiceforeach (var volume in Snapshot.Disk.Volumes){var systemDrive = volume.SystemDrive ? " [System Drive]" : "";- log.LogDebug("Disk {VolumeName}{SystemDrive} [{VolumeDriveType}] {VolumeTotalSizeGb:F1} GB (Free: {VolumeFreeSpaceGb:F1} GB)",+ log.LogDebug(+ "Disk {VolumeName}{SystemDrive} [{VolumeDriveType}] {VolumeTotalSizeGb:F1} GB (Free: {VolumeFreeSpaceGb:F1} GB)",volume.Name, systemDrive, volume.DriveTypeDescription, volume.TotalSizeGB, volume.FreeSpaceGB);}}@@ -810,6 +817,7 @@ public static class SystemInfoServicelog.LogDebug("GPU ({GpuIndex}): {GpuName} ({GpuVendor}){MemoryInfo}",index + 1, gpu.Name, gpu.Vendor, memoryInfo);}+log.LogDebug("Total GPUs : {GpuCount}", gpuCount);}}@@ -820,27 +828,27 @@ public static class SystemInfoService{// Operating System Informationvar osGroup = new List<IRenderable>- {- 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}[/]")- };+ {+ 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 Informationvar biosGroup = new List<IRenderable>- {- 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)}[/]")- };+ {+ 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 Informationvar cpuVendorColor = s.Cpu.Vendor switch@@ -850,43 +858,43 @@ public static class SystemInfoService_ => Theme.Muted};var cpuGroup = new List<IRenderable>- {- 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[/]")- };+ {+ 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 Informationvar usedColor = s.Ram.UsedPercent > 80 ? Theme.Error : Theme.Warning;var ramGroup = new List<IRenderable>- {- new Rule("Memory Overview") { Style = new Style(Color.Yellow) },-- new Markup(- $"[{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",- s.Ram.UsedGB,- Color.FromHex(Theme.Warning))- .AddItem(- "Available",- s.Ram.AvailableGB,- Color.FromHex(Theme.Success)),- };+ {+ new Rule("Memory Overview") { Style = new Style(Color.Yellow) },++ new Markup(+ $"[{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",+ s.Ram.UsedGB,+ Color.FromHex(Theme.Warning))+ .AddItem(+ "Available",+ s.Ram.AvailableGB,+ Color.FromHex(Theme.Success))+ };if (s.Ram.Modules.Count > 0){@@ -897,7 +905,8 @@ public static class SystemInfoServicevar 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]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)}[/]"));}@@ -905,9 +914,9 @@ public static class SystemInfoService// Disk Informationvar diskGroup = new List<IRenderable>- {- new Rule("Storage Overview") { Style = Theme.Info }- };+ {+ new Rule("Storage Overview") { Style = Theme.Info }+ };foreach (var volume in s.Disk.Volumes){@@ -915,10 +924,14 @@ public static class SystemInfoServicevar 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}]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 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")@@ -944,10 +957,45 @@ public static class SystemInfoServicegpuGroup.Add(new Markup($"[{Theme.Error}]No discrete GPUs were detected.[/]"));break;case 1:- {- gpuGroup.Add(new Rule("Graphics Adapter") { Style = new Style(Color.Green) });- var gpu = s.Gpus[0];+ {+ 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,+ GpuVendor.AMD => Theme.Error,+ GpuVendor.Intel => Theme.Accent,+ _ => 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)}[/]"));++ if (gpu.MemoryMB.HasValue)+ gpuGroup.Add(new Markup(+ $"[{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)}[/]"));++ if (!string.IsNullOrEmpty(gpu.PnpDeviceId))+ gpuGroup.Add(+ new Markup($"[{Theme.Info}]PCI Identifier :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));+ break;+ }+ default:+ {+ 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 Adapter]][/]"+ : "";var vendorColor = gpu.Vendor switch{GpuVendor.NVIDIA => Theme.Success,@@ -956,57 +1004,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}]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)}[/]"));if (gpu.MemoryMB.HasValue)gpuGroup.Add(new Markup(- $"[{Theme.Info}]Frame Buffer :[/] [{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 Identifier :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));- break;- }- default:- {- 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 Adapter]][/]" : "";- var vendorColor = gpu.Vendor switch- {- GpuVendor.NVIDIA => Theme.Success,- GpuVendor.AMD => Theme.Error,- GpuVendor.Intel => Theme.Accent,- _ => Theme.Muted- };-- 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)}[/]"));-- if (gpu.MemoryMB.HasValue)- gpuGroup.Add(new Markup(- $" [{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)}[/]"));-- if (!string.IsNullOrEmpty(gpu.PnpDeviceId))- gpuGroup.Add(new Markup($" [{Theme.Info}]PCI Identifier :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));- }-- break;+ gpuGroup.Add(+ new Markup($" [{Theme.Info}]PCI Identifier :[/] [dim]{Safe(gpu.PnpDeviceId)}[/]"));}- }+ break;+ }+ }// Combine all groups@@ -1035,11 +1055,15 @@ public static class SystemInfoServicecatch (Exception ex){log.LogError(ex, "Failed to generate detailed system info panel.");- var details = $"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;}}- private static string Safe(string? s) => Markup.Escape(s ?? "");+ private static string Safe(string? s)+ {+ return Markup.Escape(s ?? "");+ }}\ No newline at end of filediff --git a/optimizerDuck/src/Core/Services/UpdateService.cs b/optimizerDuck/src/Core/Services/UpdateService.csindex 27423f9..28beddb 100644--- a/optimizerDuck/src/Core/Services/UpdateService.cs+++ b/optimizerDuck/src/Core/Services/UpdateService.cs@@ -1,3 +1,6 @@+using System.Diagnostics;+using System.Net.Http.Headers;+using System.Reflection;using ConsoleInk;using Microsoft.Extensions.Logging;using Newtonsoft.Json;@@ -7,9 +10,6 @@ using optimizerDuck.UI;using optimizerDuck.UI.Components;using optimizerDuck.UI.Logger;using Spectre.Console;-using System.Diagnostics;-using System.Net.Http.Headers;-using System.Reflection;namespace optimizerDuck.Core.Services;@@ -33,7 +33,8 @@ public class UpdateServicetry{- var response = await HttpClient.GetStringAsync($"https://api.github.com/repos/{Owner}/{Repo}/releases/latest");+ var response =+ await HttpClient.GetStringAsync($"https://api.github.com/repos/{Owner}/{Repo}/releases/latest");var latestRelease = JsonConvert.DeserializeObject<GitHubRelease>(response);if (latestRelease == null || string.IsNullOrEmpty(latestRelease.TagName))@@ -89,19 +90,17 @@ public class UpdateService}if (PromptDialog.Warning(- "Update Available",- $"""- A new version [{Theme.Primary}]{latestVersionStr}[/] is ready to install.- Updating ensures you get the latest features and fixes.-- Would you like to download and install it now?- """,- new PromptOption("Yes", Theme.Success),- new PromptOption("Not now", Theme.Warning, () => Task.FromResult(false))- ))- {+ "Update Available",+ $"""+ A new version [{Theme.Primary}]{latestVersionStr}[/] is ready to install.+ Updating ensures you get the latest features and fixes.++ Would you like to download and install it now?+ """,+ new PromptOption("Yes", Theme.Success),+ new PromptOption("Not now", Theme.Warning, () => Task.FromResult(false))+ ))await DownloadAndApplyUpdate(updateExecutableAsset);- }}else{@@ -122,17 +121,20 @@ public class UpdateService{await AnsiConsole.Progress().StartAsync(async ctx =>{- Log.LogInformation("Downloading update from {DownloadUrl} to {TempPath}", asset.BrowserDownloadUrl, tempDownloadPath);+ 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);+ using var response =+ await HttpClient.GetAsync(asset.BrowserDownloadUrl, HttpCompletionOption.ResponseHeadersRead);response.EnsureSuccessStatusCode();var totalBytes = response.Content.Headers.ContentLength ?? -1L;task.MaxValue = totalBytes;await using var contentStream = await response.Content.ReadAsStreamAsync();- await using var fileStream = new FileStream(tempDownloadPath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true);+ await using var fileStream = new FileStream(tempDownloadPath, FileMode.Create, FileAccess.Write,+ FileShare.None, 8192, true);var buffer = new byte[8192];long downloadedBytes = 0;@@ -151,12 +153,8 @@ public class UpdateServiceLog.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);- })+ new PromptOption("Retry", Theme.Warning, async () => { await DownloadAndApplyUpdate(asset); }));- return;}finally{@@ -196,8 +194,10 @@ public class UpdateServiceStartInfo = new ProcessStartInfo{FileName = "powershell.exe",- Arguments = $"-NonInteractive -NoLogo -NoProfile -ExecutionPolicy Bypass -EncodedCommand {updateScript.EncodeBase64()}",- UseShellExecute = true, // start as a separate process via the shell so it doesn't inherit debugger/std handles+ Arguments =+ $"-NonInteractive -NoLogo -NoProfile -ExecutionPolicy Bypass -EncodedCommand {updateScript.EncodeBase64()}",+ UseShellExecute =+ true, // start as a separate process via the shell so it doesn't inherit debugger/std handlesCreateNoWindow = true}};@@ -205,27 +205,21 @@ public class UpdateServiceprocess.Start();Environment.Exit(0);}-}// Helper classes for deserializing GitHub API responsepublic class GitHubRelease{- [JsonProperty("tag_name")]- public required string TagName { get; set; }+ [JsonProperty("tag_name")] public required string TagName { get; set; }- [JsonProperty("assets")]- public required List<GitHubAsset> Assets { get; set; }+ [JsonProperty("assets")] public required List<GitHubAsset> Assets { get; set; }- [JsonProperty("body")]- public required string Body { get; set; }+ [JsonProperty("body")] public required string Body { get; set; }}public class GitHubAsset{- [JsonProperty("name")]- public required string Name { get; set; }+ [JsonProperty("name")] public required string Name { get; set; }- [JsonProperty("browser_download_url")]- public required string BrowserDownloadUrl { get; set; }-}+ [JsonProperty("browser_download_url")] public required string BrowserDownloadUrl { get; set; }+}\ No newline at end of filediff --git a/optimizerDuck/src/Models/OptimizationCategoryChoice.cs b/optimizerDuck/src/Models/OptimizationCategoryChoice.csindex fa2cd52..4f4b205 100644--- a/optimizerDuck/src/Models/OptimizationCategoryChoice.cs+++ b/optimizerDuck/src/Models/OptimizationCategoryChoice.cs@@ -1,3 +1,6 @@namespace optimizerDuck.Models;-public record struct OptimizationCategoryChoice(string Name, OptimizationCategoryOrder Order, List<OptimizationChoice> Optimizations);\ No newline at end of file+public record struct OptimizationCategoryChoice(+ string Name,+ OptimizationCategoryOrder Order,+ List<OptimizationChoice> Optimizations);\ No newline at end of filediff --git a/optimizerDuck/src/Models/OptimizationImpact.cs b/optimizerDuck/src/Models/OptimizationImpact.csindex f560b8e..5197338 100644--- a/optimizerDuck/src/Models/OptimizationImpact.cs+++ b/optimizerDuck/src/Models/OptimizationImpact.cs@@ -1,5 +1,5 @@-using optimizerDuck.UI;-using System.ComponentModel;+using System.ComponentModel;+using optimizerDuck.UI;namespace optimizerDuck.Models;@@ -7,10 +7,13 @@ public enum OptimizationImpact{[Description($"[{Theme.Success}]Minimal Impact[/]")]Minimal,+[Description($"[{Theme.Warning}]Moderate Impact[/]")]Moderate,+[Description($"[{Theme.Error}]High Impact[/]")]Significant,+[Description($"[{Theme.Error}]System-wide impact[/]")]Aggressive-}+}\ No newline at end of filediff --git a/optimizerDuck/src/UI/Components/PromptDialog.cs b/optimizerDuck/src/UI/Components/PromptDialog.csindex 11b473d..a0e5da2 100644--- a/optimizerDuck/src/UI/Components/PromptDialog.cs+++ b/optimizerDuck/src/UI/Components/PromptDialog.cs@@ -80,10 +80,10 @@ public class PromptDialogvar buttonList = new List<string>();var keyMap = new Dictionary<char, string>(); // "Yes" => Y: Yesforeach (var (option, key, rest, color) in from option in _options- let key = char.ToUpper(option.Key[0])- let rest = option.Key.Substring(1)- let color = option.Color- select (option, key, rest, color))+ let key = char.ToUpper(option.Key[0])+ let rest = option.Key.Substring(1)+ let color = option.Color+ select (option, key, rest, color)){buttonList.Add($"[{color}][underline bold]{key}[/]{rest}[/]");keyMap[key] = option.Key;@@ -186,7 +186,8 @@ public class PromptDialog[new PromptOption("Exit", Theme.Error, () => Environment.Exit(1)),new PromptOption("Restart", Theme.Success, () => RequirementChecker.Restart(true)),- new PromptOption("Create a new issue on GitHub", Theme.Bright, () => SystemHelper.OpenWebsite("https://github.com/itsfatduck/optimizerDuck/issues/new")),+ new PromptOption("Create a new issue on GitHub", Theme.Bright,+ () => SystemHelper.OpenWebsite("https://github.com/itsfatduck/optimizerDuck/issues/new")),new PromptOption("Open log", Theme.Warning, SystemHelper.OpenLogFile)];diff --git a/optimizerDuck/src/UI/Logger/Logger.cs b/optimizerDuck/src/UI/Logger/Logger.csindex 4b92fff..1a2c585 100644--- a/optimizerDuck/src/UI/Logger/Logger.cs+++ b/optimizerDuck/src/UI/Logger/Logger.cs@@ -25,7 +25,6 @@ public class PlainTextFormatter : ITextFormatteroutput.Write($" [{sv.Value,-25}]");-// [INFO ]var levelText = logEvent.Level switch{@@ -60,7 +59,8 @@ public class PlainTextFormatter : ITextFormatter// Messagevar message = RenderWithoutQuotes(logEvent);- if (logEvent.Level == LogEventLevel.Debug && !Defaults.IsDebug) // i want to keep markup for debug logs when not in debug mode to avoid markup exceptions+ if (logEvent.Level == LogEventLevel.Debug &&+ !Defaults.IsDebug) // i want to keep markup for debug logs when not in debug mode to avoid markup exceptionsoutput.Write($" {message}");elseoutput.Write($" {Markup.Remove(message)}");diff --git a/optimizerDuck/src/UI/Logger/ServiceTracker.cs b/optimizerDuck/src/UI/Logger/ServiceTracker.csindex d4478f5..d2c946f 100644--- a/optimizerDuck/src/UI/Logger/ServiceTracker.cs+++ b/optimizerDuck/src/UI/Logger/ServiceTracker.cs@@ -1,6 +1,6 @@-using Microsoft.Extensions.Logging;-using System.Collections.Concurrent;+using System.Collections.Concurrent;using System.Diagnostics;+using Microsoft.Extensions.Logging;namespace optimizerDuck.UI.Logger;diff --git a/optimizerDuck/src/UI/MainMenu.cs b/optimizerDuck/src/UI/MainMenu.csindex 43f45a4..f70423e 100644--- a/optimizerDuck/src/UI/MainMenu.cs+++ b/optimizerDuck/src/UI/MainMenu.cs@@ -56,11 +56,11 @@ internal static class MainMenuTheme.Accent,CustomBoxBorder.UnderlineBorder).Build())- { Expand = false }+ { Expand = false });AnsiConsole.Write(start);AnsiConsole.Write(middlePanels);AnsiConsole.WriteLine();}-}+}\ No newline at end of filediff --git a/optimizerDuck/src/UI/MenuHandler.cs b/optimizerDuck/src/UI/MenuHandler.csindex 52615ff..0b0e422 100644--- a/optimizerDuck/src/UI/MenuHandler.cs+++ b/optimizerDuck/src/UI/MenuHandler.cs@@ -30,10 +30,7 @@ internal class MenuHandlerpublic async Task<SystemSnapshot> HandleInputAsync(char option){- if (_menuActions.TryGetValue(option, out var action))- {- await action();- }+ if (_menuActions.TryGetValue(option, out var action)) await action();// If invalid key, do nothing and let the loop re-render the menu.return _systemSnapshot;@@ -47,7 +44,7 @@ internal class MenuHandler{using var cancelCancellationTokenSource = new CancellationTokenSource();ConsoleCancelEventHandler cancelHandler = null!;-+cancelHandler = (sender, e) =>{cancelCancellationTokenSource.Cancel();@@ -56,7 +53,7 @@ internal class MenuHandlerConsole.CancelKeyPress -= cancelHandler;};Console.CancelKeyPress += cancelHandler;-+await _optimizer.Run(cancelCancellationTokenSource.Token).ConfigureAwait(false);}}@@ -93,4 +90,4 @@ internal class MenuHandlerConsole.ReadKey();}}-}+}\ No newline at end of file