Skip to content

Instantly share code, notes, and snippets.

@davunderscorei
Created November 14, 2012 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davunderscorei/4072398 to your computer and use it in GitHub Desktop.
Save davunderscorei/4072398 to your computer and use it in GitHub Desktop.
protobuf-net multiple inheritance
//in order to do this
[ProtoContract]
public class Base
{
[ProtoMember(1)]
public int Value { get;set;}
}
[ProtoContract]
public class Derived : Base {}
//you have to do this?
[ProtoContract]
[ProtoInclude(123, typeof(Derived)]
public class Base
{
[ProtoMember(1)]
public int Value { get;set;}
}
[ProtoContract]
public class Derived : Base {}
//but how do you handle
[ProtoContract]
public class DerivedFromDerived : Derived {}
//?
@dimsa
Copy link

dimsa commented Mar 23, 2018

No way.

ProtoBuf.ProtoException: 'A type can only participate in one inheritance hierarchy'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment