dahomey-technologies/Dahomey.Cbor

ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type.

dxmann opened this issue · 1 comments

I'm on .NET Core 3.1.

The code is:

List<A> alist = ...;
var bw = new ArrayBufferWriter<byte>(10000);
Cbor.Serialize(alist, bw, new CborOptions { EnumFormat = ValueFormat.WriteToInt });
var cbor = Convert.ToBase64String(bw.GetSpan().ToArray());

// with

class A : List<B>
{
    public string Uno { get; set; }
    public int Due { get; set; }
    public D Tre { get; set; }
}
class B : List<C>
{
    public string Uno { get; set; }
    public int Due { get; set; }
}
class C
{
    public string Uno { get; set; }
    public int Due { get; set; }
    public B Tre { get; set; }
}
class D
{
    public string Uno { get; set; }
    public int Due { get; set; }
 }

I have that error on Cbor.Serialize: how to implement the IBufferWriter?
Many thanks :)

Hi @dxmann,

Sorry but the library does not support inheriting generic lists.
It's not recommended to inherit collections: https://stackoverflow.com/questions/21692193/why-not-inherit-from-listt
Even if I wanted, I would not know how to handle the serialization of a type that would hold custom properties and a collection of items by inheritance

Cheers,

Michael