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

add an option to disable the Pascal case convertion of enum members in generated C# code #8452

Closed
goldenbull opened this issue Apr 6, 2021 · 1 comment
Labels

Comments

@goldenbull
Copy link

goldenbull commented Apr 6, 2021

Currently, enum members in generated C# code is converted into Pascal case by default

But in real world app we need the enum members to be mandatory named. Here are some possible senarios:

  • There is already a lot of data scattered everywhere in the system, including Database, csv file, json data, etc. To make ease for debugging and human-beings daily operation, the enum field is saved as string, not integer, in these data. Although there is an ignoreCase parameter of Enum.TryParse to make it possible to read string from data, the result of ToString will be different of the existing data, which introduces inconsistence into data.
  • Migrate some hand-written enums to protobuf. Same as above, we can do some renaming work before migrating, but it's almost impossible to apply the renaming on the existing data.

Suggested modification:

  1. Add an option definition in descriptor.proto
  2. Make a small change in csharp_enum.cc, generate enum member name by option

Of course this is not an C#-only problem, and maybe related to #1079

@elharo elharo added the c# label Aug 25, 2021
@elharo
Copy link
Contributor

elharo commented Aug 25, 2021

This would break compatibility.

@elharo elharo closed this as completed Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants