Preserve interpreted options when input to compiler is already-built FileDescriptorProto #217
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.
When a resolver provides an input to the compiler in the form of a
*descriptorpb.FileDescriptorProto
(instead of as source code, or as a fully-bakedprotoreflect.FileDescriptor
), the step that interprets options could inadvertently clobber field options (thinking it was the case that the options were empty, just because there were no uninterpreted options to process). Also, thelinker.Result.CanonicalProto()
method would also clobber options, even if it had no canonical serialized bytes to replace them.These issues were discovered when trying to upgrade
github.com/jhump/protoreflect
to the latest v0.7.0. This has likely been an issue for a while, but was now noticed because the latest/currentgoogle/protobuf/descriptor.proto
(which is used inprotoreflect
'sdesc/protoparse
package) now includes options on some fields. When that file descriptor proto is used as a compiler input, those options were getting stripped from the final, compiled result.This adds a test to catch this case here, too.