The interface support in protobuf-net is intended for limited scenarios, you you are basically working to an interface-based model, in particular for nested members. For example:
[ProtoContract]
public class Foo {
[ProtoMember(1)]
public IBar Bar {get;set;}
}
In the above, we want to be able to serialize the Bar
, but we might not know a lot about it. In fact, if Foo
guarantees to return a non-null value from Bar
, protobuf-net doesn't even need to know anything about concrete types etc - it can just go ahead and populate the object it is given.
In your example, the root object is unquestionably BaseClass
. I would suggest that ISomeRules
is anciliary, and does not need to be mentioned at all in the model. However, if you want to populate members that are only exposed via ISomeRules
, then you might try (untested):
[ProtoMember(n)]
private ISomeRules Rules { get { return this; } }
This then exposes the ISomeRules
information, but spoofing it as a sub-object. It is, at the minimum, worth a try; p