-
Notifications
You must be signed in to change notification settings - Fork 8
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 option to make message type fields always nullable #9
Comments
I prefer the current implementation. We have a convention of adding Also, if We use |
No, these fields are set with default instances |
I also agree that having an option for both is the best way to go. |
One reason why Proto uses message LinkedList {
string value = 1;
LinkedList next = 2;
} In this case, the generated code shouldn't really work, right? I assume Kotlin code looks like this: data class LinkedList(
val value: String,
val next: LinkedList,
) Which is basically impossible to initialize. As long as code throws an appropriate error, I like it. |
Sorry for late response, I am reproducing the bug here: #19 Because every message is |
In proto3, message type fields are always optional; adding the optional keyword does not change the compiled java code
i.e)
is equal to
However, krotoDC currently generates different code for these two cases
Because of this, when a krotoDC message type field is not set, while message type fields with the optional keyword are "unset", fields without the keyword is set with an empty message (with all fields unset).
Strictly speaking, this contradicts the proto3 syntax's basic rule; that all message fields are optional. But it is true that this difference could be preferred for certain cases.
The best way to go would be adding an option for the krotoDC protoc plugin that when enabled, creates all message type fields as nullable. then, if this is preferred by the majority of users, we could adpot it as the default behavior
The text was updated successfully, but these errors were encountered: