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