diff options
author | Jie Luo <anandolee@gmail.com> | 2017-12-13 13:48:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-13 13:48:58 -0800 |
commit | bfd254e14f60f77f68f4de8524cd8984191206d5 (patch) | |
tree | b47be82d057f3234aa055f4da2f607a102cc5077 /csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs | |
parent | 0a7120ac32e16d49a35abf18186c8c4db515dd02 (diff) | |
download | protobuf-bfd254e14f60f77f68f4de8524cd8984191206d5.tar.gz protobuf-bfd254e14f60f77f68f4de8524cd8984191206d5.tar.bz2 protobuf-bfd254e14f60f77f68f4de8524cd8984191206d5.zip |
Add unknown field support for csharp (#3936)
Add unknown field support for csharp
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs index ea2a83fc..a9a0d490 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs @@ -179,6 +179,7 @@ namespace Google.Protobuf.TestProtos { /// </summary> public sealed partial class TestWellKnownTypes : pb::IMessage<TestWellKnownTypes> { private static readonly pb::MessageParser<TestWellKnownTypes> _parser = new pb::MessageParser<TestWellKnownTypes>(() => new TestWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<TestWellKnownTypes> Parser { get { return _parser; } } @@ -220,6 +221,7 @@ namespace Google.Protobuf.TestProtos { StringField = other.StringField; BytesField = other.BytesField; ValueField = other.valueField_ != null ? other.ValueField.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -480,7 +482,7 @@ namespace Google.Protobuf.TestProtos { if (StringField != other.StringField) return false; if (BytesField != other.BytesField) return false; if (!object.Equals(ValueField, other.ValueField)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -505,6 +507,9 @@ namespace Google.Protobuf.TestProtos { if (stringField_ != null) hash ^= StringField.GetHashCode(); if (bytesField_ != null) hash ^= BytesField.GetHashCode(); if (valueField_ != null) hash ^= ValueField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -582,6 +587,9 @@ namespace Google.Protobuf.TestProtos { output.WriteRawTag(154, 1); output.WriteMessage(ValueField); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -644,6 +652,9 @@ namespace Google.Protobuf.TestProtos { if (valueField_ != null) { size += 2 + pb::CodedOutputStream.ComputeMessageSize(ValueField); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -757,6 +768,7 @@ namespace Google.Protobuf.TestProtos { } ValueField.MergeFrom(other.ValueField); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -765,7 +777,7 @@ namespace Google.Protobuf.TestProtos { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (anyField_ == null) { @@ -911,6 +923,7 @@ namespace Google.Protobuf.TestProtos { /// </summary> public sealed partial class RepeatedWellKnownTypes : pb::IMessage<RepeatedWellKnownTypes> { private static readonly pb::MessageParser<RepeatedWellKnownTypes> _parser = new pb::MessageParser<RepeatedWellKnownTypes>(() => new RepeatedWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<RepeatedWellKnownTypes> Parser { get { return _parser; } } @@ -951,6 +964,7 @@ namespace Google.Protobuf.TestProtos { boolField_ = other.boolField_.Clone(); stringField_ = other.stringField_.Clone(); bytesField_ = other.bytesField_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1172,7 +1186,7 @@ namespace Google.Protobuf.TestProtos { if(!boolField_.Equals(other.boolField_)) return false; if(!stringField_.Equals(other.stringField_)) return false; if(!bytesField_.Equals(other.bytesField_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1196,6 +1210,9 @@ namespace Google.Protobuf.TestProtos { hash ^= boolField_.GetHashCode(); hash ^= stringField_.GetHashCode(); hash ^= bytesField_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -1224,6 +1241,9 @@ namespace Google.Protobuf.TestProtos { boolField_.WriteTo(output, _repeated_boolField_codec); stringField_.WriteTo(output, _repeated_stringField_codec); bytesField_.WriteTo(output, _repeated_bytesField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1247,6 +1267,9 @@ namespace Google.Protobuf.TestProtos { size += boolField_.CalculateSize(_repeated_boolField_codec); size += stringField_.CalculateSize(_repeated_stringField_codec); size += bytesField_.CalculateSize(_repeated_bytesField_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -1273,6 +1296,7 @@ namespace Google.Protobuf.TestProtos { boolField_.Add(other.boolField_); stringField_.Add(other.stringField_); bytesField_.Add(other.bytesField_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1281,7 +1305,7 @@ namespace Google.Protobuf.TestProtos { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { anyField_.AddEntriesFrom(input, _repeated_anyField_codec); @@ -1363,6 +1387,7 @@ namespace Google.Protobuf.TestProtos { public sealed partial class OneofWellKnownTypes : pb::IMessage<OneofWellKnownTypes> { private static readonly pb::MessageParser<OneofWellKnownTypes> _parser = new pb::MessageParser<OneofWellKnownTypes>(() => new OneofWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<OneofWellKnownTypes> Parser { get { return _parser; } } @@ -1442,6 +1467,7 @@ namespace Google.Protobuf.TestProtos { break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1723,7 +1749,7 @@ namespace Google.Protobuf.TestProtos { if (StringField != other.StringField) return false; if (BytesField != other.BytesField) return false; if (OneofFieldCase != other.OneofFieldCase) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1748,6 +1774,9 @@ namespace Google.Protobuf.TestProtos { if (oneofFieldCase_ == OneofFieldOneofCase.StringField) hash ^= StringField.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) hash ^= BytesField.GetHashCode(); hash ^= (int) oneofFieldCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -1821,6 +1850,9 @@ namespace Google.Protobuf.TestProtos { if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) { _oneof_bytesField_codec.WriteTagAndValue(output, (pb::ByteString) oneofField_); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1880,6 +1912,9 @@ namespace Google.Protobuf.TestProtos { if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) { size += _oneof_bytesField_codec.CalculateSizeWithTag(BytesField); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -1972,6 +2007,7 @@ namespace Google.Protobuf.TestProtos { break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1980,7 +2016,7 @@ namespace Google.Protobuf.TestProtos { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any(); @@ -2112,6 +2148,7 @@ namespace Google.Protobuf.TestProtos { /// </summary> public sealed partial class MapWellKnownTypes : pb::IMessage<MapWellKnownTypes> { private static readonly pb::MessageParser<MapWellKnownTypes> _parser = new pb::MessageParser<MapWellKnownTypes>(() => new MapWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<MapWellKnownTypes> Parser { get { return _parser; } } @@ -2152,6 +2189,7 @@ namespace Google.Protobuf.TestProtos { boolField_ = other.boolField_.Clone(); stringField_ = other.stringField_.Clone(); bytesField_ = other.bytesField_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2370,7 +2408,7 @@ namespace Google.Protobuf.TestProtos { if (!BoolField.Equals(other.BoolField)) return false; if (!StringField.Equals(other.StringField)) return false; if (!BytesField.Equals(other.BytesField)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2394,6 +2432,9 @@ namespace Google.Protobuf.TestProtos { hash ^= BoolField.GetHashCode(); hash ^= StringField.GetHashCode(); hash ^= BytesField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -2422,6 +2463,9 @@ namespace Google.Protobuf.TestProtos { boolField_.WriteTo(output, _map_boolField_codec); stringField_.WriteTo(output, _map_stringField_codec); bytesField_.WriteTo(output, _map_bytesField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2445,6 +2489,9 @@ namespace Google.Protobuf.TestProtos { size += boolField_.CalculateSize(_map_boolField_codec); size += stringField_.CalculateSize(_map_stringField_codec); size += bytesField_.CalculateSize(_map_bytesField_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -2471,6 +2518,7 @@ namespace Google.Protobuf.TestProtos { boolField_.Add(other.boolField_); stringField_.Add(other.stringField_); bytesField_.Add(other.bytesField_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2479,7 +2527,7 @@ namespace Google.Protobuf.TestProtos { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { anyField_.AddEntriesFrom(input, _map_anyField_codec); |