From 47736603af9c038098b707c232a49fa541d6ee32 Mon Sep 17 00:00:00 2001 From: Arjun Balgovind <32061677+arjunbalgovind@users.noreply.github.com> Date: Thu, 23 Jul 2020 16:04:04 -0700 Subject: [PATCH] Fix saving to JSON in PT Settings (#5197) * Added argument to fix saving to JSON in PT Settings * Added argument to fix saving to JSON in PT Settings --- .../BasePTModuleSettings.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs index 2a3b7b843e..a638ade38c 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs @@ -20,7 +20,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib // converts the current to a json string. public virtual string ToJsonString() { - return JsonSerializer.Serialize(this); + // By default JsonSerializer will only serialize the properties in the base class. This can be avoided by passing the object type (more details at https://stackoverflow.com/a/62498888) + return JsonSerializer.Serialize(this, this.GetType()); } } }