3
votes

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?

1
you should look at the questions you have asked previously and accept the answers or improve your questions SO works by people fulfulling their part of the deal, you ask a question, you rate and/or accept an answer. - Paul Farry

1 Answers

3
votes

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.