You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an enum that inherits from long:
public enum Code : long { BlaBla = 0xc0400001 }
and class that uses this enum as property type.
When I try to use it for serialization, it fails with OverflowException "Value was either too large or too small for an Int32" from your code.
class: "MetaType"
function: "NormalizeProtoMember"
line: "fieldNumber = Convert.ToInt32(((FieldInfo)member).GetRawConstantValue());"
Do you have some workaround for this?
Thanks
The text was updated successfully, but these errors were encountered:
This is an interesting one; I need to think about how this should work. The non-trivial part of the issue is that enums in protobuf are only defined for 32-bit values. However, since 2.3.0 adds much improved enum pass-thru support (consistent with proto3 runtime behaviour), it might be that we can simply treat long enums as direct pass-thru. Needs consideration. Adding to 2.3.1
Enum support is reworked in v3, with all enums becoming pass-thru to help support proto3 semantics; this means that I can support them in their native forms, i.e. long enums serialize as long. Short version: it all works fine in V3. If you try and generate a schema, it'll emit comments telling you why it can't describe it as en enum in .proto terms (if there are values outside the permitted range for .proto)
I have an enum that inherits from long:
public enum Code : long { BlaBla = 0xc0400001 }
and class that uses this enum as property type.
When I try to use it for serialization, it fails with OverflowException "Value was either too large or too small for an Int32" from your code.
class: "MetaType"
function: "NormalizeProtoMember"
line: "fieldNumber = Convert.ToInt32(((FieldInfo)member).GetRawConstantValue());"
Do you have some workaround for this?
Thanks
The text was updated successfully, but these errors were encountered: