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

Generate unrecognized constant for enums if option is true #2885

Merged
merged 3 commits into from
Mar 29, 2024

Conversation

oldergod
Copy link
Member

No description provided.

Comment on lines 2226 to 2234
constants = enum.constants + listOf(
EnumConstant(
location = enum.location,
name = "UNRECOGNIZED",
tag = -1,
documentation = "",
options = Options(optionType = ENUM_OPTIONS, optionElements = listOf()),
),
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super-nit: the order perhaps does not matter but does protoc list -1 tag first?

Suggested change
constants = enum.constants + listOf(
EnumConstant(
location = enum.location,
name = "UNRECOGNIZED",
tag = -1,
documentation = "",
options = Options(optionType = ENUM_OPTIONS, optionElements = listOf()),
),
),
constants = listOf(
EnumConstant(
location = enum.location,
name = "UNRECOGNIZED",
tag = -1,
documentation = "",
options = Options(optionType = ENUM_OPTIONS, optionElements = listOf()),
),
) + enum.constants,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protoc adds it at the end. But it doesn't matter really. We can put it in front

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@oldergod oldergod merged commit 9e95a85 into master Mar 29, 2024
7 checks passed
@oldergod oldergod deleted the bquenaudon.2024-03-28.kotlingeneratorunrecognized branch March 29, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants