I've defined the following inheritance hierarchy using protobuf-net and its RuntimeTypeModel
var model = RuntimeTypeModel.Create();
model.Add(typeof(LineFields), false)
.Add(1, nameof(LineFields.Length))
.UseConstructor = false;
model.Add(typeof(ArcFields), false)
.Add(1, nameof(ArcFields.Length))
.Add(2, nameof(ArcFields.Curvature))
.UseConstructor = false;
model.Add(typeof(GeometryFields), false)
.AddSubType(1, typeof(LineFields))
.AddSubType(2, typeof(ArcFields));
My tests appear to pass but I'm somewhat uneasy about the identifiers used for the above AddSubType identifiers. Should these identifiers be different from any identifiers used in the sub-types?, i.e. should I rather be doing:
model.Add(typeof(GeometryFields), false)
.AddSubType(101, typeof(LineFields))
.AddSubType(102, typeof(ArcFields));
(is the AddSubType effectively doing the same as the ProtoInclude attribute as described here?)