Closed WebDrake closed 8 years ago
as we might reasonably assume that some 3rd-party protobuf definitions written with other languages in mind will start explicitly specifying the protobuf version.
Why? As far as I know, it isn't valid proto2. It should only be used to differentiate between proto2 and proto3+ by the presence of the syntax
statement, and between proto3 and future versions by its value.
I'd say it's reasonable to assume that any .proto
file with a syntax
statement is proto3+ and therefore not currently supported by dproto.
It might be useful to detect if it's present though, to give the user a meaningful error message about the version of protobuf not being supported.
I'd say it's reasonable to assume that any .proto file with a syntax statement is proto3+ and therefore not currently supported by dproto.
Let's put it this way: if you get a .proto
file that was prepared by someone using protoc
3.0+, they might well put syntax = "proto2";
in there in order to explicitly indicate the version, and protoc
3.0+ will AFAIK accept this and output proto2-compatible data structures.
If I'm a downstream to that working with dproto
, I'd really like dproto
to just deal with that instead of being too strict about the question of whether the syntax
statement is even valid for proto2. It's going to have to deal with it anyway if proto3 support is implemented, so why not allow the possibility that someone can also specify syntax = "proto2";
... ?
It seems that they changed the language spec for proto2 to include the syntax statement.
So yes, this should indeed be implemented in dproto.
Thanks for verifying that!
protoc
3.0+ introduces a newsyntax = ...
statement that can be used to specify the protocol buffers version a definition file is intended to work with, i.e.or
While theoretically the absence of this statement will cause
protoc
to assume that a.proto
file is written inproto2
(cf. https://developers.google.com/protocol-buffers/docs/proto3#simple), in practice it may be useful to support it, as we might reasonably assume that some 3rd-party protobuf definitions written with other languages in mind will start explicitly specifying the protobuf version.