SharpSerializer icon indicating copy to clipboard operation
SharpSerializer copied to clipboard

Objects with private properties can't share property names

Open xbrady opened this issue 6 years ago • 0 comments

This is kind of difficult to explain, but here is the code to reproduce:

public class TestMain
    {
        public string TestProperty
        {
            get
            {
                return "Test";
            }
        }
        private TestDetail TestDetails { get; set; } = new TestDetail();

    }
    public class TestDetail
    {
        public string TestProperty { get; set; } = "TestDetail";
        
    }

Called with the following:

TestMain tr = new TestMain();

SharpSerializer serializer = new SharpSerializer();
serializer.Serialize(tr, "test.bin");

SharpSerializer serializer2 = new SharpSerializer();
serializer2.Deserialize("test.bin");

This will throw the following exception when deserializing: ArgumentException: Property set method not found.

If you rename the TestProperty on the TestMain class, or the TestDetail class then it will deserialize without issues.

xbrady avatar Feb 26 '19 16:02 xbrady