Protobuf-Net 2.0.0.480 can serialize structs using either the DataContract or ProtoContract attribute, and is doing so just fine.
However, Serializer.PrepareSerializer<MyStruct>() claims that MyStruct must be a reference type. Why does this limitation exist?
Fair observation! This is a hangover from v1, where the API only supported
class. The v2 implementation addsRuntimeTypeModel, and forwards the oldSerializer.*API ontoRuntimeTypeMode.Default.*.In this case, the answer is simple: because I didn’t remove the
where T : classconstraint that existed from v1 days. It will be removed in a future build.For now, you can also do this via: