-
Notifications
You must be signed in to change notification settings - Fork 570
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
EnumMode enum option #2993
Conversation
/** | ||
* 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
|
||
// Target is set to "enum_class" so the option should not have any effect. | ||
enum Period { | ||
option (wire.enum_mode) = "enum_class"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this
This takes precedence over the newly created
KotlinTarget#enumMode
to allow granular migration.Extension registered here protocolbuffers/protobuf#17158