Repository navigation
Releases
Releases · msgbuf/msgbuf
1.3.0
New Features
- TypeScript type definitions: Generate a TypeScript module per
.protofile describing its JSON
format (interfaces for messages, string-literal unions for enums, type-tagged tuple unions for polymorphic values).
Top-level types are named with the suffixJson(e.g.ShapeJson,AnyShapeJson), since they describe the JSON
format, not the data itself. Properties the Java writer always emits are required, only nullable fields are optional.
Enabled for all files with the Maven plugin parametertypeScriptOutputDirectoryor the-ts <dir>CLI argument,
or per file withoption TypeScript = "path/to/module.ts";.
For polymorphic values, the modules contain small helpers operating on the plain JSON values (#10): a visitor
interface and an exhaustive dispatch function (visitShapeJson(value, visitor), with a requiredvisitDefaultfor
option OpenWorld) and a type guard checking the type tag (isAnyShapeJson(value)) perAny...Jsonunion, and a
function creating the type-tagged tuple per concrete type (tagCircle(self)). No helpers are generated for
option SharedGraph. Helper names that would clash (e.g. ofmessage A_Band a nestedA.B) are rejected. - File documentation comment: A doc comment before the
syntaxorpackagedeclaration is kept as the documentation
of the.protofile (DefinitionFile.comment) and emitted as TSDoc@packageDocumentationof the TypeScript module.
Bug Fixes
- Nested polymorphic hierarchies (#16): An abstract message nested in another message no longer crashes the
generator with aNullPointerException. Nested sub-messages of a top-level abstract message are referenced by
their qualified names in the generated JSON and XML readers (previously uncompilable). Foroption OpenWorld, the
"same file" test for local subtypes and the impliedNoBinaryof extension files now also hold for nested
definitions. - Maven plugin parameter names (#17): The parameters
input,outputDirectory,resourceOutputDirectoryand
includePathscan be set under these names in the plugin<configuration>. Before, only the user properties
(-DoutputDir=…) worked, and the README's<resourceOutputDir>was silently ignored. - Format options for enums (#20):
option NoBinaryandoption NoJson(and the impliedNoBinaryof
option SharedGraphandoption OpenWorld) now also suppress the binary and JSON methods of enums.
Source compatibility: a file that uses an enum of another file in a format the other file disables did compile
before, because enums always had all methods. It is now rejected with an error naming both files and the option,
as are references to messages of such files and mixedoption SharedGraphreferences, which generated uncompilable
code before. The generator (CLI and Maven plugin) now stops without writing code when it finds such errors. - XML format: transient and derived fields (#29):
transientfields are no longer written in XML format, like in
JSON and binary format. Wire format change: XML documents no longer contain these attributes and elements;
readers ignore them in documents of earlier versions. The same applies to derived references (@Container,
@Reverse): writing an object whose container was set to XML recursed endlessly (StackOverflowError). - Redeclared fields (#21): A field that redeclares an inherited field (directly or through any generalization,
also across files), a field declared twice, and fields whose names generate the same Java names (e.g.foo_barand
fooBar) are rejected with an error. Before, the generator silently produced Java code that did not compile. - Extensions across files require OpenWorld (#25): A message that extends a message of another file is rejected
unless that file declaresoption OpenWorld. Extending from another package produced Java that did not compile.
Source compatibility: extending a message of an only imported (not generated together) file of the same package
compiled before, but the readers of the base did not know the subtype. It is now rejected as well. A closed
hierarchy split into files of the same package that are generated together is still accepted. Inheritance cycles
are rejected with an error instead of crashing the generator. - Nested specializations of the outer message (#32): A message nested in its own generalization (e.g.
abstract message Expr { message Sum extends Expr {…} }) crashed the generator with aStackOverflowError. - Consistent options across
extends(#37, #38, #39, #40, #41): A message that extends a message of another
file is rejected if the files disagree on the serialization formats,NoVisitor,NoVisitorExceptions,
NoTypeKindorNoInterfaces, or if it adds listener or reflection support its generalization lacks. These
combinations generated uncompilable code. The exception isNoJson(orNoXml) only on an OpenWorld extension
file: it compiled, but the extension type was written without its own fields and could not be read. It is rejected
now as well.option OpenWorldon a file whose hierarchy root is in a file without it, andOpenWorldcombined
withSharedGraphorNoInterfaces(before only a message on the console), are rejected.option NoVisitornow
also suppresses the visitor of OpenWorld extension types. - OpenWorld readers of abstract intermediates (#26): The JSON reader of an abstract message below the root of an
option OpenWorldhierarchy (e.g.BirdinAnimal > Bird > Parrot, top-level or nested) no longer fails to
compile. It reads the types of other files registered with the root, if they are specializations of the message; a
registered type of another subtree is skipped like an unknown type (the reader returnsnull). This also works for
abstract intermediates declared in extension files (which needoption OpenWorldto be extended themselves), at any
depth. All concrete messages of an extension file below an OpenWorld message of another file are now registered,
also those extending a message of their own file. Visiting a type of an extension-file intermediate with a visitor
that does not know it callsvisitDefault(), and such types returnnullfromkind(). The JSON readers load the
type registrations themselves (before, reading an extension type returnednullunless some implementation class
of the hierarchy had been initialized before). - OpenWorld XML readers (#27): The XML readers of an
option OpenWorldhierarchy (root and abstract intermediates)
now read the types of other files. The generated registration class (e.g.Ext1Types) additionally registers the
XML element name of each extension type with the root (registerXml(),XML_REGISTRY), if the files generate XML.
The wire formats are unchanged. - Primitive types in XML and binary format (#44):
bytes,fixed32anduint32fields no longer generate
uncompilable XML code (all versions since 1.1.0).bytesare written in Base64,fixed32/uint32as unsigned
decimal (the readers also accept the signed form). Nullable fields that are not set are omitted in XML format, and
bytesfields without a value in XML and binary format, instead of failing with aNullPointerException. An emptyrepeated
value (written as empty attribute) is read as empty list (before, reading failed for numbers, and a list of strings
contained one empty string). In binary format,sint32/sint64values are now written zig-zag encoded and
fixed32/sfixed32/fixed64/sfixed64values in fixed length, as the readers always expected, and 64 bit values
above 32 bits are read correctly (fix inmsgbuf-api). Wire format change: the binary encoding of these six
types changes; values written before could not be read back correctly (except0), and writing arepeatedfield
of these types failed. - Clashing type IDs in a hierarchy (#45): Two concrete specializations of an abstract message with the same type
ID (by default the simple name, e.g. a top-levelItemand a nestedMsg.Item, or an equal@Name), the same XML
element name, or the same explicit@type_id, also in extension files of anoption OpenWorldhierarchy generated
together, are rejected with an error naming both definitions. So are messages of one hierarchy with the same
TypeKindconstant (fix: rename, oroption NoTypeKind), and a message with the name of a nested definition of
one of its generalizations, which the generated class could not refer to. A top-level specialization whose simple
name is shadowed by a nested definition in the scope of its generalization is referenced by its qualified name in
the readers (before, the reader dispatched to the nested definition). Source compatibility: these definitions
generated uncompilable code before (or silently wrong readers), except equal type IDs in theoption OpenWorld
registry of extensions of different files, where the last registered type won. - Name resolution across packages (#46): An unqualified type name resolves (after nested definitions of the
message using it and its outer messages) to a definition of the package of the file using it, then to a definition
of the files it imports (directly, then indirectly), and only then to a definition of any other file generated in
the same run, if it is unique (see README, "Type names and imports"). Before, one global table of simple names was
used, and the definition of the last file loaded won. So the resolution of a file's names no longer depends on
unrelated files generated together, as long as it uses definitions of its own package or its imports. Duplicate
definitions in a package (in one or several files) stop the generation with an error naming the files, instead of
only a message on the console. A file given to the generator twice, or gi...
1.2.2
1.2.1
Full Changelog: msgbuf-api-1.2.0...msgbuf-api-1.2.1
1.2.0
What's Changed
- Fix default lifecycle phase for generate goal to generate-sources by @haumacher in #12
- Feature/issue 9 cross file extension by @haumacher in #13
- Feature/issue 11 json field type by @haumacher in #14
Full Changelog: msgbuf-api-1.1.10...msgbuf-api-1.2.0
1.1.10
What's Changed
- Fix transient inheritance by @haumacher in #7
Full Changelog: msgbuf-api-1.1.9...msgbuf-api-1.1.10
1.1.9
What's Changed
Full Changelog: msgbuf-api-1.1.8...msgbuf-api-1.1.9
msgbuf-api-1.1.8
What's Changed
- Use impl type only when interfaces are used. by @dbusche in #4
- Added listener method "afterChanged". by @dbusche in #5
- Fixed error in shared graph sync due to missing ID.
- No updates for transient objects in shard graph sync.
- Fixed endless reading from StringR.
- Allow to react on change of shared graph.
- Fixed GWT incompatibilities.
- Allow to specify field default values (9561842)
- Fixed code generation for derived fields.
Full Changelog: msgbuf-api-1.1.7...msgbuf-api-1.1.8
1.1.7
What's Changed
- Fixed reading of fields in generated classes by @dbusche in #2
- Added missing override for "set". by @dbusche in #3
Full Changelog: msgbuf-api-1.1.6...msgbuf-api-1.1.7
1.1.6
What's Changed
Full Changelog: msgbuf-api-1.1.5...msgbuf-api-1.1.6
1.1.5
- Added missing self() method override for @operations(...) annotated data classes.
- Added missing type kind literal for non-abstract root data classes.