Skip to content

Deserialize exception in inherited class from Dictionary<,> #242

@faridmehrhesam

Description

@faridmehrhesam

Hi I have a class like :

 public class Event : Dictionary<AttributeType, object>

AttributeType is enum

Deserializing will throw an exception

var @event = new Event { { AttributeType.EventId, Guid.NewGuid() } };
MessagePackSerializer.Deserialize<Event(MessagePackSerializer.Serialize(@event));

Exception message is:

System.ArgumentException: 'The value "21" is not of type "BRCo.Core.Common.Enums.AttributeType" and cannot be used in this generic collection.'

But when I use this code it's ok

var @event = new Event { { AttributeType.EventId, Guid.NewGuid() } };
MessagePackSerializer.Deserialize<Dictionary<AttributeType, object>>(MessagePackSerializer.Serialize(@event));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions