Free, open-source Windows optimization tool for performance, privacy, and simplicity.
C# csharpdebloatdotnetgamingopen-sourceoptimizationoptimizeroptimizerduckperformanceprivacytweakertweakswindowswinui
fix(bloatwareservice): added a null and empty guard
fatDuckc0c358cf1c26
diff --git a/optimizerDuck/Services/UI/BloatwareService.cs b/optimizerDuck/Services/UI/BloatwareService.csindex 8cb7779..4843ef3 100644--- a/optimizerDuck/Services/UI/BloatwareService.cs+++ b/optimizerDuck/Services/UI/BloatwareService.cs@@ -74,13 +74,27 @@ public class BloatwareService().ConfigureAwait(false);+ if (string.IsNullOrWhiteSpace(result.Stdout))+ {+ if (!string.IsNullOrWhiteSpace(result.Stderr))+ logger.LogWarning("Get-AppxPackage stderr: {Error}", result.Stderr);++ return [];+ }+var options = new JsonSerializerOptions{PropertyNameCaseInsensitive = true,Converters = { new JsonStringEnumConverter() },};- var apps = JsonSerializer.Deserialize<List<AppXPackage>>(result.Stdout, options)!;+ var apps = JsonSerializer.Deserialize<List<AppXPackage>>(result.Stdout, options);++ if (apps == null || apps.Count == 0)+ {+ logger.LogInformation("No removable AppX packages found");+ return [];+ }apps.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));