Open shpaass opened 2 weeks ago
Most json serializers have [JsonProperty(...)]
(Newtonsoft.Json) or [JsonPropertyName(...)]
(System.Text.Json.Serialization) attributes to control what gets written in the json, along with more general tools for saying "Write camelCase to the json even though the source is in PascalCase.
We can just directly copy their behavior, or we could do an class OldPropertyNamesAttribute(params string[] oldPropertyNames)
to always write the newest name but support reading from older names.
The latter means that you immediately know how projectPath
is stored in the json, but doesn't let older versions read json written by newer versions.
Right now, the deserialization of
Yafc.Preferences#Instance
breaks if you change the name of attributes inProjectDefinition
. It wipes the renamed attribute because the deserialized objects do not have the new attribute.For instance, if you were to rename
path
intoprojectPath
, the deserialization from AppData/YAFC/yafc.config can't match them, so the whole list would haveprojectPath
as empty. That ultimately results in the list of recent projects being wiped.There are ways to sove this problem, but they need time and googling.
(This ticket was created to better track the corresponding TODO in the code)