Add discard unknown API in ruby. (#3990)
* Add discard unknown API in ruby.
* Add test for oneof message field.
* Add TestUnknown to represent unknown field data clearly.
* Only serialize the message with unknown fields itself in test.
* Move discard_unknown from Message to Google.Protobuf
diff --git a/ruby/tests/generated_code.proto b/ruby/tests/generated_code.proto
index 62fd83e..3b934bd 100644
--- a/ruby/tests/generated_code.proto
+++ b/ruby/tests/generated_code.proto
@@ -57,6 +57,9 @@
}
NestedMessage nested_message = 80;
+
+ // Reserved for non-existing field test.
+ // int32 non_exist = 89;
}
enum TestEnum {
@@ -65,3 +68,13 @@
B = 2;
C = 3;
}
+
+message TestUnknown {
+ TestUnknown optional_unknown = 11;
+ repeated TestUnknown repeated_unknown = 31;
+ oneof my_oneof {
+ TestUnknown oneof_unknown = 51;
+ }
+ map<string, TestUnknown> map_unknown = 67;
+ int32 unknown_field = 89;
+}