Skip to content

Releases: jhump/protoreflect

v1.4.4

03 Jul 17:52
ae7b4b3
Compare
Choose a tag to compare

This release contains bug-fixes for a single function.

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

Changes/fixes:

  • The ResolveFilenames function previously expected file paths to always be relative to the process's current working directory. However, correct behavior (modeled after protoc) is to also allow file paths to be relative to one of the import paths. This has been fixed: file paths are only assumed to be relative to cwd when no such file exists that is relative to one of the import paths.
  • The ResolveFilenames function could get confused if provided paths that included symbolic links. When deciding whether or not one absolute path is a descendant of another (part of its logic to relate file paths with their corresponding import path), paths will now be canonicalized by resolving symbolic links.

v1.4.3

28 Jun 20:00
f5500d9
Compare
Choose a tag to compare

This release just contains one small change.

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

Changes/fixes:

  • When a parse/syntax/link error is encountered, it should always result in the client receiving an protoparse.ErrorWithSourcePos. Previously, if it happened when processing a given file's dependencies, the error would be wrapped and no longer be the right type, thus obscuring access to the source location of the error.

v1.4.2

12 Jun 16:58
efd29ef
Compare
Choose a tag to compare

This release contains just bug fixes.

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

Changes/fixes:

  • A panic could occur when removing a child element from a builder. This has been fixed.

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

Changes/fixes:

  • This package will now accept multi-line type references, as long as any whitespace (including newlines) appears between a component of a qualified name and the subsequent dot (.). For example, the following source would now be accepted (but previously would not):

    syntax = "proto3";
    import "google/protobuf/empty.proto";
    message Foo {
        google
            .protobuf
                .Empty bar = 1;
    }
  • When parsing either a well-known import (files included with protoc that have a "google/protobuf" import path) or a file that imports a well-known import, parsing would fail if the well-known import itself had any dependencies. This means that trying to parse any of the following (or files that imported any of the following) would return an error indicating unrecognized symbols:

    • google/protobuf/api.proto
    • google/protobuf/type.proto
    • google/protobuf/compiler/plugin.proto

    This issue is fixed, and parsing the above well-known imports now works.

"github.com/jhump/protoreflect/dynamic/msgregistry"

Changes/fixes:

  • The ComputeUrl method of type *msgregistry.MessageRegistry would return incorrect results for types that were explicitly added via the AddMessage, AddEnum, or AddFile methods. This has been fixed.

v1.4.1

24 May 04:03
92269e4
Compare
Choose a tag to compare

This contains a few minor changes/fixes to make the output of the protoparse package more closely resemble the descriptor protos parsed by protoc.

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

Changes/fixes:

  • Previously, the parser did not handle multi-line string literals (a C-like syntax supported by protoc). Now it does.
  • When including source info, the output did not include intermediate/aggregate data for all paths. It included only a subset of paths, whereas protoc would synthesize aggregate spans for ancestor paths, all the way up to the root path (empty path with a span that encompasses entire file). The parser in this package now also generates source info for these paths.
  • When including source info, the order of the paths was deterministic but not really per a well-defined sort order. Now the source info values are sorted by location/span.

v1.4.0

23 May 02:23
fdaf03a
Compare
Choose a tag to compare

This is a small release, mostly to support an initial release of goprotoc.

"github.com/jhump/protoreflect/desc"

Additions:

  • The ImportResolver type has a new SkipFallbackRules field. When set, any global rules set via calls to desc.RegisterImportPath will be ignored by the resolver; only rules set directly on the resolver will be respected.

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

Additions:

  • A new ResolveFilenames function has been added to help pre-process file names that may contain absolute paths. This is meant for use when the parser's Accessor is dealing with actual files on the filesystem (including when using the default accessor).

Changes/fixes:

  • Some minor changes were made to the resulting descriptor protos so they more closely match the output of protoc for the same input files:
    • The syntax field will not be set unless the file's syntax is proto3.
    • The MethodDescriptorProto.options field will be set if the source used { } to terminate the method (vs. ;), even if there were no options inside.

v1.3.0

20 May 18:36
7dce9ca
Compare
Choose a tag to compare

This release is mostly bug fixes and performance improvements to various packages. Though it does also include minor API addition to the dynamic package.

"github.com/jhump/protoreflect/dynamic"

Additions:

  • A new MarshalAppend method was added to dynamic.Message, which gives caller more control over allocation of byte slices.

