Internal changes

PiperOrigin-RevId: 637993561
pull/16957/head
Mike Kruskal 9 months ago committed by Copybara-Service
parent 2a07c57aa9
commit 433ca3e6a1
  1. 11
      editions/defaults_test.cc
  2. 6
      java/core/src/main/resources/google/protobuf/java_features.proto
  3. 1
      src/google/protobuf/compiler/cpp/generator_unittest.cc
  4. 4
      src/google/protobuf/compiler/java/java_features.pb.cc
  5. 4
      src/google/protobuf/cpp_features.pb.cc
  6. 6
      src/google/protobuf/cpp_features.proto
  7. 12
      src/google/protobuf/descriptor.pb.cc
  8. 18
      src/google/protobuf/descriptor.proto
  9. 1
      src/google/protobuf/feature_resolver_test.cc

@ -200,14 +200,15 @@ class OverridableDefaultsTest : public ::testing::Test {
}
};
// TODO Enable these once they become fixed internally.
TEST_F(OverridableDefaultsTest, Proto2) {
auto feature_defaults = ReadDefaults("protobuf_defaults");
ASSERT_OK(feature_defaults);
ASSERT_GE(feature_defaults->defaults().size(), 1);
const auto& defaults = feature_defaults->defaults(0);
auto defaults = feature_defaults->defaults(0);
ASSERT_EQ(defaults.edition(), EDITION_PROTO2);
EXPECT_THAT(defaults.overridable_features(), EqualsProto(R"pb([pb.cpp] {}
[pb.java] {}
)pb"));
@ -216,9 +217,10 @@ TEST_F(OverridableDefaultsTest, Proto3) {
auto feature_defaults = ReadDefaults("protobuf_defaults");
ASSERT_OK(feature_defaults);
ASSERT_GE(feature_defaults->defaults().size(), 2);
const auto& defaults = feature_defaults->defaults(1);
auto defaults = feature_defaults->defaults(1);
ASSERT_EQ(defaults.edition(), EDITION_PROTO3);
EXPECT_THAT(defaults.overridable_features(), EqualsProto(R"pb([pb.cpp] {}
[pb.java] {}
)pb"));
@ -230,9 +232,10 @@ TEST_F(OverridableDefaultsTest, Edition2023) {
auto feature_defaults = ReadDefaults("protobuf_defaults");
ASSERT_OK(feature_defaults);
ASSERT_GE(feature_defaults->defaults().size(), 3);
const auto& defaults = feature_defaults->defaults(2);
auto defaults = feature_defaults->defaults(2);
ASSERT_EQ(defaults.edition(), EDITION_2023);
EXPECT_THAT(defaults.overridable_features(), EqualsProto(R"pb(
field_presence: EXPLICIT
enum_type: OPEN

@ -27,7 +27,6 @@ message JavaFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
edition_deprecated: EDITION_2023,
@ -36,7 +35,7 @@ message JavaFeatures {
"edition 2025. Mark enum type on the enum "
"definitions themselves rather than on fields.",
},
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
edition_defaults = { edition: EDITION_LEGACY, value: "true" },
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
];
@ -56,7 +55,6 @@ message JavaFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
edition_deprecated: EDITION_2023,
@ -66,6 +64,6 @@ message JavaFeatures {
"use the global cross-language utf8_validation "
"feature.",
},
edition_defaults = { edition: EDITION_PROTO2, value: "DEFAULT" }
edition_defaults = { edition: EDITION_LEGACY, value: "DEFAULT" }
];
}

@ -97,6 +97,7 @@ TEST_F(CppGeneratorTest, LegacyClosedEnum) {
RunProtoc(
"protocol_compiler --proto_path=$tmpdir --cpp_out=$tmpdir foo.proto");
ExpectWarningSubstring(
"foo.proto:9:16: warning: Feature pb.CppFeatures.legacy_closed_enum has "
"been deprecated in edition 2023");

@ -77,7 +77,7 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fjava_2fjava_
"\n1google/protobuf/compiler/java/java_fea"
"tures.proto\022\002pb\032 google/protobuf/descrip"
"tor.proto\"\367\004\n\014JavaFeatures\022\374\001\n\022legacy_cl"
"osed_enum\030\001 \001(\010B\337\001\210\001\001\230\001\004\230\001\001\242\001\t\022\004true\030\346\007\242"
"osed_enum\030\001 \001(\010B\337\001\210\001\001\230\001\004\230\001\001\242\001\t\022\004true\030\204\007\242"
"\001\n\022\005false\030\347\007\262\001\271\001\010\350\007\020\350\007\032\260\001The legacy clos"
"ed enum treatment in Java is deprecated "
"and is scheduled to be removed in editio"
@ -85,7 +85,7 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fjava_2fjava_
"nitions themselves rather than on fields"
".\022\237\002\n\017utf8_validation\030\002 \001(\0162\037.pb.JavaFea"
"tures.Utf8ValidationB\344\001\210\001\001\230\001\004\230\001\001\242\001\014\022\007DEF"
"AULT\030\346\007\262\001\310\001\010\350\007\020\350\007\032\277\001The Java-specific ut"
"AULT\030\204\007\262\001\310\001\010\350\007\020\350\007\032\277\001The Java-specific ut"
"f8 validation feature is deprecated and "
"is scheduled to be removed in edition 20"
"25. Utf8 validation behavior should use"

@ -77,14 +77,14 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcpp_5ffeatures_2eproto[
"\n\"google/protobuf/cpp_features.proto\022\002pb"
"\032 google/protobuf/descriptor.proto\"\256\003\n\013C"
"ppFeatures\022\373\001\n\022legacy_closed_enum\030\001 \001(\010B"
"\336\001\210\001\001\230\001\004\230\001\001\242\001\t\022\004true\030\346\007\242\001\n\022\005false\030\347\007\262\001\270\001"
"\336\001\210\001\001\230\001\004\230\001\001\242\001\t\022\004true\030\204\007\242\001\n\022\005false\030\347\007\262\001\270\001"
"\010\350\007\020\350\007\032\257\001The legacy closed enum treatmen"
"t in C++ is deprecated and is scheduled "
"to be removed in edition 2025. Mark enu"
"m type on the enum definitions themselve"
"s rather than on fields.\022Z\n\013string_type\030"
"\002 \001(\0162\032.pb.CppFeatures.StringTypeB)\210\001\001\230\001"
"\004\230\001\001\242\001\013\022\006STRING\030\346\007\242\001\t\022\004VIEW\030\351\007\262\001\003\010\350\007\"E\n\n"
"\004\230\001\001\242\001\013\022\006STRING\030\204\007\242\001\t\022\004VIEW\030\351\007\262\001\003\010\350\007\"E\n\n"
"StringType\022\027\n\023STRING_TYPE_UNKNOWN\020\000\022\010\n\004V"
"IEW\020\001\022\010\n\004CORD\020\002\022\n\n\006STRING\020\003::\n\003cpp\022\033.goo"
"gle.protobuf.FeatureSet\030\350\007 \001(\0132\017.pb.CppF"

@ -24,7 +24,6 @@ message CppFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
edition_deprecated: EDITION_2023,
@ -33,7 +32,7 @@ message CppFeatures {
"edition 2025. Mark enum type on the enum "
"definitions themselves rather than on fields.",
},
edition_defaults = { edition: EDITION_PROTO2, value: "true" },
edition_defaults = { edition: EDITION_LEGACY, value: "true" },
edition_defaults = { edition: EDITION_PROTO3, value: "false" }
];
@ -48,11 +47,10 @@ message CppFeatures {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "STRING" },
edition_defaults = { edition: EDITION_LEGACY, value: "STRING" },
edition_defaults = { edition: EDITION_2024, value: "VIEW" }
];
}

@ -1905,22 +1905,22 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] AB
"e_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\311\t\n\nF"
"eatureSet\022\202\001\n\016field_presence\030\001 \001(\0162).goo"
"gle.protobuf.FeatureSet.FieldPresenceB\?\210"
"\001\001\230\001\004\230\001\001\242\001\r\022\010EXPLICIT\030\346\007\242\001\r\022\010IMPLICIT\030\347\007"
"\001\001\230\001\004\230\001\001\242\001\r\022\010EXPLICIT\030\204\007\242\001\r\022\010IMPLICIT\030\347\007"
"\242\001\r\022\010EXPLICIT\030\350\007\262\001\003\010\350\007\022b\n\tenum_type\030\002 \001("
"\0162$.google.protobuf.FeatureSet.EnumTypeB"
")\210\001\001\230\001\006\230\001\001\242\001\013\022\006CLOSED\030\346\007\242\001\t\022\004OPEN\030\347\007\262\001\003\010"
")\210\001\001\230\001\006\230\001\001\242\001\013\022\006CLOSED\030\204\007\242\001\t\022\004OPEN\030\347\007\262\001\003\010"
"\350\007\022\201\001\n\027repeated_field_encoding\030\003 \001(\01621.g"
"oogle.protobuf.FeatureSet.RepeatedFieldE"
"ncodingB-\210\001\001\230\001\004\230\001\001\242\001\r\022\010EXPANDED\030\346\007\242\001\013\022\006P"
"ncodingB-\210\001\001\230\001\004\230\001\001\242\001\r\022\010EXPANDED\030\204\007\242\001\013\022\006P"
"ACKED\030\347\007\262\001\003\010\350\007\022n\n\017utf8_validation\030\004 \001(\0162"
"*.google.protobuf.FeatureSet.Utf8Validat"
"ionB)\210\001\001\230\001\004\230\001\001\242\001\t\022\004NONE\030\346\007\242\001\013\022\006VERIFY\030\347\007"
"ionB)\210\001\001\230\001\004\230\001\001\242\001\t\022\004NONE\030\204\007\242\001\013\022\006VERIFY\030\347\007"
"\262\001\003\010\350\007\022m\n\020message_encoding\030\005 \001(\0162+.googl"
"e.protobuf.FeatureSet.MessageEncodingB&\210"
"\001\001\230\001\004\230\001\001\242\001\024\022\017LENGTH_PREFIXED\030\346\007\262\001\003\010\350\007\022v\n"
"\001\001\230\001\004\230\001\001\242\001\024\022\017LENGTH_PREFIXED\030\204\007\262\001\003\010\350\007\022v\n"
"\013json_format\030\006 \001(\0162&.google.protobuf.Fea"
"tureSet.JsonFormatB9\210\001\001\230\001\003\230\001\006\230\001\001\242\001\027\022\022LEG"
"ACY_BEST_EFFORT\030\346\007\242\001\n\022\005ALLOW\030\347\007\262\001\003\010\350\007\"\\\n"
"ACY_BEST_EFFORT\030\204\007\242\001\n\022\005ALLOW\030\347\007\262\001\003\010\350\007\"\\\n"
"\rFieldPresence\022\032\n\026FIELD_PRESENCE_UNKNOWN"
"\020\000\022\014\n\010EXPLICIT\020\001\022\014\n\010IMPLICIT\020\002\022\023\n\017LEGACY"
"_REQUIRED\020\003\"7\n\010EnumType\022\025\n\021ENUM_TYPE_UNK"

@ -974,11 +974,10 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "EXPLICIT" },
edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" },
edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" },
edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" }
];
@ -992,11 +991,10 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_ENUM,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "CLOSED" },
edition_defaults = { edition: EDITION_LEGACY, value: "CLOSED" },
edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" }
];
@ -1009,11 +1007,10 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "EXPANDED" },
edition_defaults = { edition: EDITION_LEGACY, value: "EXPANDED" },
edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" }
];
@ -1027,11 +1024,10 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "NONE" },
edition_defaults = { edition: EDITION_LEGACY, value: "NONE" },
edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" }
];
@ -1044,11 +1040,10 @@ message FeatureSet {
retention = RETENTION_RUNTIME,
targets = TARGET_TYPE_FIELD,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "LENGTH_PREFIXED" }
edition_defaults = { edition: EDITION_LEGACY, value: "LENGTH_PREFIXED" }
];
enum JsonFormat {
@ -1061,11 +1056,10 @@ message FeatureSet {
targets = TARGET_TYPE_MESSAGE,
targets = TARGET_TYPE_ENUM,
targets = TARGET_TYPE_FILE,
// TODO Enable this in google3 once protoc rolls out.
feature_support = {
edition_introduced: EDITION_2023,
},
edition_defaults = { edition: EDITION_PROTO2, value: "LEGACY_BEST_EFFORT" },
edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY_BEST_EFFORT" },
edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" }
];

@ -1342,7 +1342,6 @@ TEST_F(FeatureResolverPoolTest, CompileDefaultsMinimumCovered) {
auto defaults = FeatureResolver::CompileDefaults(
feature_set_, {ext}, EDITION_99997_TEST_ONLY, EDITION_99999_TEST_ONLY);
ASSERT_OK(defaults);
EXPECT_THAT(*defaults, EqualsProto(R"pb(
minimum_edition: EDITION_99997_TEST_ONLY
maximum_edition: EDITION_99999_TEST_ONLY

Loading…
Cancel
Save