Skip to content

Fails to serialize non-attributed classes with read-only properties #28

@takeshik

Description

@takeshik

actual: The following code fails w/ MsgPack.Cli-0.4.4:

public class Data
{
    public int X { get; set; }
    public int X2 { get { return this.X * 2; } }
}

static void Test()
{
    var serializer = MessagePackSerializer.Create<Data>();
    // ^ SerializationException: Cannot set value to 'Foo.X2' property
    var dat = serializer.PackSingleObject(new Data() { X = 123, });
    serializer.UnpackSingleObject(dat);
}

expect: except properties without public setter (X2 in the above code) from the serialization target.

According to the document, the Data class should be serialized that has only one member for the property X.

all read/write PUBLIC members (that is, fields which are not initonly and properties which have both of getter and etter) are serialized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions