-
Couldn't load subscription status.
- Fork 174
Closed
Labels
bugDetected as bugDetected as bug
Description
Hi, Thanks for the great work on msgpack-cli!
I'm having an issue in the following scenario: I want to implement a custom serializer for a type that I don't own. (it belongs to a dll that I can't modify)
The type implements the IEnumerable interface:
public class Person : IEnumerable<Person>
{
public string Name { get; set; }
private IEnumerable<Person> Children { get; set; }
public IEnumerator<Person> GetEnumerator()
{
return Children.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
I've implemented a custom serializer and registered it:
SerializationContext serializationContext =
new SerializationContext();
serializationContext.Serializers.Register(new PersonSerializer());
When I try serialize an instance of the Person class, it works.
But if I try to serialize an array of objects which one of them is an instance of the Person class, I get a NullReferenceException:
object[] array = new object[] {new Person {Name = "Joe"}, 3};
MessagePackSerializer<object[]> context =
serializationContext.GetSerializer<object[]>();
byte[] packed = context.PackSingleObject(array); // throws NullReferenceException
Thanks for your help,
Elad
Metadata
Metadata
Assignees
Labels
bugDetected as bugDetected as bug