From 61a787844b3975d4df22ad8a53a7f94d65d6e3e6 Mon Sep 17 00:00:00 2001 From: Den Delimarsky <1389609+dend@users.noreply.github.com> Date: Mon, 10 May 2021 18:46:39 -0700 Subject: [PATCH] Proper use of serialization routines --- src/modules/espresso/Espresso/Core/TrayHelper.cs | 9 +++++---- src/modules/espresso/Espresso/Espresso.csproj | 1 - src/modules/espresso/Espresso/Program.cs | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/espresso/Espresso/Core/TrayHelper.cs b/src/modules/espresso/Espresso/Core/TrayHelper.cs index fe03a731d1..ead4705514 100644 --- a/src/modules/espresso/Espresso/Core/TrayHelper.cs +++ b/src/modules/espresso/Espresso/Core/TrayHelper.cs @@ -3,9 +3,9 @@ // See the LICENSE file in the project root for more information. using Microsoft.PowerToys.Settings.UI.Library; -using Newtonsoft.Json; using System; using System.Drawing; +using System.Text.Json; using System.Windows.Forms; #pragma warning disable CS8602 // Dereference of a possibly null reference. @@ -47,7 +47,8 @@ namespace Espresso.Shell.Core // Set indefinite keep awake. var currentSettings = ModuleSettings.GetSettings(text); currentSettings.Properties.Mode = EspressoMode.INDEFINITE; - ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text); + + ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text); }, (hours, minutes) => { // Set timed keep awake. @@ -56,7 +57,7 @@ namespace Espresso.Shell.Core currentSettings.Properties.Hours.Value = hours; currentSettings.Properties.Minutes.Value = minutes; - ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text); + ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text); }, () => { @@ -64,7 +65,7 @@ namespace Espresso.Shell.Core var currentSettings = ModuleSettings.GetSettings(text); currentSettings.Properties.KeepDisplayOn = settings.Properties.KeepDisplayOn; - ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text); + ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text); }); } diff --git a/src/modules/espresso/Espresso/Espresso.csproj b/src/modules/espresso/Espresso/Espresso.csproj index 9658706b49..6f847d6715 100644 --- a/src/modules/espresso/Espresso/Espresso.csproj +++ b/src/modules/espresso/Espresso/Espresso.csproj @@ -38,7 +38,6 @@ - diff --git a/src/modules/espresso/Espresso/Program.cs b/src/modules/espresso/Espresso/Program.cs index c9be92c806..e9a3469e60 100644 --- a/src/modules/espresso/Espresso/Program.cs +++ b/src/modules/espresso/Espresso/Program.cs @@ -5,7 +5,6 @@ using Espresso.Shell.Core; using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; -using Newtonsoft.Json; using NLog; using System; using System.CommandLine;