Skip to content
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

Add final checks that were added to protoc between v27.0-rc3 and final v27.0 #309

Merged
merged 4 commits into from
May 30, 2024

Conversation

jhump
Copy link
Member

@jhump jhump commented May 30, 2024

There were three changes in the final v27.0 that were not previously implemented in this compiler:

  1. A new feature_support field on EnumValueOptions to allow defining the lifetime of a feature value. This is similar to the field of the same name and type on FieldOptions, but it controls the actual enum values and in which editions they are valid. (This resolves editions: how to prevent use of new "string_type" feature in edition 2023? protocolbuffers/protobuf#16369 (comment).)

  2. A new check that a feature is not used from the same file in which it's defined. (This resolves editions: options interpretation can generate incorrect results protocolbuffers/protobuf#16756.)

  3. A change to google/protobuf/descriptor.proto to add extension declarations for known custom features. (This resolves editions: strange behavior with open enums and unrecognized values in message literals protocolbuffers/protobuf#16757.)

    Unfortunately, this one isn't quite part of this PR because this configuration is not actually in the descriptorpb package. Why not? Because extension declarations are defined as source-only options, which means they aren't preserved at runtime, which means they are not present in the embedded descriptor in the latest descriptorpb package. I will address this in a subsequent PR by making the sources for these files available to compiler users. It will need to be in a separate package that so it doesn't get linked into user programs by default. For example, the buf CLI won't need it because it has its own mechanism of supplying the sources for these files.

This PR updates to use the latest (final) v27.0 release and also updates the protobuf-go dependency to include the v27.0 version of the descriptorpb package (first two commits). It then implements the same checks as the first two bullets mentioned above, each in its own commit.

@jhump jhump merged commit 4190af1 into main May 30, 2024
9 checks passed
@jhump jhump deleted the jh/feature-support-in-enum-vals branch May 30, 2024 22:25
kralicky pushed a commit to kralicky/protocompile that referenced this pull request Jun 19, 2024
…l v27.0 (bufbuild#309)

This change mirrors two of the changes in the final v27.0 of protoc
that were not previously implemented in this compiler:

1. A new `feature_support` field on `EnumValueOptions` to allow defining
the lifetime of a feature value. This is similar to the field of the
same name and type on `FieldOptions`, but it controls the actual enum
values and in which editions they are valid.
2. A new check that a feature is not used from the same file in which
it's defined.

This change updates this repo to use the latest (final) v27.0 release and
also updates the protobuf-go dependency to include the v27.0 version
of the `descriptorpb` package.

(cherry picked from commit 4190af1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants