You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to deserialize a class which has ctor with parameter (in addition to empty ctor) and the parameter name matches any property name (casing doesn't matter), and the class has any property with private setter, deserialization will fail with System.MethodAccessException
Repro steps
var m = new MemoryStream();
MessagePackSerializer.Serialize<MyClass>(m, new MyClass());
m.Seek(0, SeekOrigin.Begin);
var x = MessagePackSerializer.Deserialize<MyClass>(m);
[DataContract]
public class MyClass
{
public MyClass()
{
}
public MyClass(string foo)
: this()
{
}
[DataMember]
public string Foo { get; set; }
[DataMember]
public string Bar { get; private set; }
}
Expected behavior
Deserialization should work properly.
There is no relation between the ctor parameter name and the property, notice that changing the ctor parameter name:
public MyClass(string foo) => public MyClass(string foo1)
Will make the issue disappear and everything works
Actual behavior
Deserialization throws exception
Version used: 2.5.129
Runtime: .net 7.0
Additional context
This scenario works as expected up until version 2.2.113, it broke since version 2.3.75+
The text was updated successfully, but these errors were encountered:
Bug description
When trying to deserialize a class which has ctor with parameter (in addition to empty ctor) and the parameter name matches any property name (casing doesn't matter), and the class has any property with private setter, deserialization will fail with System.MethodAccessException
Repro steps
Expected behavior
Deserialization should work properly.
There is no relation between the ctor parameter name and the property, notice that changing the ctor parameter name:
public MyClass(string foo) => public MyClass(string foo1)
Will make the issue disappear and everything works
Actual behavior
Deserialization throws exception
Additional context
This scenario works as expected up until version 2.2.113, it broke since version 2.3.75+
The text was updated successfully, but these errors were encountered: