aboutsummaryrefslogtreecommitdiff
path: root/csharp/protos/extest
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-04-28 15:06:59 +0100
committerJon Skeet <jonskeet@google.com>2015-04-28 15:06:59 +0100
commitce66c5f1b99fe36b5b91e8b59cc75ce8a4e9cba5 (patch)
tree84adc050b8ee575f94a5efc13322dd7d344fcff7 /csharp/protos/extest
parentf3504cf3b1d456a843e8242fdee9ba0bf2991dc1 (diff)
downloadprotobuf-ce66c5f1b99fe36b5b91e8b59cc75ce8a4e9cba5.tar.gz
protobuf-ce66c5f1b99fe36b5b91e8b59cc75ce8a4e9cba5.tar.bz2
protobuf-ce66c5f1b99fe36b5b91e8b59cc75ce8a4e9cba5.zip
Updated set of unit tests and unit test protos.
This commit includes changes to the C#-specific protos, and rebuilt versions of the "stock" protos. The stock protos have been locally updated to have a specific C# namespace, but this is expected to change soon, so hasn't been committed. Four areas are currently not tested: 1) Serialization - we may restore this at some point, possibly optionally. 2) Services - currently nothing is generated for this; will need to see how it interacts with GRPC 3) Fields beginning with _{digit} - see https://github.com/google/protobuf/issues/308 4) Fields with names which conflict with the declaring type in nasty ways - see https://github.com/google/protobuf/issues/309
Diffstat (limited to 'csharp/protos/extest')
-rw-r--r--csharp/protos/extest/unittest_extras.proto37
-rw-r--r--csharp/protos/extest/unittest_extras_full.proto13
-rw-r--r--csharp/protos/extest/unittest_extras_lite.proto14
-rw-r--r--csharp/protos/extest/unittest_extras_xmltest.proto7
-rw-r--r--csharp/protos/extest/unittest_generic_services.proto35
-rw-r--r--csharp/protos/extest/unittest_issues.proto36
6 files changed, 53 insertions, 89 deletions
diff --git a/csharp/protos/extest/unittest_extras.proto b/csharp/protos/extest/unittest_extras.proto
deleted file mode 100644
index 91f10fbd..00000000
--- a/csharp/protos/extest/unittest_extras.proto
+++ /dev/null
@@ -1,37 +0,0 @@
-// Additional options required for C# generation. File from copyright
-// line onwards is as per original distribution.
-import "google/protobuf/csharp_options.proto";
-option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
-option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasProtoFile";
-option (google.protobuf.csharp_file_options).add_serializable = true;
-
-package protobuf_unittest_extra;
-
-option java_package = "com.google.protobuf";
-
-message TestUnpackedExtensions {
- extensions 1 to max;
-}
-
-extend TestUnpackedExtensions {
- repeated int32 unpacked_int32_extension = 90;
- repeated int64 unpacked_int64_extension = 91;
- repeated uint32 unpacked_uint32_extension = 92;
- repeated uint64 unpacked_uint64_extension = 93;
- repeated sint32 unpacked_sint32_extension = 94;
- repeated sint64 unpacked_sint64_extension = 95;
- repeated fixed32 unpacked_fixed32_extension = 96;
- repeated fixed64 unpacked_fixed64_extension = 97;
- repeated sfixed32 unpacked_sfixed32_extension = 98;
- repeated sfixed64 unpacked_sfixed64_extension = 99;
- repeated float unpacked_float_extension = 100;
- repeated double unpacked_double_extension = 101;
- repeated bool unpacked_bool_extension = 102;
- repeated UnpackedExtensionsForeignEnum unpacked_enum_extension = 103;
-}
-
-enum UnpackedExtensionsForeignEnum {
- FOREIGN_FOO = 4;
- FOREIGN_BAR = 5;
- FOREIGN_BAZ = 6;
-}
diff --git a/csharp/protos/extest/unittest_extras_full.proto b/csharp/protos/extest/unittest_extras_full.proto
index a334bbf1..1b546053 100644
--- a/csharp/protos/extest/unittest_extras_full.proto
+++ b/csharp/protos/extest/unittest_extras_full.proto
@@ -1,13 +1,9 @@
-// Additional options required for C# generation. File from copyright
-// line onwards is as per original distribution.
-import "google/protobuf/csharp_options.proto";
-option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
-option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasFullProtoFile";
+syntax = "proto2";
package protobuf_unittest_extra;
+option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
option optimize_for = CODE_SIZE;
-
option java_package = "com.google.protobuf";
message TestInteropPerson {
@@ -45,7 +41,10 @@ message TestInteropEmployeeId {
}
extend TestInteropPerson {
- required TestInteropEmployeeId employee_id = 126;
+ // Note: changed from required to optional, as required fields are not
+ // permitted in extensions. (The fact that this was allowed in protogen
+ // before was almost certainly a bug.)
+ optional TestInteropEmployeeId employee_id = 126;
}
message TestMissingFieldsA {
diff --git a/csharp/protos/extest/unittest_extras_lite.proto b/csharp/protos/extest/unittest_extras_lite.proto
index ea1bcd25..0c242d2f 100644
--- a/csharp/protos/extest/unittest_extras_lite.proto
+++ b/csharp/protos/extest/unittest_extras_lite.proto
@@ -1,14 +1,9 @@
-// Additional options required for C# generation. File from copyright
-// line onwards is as per original distribution.
-import "google/protobuf/csharp_options.proto";
-option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
-option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasLiteProtoFile";
-option (google.protobuf.csharp_file_options).add_serializable = true;
+syntax = "proto2";
package protobuf_unittest_extra;
+option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
option optimize_for = LITE_RUNTIME;
-
option java_package = "com.google.protobuf";
message TestRequiredLite {
@@ -58,7 +53,10 @@ message TestInteropEmployeeIdLite {
}
extend TestInteropPersonLite {
- required TestInteropEmployeeIdLite employee_id_lite = 126;
+ // Note: changed from required to optional, as required fields are not
+ // permitted in extensions. (The fact that this was allowed in protogen
+ // before was almost certainly a bug.)
+ optional TestInteropEmployeeIdLite employee_id_lite = 126;
}
/* Removed from unittest_lite.proto and added back here */
diff --git a/csharp/protos/extest/unittest_extras_xmltest.proto b/csharp/protos/extest/unittest_extras_xmltest.proto
index ab8088a7..fae36165 100644
--- a/csharp/protos/extest/unittest_extras_xmltest.proto
+++ b/csharp/protos/extest/unittest_extras_xmltest.proto
@@ -1,7 +1,6 @@
-import "google/protobuf/csharp_options.proto";
-option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
-option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestXmlSerializerTestProtoFile";
-option (google.protobuf.csharp_file_options).add_serializable = true;
+syntax = "proto2";
+
+option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
package protobuf_unittest_extra;
diff --git a/csharp/protos/extest/unittest_generic_services.proto b/csharp/protos/extest/unittest_generic_services.proto
index 3fe2e8eb..4e68ff0f 100644
--- a/csharp/protos/extest/unittest_generic_services.proto
+++ b/csharp/protos/extest/unittest_generic_services.proto
@@ -1,29 +1,30 @@
+syntax = "proto2";
+
// Additional options required for C# generation. File from copyright
// line onwards is as per original distribution.
-import "google/protobuf/csharp_options.proto";
import "google/protobuf/unittest.proto";
import "google/protobuf/unittest_custom_options.proto";
-option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
-option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestGenericServices";
-option (google.protobuf.csharp_file_options).service_generator_type = GENERIC;
+option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
+
+// option (google.protobuf.csharp_file_options).service_generator_type = GENERIC;
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+package protobuf_unittest;
-// We don't put this in a package within proto2 because we need to make sure
-// that the generated code doesn't depend on being in the proto2 namespace.
-package protobuf_unittest;
-
option optimize_for = SPEED;
service TestGenericService {
rpc Foo(FooRequest) returns (FooResponse);
rpc Bar(BarRequest) returns (BarResponse);
}
-
-service TestGenericServiceWithCustomOptions {
- option (service_opt1) = -9876543210;
-
- rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
- option (method_opt1) = METHODOPT1_VAL2;
- }
-}
-
+
+service TestGenericServiceWithCustomOptions {
+ option (service_opt1) = -9876543210;
+
+ rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
+ option (method_opt1) = METHODOPT1_VAL2;
+ }
+}
+
diff --git a/csharp/protos/extest/unittest_issues.proto b/csharp/protos/extest/unittest_issues.proto
index cb803791..97249dff 100644
--- a/csharp/protos/extest/unittest_issues.proto
+++ b/csharp/protos/extest/unittest_issues.proto
@@ -1,10 +1,10 @@
+syntax = "proto2";
+
// These proto descriptors have at one time been reported as an issue or defect.
// They are kept here to replicate the issue, and continue to verify the fix.
-import "google/protobuf/csharp_options.proto";
// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified
-option (google.protobuf.csharp_file_options).namespace = "UnitTest.Issues.TestProtos";
-option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestExtrasIssuesProtoFile";
+option csharp_namespace = "UnitTest.Issues.TestProtos";
package unittest_issues;
option optimize_for = SPEED;
@@ -67,24 +67,28 @@ service TestGenericService {
rpc Bar(TestBasicNoFields) returns (TestBasicMessage);
}
*/
-// Issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
+
+// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
+// New issue 309: https://github.com/google/protobuf/issues/309
-message A {
- optional int32 _A = 1;
-}
+// message A {
+// optional int32 _A = 1;
+// }
-message B {
- optional int32 B_ = 1;
-}
+// message B {
+// optional int32 B_ = 1;
+// }
-message AB {
- optional int32 a_b = 1;
-}
+//message AB {
+// optional int32 a_b = 1;
+//}
// Similar issue with numeric names
-message NumberField {
- optional int32 _01 = 1;
-}
+// Java code failed too, so probably best for this to be a restriction.
+// See https://github.com/google/protobuf/issues/308
+// message NumberField {
+// optional int32 _01 = 1;
+// }
// Issue 28: Circular message dependencies result in null defaults for DefaultInstance