Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix Gen Class Without Any Properties #15
Fix Gen Class Without Any Properties #15
Changes from 1 commit
1890b34
65e124b
ca16e4f
094fe23
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 150 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L149-L150
Check warning on line 153 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L152-L153
Check warning on line 181 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L181
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 have a question, in proto3 if
optional int32 x = 1
is considered optional and in proto2 ifrequired int32 x = 1
is considered required, is this going to return falseint32 x = 1
?I think we should have a couple of unit tests to verify this doesn't break anything.
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.
One thing I would suggest to simplify the code and reduce duplication is to add this modifier conditionally based on
isHasPropertyField
call. Simply we can hide this logic behind thegenerateSingleClass
method so users don't have to worry about figuring out which method to call 🙂Check warning on line 255 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L255
Check warning on line 268 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L268
Check warning on line 270 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L270
Check warning on line 311 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L310-L311
Check warning on line 321 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L314-L321
Check warning on line 323 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L323
Check warning on line 327 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L326-L327
Check warning on line 330 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L329-L330
Check warning on line 332 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L332
Check warning on line 334 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L334
Check warning on line 337 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L337
Check warning on line 340 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L339-L340
Check warning on line 342 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L342
Check warning on line 344 in app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt
Codecov / codecov/patch
app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt#L344
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.
Can you run
./gradlew build
in your local? I commit all the generated classes under generated-code-tests. Also we should have a test there to verify an empty message without any properties are serialized correctly.