title: Using protobuf-net, what is the correct way to serialize a derived type that implements an interface?
body: <p>I realize that there are similar questions here, but none that asks this quite as straightforwardly as what I need, probably because of my lack of protobuf experience. I am transcoding for enyim's caching client, and having trouble figuring out how to make a class that is both derived and implementing an interface de/serialize correctly.</p>
  
  <p>For a sample like this</p>
  
  <pre><code>public class BaseClass
  {
  }
  
  public interface ISomeRules
  {
  }
  
  public class DerivedClass : BaseClass, ISomeRules
  {
  }
  
  public class ThirdClass
  {
      ISomeRules ruleUser;
  }
  </code></pre>
  
  <p>I want to do something like this, because I generally use attributes everywhere</p>
  
  <pre><code>[ProtoContract
  ,ProtoInclude(101,typeof(DerivedClass))
  ]
  public class BaseClass
  {
  }
  
  [ProtoContract
  ,ProtoInclude(102,typeof(DerivedClass))
  ]
  public interface ISomeRules
  {
  }
  
  [ProtoContract]
  public class DerivedClass : BaseClass, ISomeRules
  {
  }
  
  [ProtoContract]
  public class ThirdClass
  {
      [ProtoMember(1)]
      ISomeRules ruleUser;
  }
  </code></pre>
  
  <p>but it fails caching silently. If as some have suggested I remove the <code>ProtoContract</code> attribute from <code>ISomeRules</code>, the deserialization fails.</p>
  
  <p>Is this doable using protobuf-net? What is the right way to do this? Should I be using the TypeModel (which I do not master, but which simple tests indicate has the same problem) instead? Or a combination of TypeModel and attributes? </p>