Changes/fixes:

  • Numerous small performance improvements were made:
    • Setting values on a dynamic message would eagerly allocate and construct strings that were only used when errors were encountered. This is no longer done; strings are not allocated/computed until error actually occurs. This greatly reduces the number of allocations during de-serialization of messages.
    • When a dynamic message was cleared, its internal maps were set to nil. Now they are instead cleared (e.g. every key+value removed) so that they do not need to be re-allocated when the message is re-used.
    • When using Go 1.12 (which introduced MapRange to reflect.Value), reflective operations on map fields and values use the new MapRange method instead of MapKeys. This is much more efficient (less memory used, fewer allocations).
  • When a dynamic.Message is cloned using the proto.Clone method, the new message failed to copy an internal field (the message's associated dynamic.MessageFactory. This could cause strange behavior during de-serialization, where construction of nested message objects in the clone would vary from the source message.
  • Two dynamic.Message instances, for messages defined in "proto2" syntax, would previously be considered not equal if one of them had no value for a repeated or map field but the other had an explicitly empty value. However, for protobufs (and as implemented in proto.Equal), empty and unset map and repeated values should be indistinguishable. This was fixed.
  • Support was added to dynamic.Message for parsing "extended Any syntax" in the text format. This format allows google.protobuf.Any messages to be represented in a much more readable manner, where the embedded message value uses the text format (instead of being represented as bytes in the binary format).
  • A dynamic.Message with a float or double field with an infinite or NaN value could not be correctly marshaled to JSON. No error would occur, but the resulting JSON output would be invalid and un-parseable. This has been remedied.
  • A dynamic.Message could not be unmarshaled via the text format if the text data included an infinite or NaN value. This has also been remedied.

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

Changes/fixes:

  • Attempting to parse an empty file (or a file with only whitespace) would result in a panic. Now it returns an error.

v1.2.0

07 Mar 17:23
8bfeffd
Compare
Choose a tag to compare

This release includes numerous changes and enhancements in several packages herein.

"github.com/jhump/protoreflect/desc"

Additions:

  • Added ImportResolver type and RegisterImportPath functions, to aid with working around known link errors that can happen due to the way that generated code registers file descriptors in the proto runtime.

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

Changes/Fixes:

  • Previously, custom options were not examined. The result was that the built *desc.FileDescriptor did not have dependencies that properly reflected the true transitive closure of the descriptors therein.

    While this was not usually a problem when using the built descriptors, trying to use them with the protoprint package would fail to print these custom options (since they could not be resolved from the file's imports). This is now fixed.

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

Changes/Fixes:

  • Fixed issue where source info was not properly defined in parsed descriptors, even after setting the IncludeSourceInfo field on the Parser to true.

Additions:

  • Added ParseFilesButDoNotLink method to the Parser. This allows a "light weight" parse that simply turns a proto source file into a FileDescriptorProto.

    Note that since linking is skipped, many aspects of the file cannot be checked and some properties in the resulting descriptor will be wrong. For example, options cannot be interpreted, type references will be left as they are in source (e.g. unqualified), and fields with enum types will actually indicate they their type is message (the only way to distinguish an enum field from a message field is during linking, to examine whether the referenced element is an enum or a message).

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

Changes/Fixes:

  • Several fixes in marshaling/unmarshaling *dynamic.Message to/from JSON:
    • Dynamic messages that represented google.protobuf.Value or google.protobuf.ListValue could not be correctly unmarshalled from "null" or "[]" JSON, respectively. This is now fixed.
    • One-of fields in proto3 syntax files were not always correctly marshalled:
      • If EmitDefaults on the marshaler was true, the code would incorrectly include all of the oneof fields in the resulting JSON, each showing their default value. This makes it impossible for unmarshalling code to know which field was actually supposed to be set.
      • If EmitDefaults on the marshaler was false, but the oneof field had its default/zero value, it would be incorrectly excluded from the resulting JSON. This makes it impossible for unmarshalling code to know which field was supposed to be set.
  • The MergeFrom method of a dynamic message has a slightly more efficient implementation for merging in unknown extension fields.

Additions:

  • A GetKnownType method was added to KnownTypeRegistry.
  • Adds a SetExtension function, which can be used to set extension values using a *desc.FieldDescriptor to describe the extension and can be used to set extension fields on either dynamic messages or generated message structs.

"github.com/jhump/protoreflect/desc/dynamic/msgregistry"

Changes/Fixes:

  • The MessageAsPType method of the registry, for converting a message descriptor to a google.protobuf.Type, would panic with the following error:
    reflect: call of reflect.Value.Type on zero Value
    
    This is now fixed.
  • Previously, MessageRegistry could not resolve types provided by a TypeFetcher unless that fetcher could provide the entire transitive closure for the type. Now, such types can be resolved as long as the type's dependencies are known to the registry (e.g. explicitly added via AddMessage or AddEnum methods).

v1.1.0

17 Oct 21:53
f90aa08
Compare
Choose a tag to compare

This version includes several enhancements to the "github.com/jhump/protoreflect/desc/protoprint" package.

Changes/fixes:

  1. Trailing comments will be rendered on the same line as element in many cases.
  2. Fixed issue with errant comments showing up before and after extend ... blocks.
  3. Changed canonical ordering of elements when Printer.SortElements is true: options now show up after the package and import statements.

Additions:

  1. The protoprint.Printer type has a new method that allows printing any kind of descriptor to a string, not just files.
  2. There are several new options on protoprint.Printer which provide more control over how comments, type references, and whitespace get printed.

Deprecations:

  1. The OmitDetachedComments field of protoprint.Printer has been deprecated in favor of a new field that provides more control over what comments are included in the printed output.

Version 1.0.0

13 Sep 16:29
b28d968
Compare
Choose a tag to compare

This repo is sufficiently mature and used in enough production systems that a "1.0" release is overdue.

This 1.0.0 release includes a go.mod file, so it should be easy to use with vgo (or with GO111MODULE=on with Go 1.11). We'll use semantic versioning going forward.