diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Library/Utilities/Logger.cs b/src/core/Microsoft.PowerToys.Settings.UI.Library/Utilities/Logger.cs index ebf9dc633c..7d98018af7 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Library/Utilities/Logger.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Library/Utilities/Logger.cs @@ -32,6 +32,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Utilities Log(message, "INFO"); } + public static void LogError(string message) + { + Log(message, "ERROR"); +#if DEBUG + Debugger.Break(); +#endif + } + public static void LogError(string message, Exception e) { Log( @@ -42,6 +50,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Utilities "Stack trace: " + Environment.NewLine + e?.StackTrace, "ERROR"); +#if DEBUG + Debugger.Break(); +#endif } private static void Log(string message, string type) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs index 38c02e694a..04ac56367d 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs @@ -5,6 +5,7 @@ using System; using System.Windows; using Microsoft.PowerLauncher.Telemetry; +using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Views; using Microsoft.PowerToys.Telemetry; using Microsoft.Toolkit.Wpf.UI.XamlHost; @@ -67,16 +68,17 @@ namespace Microsoft.PowerToys.Settings.UI.Runner { if (ShellPage.ShellHandler.IPCResponseHandleList != null) { - try + var success = JsonObject.TryParse(msg, out JsonObject json); + if (success) { - JsonObject json = JsonObject.Parse(msg); foreach (Action handle in ShellPage.ShellHandler.IPCResponseHandleList) { handle(json); } } - catch (Exception) + else { + Logger.LogError("Failed to parse JSON from IPC message."); } } }; diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj index f102c653e4..5071d015f8 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj @@ -69,6 +69,11 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + 3.3.0 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs index b4f38bf3ef..8220056412 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs @@ -13,7 +13,7 @@ using Windows.UI.Popups; namespace Microsoft.PowerToys.Settings.UI.Runner { - public class Program + public static class Program { // Quantity of arguments private const int ArgumentsQty = 5; @@ -37,9 +37,9 @@ namespace Microsoft.PowerToys.Settings.UI.Runner App app = new App(); app.InitializeComponent(); - if (args.Length >= ArgumentsQty) + if (args != null && args.Length >= ArgumentsQty) { - int.TryParse(args[2], out int powerToysPID); + _ = int.TryParse(args[2], out int powerToysPID); PowerToysPID = powerToysPID; if (args[4] == "true")