I’m trying to move an existing code to use ProtoBuf-Net. Some classes have DataContract but DataMembers has no order, this results with ignoring these properties instead of serializing them.
Is there a way to tell ProtoBuf-Net to serialize only classes that are marked with [ProtoContract] and throw exception when trying to serialize classes with [XmlType] or [DataContract]? If it’s possible, will the other system classes (for example System.String) be serialized correctly using GPB?
Thanks.
Fair question; it isn’t a scenario that has come up before, but it is a fair-enough scenario, and is pretty easily solved, thankfully… I’ve added
AutoAddProtoContractTypesOnlytoRuntimeTypeModelin r567. If you are using the v1-styleSerializer.Serialize(...)methods, then you can apply this via:(all the
Serializer.*methods are mapped to theRuntimeTypeModel.Defaultmodel instance)Here’s my now-passing test: