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

Add support for proto2 required fields #216

Merged
merged 2 commits into from
May 17, 2022

Conversation

garyp
Copy link
Collaborator

@garyp garyp commented Mar 31, 2022

Also refactor some of the hasPresence-related code in the code generator to make it easier to understand.

Fixes #71.

Guide to changes

There's a lot of noise in this PR from empty lines being added to generated code. The interesting changes are in File.kt, FileBuilder.kt and CodeGenerator.kt under protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/. You can see an example of how these changes impact the generated code in runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt, where a couple required fields in the NamePart message were previously being generated incorrectly and now are handled properly.

Aside from the main changes, there is also some slight refactoring of the kotlinJavaRoundtripTest() method used in some of the tests (and the method also got renamed to pbandkJavaRoundtripTest()).

garyp added 2 commits March 29, 2022 00:28
Also refactor some of the `hasPresence`-related code in the code
generator to make it easier to understand.

Fixes #71.
@garyp garyp force-pushed the bug/GH-71-required-default-values branch from b44f412 to f5bb168 Compare March 31, 2022 14:39
Copy link
Contributor

@rahulreddym rahulreddym left a comment

Choose a reason for hiding this comment

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

LGTM

@garyp garyp merged commit 348d2f3 into master May 17, 2022
@garyp garyp deleted the bug/GH-71-required-default-values branch May 17, 2022 16:42
garyp added a commit that referenced this pull request Mar 7, 2023
Also refactor some of the `hasPresence`-related code in the code generator to make it easier to understand.

Fixes #71.

There's a lot of noise in this PR from empty lines being added to generated code. The interesting changes are in `File.kt`, `FileBuilder.kt` and `CodeGenerator.kt` under `protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/`. You can see an example of how these changes impact the generated code in `runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt`, where a couple `required` fields in the `NamePart` message were previously being generated incorrectly and now are handled properly.

Aside from the main changes, there is also some slight refactoring of the `kotlinJavaRoundtripTest()` method used in some of the tests (and the method also got renamed to `pbandkJavaRoundtripTest()`).
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.

Proto2 required fields that contain default values are not serialized correctly
2 participants