如何在 ProtoBuf 中声明一个类型正在实现一个接口和一个基 class?

How to declare that a type is implementing an interface and a base class in ProtoBuf?

我们的模型中有一个案例如下所示:

[ProtoContract]
public interface ISomeInterface{
    //...
}

[ProtoContract]
[ProtoInclude(100,typeof(SomeImplementation)]
public class SomeRootClass {
    //...
}

[ProtoContract]
public class SomeImplementation: SomeRootClass,ISomeInterface{
    //...
}

在某些时候,我们有一个 SomeImplementation 的实例,它在 class:

中被引用
[ProtoContract]
public class SomeClassWithInterfaceUsage{
    [ProtoMember(1)]
    public ISomeInterface SomeReference{get;set;}
}

当我们尝试序列化时,出现此错误:

System.InvalidOperationException : It was not possible to prepare a serializer for: SomeRootClass ----> System.InvalidOperationException : No serializer defined for type: ISomeInterface

所以我将界面更改为:

[ProtoContract]
[ProtoInclude(100,typeof(SomeImplementation)]
public interface ISomeInterface{
    //...
}

但现在我遇到了这个错误:

System.InvalidOperationException : A type can only participate in one inheritance hierarchy

我应该如何处理这个案例?

据我所知这不受支持,请在此处检查标记答案:enter link description here

我最终只声明了类型,并使用 ProtoMemberAttribute 上带有 DynamicType 标志的属性对象