blob: 388998f0a0ea1863f33cc12179ddb71ed5494b91 [file] [log] [blame]
Jon Skeet0f370b42015-08-03 10:59:27 +01001syntax = "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
7option csharp_namespace = "UnitTest.Issues.TestProtos";
8
9package unittest_issues;
Jon Skeet0f370b42015-08-03 10:59:27 +010010
Jon Skeet0dd5fff2020-06-05 14:48:55 +010011import "google/protobuf/struct.proto";
12
Jon Skeet0f370b42015-08-03 10:59:27 +010013// Issue 307: when generating doubly-nested types, any references
14// should be of the form A.Types.B.Types.C.
15message 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 Xiaoafe98de2018-08-22 11:55:30 -070023// New issue 309: https://github.com/protocolbuffers/protobuf/issues/309
Xiang Daie4794102019-02-21 11:28:50 +080024
Jon Skeet0f370b42015-08-03 10:59:27 +010025// 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 Xiaoafe98de2018-08-22 11:55:30 -070039// See https://github.com/protocolbuffers/protobuf/issues/308
Jon Skeet0f370b42015-08-03 10:59:27 +010040// message NumberField {
41// optional int32 _01 = 1;
42// }
43
44// issue 19 - negative enum values
45
46enum NegativeEnum {
47 NEGATIVE_ENUM_ZERO = 0;
48 FiveBelow = -5;
49 MinusOne = -1;
50}
51
52message 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
61message DeprecatedChild {
62}
63
64enum DeprecatedEnum {
65 DEPRECATED_ZERO = 0;
66 one = 1;
67}
68
69message 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
81message ItemField {
82 int32 item = 1;
83}
84
85message ReservedNames {
86 // Force a nested type called Types
87 message SomeNestedType {
88 }
89
90 int32 types = 1;
91 int32 descriptor = 2;
92}
93
94message 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 Daie4794102019-02-21 11:28:50 +0800105
Jon Skeet0f370b42015-08-03 10:59:27 +0100106 int32 plain_int32 = 4;
107
108 oneof o1 {
109 string o1_string = 2;
110 int32 o1_int32 = 5;
111 }
Xiang Daie4794102019-02-21 11:28:50 +0800112
Jon Skeet0f370b42015-08-03 10:59:27 +0100113 string plain_string = 1;
Xiang Daie4794102019-02-21 11:28:50 +0800114
Jon Skeet0f370b42015-08-03 10:59:27 +0100115 oneof o2 {
116 int32 o2_int32 = 6;
117 string o2_string = 3;
118 }
Xiang Daie4794102019-02-21 11:28:50 +0800119
alien0d32ab32016-03-17 15:19:04 +0300120}
121
122message TestJsonName {
alien6f8dd212016-03-29 20:56:32 +0300123 // Message for testing the effects for of the json_name option
alien0d32ab32016-03-17 15:19:04 +0300124 string name = 1;
125 string description = 2 [json_name = "desc"];
126 string guid = 3 [json_name = "exid"];
127}
Jon Skeetcbe25052017-10-24 14:14:15 +0100128
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.
132message 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 Skeet0dd5fff2020-06-05 14:48:55 +0100142}
143
144message NullValueOutsideStruct {
145 oneof value {
146 string string_value = 1;
147 google.protobuf.NullValue null_value = 2;
148 }
149}
Jon Skeet2c1a4612020-06-16 15:21:03 +0100150
151message NullValueNotInOneof {
152 google.protobuf.NullValue null_value = 2;
153}
Jon Skeetd4ec70f2020-07-14 05:51:52 +0100154
155message MixedRegularAndOptional {
156 string regular_field = 1;
157 optional string optional_field = 2;
158}