Here's a scenario:
[ProtoContract]
class A{}
A while later another dev adds:
class B : A {
int m;
}
I have a fallback to XML if a class doesn't have ProtoContractAttribute or had errors during Google Protocol Buffers serialization. The problem with the code above is that B inherent ProtoContractAttribute from A (note Inherited = true below), but member 'm' will not be serialized since it does not have ProtoMemberAttribute.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum
| AttributeTargets.Interface, AllowMultiple = false, Inherited = true)]
public sealed class ProtoContractAttribute : Attribute
{...}
It would be great to be able to add:
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public class ProtoContractWithoutInheritance : ProtoBuf.ProtoContractAttribute
{
}
But ProtoContractAttribute is sealed, and even if it hadn't been sealed, ProtoBuf-Net is looking for the explicit type:
if (item.AttributeType.FullName == "ProtoBuf.ProtoContractAttribute")
{...}
Any solution / workaround?
Thanks!