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