diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index d3e1ea95344f..c05125c629cd 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -260,7 +260,9 @@ public sealed partial class Person : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -440,7 +442,9 @@ public sealed partial class PhoneNumber : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Number = input.ReadString(); @@ -573,7 +577,9 @@ public sealed partial class AddressBook : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { people_.AddEntriesFrom(input, _repeated_people_codec); diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs index cd9b77abe5fc..1642669e92ca 100644 --- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs +++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs @@ -343,7 +343,9 @@ public enum PayloadOneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { ProtobufPayload = input.ReadBytes(); @@ -683,7 +685,9 @@ public enum ResultOneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { ParseError = input.ReadString(); diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs index 6d3cd026d112..2844ca62ce4e 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs @@ -541,7 +541,9 @@ public sealed partial class TestMap : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); @@ -737,7 +739,9 @@ public sealed partial class TestMapSubmessage : pb::IMessage while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { if (testMap_ == null) { @@ -861,7 +865,9 @@ public sealed partial class TestMessageMap : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec); @@ -1001,7 +1007,9 @@ public sealed partial class TestSameTypeMap : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { map1_.AddEntriesFrom(input, _map_map1_codec); @@ -1350,7 +1358,9 @@ public sealed partial class TestArenaMap : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); @@ -1531,7 +1541,9 @@ public sealed partial class MessageContainingEnumCalledType : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { A = input.ReadInt32(); @@ -3723,7 +3727,9 @@ public sealed partial class ForeignMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { C = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs index 2a9efe55fff1..9b9ffe256005 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs @@ -352,7 +352,9 @@ public enum AnOneofOneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Field1 = input.ReadString(); @@ -478,7 +480,9 @@ public sealed partial class CustomOptionFooRequest : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { I = input.ReadInt32(); @@ -2615,7 +2651,9 @@ public sealed partial class AggregateMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Fieldname = input.ReadInt32(); @@ -2723,7 +2761,9 @@ public sealed partial class NestedOptionType : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -2855,7 +2895,9 @@ public sealed partial class NestedMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { NestedField = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs index 6bf97151715e..931dc2eb03a0 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs @@ -167,7 +167,9 @@ public sealed partial class ImportMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { D = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs index 97d181aff48c..fee0120b42d1 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs @@ -155,7 +155,9 @@ public sealed partial class PublicImportMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -284,7 +286,9 @@ public sealed partial class NestedOnce : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -387,7 +391,9 @@ public sealed partial class NestedTwice : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -554,7 +560,9 @@ public sealed partial class NegativeEnumMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -899,7 +909,9 @@ public sealed partial class DeprecatedFieldsMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Item = input.ReadInt32(); @@ -1209,7 +1223,9 @@ public sealed partial class ReservedNames : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Types_ = input.ReadInt32(); @@ -1323,7 +1339,9 @@ public sealed partial class SomeNestedType : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -1647,7 +1665,9 @@ public enum O2OneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { PlainString = input.ReadString(); @@ -1847,7 +1867,9 @@ public sealed partial class TestJsonName : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -2047,7 +2069,9 @@ public enum ValueOneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Text = input.ReadString(); @@ -2211,7 +2235,9 @@ public sealed partial class Nested : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { X = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs index bbbee22c7b6a..1d4367b78151 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs @@ -1387,7 +1387,9 @@ public enum OneofFieldOneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { SingleInt32 = input.ReadInt32(); @@ -1755,7 +1757,9 @@ public sealed partial class NestedMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Bb = input.ReadInt32(); @@ -1938,7 +1942,9 @@ public sealed partial class NestedTestAllTypes : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { C = input.ReadInt32(); @@ -2320,7 +2330,9 @@ public sealed partial class TestReservedFields : pb::IMessage while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { if (foreignNested_ == null) { @@ -2614,7 +2628,9 @@ public sealed partial class TestReallyLargeTagNumber : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Bb = input.ReadInt32(); @@ -4037,7 +4067,9 @@ public sealed partial class SparseEnumMessage : pb::IMessage while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { SparseEnum = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum(); @@ -4169,7 +4201,9 @@ public sealed partial class OneString : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Data = input.ReadString(); @@ -4290,7 +4324,9 @@ public sealed partial class MoreString : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { data_.AddEntriesFrom(input, _repeated_data_codec); @@ -4419,7 +4455,9 @@ public sealed partial class OneBytes : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Data = input.ReadBytes(); @@ -4548,7 +4586,9 @@ public sealed partial class MoreBytes : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Data = input.ReadBytes(); @@ -4680,7 +4720,9 @@ public sealed partial class Int32Message : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Data = input.ReadInt32(); @@ -4809,7 +4851,9 @@ public sealed partial class Uint32Message : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Data = input.ReadUInt32(); @@ -4938,7 +4982,9 @@ public sealed partial class Int64Message : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Data = input.ReadInt64(); @@ -5067,7 +5113,9 @@ public sealed partial class Uint64Message : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Data = input.ReadUInt64(); @@ -5196,7 +5244,9 @@ public sealed partial class BoolMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Data = input.ReadBool(); @@ -5413,7 +5463,9 @@ public enum FooOneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { FooInt = input.ReadInt32(); @@ -5755,7 +5807,9 @@ public sealed partial class TestPackedTypes : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 722: case 720: { @@ -6154,7 +6208,9 @@ public sealed partial class TestUnpackedTypes : pb::IMessage while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 722: case 720: { @@ -6435,7 +6491,9 @@ public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -6802,7 +6864,9 @@ public sealed partial class FooResponse : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -6903,7 +6967,9 @@ public sealed partial class FooClientMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -7004,7 +7070,9 @@ public sealed partial class FooServerMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -7105,7 +7173,9 @@ public sealed partial class BarRequest : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -7206,7 +7276,9 @@ public sealed partial class BarResponse : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -7307,7 +7379,9 @@ public sealed partial class TestEmptyMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } @@ -7438,7 +7512,9 @@ public sealed partial class CommentMessage : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Text = input.ReadString(); @@ -7585,7 +7661,9 @@ public sealed partial class NestedCommentMessage : pb::IMessage while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { anyField_.AddEntriesFrom(input, _map_anyField_codec); diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index 94ff381705ad..69950675d86e 100644 Binary files a/csharp/src/Google.Protobuf.Test/testprotos.pb and b/csharp/src/Google.Protobuf.Test/testprotos.pb differ diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs index 0a829545e257..0428fb54e672 100644 --- a/csharp/src/Google.Protobuf/CodedInputStream.cs +++ b/csharp/src/Google.Protobuf/CodedInputStream.cs @@ -373,7 +373,7 @@ public uint ReadTag() if (IsAtEnd) { lastTag = 0; - return 0; // This is the only case in which we return 0. + return 0; } lastTag = ReadRawVarint32(); @@ -383,6 +383,10 @@ public uint ReadTag() // If we actually read a tag with a field of 0, that's not a valid tag. throw InvalidProtocolBufferException.InvalidTag(); } + if (ReachedLimit) + { + return 0; + } return lastTag; } @@ -591,6 +595,20 @@ public void ReadMessage(IMessage builder) PopLimit(oldLimit); } + /// + /// Reads an embedded group field from the stream. + /// + public void ReadGroup(IMessage builder) + { + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + ++recursionDepth; + builder.MergeFrom(this); + --recursionDepth; + } + /// /// Reads a bytes field value from the stream. /// diff --git a/csharp/src/Google.Protobuf/CodedOutputStream.cs b/csharp/src/Google.Protobuf/CodedOutputStream.cs index 6211aac32cb1..f9ad29086bda 100644 --- a/csharp/src/Google.Protobuf/CodedOutputStream.cs +++ b/csharp/src/Google.Protobuf/CodedOutputStream.cs @@ -303,6 +303,15 @@ public void WriteMessage(IMessage value) value.WriteTo(this); } + /// + /// Writes a group, without a tag, to the stream. + /// + /// The value to write + public void WriteGroup(IMessage value) + { + value.WriteTo(this); + } + /// /// Write a byte string, without a tag, to the stream. /// The data is length-prefixed. diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs index 613ca9c48e7f..827bc711832b 100644 --- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs +++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs @@ -208,6 +208,10 @@ public void WriteTo(CodedOutputStream output, FieldCodec codec) { output.WriteTag(tag); writer(output, array[i]); + if (codec.EndTag != 0) + { + output.WriteTag(codec.EndTag); + } } } } diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs index a11f2420e313..221ad5fd2d50 100644 --- a/csharp/src/Google.Protobuf/FieldCodec.cs +++ b/csharp/src/Google.Protobuf/FieldCodec.cs @@ -225,6 +225,19 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func output.WriteMessage(value), message => CodedOutputStream.ComputeMessageSize(message), tag); } + /// + /// Retrieves a codec suitable for a group field with the given tag. + /// + /// The start group tag. + /// The end group tag. + /// A parser to use for the group message type. + /// A codec for given tag + public static FieldCodec ForGroup(uint startTag, uint endTag, MessageParser parser) where T : IMessage + { + return new FieldCodec(input => { T message = parser.CreateTemplate(); input.ReadGroup(message); return message; }, + (output, value) => output.WriteGroup(value), message => CodedOutputStream.ComputeGroupSize(message), startTag, endTag); + } + /// /// Creates a codec for a wrapper type of a class - which must be string or ByteString. /// @@ -235,7 +248,7 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func WrapperCodecs.Read(input, nestedCodec), (output, value) => WrapperCodecs.Write(output, value, nestedCodec), value => WrapperCodecs.CalculateSize(value, nestedCodec), - tag, + tag, 0, null); // Default value for the wrapper } @@ -250,7 +263,7 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func WrapperCodecs.Read(input, nestedCodec), (output, value) => WrapperCodecs.Write(output, value.Value, nestedCodec), value => value == null ? 0 : WrapperCodecs.CalculateSize(value.Value, nestedCodec), - tag, + tag, 0, null); // Default value for the wrapper } @@ -399,6 +412,14 @@ static FieldCodec() /// internal uint Tag { get; } + /// + /// Gets the end tag of the codec or 0 if there is no end tag + /// + /// + /// The end tag of the codec. + /// + internal uint EndTag { get; } + /// /// Default value for this codec. Usually the same for every instance of the same type, but /// for string/ByteString wrapper fields the codec's default value is null, whereas for @@ -424,7 +445,8 @@ static FieldCodec() Func reader, Action writer, Func sizeCalculator, - uint tag) : this(reader, writer, sizeCalculator, tag, DefaultDefault) + uint tag, + uint endTag = 0) : this(reader, writer, sizeCalculator, tag, endTag, DefaultDefault) { } @@ -433,6 +455,7 @@ static FieldCodec() Action writer, Func sizeCalculator, uint tag, + uint endTag, T defaultValue) { ValueReader = reader; @@ -455,6 +478,10 @@ public void WriteTagAndValue(CodedOutputStream output, T value) { output.WriteTag(Tag); ValueWriter(output, value); + if (EndTag != 0) + { + output.WriteTag(EndTag); + } } } diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index 0c33e63df46a..f101cd35265c 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -302,7 +302,9 @@ internal sealed partial class FileDescriptorSet : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -1357,7 +1363,9 @@ internal sealed partial class ExtensionRange : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Start = input.ReadInt32(); @@ -1560,7 +1568,9 @@ internal sealed partial class ReservedRange : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Start = input.ReadInt32(); @@ -1693,7 +1703,9 @@ internal sealed partial class ExtensionRangeOptions : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { NamePart_ = input.ReadString(); @@ -7315,7 +7345,9 @@ internal sealed partial class SourceCodeInfo : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { location_.AddEntriesFrom(input, _repeated_location_codec); @@ -7623,7 +7655,9 @@ internal sealed partial class Location : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: case 8: { @@ -7776,7 +7810,9 @@ internal sealed partial class GeneratedCodeInfo : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: case 8: { diff --git a/csharp/src/Google.Protobuf/UnknownField.cs b/csharp/src/Google.Protobuf/UnknownField.cs index 0d6eed6357a8..2b13fdb3ec6a 100644 --- a/csharp/src/Google.Protobuf/UnknownField.cs +++ b/csharp/src/Google.Protobuf/UnknownField.cs @@ -55,6 +55,7 @@ internal sealed class UnknownField private List fixed32List; private List fixed64List; private List lengthDelimitedList; + private List groupList; /// /// Creates a new UnknownField. @@ -77,7 +78,8 @@ public override bool Equals(object other) && Lists.Equals(varintList, otherField.varintList) && Lists.Equals(fixed32List, otherField.fixed32List) && Lists.Equals(fixed64List, otherField.fixed64List) - && Lists.Equals(lengthDelimitedList, otherField.lengthDelimitedList); + && Lists.Equals(lengthDelimitedList, otherField.lengthDelimitedList) + && Lists.Equals(groupList, otherField.groupList); } /// @@ -90,6 +92,7 @@ public override int GetHashCode() hash = hash * 47 + Lists.GetHashCode(fixed32List); hash = hash * 47 + Lists.GetHashCode(fixed64List); hash = hash * 47 + Lists.GetHashCode(lengthDelimitedList); + hash = hash * 47 + Lists.GetHashCode(groupList); return hash; } @@ -133,6 +136,15 @@ internal void WriteTo(int fieldNumber, CodedOutputStream output) output.WriteBytes(value); } } + if (groupList != null) + { + foreach (UnknownFieldSet value in groupList) + { + output.WriteTag(fieldNumber, WireFormat.WireType.StartGroup); + value.WriteTo(output); + output.WriteTag(fieldNumber, WireFormat.WireType.EndGroup); + } + } } /// @@ -168,6 +180,14 @@ internal int GetSerializedSize(int fieldNumber) result += CodedOutputStream.ComputeBytesSize(value); } } + if (groupList != null) + { + result += CodedOutputStream.ComputeTagSize(fieldNumber) * 2 * groupList.Count; + foreach (UnknownFieldSet value in groupList) + { + result += value.CalculateSize(); + } + } return result; } @@ -182,6 +202,7 @@ internal UnknownField MergeFrom(UnknownField other) fixed32List = AddAll(fixed32List, other.fixed32List); fixed64List = AddAll(fixed64List, other.fixed64List); lengthDelimitedList = AddAll(lengthDelimitedList, other.lengthDelimitedList); + groupList = AddAll(groupList, other.groupList); return this; } @@ -245,6 +266,12 @@ internal UnknownField AddLengthDelimited(ByteString value) return this; } + internal UnknownField AddGroup(UnknownFieldSet value) + { + groupList = Add(groupList, value); + return this; + } + /// /// Adds to the , creating /// a new list if is null. The list is returned - either diff --git a/csharp/src/Google.Protobuf/UnknownFieldSet.cs b/csharp/src/Google.Protobuf/UnknownFieldSet.cs index 6404c3c08f85..9121567621a1 100644 --- a/csharp/src/Google.Protobuf/UnknownFieldSet.cs +++ b/csharp/src/Google.Protobuf/UnknownFieldSet.cs @@ -183,7 +183,7 @@ internal UnknownFieldSet AddOrReplaceField(int number, UnknownField field) /// /// The coded input stream containing the field /// false if the tag is an "end group" tag, true otherwise - private void MergeFieldFrom(CodedInputStream input) + private bool MergeFieldFrom(CodedInputStream input) { uint tag = input.LastTag; int number = WireFormat.GetTagFieldNumber(tag); @@ -193,34 +193,40 @@ private void MergeFieldFrom(CodedInputStream input) { ulong uint64 = input.ReadUInt64(); GetOrAddField(number).AddVarint(uint64); - return; + return true; } case WireFormat.WireType.Fixed32: { uint uint32 = input.ReadFixed32(); GetOrAddField(number).AddFixed32(uint32); - return; + return true; } case WireFormat.WireType.Fixed64: { ulong uint64 = input.ReadFixed64(); GetOrAddField(number).AddFixed64(uint64); - return; + return true; } case WireFormat.WireType.LengthDelimited: { ByteString bytes = input.ReadBytes(); GetOrAddField(number).AddLengthDelimited(bytes); - return; + return true; } case WireFormat.WireType.StartGroup: { - input.SkipGroup(tag); - return; + uint endTag = WireFormat.MakeTag(number, WireFormat.WireType.EndGroup); + UnknownFieldSet set = new UnknownFieldSet(); + while (input.ReadTag() != endTag) + { + set.MergeFieldFrom(input); + } + GetOrAddField(number).AddGroup(set); + return true; } case WireFormat.WireType.EndGroup: { - throw new InvalidProtocolBufferException("Merge an unknown field of end-group tag, indicating that the corresponding start-group was missing."); + return false; } default: throw new InvalidOperationException("Wire Type is invalid."); @@ -248,8 +254,34 @@ private void MergeFieldFrom(CodedInputStream input) { unknownFields = new UnknownFieldSet(); } - unknownFields.MergeFieldFrom(input); + if (!unknownFields.MergeFieldFrom(input)) + { + throw new InvalidProtocolBufferException("Merge an unknown field of end-group tag, indicating that the corresponding start-group was missing."); // match the old code-gen + } return unknownFields; + } + + /// + /// Create a new UnknownFieldSet if unknownFields is null. + /// Parse a single field from and merge it + /// into unknownFields. If is configured to discard unknown fields, + /// will be returned as-is and the field will be skipped. + /// + /// The UnknownFieldSet which need to be merged + /// The coded input stream containing the field + /// The merged UnknownFieldSet + public static bool MergeFieldFrom(ref UnknownFieldSet unknownFields, CodedInputStream input) + { + if (input.DiscardUnknownFields) + { + input.SkipLastField(); + return true; + } + if (unknownFields == null) + { + unknownFields = new UnknownFieldSet(); + } + return unknownFields.MergeFieldFrom(input); } /// diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index dd9911067ed9..b1ed0bc3077c 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -292,7 +292,9 @@ public sealed partial class Any : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { TypeUrl = input.ReadString(); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index 438e1db8da2f..a566e406403b 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -345,7 +345,9 @@ public sealed partial class Api : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -661,7 +663,9 @@ public sealed partial class Method : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -925,7 +929,9 @@ public sealed partial class Mixin : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index 2858b532b636..691ca334ea2b 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -254,7 +254,9 @@ public sealed partial class Duration : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Seconds = input.ReadInt64(); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs index 2113add9bca1..03ffc4a05776 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs @@ -143,7 +143,9 @@ public sealed partial class Empty : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index 6ad31a50eacc..8114aa3924ef 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -352,7 +352,9 @@ public sealed partial class FieldMask : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { paths_.AddEntriesFrom(input, _repeated_paths_codec); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs index 124ddaa71234..2cae68631df8 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs @@ -165,7 +165,9 @@ public sealed partial class SourceContext : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { FileName = input.ReadString(); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs index 194b81e965e5..9667472522e2 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -189,7 +189,9 @@ public sealed partial class Struct : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { fields_.AddEntriesFrom(input, _map_fields_codec); @@ -513,7 +515,9 @@ public enum KindOneofCase { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { kind_ = input.ReadEnum(); @@ -673,7 +677,9 @@ public sealed partial class ListValue : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { values_.AddEntriesFrom(input, _repeated_values_codec); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs index 984e226fd449..9e37e9dda7de 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs @@ -273,7 +273,9 @@ public sealed partial class Timestamp : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Seconds = input.ReadInt64(); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index 52bd343ba841..adea91063496 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -328,7 +328,9 @@ public sealed partial class Type : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -723,7 +725,9 @@ public sealed partial class Field : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 8: { Kind = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum(); @@ -1100,7 +1104,9 @@ public sealed partial class Enum : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -1300,7 +1306,9 @@ public sealed partial class EnumValue : pb::IMessage { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) { + return; + } break; case 10: { Name = input.ReadString(); @@ -1480,7 +1488,9 @@ public sealed partial class Option : pb::IMessage