diff options
author | Jie Luo <jieluo@google.com> | 2017-12-19 11:54:11 -0800 |
---|---|---|
committer | Jie Luo <jieluo@google.com> | 2017-12-19 15:38:02 -0800 |
commit | b308580bb1c3f87a062ac1448a3e0bdaab9d40cf (patch) | |
tree | ea211f27b3deb05a9ba5461079288020a11b5c8d /csharp/src/AddressBook/Addressbook.cs | |
parent | 3a06fe1fc9590b534f403114a0668befba926947 (diff) | |
download | protobuf-b308580bb1c3f87a062ac1448a3e0bdaab9d40cf.tar.gz protobuf-b308580bb1c3f87a062ac1448a3e0bdaab9d40cf.tar.bz2 protobuf-b308580bb1c3f87a062ac1448a3e0bdaab9d40cf.zip |
Cherrypick for csharp, including:
Add preserve UnknownFields
Compare floating point values bitwise
Add auto-generated header to C# generated files
Diffstat (limited to 'csharp/src/AddressBook/Addressbook.cs')
-rw-r--r-- | csharp/src/AddressBook/Addressbook.cs | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index e595e58b..ceb93699 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: addressbook.proto +// <auto-generated> +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: addressbook.proto +// </auto-generated> #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -49,6 +51,7 @@ namespace Google.Protobuf.Examples.AddressBook { /// </summary> public sealed partial class Person : pb::IMessage<Person> { private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<Person> Parser { get { return _parser; } } @@ -76,6 +79,7 @@ namespace Google.Protobuf.Examples.AddressBook { email_ = other.email_; phones_ = other.phones_.Clone(); LastUpdated = other.lastUpdated_ != null ? other.LastUpdated.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -158,7 +162,7 @@ namespace Google.Protobuf.Examples.AddressBook { if (Email != other.Email) return false; if(!phones_.Equals(other.phones_)) return false; if (!object.Equals(LastUpdated, other.LastUpdated)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -169,6 +173,9 @@ namespace Google.Protobuf.Examples.AddressBook { if (Email.Length != 0) hash ^= Email.GetHashCode(); hash ^= phones_.GetHashCode(); if (lastUpdated_ != null) hash ^= LastUpdated.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -196,6 +203,9 @@ namespace Google.Protobuf.Examples.AddressBook { output.WriteRawTag(42); output.WriteMessage(LastUpdated); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -214,6 +224,9 @@ namespace Google.Protobuf.Examples.AddressBook { if (lastUpdated_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(LastUpdated); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -238,6 +251,7 @@ namespace Google.Protobuf.Examples.AddressBook { } LastUpdated.MergeFrom(other.LastUpdated); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -246,7 +260,7 @@ namespace Google.Protobuf.Examples.AddressBook { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -287,6 +301,7 @@ namespace Google.Protobuf.Examples.AddressBook { public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> { private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } } @@ -311,6 +326,7 @@ namespace Google.Protobuf.Examples.AddressBook { public PhoneNumber(PhoneNumber other) : this() { number_ = other.number_; type_ = other.type_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -355,7 +371,7 @@ namespace Google.Protobuf.Examples.AddressBook { } if (Number != other.Number) return false; if (Type != other.Type) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -363,6 +379,9 @@ namespace Google.Protobuf.Examples.AddressBook { int hash = 1; if (Number.Length != 0) hash ^= Number.GetHashCode(); if (Type != 0) hash ^= Type.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -381,6 +400,9 @@ namespace Google.Protobuf.Examples.AddressBook { output.WriteRawTag(16); output.WriteEnum((int) Type); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -392,6 +414,9 @@ namespace Google.Protobuf.Examples.AddressBook { if (Type != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -406,6 +431,7 @@ namespace Google.Protobuf.Examples.AddressBook { if (other.Type != 0) { Type = other.Type; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -414,7 +440,7 @@ namespace Google.Protobuf.Examples.AddressBook { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Number = input.ReadString(); @@ -440,6 +466,7 @@ namespace Google.Protobuf.Examples.AddressBook { /// </summary> public sealed partial class AddressBook : pb::IMessage<AddressBook> { private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook()); + private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<AddressBook> Parser { get { return _parser; } } @@ -463,6 +490,7 @@ namespace Google.Protobuf.Examples.AddressBook { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public AddressBook(AddressBook other) : this() { people_ = other.people_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -494,13 +522,16 @@ namespace Google.Protobuf.Examples.AddressBook { return true; } if(!people_.Equals(other.people_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= people_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } @@ -512,12 +543,18 @@ namespace Google.Protobuf.Examples.AddressBook { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { people_.WriteTo(output, _repeated_people_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += people_.CalculateSize(_repeated_people_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } @@ -527,6 +564,7 @@ namespace Google.Protobuf.Examples.AddressBook { return; } people_.Add(other.people_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -535,7 +573,7 @@ namespace Google.Protobuf.Examples.AddressBook { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { people_.AddEntriesFrom(input, _repeated_people_codec); |