libMarshal icon indicating copy to clipboard operation
libMarshal copied to clipboard

Tags

Open inxomnyaa opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. I have faced 3 issues with i.e. values that come from saved configs marshaled via libMarshal:

  • A new version of a config might rename, remove or change the type of a value
  • Config values that are optional are hard to implement without assigning null as default, causing a trail of null checks
  • Sometimes you'd want specific values to be saved in different configs or arrays/json, i.e. a Tool (in MagicWE2, item with interactions. Brush might be the best example) should have runtime options and config options, one being used as file on disk and one i.e. as an array that is being serialized for async tasks.

Describe the solution you'd like A possible solution i propose is adding an optional tags <list<string>> parameter. Then when using marshal() you can pass a list of tags you want serialized.

Describe alternatives you've considered So far, none

Additional context I got stuck at implementing libMarshal into MagicWE2 due to this. Right now the code isn't public though.

But an example is the usersessions: https://github.com/thebigsmileXD/MagicWE2/blob/experiment/libMarshal/src/xenialdan/MagicWE2/session/UserSession.php#L29-L42 Some of those values are optional, for example $brushes. The brushcollection holds brushes, https://github.com/thebigsmileXD/MagicWE2/blob/experiment%2FlibMarshal/src/xenialdan/MagicWE2/session/data/BrushCollection.php#L28. These already have some kind of versioning implemented, but.. honestly not in a great way, they can't really be upgraded yet.

The current format Session->save() produces is also not compatible with unmarshal due to some object arrays like BrushCollection being boiled down to an array that is not nested https://github.com/thebigsmileXD/MagicWE2/blob/0ed0c1a67c99314bcfbeafc36d4e826e1398e0a0/src/xenialdan/MagicWE2/session/UserSession.php#L279

inxomnyaa avatar Dec 17 '22 03:12 inxomnyaa