Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 1 | syntax = "proto3"; |
| 2 | |
| 3 | // These proto descriptors have at one time been reported as an issue or defect. |
| 4 | // They are kept here to replicate the issue, and continue to verify the fix. |
| 5 | |
| 6 | // Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified |
| 7 | option csharp_namespace = "UnitTest.Issues.TestProtos"; |
| 8 | |
| 9 | package unittest_issues; |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 10 | |
Jon Skeet | 0dd5fff | 2020-06-05 14:48:55 +0100 | [diff] [blame] | 11 | import "google/protobuf/struct.proto"; |
| 12 | |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 13 | // Issue 307: when generating doubly-nested types, any references |
| 14 | // should be of the form A.Types.B.Types.C. |
| 15 | message Issue307 { |
| 16 | message NestedOnce { |
| 17 | message NestedTwice { |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | // Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13 |
Feng Xiao | afe98de | 2018-08-22 11:55:30 -0700 | [diff] [blame] | 23 | // New issue 309: https://github.com/protocolbuffers/protobuf/issues/309 |
Xiang Dai | e479410 | 2019-02-21 11:28:50 +0800 | [diff] [blame] | 24 | |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 25 | // message A { |
| 26 | // optional int32 _A = 1; |
| 27 | // } |
| 28 | |
| 29 | // message B { |
| 30 | // optional int32 B_ = 1; |
| 31 | // } |
| 32 | |
| 33 | //message AB { |
| 34 | // optional int32 a_b = 1; |
| 35 | //} |
| 36 | |
| 37 | // Similar issue with numeric names |
| 38 | // Java code failed too, so probably best for this to be a restriction. |
Feng Xiao | afe98de | 2018-08-22 11:55:30 -0700 | [diff] [blame] | 39 | // See https://github.com/protocolbuffers/protobuf/issues/308 |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 40 | // message NumberField { |
| 41 | // optional int32 _01 = 1; |
| 42 | // } |
| 43 | |
| 44 | // issue 19 - negative enum values |
| 45 | |
| 46 | enum NegativeEnum { |
| 47 | NEGATIVE_ENUM_ZERO = 0; |
| 48 | FiveBelow = -5; |
| 49 | MinusOne = -1; |
| 50 | } |
| 51 | |
| 52 | message NegativeEnumMessage { |
| 53 | NegativeEnum value = 1; |
| 54 | repeated NegativeEnum values = 2 [packed = false]; |
| 55 | repeated NegativeEnum packed_values = 3 [packed=true]; |
| 56 | } |
| 57 | |
| 58 | // Issue 21: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=21 |
| 59 | // Decorate fields with [deprecated=true] as [System.Obsolete] |
| 60 | |
| 61 | message DeprecatedChild { |
| 62 | } |
| 63 | |
| 64 | enum DeprecatedEnum { |
| 65 | DEPRECATED_ZERO = 0; |
| 66 | one = 1; |
| 67 | } |
| 68 | |
| 69 | message DeprecatedFieldsMessage { |
| 70 | int32 PrimitiveValue = 1 [deprecated = true]; |
| 71 | repeated int32 PrimitiveArray = 2 [deprecated = true]; |
| 72 | |
| 73 | DeprecatedChild MessageValue = 3 [deprecated = true]; |
| 74 | repeated DeprecatedChild MessageArray = 4 [deprecated = true]; |
| 75 | |
| 76 | DeprecatedEnum EnumValue = 5 [deprecated = true]; |
| 77 | repeated DeprecatedEnum EnumArray = 6 [deprecated = true]; |
| 78 | } |
| 79 | |
| 80 | // Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 |
| 81 | message ItemField { |
| 82 | int32 item = 1; |
| 83 | } |
| 84 | |
| 85 | message ReservedNames { |
| 86 | // Force a nested type called Types |
| 87 | message SomeNestedType { |
| 88 | } |
| 89 | |
| 90 | int32 types = 1; |
| 91 | int32 descriptor = 2; |
| 92 | } |
| 93 | |
| 94 | message TestJsonFieldOrdering { |
| 95 | // These fields are deliberately not declared in numeric |
| 96 | // order, and the oneof fields aren't contiguous either. |
| 97 | // This allows for reasonably robust tests of JSON output |
| 98 | // ordering. |
| 99 | // TestFieldOrderings in unittest_proto3.proto is similar, |
| 100 | // but doesn't include oneofs. |
| 101 | // TODO: Consider adding oneofs to TestFieldOrderings, although |
| 102 | // that will require fixing other tests in multiple platforms. |
| 103 | // Alternatively, consider just adding this to |
| 104 | // unittest_proto3.proto if multiple platforms want it. |
Xiang Dai | e479410 | 2019-02-21 11:28:50 +0800 | [diff] [blame] | 105 | |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 106 | int32 plain_int32 = 4; |
| 107 | |
| 108 | oneof o1 { |
| 109 | string o1_string = 2; |
| 110 | int32 o1_int32 = 5; |
| 111 | } |
Xiang Dai | e479410 | 2019-02-21 11:28:50 +0800 | [diff] [blame] | 112 | |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 113 | string plain_string = 1; |
Xiang Dai | e479410 | 2019-02-21 11:28:50 +0800 | [diff] [blame] | 114 | |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 115 | oneof o2 { |
| 116 | int32 o2_int32 = 6; |
| 117 | string o2_string = 3; |
| 118 | } |
Xiang Dai | e479410 | 2019-02-21 11:28:50 +0800 | [diff] [blame] | 119 | |
alien | 0d32ab3 | 2016-03-17 15:19:04 +0300 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | message TestJsonName { |
alien | 6f8dd21 | 2016-03-29 20:56:32 +0300 | [diff] [blame] | 123 | // Message for testing the effects for of the json_name option |
alien | 0d32ab3 | 2016-03-17 15:19:04 +0300 | [diff] [blame] | 124 | string name = 1; |
| 125 | string description = 2 [json_name = "desc"]; |
| 126 | string guid = 3 [json_name = "exid"]; |
| 127 | } |
Jon Skeet | cbe2505 | 2017-10-24 14:14:15 +0100 | [diff] [blame] | 128 | |
| 129 | // Issue 3200: When merging two messages which use the same |
| 130 | // oneof case, which is itself a message type, the submessages should |
| 131 | // be merged. |
| 132 | message OneofMerging { |
| 133 | message Nested { |
| 134 | int32 x = 1; |
| 135 | int32 y = 2; |
| 136 | } |
| 137 | |
| 138 | oneof value { |
| 139 | string text = 1; |
| 140 | Nested nested = 2; |
| 141 | } |
Jon Skeet | 0dd5fff | 2020-06-05 14:48:55 +0100 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | message NullValueOutsideStruct { |
| 145 | oneof value { |
| 146 | string string_value = 1; |
| 147 | google.protobuf.NullValue null_value = 2; |
| 148 | } |
| 149 | } |
Jon Skeet | 2c1a461 | 2020-06-16 15:21:03 +0100 | [diff] [blame] | 150 | |
| 151 | message NullValueNotInOneof { |
| 152 | google.protobuf.NullValue null_value = 2; |
| 153 | } |
Jon Skeet | d4ec70f | 2020-07-14 05:51:52 +0100 | [diff] [blame] | 154 | |
| 155 | message MixedRegularAndOptional { |
| 156 | string regular_field = 1; |
| 157 | optional string optional_field = 2; |
| 158 | } |