gluon icon indicating copy to clipboard operation
gluon copied to clipboard

Derived Variant serialization is untagged

Open omegablitz opened this issue 4 years ago • 1 comments

Deriving Serialize on a variant leads to an untagged representation right now. This means that serializing variants such as type Variant = | A | B or type Variant = | A String | B String is not reversible. In the former case, both will serialize to null, and in the latter, both will serialize to the contained string.

Would it make sense to change the default derived scheme of Variants to an Externally Tagged or Adjacently Tagged model?

omegablitz avatar May 27 '20 20:05 omegablitz

Certainly, though having an attribute to keep it as untagged should still exist since it is needed for some uses (untagged was just the first representation I needed).

Marwes avatar May 27 '20 20:05 Marwes