While serializing a Flags long Enum, protobuf-net throws a System.Overflow exception. Here's a schematic description of what I'm doing:
Class being serialized:
[ProtoContract()]
public class Entry
{
[ProtoMember(1)]
public FancyLongEnum FancyLongEnum {get;set;}
}
The Enum:
[ProtoContract(ImplicitFields = ImplicitFields.AllFields, EnumPassthru = true)]
[Flags]
public enum FancyLongEnum : long
{
FirstFancyValue = 1,
[...]
LastFancyValue = 137438953472
}
The result:
System.OverflowException: Arithmetic operation resulted in an overflow.
A workaround is to use a wrapper long property and ignore the FancyLongEnum during serialization. However, I was hoping there is a cleaner way.
A similar issue was discussed in Error while using ProtoBuf-Net with flags enum. It resulted in a fix to protobuf-net.
How can I make serialization work directly, without resorting to wrapper property?