-
-
Notifications
You must be signed in to change notification settings - Fork 753
Closed
Description
With keyAsPropertyName: true it's not possible to force key order.
The problem is that class inheritance leads to an (for me) unexpected order and there is no builtin method to influence the messagepack generator in a appriorate way.
[MessagePack.MessagePackObject(keyAsPropertyName: true)]
public abstract class AbstractBase
{
public UInt32 Id = 0xaa00aa00;
}
public sealed class RealClass : AbstractBase
{
public String Str;
}
static async Task Main(string[] args)
{
RealClass realClass = new RealClass { Str = "X" };
var msgRawData = MessagePack.MessagePackSerializer.Serialize(realClass);
// msgRawData result: 82A3537472A158A24964CEAA00AA00
// ^^^^^^^^^^
// Id from abstract base class can be found at the end.
}
So I cannot easily "sniff" the abstract property UInt32 Id from the raw byte array because it's not at the beginning.
Metadata
Metadata
Assignees
Labels
No labels