Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

long enum OverflowException #219

Closed
visur opened this issue Feb 22, 2017 · 2 comments
Closed

long enum OverflowException #219

visur opened this issue Feb 22, 2017 · 2 comments
Assignees
Milestone

Comments

@visur
Copy link

visur commented Feb 22, 2017

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

@mgravell
Copy link
Member

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

@mgravell mgravell self-assigned this Jun 20, 2017
@mgravell mgravell added this to the 2.3.1 milestone Jun 20, 2017
@mgravell mgravell modified the milestones: 2.3.2, 2.3.1 Jul 30, 2017
@mgravell
Copy link
Member

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)

@mgravell mgravell modified the milestones: 2.3.2, 3.0, 2.3.1 Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants