Skip to content

Commit e4603b2

Browse files
zadjii-msftyeelam-gordon
authored andcommitted
Fix loading our app state (#40401)
Yea this is dumb. Cant have private setters when json deserializing. closes #40399
1 parent 1f614a2 commit e4603b2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/AppStateModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public partial class AppStateModel : ObservableObject
2121

2222
///////////////////////////////////////////////////////////////////////////
2323
// STATE HERE
24-
public RecentCommandsManager RecentCommands { get; private set; } = new();
24+
public RecentCommandsManager RecentCommands { get; set; } = new();
2525

2626
// END SETTINGS
2727
///////////////////////////////////////////////////////////////////////////

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static void SaveSettings(SettingsModel model)
130130
{
131131
foreach (var item in newSettings)
132132
{
133-
savedSettings[item.Key] = item.Value != null ? item.Value.DeepClone() : null;
133+
savedSettings[item.Key] = item.Value?.DeepClone();
134134
}
135135

136136
var serialized = savedSettings.ToJsonString(JsonSerializationContext.Default.Options);
@@ -188,6 +188,8 @@ internal static string SettingsJsonPath()
188188
[JsonSerializable(typeof(HistoryItem))]
189189
[JsonSerializable(typeof(SettingsModel))]
190190
[JsonSerializable(typeof(AppStateModel))]
191+
[JsonSerializable(typeof(RecentCommandsManager))]
192+
[JsonSerializable(typeof(List<string>), TypeInfoPropertyName = "StringList")]
191193
[JsonSerializable(typeof(List<HistoryItem>), TypeInfoPropertyName = "HistoryList")]
192194
[JsonSerializable(typeof(Dictionary<string, object>), TypeInfoPropertyName = "Dictionary")]
193195
[JsonSourceGenerationOptions(UseStringEnumConverter = true, WriteIndented = true, IncludeFields = true, PropertyNameCaseInsensitive = true, AllowTrailingCommas = true)]

0 commit comments

Comments
 (0)