doc/analyzers/MsgPack018.md
[MessagePackObject]-attributed types may omit attributing each member with a [Key] attribute using forced map mode.
In that mode, all serialized members must have unique names or a key collision would result in the serialized object.
[MessagePackObject]
public class A
{
public string Prop1 { get; set; }
}
[MessagePackObject]
public class B : A
{
public new string Prop1 { get; set; } // Diagnostic reported here due to redefinition of Prop1
}
Rename one of the colliding properties:
[MessagePackObject]
public class A
{
public string Prop1 { get; set; }
}
[MessagePackObject]
public class B : A
{
public string Prop2 { get; set; }
}
Or add a [Key] attribute that assigns a unique serialized key to that member:
[MessagePackObject]
public class A
{
public string Prop1 { get; set; }
}
[MessagePackObject]
public class B : A
{
[Key("B_Prop1")]
public new string Prop1 { get; set; }
}