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