Fix loading our app state (#40401)

Yea this is dumb. Cant have private setters when json deserializing.
closes #40399
This commit is contained in:
Mike Griese
2025-07-06 16:10:15 -05:00
committed by GitHub
parent 0c425fd1d7
commit 0f279002f8
2 changed files with 4 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ public partial class AppStateModel : ObservableObject
///////////////////////////////////////////////////////////////////////////
// STATE HERE
public RecentCommandsManager RecentCommands { get; private set; } = new();
public RecentCommandsManager RecentCommands { get; set; } = new();
// END SETTINGS
///////////////////////////////////////////////////////////////////////////

View File

@@ -130,7 +130,7 @@ public partial class SettingsModel : ObservableObject
{
foreach (var item in newSettings)
{
savedSettings[item.Key] = item.Value != null ? item.Value.DeepClone() : null;
savedSettings[item.Key] = item.Value?.DeepClone();
}
var serialized = savedSettings.ToJsonString(JsonSerializationContext.Default.Options);
@@ -188,6 +188,8 @@ public partial class SettingsModel : ObservableObject
[JsonSerializable(typeof(HistoryItem))]
[JsonSerializable(typeof(SettingsModel))]
[JsonSerializable(typeof(AppStateModel))]
[JsonSerializable(typeof(RecentCommandsManager))]
[JsonSerializable(typeof(List<string>), TypeInfoPropertyName = "StringList")]
[JsonSerializable(typeof(List<HistoryItem>), TypeInfoPropertyName = "HistoryList")]
[JsonSerializable(typeof(Dictionary<string, object>), TypeInfoPropertyName = "Dictionary")]
[JsonSourceGenerationOptions(UseStringEnumConverter = true, WriteIndented = true, IncludeFields = true, PropertyNameCaseInsensitive = true, AllowTrailingCommas = true)]