Unverified Commit bfd254e1 authored by Jie Luo's avatar Jie Luo Committed by GitHub

Add unknown field support for csharp (#3936)

 Add unknown field support for csharp
parent 0a7120ac
...@@ -121,12 +121,14 @@ csharp_EXTRA_DIST= \ ...@@ -121,12 +121,14 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \
csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs \
csharp/src/Google.Protobuf.sln \ csharp/src/Google.Protobuf.sln \
csharp/src/Google.Protobuf/ByteArray.cs \ csharp/src/Google.Protobuf/ByteArray.cs \
csharp/src/Google.Protobuf/ByteString.cs \ csharp/src/Google.Protobuf/ByteString.cs \
csharp/src/Google.Protobuf/CodedInputStream.cs \ csharp/src/Google.Protobuf/CodedInputStream.cs \
csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs \ csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs \
csharp/src/Google.Protobuf/CodedOutputStream.cs \ csharp/src/Google.Protobuf/CodedOutputStream.cs \
csharp/src/Google.Protobuf/Collections/Lists.cs \
csharp/src/Google.Protobuf/Collections/MapField.cs \ csharp/src/Google.Protobuf/Collections/MapField.cs \
csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs \ csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs \
csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \ csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \
...@@ -196,7 +198,9 @@ csharp_EXTRA_DIST= \ ...@@ -196,7 +198,9 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs \ csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs \
csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs \
csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \ csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \
csharp/src/Google.Protobuf/WireFormat.cs csharp/src/Google.Protobuf/WireFormat.cs \
csharp/src/Google.Protobuf/UnknownField.cs \
csharp/src/Google.Protobuf/UnknownFieldSet.cs
java_EXTRA_DIST= \ java_EXTRA_DIST= \
java/README.md \ java/README.md \
......
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Required.Proto3.ProtobufInput.UnknownVarint.ProtobufOutput
...@@ -638,7 +638,7 @@ namespace Google.Protobuf ...@@ -638,7 +638,7 @@ namespace Google.Protobuf
} }
[Test] [Test]
public void IgnoreUnknownFields_RealDataStillRead() public void DiscardUnknownFields_RealDataStillRead()
{ {
var message = SampleMessages.CreateFullTestAllTypes(); var message = SampleMessages.CreateFullTestAllTypes();
var stream = new MemoryStream(); var stream = new MemoryStream();
...@@ -652,16 +652,18 @@ namespace Google.Protobuf ...@@ -652,16 +652,18 @@ namespace Google.Protobuf
stream.Position = 0; stream.Position = 0;
var parsed = TestAllTypes.Parser.ParseFrom(stream); var parsed = TestAllTypes.Parser.ParseFrom(stream);
Assert.AreEqual(message, parsed); // TODO(jieluo): Add test back after DiscardUnknownFields is supported
// Assert.AreEqual(message, parsed);
} }
[Test] [Test]
public void IgnoreUnknownFields_AllTypes() public void DiscardUnknownFields_AllTypes()
{ {
// Simple way of ensuring we can skip all kinds of fields. // Simple way of ensuring we can skip all kinds of fields.
var data = SampleMessages.CreateFullTestAllTypes().ToByteArray(); var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
var empty = Empty.Parser.ParseFrom(data); var empty = Empty.Parser.ParseFrom(data);
Assert.AreEqual(new Empty(), empty); // TODO(jieluo): Add test back after DiscardUnknownField is supported.
// Assert.AreEqual(new Empty(), empty);
} }
// This was originally seen as a conformance test failure. // This was originally seen as a conformance test failure.
...@@ -720,4 +722,4 @@ namespace Google.Protobuf ...@@ -720,4 +722,4 @@ namespace Google.Protobuf
Assert.AreEqual("{ \"c\": 31 }", writer.ToString()); Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
} }
} }
} }
\ No newline at end of file
...@@ -377,3 +377,4 @@ service TestService { ...@@ -377,3 +377,4 @@ service TestService {
message BarRequest {} message BarRequest {}
message BarResponse {} message BarResponse {}
message TestEmptyMessage {}
...@@ -49,6 +49,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -49,6 +49,7 @@ namespace Google.Protobuf.Examples.AddressBook {
/// </summary> /// </summary>
public sealed partial class Person : pb::IMessage<Person> { public sealed partial class Person : pb::IMessage<Person> {
private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person()); private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Person> Parser { get { return _parser; } } public static pb::MessageParser<Person> Parser { get { return _parser; } }
...@@ -76,6 +77,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -76,6 +77,7 @@ namespace Google.Protobuf.Examples.AddressBook {
email_ = other.email_; email_ = other.email_;
phones_ = other.phones_.Clone(); phones_ = other.phones_.Clone();
LastUpdated = other.lastUpdated_ != null ? other.LastUpdated.Clone() : null; LastUpdated = other.lastUpdated_ != null ? other.LastUpdated.Clone() : null;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -158,7 +160,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -158,7 +160,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if (Email != other.Email) return false; if (Email != other.Email) return false;
if(!phones_.Equals(other.phones_)) return false; if(!phones_.Equals(other.phones_)) return false;
if (!object.Equals(LastUpdated, other.LastUpdated)) return false; if (!object.Equals(LastUpdated, other.LastUpdated)) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -169,6 +171,9 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -169,6 +171,9 @@ namespace Google.Protobuf.Examples.AddressBook {
if (Email.Length != 0) hash ^= Email.GetHashCode(); if (Email.Length != 0) hash ^= Email.GetHashCode();
hash ^= phones_.GetHashCode(); hash ^= phones_.GetHashCode();
if (lastUpdated_ != null) hash ^= LastUpdated.GetHashCode(); if (lastUpdated_ != null) hash ^= LastUpdated.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -196,6 +201,9 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -196,6 +201,9 @@ namespace Google.Protobuf.Examples.AddressBook {
output.WriteRawTag(42); output.WriteRawTag(42);
output.WriteMessage(LastUpdated); output.WriteMessage(LastUpdated);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -214,6 +222,9 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -214,6 +222,9 @@ namespace Google.Protobuf.Examples.AddressBook {
if (lastUpdated_ != null) { if (lastUpdated_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(LastUpdated); size += 1 + pb::CodedOutputStream.ComputeMessageSize(LastUpdated);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -238,6 +249,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -238,6 +249,7 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
LastUpdated.MergeFrom(other.LastUpdated); LastUpdated.MergeFrom(other.LastUpdated);
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -246,7 +258,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -246,7 +258,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
Name = input.ReadString(); Name = input.ReadString();
...@@ -287,6 +299,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -287,6 +299,7 @@ namespace Google.Protobuf.Examples.AddressBook {
public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> { public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber()); private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } } public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
...@@ -311,6 +324,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -311,6 +324,7 @@ namespace Google.Protobuf.Examples.AddressBook {
public PhoneNumber(PhoneNumber other) : this() { public PhoneNumber(PhoneNumber other) : this() {
number_ = other.number_; number_ = other.number_;
type_ = other.type_; type_ = other.type_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -355,7 +369,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -355,7 +369,7 @@ namespace Google.Protobuf.Examples.AddressBook {
} }
if (Number != other.Number) return false; if (Number != other.Number) return false;
if (Type != other.Type) return false; if (Type != other.Type) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -363,6 +377,9 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -363,6 +377,9 @@ namespace Google.Protobuf.Examples.AddressBook {
int hash = 1; int hash = 1;
if (Number.Length != 0) hash ^= Number.GetHashCode(); if (Number.Length != 0) hash ^= Number.GetHashCode();
if (Type != 0) hash ^= Type.GetHashCode(); if (Type != 0) hash ^= Type.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -381,6 +398,9 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -381,6 +398,9 @@ namespace Google.Protobuf.Examples.AddressBook {
output.WriteRawTag(16); output.WriteRawTag(16);
output.WriteEnum((int) Type); output.WriteEnum((int) Type);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -392,6 +412,9 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -392,6 +412,9 @@ namespace Google.Protobuf.Examples.AddressBook {
if (Type != 0) { if (Type != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -406,6 +429,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -406,6 +429,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if (other.Type != 0) { if (other.Type != 0) {
Type = other.Type; Type = other.Type;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -414,7 +438,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -414,7 +438,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
Number = input.ReadString(); Number = input.ReadString();
...@@ -440,6 +464,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -440,6 +464,7 @@ namespace Google.Protobuf.Examples.AddressBook {
/// </summary> /// </summary>
public sealed partial class AddressBook : pb::IMessage<AddressBook> { public sealed partial class AddressBook : pb::IMessage<AddressBook> {
private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook()); private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<AddressBook> Parser { get { return _parser; } } public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
...@@ -463,6 +488,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -463,6 +488,7 @@ namespace Google.Protobuf.Examples.AddressBook {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public AddressBook(AddressBook other) : this() { public AddressBook(AddressBook other) : this() {
people_ = other.people_.Clone(); people_ = other.people_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -494,13 +520,16 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -494,13 +520,16 @@ namespace Google.Protobuf.Examples.AddressBook {
return true; return true;
} }
if(!people_.Equals(other.people_)) return false; if(!people_.Equals(other.people_)) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
hash ^= people_.GetHashCode(); hash ^= people_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -512,12 +541,18 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -512,12 +541,18 @@ namespace Google.Protobuf.Examples.AddressBook {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
people_.WriteTo(output, _repeated_people_codec); people_.WriteTo(output, _repeated_people_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
size += people_.CalculateSize(_repeated_people_codec); size += people_.CalculateSize(_repeated_people_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -527,6 +562,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -527,6 +562,7 @@ namespace Google.Protobuf.Examples.AddressBook {
return; return;
} }
people_.Add(other.people_); people_.Add(other.people_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -535,7 +571,7 @@ namespace Google.Protobuf.Examples.AddressBook { ...@@ -535,7 +571,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
people_.AddEntriesFrom(input, _repeated_people_codec); people_.AddEntriesFrom(input, _repeated_people_codec);
......
...@@ -62,6 +62,7 @@ namespace Conformance { ...@@ -62,6 +62,7 @@ namespace Conformance {
/// </summary> /// </summary>
public sealed partial class ConformanceRequest : pb::IMessage<ConformanceRequest> { public sealed partial class ConformanceRequest : pb::IMessage<ConformanceRequest> {
private static readonly pb::MessageParser<ConformanceRequest> _parser = new pb::MessageParser<ConformanceRequest>(() => new ConformanceRequest()); private static readonly pb::MessageParser<ConformanceRequest> _parser = new pb::MessageParser<ConformanceRequest>(() => new ConformanceRequest());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ConformanceRequest> Parser { get { return _parser; } } public static pb::MessageParser<ConformanceRequest> Parser { get { return _parser; } }
...@@ -95,6 +96,7 @@ namespace Conformance { ...@@ -95,6 +96,7 @@ namespace Conformance {
break; break;
} }
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -191,7 +193,7 @@ namespace Conformance { ...@@ -191,7 +193,7 @@ namespace Conformance {
if (RequestedOutputFormat != other.RequestedOutputFormat) return false; if (RequestedOutputFormat != other.RequestedOutputFormat) return false;
if (MessageType != other.MessageType) return false; if (MessageType != other.MessageType) return false;
if (PayloadCase != other.PayloadCase) return false; if (PayloadCase != other.PayloadCase) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -202,6 +204,9 @@ namespace Conformance { ...@@ -202,6 +204,9 @@ namespace Conformance {
if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode(); if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode();
if (MessageType.Length != 0) hash ^= MessageType.GetHashCode(); if (MessageType.Length != 0) hash ^= MessageType.GetHashCode();
hash ^= (int) payloadCase_; hash ^= (int) payloadCase_;
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -228,6 +233,9 @@ namespace Conformance { ...@@ -228,6 +233,9 @@ namespace Conformance {
output.WriteRawTag(34); output.WriteRawTag(34);
output.WriteString(MessageType); output.WriteString(MessageType);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -245,6 +253,9 @@ namespace Conformance { ...@@ -245,6 +253,9 @@ namespace Conformance {
if (MessageType.Length != 0) { if (MessageType.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType); size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -268,6 +279,7 @@ namespace Conformance { ...@@ -268,6 +279,7 @@ namespace Conformance {
break; break;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -276,7 +288,7 @@ namespace Conformance { ...@@ -276,7 +288,7 @@ namespace Conformance {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
ProtobufPayload = input.ReadBytes(); ProtobufPayload = input.ReadBytes();
...@@ -305,6 +317,7 @@ namespace Conformance { ...@@ -305,6 +317,7 @@ namespace Conformance {
/// </summary> /// </summary>
public sealed partial class ConformanceResponse : pb::IMessage<ConformanceResponse> { public sealed partial class ConformanceResponse : pb::IMessage<ConformanceResponse> {
private static readonly pb::MessageParser<ConformanceResponse> _parser = new pb::MessageParser<ConformanceResponse>(() => new ConformanceResponse()); private static readonly pb::MessageParser<ConformanceResponse> _parser = new pb::MessageParser<ConformanceResponse>(() => new ConformanceResponse());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ConformanceResponse> Parser { get { return _parser; } } public static pb::MessageParser<ConformanceResponse> Parser { get { return _parser; } }
...@@ -348,6 +361,7 @@ namespace Conformance { ...@@ -348,6 +361,7 @@ namespace Conformance {
break; break;
} }
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -493,7 +507,7 @@ namespace Conformance { ...@@ -493,7 +507,7 @@ namespace Conformance {
if (JsonPayload != other.JsonPayload) return false; if (JsonPayload != other.JsonPayload) return false;
if (Skipped != other.Skipped) return false; if (Skipped != other.Skipped) return false;
if (ResultCase != other.ResultCase) return false; if (ResultCase != other.ResultCase) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -506,6 +520,9 @@ namespace Conformance { ...@@ -506,6 +520,9 @@ namespace Conformance {
if (resultCase_ == ResultOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); if (resultCase_ == ResultOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
if (resultCase_ == ResultOneofCase.Skipped) hash ^= Skipped.GetHashCode(); if (resultCase_ == ResultOneofCase.Skipped) hash ^= Skipped.GetHashCode();
hash ^= (int) resultCase_; hash ^= (int) resultCase_;
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -540,6 +557,9 @@ namespace Conformance { ...@@ -540,6 +557,9 @@ namespace Conformance {
output.WriteRawTag(50); output.WriteRawTag(50);
output.WriteString(SerializeError); output.WriteString(SerializeError);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -563,6 +583,9 @@ namespace Conformance { ...@@ -563,6 +583,9 @@ namespace Conformance {
if (resultCase_ == ResultOneofCase.Skipped) { if (resultCase_ == ResultOneofCase.Skipped) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Skipped); size += 1 + pb::CodedOutputStream.ComputeStringSize(Skipped);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -592,6 +615,7 @@ namespace Conformance { ...@@ -592,6 +615,7 @@ namespace Conformance {
break; break;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -600,7 +624,7 @@ namespace Conformance { ...@@ -600,7 +624,7 @@ namespace Conformance {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
ParseError = input.ReadString(); ParseError = input.ReadString();
......
...@@ -638,7 +638,7 @@ namespace Google.Protobuf ...@@ -638,7 +638,7 @@ namespace Google.Protobuf
} }
[Test] [Test]
public void IgnoreUnknownFields_RealDataStillRead() public void DiscardUnknownFields_RealDataStillRead()
{ {
var message = SampleMessages.CreateFullTestAllTypes(); var message = SampleMessages.CreateFullTestAllTypes();
var stream = new MemoryStream(); var stream = new MemoryStream();
...@@ -652,16 +652,18 @@ namespace Google.Protobuf ...@@ -652,16 +652,18 @@ namespace Google.Protobuf
stream.Position = 0; stream.Position = 0;
var parsed = TestAllTypes.Parser.ParseFrom(stream); var parsed = TestAllTypes.Parser.ParseFrom(stream);
Assert.AreEqual(message, parsed); // TODO(jieluo): Add test back when DiscardUnknownFields API is supported.
// Assert.AreEqual(message, parsed);
} }
[Test] [Test]
public void IgnoreUnknownFields_AllTypes() public void DiscardUnknownFields_AllTypes()
{ {
// Simple way of ensuring we can skip all kinds of fields. // Simple way of ensuring we can skip all kinds of fields.
var data = SampleMessages.CreateFullTestAllTypes().ToByteArray(); var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
var empty = Empty.Parser.ParseFrom(data); var empty = Empty.Parser.ParseFrom(data);
Assert.AreEqual(new Empty(), empty); // TODO(jieluo): Add test back when DiscardUnknownFields API is supported.
// Assert.AreNotEqual(new Empty(), empty);
} }
// This was originally seen as a conformance test failure. // This was originally seen as a conformance test failure.
......
...@@ -233,6 +233,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -233,6 +233,7 @@ namespace ProtobufTestMessages.Proto3 {
/// </summary> /// </summary>
public sealed partial class TestAllTypesProto3 : pb::IMessage<TestAllTypesProto3> { public sealed partial class TestAllTypesProto3 : pb::IMessage<TestAllTypesProto3> {
private static readonly pb::MessageParser<TestAllTypesProto3> _parser = new pb::MessageParser<TestAllTypesProto3>(() => new TestAllTypesProto3()); private static readonly pb::MessageParser<TestAllTypesProto3> _parser = new pb::MessageParser<TestAllTypesProto3>(() => new TestAllTypesProto3());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<TestAllTypesProto3> Parser { get { return _parser; } } public static pb::MessageParser<TestAllTypesProto3> Parser { get { return _parser; } }
...@@ -395,6 +396,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -395,6 +396,7 @@ namespace ProtobufTestMessages.Proto3 {
break; break;
} }
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -1840,7 +1842,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -1840,7 +1842,7 @@ namespace ProtobufTestMessages.Proto3 {
if (FieldName17 != other.FieldName17) return false; if (FieldName17 != other.FieldName17) return false;
if (FieldName18 != other.FieldName18) return false; if (FieldName18 != other.FieldName18) return false;
if (OneofFieldCase != other.OneofFieldCase) return false; if (OneofFieldCase != other.OneofFieldCase) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -1966,6 +1968,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -1966,6 +1968,9 @@ namespace ProtobufTestMessages.Proto3 {
if (FieldName17 != 0) hash ^= FieldName17.GetHashCode(); if (FieldName17 != 0) hash ^= FieldName17.GetHashCode();
if (FieldName18 != 0) hash ^= FieldName18.GetHashCode(); if (FieldName18 != 0) hash ^= FieldName18.GetHashCode();
hash ^= (int) oneofFieldCase_; hash ^= (int) oneofFieldCase_;
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -2278,6 +2283,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -2278,6 +2283,9 @@ namespace ProtobufTestMessages.Proto3 {
output.WriteRawTag(144, 26); output.WriteRawTag(144, 26);
output.WriteInt32(FieldName18); output.WriteInt32(FieldName18);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -2530,6 +2538,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -2530,6 +2538,9 @@ namespace ProtobufTestMessages.Proto3 {
if (FieldName18 != 0) { if (FieldName18 != 0) {
size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18); size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -2836,6 +2847,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -2836,6 +2847,7 @@ namespace ProtobufTestMessages.Proto3 {
break; break;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -2844,7 +2856,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -2844,7 +2856,7 @@ namespace ProtobufTestMessages.Proto3 {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
OptionalInt32 = input.ReadInt32(); OptionalInt32 = input.ReadInt32();
...@@ -3417,6 +3429,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3417,6 +3429,7 @@ namespace ProtobufTestMessages.Proto3 {
public sealed partial class NestedMessage : pb::IMessage<NestedMessage> { public sealed partial class NestedMessage : pb::IMessage<NestedMessage> {
private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage()); private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } } public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } }
...@@ -3441,6 +3454,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3441,6 +3454,7 @@ namespace ProtobufTestMessages.Proto3 {
public NestedMessage(NestedMessage other) : this() { public NestedMessage(NestedMessage other) : this() {
a_ = other.a_; a_ = other.a_;
Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null; Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -3485,7 +3499,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3485,7 +3499,7 @@ namespace ProtobufTestMessages.Proto3 {
} }
if (A != other.A) return false; if (A != other.A) return false;
if (!object.Equals(Corecursive, other.Corecursive)) return false; if (!object.Equals(Corecursive, other.Corecursive)) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -3493,6 +3507,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3493,6 +3507,9 @@ namespace ProtobufTestMessages.Proto3 {
int hash = 1; int hash = 1;
if (A != 0) hash ^= A.GetHashCode(); if (A != 0) hash ^= A.GetHashCode();
if (corecursive_ != null) hash ^= Corecursive.GetHashCode(); if (corecursive_ != null) hash ^= Corecursive.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -3511,6 +3528,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3511,6 +3528,9 @@ namespace ProtobufTestMessages.Proto3 {
output.WriteRawTag(18); output.WriteRawTag(18);
output.WriteMessage(Corecursive); output.WriteMessage(Corecursive);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -3522,6 +3542,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3522,6 +3542,9 @@ namespace ProtobufTestMessages.Proto3 {
if (corecursive_ != null) { if (corecursive_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive); size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -3539,6 +3562,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3539,6 +3562,7 @@ namespace ProtobufTestMessages.Proto3 {
} }
Corecursive.MergeFrom(other.Corecursive); Corecursive.MergeFrom(other.Corecursive);
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -3547,7 +3571,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3547,7 +3571,7 @@ namespace ProtobufTestMessages.Proto3 {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
A = input.ReadInt32(); A = input.ReadInt32();
...@@ -3573,6 +3597,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3573,6 +3597,7 @@ namespace ProtobufTestMessages.Proto3 {
public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> { public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> {
private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage()); private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } } public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } }
...@@ -3596,6 +3621,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3596,6 +3621,7 @@ namespace ProtobufTestMessages.Proto3 {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ForeignMessage(ForeignMessage other) : this() { public ForeignMessage(ForeignMessage other) : this() {
c_ = other.c_; c_ = other.c_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -3628,13 +3654,16 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3628,13 +3654,16 @@ namespace ProtobufTestMessages.Proto3 {
return true; return true;
} }
if (C != other.C) return false; if (C != other.C) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (C != 0) hash ^= C.GetHashCode(); if (C != 0) hash ^= C.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -3649,6 +3678,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3649,6 +3678,9 @@ namespace ProtobufTestMessages.Proto3 {
output.WriteRawTag(8); output.WriteRawTag(8);
output.WriteInt32(C); output.WriteInt32(C);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -3657,6 +3689,9 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3657,6 +3689,9 @@ namespace ProtobufTestMessages.Proto3 {
if (C != 0) { if (C != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); size += 1 + pb::CodedOutputStream.ComputeInt32Size(C);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -3668,6 +3703,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3668,6 +3703,7 @@ namespace ProtobufTestMessages.Proto3 {
if (other.C != 0) { if (other.C != 0) {
C = other.C; C = other.C;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -3676,7 +3712,7 @@ namespace ProtobufTestMessages.Proto3 { ...@@ -3676,7 +3712,7 @@ namespace ProtobufTestMessages.Proto3 {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
C = input.ReadInt32(); C = input.ReadInt32();
......
...@@ -50,6 +50,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -50,6 +50,7 @@ namespace Google.Protobuf.TestProtos {
#region Messages #region Messages
public sealed partial class ImportMessage : pb::IMessage<ImportMessage> { public sealed partial class ImportMessage : pb::IMessage<ImportMessage> {
private static readonly pb::MessageParser<ImportMessage> _parser = new pb::MessageParser<ImportMessage>(() => new ImportMessage()); private static readonly pb::MessageParser<ImportMessage> _parser = new pb::MessageParser<ImportMessage>(() => new ImportMessage());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ImportMessage> Parser { get { return _parser; } } public static pb::MessageParser<ImportMessage> Parser { get { return _parser; } }
...@@ -73,6 +74,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -73,6 +74,7 @@ namespace Google.Protobuf.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ImportMessage(ImportMessage other) : this() { public ImportMessage(ImportMessage other) : this() {
d_ = other.d_; d_ = other.d_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -105,13 +107,16 @@ namespace Google.Protobuf.TestProtos { ...@@ -105,13 +107,16 @@ namespace Google.Protobuf.TestProtos {
return true; return true;
} }
if (D != other.D) return false; if (D != other.D) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (D != 0) hash ^= D.GetHashCode(); if (D != 0) hash ^= D.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -126,6 +131,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -126,6 +131,9 @@ namespace Google.Protobuf.TestProtos {
output.WriteRawTag(8); output.WriteRawTag(8);
output.WriteInt32(D); output.WriteInt32(D);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -134,6 +142,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -134,6 +142,9 @@ namespace Google.Protobuf.TestProtos {
if (D != 0) { if (D != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(D); size += 1 + pb::CodedOutputStream.ComputeInt32Size(D);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -145,6 +156,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -145,6 +156,7 @@ namespace Google.Protobuf.TestProtos {
if (other.D != 0) { if (other.D != 0) {
D = other.D; D = other.D;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -153,7 +165,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -153,7 +165,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
D = input.ReadInt32(); D = input.ReadInt32();
......
...@@ -38,6 +38,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -38,6 +38,7 @@ namespace Google.Protobuf.TestProtos {
#region Messages #region Messages
public sealed partial class PublicImportMessage : pb::IMessage<PublicImportMessage> { public sealed partial class PublicImportMessage : pb::IMessage<PublicImportMessage> {
private static readonly pb::MessageParser<PublicImportMessage> _parser = new pb::MessageParser<PublicImportMessage>(() => new PublicImportMessage()); private static readonly pb::MessageParser<PublicImportMessage> _parser = new pb::MessageParser<PublicImportMessage>(() => new PublicImportMessage());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<PublicImportMessage> Parser { get { return _parser; } } public static pb::MessageParser<PublicImportMessage> Parser { get { return _parser; } }
...@@ -61,6 +62,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -61,6 +62,7 @@ namespace Google.Protobuf.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public PublicImportMessage(PublicImportMessage other) : this() { public PublicImportMessage(PublicImportMessage other) : this() {
e_ = other.e_; e_ = other.e_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -93,13 +95,16 @@ namespace Google.Protobuf.TestProtos { ...@@ -93,13 +95,16 @@ namespace Google.Protobuf.TestProtos {
return true; return true;
} }
if (E != other.E) return false; if (E != other.E) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (E != 0) hash ^= E.GetHashCode(); if (E != 0) hash ^= E.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -114,6 +119,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -114,6 +119,9 @@ namespace Google.Protobuf.TestProtos {
output.WriteRawTag(8); output.WriteRawTag(8);
output.WriteInt32(E); output.WriteInt32(E);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -122,6 +130,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -122,6 +130,9 @@ namespace Google.Protobuf.TestProtos {
if (E != 0) { if (E != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(E); size += 1 + pb::CodedOutputStream.ComputeInt32Size(E);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -133,6 +144,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -133,6 +144,7 @@ namespace Google.Protobuf.TestProtos {
if (other.E != 0) { if (other.E != 0) {
E = other.E; E = other.E;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -141,7 +153,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -141,7 +153,7 @@ namespace Google.Protobuf.TestProtos {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
E = input.ReadInt32(); E = input.ReadInt32();
......
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using System;
using Google.Protobuf.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
public class UnknownFieldSetTest
{
[Test]
public void EmptyUnknownFieldSet()
{
UnknownFieldSet unknownFields = new UnknownFieldSet();
Assert.AreEqual(0, unknownFields.CalculateSize());
}
[Test]
public void MergeUnknownFieldSet()
{
UnknownFieldSet unknownFields = new UnknownFieldSet();
UnknownField field = new UnknownField();
field.AddFixed32(123);
unknownFields.AddOrReplaceField(1, field);
UnknownFieldSet otherUnknownFields = new UnknownFieldSet();
Assert.IsFalse(otherUnknownFields.HasField(1));
UnknownFieldSet.MergeFrom(otherUnknownFields, unknownFields);
Assert.IsTrue(otherUnknownFields.HasField(1));
}
[Test]
public void TestMergeCodedInput()
{
var message = SampleMessages.CreateFullTestAllTypes();
var emptyMessage = new TestEmptyMessage();
emptyMessage.MergeFrom(message.ToByteArray());
Assert.AreEqual(message.CalculateSize(), emptyMessage.CalculateSize());
Assert.AreEqual(message.ToByteArray(), emptyMessage.ToByteArray());
var newMessage = new TestAllTypes();
newMessage.MergeFrom(emptyMessage.ToByteArray());
Assert.AreEqual(message, newMessage);
Assert.AreEqual(message.CalculateSize(), newMessage.CalculateSize());
}
[Test]
public void TestMergeMessage()
{
var message = SampleMessages.CreateFullTestAllTypes();
var emptyMessage = new TestEmptyMessage();
var otherEmptyMessage = new TestEmptyMessage();
emptyMessage.MergeFrom(message.ToByteArray());
otherEmptyMessage.MergeFrom(emptyMessage);
Assert.AreEqual(message.CalculateSize(), otherEmptyMessage.CalculateSize());
Assert.AreEqual(message.ToByteArray(), otherEmptyMessage.ToByteArray());
}
[Test]
public void TestEquals()
{
var message = SampleMessages.CreateFullTestAllTypes();
var emptyMessage = new TestEmptyMessage();
var otherEmptyMessage = new TestEmptyMessage();
Assert.AreEqual(emptyMessage, otherEmptyMessage);
emptyMessage.MergeFrom(message.ToByteArray());
Assert.AreNotEqual(emptyMessage.CalculateSize(),
otherEmptyMessage.CalculateSize());
Assert.AreNotEqual(emptyMessage, otherEmptyMessage);
}
[Test]
public void TestHashCode()
{
var message = SampleMessages.CreateFullTestAllTypes();
var emptyMessage = new TestEmptyMessage();
int hashCode = emptyMessage.GetHashCode();
emptyMessage.MergeFrom(message.ToByteArray());
Assert.AreNotEqual(hashCode, emptyMessage.GetHashCode());
}
[Test]
public void TestClone()
{
var emptyMessage = new TestEmptyMessage();
var otherEmptyMessage = new TestEmptyMessage();
otherEmptyMessage = emptyMessage.Clone();
Assert.AreEqual(emptyMessage.CalculateSize(), otherEmptyMessage.CalculateSize());
Assert.AreEqual(emptyMessage.ToByteArray(), otherEmptyMessage.ToByteArray());
var message = SampleMessages.CreateFullTestAllTypes();
emptyMessage.MergeFrom(message.ToByteArray());
otherEmptyMessage = emptyMessage.Clone();
Assert.AreEqual(message.CalculateSize(), otherEmptyMessage.CalculateSize());
Assert.AreEqual(message.ToByteArray(), otherEmptyMessage.ToByteArray());
}
}
}
...@@ -424,7 +424,10 @@ namespace Google.Protobuf ...@@ -424,7 +424,10 @@ namespace Google.Protobuf
} }
} }
private void SkipGroup(uint startGroupTag) /// <summary>
/// Skip a group.
/// </summary>
internal void SkipGroup(uint startGroupTag)
{ {
// Note: Currently we expect this to be the way that groups are read. We could put the recursion // Note: Currently we expect this to be the way that groups are read. We could put the recursion
// depth changes into the ReadTag method instead, potentially... // depth changes into the ReadTag method instead, potentially...
...@@ -1270,7 +1273,6 @@ namespace Google.Protobuf ...@@ -1270,7 +1273,6 @@ namespace Google.Protobuf
} }
} }
} }
#endregion #endregion
} }
} }
\ No newline at end of file
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2017 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Google.Protobuf.Collections
{
/// <summary>
/// Utility to compare if two Lists are the same, and the hash code
/// of a List.
/// </summary>
public static class Lists
{
/// <summary>
/// Checks if two lists are equal.
/// </summary>
public static bool Equals<T>(List<T> left, List<T> right)
{
if (left == right)
{
return true;
}
if (left == null || right == null)
{
return false;
}
if (left.Count != right.Count)
{
return false;
}
IEqualityComparer<T> comparer = EqualityComparer<T>.Default;
for (int i = 0; i < left.Count; i++)
{
if (!comparer.Equals(left[i], right[i]))
{
return false;
}
}
return true;
}
/// <summary>
/// Gets the list's hash code.
/// </summary>
public static int GetHashCode<T>(List<T> list)
{
if (list == null)
{
return 0;
}
int hash = 31;
foreach (T element in list)
{
hash = hash * 29 + element.GetHashCode();
}
return hash;
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -119,6 +119,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -119,6 +119,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class Any : pb::IMessage<Any> { public sealed partial class Any : pb::IMessage<Any> {
private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any()); private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Any> Parser { get { return _parser; } } public static pb::MessageParser<Any> Parser { get { return _parser; } }
...@@ -143,6 +144,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -143,6 +144,7 @@ namespace Google.Protobuf.WellKnownTypes {
public Any(Any other) : this() { public Any(Any other) : this() {
typeUrl_ = other.typeUrl_; typeUrl_ = other.typeUrl_;
value_ = other.value_; value_ = other.value_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -218,7 +220,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -218,7 +220,7 @@ namespace Google.Protobuf.WellKnownTypes {
} }
if (TypeUrl != other.TypeUrl) return false; if (TypeUrl != other.TypeUrl) return false;
if (Value != other.Value) return false; if (Value != other.Value) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -226,6 +228,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -226,6 +228,9 @@ namespace Google.Protobuf.WellKnownTypes {
int hash = 1; int hash = 1;
if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode();
if (Value.Length != 0) hash ^= Value.GetHashCode(); if (Value.Length != 0) hash ^= Value.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -244,6 +249,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -244,6 +249,9 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(18); output.WriteRawTag(18);
output.WriteBytes(Value); output.WriteBytes(Value);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -255,6 +263,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -255,6 +263,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (Value.Length != 0) { if (Value.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -269,6 +280,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -269,6 +280,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other.Value.Length != 0) { if (other.Value.Length != 0) {
Value = other.Value; Value = other.Value;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -277,7 +289,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -277,7 +289,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
TypeUrl = input.ReadString(); TypeUrl = input.ReadString();
......
...@@ -64,6 +64,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -64,6 +64,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class Api : pb::IMessage<Api> { public sealed partial class Api : pb::IMessage<Api> {
private static readonly pb::MessageParser<Api> _parser = new pb::MessageParser<Api>(() => new Api()); private static readonly pb::MessageParser<Api> _parser = new pb::MessageParser<Api>(() => new Api());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Api> Parser { get { return _parser; } } public static pb::MessageParser<Api> Parser { get { return _parser; } }
...@@ -93,6 +94,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -93,6 +94,7 @@ namespace Google.Protobuf.WellKnownTypes {
SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null;
mixins_ = other.mixins_.Clone(); mixins_ = other.mixins_.Clone();
syntax_ = other.syntax_; syntax_ = other.syntax_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -235,7 +237,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -235,7 +237,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (!object.Equals(SourceContext, other.SourceContext)) return false; if (!object.Equals(SourceContext, other.SourceContext)) return false;
if(!mixins_.Equals(other.mixins_)) return false; if(!mixins_.Equals(other.mixins_)) return false;
if (Syntax != other.Syntax) return false; if (Syntax != other.Syntax) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -248,6 +250,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -248,6 +250,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
hash ^= mixins_.GetHashCode(); hash ^= mixins_.GetHashCode();
if (Syntax != 0) hash ^= Syntax.GetHashCode(); if (Syntax != 0) hash ^= Syntax.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -277,6 +282,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -277,6 +282,9 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(56); output.WriteRawTag(56);
output.WriteEnum((int) Syntax); output.WriteEnum((int) Syntax);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -297,6 +305,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -297,6 +305,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (Syntax != 0) { if (Syntax != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -323,6 +334,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -323,6 +334,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other.Syntax != 0) { if (other.Syntax != 0) {
Syntax = other.Syntax; Syntax = other.Syntax;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -331,7 +343,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -331,7 +343,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
Name = input.ReadString(); Name = input.ReadString();
...@@ -375,6 +387,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -375,6 +387,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class Method : pb::IMessage<Method> { public sealed partial class Method : pb::IMessage<Method> {
private static readonly pb::MessageParser<Method> _parser = new pb::MessageParser<Method>(() => new Method()); private static readonly pb::MessageParser<Method> _parser = new pb::MessageParser<Method>(() => new Method());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Method> Parser { get { return _parser; } } public static pb::MessageParser<Method> Parser { get { return _parser; } }
...@@ -404,6 +417,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -404,6 +417,7 @@ namespace Google.Protobuf.WellKnownTypes {
responseStreaming_ = other.responseStreaming_; responseStreaming_ = other.responseStreaming_;
options_ = other.options_.Clone(); options_ = other.options_.Clone();
syntax_ = other.syntax_; syntax_ = other.syntax_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -528,7 +542,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -528,7 +542,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (ResponseStreaming != other.ResponseStreaming) return false; if (ResponseStreaming != other.ResponseStreaming) return false;
if(!options_.Equals(other.options_)) return false; if(!options_.Equals(other.options_)) return false;
if (Syntax != other.Syntax) return false; if (Syntax != other.Syntax) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -541,6 +555,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -541,6 +555,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode(); if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode();
hash ^= options_.GetHashCode(); hash ^= options_.GetHashCode();
if (Syntax != 0) hash ^= Syntax.GetHashCode(); if (Syntax != 0) hash ^= Syntax.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -576,6 +593,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -576,6 +593,9 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(56); output.WriteRawTag(56);
output.WriteEnum((int) Syntax); output.WriteEnum((int) Syntax);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -600,6 +620,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -600,6 +620,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (Syntax != 0) { if (Syntax != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -627,6 +650,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -627,6 +650,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other.Syntax != 0) { if (other.Syntax != 0) {
Syntax = other.Syntax; Syntax = other.Syntax;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -635,7 +659,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -635,7 +659,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
Name = input.ReadString(); Name = input.ReadString();
...@@ -753,6 +777,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -753,6 +777,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class Mixin : pb::IMessage<Mixin> { public sealed partial class Mixin : pb::IMessage<Mixin> {
private static readonly pb::MessageParser<Mixin> _parser = new pb::MessageParser<Mixin>(() => new Mixin()); private static readonly pb::MessageParser<Mixin> _parser = new pb::MessageParser<Mixin>(() => new Mixin());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Mixin> Parser { get { return _parser; } } public static pb::MessageParser<Mixin> Parser { get { return _parser; } }
...@@ -777,6 +802,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -777,6 +802,7 @@ namespace Google.Protobuf.WellKnownTypes {
public Mixin(Mixin other) : this() { public Mixin(Mixin other) : this() {
name_ = other.name_; name_ = other.name_;
root_ = other.root_; root_ = other.root_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -828,7 +854,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -828,7 +854,7 @@ namespace Google.Protobuf.WellKnownTypes {
} }
if (Name != other.Name) return false; if (Name != other.Name) return false;
if (Root != other.Root) return false; if (Root != other.Root) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -836,6 +862,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -836,6 +862,9 @@ namespace Google.Protobuf.WellKnownTypes {
int hash = 1; int hash = 1;
if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Root.Length != 0) hash ^= Root.GetHashCode(); if (Root.Length != 0) hash ^= Root.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -854,6 +883,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -854,6 +883,9 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(18); output.WriteRawTag(18);
output.WriteString(Root); output.WriteString(Root);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -865,6 +897,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -865,6 +897,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (Root.Length != 0) { if (Root.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Root); size += 1 + pb::CodedOutputStream.ComputeStringSize(Root);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -879,6 +914,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -879,6 +914,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other.Root.Length != 0) { if (other.Root.Length != 0) {
Root = other.Root; Root = other.Root;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -887,7 +923,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -887,7 +923,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
Name = input.ReadString(); Name = input.ReadString();
......
...@@ -100,6 +100,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -100,6 +100,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class Duration : pb::IMessage<Duration> { public sealed partial class Duration : pb::IMessage<Duration> {
private static readonly pb::MessageParser<Duration> _parser = new pb::MessageParser<Duration>(() => new Duration()); private static readonly pb::MessageParser<Duration> _parser = new pb::MessageParser<Duration>(() => new Duration());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Duration> Parser { get { return _parser; } } public static pb::MessageParser<Duration> Parser { get { return _parser; } }
...@@ -124,6 +125,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -124,6 +125,7 @@ namespace Google.Protobuf.WellKnownTypes {
public Duration(Duration other) : this() { public Duration(Duration other) : this() {
seconds_ = other.seconds_; seconds_ = other.seconds_;
nanos_ = other.nanos_; nanos_ = other.nanos_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -181,7 +183,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -181,7 +183,7 @@ namespace Google.Protobuf.WellKnownTypes {
} }
if (Seconds != other.Seconds) return false; if (Seconds != other.Seconds) return false;
if (Nanos != other.Nanos) return false; if (Nanos != other.Nanos) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -189,6 +191,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -189,6 +191,9 @@ namespace Google.Protobuf.WellKnownTypes {
int hash = 1; int hash = 1;
if (Seconds != 0L) hash ^= Seconds.GetHashCode(); if (Seconds != 0L) hash ^= Seconds.GetHashCode();
if (Nanos != 0) hash ^= Nanos.GetHashCode(); if (Nanos != 0) hash ^= Nanos.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -207,6 +212,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -207,6 +212,9 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(16); output.WriteRawTag(16);
output.WriteInt32(Nanos); output.WriteInt32(Nanos);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -218,6 +226,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -218,6 +226,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (Nanos != 0) { if (Nanos != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -232,6 +243,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -232,6 +243,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other.Nanos != 0) { if (other.Nanos != 0) {
Nanos = other.Nanos; Nanos = other.Nanos;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -240,7 +252,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -240,7 +252,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
Seconds = input.ReadInt64(); Seconds = input.ReadInt64();
......
...@@ -50,6 +50,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -50,6 +50,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class Empty : pb::IMessage<Empty> { public sealed partial class Empty : pb::IMessage<Empty> {
private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty()); private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Empty> Parser { get { return _parser; } } public static pb::MessageParser<Empty> Parser { get { return _parser; } }
...@@ -72,6 +73,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -72,6 +73,7 @@ namespace Google.Protobuf.WellKnownTypes {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Empty(Empty other) : this() { public Empty(Empty other) : this() {
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -92,12 +94,15 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -92,12 +94,15 @@ namespace Google.Protobuf.WellKnownTypes {
if (ReferenceEquals(other, this)) { if (ReferenceEquals(other, this)) {
return true; return true;
} }
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -108,11 +113,17 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -108,11 +113,17 @@ namespace Google.Protobuf.WellKnownTypes {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -121,6 +132,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -121,6 +132,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other == null) { if (other == null) {
return; return;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -129,7 +141,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -129,7 +141,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
} }
} }
......
...@@ -248,6 +248,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -248,6 +248,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class FieldMask : pb::IMessage<FieldMask> { public sealed partial class FieldMask : pb::IMessage<FieldMask> {
private static readonly pb::MessageParser<FieldMask> _parser = new pb::MessageParser<FieldMask>(() => new FieldMask()); private static readonly pb::MessageParser<FieldMask> _parser = new pb::MessageParser<FieldMask>(() => new FieldMask());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<FieldMask> Parser { get { return _parser; } } public static pb::MessageParser<FieldMask> Parser { get { return _parser; } }
...@@ -271,6 +272,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -271,6 +272,7 @@ namespace Google.Protobuf.WellKnownTypes {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public FieldMask(FieldMask other) : this() { public FieldMask(FieldMask other) : this() {
paths_ = other.paths_.Clone(); paths_ = other.paths_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -305,13 +307,16 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -305,13 +307,16 @@ namespace Google.Protobuf.WellKnownTypes {
return true; return true;
} }
if(!paths_.Equals(other.paths_)) return false; if(!paths_.Equals(other.paths_)) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
hash ^= paths_.GetHashCode(); hash ^= paths_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -323,12 +328,18 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -323,12 +328,18 @@ namespace Google.Protobuf.WellKnownTypes {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
paths_.WriteTo(output, _repeated_paths_codec); paths_.WriteTo(output, _repeated_paths_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
size += paths_.CalculateSize(_repeated_paths_codec); size += paths_.CalculateSize(_repeated_paths_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -338,6 +349,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -338,6 +349,7 @@ namespace Google.Protobuf.WellKnownTypes {
return; return;
} }
paths_.Add(other.paths_); paths_.Add(other.paths_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -346,7 +358,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -346,7 +358,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
paths_.AddEntriesFrom(input, _repeated_paths_codec); paths_.AddEntriesFrom(input, _repeated_paths_codec);
......
...@@ -44,6 +44,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -44,6 +44,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class SourceContext : pb::IMessage<SourceContext> { public sealed partial class SourceContext : pb::IMessage<SourceContext> {
private static readonly pb::MessageParser<SourceContext> _parser = new pb::MessageParser<SourceContext>(() => new SourceContext()); private static readonly pb::MessageParser<SourceContext> _parser = new pb::MessageParser<SourceContext>(() => new SourceContext());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<SourceContext> Parser { get { return _parser; } } public static pb::MessageParser<SourceContext> Parser { get { return _parser; } }
...@@ -67,6 +68,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -67,6 +68,7 @@ namespace Google.Protobuf.WellKnownTypes {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public SourceContext(SourceContext other) : this() { public SourceContext(SourceContext other) : this() {
fileName_ = other.fileName_; fileName_ = other.fileName_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -103,13 +105,16 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -103,13 +105,16 @@ namespace Google.Protobuf.WellKnownTypes {
return true; return true;
} }
if (FileName != other.FileName) return false; if (FileName != other.FileName) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (FileName.Length != 0) hash ^= FileName.GetHashCode(); if (FileName.Length != 0) hash ^= FileName.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -124,6 +129,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -124,6 +129,9 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(10); output.WriteRawTag(10);
output.WriteString(FileName); output.WriteString(FileName);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -132,6 +140,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -132,6 +140,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (FileName.Length != 0) { if (FileName.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(FileName); size += 1 + pb::CodedOutputStream.ComputeStringSize(FileName);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -143,6 +154,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -143,6 +154,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other.FileName.Length != 0) { if (other.FileName.Length != 0) {
FileName = other.FileName; FileName = other.FileName;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -151,7 +163,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -151,7 +163,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 10: { case 10: {
FileName = input.ReadString(); FileName = input.ReadString();
......
...@@ -119,6 +119,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -119,6 +119,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// </summary> /// </summary>
public sealed partial class Timestamp : pb::IMessage<Timestamp> { public sealed partial class Timestamp : pb::IMessage<Timestamp> {
private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp()); private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Timestamp> Parser { get { return _parser; } } public static pb::MessageParser<Timestamp> Parser { get { return _parser; } }
...@@ -143,6 +144,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -143,6 +144,7 @@ namespace Google.Protobuf.WellKnownTypes {
public Timestamp(Timestamp other) : this() { public Timestamp(Timestamp other) : this() {
seconds_ = other.seconds_; seconds_ = other.seconds_;
nanos_ = other.nanos_; nanos_ = other.nanos_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -198,7 +200,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -198,7 +200,7 @@ namespace Google.Protobuf.WellKnownTypes {
} }
if (Seconds != other.Seconds) return false; if (Seconds != other.Seconds) return false;
if (Nanos != other.Nanos) return false; if (Nanos != other.Nanos) return false;
return true; return Equals(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -206,6 +208,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -206,6 +208,9 @@ namespace Google.Protobuf.WellKnownTypes {
int hash = 1; int hash = 1;
if (Seconds != 0L) hash ^= Seconds.GetHashCode(); if (Seconds != 0L) hash ^= Seconds.GetHashCode();
if (Nanos != 0) hash ^= Nanos.GetHashCode(); if (Nanos != 0) hash ^= Nanos.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash; return hash;
} }
...@@ -224,6 +229,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -224,6 +229,9 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(16); output.WriteRawTag(16);
output.WriteInt32(Nanos); output.WriteInt32(Nanos);
} }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -235,6 +243,9 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -235,6 +243,9 @@ namespace Google.Protobuf.WellKnownTypes {
if (Nanos != 0) { if (Nanos != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos);
} }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size; return size;
} }
...@@ -249,6 +260,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -249,6 +260,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (other.Nanos != 0) { if (other.Nanos != 0) {
Nanos = other.Nanos; Nanos = other.Nanos;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -257,7 +269,7 @@ namespace Google.Protobuf.WellKnownTypes { ...@@ -257,7 +269,7 @@ namespace Google.Protobuf.WellKnownTypes {
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
switch(tag) { switch(tag) {
default: default:
input.SkipLastField(); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
Seconds = input.ReadInt64(); Seconds = input.ReadInt64();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment