Skip to content

Index out of bounds exception when trying to deserialize object with missing List property on iPad #199

@diopol

Description

@diopol

This simple scenario throws exception on iPad:

    public class Obj1
    {
        [MessagePackMember(0)]
        public string Id { get; set; }

        [MessagePackMember(1)]
        public List<string> Items { get; set; }
    }

    public class Obj2
    {
        [MessagePackMember(0)]
        public string Id { get; set; }

        // doesn't know about Items
    }

    void ThisMethodThrowsIndexOutOfBoundsException()
    {
        using (var memStream = new MemoryStream())
        {
            SerializationContext.Default.GetSerializer<Obj1>().Pack(memStream, new Obj1
            {
                Id = "1",
                Items = new List<string> { "a", "b" }
            });

            memStream.Seek(0, SeekOrigin.Begin);

            var serializer2 = SerializationContext.Default.GetSerializer<Obj2>();

            // this call throws
            Obj2 obj = serializer2.Unpack(memStream);
        }
    }

Works well in full .NET
MsgPack Cli is installed from Nuget, version 0.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDetected as bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions