Dahomey.Cbor icon indicating copy to clipboard operation
Dahomey.Cbor copied to clipboard

Feature request: Add and support int key for CborPropertyAttribute

Open rmja opened this issue 3 years ago • 1 comments

It would be really useful if the CborPropertyAttribute could support an int key similar to the KeyAttribute in MessagePack.

Edit: Mayby this is actually two feature requests:

  1. CborProperty(x) should be used in an map object mapping where the key is the integer x.
  2. CborKey(x) should be used in an array mapping where x is the array position just like messagepack.

rmja avatar Jun 30 '22 08:06 rmja

plan:

  • add a property int Index to CborPropertyAttribute
  • add a CborObjectFormatAttribute to annotate a class or a struct

mcatanzariti avatar Oct 24 '22 22:10 mcatanzariti

Current implementation does not yet support Discriminators nor CreatorMappings.

Supporting Discriminators is tricky, especially for the array format because the number of items in the array for a specific class could be variable if DiscriminatorPolicy is set to Auto.

One possible implementation is to use a Semantic Tag to identify the discriminator property/field. Semating Tag 39 could be used for this purpose.

mcatanzariti avatar Oct 28 '22 21:10 mcatanzariti