github.com/jhump/protoreflect@v1.16.0/desc/protoprint/testfiles/descriptor-trailing-on-next-line.proto (about) 1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2008 Google Inc. All rights reserved. 3 // https://developers.google.com/protocol-buffers/ 4 // 5 // Redistribution and use in source and binary forms, with or without 6 // modification, are permitted provided that the following conditions are 7 // met: 8 // 9 // * Redistributions of source code must retain the above copyright 10 // notice, this list of conditions and the following disclaimer. 11 // * Redistributions in binary form must reproduce the above 12 // copyright notice, this list of conditions and the following disclaimer 13 // in the documentation and/or other materials provided with the 14 // distribution. 15 // * Neither the name of Google Inc. nor the names of its 16 // contributors may be used to endorse or promote products derived from 17 // this software without specific prior written permission. 18 // 19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31 // Author: kenton@google.com (Kenton Varda) 32 // Based on original Protocol Buffers design by 33 // Sanjay Ghemawat, Jeff Dean, and others. 34 // 35 // The messages in this file describe the definitions found in .proto files. 36 // A valid .proto file can be translated directly to a FileDescriptorProto 37 // without any other information (e.g. without reading its imports). 38 39 syntax = "proto2"; 40 41 package google.protobuf; 42 43 option go_package = "google.golang.org/protobuf/types/descriptorpb"; 44 45 option java_package = "com.google.protobuf"; 46 47 option java_outer_classname = "DescriptorProtos"; 48 49 option csharp_namespace = "Google.Protobuf.Reflection"; 50 51 option objc_class_prefix = "GPB"; 52 53 option cc_enable_arenas = true; 54 55 // descriptor.proto must be optimized for speed because reflection-based 56 // algorithms don't work during bootstrapping. 57 option optimize_for = SPEED; 58 59 // The protocol compiler can output a FileDescriptorSet containing the .proto 60 // files it parses. 61 message FileDescriptorSet { 62 repeated FileDescriptorProto file = 1; 63 } 64 65 // The full set of known editions. 66 enum Edition { 67 // A placeholder for an unknown edition value. 68 EDITION_UNKNOWN = 0; 69 70 // Legacy syntax "editions". These pre-date editions, but behave much like 71 // distinct editions. These can't be used to specify the edition of proto 72 // files, but feature definitions must supply proto2/proto3 defaults for 73 // backwards compatibility. 74 EDITION_PROTO2 = 998; 75 76 EDITION_PROTO3 = 999; 77 78 // Editions that have been released. The specific values are arbitrary and 79 // should not be depended on, but they will always be time-ordered for easy 80 // comparison. 81 EDITION_2023 = 1000; 82 83 EDITION_2024 = 1001; 84 85 // Placeholder editions for testing feature resolution. These should not be 86 // used or relyed on outside of tests. 87 EDITION_1_TEST_ONLY = 1; 88 89 EDITION_2_TEST_ONLY = 2; 90 91 EDITION_99997_TEST_ONLY = 99997; 92 93 EDITION_99998_TEST_ONLY = 99998; 94 95 EDITION_99999_TEST_ONLY = 99999; 96 97 // Placeholder for specifying unbounded edition support. This should only 98 // ever be used by plugins that can expect to never require any changes to 99 // support a new edition. 100 EDITION_MAX = 2147483647; 101 } 102 103 // Describes a complete .proto file. 104 message FileDescriptorProto { 105 optional string name = 1; 106 // file name, relative to root of source tree 107 108 optional string package = 2; 109 // e.g. "foo", "foo.bar", etc. 110 111 // Names of files imported by this file. 112 repeated string dependency = 3; 113 114 // Indexes of the public imported files in the dependency list above. 115 repeated int32 public_dependency = 10; 116 117 // Indexes of the weak imported files in the dependency list. 118 // For Google-internal migration only. Do not use. 119 repeated int32 weak_dependency = 11; 120 121 // All top-level definitions in this file. 122 repeated DescriptorProto message_type = 4; 123 124 repeated EnumDescriptorProto enum_type = 5; 125 126 repeated ServiceDescriptorProto service = 6; 127 128 repeated FieldDescriptorProto extension = 7; 129 130 optional FileOptions options = 8; 131 132 // This field contains optional information about the original source code. 133 // You may safely remove this entire field without harming runtime 134 // functionality of the descriptors -- the information is needed only by 135 // development tools. 136 optional SourceCodeInfo source_code_info = 9; 137 138 // The syntax of the proto file. 139 // The supported values are "proto2", "proto3", and "editions". 140 // 141 // If `edition` is present, this value must be "editions". 142 optional string syntax = 12; 143 144 // The edition of the proto file. 145 optional Edition edition = 14; 146 } 147 148 // Describes a message type. 149 message DescriptorProto { 150 optional string name = 1; 151 152 repeated FieldDescriptorProto field = 2; 153 154 repeated FieldDescriptorProto extension = 6; 155 156 repeated DescriptorProto nested_type = 3; 157 158 repeated EnumDescriptorProto enum_type = 4; 159 160 message ExtensionRange { 161 optional int32 start = 1; 162 // Inclusive. 163 164 optional int32 end = 2; 165 // Exclusive. 166 167 optional ExtensionRangeOptions options = 3; 168 } 169 170 repeated ExtensionRange extension_range = 5; 171 172 repeated OneofDescriptorProto oneof_decl = 8; 173 174 optional MessageOptions options = 7; 175 176 // Range of reserved tag numbers. Reserved tag numbers may not be used by 177 // fields or extension ranges in the same message. Reserved ranges may 178 // not overlap. 179 message ReservedRange { 180 optional int32 start = 1; 181 // Inclusive. 182 183 optional int32 end = 2; 184 // Exclusive. 185 } 186 187 repeated ReservedRange reserved_range = 9; 188 189 // Reserved field names, which may not be used by fields in the same message. 190 // A given name may only be reserved once. 191 repeated string reserved_name = 10; 192 } 193 194 message ExtensionRangeOptions { 195 // The parser stores options it doesn't recognize here. See above. 196 repeated UninterpretedOption uninterpreted_option = 999; 197 198 message Declaration { 199 // The extension number declared within the extension range. 200 optional int32 number = 1; 201 202 // The fully-qualified name of the extension field. There must be a leading 203 // dot in front of the full name. 204 optional string full_name = 2; 205 206 // The fully-qualified type name of the extension field. Unlike 207 // Metadata.type, Declaration.type must have a leading dot for messages 208 // and enums. 209 optional string type = 3; 210 211 // If true, indicates that the number is reserved in the extension range, 212 // and any extension field with the number will fail to compile. Set this 213 // when a declared extension field is deleted. 214 optional bool reserved = 5; 215 216 // If true, indicates that the extension must be defined as repeated. 217 // Otherwise the extension must be defined as optional. 218 optional bool repeated = 6; 219 220 reserved 4; 221 } 222 223 // For external users: DO NOT USE. We are in the process of open sourcing 224 // extension declaration and executing internal cleanups before it can be 225 // used externally. 226 repeated Declaration declaration = 2 [retention = RETENTION_SOURCE]; 227 228 // Any features defined in the specific edition. 229 optional FeatureSet features = 50; 230 231 // The verification state of the extension range. 232 enum VerificationState { 233 // All the extensions of the range must be declared. 234 DECLARATION = 0; 235 236 UNVERIFIED = 1; 237 } 238 239 // The verification state of the range. 240 // TODO: flip the default to DECLARATION once all empty ranges 241 // are marked as UNVERIFIED. 242 optional VerificationState verification = 3 [default = UNVERIFIED, retention = RETENTION_SOURCE]; 243 244 extensions 1000 to max; 245 } 246 247 // Describes a field within a message. 248 message FieldDescriptorProto { 249 enum Type { 250 // 0 is reserved for errors. 251 // Order is weird for historical reasons. 252 TYPE_DOUBLE = 1; 253 254 TYPE_FLOAT = 2; 255 256 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if 257 // negative values are likely. 258 TYPE_INT64 = 3; 259 260 TYPE_UINT64 = 4; 261 262 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if 263 // negative values are likely. 264 TYPE_INT32 = 5; 265 266 TYPE_FIXED64 = 6; 267 268 TYPE_FIXED32 = 7; 269 270 TYPE_BOOL = 8; 271 272 TYPE_STRING = 9; 273 274 // Tag-delimited aggregate. 275 // Group type is deprecated and not supported after google.protobuf. However, Proto3 276 // implementations should still be able to parse the group wire format and 277 // treat group fields as unknown fields. In Editions, the group wire format 278 // can be enabled via the `message_encoding` feature. 279 TYPE_GROUP = 10; 280 281 TYPE_MESSAGE = 11; 282 // Length-delimited aggregate. 283 284 // New in version 2. 285 TYPE_BYTES = 12; 286 287 TYPE_UINT32 = 13; 288 289 TYPE_ENUM = 14; 290 291 TYPE_SFIXED32 = 15; 292 293 TYPE_SFIXED64 = 16; 294 295 TYPE_SINT32 = 17; 296 // Uses ZigZag encoding. 297 298 TYPE_SINT64 = 18; 299 // Uses ZigZag encoding. 300 } 301 302 enum Label { 303 // 0 is reserved for errors 304 LABEL_OPTIONAL = 1; 305 306 LABEL_REPEATED = 3; 307 308 // The required label is only allowed in google.protobuf. In proto3 and Editions 309 // it's explicitly prohibited. In Editions, the `field_presence` feature 310 // can be used to get this behavior. 311 LABEL_REQUIRED = 2; 312 } 313 314 optional string name = 1; 315 316 optional int32 number = 3; 317 318 optional Label label = 4; 319 320 // If type_name is set, this need not be set. If both this and type_name 321 // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. 322 optional Type type = 5; 323 324 // For message and enum types, this is the name of the type. If the name 325 // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping 326 // rules are used to find the type (i.e. first the nested types within this 327 // message are searched, then within the parent, on up to the root 328 // namespace). 329 optional string type_name = 6; 330 331 // For extensions, this is the name of the type being extended. It is 332 // resolved in the same manner as type_name. 333 optional string extendee = 2; 334 335 // For numeric types, contains the original text representation of the value. 336 // For booleans, "true" or "false". 337 // For strings, contains the default text contents (not escaped in any way). 338 // For bytes, contains the C escaped value. All bytes >= 128 are escaped. 339 optional string default_value = 7; 340 341 // If set, gives the index of a oneof in the containing type's oneof_decl 342 // list. This field is a member of that oneof. 343 optional int32 oneof_index = 9; 344 345 // JSON name of this field. The value is set by protocol compiler. If the 346 // user has set a "json_name" option on this field, that option's value 347 // will be used. Otherwise, it's deduced from the field's name by converting 348 // it to camelCase. 349 optional string json_name = 10; 350 351 optional FieldOptions options = 8; 352 353 // If true, this is a proto3 "optional". When a proto3 field is optional, it 354 // tracks presence regardless of field type. 355 // 356 // When proto3_optional is true, this field must belong to a oneof to signal 357 // to old proto3 clients that presence is tracked for this field. This oneof 358 // is known as a "synthetic" oneof, and this field must be its sole member 359 // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs 360 // exist in the descriptor only, and do not generate any API. Synthetic oneofs 361 // must be ordered after all "real" oneofs. 362 // 363 // For message fields, proto3_optional doesn't create any semantic change, 364 // since non-repeated message fields always track presence. However it still 365 // indicates the semantic detail of whether the user wrote "optional" or not. 366 // This can be useful for round-tripping the .proto file. For consistency we 367 // give message fields a synthetic oneof also, even though it is not required 368 // to track presence. This is especially important because the parser can't 369 // tell if a field is a message or an enum, so it must always create a 370 // synthetic oneof. 371 // 372 // Proto2 optional fields do not set this flag, because they already indicate 373 // optional with `LABEL_OPTIONAL`. 374 optional bool proto3_optional = 17; 375 } 376 377 // Describes a oneof. 378 message OneofDescriptorProto { 379 optional string name = 1; 380 381 optional OneofOptions options = 2; 382 } 383 384 // Describes an enum type. 385 message EnumDescriptorProto { 386 optional string name = 1; 387 388 repeated EnumValueDescriptorProto value = 2; 389 390 optional EnumOptions options = 3; 391 392 // Range of reserved numeric values. Reserved values may not be used by 393 // entries in the same enum. Reserved ranges may not overlap. 394 // 395 // Note that this is distinct from DescriptorProto.ReservedRange in that it 396 // is inclusive such that it can appropriately represent the entire int32 397 // domain. 398 message EnumReservedRange { 399 optional int32 start = 1; 400 // Inclusive. 401 402 optional int32 end = 2; 403 // Inclusive. 404 } 405 406 // Range of reserved numeric values. Reserved numeric values may not be used 407 // by enum values in the same enum declaration. Reserved ranges may not 408 // overlap. 409 repeated EnumReservedRange reserved_range = 4; 410 411 // Reserved enum value names, which may not be reused. A given name may only 412 // be reserved once. 413 repeated string reserved_name = 5; 414 } 415 416 // Describes a value within an enum. 417 message EnumValueDescriptorProto { 418 optional string name = 1; 419 420 optional int32 number = 2; 421 422 optional EnumValueOptions options = 3; 423 } 424 425 // Describes a service. 426 message ServiceDescriptorProto { 427 optional string name = 1; 428 429 repeated MethodDescriptorProto method = 2; 430 431 optional ServiceOptions options = 3; 432 } 433 434 // Describes a method of a service. 435 message MethodDescriptorProto { 436 optional string name = 1; 437 438 // Input and output type names. These are resolved in the same way as 439 // FieldDescriptorProto.type_name, but must refer to a message type. 440 optional string input_type = 2; 441 442 optional string output_type = 3; 443 444 optional MethodOptions options = 4; 445 446 // Identifies if client streams multiple client messages 447 optional bool client_streaming = 5 [default = false]; 448 449 // Identifies if server streams multiple server messages 450 optional bool server_streaming = 6 [default = false]; 451 } 452 453 // =================================================================== 454 // Options 455 456 // Each of the definitions above may have "options" attached. These are 457 // just annotations which may cause code to be generated slightly differently 458 // or may contain hints for code that manipulates protocol messages. 459 // 460 // Clients may define custom options as extensions of the *Options messages. 461 // These extensions may not yet be known at parsing time, so the parser cannot 462 // store the values in them. Instead it stores them in a field in the *Options 463 // message called uninterpreted_option. This field must have the same name 464 // across all *Options messages. We then use this field to populate the 465 // extensions when we build a descriptor, at which point all protos have been 466 // parsed and so all extensions are known. 467 // 468 // Extension numbers for custom options may be chosen as follows: 469 // * For options which will only be used within a single application or 470 // organization, or for experimental options, use field numbers 50000 471 // through 99999. It is up to you to ensure that you do not use the 472 // same number for multiple options. 473 // * For options which will be published and used publicly by multiple 474 // independent entities, e-mail protobuf-global-extension-registry@google.com 475 // to reserve extension numbers. Simply provide your project name (e.g. 476 // Objective-C plugin) and your project website (if available) -- there's no 477 // need to explain how you intend to use them. Usually you only need one 478 // extension number. You can declare multiple options with only one extension 479 // number by putting them in a sub-message. See the Custom Options section of 480 // the docs for examples: 481 // https://developers.google.com/protocol-buffers/docs/proto#options 482 // If this turns out to be popular, a web service will be set up 483 // to automatically assign option numbers. 484 485 message FileOptions { 486 // Sets the Java package where classes generated from this .proto will be 487 // placed. By default, the proto package is used, but this is often 488 // inappropriate because proto packages do not normally start with backwards 489 // domain names. 490 optional string java_package = 1; 491 492 // Controls the name of the wrapper Java class generated for the .proto file. 493 // That class will always contain the .proto file's getDescriptor() method as 494 // well as any top-level extensions defined in the .proto file. 495 // If java_multiple_files is disabled, then all the other classes from the 496 // .proto file will be nested inside the single wrapper outer class. 497 optional string java_outer_classname = 8; 498 499 // If enabled, then the Java code generator will generate a separate .java 500 // file for each top-level message, enum, and service defined in the .proto 501 // file. Thus, these types will *not* be nested inside the wrapper class 502 // named by java_outer_classname. However, the wrapper class will still be 503 // generated to contain the file's getDescriptor() method as well as any 504 // top-level extensions defined in the file. 505 optional bool java_multiple_files = 10 [default = false]; 506 507 // This option does nothing. 508 optional bool java_generate_equals_and_hash = 20 [deprecated = true]; 509 510 // If set true, then the Java2 code generator will generate code that 511 // throws an exception whenever an attempt is made to assign a non-UTF-8 512 // byte sequence to a string field. 513 // Message reflection will do the same. 514 // However, an extension field still accepts non-UTF-8 byte sequences. 515 // This option has no effect on when used with the lite runtime. 516 optional bool java_string_check_utf8 = 27 [default = false]; 517 518 // Generated classes can be optimized for speed or code size. 519 enum OptimizeMode { 520 SPEED = 1; 521 // Generate complete code for parsing, serialization, 522 523 // etc. 524 CODE_SIZE = 2; 525 // Use ReflectionOps to implement these methods. 526 527 LITE_RUNTIME = 3; 528 // Generate code using MessageLite and the lite runtime. 529 } 530 531 optional OptimizeMode optimize_for = 9 [default = SPEED]; 532 533 // Sets the Go package where structs generated from this .proto will be 534 // placed. If omitted, the Go package will be derived from the following: 535 // - The basename of the package import path, if provided. 536 // - Otherwise, the package statement in the .proto file, if present. 537 // - Otherwise, the basename of the .proto file, without extension. 538 optional string go_package = 11; 539 540 // Should generic services be generated in each language? "Generic" services 541 // are not specific to any particular RPC system. They are generated by the 542 // main code generators in each language (without additional plugins). 543 // Generic services were the only kind of service generation supported by 544 // early versions of google.protobuf. 545 // 546 // Generic services are now considered deprecated in favor of using plugins 547 // that generate code specific to your particular RPC system. Therefore, 548 // these default to false. Old code which depends on generic services should 549 // explicitly set them to true. 550 optional bool cc_generic_services = 16 [default = false]; 551 552 optional bool java_generic_services = 17 [default = false]; 553 554 optional bool py_generic_services = 18 [default = false]; 555 556 reserved 42; 557 558 // Is this file deprecated? 559 // Depending on the target platform, this can emit Deprecated annotations 560 // for everything in the file, or it will be completely ignored; in the very 561 // least, this is a formalization for deprecating files. 562 optional bool deprecated = 23 [default = false]; 563 564 // Enables the use of arenas for the proto messages in this file. This applies 565 // only to generated classes for C++. 566 optional bool cc_enable_arenas = 31 [default = true]; 567 568 // Sets the objective c class prefix which is prepended to all objective c 569 // generated classes from this .proto. There is no default. 570 optional string objc_class_prefix = 36; 571 572 // Namespace for generated classes; defaults to the package. 573 optional string csharp_namespace = 37; 574 575 // By default Swift generators will take the proto package and CamelCase it 576 // replacing '.' with underscore and use that to prefix the types/symbols 577 // defined. When this options is provided, they will use this value instead 578 // to prefix the types/symbols defined. 579 optional string swift_prefix = 39; 580 581 // Sets the php class prefix which is prepended to all php generated classes 582 // from this .proto. Default is empty. 583 optional string php_class_prefix = 40; 584 585 // Use this option to change the namespace of php generated classes. Default 586 // is empty. When this option is empty, the package name will be used for 587 // determining the namespace. 588 optional string php_namespace = 41; 589 590 // Use this option to change the namespace of php generated metadata classes. 591 // Default is empty. When this option is empty, the proto file name will be 592 // used for determining the namespace. 593 optional string php_metadata_namespace = 44; 594 595 // Use this option to change the package of ruby generated classes. Default 596 // is empty. When this option is not set, the package name will be used for 597 // determining the ruby package. 598 optional string ruby_package = 45; 599 600 // Any features defined in the specific edition. 601 optional FeatureSet features = 50; 602 603 // The parser stores options it doesn't recognize here. 604 // See the documentation for the "Options" section above. 605 repeated UninterpretedOption uninterpreted_option = 999; 606 607 extensions 1000 to max; 608 609 reserved 38; 610 } 611 612 message MessageOptions { 613 // Set true to use the old proto1 MessageSet wire format for extensions. 614 // This is provided for backwards-compatibility with the MessageSet wire 615 // format. You should not use this for any other reason: It's less 616 // efficient, has fewer features, and is more complicated. 617 // 618 // The message must be defined exactly as follows: 619 // message Foo { 620 // option message_set_wire_format = true; 621 // extensions 4 to max; 622 // } 623 // Note that the message cannot have any defined fields; MessageSets only 624 // have extensions. 625 // 626 // All extensions of your type must be singular messages; e.g. they cannot 627 // be int32s, enums, or repeated messages. 628 // 629 // Because this is an option, the above two restrictions are not enforced by 630 // the protocol compiler. 631 optional bool message_set_wire_format = 1 [default = false]; 632 633 // Disables the generation of the standard "descriptor()" accessor, which can 634 // conflict with a field of the same name. This is meant to make migration 635 // from proto1 easier; new code should avoid fields named "descriptor". 636 optional bool no_standard_descriptor_accessor = 2 [default = false]; 637 638 // Is this message deprecated? 639 // Depending on the target platform, this can emit Deprecated annotations 640 // for the message, or it will be completely ignored; in the very least, 641 // this is a formalization for deprecating messages. 642 optional bool deprecated = 3 [default = false]; 643 644 reserved 4, 5, 6; 645 646 // Whether the message is an automatically generated map entry type for the 647 // maps field. 648 // 649 // For maps fields: 650 // map<KeyType, ValueType> map_field = 1; 651 // The parsed descriptor looks like: 652 // message MapFieldEntry { 653 // option map_entry = true; 654 // optional KeyType key = 1; 655 // optional ValueType value = 2; 656 // } 657 // repeated MapFieldEntry map_field = 1; 658 // 659 // Implementations may choose not to generate the map_entry=true message, but 660 // use a native map in the target language to hold the keys and values. 661 // The reflection APIs in such implementations still need to work as 662 // if the field is a repeated message field. 663 // 664 // NOTE: Do not set the option in .proto files. Always use the maps syntax 665 // instead. The option should only be implicitly set by the proto compiler 666 // parser. 667 optional bool map_entry = 7; 668 669 reserved 8, 9; 670 671 // Enable the legacy handling of JSON field name conflicts. This lowercases 672 // and strips underscored from the fields before comparison in proto3 only. 673 // The new behavior takes `json_name` into account and applies to proto2 as 674 // well. 675 // 676 // This should only be used as a temporary measure against broken builds due 677 // to the change in behavior for JSON field name conflicts. 678 // 679 // TODO This is legacy behavior we plan to remove once downstream 680 // teams have had time to migrate. 681 optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true]; 682 683 // Any features defined in the specific edition. 684 optional FeatureSet features = 12; 685 686 // The parser stores options it doesn't recognize here. See above. 687 repeated UninterpretedOption uninterpreted_option = 999; 688 689 extensions 1000 to max; 690 } 691 692 message FieldOptions { 693 // The ctype option instructs the C++ code generator to use a different 694 // representation of the field than it normally would. See the specific 695 // options below. This option is only implemented to support use of 696 // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of 697 // type "bytes" in the open source release -- sorry, we'll try to include 698 // other types in a future version! 699 optional CType ctype = 1 [default = STRING]; 700 701 enum CType { 702 // Default mode. 703 STRING = 0; 704 705 // The option [ctype=CORD] may be applied to a non-repeated field of type 706 // "bytes". It indicates that in C++, the data should be stored in a Cord 707 // instead of a string. For very large strings, this may reduce memory 708 // fragmentation. It may also allow better performance when parsing from a 709 // Cord, or when parsing with aliasing enabled, as the parsed Cord may then 710 // alias the original buffer. 711 CORD = 1; 712 713 STRING_PIECE = 2; 714 } 715 716 // The packed option can be enabled for repeated primitive fields to enable 717 // a more efficient representation on the wire. Rather than repeatedly 718 // writing the tag and type for each element, the entire array is encoded as 719 // a single length-delimited blob. In proto3, only explicit setting it to 720 // false will avoid using packed encoding. This option is prohibited in 721 // Editions, but the `repeated_field_encoding` feature can be used to control 722 // the behavior. 723 optional bool packed = 2; 724 725 // The jstype option determines the JavaScript type used for values of the 726 // field. The option is permitted only for 64 bit integral and fixed types 727 // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING 728 // is represented as JavaScript string, which avoids loss of precision that 729 // can happen when a large value is converted to a floating point JavaScript. 730 // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to 731 // use the JavaScript "number" type. The behavior of the default option 732 // JS_NORMAL is implementation dependent. 733 // 734 // This option is an enum to permit additional types to be added, e.g. 735 // goog.math.Integer. 736 optional JSType jstype = 6 [default = JS_NORMAL]; 737 738 enum JSType { 739 // Use the default type. 740 JS_NORMAL = 0; 741 742 // Use JavaScript strings. 743 JS_STRING = 1; 744 745 // Use JavaScript numbers. 746 JS_NUMBER = 2; 747 } 748 749 // Should this field be parsed lazily? Lazy applies only to message-type 750 // fields. It means that when the outer message is initially parsed, the 751 // inner message's contents will not be parsed but instead stored in encoded 752 // form. The inner message will actually be parsed when it is first accessed. 753 // 754 // This is only a hint. Implementations are free to choose whether to use 755 // eager or lazy parsing regardless of the value of this option. However, 756 // setting this option true suggests that the protocol author believes that 757 // using lazy parsing on this field is worth the additional bookkeeping 758 // overhead typically needed to implement it. 759 // 760 // This option does not affect the public interface of any generated code; 761 // all method signatures remain the same. Furthermore, thread-safety of the 762 // interface is not affected by this option; const methods remain safe to 763 // call from multiple threads concurrently, while non-const methods continue 764 // to require exclusive access. 765 // 766 // Note that lazy message fields are still eagerly verified to check 767 // ill-formed wireformat or missing required fields. Calling IsInitialized() 768 // on the outer message would fail if the inner message has missing required 769 // fields. Failed verification would result in parsing failure (except when 770 // uninitialized messages are acceptable). 771 optional bool lazy = 5 [default = false]; 772 773 // unverified_lazy does no correctness checks on the byte stream. This should 774 // only be used where lazy with verification is prohibitive for performance 775 // reasons. 776 optional bool unverified_lazy = 15 [default = false]; 777 778 // Is this field deprecated? 779 // Depending on the target platform, this can emit Deprecated annotations 780 // for accessors, or it will be completely ignored; in the very least, this 781 // is a formalization for deprecating fields. 782 optional bool deprecated = 3 [default = false]; 783 784 // For Google-internal migration only. Do not use. 785 optional bool weak = 10 [default = false]; 786 787 // Indicate that the field value should not be printed out when using debug 788 // formats, e.g. when the field contains sensitive credentials. 789 optional bool debug_redact = 16 [default = false]; 790 791 // If set to RETENTION_SOURCE, the option will be omitted from the binary. 792 // Note: as of January 2023, support for this is in progress and does not yet 793 // have an effect (b/264593489). 794 enum OptionRetention { 795 RETENTION_UNKNOWN = 0; 796 797 RETENTION_RUNTIME = 1; 798 799 RETENTION_SOURCE = 2; 800 } 801 802 optional OptionRetention retention = 17; 803 804 // This indicates the types of entities that the field may apply to when used 805 // as an option. If it is unset, then the field may be freely used as an 806 // option on any kind of entity. Note: as of January 2023, support for this is 807 // in progress and does not yet have an effect (b/264593489). 808 enum OptionTargetType { 809 TARGET_TYPE_UNKNOWN = 0; 810 811 TARGET_TYPE_FILE = 1; 812 813 TARGET_TYPE_EXTENSION_RANGE = 2; 814 815 TARGET_TYPE_MESSAGE = 3; 816 817 TARGET_TYPE_FIELD = 4; 818 819 TARGET_TYPE_ONEOF = 5; 820 821 TARGET_TYPE_ENUM = 6; 822 823 TARGET_TYPE_ENUM_ENTRY = 7; 824 825 TARGET_TYPE_SERVICE = 8; 826 827 TARGET_TYPE_METHOD = 9; 828 } 829 830 repeated OptionTargetType targets = 19; 831 832 message EditionDefault { 833 optional Edition edition = 3; 834 835 optional string value = 2; 836 // Textproto value. 837 } 838 839 repeated EditionDefault edition_defaults = 20; 840 841 // Any features defined in the specific edition. 842 optional FeatureSet features = 21; 843 844 // The parser stores options it doesn't recognize here. See above. 845 repeated UninterpretedOption uninterpreted_option = 999; 846 847 extensions 1000 to max; 848 849 reserved 4, 18; 850 } 851 852 message OneofOptions { 853 // Any features defined in the specific edition. 854 optional FeatureSet features = 1; 855 856 // The parser stores options it doesn't recognize here. See above. 857 repeated UninterpretedOption uninterpreted_option = 999; 858 859 extensions 1000 to max; 860 } 861 862 message EnumOptions { 863 // Set this option to true to allow mapping different tag names to the same 864 // value. 865 optional bool allow_alias = 2; 866 867 // Is this enum deprecated? 868 // Depending on the target platform, this can emit Deprecated annotations 869 // for the enum, or it will be completely ignored; in the very least, this 870 // is a formalization for deprecating enums. 871 optional bool deprecated = 3 [default = false]; 872 873 reserved 5; 874 875 // Enable the legacy handling of JSON field name conflicts. This lowercases 876 // and strips underscored from the fields before comparison in proto3 only. 877 // The new behavior takes `json_name` into account and applies to proto2 as 878 // well. 879 // TODO Remove this legacy behavior once downstream teams have 880 // had time to migrate. 881 optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true]; 882 883 // Any features defined in the specific edition. 884 optional FeatureSet features = 7; 885 886 // The parser stores options it doesn't recognize here. See above. 887 repeated UninterpretedOption uninterpreted_option = 999; 888 889 extensions 1000 to max; 890 } 891 892 message EnumValueOptions { 893 // Is this enum value deprecated? 894 // Depending on the target platform, this can emit Deprecated annotations 895 // for the enum value, or it will be completely ignored; in the very least, 896 // this is a formalization for deprecating enum values. 897 optional bool deprecated = 1 [default = false]; 898 899 // Any features defined in the specific edition. 900 optional FeatureSet features = 2; 901 902 // Indicate that fields annotated with this enum value should not be printed 903 // out when using debug formats, e.g. when the field contains sensitive 904 // credentials. 905 optional bool debug_redact = 3 [default = false]; 906 907 // The parser stores options it doesn't recognize here. See above. 908 repeated UninterpretedOption uninterpreted_option = 999; 909 910 extensions 1000 to max; 911 } 912 913 message ServiceOptions { 914 // Any features defined in the specific edition. 915 optional FeatureSet features = 34; 916 917 // Note: Field numbers 1 through 32 are reserved for Google's internal RPC 918 // framework. We apologize for hoarding these numbers to ourselves, but 919 // we were already using them long before we decided to release Protocol 920 // Buffers. 921 922 // Is this service deprecated? 923 // Depending on the target platform, this can emit Deprecated annotations 924 // for the service, or it will be completely ignored; in the very least, 925 // this is a formalization for deprecating services. 926 optional bool deprecated = 33 [default = false]; 927 928 // The parser stores options it doesn't recognize here. See above. 929 repeated UninterpretedOption uninterpreted_option = 999; 930 931 extensions 1000 to max; 932 } 933 934 message MethodOptions { 935 // Note: Field numbers 1 through 32 are reserved for Google's internal RPC 936 // framework. We apologize for hoarding these numbers to ourselves, but 937 // we were already using them long before we decided to release Protocol 938 // Buffers. 939 940 // Is this method deprecated? 941 // Depending on the target platform, this can emit Deprecated annotations 942 // for the method, or it will be completely ignored; in the very least, 943 // this is a formalization for deprecating methods. 944 optional bool deprecated = 33 [default = false]; 945 946 // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, 947 // or neither? HTTP based RPC implementation may choose GET verb for safe 948 // methods, and PUT verb for idempotent methods instead of the default POST. 949 enum IdempotencyLevel { 950 IDEMPOTENCY_UNKNOWN = 0; 951 952 NO_SIDE_EFFECTS = 1; 953 // implies idempotent 954 955 IDEMPOTENT = 2; 956 // idempotent, but may have side effects 957 } 958 959 optional IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; 960 961 // Any features defined in the specific edition. 962 optional FeatureSet features = 35; 963 964 // The parser stores options it doesn't recognize here. See above. 965 repeated UninterpretedOption uninterpreted_option = 999; 966 967 extensions 1000 to max; 968 } 969 970 // A message representing a option the parser does not recognize. This only 971 // appears in options protos created by the compiler::Parser class. 972 // DescriptorPool resolves these when building Descriptor objects. Therefore, 973 // options protos in descriptor objects (e.g. returned by Descriptor::options(), 974 // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions 975 // in them. 976 message UninterpretedOption { 977 // The name of the uninterpreted option. Each string represents a segment in 978 // a dot-separated name. is_extension is true iff a segment represents an 979 // extension (denoted with parentheses in options specs in .proto files). 980 // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents 981 // "foo.(bar.baz).moo". 982 message NamePart { 983 required string name_part = 1; 984 985 required bool is_extension = 2; 986 } 987 988 repeated NamePart name = 2; 989 990 // The value of the uninterpreted option, in whatever type the tokenizer 991 // identified it as during parsing. Exactly one of these should be set. 992 optional string identifier_value = 3; 993 994 optional uint64 positive_int_value = 4; 995 996 optional int64 negative_int_value = 5; 997 998 optional double double_value = 6; 999 1000 optional bytes string_value = 7; 1001 1002 optional string aggregate_value = 8; 1003 } 1004 1005 // =================================================================== 1006 // Features 1007 1008 // TODO Enums in C++ gencode (and potentially other languages) are 1009 // not well scoped. This means that each of the feature enums below can clash 1010 // with each other. The short names we've chosen maximize call-site 1011 // readability, but leave us very open to this scenario. A future feature will 1012 // be designed and implemented to handle this, hopefully before we ever hit a 1013 // conflict here. 1014 message FeatureSet { 1015 enum FieldPresence { 1016 FIELD_PRESENCE_UNKNOWN = 0; 1017 1018 EXPLICIT = 1; 1019 1020 IMPLICIT = 2; 1021 1022 LEGACY_REQUIRED = 3; 1023 } 1024 1025 optional FieldPresence field_presence = 1 [ 1026 retention = RETENTION_RUNTIME, 1027 targets = TARGET_TYPE_FIELD, 1028 targets = TARGET_TYPE_FILE, 1029 edition_defaults = { value: "EXPLICIT", edition: EDITION_PROTO2 }, 1030 edition_defaults = { value: "IMPLICIT", edition: EDITION_PROTO3 }, 1031 edition_defaults = { value: "EXPLICIT", edition: EDITION_2023 } 1032 ]; 1033 1034 enum EnumType { 1035 ENUM_TYPE_UNKNOWN = 0; 1036 1037 OPEN = 1; 1038 1039 CLOSED = 2; 1040 } 1041 1042 optional EnumType enum_type = 2 [ 1043 retention = RETENTION_RUNTIME, 1044 targets = TARGET_TYPE_ENUM, 1045 targets = TARGET_TYPE_FILE, 1046 edition_defaults = { value: "CLOSED", edition: EDITION_PROTO2 }, 1047 edition_defaults = { value: "OPEN", edition: EDITION_PROTO3 } 1048 ]; 1049 1050 enum RepeatedFieldEncoding { 1051 REPEATED_FIELD_ENCODING_UNKNOWN = 0; 1052 1053 PACKED = 1; 1054 1055 EXPANDED = 2; 1056 } 1057 1058 optional RepeatedFieldEncoding repeated_field_encoding = 3 [ 1059 retention = RETENTION_RUNTIME, 1060 targets = TARGET_TYPE_FIELD, 1061 targets = TARGET_TYPE_FILE, 1062 edition_defaults = { value: "EXPANDED", edition: EDITION_PROTO2 }, 1063 edition_defaults = { value: "PACKED", edition: EDITION_PROTO3 } 1064 ]; 1065 1066 enum Utf8Validation { 1067 UTF8_VALIDATION_UNKNOWN = 0; 1068 1069 VERIFY = 2; 1070 1071 NONE = 3; 1072 } 1073 1074 optional Utf8Validation utf8_validation = 4 [ 1075 retention = RETENTION_RUNTIME, 1076 targets = TARGET_TYPE_FIELD, 1077 targets = TARGET_TYPE_FILE, 1078 edition_defaults = { value: "NONE", edition: EDITION_PROTO2 }, 1079 edition_defaults = { value: "VERIFY", edition: EDITION_PROTO3 } 1080 ]; 1081 1082 enum MessageEncoding { 1083 MESSAGE_ENCODING_UNKNOWN = 0; 1084 1085 LENGTH_PREFIXED = 1; 1086 1087 DELIMITED = 2; 1088 } 1089 1090 optional MessageEncoding message_encoding = 5 [ 1091 retention = RETENTION_RUNTIME, 1092 targets = TARGET_TYPE_FIELD, 1093 targets = TARGET_TYPE_FILE, 1094 edition_defaults = { value: "LENGTH_PREFIXED", edition: EDITION_PROTO2 } 1095 ]; 1096 1097 enum JsonFormat { 1098 JSON_FORMAT_UNKNOWN = 0; 1099 1100 ALLOW = 1; 1101 1102 LEGACY_BEST_EFFORT = 2; 1103 } 1104 1105 optional JsonFormat json_format = 6 [ 1106 retention = RETENTION_RUNTIME, 1107 targets = TARGET_TYPE_MESSAGE, 1108 targets = TARGET_TYPE_ENUM, 1109 targets = TARGET_TYPE_FILE, 1110 edition_defaults = { value: "LEGACY_BEST_EFFORT", edition: EDITION_PROTO2 }, 1111 edition_defaults = { value: "ALLOW", edition: EDITION_PROTO3 } 1112 ]; 1113 1114 reserved 999; 1115 1116 extensions 1000, 1001, 1002, 9995 to 9999, 10000; 1117 } 1118 1119 // A compiled specification for the defaults of a set of features. These 1120 // messages are generated from FeatureSet extensions and can be used to seed 1121 // feature resolution. The resolution with this object becomes a simple search 1122 // for the closest matching edition, followed by proto merges. 1123 message FeatureSetDefaults { 1124 // A map from every known edition with a unique set of defaults to its 1125 // defaults. Not all editions may be contained here. For a given edition, 1126 // the defaults at the closest matching edition ordered at or before it should 1127 // be used. This field must be in strict ascending order by edition. 1128 message FeatureSetEditionDefault { 1129 optional Edition edition = 3; 1130 1131 optional FeatureSet features = 2; 1132 } 1133 1134 repeated FeatureSetEditionDefault defaults = 1; 1135 1136 // The minimum supported edition (inclusive) when this was constructed. 1137 // Editions before this will not have defaults. 1138 optional Edition minimum_edition = 4; 1139 1140 // The maximum known edition (inclusive) when this was constructed. Editions 1141 // after this will not have reliable defaults. 1142 optional Edition maximum_edition = 5; 1143 } 1144 1145 // =================================================================== 1146 // Optional source code info 1147 1148 // Encapsulates information about the original source file from which a 1149 // FileDescriptorProto was generated. 1150 message SourceCodeInfo { 1151 // A Location identifies a piece of source code in a .proto file which 1152 // corresponds to a particular definition. This information is intended 1153 // to be useful to IDEs, code indexers, documentation generators, and similar 1154 // tools. 1155 // 1156 // For example, say we have a file like: 1157 // message Foo { 1158 // optional string foo = 1; 1159 // } 1160 // Let's look at just the field definition: 1161 // optional string foo = 1; 1162 // ^ ^^ ^^ ^ ^^^ 1163 // a bc de f ghi 1164 // We have the following locations: 1165 // span path represents 1166 // [a,i) [ 4, 0, 2, 0 ] The whole field definition. 1167 // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). 1168 // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). 1169 // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). 1170 // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). 1171 // 1172 // Notes: 1173 // - A location may refer to a repeated field itself (i.e. not to any 1174 // particular index within it). This is used whenever a set of elements are 1175 // logically enclosed in a single code segment. For example, an entire 1176 // extend block (possibly containing multiple extension definitions) will 1177 // have an outer location whose path refers to the "extensions" repeated 1178 // field without an index. 1179 // - Multiple locations may have the same path. This happens when a single 1180 // logical declaration is spread out across multiple places. The most 1181 // obvious example is the "extend" block again -- there may be multiple 1182 // extend blocks in the same scope, each of which will have the same path. 1183 // - A location's span is not always a subset of its parent's span. For 1184 // example, the "extendee" of an extension declaration appears at the 1185 // beginning of the "extend" block and is shared by all extensions within 1186 // the block. 1187 // - Just because a location's span is a subset of some other location's span 1188 // does not mean that it is a descendant. For example, a "group" defines 1189 // both a type and a field in a single declaration. Thus, the locations 1190 // corresponding to the type and field and their components will overlap. 1191 // - Code which tries to interpret locations should probably be designed to 1192 // ignore those that it doesn't understand, as more types of locations could 1193 // be recorded in the future. 1194 repeated Location location = 1; 1195 1196 message Location { 1197 // Identifies which part of the FileDescriptorProto was defined at this 1198 // location. 1199 // 1200 // Each element is a field number or an index. They form a path from 1201 // the root FileDescriptorProto to the place where the definition appears. 1202 // For example, this path: 1203 // [ 4, 3, 2, 7, 1 ] 1204 // refers to: 1205 // file.message_type(3) // 4, 3 1206 // .field(7) // 2, 7 1207 // .name() // 1 1208 // This is because FileDescriptorProto.message_type has field number 4: 1209 // repeated DescriptorProto message_type = 4; 1210 // and DescriptorProto.field has field number 2: 1211 // repeated FieldDescriptorProto field = 2; 1212 // and FieldDescriptorProto.name has field number 1: 1213 // optional string name = 1; 1214 // 1215 // Thus, the above path gives the location of a field name. If we removed 1216 // the last element: 1217 // [ 4, 3, 2, 7 ] 1218 // this path refers to the whole field declaration (from the beginning 1219 // of the label to the terminating semicolon). 1220 repeated int32 path = 1 [packed = true]; 1221 1222 // Always has exactly three or four elements: start line, start column, 1223 // end line (optional, otherwise assumed same as start line), end column. 1224 // These are packed into a single field for efficiency. Note that line 1225 // and column numbers are zero-based -- typically you will want to add 1226 // 1 to each before displaying to a user. 1227 repeated int32 span = 2 [packed = true]; 1228 1229 // If this SourceCodeInfo represents a complete declaration, these are any 1230 // comments appearing before and after the declaration which appear to be 1231 // attached to the declaration. 1232 // 1233 // A series of line comments appearing on consecutive lines, with no other 1234 // tokens appearing on those lines, will be treated as a single comment. 1235 // 1236 // leading_detached_comments will keep paragraphs of comments that appear 1237 // before (but not connected to) the current element. Each paragraph, 1238 // separated by empty lines, will be one comment element in the repeated 1239 // field. 1240 // 1241 // Only the comment content is provided; comment markers (e.g. //) are 1242 // stripped out. For block comments, leading whitespace and an asterisk 1243 // will be stripped from the beginning of each line other than the first. 1244 // Newlines are included in the output. 1245 // 1246 // Examples: 1247 // 1248 // optional int32 foo = 1; // Comment attached to foo. 1249 // // Comment attached to bar. 1250 // optional int32 bar = 2; 1251 // 1252 // optional string baz = 3; 1253 // // Comment attached to baz. 1254 // // Another line attached to baz. 1255 // 1256 // // Comment attached to moo. 1257 // // 1258 // // Another line attached to moo. 1259 // optional double moo = 4; 1260 // 1261 // // Detached comment for corge. This is not leading or trailing comments 1262 // // to moo or corge because there are blank lines separating it from 1263 // // both. 1264 // 1265 // // Detached comment for corge paragraph 2. 1266 // 1267 // optional string corge = 5; 1268 // /* Block comment attached 1269 // * to corge. Leading asterisks 1270 // * will be removed. */ 1271 // /* Block comment attached to 1272 // * grault. */ 1273 // optional int32 grault = 6; 1274 // 1275 // // ignored detached comments. 1276 optional string leading_comments = 3; 1277 1278 optional string trailing_comments = 4; 1279 1280 repeated string leading_detached_comments = 6; 1281 } 1282 } 1283 1284 // Describes the relationship between generated code and its original source 1285 // file. A GeneratedCodeInfo message is associated with only one generated 1286 // source file, but may contain references to different source .proto files. 1287 message GeneratedCodeInfo { 1288 // An Annotation connects some span of text in generated code to an element 1289 // of its generating .proto file. 1290 repeated Annotation annotation = 1; 1291 1292 message Annotation { 1293 // Identifies the element in the original source .proto file. This field 1294 // is formatted the same as SourceCodeInfo.Location.path. 1295 repeated int32 path = 1 [packed = true]; 1296 1297 // Identifies the filesystem path to the original source .proto. 1298 optional string source_file = 2; 1299 1300 // Identifies the starting offset in bytes in the generated code 1301 // that relates to the identified object. 1302 optional int32 begin = 3; 1303 1304 // Identifies the ending offset in bytes in the generated code that 1305 // relates to the identified object. The end offset should be one past 1306 // the last relevant byte (so the length of the text = end - begin). 1307 optional int32 end = 4; 1308 1309 // Represents the identified object's effect on the element in the original 1310 // .proto file. 1311 enum Semantic { 1312 // There is no effect or the effect is indescribable. 1313 NONE = 0; 1314 1315 // The element is set or otherwise mutated. 1316 SET = 1; 1317 1318 // An alias to the element is returned. 1319 ALIAS = 2; 1320 } 1321 1322 optional Semantic semantic = 5; 1323 } 1324 }