@@ -62,6 +62,13 @@ enum Edition {
62
62
// A placeholder for an unknown edition value.
63
63
EDITION_UNKNOWN = 0 ;
64
64
65
+ // Legacy syntax "editions". These pre-date editions, but behave much like
66
+ // distinct editions. These can't be used to specify the edition of proto
67
+ // files, but feature definitions must supply proto2/proto3 defaults for
68
+ // backwards compatibility.
69
+ EDITION_PROTO2 = 998 ;
70
+ EDITION_PROTO3 = 999 ;
71
+
65
72
// Editions that have been released. The specific values are arbitrary and
66
73
// should not be depended on, but they will always be time-ordered for easy
67
74
// comparison.
@@ -74,6 +81,11 @@ enum Edition {
74
81
EDITION_99997_TEST_ONLY = 99997 ;
75
82
EDITION_99998_TEST_ONLY = 99998 ;
76
83
EDITION_99999_TEST_ONLY = 99999 ;
84
+
85
+ // Placeholder for specifying unbounded edition support. This should only
86
+ // ever be used by plugins that can expect to never require any changes to
87
+ // support a new edition.
88
+ EDITION_MAX = 0x7FFFFFFF ;
77
89
}
78
90
79
91
// Describes a complete .proto file.
@@ -109,12 +121,8 @@ message FileDescriptorProto {
109
121
// If `edition` is present, this value must be "editions".
110
122
optional string syntax = 12 ;
111
123
112
- // The edition of the proto file, which is an opaque string.
113
- // TODO(b/297898292) Deprecate and remove this field in favor of enums.
114
- optional string edition = 13 ;
115
-
116
124
// The edition of the proto file.
117
- optional Edition edition_enum = 14 ;
125
+ optional Edition edition = 14 ;
118
126
}
119
127
120
128
// Describes a message type.
@@ -197,9 +205,10 @@ message ExtensionRangeOptions {
197
205
}
198
206
199
207
// The verification state of the range.
200
- // TODO(b/278783756) : flip the default to DECLARATION once all empty ranges
208
+ // TODO: flip the default to DECLARATION once all empty ranges
201
209
// are marked as UNVERIFIED.
202
- optional VerificationState verification = 3 [default = UNVERIFIED ];
210
+ optional VerificationState verification = 3
211
+ [default = UNVERIFIED , retention = RETENTION_SOURCE ];
203
212
204
213
// Clients can define custom options in extensions of this message. See above.
205
214
extensions 1000 to max;
@@ -224,9 +233,10 @@ message FieldDescriptorProto {
224
233
TYPE_BOOL = 8 ;
225
234
TYPE_STRING = 9 ;
226
235
// Tag-delimited aggregate.
227
- // Group type is deprecated and not supported in proto3 . However, Proto3
236
+ // Group type is deprecated and not supported after google.protobuf . However, Proto3
228
237
// implementations should still be able to parse the group wire format and
229
- // treat group fields as unknown fields.
238
+ // treat group fields as unknown fields. In Editions, the group wire format
239
+ // can be enabled via the `message_encoding` feature.
230
240
TYPE_GROUP = 10 ;
231
241
TYPE_MESSAGE = 11 ; // Length-delimited aggregate.
232
242
@@ -243,8 +253,11 @@ message FieldDescriptorProto {
243
253
enum Label {
244
254
// 0 is reserved for errors
245
255
LABEL_OPTIONAL = 1 ;
246
- LABEL_REQUIRED = 2 ;
247
256
LABEL_REPEATED = 3 ;
257
+ // The required label is only allowed in google.protobuf. In proto3 and Editions
258
+ // it's explicitly prohibited. In Editions, the `field_presence` feature
259
+ // can be used to get this behavior.
260
+ LABEL_REQUIRED = 2 ;
248
261
}
249
262
250
263
optional string name = 1 ;
@@ -287,12 +300,12 @@ message FieldDescriptorProto {
287
300
// If true, this is a proto3 "optional". When a proto3 field is optional, it
288
301
// tracks presence regardless of field type.
289
302
//
290
- // When proto3_optional is true, this field must be belong to a oneof to
291
- // signal to old proto3 clients that presence is tracked for this field. This
292
- // oneof is known as a "synthetic" oneof, and this field must be its sole
293
- // member (each proto3 optional field gets its own synthetic oneof). Synthetic
294
- // oneofs exist in the descriptor only, and do not generate any API. Synthetic
295
- // oneofs must be ordered after all "real" oneofs.
303
+ // When proto3_optional is true, this field must belong to a oneof to signal
304
+ // to old proto3 clients that presence is tracked for this field. This oneof
305
+ // is known as a "synthetic" oneof, and this field must be its sole member
306
+ // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
307
+ // exist in the descriptor only, and do not generate any API. Synthetic oneofs
308
+ // must be ordered after all "real" oneofs.
296
309
//
297
310
// For message fields, proto3_optional doesn't create any semantic change,
298
311
// since non-repeated message fields always track presence. However it still
@@ -597,7 +610,7 @@ message MessageOptions {
597
610
// This should only be used as a temporary measure against broken builds due
598
611
// to the change in behavior for JSON field name conflicts.
599
612
//
600
- // TODO(b/261750190) This is legacy behavior we plan to remove once downstream
613
+ // TODO This is legacy behavior we plan to remove once downstream
601
614
// teams have had time to migrate.
602
615
optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true ];
603
616
@@ -637,7 +650,9 @@ message FieldOptions {
637
650
// a more efficient representation on the wire. Rather than repeatedly
638
651
// writing the tag and type for each element, the entire array is encoded as
639
652
// a single length-delimited blob. In proto3, only explicit setting it to
640
- // false will avoid using packed encoding.
653
+ // false will avoid using packed encoding. This option is prohibited in
654
+ // Editions, but the `repeated_field_encoding` feature can be used to control
655
+ // the behavior.
641
656
optional bool packed = 2 ;
642
657
643
658
// The jstype option determines the JavaScript type used for values of the
@@ -744,9 +759,7 @@ message FieldOptions {
744
759
repeated OptionTargetType targets = 19 ;
745
760
746
761
message EditionDefault {
747
- // TODO(b/297898292) Deprecate and remove this field in favor of enums.
748
- optional string edition = 1 ;
749
- optional Edition edition_enum = 3 ;
762
+ optional Edition edition = 3 ;
750
763
optional string value = 2 ; // Textproto value.
751
764
}
752
765
repeated EditionDefault edition_defaults = 20 ;
@@ -793,7 +806,7 @@ message EnumOptions {
793
806
// and strips underscored from the fields before comparison in proto3 only.
794
807
// The new behavior takes `json_name` into account and applies to proto2 as
795
808
// well.
796
- // TODO(b/261750190) Remove this legacy behavior once downstream teams have
809
+ // TODO Remove this legacy behavior once downstream teams have
797
810
// had time to migrate.
798
811
optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true ];
799
812
@@ -917,7 +930,7 @@ message UninterpretedOption {
917
930
// ===================================================================
918
931
// Features
919
932
920
- // TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are
933
+ // TODO Enums in C++ gencode (and potentially other languages) are
921
934
// not well scoped. This means that each of the feature enums below can clash
922
935
// with each other. The short names we've chosen maximize call-site
923
936
// readability, but leave us very open to this scenario. A future feature will
@@ -934,7 +947,9 @@ message FeatureSet {
934
947
retention = RETENTION_RUNTIME ,
935
948
targets = TARGET_TYPE_FIELD ,
936
949
targets = TARGET_TYPE_FILE ,
937
- edition_defaults = { edition_enum : EDITION_2023, value : "EXPLICIT" }
950
+ edition_defaults = { edition : EDITION_PROTO2, value : "EXPLICIT" },
951
+ edition_defaults = { edition : EDITION_PROTO3, value : "IMPLICIT" },
952
+ edition_defaults = { edition : EDITION_2023, value : "EXPLICIT" }
938
953
];
939
954
940
955
enum EnumType {
@@ -946,7 +961,8 @@ message FeatureSet {
946
961
retention = RETENTION_RUNTIME ,
947
962
targets = TARGET_TYPE_ENUM ,
948
963
targets = TARGET_TYPE_FILE ,
949
- edition_defaults = { edition_enum : EDITION_2023, value : "OPEN" }
964
+ edition_defaults = { edition : EDITION_PROTO2, value : "CLOSED" },
965
+ edition_defaults = { edition : EDITION_PROTO3, value : "OPEN" }
950
966
];
951
967
952
968
enum RepeatedFieldEncoding {
@@ -958,7 +974,21 @@ message FeatureSet {
958
974
retention = RETENTION_RUNTIME ,
959
975
targets = TARGET_TYPE_FIELD ,
960
976
targets = TARGET_TYPE_FILE ,
961
- edition_defaults = { edition_enum : EDITION_2023, value : "PACKED" }
977
+ edition_defaults = { edition : EDITION_PROTO2, value : "EXPANDED" },
978
+ edition_defaults = { edition : EDITION_PROTO3, value : "PACKED" }
979
+ ];
980
+
981
+ enum Utf8Validation {
982
+ UTF8_VALIDATION_UNKNOWN = 0 ;
983
+ VERIFY = 2 ;
984
+ NONE = 3 ;
985
+ }
986
+ optional Utf8Validation utf8_validation = 4 [
987
+ retention = RETENTION_RUNTIME ,
988
+ targets = TARGET_TYPE_FIELD ,
989
+ targets = TARGET_TYPE_FILE ,
990
+ edition_defaults = { edition : EDITION_PROTO2, value : "NONE" },
991
+ edition_defaults = { edition : EDITION_PROTO3, value : "VERIFY" }
962
992
];
963
993
964
994
enum MessageEncoding {
@@ -970,7 +1000,7 @@ message FeatureSet {
970
1000
retention = RETENTION_RUNTIME ,
971
1001
targets = TARGET_TYPE_FIELD ,
972
1002
targets = TARGET_TYPE_FILE ,
973
- edition_defaults = { edition_enum : EDITION_2023 , value : "LENGTH_PREFIXED" }
1003
+ edition_defaults = { edition : EDITION_PROTO2 , value : "LENGTH_PREFIXED" }
974
1004
];
975
1005
976
1006
enum JsonFormat {
@@ -983,10 +1013,11 @@ message FeatureSet {
983
1013
targets = TARGET_TYPE_MESSAGE ,
984
1014
targets = TARGET_TYPE_ENUM ,
985
1015
targets = TARGET_TYPE_FILE ,
986
- edition_defaults = { edition_enum : EDITION_2023, value : "ALLOW" }
1016
+ edition_defaults = { edition : EDITION_PROTO2, value : "LEGACY_BEST_EFFORT" },
1017
+ edition_defaults = { edition : EDITION_PROTO3, value : "ALLOW" }
987
1018
];
988
1019
989
- reserved 4 , 999 ;
1020
+ reserved 999 ;
990
1021
991
1022
extensions 1000; // for Protobuf C++
992
1023
extensions 1001; // for Protobuf Java
@@ -1004,24 +1035,18 @@ message FeatureSetDefaults {
1004
1035
// the defaults at the closest matching edition ordered at or before it should
1005
1036
// be used. This field must be in strict ascending order by edition.
1006
1037
message FeatureSetEditionDefault {
1007
- // TODO(b/297898292) Deprecate and remove this field in favor of enums.
1008
- optional string edition = 1 ;
1009
- optional Edition edition_enum = 3 ;
1038
+ optional Edition edition = 3 ;
1010
1039
optional FeatureSet features = 2 ;
1011
1040
}
1012
1041
repeated FeatureSetEditionDefault defaults = 1 ;
1013
1042
1014
- // TODO(b/297898292) Deprecate and remove these fields in favor of enums.
1015
- optional string minimum_edition = 2 ;
1016
- optional string maximum_edition = 3 ;
1017
-
1018
1043
// The minimum supported edition (inclusive) when this was constructed.
1019
1044
// Editions before this will not have defaults.
1020
- optional Edition minimum_edition_enum = 4 ;
1045
+ optional Edition minimum_edition = 4 ;
1021
1046
1022
1047
// The maximum known edition (inclusive) when this was constructed. Editions
1023
1048
// after this will not have reliable defaults.
1024
- optional Edition maximum_edition_enum = 5 ;
1049
+ optional Edition maximum_edition = 5 ;
1025
1050
}
1026
1051
1027
1052
// ===================================================================
0 commit comments