-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Enable enumPropertyNaming for java generators #19277
Conversation
It is good to have this option in the java generators. Is original the option to generate upper case names without underscore (like in 7.5.0)? I don't like the name original because it will not mean anything in the future. Maybe ALPHANUMERIC_UPPERCASE or UPPERCASE_WITHOUT_UNDERSCORE? I wonder about he option camelCaseDollarSign. Should it be used as well for enum names? I've worked on a similar PR, but I have no time to work on it. |
To all of the above: For consistency's sake, I have simply repurposed the options from the Kotlin generator (as the option itself as well as its value set are defined globally) with a few adjustments in behaviour for the recently-released changes to enum property naming in 7.7 (see the bug referenced above). Therefore, I'm hesitant to modify the list of option values, and their corresponding behaviours. "original" is (from what I can tell in the Kotlin generator) meant to mostly preserve the input value. So it would not actually convert to uppercase, but preserve case from input, I think. I'm personally not sure on this either (hence my above description re preserving the old behaviour), and would rather have a distinction between the two modes of UPPERCASE/SCREAMING_SNAKE_CASE, but again, don't want to mess with existing implementations of the option unless unavoidable. I'll think about it some more while I explore the samples and tests, but this is one of the reasons I opened the PR to discussion at this stage already.
Thanks, will have a look. |
bf7ad3b
to
99c6546
Compare
I've adjusted some of the test cases to be more in line with the Kotlin example - not entirely happy with the current results, but it's fairly consistent now at least. |
As the existing samples work with the default and the unit tests cover most of the relevant options, I've omitted additional samples. |
I like the distinction between UPPERCASE/SCREAMING_SNAKE_CASE. |
Hi @vad-systems, thanks for the PR! For some |
I would tend to agree. That particular part might need a rework. However, the changes made in toVarName cause some issues otherwise, which I haven't been able to resolve without a much broader rewrite. I'm certainly open to contributions to that effect. |
I have created this commit to show how the adaptions could be done. This commit covers only the "original" enumPropertyNaming value, and it might be missing some edge cases. But it should be a good starting point. And all the test cases in Does this resolve the issues you mentioned? If not, could you give a concrete example what problems are coming up? |
thanks for the PR. I've filed #20172 to add the option (MACRO_CASE, legacy) please give it a try when you've time. |
updated the comment. thanks for pointing it out. |
update: PR merged. please give it a try with the latest master or snapshot version. closing this one for the time being |
@wing328 why was this PR not approved and merged ? |
@jrxap Because I've been out of commission for a few months and hopefully the other PR resolved this issue already. I unfortunately haven't been able to check because I'm not wholly affiliated with the project in question anymore. Cursory look over the other PR indicates that it should work for most cases. |
Copied the enumPropertyNaming functionality from the Kotlin generator, with some adjustments to make it compliant with the current implementation of the
enumPropertyNaming=UPPERCASE
default case. Most notably, this implementation handles a few further special cases and is more lenient on stripping e.g. a leading underscore.Users experiencing a change in naming when upgrading to a >=7.7 version should be able to use the
enumPropertyNaming=original
to restore the prior behaviour.Pending:
Test cases and samplesoriginal
implementation restores old behaviour to a reasonable extentCould potentially fix #19066 and resolve #18987
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.8.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)