Add proto2 required
to generated field info
#700
Merged
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.
To support field presence going forward, this PR adds a property to the minimal field info we generate.
For a proto2 message that defines
required string string_field = 1
, generated code changes as follows:Previously, required fields were identified by the omission of
opt: true
. The new property will make it possible to merge the reflection-based serialization logic for proto2 and proto3.When updating to the next release of
@bufbuild/protobuf
, it is important to update the plugin@bufbuild/protoc-gen-es
as well, and regenerate code. (This PR does not rely on the new propertyreq
in generated code yet, but upcoming changes will.)Before any changes were made, test coverage for field info was added in 202baf0.