From fb1d87794998ea8f0ab0248420748df8491b695c Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 2 Feb 2023 09:50:39 -0800 Subject: [PATCH] Internal changes PiperOrigin-RevId: 506649450 --- .../unittest_custom_options_proto3.proto | 174 ++++++++++-------- csharp/protos/unittest_issue6936_a.proto | 4 +- .../unittest_selfreferential_options.proto | 13 +- .../protobuf/unittest_proto3_optional.proto | 1 + 4 files changed, 108 insertions(+), 84 deletions(-) diff --git a/csharp/protos/unittest_custom_options_proto3.proto b/csharp/protos/unittest_custom_options_proto3.proto index 0e7c2e276c..6c5bd92b72 100644 --- a/csharp/protos/unittest_custom_options_proto3.proto +++ b/csharp/protos/unittest_custom_options_proto3.proto @@ -41,7 +41,6 @@ // proto2 syntax. It's cut down significantly as proto3 only supports // extensions for options. - syntax = "proto3"; // A custom file option (defined below). @@ -98,39 +97,34 @@ extend google.protobuf.MethodOptions { // regular options, to make sure they interact nicely). message TestMessageWithCustomOptions { option message_set_wire_format = false; - option (message_opt1) = -56; - string field1 = 1 [ctype=CORD, - (field_opt1)=8765432109]; + string field1 = 1 [ctype = CORD, (field_opt1) = 8765432109]; oneof AnOneof { option (oneof_opt1) = -99; + int32 oneof_field = 2; } enum AnEnum { option (enum_opt1) = -789; + ANENUM_UNSPECIFIED = 0; ANENUM_VAL1 = 1; ANENUM_VAL2 = 2 [(enum_value_opt1) = 123]; } } - // A test RPC service with custom options at all possible locations (and also // some regular options, to make sure they interact nicely). -message CustomOptionFooRequest { -} +message CustomOptionFooRequest {} -message CustomOptionFooResponse { -} +message CustomOptionFooResponse {} -message CustomOptionFooClientMessage { -} +message CustomOptionFooClientMessage {} -message CustomOptionFooServerMessage { -} +message CustomOptionFooServerMessage {} service TestServiceWithCustomOptions { option (service_opt1) = -9876543210; @@ -140,8 +134,6 @@ service TestServiceWithCustomOptions { } } - - // Options of every possible field type, so we can test them all exhaustively. message DummyMessageContainingEnum { @@ -152,74 +144,73 @@ message DummyMessageContainingEnum { } } -message DummyMessageInvalidAsOptionType { -} +message DummyMessageInvalidAsOptionType {} extend google.protobuf.MessageOptions { - bool bool_opt = 7706090; - int32 int32_opt = 7705709; - int64 int64_opt = 7705542; - uint32 uint32_opt = 7704880; - uint64 uint64_opt = 7702367; - sint32 sint32_opt = 7701568; - sint64 sint64_opt = 7700863; - fixed32 fixed32_opt = 7700307; - fixed64 fixed64_opt = 7700194; - sfixed32 sfixed32_opt = 7698645; - sfixed64 sfixed64_opt = 7685475; - float float_opt = 7675390; - double double_opt = 7673293; - string string_opt = 7673285; - bytes bytes_opt = 7673238; + bool bool_opt = 7706090; + int32 int32_opt = 7705709; + int64 int64_opt = 7705542; + uint32 uint32_opt = 7704880; + uint64 uint64_opt = 7702367; + sint32 sint32_opt = 7701568; + sint64 sint64_opt = 7700863; + fixed32 fixed32_opt = 7700307; + fixed64 fixed64_opt = 7700194; + sfixed32 sfixed32_opt = 7698645; + sfixed64 sfixed64_opt = 7685475; + float float_opt = 7675390; + double double_opt = 7673293; + string string_opt = 7673285; + bytes bytes_opt = 7673238; DummyMessageContainingEnum.TestEnumType enum_opt = 7673233; DummyMessageInvalidAsOptionType message_type_opt = 7665967; } message CustomOptionMinIntegerValues { - option (bool_opt) = false; - option (int32_opt) = -0x80000000; - option (int64_opt) = -0x8000000000000000; - option (uint32_opt) = 0; - option (uint64_opt) = 0; - option (sint32_opt) = -0x80000000; - option (sint64_opt) = -0x8000000000000000; - option (fixed32_opt) = 0; - option (fixed64_opt) = 0; + option (bool_opt) = false; + option (int32_opt) = -0x80000000; + option (int64_opt) = -0x8000000000000000; + option (uint32_opt) = 0; + option (uint64_opt) = 0; + option (sint32_opt) = -0x80000000; + option (sint64_opt) = -0x8000000000000000; + option (fixed32_opt) = 0; + option (fixed64_opt) = 0; option (sfixed32_opt) = -0x80000000; option (sfixed64_opt) = -0x8000000000000000; } message CustomOptionMaxIntegerValues { - option (bool_opt) = true; - option (int32_opt) = 0x7FFFFFFF; - option (int64_opt) = 0x7FFFFFFFFFFFFFFF; - option (uint32_opt) = 0xFFFFFFFF; - option (uint64_opt) = 0xFFFFFFFFFFFFFFFF; - option (sint32_opt) = 0x7FFFFFFF; - option (sint64_opt) = 0x7FFFFFFFFFFFFFFF; - option (fixed32_opt) = 0xFFFFFFFF; - option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF; + option (bool_opt) = true; + option (int32_opt) = 0x7FFFFFFF; + option (int64_opt) = 0x7FFFFFFFFFFFFFFF; + option (uint32_opt) = 0xFFFFFFFF; + option (uint64_opt) = 0xFFFFFFFFFFFFFFFF; + option (sint32_opt) = 0x7FFFFFFF; + option (sint64_opt) = 0x7FFFFFFFFFFFFFFF; + option (fixed32_opt) = 0xFFFFFFFF; + option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF; option (sfixed32_opt) = 0x7FFFFFFF; option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF; } message CustomOptionOtherValues { - option (int32_opt) = -100; // To test sign-extension. - option (float_opt) = 12.3456789; + option (int32_opt) = -100; // To test sign-extension. + option (float_opt) = 12.3456789; option (double_opt) = 1.234567890123456789; option (string_opt) = "Hello, \"World\""; - option (bytes_opt) = "Hello\0World"; - option (enum_opt) = TEST_OPTION_ENUM_TYPE2; + option (bytes_opt) = "Hello\0World"; + option (enum_opt) = TEST_OPTION_ENUM_TYPE2; } message SettingRealsFromPositiveInts { - option (float_opt) = 12; + option (float_opt) = 12; option (double_opt) = 154; } message SettingRealsFromNegativeInts { - option (float_opt) = -12; - option (double_opt) = -154; + option (float_opt) = -12; + option (double_opt) = -154; } // Options of complex message types, themselves combined and extended in @@ -267,8 +258,12 @@ message VariousComplexOptions { option (complex_opt2).bar.foo = 743; option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; option (complex_opt2).fred.waldo = 321; - option (complex_opt2).barney = { waldo: 101 }; - option (complex_opt2).barney = { waldo: 212 }; + option (complex_opt2).barney = { + waldo: 101 + }; + option (complex_opt2).barney = { + waldo: 212 + }; option (protobuf_unittest.complex_opt3).qux = 9; } @@ -287,50 +282,79 @@ message Aggregate { // Allow Aggregate to be used as an option at all possible locations // in the .proto grammar. -extend google.protobuf.FileOptions { Aggregate fileopt = 15478479; } -extend google.protobuf.MessageOptions { Aggregate msgopt = 15480088; } -extend google.protobuf.FieldOptions { Aggregate fieldopt = 15481374; } -extend google.protobuf.EnumOptions { Aggregate enumopt = 15483218; } -extend google.protobuf.EnumValueOptions { Aggregate enumvalopt = 15486921; } -extend google.protobuf.ServiceOptions { Aggregate serviceopt = 15497145; } -extend google.protobuf.MethodOptions { Aggregate methodopt = 15512713; } +extend google.protobuf.FileOptions { + Aggregate fileopt = 15478479; +} +extend google.protobuf.MessageOptions { + Aggregate msgopt = 15480088; +} +extend google.protobuf.FieldOptions { + Aggregate fieldopt = 15481374; +} +extend google.protobuf.EnumOptions { + Aggregate enumopt = 15483218; +} +extend google.protobuf.EnumValueOptions { + Aggregate enumvalopt = 15486921; +} +extend google.protobuf.ServiceOptions { + Aggregate serviceopt = 15497145; +} +extend google.protobuf.MethodOptions { + Aggregate methodopt = 15512713; +} // Try using AggregateOption at different points in the proto grammar option (fileopt) = { s: 'FileAnnotation' // Also test the handling of comments - /* of both types */ i: 100 + /* of both types */ + i: 100 sub { s: 'NestedFileAnnotation' } }; message AggregateMessage { - option (msgopt) = { i:101 s:'MessageAnnotation' }; - int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }]; + option (msgopt) = { + i: 101 + s: 'MessageAnnotation' + }; + + int32 fieldname = 1 [(fieldopt) = { s: 'FieldAnnotation' }]; } service AggregateService { - option (serviceopt) = { s:'ServiceAnnotation' }; - rpc Method (AggregateMessage) returns (AggregateMessage) { - option (methodopt) = { s:'MethodAnnotation' }; + option (serviceopt) = { + s: 'ServiceAnnotation' + }; + + rpc Method(AggregateMessage) returns (AggregateMessage) { + option (methodopt) = { + s: 'MethodAnnotation' + }; } } enum AggregateEnum { - option (enumopt) = { s:'EnumAnnotation' }; + option (enumopt) = { + s: 'EnumAnnotation' + }; + UNSPECIFIED = 0; - VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }]; + VALUE = 1 [(enumvalopt) = { s: 'EnumValueAnnotation' }]; } // Test custom options for nested type. message NestedOptionType { message NestedMessage { option (message_opt1) = 1001; + int32 nested_field = 1 [(field_opt1) = 1002]; } enum NestedEnum { - UNSPECIFIED = 0; option (enum_opt1) = 1003; + + UNSPECIFIED = 0; NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004]; } } diff --git a/csharp/protos/unittest_issue6936_a.proto b/csharp/protos/unittest_issue6936_a.proto index 45214c7eb6..07bb2faecb 100644 --- a/csharp/protos/unittest_issue6936_a.proto +++ b/csharp/protos/unittest_issue6936_a.proto @@ -35,11 +35,11 @@ package unittest_issues; option csharp_namespace = "UnitTest.Issues.TestProtos"; // This file is used as part of a unit test for issue 6936 -// We don't need to use it, we just have to import it in both +// We don't need to use it, we just have to import it in both // "extensions_issue6936_b.proto" and "extensions_issue6936_c.proto" import "google/protobuf/descriptor.proto"; extend google.protobuf.MessageOptions { - string opt = 50000; + string opt = 50000; } diff --git a/csharp/protos/unittest_selfreferential_options.proto b/csharp/protos/unittest_selfreferential_options.proto index 22f16cfbf5..71cc1e6f7e 100644 --- a/csharp/protos/unittest_selfreferential_options.proto +++ b/csharp/protos/unittest_selfreferential_options.proto @@ -31,22 +31,21 @@ syntax = "proto2"; package protobuf_unittest_selfreferential_options; -option csharp_namespace = "UnitTest.Issues.TestProtos.SelfreferentialOptions"; import "google/protobuf/descriptor.proto"; +option csharp_namespace = "UnitTest.Issues.TestProtos.SelfreferentialOptions"; + message FooOptions { // Custom field option used in definition of the extension message. optional int32 int_opt = 1 [(foo_options) = { int_opt: 1 [foo_int_opt]: 2 - [foo_foo_opt]: { - int_opt: 3 - } + [foo_foo_opt]: { int_opt: 3 } }]; // Custom field option used in definition of the custom option's message. - optional int32 foo = 2 [(foo_options) = {foo: 1234}]; + optional int32 foo = 2 [(foo_options) = { foo: 1234 }]; extensions 1000 to max; } @@ -59,6 +58,6 @@ extend google.protobuf.FieldOptions { } extend FooOptions { - optional int32 foo_int_opt = 1000; - optional FooOptions foo_foo_opt = 1001; + optional int32 foo_int_opt = 1000; + optional FooOptions foo_foo_opt = 1001; } diff --git a/src/google/protobuf/unittest_proto3_optional.proto b/src/google/protobuf/unittest_proto3_optional.proto index 09d17182ef..7085c79e47 100644 --- a/src/google/protobuf/unittest_proto3_optional.proto +++ b/src/google/protobuf/unittest_proto3_optional.proto @@ -34,6 +34,7 @@ package protobuf_unittest; import "google/protobuf/descriptor.proto"; +option csharp_namespace = "ProtobufUnittest"; option java_multiple_files = true; option java_package = "com.google.protobuf.testing.proto";