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

EnumMode enum option #2993

Merged
merged 1 commit into from
Jun 17, 2024
Merged

Conversation

oldergod
Copy link
Member

This takes precedence over the newly created KotlinTarget#enumMode to allow granular migration.

Extension registered here protocolbuffers/protobuf#17158

@oldergod oldergod requested a review from swankjesse June 17, 2024 10:53
Comment on lines +47 to +55
/**
* Defines how an enum type is to be generated. This is only supported by Kotlin generation.
* - 'enum_class': the enum type will be generated as a Kotlin enum class.
* - 'sealed_class': the enum type will be generated as a Kotlin sealed class.
*
* When set, the value of this option takes precedence over the global enum mode that may be set
* at the Kotlin target level in the Wire Gradle plugin.
*/
optional string enum_mode = 1190;
Copy link
Member Author

Choose a reason for hiding this comment

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

even though enum_class and sealed_class are Kotlin words, I think we'd wanna use this option on Java generation as well later, even if they are less explicit.
Hence the option name to enum_mode instead of something like kotlin_enum

Copy link
Member

Choose a reason for hiding this comment

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

I like it

@oldergod oldergod changed the title EnunMode enum option Jun 17, 2024

// Target is set to "enum_class" so the option should not have any effect.
enum Period {
option (wire.enum_mode) = "enum_class";
Copy link
Member

Choose a reason for hiding this comment

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

Love this

@oldergod oldergod merged commit 6d96dc2 into master Jun 17, 2024
11 checks passed
@oldergod oldergod deleted the bquenaudon.2024-06-17.enummodeextension branch June 17, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants