3636// A valid .proto file can be translated directly to a FileDescriptorProto
3737// without any other information (e.g. without reading its imports).
3838
39-
4039syntax = "proto2" ;
4140
4241package google.protobuf ;
@@ -86,8 +85,13 @@ message FileDescriptorProto {
8685 optional SourceCodeInfo source_code_info = 9 ;
8786
8887 // The syntax of the proto file.
89- // The supported values are "proto2" and "proto3".
88+ // The supported values are "proto2", "proto3", and "editions".
89+ //
90+ // If `edition` is present, this value must be "editions".
9091 optional string syntax = 12 ;
92+
93+ // The edition of the proto file, which is an opaque string.
94+ optional string edition = 13 ;
9195}
9296
9397// Describes a message type.
@@ -129,7 +133,6 @@ message ExtensionRangeOptions {
129133 // The parser stores options it doesn't recognize here. See above.
130134 repeated UninterpretedOption uninterpreted_option = 999 ;
131135
132-
133136 // Clients can define custom options in extensions of this message. See above.
134137 extensions 1000 to max;
135138}
@@ -305,7 +308,6 @@ message MethodDescriptorProto {
305308 optional bool server_streaming = 6 [default = false ];
306309}
307310
308-
309311// ===================================================================
310312// Options
311313
@@ -346,7 +348,6 @@ message FileOptions {
346348 // domain names.
347349 optional string java_package = 1 ;
348350
349-
350351 // Controls the name of the wrapper Java class generated for the .proto file.
351352 // That class will always contain the .proto file's getDescriptor() method as
352353 // well as any top-level extensions defined in the .proto file.
@@ -373,7 +374,6 @@ message FileOptions {
373374 // This option has no effect on when used with the lite runtime.
374375 optional bool java_string_check_utf8 = 27 [default = false ];
375376
376-
377377 // Generated classes can be optimized for speed or code size.
378378 enum OptimizeMode {
379379 SPEED = 1 ; // Generate complete code for parsing, serialization,
@@ -390,9 +390,6 @@ message FileOptions {
390390 // - Otherwise, the basename of the .proto file, without extension.
391391 optional string go_package = 11 ;
392392
393-
394-
395-
396393 // Should generic services be generated in each language? "Generic" services
397394 // are not specific to any particular RPC system. They are generated by the
398395 // main code generators in each language (without additional plugins).
@@ -418,7 +415,6 @@ message FileOptions {
418415 // only to generated classes for C++.
419416 optional bool cc_enable_arenas = 31 [default = true ];
420417
421-
422418 // Sets the objective c class prefix which is prepended to all objective c
423419 // generated classes from this .proto. There is no default.
424420 optional string objc_class_prefix = 36 ;
@@ -451,7 +447,6 @@ message FileOptions {
451447 // determining the ruby package.
452448 optional string ruby_package = 45 ;
453449
454-
455450 // The parser stores options it doesn't recognize here.
456451 // See the documentation for the "Options" section above.
457452 repeated UninterpretedOption uninterpreted_option = 999 ;
@@ -497,6 +492,10 @@ message MessageOptions {
497492
498493 reserved 4 , 5 , 6 ;
499494
495+ // NOTE: Do not set the option in .proto files. Always use the maps syntax
496+ // instead. The option should only be implicitly set by the proto compiler
497+ // parser.
498+ //
500499 // Whether the message is an automatically generated map entry type for the
501500 // maps field.
502501 //
@@ -514,15 +513,22 @@ message MessageOptions {
514513 // use a native map in the target language to hold the keys and values.
515514 // The reflection APIs in such implementations still need to work as
516515 // if the field is a repeated message field.
517- //
518- // NOTE: Do not set the option in .proto files. Always use the maps syntax
519- // instead. The option should only be implicitly set by the proto compiler
520- // parser.
521516 optional bool map_entry = 7 ;
522517
523518 reserved 8 ; // javalite_serializable
524519 reserved 9 ; // javanano_as_lite
525520
521+ // Enable the legacy handling of JSON field name conflicts. This lowercases
522+ // and strips underscored from the fields before comparison in proto3 only.
523+ // The new behavior takes `json_name` into account and applies to proto2 as
524+ // well.
525+ //
526+ // This should only be used as a temporary measure against broken builds due
527+ // to the change in behavior for JSON field name conflicts.
528+ //
529+ // TODO(b/261750190) This is legacy behavior we plan to remove once downstream
530+ // teams have had time to migrate.
531+ optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true ];
526532
527533 // The parser stores options it doesn't recognize here. See above.
528534 repeated UninterpretedOption uninterpreted_option = 999 ;
@@ -592,7 +598,6 @@ message FieldOptions {
592598 // call from multiple threads concurrently, while non-const methods continue
593599 // to require exclusive access.
594600 //
595- //
596601 // Note that implementations may choose not to check required fields within
597602 // a lazy sub-message. That is, calling IsInitialized() on the outer message
598603 // may return true even if the inner message has missing required fields.
@@ -604,11 +609,8 @@ message FieldOptions {
604609 // check its required fields, regardless of whether or not the message has
605610 // been parsed.
606611 //
607- // As of 2021, lazy does no correctness checks on the byte stream during
608- // parsing. This may lead to crashes if and when an invalid byte stream is
609- // finally parsed upon access.
610- //
611- // TODO(b/211906113): Enable validation on lazy fields.
612+ // As of May 2022, lazy verifies the contents of the byte stream during
613+ // parsing. An invalid byte stream will cause the overall parsing to fail.
612614 optional bool lazy = 5 [default = false ];
613615
614616 // unverified_lazy does no correctness checks on the byte stream. This should
@@ -625,6 +627,39 @@ message FieldOptions {
625627 // For Google-internal migration only. Do not use.
626628 optional bool weak = 10 [default = false ];
627629
630+ // Indicate that the field value should not be printed out when using debug
631+ // formats, e.g. when the field contains sensitive credentials.
632+ optional bool debug_redact = 16 [default = false ];
633+
634+ // If set to RETENTION_SOURCE, the option will be omitted from the binary.
635+ // Note: as of January 2023, support for this is in progress and does not yet
636+ // have an effect (b/264593489).
637+ enum OptionRetention {
638+ RETENTION_UNKNOWN = 0 ;
639+ RETENTION_RUNTIME = 1 ;
640+ RETENTION_SOURCE = 2 ;
641+ }
642+
643+ optional OptionRetention retention = 17 ;
644+
645+ // This indicates the types of entities that the field may apply to when used
646+ // as an option. If it is unset, then the field may be freely used as an
647+ // option on any kind of entity. Note: as of January 2023, support for this is
648+ // in progress and does not yet have an effect (b/264593489).
649+ enum OptionTargetType {
650+ TARGET_TYPE_UNKNOWN = 0 ;
651+ TARGET_TYPE_FILE = 1 ;
652+ TARGET_TYPE_EXTENSION_RANGE = 2 ;
653+ TARGET_TYPE_MESSAGE = 3 ;
654+ TARGET_TYPE_FIELD = 4 ;
655+ TARGET_TYPE_ONEOF = 5 ;
656+ TARGET_TYPE_ENUM = 6 ;
657+ TARGET_TYPE_ENUM_ENTRY = 7 ;
658+ TARGET_TYPE_SERVICE = 8 ;
659+ TARGET_TYPE_METHOD = 9 ;
660+ }
661+
662+ optional OptionTargetType target = 18 ;
628663
629664 // The parser stores options it doesn't recognize here. See above.
630665 repeated UninterpretedOption uninterpreted_option = 999 ;
@@ -657,6 +692,14 @@ message EnumOptions {
657692
658693 reserved 5 ; // javanano_as_lite
659694
695+ // Enable the legacy handling of JSON field name conflicts. This lowercases
696+ // and strips underscored from the fields before comparison in proto3 only.
697+ // The new behavior takes `json_name` into account and applies to proto2 as
698+ // well.
699+ // TODO(b/261750190) Remove this legacy behavior once downstream teams have
700+ // had time to migrate.
701+ optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true ];
702+
660703 // The parser stores options it doesn't recognize here. See above.
661704 repeated UninterpretedOption uninterpreted_option = 999 ;
662705
@@ -729,7 +772,6 @@ message MethodOptions {
729772 extensions 1000 to max;
730773}
731774
732-
733775// A message representing a option the parser does not recognize. This only
734776// appears in options protos created by the compiler::Parser class.
735777// DescriptorPool resolves these when building Descriptor objects. Therefore,
@@ -914,8 +956,20 @@ message GeneratedCodeInfo {
914956 optional int32 begin = 3 ;
915957
916958 // Identifies the ending offset in bytes in the generated code that
917- // relates to the identified offset . The end offset should be one past
959+ // relates to the identified object . The end offset should be one past
918960 // the last relevant byte (so the length of the text = end - begin).
919961 optional int32 end = 4 ;
962+
963+ // Represents the identified object's effect on the element in the original
964+ // .proto file.
965+ enum Semantic {
966+ // There is no effect or the effect is indescribable.
967+ NONE = 0 ;
968+ // The element is set or otherwise mutated.
969+ SET = 1 ;
970+ // An alias to the element is returned.
971+ ALIAS = 2 ;
972+ }
973+ optional Semantic semantic = 5 ;
920974 }
921975}
0 commit comments