You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A private setter on a nested settings object ({ get; private set; } inside a class held by an AppData property) still loads back as its default, and the next save erases it #365
#364 fixed #362 for properties declared directly on an AppData<T> type, but the resolver modifier only covers those types. UseNonPublicSettersOfAppDataProperties returns straight away for any contract whose type is not derived from AppData<> (AppDataStorage/AppData.cs:70-73, IsAppDataType at :86-97). So a settings object that groups its values in a nested class still hits the original System.Text.Json behaviour: the property is written on save and skipped on load, with no error.
publicclassWindowSettings{publicintWidth{get;privateset;}=800;publicvoidResize(intwidth)=>Width=width;}publicclassMySettings:AppData<MySettings>{publicWindowSettingsWindow{get;set;}=new();}vars=MySettings.LoadOrCreateIn(root);s.Window.Resize(1920);s.Save();// file holds "Window": { "Width": 1920 }varr=MySettings.LoadOrCreateIn(root);// r.Window.Width == 800, but 1920 was expectedr.Save();// the file now holds "Width": 800, so the stored 1920 is gone
This is the same silent data loss #362 describes, one level down. Nothing is thrown, the .corrupt archive never fires, and the next Save()/QueueSave() writes the default over the user's value. Grouping settings into nested classes (Window, Audio, Recent) is the usual way to organise a settings file. The private-setter-plus-method shape is the encapsulated style #362 calls natural, and it shows up most often in exactly these nested value objects.
The PR said it left nested types out on purpose, to stay within what #362 asked for. It doesn't say nested types should keep losing data, so this issue is the follow-up.
Suggested fix
Apply the modifier to every object contract the AppData options build, not only AppData<T> types. These options are private to the library, and serializing an AppData graph is all they're used for, so widening the check doesn't reach any other caller's serialization. The current guards still keep it safe:
only properties already in the contract are touched, so [JsonIgnore] stays ignored
only properties with no setter in the contract get one
converter-handled types (RoundTripStringJsonConverterFactory, semantic strings, enums) have no object contract, so they're unaffected
If widening seems too broad, an alternative is to fail loudly for any serialized property that can't be read back.
Acceptance criteria
A round-trip test with a nested class holding { get; private set; } and { get; internal set; } properties keeps the stored values on reload, and saving the reloaded instance doesn't overwrite them.
A nested [JsonIgnore] property with a private setter stays ignored.
Next step: Widen the modifier to every object contract the private AppData options build, keeping the existing guards (only properties already in the contract, only ones without a setter, and converter-handled types untouched). Then add nested round-trip tests for private set and internal set, and a test that a nested [JsonIgnore] property stays ignored.
Activity
matt-edmondson commentedon Nov 4, 2026
Triage
WindowandAudioare a common way to lay out settings, and the next save overwrites the stored value with the default without any error or.corruptarchive.AppDataStorage/AppData.cs, inUseNonPublicSettersOfAppDataPropertiesandIsAppDataType(:70-97), the type-info resolver that Load properties whose setter is private or internal [patch] #364 added. Whoever did Load properties whose setter is private or internal [patch] #364 is the natural owner, and Get-only collection properties (List<string> Items { get; } = []) are saved but load back empty, and the next save erases them #341 (get-only collections) touches the same resolver.List<string> Items { get; } = []) are saved but load back empty, and the next save erases them #341, which is still open: both are properties that are written on save and skipped on load, so a single change to the resolver could close both.private setandinternal set, and a test that a nested[JsonIgnore]property stays ignored.Generated by Claude Code