question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor/rethink how duality handles settings

See original GitHub issue

Summary

There are some things that might be improved in the settings department of duality:

First it seems that duality uses 2 approaches to storing settings.

  • EditorUserData.xml seems to use a completely separate code flow for writing to the settings file in DualityEditorApp.SaveUserData(). The file itself also has 2 <?xml version="1.0" encoding="utf-8"?> which I have never seen before in a single file. Maybe some hack around dockpanel behavior?
  • Other setting files are using the duality Serializer class to write to the files. They also use the .dat file extension instead of .xml

Second there’s not a clear location for where saving and loading is implemented. Sometimes it happens in DualityApp or DualityEditorApp and other times it happens in the settings class itself. I think we might benefit from making a interface with Save and Load methods where these are implemented on the class itself as that would allow us to treat settings in a more generic way (such as here https://github.com/AdamsLair/duality/blob/master/Source/Editor/DualityEditor/DualityEditorApp.cs#L1012) and also clean up some code from the already big DualityApp and DualityEditorApp classes.

Thirdly because of how the serializer api works atm it always creates a new instance. This makes it impossible to put change events on the settings class itself because then you would also have to resubscribe to those events which kinda defeats the purpose. It might be beneficial if the serializer api could take a already existing instance and update that instance.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
Barsonaxcommented, Jul 13, 2020

Extensions are currently changed to xml in #860 actually. Didn’t changed them all in #856 due to conflicts.

The PR is still WIP though. Will probably split it up since it has grown quite a bit.

1reaction
ilexpcommented, Jul 6, 2020

In that case, the code that serializes any of these settings should choose the XmlSerializer specifically via preferredSerializer, avoiding that any future or project-specific change will cause them to use a different one. Having binary (or something else entirely) in a .xml is not fun 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duality Serializers should support updating an existing ...
Summary Right now, Duality serializers always return a new instance of a deserialized ... Refactor/rethink how duality handles settings #855.
Read more >
Issues · AdamsLair/duality
Refactor/rethink how duality handles settings Cleanup Improving form, keeping function Discussion Nothing to be done until decided otherwise.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found