How are shared/placed the int of the ProtoMember/ProtoInclude in ProtoBuf?

Viewed 693

I've several questions on how/where the ID of a [ProtoContract] should be declared.

Imagine the following code:

[ProtoContract]
[ProtoInclude(100, typeof(SomeClassA))]//1) CAN I USE 1 here?
public abstract class RootClass{
    [ProtoMember(1)]
    public int NodeId {get;set;}
}

[ProtoContract]
[ProtoInclude(200, typeof(SomeClassC)]//2) Should I declare this here or directly on the RootClass?
//3) Can I use the id 100 here?
//4) Can I use the id 1 here? or member + include share the id?
public class SomeClassA : RootClass{

    [ProtoMember(1)]//5) CAN I USE 1 here? Since the parent already use it but it's a different class
    public String Name{get;set;}
}

[ProtoContract]
public class SomeClassC : SomeClassA {
    [ProtoMember(2)]
    public int Count{get;set;}
}

[ProtoContract]
public class SomeClassD : SomeClassA {
    [ProtoMember(2)] //6) Can I use 2 here? Since SomeClassC already use it and is a sibling?
    public int Count{get;set;}
}

I've put several number with questions:

  1. CAN I USE 1 here?
  2. Should I declare this here or directly on the RootClass?
  3. Can I use the id 100 here?
  4. Can I use the id 1 here? or member + include share the id?
  5. CAN I USE 1 here? Since the parent already use it but it's a different class
  6. Can I use 2 here? Since SomeClassC already use it and is a sibling?

The thing is that we have a huge model with a lot of classes, which all herits from the same object, so I'm trying to figure out to which ID I should take care.

1 Answers
Related