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
The current mechanism is based on .NET's built-in Settings serialization class. It's not clear why, but sometimes serlialization gets messed up and the file corrupted.
We should take a fresh look at how settings should be persisted.
I've been thinking about this some.... Do you have an example of a corrupted settings file? (Is it just empty or full of defaults? Or is it actually mangled, like the serialization was interrupted?) I've seen rare cases where settings files of my own reset mysteriously, but this wasn't using the built-in Settings thing. Some unrelated exception would (I think) reset and new up a fresh form-level instance variable holding my settings, then on app exit, the empty settings object would save. So, in my case, I would end up with empty settings files.
I'm really not sure how to replicate that fail condition for test purposes, so I was thinking of approaching this by adding "reslience" to a settings architecture. I was thinking about making all Settings property setters write to disk immediately. I would probably have a Settings.Update method that took an Action<T> where the property setter is called. This Update method would call Save implicitly. Then I would consider removing the Settings save call on app exit.
Another idea I had was making the settings Save method increment a version number on each write, and keep the last 4 settings versions, or something like that. The occasional failures would still happen, but there would be some way in the UI to recover a previous settings version, or maybe recover it silently. I don't think users would understand why they needed to "recover a prior settings version", so I would try to detect on startup when a failure had happened (by noticing an empty settings file) and silently replacing the prior version.
Activity
adamfoneil commentedon Apr 28, 2020
I'm interested in this and taking a look
adamfoneil commentedon Apr 29, 2020
I've been thinking about this some.... Do you have an example of a corrupted settings file? (Is it just empty or full of defaults? Or is it actually mangled, like the serialization was interrupted?) I've seen rare cases where settings files of my own reset mysteriously, but this wasn't using the built-in Settings thing. Some unrelated exception would (I think) reset and new up a fresh form-level instance variable holding my settings, then on app exit, the empty settings object would save. So, in my case, I would end up with empty settings files.
I'm really not sure how to replicate that fail condition for test purposes, so I was thinking of approaching this by adding "reslience" to a settings architecture. I was thinking about making all Settings property setters write to disk immediately. I would probably have a
Settings.Updatemethod that took anAction<T>where the property setter is called. ThisUpdatemethod would callSaveimplicitly. Then I would consider removing the Settings save call on app exit.Another idea I had was making the settings
Savemethod increment a version number on each write, and keep the last 4 settings versions, or something like that. The occasional failures would still happen, but there would be some way in the UI to recover a previous settings version, or maybe recover it silently. I don't think users would understand why they needed to "recover a prior settings version", so I would try to detect on startup when a failure had happened (by noticing an empty settings file) and silently replacing the prior version.