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/WellKnownTypes/Any.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/WellKnownTypes/Any.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/WellKnownTypes/Any.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index d94feb1e..0896140d 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -119,6 +119,7 @@ namespace Google.Protobuf.WellKnownTypes { /// </summary> public sealed partial class Any : pb::IMessage<Any> { private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<Any> Parser { get { return _parser; } } @@ -143,6 +144,7 @@ namespace Google.Protobuf.WellKnownTypes { public Any(Any other) : this() { typeUrl_ = other.typeUrl_; value_ = other.value_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -218,7 +220,7 @@ namespace Google.Protobuf.WellKnownTypes { } if (TypeUrl != other.TypeUrl) return false; if (Value != other.Value) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -226,6 +228,9 @@ namespace Google.Protobuf.WellKnownTypes { int hash = 1; if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); if (Value.Length != 0) hash ^= Value.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -244,6 +249,9 @@ namespace Google.Protobuf.WellKnownTypes { output.WriteRawTag(18); output.WriteBytes(Value); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -255,6 +263,9 @@ namespace Google.Protobuf.WellKnownTypes { if (Value.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -269,6 +280,7 @@ namespace Google.Protobuf.WellKnownTypes { if (other.Value.Length != 0) { Value = other.Value; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -277,7 +289,7 @@ namespace Google.Protobuf.WellKnownTypes { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { TypeUrl = input.ReadString(); |