Skip to content

v1.7.0

Choose a tag to compare

@jhump jhump released this 30 Jun 15:07
93246e2

This release contains some bug fixes and some new API. Most of the new API is to support the new proto3 optional feature introduced with protoc 3.12 (aka "field presence in proto3").

"github.com/jhump/protoreflect/desc"

Additions:

  • The desc.FieldDescriptor and desc.OneOfDescriptor types have new methods related to "proto3 optional" fields: FieldDescriptor.IsProto3Optional, FieldDescriptor.HasPresence, and OneOfDescriptor.IsSynthetic.

"github.com/jhump/protoreflect/desc/builder"

Additions:

  • The builder.FieldBuilder type has a new bool field Proto3Optional as well as related method SetProto3Optional, for working with and building "proto3 optional" fields.

"github.com/jhump/protoreflect/desc/protoparse"

Additions:

  • Adds a new WarningReporter type and field of the same name on the Parser type. When the field is populated (e.g. non-nil), the value will be used to report warnings. Currently, the only warning supported is for files that do not have a syntax declaration. The reporter will receive a warning where the given error value is protoparse.ErrNoSyntax.

Changes/fixes:

  • This package now accepts source files that use the optional field label for syntax = "proto3" files. Like protoc, this results in a synthetic single-field oneof that wraps the optional field.
  • Fixes a panic that could occur when calling the GetPosition field of an ErrorWithPos value returned by this package. This occurred when there were I/O errors (or other errors returned by the parser's file accessor) when accessing the top-level filenames requested for the parse operation.
  • When a custom error reporter is in use, the reporter can return nil to indicate that the operation should proceed. The spec states that even if the reporter returns nil and does not abort processing, the final result of the parse operation would be protoparse.ErrInvalidSource if any errors were reported. But for some errors (specifically: linking errors), errors could be reported but the final disposition would be successful. This has been remedied to correctly return an error if any errors are reported.

"github.com/jhump/protoreflect/desc/protoprint"

Changes/fixes:

  • This package can now correctly print files that contain "proto3 optional" fields. Previously, it would explicitly print the synthetic one-of and not include the optional label; that is now fixed.