i have a base class which decorated with [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
in order to be able to serialize a derived class , do i only need to add ProtoInclude? as the derived class fields are not being serialize - does the inheritance works only with Protomember?
Protobuf doesn't fully support inheritance you need to do a little decoration in your base class.
[
ProtoContract(),
ProtoInclude(100, typeof(Peer)),
ProtoInclude(101, typeof(Instruction))
]
class Base {...}
[ProtoContract()]
class Peer: Base
{ ... }
[ProtoContract()]
class Instruction: Base
{ ... }
for derived classes that only provide properties via the Base class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With