Open
Description
Background and motivation
In some serialization systems (e.g. protobuf), any member, including those of derived types require a unique order indicator.
It would thus be beneficial to include the Order
property in the KnownType
attribute as well, so the serializer knows how to order to items of the derived types.
API Proposal
public sealed class KnownTypeAttribute : Attribute
{
public string? MethodName { get; }
public Type? Type { get; }
+ public int Order { get; set; }
}
API Usage
[DataContract]
[KnownType(typeof(Dog), Order = 100)]
public class Animal
{
[DataMember(Order = 1)]
public string Name { get; set; }
}
[DataContract]
public class Dog
{
[DataMember(Order = 1)]
public int TailLength { get; set; }
}
Alternative Designs
No response
Risks
No response