When a [MessagePackObject] includes serializable members with less than internal visibility, the declaring type must use the partial modifier, so that the source generated formatter can be emitted as a member of that type and thus gain access to its private members.
[MessagePackObject]
public class A {
[Key(0)]
private B b;
}Add the partial keyword:
[MessagePackObject]
public partial class A {
[Key(0)]
private B b;
}An automated code fix is available for this.
Alternatively, make all private/protected serializable members internal instead so that a formatter declared elsewhere in the compilation can reach them:
[MessagePackObject]
public class A {
[Key(0)]
internal B b;
}