Open
Description
I currently have an issue with a particular part of my code. Here is the exception:
Did not expect any exception, but found System.ArgumentException: GenericArguments[0], '<>z__ReadOnlySingleElementList`1[My.Models.Model]', on 'Dahomey.Cbor.Serialization.Converters.CollectionConverter`2[TC,TI]' violates the constraint of type 'TC'.
---> System.TypeLoadException: GenericArguments[0], '<>z__ReadOnlySingleElementList`1[My.Models.Model]', on 'Dahomey.Cbor.Serialization.Converters.CollectionConverter`2[TC,TI]' violates the constraint of type parameter 'TC'.
You can reproduce by serializing a single element array created via the new Collection expression feature, see:
var array = [42];
I use an array of complex of objects but I suppose it should have the same effect on primitives.
Note that standard arrays like new [] { 42 }
still work perfectly.
I did not take a closer look but I suppose it has to do with the underlying (optimized?) type generated by the Collection expression.
Metadata
Metadata
Assignees
Labels
No labels