UnPackaged Mode is Broken
Which version of the app?
WinUI 3 Gallery
Description
Unpackaged mode is broken due to the use of LocalSettings for saving app settings, which is not supported in unpackaged apps.
I’m considering two possible solutions:
-
Implement a simple class to serialize/deserialize a model to a JSON file — straightforward, with no extra features.
-
Use Nucs.JsonSettings, which offers features like:
- Versioning
- AutoSave
- And more...
I’m ready to submit a PR.
Screenshots
No response
Windows version
No response
Additional context
No response
@marcelwgn
Could you pick one option so I can begin?
If I implement a custom Serializer class, it’ll be a simple setup—something like
GlobalData.Settings.Property = true;
GlobalData.Save();
However, saving and restoring collections might be a bit tricky.
On the other hand, using nucs.JsonSettings would be much easier and comes with plenty of useful features. For example, you can use
Settings.Property = true;
and it saves automatically. Plus, two-way x:Bind support could be really powerful.
nucs.JsonSettings is open-source and licensed under the MIT license, so I don't think there's any issue with using it.
I think we should implement a simple serializer ourselves, pulling in dependencies, especially as a reference project like the WinUI Gallery is has its own suite of problems. We should probably just use a JSON Serializer for this instead of trying to be too smart here. The API surface should be similar to the existing AppSettings and that switch should be implemented in the SettingsHelper class.
Hi @marcelwgn I added a PR for this issue https://github.com/microsoft/WinUI-Gallery/pull/2001
Old Settings System:
appData.LocalSettings.Values[SettingsKeys.IsLeftMode] = true;
New Settings System:
SettingsHelper.Config.IsLeftMode = true;
SettingsHelper.Save();