-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose experimental syntax "editions" in descriptor sets #621
Conversation
case "editions": | ||
// TODO support edition featureset | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would probably unify this with "proto3" so it is at least closer to accurate. By default in editions (without element-level feature override), it behaves the same as proto3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In EDITION_2023 it does, but in EDITION_PROTO2 it does not 😛 Will update this logic in the next step, where this value will be plucked from FeatureSetDefaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if the edition is EDITION_PROTO2
, the syntax will not be "editions"; it will be "proto2".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right about "proto2" of course.
Here is the new implementation of isPackedFieldByDefault. It uses the seeded default value of repeated_field_encoding
for the edition, including EDITION_PROTO2
, EDITION_PROTO3
, EDITION_2023
, and any future edition.
The implementation is shorter and seems less ambiguous. I guessed it would, which is why I wanted to hold off modifying it in this PR. I should have explained better.
This change exposes the editions syntax in a
DescriptorSet
, the wrapper around protobuf file descriptor messages provided bycreateDescriptorSet
from@bufbuild/protobuf
.The type
DescFile
receives a new property:The
syntax
property is updated to include"editions"
in the union type:For example, a file with
syntax="proto3"
will have the propertiessyntax: "proto3"
andedition: Edition.EDITION_PROTO3
. A file withedition="2023"
will have the propertiessyntax: "editions"
andedition: Edition.EDITION_2023
.Note that this change may cause compile time errors in your code, even if you are not using editions yet.
Edition FeatureSets are not exposed yet.
protoc-gen-es
cannot generate code for editions yet. This change just allowscreateDescriptorSet
to wrap descriptors using editions.