unittest_issues.proto 3.8 KB

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