-
Couldn't load subscription status.
- Fork 174
Description
Hullo,
I am creating a networked application with this library for serialising my packet payloads. Some packets have no payload, which I represent for convenience as an empty dictionary (since all other payloads are encoded as a dictionary).
The problem is that this library does not allow you to serialise/deserialise classes with no fields:
With the class:
class SerializeMe {}This line will throw an exception complaining about a lack of fields to serialise:
var serializer = MessagePackSerializer.Get<SerializeMe>(m_Serialisation);Understanding that, whilst I would like for this to work, it may go against the libraries design decisions - I decided to implement IPackable and IUnpackable for SerializeMe:
class SerializeMe : IPackable, IUnpackable
{
public void PackToMessage(Packer packer, PackingOptions options)
{
packer.PackMapHeader(0);
}
public void UnpackFromMessage(Unpacker unpacker)
{
long length;
unpacker.ReadMapHeader(out length);
}
}The library still complains that I have no fields to serialise, even though it shouldn't care as I now provide a manual packable/unpackable interface? I feel like this is unintentional behaviour? Adding a dummy field to SerializeMe causes it to use the IPackable/IUnpackable interface.
I hope I've described the situation adequately, let me know if you need more information :)