From 175c96565f7ed97c07a78da0698c5e929dc7ef0d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 31 Mar 2020 18:55:31 +0200 Subject: [PATCH 01/36] bring in new files --- .../src/Google.Protobuf/CodedInputStream.cs | 1179 ++--------------- csharp/src/Google.Protobuf/IBufferMessage.cs | 63 + csharp/src/Google.Protobuf/ParseContext.cs | 322 +++++ .../Google.Protobuf/ParserInternalState.cs | 116 ++ .../src/Google.Protobuf/ParsingPrimitives.cs | 726 ++++++++++ .../ParsingPrimitivesMessages.cs | 231 ++++ .../ParsingPrimitivesWrappers.cs | 352 +++++ .../Google.Protobuf/SegmentedBufferHelper.cs | 283 ++++ 8 files changed, 2196 insertions(+), 1076 deletions(-) create mode 100644 csharp/src/Google.Protobuf/IBufferMessage.cs create mode 100644 csharp/src/Google.Protobuf/ParseContext.cs create mode 100644 csharp/src/Google.Protobuf/ParserInternalState.cs create mode 100644 csharp/src/Google.Protobuf/ParsingPrimitives.cs create mode 100644 csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs create mode 100644 csharp/src/Google.Protobuf/ParsingPrimitivesWrappers.cs create mode 100644 csharp/src/Google.Protobuf/SegmentedBufferHelper.cs diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs index 9976f58234..248f7e4a3d 100644 --- a/csharp/src/Google.Protobuf/CodedInputStream.cs +++ b/csharp/src/Google.Protobuf/CodedInputStream.cs @@ -34,6 +34,9 @@ using Google.Protobuf.Collections; using System; using System.Collections.Generic; using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; namespace Google.Protobuf { @@ -64,17 +67,6 @@ namespace Google.Protobuf /// private readonly byte[] buffer; - /// - /// The index of the buffer at which we need to refill from the stream (if there is one). - /// - private int bufferSize; - - private int bufferSizeAfterLimit = 0; - /// - /// The position within the current buffer (i.e. the next byte to read) - /// - private int bufferPos = 0; - /// /// The stream to read further input from, or null if the byte array buffer was provided /// directly on construction, with no further data available. @@ -82,38 +74,15 @@ namespace Google.Protobuf private readonly Stream input; /// - /// The last tag we read. 0 indicates we've read to the end of the stream - /// (or haven't read anything yet). + /// The parser state is kept separately so that other parse implementations can reuse the same + /// parsing primitives. /// - private uint lastTag = 0; - - /// - /// The next tag, used to store the value read by PeekTag. - /// - private uint nextTag = 0; - private bool hasNextTag = false; + private ParserInternalState state; internal const int DefaultRecursionLimit = 100; internal const int DefaultSizeLimit = Int32.MaxValue; internal const int BufferSize = 4096; - /// - /// The total number of bytes read before the current buffer. The - /// total bytes read up to the current position can be computed as - /// totalBytesRetired + bufferPos. - /// - private int totalBytesRetired = 0; - - /// - /// The absolute position of the end of the current message. - /// - private int currentLimit = int.MaxValue; - - private int recursionDepth = 0; - - private readonly int recursionLimit; - private readonly int sizeLimit; - #region Construction // Note that the checks are performed such that we don't end up checking obviously-valid things // like non-null references for arrays we've just created. @@ -170,11 +139,15 @@ namespace Google.Protobuf { this.input = input; this.buffer = buffer; - this.bufferPos = bufferPos; - this.bufferSize = bufferSize; - this.sizeLimit = DefaultSizeLimit; - this.recursionLimit = DefaultRecursionLimit; + this.state.bufferPos = bufferPos; + this.state.bufferSize = bufferSize; + this.state.sizeLimit = DefaultSizeLimit; + this.state.recursionLimit = DefaultRecursionLimit; + this.state.segmentedBufferHelper = new SegmentedBufferHelper(this); + this.state.codedInputStream = this; this.leaveOpen = leaveOpen; + + this.state.currentLimit = int.MaxValue; } /// @@ -196,8 +169,8 @@ namespace Google.Protobuf { throw new ArgumentOutOfRangeException("recursionLimit!", "Recursion limit must be positive"); } - this.sizeLimit = sizeLimit; - this.recursionLimit = recursionLimit; + this.state.sizeLimit = sizeLimit; + this.state.recursionLimit = recursionLimit; } #endregion @@ -230,9 +203,9 @@ namespace Google.Protobuf { if (input != null) { - return input.Position - ((bufferSize + bufferSizeAfterLimit) - bufferPos); + return input.Position - ((state.bufferSize + state.bufferSizeAfterLimit) - state.bufferPos); } - return bufferPos; + return state.bufferPos; } } @@ -240,7 +213,7 @@ namespace Google.Protobuf /// Returns the last tag read, or 0 if no tags have been read or we've read beyond /// the end of the stream. /// - internal uint LastTag { get { return lastTag; } } + internal uint LastTag { get { return state.lastTag; } } /// /// Returns the size limit for this stream. @@ -253,7 +226,7 @@ namespace Google.Protobuf /// /// The size limit. /// - public int SizeLimit { get { return sizeLimit; } } + public int SizeLimit { get { return state.sizeLimit; } } /// /// Returns the recursion limit for this stream. This limit is applied whilst reading messages, @@ -265,17 +238,31 @@ namespace Google.Protobuf /// /// The recursion limit for this stream. /// - public int RecursionLimit { get { return recursionLimit; } } + public int RecursionLimit { get { return state.recursionLimit; } } /// /// Internal-only property; when set to true, unknown fields will be discarded while parsing. /// - internal bool DiscardUnknownFields { get; set; } + internal bool DiscardUnknownFields + { + get { return state.DiscardUnknownFields; } + set { state.DiscardUnknownFields = value; } + } /// /// Internal-only property; provides extension identifiers to compatible messages while parsing. /// - internal ExtensionRegistry ExtensionRegistry { get; set; } + internal ExtensionRegistry ExtensionRegistry + { + get { return state.ExtensionRegistry; } + set { state.ExtensionRegistry = value; } + } + + internal byte[] InternalBuffer => buffer; + + internal Stream InternalInputStream => input; + + internal ref ParserInternalState InternalState => ref state; /// /// Disposes of this instance, potentially closing any underlying stream. @@ -302,17 +289,7 @@ namespace Google.Protobuf /// tag read was not the one specified internal void CheckReadEndOfStreamTag() { - if (lastTag != 0) - { - throw InvalidProtocolBufferException.MoreDataAvailable(); - } - } - - internal void CheckLastTagWas(uint expectedTag) - { - if (lastTag != expectedTag) { - throw InvalidProtocolBufferException.InvalidEndTag(); - } + ParsingPrimitivesMessages.CheckReadEndOfStreamTag(ref state); } #endregion @@ -325,16 +302,8 @@ namespace Google.Protobuf /// public uint PeekTag() { - if (hasNextTag) - { - return nextTag; - } - - uint savedLast = lastTag; - nextTag = ReadTag(); - hasNextTag = true; - lastTag = savedLast; // Undo the side effect of ReadTag - return nextTag; + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.PeekTag(ref span, ref state); } /// @@ -348,54 +317,8 @@ namespace Google.Protobuf /// The next field tag, or 0 for end of stream. (0 is never a valid tag.) public uint ReadTag() { - if (hasNextTag) - { - lastTag = nextTag; - hasNextTag = false; - return lastTag; - } - - // Optimize for the incredibly common case of having at least two bytes left in the buffer, - // and those two bytes being enough to get the tag. This will be true for fields up to 4095. - if (bufferPos + 2 <= bufferSize) - { - int tmp = buffer[bufferPos++]; - if (tmp < 128) - { - lastTag = (uint)tmp; - } - else - { - int result = tmp & 0x7f; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 7; - lastTag = (uint) result; - } - else - { - // Nope, rewind and go the potentially slow route. - bufferPos -= 2; - lastTag = ReadRawVarint32(); - } - } - } - else - { - if (IsAtEnd) - { - lastTag = 0; - return 0; - } - - lastTag = ReadRawVarint32(); - } - if (WireFormat.GetTagFieldNumber(lastTag) == 0) - { - // If we actually read a tag with a field of 0, that's not a valid tag. - throw InvalidProtocolBufferException.InvalidTag(); - } - return lastTag; + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseTag(ref span, ref state); } /// @@ -413,32 +336,8 @@ namespace Google.Protobuf /// The last read operation read to the end of the logical stream public void SkipLastField() { - if (lastTag == 0) - { - throw new InvalidOperationException("SkipLastField cannot be called at the end of a stream"); - } - switch (WireFormat.GetTagWireType(lastTag)) - { - case WireFormat.WireType.StartGroup: - SkipGroup(lastTag); - break; - case WireFormat.WireType.EndGroup: - throw new InvalidProtocolBufferException( - "SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing"); - case WireFormat.WireType.Fixed32: - ReadFixed32(); - break; - case WireFormat.WireType.Fixed64: - ReadFixed64(); - break; - case WireFormat.WireType.LengthDelimited: - var length = ReadLength(); - SkipRawBytes(length); - break; - case WireFormat.WireType.Varint: - ReadRawVarint32(); - break; - } + var span = new ReadOnlySpan(buffer); + ParsingPrimitivesMessages.SkipLastField(ref span, ref state); } /// @@ -446,37 +345,8 @@ namespace Google.Protobuf /// internal void SkipGroup(uint startGroupTag) { - // 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... - recursionDepth++; - if (recursionDepth >= recursionLimit) - { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); - } - uint tag; - while (true) - { - tag = ReadTag(); - if (tag == 0) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - // Can't call SkipLastField for this case- that would throw. - if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup) - { - break; - } - // This recursion will allow us to handle nested groups. - SkipLastField(); - } - int startField = WireFormat.GetTagFieldNumber(startGroupTag); - int endField = WireFormat.GetTagFieldNumber(tag); - if (startField != endField) - { - throw new InvalidProtocolBufferException( - $"Mismatched end-group tag. Started with field {startField}; ended with field {endField}"); - } - recursionDepth--; + var span = new ReadOnlySpan(buffer); + ParsingPrimitivesMessages.SkipGroup(ref span, ref state, startGroupTag); } /// @@ -484,33 +354,8 @@ namespace Google.Protobuf /// public double ReadDouble() { - if (bufferPos + 8 <= bufferSize) - { - if (BitConverter.IsLittleEndian) - { - var result = BitConverter.ToDouble(buffer, bufferPos); - bufferPos += 8; - return result; - } - else - { - var bytes = new byte[8]; - bytes[0] = buffer[bufferPos + 7]; - bytes[1] = buffer[bufferPos + 6]; - bytes[2] = buffer[bufferPos + 5]; - bytes[3] = buffer[bufferPos + 4]; - bytes[4] = buffer[bufferPos + 3]; - bytes[5] = buffer[bufferPos + 2]; - bytes[6] = buffer[bufferPos + 1]; - bytes[7] = buffer[bufferPos]; - bufferPos += 8; - return BitConverter.ToDouble(bytes, 0); - } - } - else - { - return BitConverter.Int64BitsToDouble((long)ReadRawLittleEndian64()); - } + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseDouble(ref span, ref state); } /// @@ -518,21 +363,8 @@ namespace Google.Protobuf /// public float ReadFloat() { - if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos) - { - float ret = BitConverter.ToSingle(buffer, bufferPos); - bufferPos += 4; - return ret; - } - else - { - byte[] rawBytes = ReadRawBytes(4); - if (!BitConverter.IsLittleEndian) - { - ByteArray.Reverse(rawBytes); - } - return BitConverter.ToSingle(rawBytes, 0); - } + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseFloat(ref span, ref state); } /// @@ -589,21 +421,8 @@ namespace Google.Protobuf public string ReadString() { int length = ReadLength(); - // No need to read any data for an empty string. - if (length == 0) - { - return ""; - } - if (length <= bufferSize - bufferPos && length > 0) - { - // Fast path: We already have the bytes in a contiguous buffer, so - // just copy directly from it. - String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, length); - bufferPos += length; - return result; - } - // Slow path: Build a byte array first then copy it. - return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(length), 0, length); + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ReadRawString(ref span, ref state, length); } /// @@ -611,22 +430,17 @@ namespace Google.Protobuf /// public void ReadMessage(IMessage builder) { - int length = ReadLength(); - if (recursionDepth >= recursionLimit) + var span = new ReadOnlySpan(buffer); + var ctx = new CodedInputReader(ref span, ref state); + try { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); + ParsingPrimitivesMessages.ReadMessage(ref ctx, builder); } - int oldLimit = PushLimit(length); - ++recursionDepth; - builder.MergeFrom(this); - CheckReadEndOfStreamTag(); - // Check that we've read exactly as much data as expected. - if (!ReachedLimit) + finally { - throw InvalidProtocolBufferException.TruncatedMessage(); + // store the state + state = ctx.state; } - --recursionDepth; - PopLimit(oldLimit); } /// @@ -634,33 +448,15 @@ namespace Google.Protobuf /// public void ReadGroup(IMessage builder) { - if (recursionDepth >= recursionLimit) + var ctx = new ParseContext(this); + try { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); + ParsingPrimitivesMessages.ReadGroup(ref ctx, builder); } - ++recursionDepth; - - uint tag = lastTag; - int fieldNumber = WireFormat.GetTagFieldNumber(tag); - - builder.MergeFrom(this); - CheckLastTagWas(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.EndGroup)); - --recursionDepth; - } - - /// - /// Reads an embedded group unknown field from the stream. - /// - internal void ReadGroup(int fieldNumber, UnknownFieldSet set) - { - if (recursionDepth >= recursionLimit) + finally { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); + ctx.CopyStateTo(this); } - ++recursionDepth; - set.MergeGroupFrom(this); - CheckLastTagWas(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.EndGroup)); - --recursionDepth; } /// @@ -669,12 +465,12 @@ namespace Google.Protobuf public ByteString ReadBytes() { int length = ReadLength(); - if (length <= bufferSize - bufferPos && length > 0) + if (length <= state.bufferSize - state.bufferPos && length > 0) { // Fast path: We already have the bytes in a contiguous buffer, so // just copy directly from it. - ByteString result = ByteString.CopyFrom(buffer, bufferPos, length); - bufferPos += length; + ByteString result = ByteString.CopyFrom(buffer, state.bufferPos, length); + state.bufferPos += length; return result; } else @@ -722,7 +518,7 @@ namespace Google.Protobuf /// public int ReadSInt32() { - return DecodeZigZag32(ReadRawVarint32()); + return ParsingPrimitives.DecodeZigZag32(ReadRawVarint32()); } /// @@ -730,7 +526,7 @@ namespace Google.Protobuf /// public long ReadSInt64() { - return DecodeZigZag64(ReadRawVarint64()); + return ParsingPrimitives.DecodeZigZag64(ReadRawVarint64()); } /// @@ -742,7 +538,8 @@ namespace Google.Protobuf /// public int ReadLength() { - return (int) ReadRawVarint32(); + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseLength(ref span, ref state); } /// @@ -752,323 +549,14 @@ namespace Google.Protobuf /// public bool MaybeConsumeTag(uint tag) { - if (PeekTag() == tag) - { - hasNextTag = false; - return true; - } - return false; - } - - internal static float? ReadFloatWrapperLittleEndian(CodedInputStream input) - { - // length:1 + tag:1 + value:4 = 6 bytes - if (input.bufferPos + 6 <= input.bufferSize) - { - // The entire wrapper message is already contained in `buffer`. - int length = input.buffer[input.bufferPos]; - if (length == 0) - { - input.bufferPos++; - return 0F; - } - // tag:1 + value:4 = length of 5 bytes - // field=1, type=32-bit = tag of 13 - if (length != 5 || input.buffer[input.bufferPos + 1] != 13) - { - return ReadFloatWrapperSlow(input); - } - var result = BitConverter.ToSingle(input.buffer, input.bufferPos + 2); - input.bufferPos += 6; - return result; - } - else - { - return ReadFloatWrapperSlow(input); - } - } - - internal static float? ReadFloatWrapperSlow(CodedInputStream input) - { - int length = input.ReadLength(); - if (length == 0) - { - return 0F; - } - int finalBufferPos = input.totalBytesRetired + input.bufferPos + length; - float result = 0F; - do - { - // field=1, type=32-bit = tag of 13 - if (input.ReadTag() == 13) - { - result = input.ReadFloat(); - } - else - { - input.SkipLastField(); - } - } - while (input.totalBytesRetired + input.bufferPos < finalBufferPos); - return result; - } - - internal static double? ReadDoubleWrapperLittleEndian(CodedInputStream input) - { - // length:1 + tag:1 + value:8 = 10 bytes - if (input.bufferPos + 10 <= input.bufferSize) - { - // The entire wrapper message is already contained in `buffer`. - int length = input.buffer[input.bufferPos]; - if (length == 0) - { - input.bufferPos++; - return 0D; - } - // tag:1 + value:8 = length of 9 bytes - // field=1, type=64-bit = tag of 9 - if (length != 9 || input.buffer[input.bufferPos + 1] != 9) - { - return ReadDoubleWrapperSlow(input); - } - var result = BitConverter.ToDouble(input.buffer, input.bufferPos + 2); - input.bufferPos += 10; - return result; - } - else - { - return ReadDoubleWrapperSlow(input); - } - } - - internal static double? ReadDoubleWrapperSlow(CodedInputStream input) - { - int length = input.ReadLength(); - if (length == 0) - { - return 0D; - } - int finalBufferPos = input.totalBytesRetired + input.bufferPos + length; - double result = 0D; - do - { - // field=1, type=64-bit = tag of 9 - if (input.ReadTag() == 9) - { - result = input.ReadDouble(); - } - else - { - input.SkipLastField(); - } - } - while (input.totalBytesRetired + input.bufferPos < finalBufferPos); - return result; - } - - internal static bool? ReadBoolWrapper(CodedInputStream input) - { - return ReadUInt64Wrapper(input) != 0; - } - - internal static uint? ReadUInt32Wrapper(CodedInputStream input) - { - // length:1 + tag:1 + value:5(varint32-max) = 7 bytes - if (input.bufferPos + 7 <= input.bufferSize) - { - // The entire wrapper message is already contained in `buffer`. - int pos0 = input.bufferPos; - int length = input.buffer[input.bufferPos++]; - if (length == 0) - { - return 0; - } - // Length will always fit in a single byte. - if (length >= 128) - { - input.bufferPos = pos0; - return ReadUInt32WrapperSlow(input); - } - int finalBufferPos = input.bufferPos + length; - // field=1, type=varint = tag of 8 - if (input.buffer[input.bufferPos++] != 8) - { - input.bufferPos = pos0; - return ReadUInt32WrapperSlow(input); - } - var result = input.ReadUInt32(); - // Verify this message only contained a single field. - if (input.bufferPos != finalBufferPos) - { - input.bufferPos = pos0; - return ReadUInt32WrapperSlow(input); - } - return result; - } - else - { - return ReadUInt32WrapperSlow(input); - } - } - - private static uint? ReadUInt32WrapperSlow(CodedInputStream input) - { - int length = input.ReadLength(); - if (length == 0) - { - return 0; - } - int finalBufferPos = input.totalBytesRetired + input.bufferPos + length; - uint result = 0; - do - { - // field=1, type=varint = tag of 8 - if (input.ReadTag() == 8) - { - result = input.ReadUInt32(); - } - else - { - input.SkipLastField(); - } - } - while (input.totalBytesRetired + input.bufferPos < finalBufferPos); - return result; - } - - internal static int? ReadInt32Wrapper(CodedInputStream input) - { - return (int?)ReadUInt32Wrapper(input); - } - - internal static ulong? ReadUInt64Wrapper(CodedInputStream input) - { - // field=1, type=varint = tag of 8 - const int expectedTag = 8; - // length:1 + tag:1 + value:10(varint64-max) = 12 bytes - if (input.bufferPos + 12 <= input.bufferSize) - { - // The entire wrapper message is already contained in `buffer`. - int pos0 = input.bufferPos; - int length = input.buffer[input.bufferPos++]; - if (length == 0) - { - return 0L; - } - // Length will always fit in a single byte. - if (length >= 128) - { - input.bufferPos = pos0; - return ReadUInt64WrapperSlow(input); - } - int finalBufferPos = input.bufferPos + length; - if (input.buffer[input.bufferPos++] != expectedTag) - { - input.bufferPos = pos0; - return ReadUInt64WrapperSlow(input); - } - var result = input.ReadUInt64(); - // Verify this message only contained a single field. - if (input.bufferPos != finalBufferPos) - { - input.bufferPos = pos0; - return ReadUInt64WrapperSlow(input); - } - return result; - } - else - { - return ReadUInt64WrapperSlow(input); - } - } - - internal static ulong? ReadUInt64WrapperSlow(CodedInputStream input) - { - // field=1, type=varint = tag of 8 - const int expectedTag = 8; - int length = input.ReadLength(); - if (length == 0) - { - return 0L; - } - int finalBufferPos = input.totalBytesRetired + input.bufferPos + length; - ulong result = 0L; - do - { - if (input.ReadTag() == expectedTag) - { - result = input.ReadUInt64(); - } - else - { - input.SkipLastField(); - } - } - while (input.totalBytesRetired + input.bufferPos < finalBufferPos); - return result; - } - - internal static long? ReadInt64Wrapper(CodedInputStream input) - { - return (long?)ReadUInt64Wrapper(input); + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.MaybeConsumeTag(ref span, ref state, tag); } #endregion #region Underlying reading primitives - /// - /// Same code as ReadRawVarint32, but read each byte individually, checking for - /// buffer overflow. - /// - private uint SlowReadRawVarint32() - { - int tmp = ReadRawByte(); - if (tmp < 128) - { - return (uint) tmp; - } - int result = tmp & 0x7f; - if ((tmp = ReadRawByte()) < 128) - { - result |= tmp << 7; - } - else - { - result |= (tmp & 0x7f) << 7; - if ((tmp = ReadRawByte()) < 128) - { - result |= tmp << 14; - } - else - { - result |= (tmp & 0x7f) << 14; - if ((tmp = ReadRawByte()) < 128) - { - result |= tmp << 21; - } - else - { - result |= (tmp & 0x7f) << 21; - result |= (tmp = ReadRawByte()) << 28; - if (tmp >= 128) - { - // Discard upper 32 bits. - for (int i = 0; i < 5; i++) - { - if (ReadRawByte() < 128) - { - return (uint) result; - } - } - throw InvalidProtocolBufferException.MalformedVarint(); - } - } - } - } - return (uint) result; - } - /// /// Reads a raw Varint from the stream. If larger than 32 bits, discard the upper bits. /// This method is optimised for the case where we've got lots of data in the buffer. @@ -1077,58 +565,8 @@ namespace Google.Protobuf /// internal uint ReadRawVarint32() { - if (bufferPos + 5 > bufferSize) - { - return SlowReadRawVarint32(); - } - - int tmp = buffer[bufferPos++]; - if (tmp < 128) - { - return (uint) tmp; - } - int result = tmp & 0x7f; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 7; - } - else - { - result |= (tmp & 0x7f) << 7; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 14; - } - else - { - result |= (tmp & 0x7f) << 14; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 21; - } - else - { - result |= (tmp & 0x7f) << 21; - result |= (tmp = buffer[bufferPos++]) << 28; - if (tmp >= 128) - { - // Discard upper 32 bits. - // Note that this has to use ReadRawByte() as we only ensure we've - // got at least 5 bytes at the start of the method. This lets us - // use the fast path in more cases, and we rarely hit this section of code. - for (int i = 0; i < 5; i++) - { - if (ReadRawByte() < 128) - { - return (uint) result; - } - } - throw InvalidProtocolBufferException.MalformedVarint(); - } - } - } - } - return (uint) result; + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseRawVarint32(ref span, ref state); } /// @@ -1142,35 +580,7 @@ namespace Google.Protobuf /// internal static uint ReadRawVarint32(Stream input) { - int result = 0; - int offset = 0; - for (; offset < 32; offset += 7) - { - int b = input.ReadByte(); - if (b == -1) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - result |= (b & 0x7f) << offset; - if ((b & 0x80) == 0) - { - return (uint) result; - } - } - // Keep reading up to 64 bits. - for (; offset < 64; offset += 7) - { - int b = input.ReadByte(); - if (b == -1) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - if ((b & 0x80) == 0) - { - return (uint) result; - } - } - throw InvalidProtocolBufferException.MalformedVarint(); + return ParsingPrimitives.ReadRawVarint32(input); } /// @@ -1178,44 +588,8 @@ namespace Google.Protobuf /// internal ulong ReadRawVarint64() { - if (bufferPos + 10 <= bufferSize) - { - ulong result = buffer[bufferPos++]; - if (result < 128) - { - return result; - } - result &= 0x7f; - int shift = 7; - do - { - byte b = buffer[bufferPos++]; - result |= (ulong)(b & 0x7F) << shift; - if (b < 0x80) - { - return result; - } - shift += 7; - } - while (shift < 64); - } - else - { - int shift = 0; - ulong result = 0; - do - { - byte b = ReadRawByte(); - result |= (ulong)(b & 0x7F) << shift; - if (b < 0x80) - { - return result; - } - shift += 7; - } - while (shift < 64); - } - throw InvalidProtocolBufferException.MalformedVarint(); + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseRawVarint64(ref span, ref state); } /// @@ -1223,32 +597,8 @@ namespace Google.Protobuf /// internal uint ReadRawLittleEndian32() { - if (bufferPos + 4 <= bufferSize) - { - if (BitConverter.IsLittleEndian) - { - var result = BitConverter.ToUInt32(buffer, bufferPos); - bufferPos += 4; - return result; - } - else - { - uint b1 = buffer[bufferPos]; - uint b2 = buffer[bufferPos + 1]; - uint b3 = buffer[bufferPos + 2]; - uint b4 = buffer[bufferPos + 3]; - bufferPos += 4; - return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); - } - } - else - { - uint b1 = ReadRawByte(); - uint b2 = ReadRawByte(); - uint b3 = ReadRawByte(); - uint b4 = ReadRawByte(); - return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); - } + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseRawLittleEndian32(ref span, ref state); } /// @@ -1256,70 +606,8 @@ namespace Google.Protobuf /// internal ulong ReadRawLittleEndian64() { - if (bufferPos + 8 <= bufferSize) - { - if (BitConverter.IsLittleEndian) - { - var result = BitConverter.ToUInt64(buffer, bufferPos); - bufferPos += 8; - return result; - } - else - { - ulong b1 = buffer[bufferPos]; - ulong b2 = buffer[bufferPos + 1]; - ulong b3 = buffer[bufferPos + 2]; - ulong b4 = buffer[bufferPos + 3]; - ulong b5 = buffer[bufferPos + 4]; - ulong b6 = buffer[bufferPos + 5]; - ulong b7 = buffer[bufferPos + 6]; - ulong b8 = buffer[bufferPos + 7]; - bufferPos += 8; - return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24) - | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56); - } - } - else - { - ulong b1 = ReadRawByte(); - ulong b2 = ReadRawByte(); - ulong b3 = ReadRawByte(); - ulong b4 = ReadRawByte(); - ulong b5 = ReadRawByte(); - ulong b6 = ReadRawByte(); - ulong b7 = ReadRawByte(); - ulong b8 = ReadRawByte(); - return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24) - | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56); - } - } - - /// - /// Decode a 32-bit value with ZigZag encoding. - /// - /// - /// ZigZag encodes signed integers into values that can be efficiently - /// encoded with varint. (Otherwise, negative values must be - /// sign-extended to 64 bits to be varint encoded, thus always taking - /// 10 bytes on the wire.) - /// - internal static int DecodeZigZag32(uint n) - { - return (int)(n >> 1) ^ -(int)(n & 1); - } - - /// - /// Decode a 32-bit value with ZigZag encoding. - /// - /// - /// ZigZag encodes signed integers into values that can be efficiently - /// encoded with varint. (Otherwise, negative values must be - /// sign-extended to 64 bits to be varint encoded, thus always taking - /// 10 bytes on the wire.) - /// - internal static long DecodeZigZag64(ulong n) - { - return (long)(n >> 1) ^ -(long)(n & 1); + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ParseRawLittleEndian64(ref span, ref state); } #endregion @@ -1333,37 +621,7 @@ namespace Google.Protobuf /// The old limit. internal int PushLimit(int byteLimit) { - if (byteLimit < 0) - { - throw InvalidProtocolBufferException.NegativeSize(); - } - byteLimit += totalBytesRetired + bufferPos; - int oldLimit = currentLimit; - if (byteLimit > oldLimit) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - currentLimit = byteLimit; - - RecomputeBufferSizeAfterLimit(); - - return oldLimit; - } - - private void RecomputeBufferSizeAfterLimit() - { - bufferSize += bufferSizeAfterLimit; - int bufferEnd = totalBytesRetired + bufferSize; - if (bufferEnd > currentLimit) - { - // Limit is in current buffer. - bufferSizeAfterLimit = bufferEnd - currentLimit; - bufferSize -= bufferSizeAfterLimit; - } - else - { - bufferSizeAfterLimit = 0; - } + return SegmentedBufferHelper.PushLimit(ref state, byteLimit); } /// @@ -1371,8 +629,7 @@ namespace Google.Protobuf /// internal void PopLimit(int oldLimit) { - currentLimit = oldLimit; - RecomputeBufferSizeAfterLimit(); + SegmentedBufferHelper.PopLimit(ref state, oldLimit); } /// @@ -1383,12 +640,7 @@ namespace Google.Protobuf { get { - if (currentLimit == int.MaxValue) - { - return false; - } - int currentAbsolutePosition = totalBytesRetired + bufferPos; - return currentAbsolutePosition >= currentLimit; + return SegmentedBufferHelper.IsReachedLimit(ref state); } } @@ -1399,7 +651,11 @@ namespace Google.Protobuf /// public bool IsAtEnd { - get { return bufferPos == bufferSize && !RefillBuffer(false); } + get + { + var span = new ReadOnlySpan(buffer); + return SegmentedBufferHelper.IsAtEnd(ref span, ref state); + } } /// @@ -1413,69 +669,8 @@ namespace Google.Protobuf /// private bool RefillBuffer(bool mustSucceed) { - if (bufferPos < bufferSize) - { - throw new InvalidOperationException("RefillBuffer() called when buffer wasn't empty."); - } - - if (totalBytesRetired + bufferSize == currentLimit) - { - // Oops, we hit a limit. - if (mustSucceed) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - else - { - return false; - } - } - - totalBytesRetired += bufferSize; - - bufferPos = 0; - bufferSize = (input == null) ? 0 : input.Read(buffer, 0, buffer.Length); - if (bufferSize < 0) - { - throw new InvalidOperationException("Stream.Read returned a negative count"); - } - if (bufferSize == 0) - { - if (mustSucceed) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - else - { - return false; - } - } - else - { - RecomputeBufferSizeAfterLimit(); - int totalBytesRead = - totalBytesRetired + bufferSize + bufferSizeAfterLimit; - if (totalBytesRead < 0 || totalBytesRead > sizeLimit) - { - throw InvalidProtocolBufferException.SizeLimitExceeded(); - } - return true; - } - } - - /// - /// Read one byte from the input. - /// - /// - /// the end of the stream or the current limit was reached - /// - internal byte ReadRawByte() - { - if (bufferPos == bufferSize) - { - RefillBuffer(true); - } - return buffer[bufferPos++]; + var span = new ReadOnlySpan(buffer); + return state.segmentedBufferHelper.RefillBuffer(ref span, ref state, mustSucceed); } /// @@ -1486,193 +681,25 @@ namespace Google.Protobuf /// internal byte[] ReadRawBytes(int size) { - if (size < 0) - { - throw InvalidProtocolBufferException.NegativeSize(); - } - - if (totalBytesRetired + bufferPos + size > currentLimit) - { - // Read to the end of the stream (up to the current limit) anyway. - SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); - // Then fail. - throw InvalidProtocolBufferException.TruncatedMessage(); - } - - if (size <= bufferSize - bufferPos) - { - // We have all the bytes we need already. - byte[] bytes = new byte[size]; - ByteArray.Copy(buffer, bufferPos, bytes, 0, size); - bufferPos += size; - return bytes; - } - else if (size < buffer.Length) - { - // Reading more bytes than are in the buffer, but not an excessive number - // of bytes. We can safely allocate the resulting array ahead of time. - - // First copy what we have. - byte[] bytes = new byte[size]; - int pos = bufferSize - bufferPos; - ByteArray.Copy(buffer, bufferPos, bytes, 0, pos); - bufferPos = bufferSize; - - // We want to use RefillBuffer() and then copy from the buffer into our - // byte array rather than reading directly into our byte array because - // the input may be unbuffered. - RefillBuffer(true); - - while (size - pos > bufferSize) - { - Buffer.BlockCopy(buffer, 0, bytes, pos, bufferSize); - pos += bufferSize; - bufferPos = bufferSize; - RefillBuffer(true); - } - - ByteArray.Copy(buffer, 0, bytes, pos, size - pos); - bufferPos = size - pos; - - return bytes; - } - else - { - // The size is very large. For security reasons, we can't allocate the - // entire byte array yet. The size comes directly from the input, so a - // maliciously-crafted message could provide a bogus very large size in - // order to trick the app into allocating a lot of memory. We avoid this - // by allocating and reading only a small chunk at a time, so that the - // malicious message must actually *be* extremely large to cause - // problems. Meanwhile, we limit the allowed size of a message elsewhere. - - // Remember the buffer markers since we'll have to copy the bytes out of - // it later. - int originalBufferPos = bufferPos; - int originalBufferSize = bufferSize; - - // Mark the current buffer consumed. - totalBytesRetired += bufferSize; - bufferPos = 0; - bufferSize = 0; - - // Read all the rest of the bytes we need. - int sizeLeft = size - (originalBufferSize - originalBufferPos); - List chunks = new List(); - - while (sizeLeft > 0) - { - byte[] chunk = new byte[Math.Min(sizeLeft, buffer.Length)]; - int pos = 0; - while (pos < chunk.Length) - { - int n = (input == null) ? -1 : input.Read(chunk, pos, chunk.Length - pos); - if (n <= 0) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - totalBytesRetired += n; - pos += n; - } - sizeLeft -= chunk.Length; - chunks.Add(chunk); - } - - // OK, got everything. Now concatenate it all into one buffer. - byte[] bytes = new byte[size]; - - // Start by copying the leftover bytes from this.buffer. - int newPos = originalBufferSize - originalBufferPos; - ByteArray.Copy(buffer, originalBufferPos, bytes, 0, newPos); - - // And now all the chunks. - foreach (byte[] chunk in chunks) - { - Buffer.BlockCopy(chunk, 0, bytes, newPos, chunk.Length); - newPos += chunk.Length; - } - - // Done. - return bytes; - } - } - - /// - /// Reads and discards bytes. - /// - /// the end of the stream - /// or the current limit was reached - private void SkipRawBytes(int size) - { - if (size < 0) - { - throw InvalidProtocolBufferException.NegativeSize(); - } - - if (totalBytesRetired + bufferPos + size > currentLimit) - { - // Read to the end of the stream anyway. - SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); - // Then fail. - throw InvalidProtocolBufferException.TruncatedMessage(); - } - - if (size <= bufferSize - bufferPos) - { - // We have all the bytes we need already. - bufferPos += size; - } - else - { - // Skipping more bytes than are in the buffer. First skip what we have. - int pos = bufferSize - bufferPos; - - // ROK 5/7/2013 Issue #54: should retire all bytes in buffer (bufferSize) - // totalBytesRetired += pos; - totalBytesRetired += bufferSize; - - bufferPos = 0; - bufferSize = 0; - - // Then skip directly from the InputStream for the rest. - if (pos < size) - { - if (input == null) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - SkipImpl(size - pos); - totalBytesRetired += size - pos; - } - } + var span = new ReadOnlySpan(buffer); + return ParsingPrimitives.ReadRawBytes(ref span, ref state, size); } /// - /// Abstraction of skipping to cope with streams which can't really skip. + /// Reads a top-level message or a nested message after the limits for this message have been pushed. + /// (parser will proceed until the end of the current limit) + /// NOTE: this method needs to be public because it's invoked by the generated code - e.g. msg.MergeFrom(CodedInputStream input) method /// - private void SkipImpl(int amountToSkip) + public void ReadRawMessage(IMessage message) { - if (input.CanSeek) + var ctx = new ParseContext(this); + try { - long previousPosition = input.Position; - input.Position += amountToSkip; - if (input.Position != previousPosition + amountToSkip) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } + ParsingPrimitivesMessages.ReadRawMessage(ref ctx, message); } - else + finally { - byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)]; - while (amountToSkip > 0) - { - int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip)); - if (bytesRead <= 0) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - amountToSkip -= bytesRead; - } + ctx.CopyStateTo(this); } } #endregion diff --git a/csharp/src/Google.Protobuf/IBufferMessage.cs b/csharp/src/Google.Protobuf/IBufferMessage.cs new file mode 100644 index 0000000000..ddd49b1bb4 --- /dev/null +++ b/csharp/src/Google.Protobuf/IBufferMessage.cs @@ -0,0 +1,63 @@ +#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 + +namespace Google.Protobuf +{ +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Interface for a Protocol Buffers message, supporting + /// and + /// serialization operations. + /// + public interface IBufferMessage : IMessage + { + /// + /// Merges the data from the specified with the current message. + /// + /// See the user guide for precise merge semantics. + /// to read data from. Must not be null. + void MergeFrom(ref CodedInputReader input); + + /// + /// Internal implementation of merging data from given parse context into this message. + /// Users should never invoke this method directly. + /// + void MergeFrom_Internal(ref ParseContext ctx); + + /// + /// Writes the data to the given . + /// + /// to write the data to. Must not be null. + void WriteTo(ref CodedOutputWriter output); + } +#endif +} diff --git a/csharp/src/Google.Protobuf/ParseContext.cs b/csharp/src/Google.Protobuf/ParseContext.cs new file mode 100644 index 0000000000..4b0b76d453 --- /dev/null +++ b/csharp/src/Google.Protobuf/ParseContext.cs @@ -0,0 +1,322 @@ +#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 System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using Google.Protobuf.Collections; + +namespace Google.Protobuf +{ + /// + /// An opaque struct that represents the current parsing state and is passed along + /// as the parsing proceeds. + /// All the public methods are intended to be invoked only by the generated code, + /// users should never invoke them directly. + /// + [SecuritySafeCritical] + public ref struct ParseContext + { + internal const int DefaultRecursionLimit = 100; + internal const int DefaultSizeLimit = Int32.MaxValue; + + internal ReadOnlySpan buffer; + internal ParserInternalState state; + + internal ParseContext(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + this.buffer = buffer; + this.state = state; + } + + /// + /// Creates a ParseContext instance from CodedInputStream. + /// WARNING: internally this copies the CodedInputStream's state, so after done with the ParseContext, + /// the CodedInputStream's state needs to be updated. + /// + internal ParseContext(CodedInputStream input) + { + this.buffer = new ReadOnlySpan(input.InternalBuffer); + // TODO: ideally we would use a reference to the original state, but that doesn't seem possible + this.state = input.InternalState; // creates copy of the state + } + + internal ParseContext(ReadOnlySequence input) : this(input, DefaultRecursionLimit) + { + } + + internal ParseContext(ReadOnlySequence input, int recursionLimit) + { + this.buffer = default; + this.state = default; + this.state.lastTag = 0; + this.state.recursionDepth = 0; + this.state.sizeLimit = DefaultSizeLimit; + this.state.recursionLimit = recursionLimit; + this.state.currentLimit = int.MaxValue; + this.state.segmentedBufferHelper = new SegmentedBufferHelper(input, out this.buffer); + this.state.bufferPos = 0; + this.state.bufferSize = this.buffer.Length; + this.state.codedInputStream = null; + + this.state.DiscardUnknownFields = false; + this.state.ExtensionRegistry = null; + } + + /// + /// Returns the last tag read, or 0 if no tags have been read or we've read beyond + /// the end of the input. + /// + internal uint LastTag { get { return state.lastTag; } } + + /// + /// Internal-only property; when set to true, unknown fields will be discarded while parsing. + /// + internal bool DiscardUnknownFields { + get { return state.DiscardUnknownFields; } + set { state.DiscardUnknownFields = value; } + } + + /// + /// Internal-only property; provides extension identifiers to compatible messages while parsing. + /// + internal ExtensionRegistry ExtensionRegistry + { + get { return state.ExtensionRegistry; } + set { state.ExtensionRegistry = value; } + } + + /// + /// Reads a field tag, returning the tag of 0 for "end of input". + /// + /// + /// If this method returns 0, it doesn't necessarily mean the end of all + /// the data in this CodedInputReader; it may be the end of the logical input + /// for an embedded message, for example. + /// + /// The next field tag, or 0 for end of input. (0 is never a valid tag.) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + + public uint ReadTag() + { + return ParsingPrimitives.ParseTag(ref buffer, ref state); + } + + /// + /// Reads a double field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public double ReadDouble() + { + return ParsingPrimitives.ParseDouble(ref buffer, ref state); + } + + /// + /// Reads a float field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public float ReadFloat() + { + return ParsingPrimitives.ParseFloat(ref buffer, ref state); + } + + /// + /// Reads a uint64 field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public ulong ReadUInt64() + { + return ParsingPrimitives.ParseRawVarint64(ref buffer, ref state); + } + + /// + /// Reads an int64 field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public long ReadInt64() + { + return (long)ParsingPrimitives.ParseRawVarint64(ref buffer, ref state); + } + + /// + /// Reads an int32 field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int ReadInt32() + { + return (int)ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + } + + /// + /// Reads a fixed64 field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public ulong ReadFixed64() + { + return ParsingPrimitives.ParseRawLittleEndian64(ref buffer, ref state); + } + + /// + /// Reads a fixed32 field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public uint ReadFixed32() + { + return ParsingPrimitives.ParseRawLittleEndian32(ref buffer, ref state); + } + + /// + /// Reads a bool field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool ReadBool() + { + return ParsingPrimitives.ParseRawVarint64(ref buffer, ref state) != 0; + } + /// + /// Reads a string field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public string ReadString() + { + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + return ParsingPrimitives.ReadRawString(ref buffer, ref state, length); + } + + /// + /// Reads an embedded message field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void ReadMessage(IMessage message) + { + // TODO: add a fallback if IMessage does not implement IBufferMessage + ParsingPrimitivesMessages.ReadMessage(ref this, message); + } + + /// + /// Reads an embedded group field from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void ReadGroup(IMessage message) + { + ParsingPrimitivesMessages.ReadGroup(ref this, message); + } + + /// + /// Reads a bytes field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public ByteString ReadBytes() + { + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + return ByteString.AttachBytes(ParsingPrimitives.ReadRawBytes(ref buffer, ref state, length)); + } + /// + /// Reads a uint32 field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public uint ReadUInt32() + { + return ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + } + + /// + /// Reads an enum field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int ReadEnum() + { + // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. + return (int)ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + } + + /// + /// Reads an sfixed32 field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int ReadSFixed32() + { + return (int)ParsingPrimitives.ParseRawLittleEndian32(ref buffer, ref state); + } + + /// + /// Reads an sfixed64 field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public long ReadSFixed64() + { + return (long)ParsingPrimitives.ParseRawLittleEndian64(ref buffer, ref state); + } + + /// + /// Reads an sint32 field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int ReadSInt32() + { + return ParsingPrimitives.DecodeZigZag32(ParsingPrimitives.ParseRawVarint32(ref buffer, ref state)); + } + + /// + /// Reads an sint64 field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public long ReadSInt64() + { + return ParsingPrimitives.DecodeZigZag64(ParsingPrimitives.ParseRawVarint64(ref buffer, ref state)); + } + + /// + /// Reads a length for length-delimited data. + /// + /// + /// This is internally just reading a varint, but this method exists + /// to make the calling code clearer. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int ReadLength() + { + return (int)ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + } + + internal void CopyStateTo(CodedInputStream input) + { + input.InternalState = state; + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/ParserInternalState.cs b/csharp/src/Google.Protobuf/ParserInternalState.cs new file mode 100644 index 0000000000..5875173d8a --- /dev/null +++ b/csharp/src/Google.Protobuf/ParserInternalState.cs @@ -0,0 +1,116 @@ +#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 System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using Google.Protobuf.Collections; + +namespace Google.Protobuf +{ + + // warning: this is a mutable struct, so it needs to be only passed as a ref! + internal struct ParserInternalState + { + // NOTE: the Span representing the current buffer is kept separate so that this doesn't have to be a ref struct and so it can live + // be included in CodedInputStream's internal state + + /// + /// The position within the current buffer (i.e. the next byte to read) + /// + internal int bufferPos; + + /// + /// Size of the current buffer + /// + internal int bufferSize; + + /// + /// If we are currently inside a length-delimited block, this is the number of + /// bytes in the buffer that are still available once we leave the delimited block. + /// + internal int bufferSizeAfterLimit; + + /// + /// The absolute position of the end of the current length-delimited block (including totalBytesRetired) + /// + internal int currentLimit; + + /// + /// The total number of consumed before the start of the current buffer. The + /// total bytes read up to the current position can be computed as + /// totalBytesRetired + bufferPos. + /// + internal int totalBytesRetired; + + internal int recursionDepth; // current recursion depth + + internal SegmentedBufferHelper segmentedBufferHelper; + + // TODO: remember if this context is supposed to call MergeFrom(CodedInputStream cis) or MergeFrom(ref ParseContext ....) for submessages. + // if non-null, the top level parse method was started with given cis as an argument + internal CodedInputStream codedInputStream; + + + /// + /// The last tag we read. 0 indicates we've read to the end of the stream + /// (or haven't read anything yet). + /// + internal uint lastTag; + + /// + /// The next tag, used to store the value read by PeekTag. + /// + internal uint nextTag; + internal bool hasNextTag; + + // TODO: these fields are configuration, they should be readonly + internal int sizeLimit; + internal int recursionLimit; + + /// + /// Internal-only property; when set to true, unknown fields will be discarded while parsing. + /// + internal bool DiscardUnknownFields { get; set; } + + /// + /// Internal-only property; provides extension identifiers to compatible messages while parsing. + /// + internal ExtensionRegistry ExtensionRegistry { get; set; } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/ParsingPrimitives.cs b/csharp/src/Google.Protobuf/ParsingPrimitives.cs new file mode 100644 index 0000000000..93852344ed --- /dev/null +++ b/csharp/src/Google.Protobuf/ParsingPrimitives.cs @@ -0,0 +1,726 @@ +#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 System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using Google.Protobuf.Collections; + +namespace Google.Protobuf +{ + /// + /// Primitives for parsing protobuf wire format. + /// + internal static class ParsingPrimitives + { + + /// + /// Reads a length for length-delimited data. + /// + /// + /// This is internally just reading a varint, but this method exists + /// to make the calling code clearer. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + + public static int ParseLength(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + return (int)ParseRawVarint32(ref buffer, ref state); + } + + /// + /// Parses the next tag. + /// If the end of logical stream was reached, an invalid tag of 0 is returned. + /// + public static uint ParseTag(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + // The "nextTag" logic is there only as an optimization for reading non-packed repeated / map + // fields and is strictly speaking not necessary. + // TODO(jtattermusch): look into simplifying the ParseTag logic. + if (state.hasNextTag) + { + state.lastTag = state.nextTag; + state.hasNextTag = false; + return state.lastTag; + } + + // Optimize for the incredibly common case of having at least two bytes left in the buffer, + // and those two bytes being enough to get the tag. This will be true for fields up to 4095. + if (state.bufferPos + 2 <= state.bufferSize) + { + int tmp = buffer[state.bufferPos++]; + if (tmp < 128) + { + state.lastTag = (uint)tmp; + } + else + { + int result = tmp & 0x7f; + if ((tmp = buffer[state.bufferPos++]) < 128) + { + result |= tmp << 7; + state.lastTag = (uint) result; + } + else + { + // Nope, rewind and go the potentially slow route. + state.bufferPos -= 2; + state.lastTag = ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + } + } + } + else + { + if (SegmentedBufferHelper.IsAtEnd(ref buffer, ref state)) + { + state.lastTag = 0; + return 0; + } + + state.lastTag = ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + } + if (WireFormat.GetTagFieldNumber(state.lastTag) == 0) + { + // If we actually read a tag with a field of 0, that's not a valid tag. + throw InvalidProtocolBufferException.InvalidTag(); + } + return state.lastTag; + } + + /// + /// Peeks at the next tag in the stream. If it matches , + /// the tag is consumed and the method returns true; otherwise, the + /// stream is left in the original position and the method returns false. + /// + public static bool MaybeConsumeTag(ref ReadOnlySpan buffer, ref ParserInternalState state, uint tag) + { + if (PeekTag(ref buffer, ref state) == tag) + { + state.hasNextTag = false; + return true; + } + return false; + } + + /// + /// Peeks at the next field tag. This is like calling , but the + /// tag is not consumed. (So a subsequent call to will return the + /// same value.) + /// + public static uint PeekTag(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + if (state.hasNextTag) + { + return state.nextTag; + } + + uint savedLast = state.lastTag; + state.nextTag = ParseTag(ref buffer, ref state); + state.hasNextTag = true; + state.lastTag = savedLast; // Undo the side effect of ReadTag + return state.nextTag; + } + + /// + /// Parses a raw varint. + /// + public static ulong ParseRawVarint64(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + if (state.bufferPos + 10 > state.bufferSize) + { + return ParseRawVarint64SlowPath(ref buffer, ref state); + } + + ulong result = buffer[state.bufferPos++]; + if (result < 128) + { + return result; + } + result &= 0x7f; + int shift = 7; + do + { + byte b = buffer[state.bufferPos++]; + result |= (ulong)(b & 0x7F) << shift; + if (b < 0x80) + { + return result; + } + shift += 7; + } + while (shift < 64); + + throw InvalidProtocolBufferException.MalformedVarint(); + } + + private static ulong ParseRawVarint64SlowPath(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + int shift = 0; + ulong result = 0; + do + { + byte b = ReadRawByte(ref buffer, ref state); + result |= (ulong)(b & 0x7F) << shift; + if (b < 0x80) + { + return result; + } + shift += 7; + } + while (shift < 64); + + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Parses a raw Varint. If larger than 32 bits, discard the upper bits. + /// This method is optimised for the case where we've got lots of data in the buffer. + /// That means we can check the size just once, then just read directly from the buffer + /// without constant rechecking of the buffer length. + /// + public static uint ParseRawVarint32(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + if (state.bufferPos + 5 > state.bufferSize) + { + return ParseRawVarint32SlowPath(ref buffer, ref state); + } + + int tmp = buffer[state.bufferPos++]; + if (tmp < 128) + { + return (uint)tmp; + } + int result = tmp & 0x7f; + if ((tmp = buffer[state.bufferPos++]) < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + if ((tmp = buffer[state.bufferPos++]) < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + if ((tmp = buffer[state.bufferPos++]) < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + result |= (tmp = buffer[state.bufferPos++]) << 28; + if (tmp >= 128) + { + // Discard upper 32 bits. + // Note that this has to use ReadRawByte() as we only ensure we've + // got at least 5 bytes at the start of the method. This lets us + // use the fast path in more cases, and we rarely hit this section of code. + for (int i = 0; i < 5; i++) + { + if (ReadRawByte(ref buffer, ref state) < 128) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + return (uint)result; + } + + private static uint ParseRawVarint32SlowPath(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + int tmp = ReadRawByte(ref buffer, ref state); + if (tmp < 128) + { + return (uint) tmp; + } + int result = tmp & 0x7f; + if ((tmp = ReadRawByte(ref buffer, ref state)) < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + if ((tmp = ReadRawByte(ref buffer, ref state)) < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + if ((tmp = ReadRawByte(ref buffer, ref state)) < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + result |= (tmp = ReadRawByte(ref buffer, ref state)) << 28; + if (tmp >= 128) + { + // Discard upper 32 bits. + for (int i = 0; i < 5; i++) + { + if (ReadRawByte(ref buffer, ref state) < 128) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + return (uint) result; + } + + /// + /// Parses a 32-bit little-endian integer. + /// + public static uint ParseRawLittleEndian32(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + const int length = sizeof(uint); + if (state.bufferPos + length > state.bufferSize) + { + return ParseRawLittleEndian32SlowPath(ref buffer, ref state); + } + uint result = BinaryPrimitives.ReadUInt32LittleEndian(buffer.Slice(state.bufferPos, length)); + state.bufferPos += length; + return result; + } + + private static uint ParseRawLittleEndian32SlowPath(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + uint b1 = ReadRawByte(ref buffer, ref state); + uint b2 = ReadRawByte(ref buffer, ref state); + uint b3 = ReadRawByte(ref buffer, ref state); + uint b4 = ReadRawByte(ref buffer, ref state); + return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); + } + + /// + /// Parses a 64-bit little-endian integer. + /// + public static ulong ParseRawLittleEndian64(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + const int length = sizeof(ulong); + if (state.bufferPos + length > state.bufferSize) + { + return ParseRawLittleEndian64SlowPath(ref buffer, ref state); + } + ulong result = BinaryPrimitives.ReadUInt64LittleEndian(buffer.Slice(state.bufferPos, length)); + state.bufferPos += length; + return result; + } + + private static ulong ParseRawLittleEndian64SlowPath(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + ulong b1 = ReadRawByte(ref buffer, ref state); + ulong b2 = ReadRawByte(ref buffer, ref state); + ulong b3 = ReadRawByte(ref buffer, ref state); + ulong b4 = ReadRawByte(ref buffer, ref state); + ulong b5 = ReadRawByte(ref buffer, ref state); + ulong b6 = ReadRawByte(ref buffer, ref state); + ulong b7 = ReadRawByte(ref buffer, ref state); + ulong b8 = ReadRawByte(ref buffer, ref state); + return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24) + | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56); + } + + /// + /// Parses a double value. + /// + public static double ParseDouble(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + const int length = sizeof(double); + if (!BitConverter.IsLittleEndian || state.bufferPos + length > state.bufferSize) + { + return BitConverter.Int64BitsToDouble((long)ParseRawLittleEndian64(ref buffer, ref state)); + } + // ReadUnaligned uses processor architecture for endianness. + double result = Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(buffer.Slice(state.bufferPos, length))); + state.bufferPos += length; + return result; + } + + /// + /// Parses a float value. + /// + public static float ParseFloat(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + const int length = sizeof(float); + if (!BitConverter.IsLittleEndian || state.bufferPos + length > state.bufferSize) + { + return ParseFloatSlow(ref buffer, ref state); + } + // ReadUnaligned uses processor architecture for endianness. + float result = Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(buffer.Slice(state.bufferPos, length))); + state.bufferPos += length; + return result; + } + + private static unsafe float ParseFloatSlow(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + const int length = sizeof(float); + byte* stackBuffer = stackalloc byte[length]; + Span tempSpan = new Span(stackBuffer, length); + for (int i = 0; i < length; i++) + { + tempSpan[i] = ReadRawByte(ref buffer, ref state); + } + + // Content is little endian. Reverse if needed to match endianness of architecture. + if (!BitConverter.IsLittleEndian) + { + tempSpan.Reverse(); + } + return Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(tempSpan)); + } + + /// + /// Reads a fixed size of bytes from the input. + /// + /// + /// the end of the stream or the current limit was reached + /// + public static byte[] ReadRawBytes(ref ReadOnlySpan buffer, ref ParserInternalState state, int size) + { + if (size < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + if (state.totalBytesRetired + state.bufferPos + size > state.currentLimit) + { + // Read to the end of the stream (up to the current limit) anyway. + SkipRawBytes(ref buffer, ref state, state.currentLimit - state.totalBytesRetired - state.bufferPos); + // Then fail. + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + if (size <= state.bufferSize - state.bufferPos) + { + // We have all the bytes we need already. + byte[] bytes = new byte[size]; + buffer.Slice(state.bufferPos, size).CopyTo(bytes); + state.bufferPos += size; + return bytes; + } + else if (size < buffer.Length || size < state.segmentedBufferHelper.TotalLength) + { + // Reading more bytes than are in the buffer, but not an excessive number + // of bytes. We can safely allocate the resulting array ahead of time. + + // First copy what we have. + byte[] bytes = new byte[size]; + var bytesSpan = new Span(bytes); + int pos = state.bufferSize - state.bufferPos; + buffer.Slice(state.bufferPos, pos).CopyTo(bytesSpan.Slice(0, pos)); + state.bufferPos = state.bufferSize; + + // We want to use RefillBuffer() and then copy from the buffer into our + // byte array rather than reading directly into our byte array because + // the input may be unbuffered. + state.segmentedBufferHelper.RefillBuffer(ref buffer, ref state, true); + + while (size - pos > state.bufferSize) + { + buffer.Slice(0, state.bufferSize) + .CopyTo(bytesSpan.Slice(pos, state.bufferSize)); + pos += state.bufferSize; + state.bufferPos = state.bufferSize; + state.segmentedBufferHelper.RefillBuffer(ref buffer, ref state, true); + } + + buffer.Slice(0, size - pos) + .CopyTo(bytesSpan.Slice(pos, size - pos)); + state.bufferPos = size - pos; + + return bytes; + } + else + { + // The size is very large. For security reasons, we can't allocate the + // entire byte array yet. The size comes directly from the input, so a + // maliciously-crafted message could provide a bogus very large size in + // order to trick the app into allocating a lot of memory. We avoid this + // by allocating and reading only a small chunk at a time, so that the + // malicious message must actually *be* extremely large to cause + // problems. Meanwhile, we limit the allowed size of a message elsewhere. + + List chunks = new List(); + + int pos = state.bufferSize - state.bufferPos; + byte[] firstChunk = new byte[pos]; + buffer.Slice(state.bufferPos, pos).CopyTo(firstChunk); + chunks.Add(firstChunk); + state.bufferPos = state.bufferSize; + + // Read all the rest of the bytes we need. + int sizeLeft = size - pos; + while (sizeLeft > 0) + { + state.segmentedBufferHelper.RefillBuffer(ref buffer, ref state, true); + byte[] chunk = new byte[Math.Min(sizeLeft, state.bufferSize)]; + + buffer.Slice(0, chunk.Length) + .CopyTo(chunk); + state.bufferPos += chunk.Length; + sizeLeft -= chunk.Length; + chunks.Add(chunk); + } + + // OK, got everything. Now concatenate it all into one buffer. + byte[] bytes = new byte[size]; + int newPos = 0; + foreach (byte[] chunk in chunks) + { + Buffer.BlockCopy(chunk, 0, bytes, newPos, chunk.Length); + newPos += chunk.Length; + } + + // Done. + return bytes; + } + } + + /// + /// Reads and discards bytes. + /// + /// the end of the stream + /// or the current limit was reached + public static void SkipRawBytes(ref ReadOnlySpan buffer, ref ParserInternalState state, int size) + { + if (size < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + if (state.totalBytesRetired + state.bufferPos + size > state.currentLimit) + { + // Read to the end of the stream anyway. + SkipRawBytes(ref buffer, ref state, state.currentLimit - state.totalBytesRetired - state.bufferPos); + // Then fail. + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + if (size <= state.bufferSize - state.bufferPos) + { + // We have all the bytes we need already. + state.bufferPos += size; + } + else + { + // TODO: do we need to support skipping in seekable Streams? + + // Skipping more bytes than are in the buffer. First skip what we have. + int pos = state.bufferSize - state.bufferPos; + state.bufferPos = state.bufferSize; + + state.segmentedBufferHelper.RefillBuffer(ref buffer, ref state, true); + + while (size - pos > state.bufferSize) + { + pos += state.bufferSize; + state.bufferPos = state.bufferSize; + state.segmentedBufferHelper.RefillBuffer(ref buffer, ref state, true); + } + + state.bufferPos = size - pos; + } + } + + public static string ReadString(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + return ParsingPrimitives.ReadRawString(ref buffer, ref state, length); + } + + /// + /// Reads a bytes field value from the input. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ByteString ReadBytes(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + return ByteString.AttachBytes(ParsingPrimitives.ReadRawBytes(ref buffer, ref state, length)); + } + + /// + /// Reads a UTF-8 string from the next "length" bytes. + /// + /// + /// the end of the stream or the current limit was reached + /// + public static string ReadRawString(ref ReadOnlySpan buffer, ref ParserInternalState state, int length) + { + // No need to read any data for an empty string. + if (length == 0) + { + return string.Empty; + } + + if (length < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + +#if GOOGLE_PROTOBUF_SUPPORT_FAST_STRING + if (length <= state.bufferSize - state.bufferPos && length > 0) + { + // Fast path: all bytes to decode appear in the same span. + ReadOnlySpan data = buffer.Slice(state.bufferPos, length); + + string value; + unsafe + { + fixed (byte* sourceBytes = &MemoryMarshal.GetReference(data)) + { + value = CodedOutputStream.Utf8Encoding.GetString(sourceBytes, length); + } + } + + state.bufferPos += length; + return value; + } +#endif + + // TODO: what if GOOGLE_PROTOBUF_SUPPORT_FAST_STRING is not supported? + // -> can we still try to grab an array from the span? + // if (length <= state.bufferSize - state.bufferPos && length > 0) + // { + // // Fast path: We already have the bytes in a contiguous buffer, so + // // just copy directly from it. + // String result = CodedOutputStream.Utf8Encoding.GetString(buffer, state.bufferPos, length); + // state.bufferPos += length; + // return result; + // } + + // TODO: creating a char[] and decoding into it and then creating a string from that array might be more efficient + // Slow path: Build a byte array first then copy it. + return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(ref buffer, ref state, length), 0, length); + } + + private static byte ReadRawByte(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + if (state.bufferPos == state.bufferSize) + { + state.segmentedBufferHelper.RefillBuffer(ref buffer, ref state, true); + } + return buffer[state.bufferPos++]; + } + + /// + /// Reads a varint from the input one byte at a time, so that it does not + /// read any bytes after the end of the varint. If you simply wrapped the + /// stream in a CodedInputStream and used ReadRawVarint32(Stream) + /// then you would probably end up reading past the end of the varint since + /// CodedInputStream buffers its input. + /// + /// + /// + public static uint ReadRawVarint32(Stream input) + { + int result = 0; + int offset = 0; + for (; offset < 32; offset += 7) + { + int b = input.ReadByte(); + if (b == -1) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + result |= (b & 0x7f) << offset; + if ((b & 0x80) == 0) + { + return (uint) result; + } + } + // Keep reading up to 64 bits. + for (; offset < 64; offset += 7) + { + int b = input.ReadByte(); + if (b == -1) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + if ((b & 0x80) == 0) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Decode a 32-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 32 bits to be varint encoded, thus always taking + /// 5 bytes on the wire.) + /// + public static int DecodeZigZag32(uint n) + { + return (int)(n >> 1) ^ -(int)(n & 1); + } + + /// + /// Decode a 64-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + public static long DecodeZigZag64(ulong n) + { + return (long)(n >> 1) ^ -(long)(n & 1); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs b/csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs new file mode 100644 index 0000000000..5be010cc44 --- /dev/null +++ b/csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs @@ -0,0 +1,231 @@ +#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 System.Buffers; +using System.IO; +using System.Runtime.CompilerServices; + +namespace Google.Protobuf +{ + /// + /// Reading and skipping messages / groups + /// + internal static class ParsingPrimitivesMessages + { + public static void SkipLastField(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + if (state.lastTag == 0) + { + throw new InvalidOperationException("SkipLastField cannot be called at the end of a stream"); + } + switch (WireFormat.GetTagWireType(state.lastTag)) + { + case WireFormat.WireType.StartGroup: + SkipGroup(ref buffer, ref state, state.lastTag); + break; + case WireFormat.WireType.EndGroup: + throw new InvalidProtocolBufferException( + "SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing"); + case WireFormat.WireType.Fixed32: + ParsingPrimitives.ParseRawLittleEndian32(ref buffer, ref state); + break; + case WireFormat.WireType.Fixed64: + ParsingPrimitives.ParseRawLittleEndian64(ref buffer, ref state); + break; + case WireFormat.WireType.LengthDelimited: + var length = ParsingPrimitives.ParseLength(ref buffer, ref state); + ParsingPrimitives.SkipRawBytes(ref buffer, ref state, length); + break; + case WireFormat.WireType.Varint: + ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + break; + } + } + + /// + /// Skip a group. + /// + public static void SkipGroup(ref ReadOnlySpan buffer, ref ParserInternalState state, uint startGroupTag) + { + // 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... + state.recursionDepth++; + if (state.recursionDepth >= state.recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + uint tag; + while (true) + { + tag = ParsingPrimitives.ParseTag(ref buffer, ref state); + if (tag == 0) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + // Can't call SkipLastField for this case- that would throw. + if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup) + { + break; + } + // This recursion will allow us to handle nested groups. + SkipLastField(ref buffer, ref state); + } + int startField = WireFormat.GetTagFieldNumber(startGroupTag); + int endField = WireFormat.GetTagFieldNumber(tag); + if (startField != endField) + { + throw new InvalidProtocolBufferException( + $"Mismatched end-group tag. Started with field {startField}; ended with field {endField}"); + } + state.recursionDepth--; + } + + public static void ReadMessage(ref CodedInputReader ctx, IMessage message) + { + int length = ParsingPrimitives.ParseLength(ref ctx.buffer, ref ctx.state); + if (ctx.state.recursionDepth >= ctx.state.recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + int oldLimit = SegmentedBufferHelper.PushLimit(ref ctx.state, length); + ++ctx.state.recursionDepth; + + ReadRawMessage(ref ctx, message); + + CheckReadEndOfStreamTag(ref ctx.state); + // Check that we've read exactly as much data as expected. + if (!SegmentedBufferHelper.IsReachedLimit(ref ctx.state)) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + --ctx.state.recursionDepth; + SegmentedBufferHelper.PopLimit(ref ctx.state, oldLimit); + } + + public static void ReadMessage(ref ParseContext ctx, IMessage message) + { + int length = ParsingPrimitives.ParseLength(ref ctx.buffer, ref ctx.state); + if (ctx.state.recursionDepth >= ctx.state.recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + int oldLimit = SegmentedBufferHelper.PushLimit(ref ctx.state, length); + ++ctx.state.recursionDepth; + + ReadRawMessage(ref ctx, message); + + CheckReadEndOfStreamTag(ref ctx.state); + // Check that we've read exactly as much data as expected. + if (!SegmentedBufferHelper.IsReachedLimit(ref ctx.state)) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + --ctx.state.recursionDepth; + SegmentedBufferHelper.PopLimit(ref ctx.state, oldLimit); + } + + public static void ReadGroup(ref CodedInputReader ctx, IMessage message) + { + if (ctx.state.recursionDepth >= ctx.state.recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + ++ctx.state.recursionDepth; + + ReadRawMessage(ref ctx, message); + + --ctx.state.recursionDepth; + } + + public static void ReadGroup(ref ParseContext ctx, IMessage message) + { + if (ctx.state.recursionDepth >= ctx.state.recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + ++ctx.state.recursionDepth; + + ReadRawMessage(ref ctx, message); + + --ctx.state.recursionDepth; + } + + public static void ReadRawMessage(ref CodedInputReader ctx, IMessage message) + { + if (message is IBufferMessage bufferMessage) + { + bufferMessage.MergeFrom(ref ctx); + } + else + { + if (ctx.state.codedInputStream == null) + { + // TODO: improve the msg + throw new InvalidProtocolBufferException("Cannot parse message with current parse context. Do you need to regenerate the code?"); + } + message.MergeFrom(ctx.state.codedInputStream); + } + } + + public static void ReadRawMessage(ref ParseContext ctx, IMessage message) + { + if (message is IBufferMessage bufferMessage) + { + bufferMessage.MergeFrom_Internal(ref ctx); + } + else + { + if (ctx.state.codedInputStream == null) + { + // TODO: improve the msg + throw new InvalidProtocolBufferException("Cannot parse message with current parse context. Do you need to regenerate the code?"); + } + message.MergeFrom(ctx.state.codedInputStream); + } + } + + /// + /// Verifies that the last call to ReadTag() returned tag 0 - in other words, + /// we've reached the end of the stream when we expected to. + /// + /// The + /// tag read was not the one specified + public static void CheckReadEndOfStreamTag(ref ParserInternalState state) + { + if (state.lastTag != 0) + { + throw InvalidProtocolBufferException.MoreDataAvailable(); + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/ParsingPrimitivesWrappers.cs b/csharp/src/Google.Protobuf/ParsingPrimitivesWrappers.cs new file mode 100644 index 0000000000..fce78ac588 --- /dev/null +++ b/csharp/src/Google.Protobuf/ParsingPrimitivesWrappers.cs @@ -0,0 +1,352 @@ +#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 System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using Google.Protobuf.Collections; + +namespace Google.Protobuf +{ + /// + /// Fast parsing primitives for wrapper types + /// + internal static class ParsingPrimitivesWrappers + { + internal static float? ReadFloatWrapperLittleEndian(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + // length:1 + tag:1 + value:4 = 6 bytes + if (state.bufferPos + 6 <= state.bufferSize) + { + // The entire wrapper message is already contained in `buffer`. + int length = buffer[state.bufferPos]; + if (length == 0) + { + state.bufferPos++; + return 0F; + } + // tag:1 + value:4 = length of 5 bytes + // field=1, type=32-bit = tag of 13 + if (length != 5 || buffer[state.bufferPos + 1] != 13) + { + return ReadFloatWrapperSlow(ref buffer, ref state); + } + state.bufferPos += 2; + return ParsingPrimitives.ParseFloat(ref buffer, ref state); + } + else + { + return ReadFloatWrapperSlow(ref buffer, ref state); + } + } + + internal static float? ReadFloatWrapperSlow(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + if (length == 0) + { + return 0F; + } + int finalBufferPos = state.totalBytesRetired + state.bufferPos + length; + float result = 0F; + do + { + // field=1, type=32-bit = tag of 13 + if (ParsingPrimitives.ParseTag(ref buffer, ref state) == 13) + { + result = ParsingPrimitives.ParseFloat(ref buffer, ref state); + } + else + { + ParsingPrimitivesMessages.SkipLastField(ref buffer, ref state); + } + } + while (state.totalBytesRetired + state.bufferPos < finalBufferPos); + return result; + } + + internal static double? ReadDoubleWrapperLittleEndian(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + // length:1 + tag:1 + value:8 = 10 bytes + if (state.bufferPos + 10 <= state.bufferSize) + { + // The entire wrapper message is already contained in `buffer`. + int length = buffer[state.bufferPos]; + if (length == 0) + { + state.bufferPos++; + return 0D; + } + // tag:1 + value:8 = length of 9 bytes + // field=1, type=64-bit = tag of 9 + if (length != 9 || buffer[state.bufferPos + 1] != 9) + { + return ReadDoubleWrapperSlow(ref buffer, ref state); + } + state.bufferPos += 2; + return ParsingPrimitives.ParseDouble(ref buffer, ref state); + } + else + { + return ReadDoubleWrapperSlow(ref buffer, ref state); + } + } + + internal static double? ReadDoubleWrapperSlow(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + if (length == 0) + { + return 0D; + } + int finalBufferPos = state.totalBytesRetired + state.bufferPos + length; + double result = 0D; + do + { + // field=1, type=64-bit = tag of 9 + if (ParsingPrimitives.ParseTag(ref buffer, ref state) == 9) + { + result = ParsingPrimitives.ParseDouble(ref buffer, ref state); + } + else + { + ParsingPrimitivesMessages.SkipLastField(ref buffer, ref state); + } + } + while (state.totalBytesRetired + state.bufferPos < finalBufferPos); + return result; + } + + internal static bool? ReadBoolWrapper(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + return ReadUInt64Wrapper(ref buffer, ref state) != 0; + } + + internal static uint? ReadUInt32Wrapper(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + // length:1 + tag:1 + value:5(varint32-max) = 7 bytes + if (state.bufferPos + 7 <= state.bufferSize) + { + // The entire wrapper message is already contained in `buffer`. + int pos0 = state.bufferPos; + int length = buffer[state.bufferPos++]; + if (length == 0) + { + return 0; + } + // Length will always fit in a single byte. + if (length >= 128) + { + state.bufferPos = pos0; + return ReadUInt32WrapperSlow(ref buffer, ref state); + } + int finalBufferPos = state.bufferPos + length; + // field=1, type=varint = tag of 8 + if (buffer[state.bufferPos++] != 8) + { + state.bufferPos = pos0; + return ReadUInt32WrapperSlow(ref buffer, ref state); + } + var result = ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + // Verify this message only contained a single field. + if (state.bufferPos != finalBufferPos) + { + state.bufferPos = pos0; + return ReadUInt32WrapperSlow(ref buffer, ref state); + } + return result; + } + else + { + return ReadUInt32WrapperSlow(ref buffer, ref state); + } + } + + internal static uint? ReadUInt32WrapperSlow(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + if (length == 0) + { + return 0; + } + int finalBufferPos = state.totalBytesRetired + state.bufferPos + length; + uint result = 0; + do + { + // field=1, type=varint = tag of 8 + if (ParsingPrimitives.ParseTag(ref buffer, ref state) == 8) + { + result = ParsingPrimitives.ParseRawVarint32(ref buffer, ref state); + } + else + { + ParsingPrimitivesMessages.SkipLastField(ref buffer, ref state); + } + } + while (state.totalBytesRetired + state.bufferPos < finalBufferPos); + return result; + } + + internal static int? ReadInt32Wrapper(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + return (int?)ReadUInt32Wrapper(ref buffer, ref state); + } + + internal static ulong? ReadUInt64Wrapper(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + // field=1, type=varint = tag of 8 + const int expectedTag = 8; + // length:1 + tag:1 + value:10(varint64-max) = 12 bytes + if (state.bufferPos + 12 <= state.bufferSize) + { + // The entire wrapper message is already contained in `buffer`. + int pos0 = state.bufferPos; + int length = buffer[state.bufferPos++]; + if (length == 0) + { + return 0L; + } + // Length will always fit in a single byte. + if (length >= 128) + { + state.bufferPos = pos0; + return ReadUInt64WrapperSlow(ref buffer, ref state); + } + int finalBufferPos = state.bufferPos + length; + if (buffer[state.bufferPos++] != expectedTag) + { + state.bufferPos = pos0; + return ReadUInt64WrapperSlow(ref buffer, ref state); + } + var result = ParsingPrimitives.ParseRawVarint64(ref buffer, ref state); + // Verify this message only contained a single field. + if (state.bufferPos != finalBufferPos) + { + state.bufferPos = pos0; + return ReadUInt64WrapperSlow(ref buffer, ref state); + } + return result; + } + else + { + return ReadUInt64WrapperSlow(ref buffer, ref state); + } + } + + internal static ulong? ReadUInt64WrapperSlow(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + // field=1, type=varint = tag of 8 + const int expectedTag = 8; + int length = ParsingPrimitives.ParseLength(ref buffer, ref state); + if (length == 0) + { + return 0L; + } + int finalBufferPos = state.totalBytesRetired + state.bufferPos + length; + ulong result = 0L; + do + { + if (ParsingPrimitives.ParseTag(ref buffer, ref state) == expectedTag) + { + result = ParsingPrimitives.ParseRawVarint64(ref buffer, ref state); + } + else + { + ParsingPrimitivesMessages.SkipLastField(ref buffer, ref state); + } + } + while (state.totalBytesRetired + state.bufferPos < finalBufferPos); + return result; + } + + internal static long? ReadInt64Wrapper(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + return (long?)ReadUInt64Wrapper(ref buffer, ref state); + } + + internal static float? ReadFloatWrapperLittleEndian(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadFloatWrapperLittleEndian(ref ctx.buffer, ref ctx.state); + } + + internal static float? ReadFloatWrapperSlow(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadFloatWrapperSlow(ref ctx.buffer, ref ctx.state); + } + + internal static double? ReadDoubleWrapperLittleEndian(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadDoubleWrapperLittleEndian(ref ctx.buffer, ref ctx.state); + } + + internal static double? ReadDoubleWrapperSlow(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadDoubleWrapperSlow(ref ctx.buffer, ref ctx.state); + } + + internal static bool? ReadBoolWrapper(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadBoolWrapper(ref ctx.buffer, ref ctx.state); + } + + internal static uint? ReadUInt32Wrapper(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadUInt32Wrapper(ref ctx.buffer, ref ctx.state); + } + + internal static int? ReadInt32Wrapper(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadInt32Wrapper(ref ctx.buffer, ref ctx.state); + } + + internal static ulong? ReadUInt64Wrapper(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadUInt64Wrapper(ref ctx.buffer, ref ctx.state); + } + + internal static ulong? ReadUInt64WrapperSlow(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadUInt64WrapperSlow(ref ctx.buffer, ref ctx.state); + } + + internal static long? ReadInt64Wrapper(ref ParseContext ctx) + { + return ParsingPrimitivesWrappers.ReadInt64Wrapper(ref ctx.buffer, ref ctx.state); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/SegmentedBufferHelper.cs b/csharp/src/Google.Protobuf/SegmentedBufferHelper.cs new file mode 100644 index 0000000000..2c9db88e95 --- /dev/null +++ b/csharp/src/Google.Protobuf/SegmentedBufferHelper.cs @@ -0,0 +1,283 @@ +#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 System.Buffers; +using System.IO; +using System.Runtime.CompilerServices; + +namespace Google.Protobuf +{ + /// + /// Abstraction for reading from a stream / read only sequence. + /// Parsing from the buffer is a loop of reading from current buffer / refreshing the buffer once done. + /// + internal struct SegmentedBufferHelper + { + private readonly int? totalLength; + private ReadOnlySequence.Enumerator readOnlySequenceEnumerator; + private readonly CodedInputStream codedInputStream; + + public SegmentedBufferHelper(ReadOnlySequence sequence, out ReadOnlySpan firstSpan) + { + this.codedInputStream = null; + if (sequence.IsSingleSegment) + { + firstSpan = sequence.First.Span; + this.totalLength = firstSpan.Length; + this.readOnlySequenceEnumerator = default; + } + else + { + // TODO(jtattermusch): try to initialize the first segment, otherwise the + // very first read will result in slowpath (because the first thing to do is to + // refill to get the first buffer segment) + firstSpan = default; + this.totalLength = (int) sequence.Length; + this.readOnlySequenceEnumerator = sequence.GetEnumerator(); + } + } + + public SegmentedBufferHelper(CodedInputStream codedInputStream) + { + this.totalLength = codedInputStream.InternalInputStream == null ? (int?)codedInputStream.InternalBuffer.Length : null; + this.readOnlySequenceEnumerator = default; + this.codedInputStream = codedInputStream; + } + + public bool RefillBuffer(ref ReadOnlySpan buffer, ref ParserInternalState state, bool mustSucceed) + { + if (codedInputStream != null) + { + return RefillFromCodedInputStream(ref buffer, ref state, mustSucceed); + } + else + { + return RefillFromReadOnlySequence(ref buffer, ref state, mustSucceed); + } + } + + public int? TotalLength => totalLength; + + public CodedInputStream CodedInputStream => codedInputStream; + + /// + /// Sets currentLimit to (current position) + byteLimit. This is called + /// when descending into a length-delimited embedded message. The previous + /// limit is returned. + /// + /// The old limit. + public static int PushLimit(ref ParserInternalState state, int byteLimit) + { + if (byteLimit < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + byteLimit += state.totalBytesRetired + state.bufferPos; + int oldLimit = state.currentLimit; + if (byteLimit > oldLimit) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + state.currentLimit = byteLimit; + + RecomputeBufferSizeAfterLimit(ref state); + + return oldLimit; + } + + /// + /// Discards the current limit, returning the previous limit. + /// + public static void PopLimit(ref ParserInternalState state, int oldLimit) + { + state.currentLimit = oldLimit; + RecomputeBufferSizeAfterLimit(ref state); + } + + /// + /// Returns whether or not all the data before the limit has been read. + /// + /// + public static bool IsReachedLimit(ref ParserInternalState state) + { + if (state.currentLimit == int.MaxValue) + { + return false; + } + int currentAbsolutePosition = state.totalBytesRetired + state.bufferPos; + return currentAbsolutePosition >= state.currentLimit; + } + + /// + /// Returns true if the stream has reached the end of the input. This is the + /// case if either the end of the underlying input source has been reached or + /// the stream has reached a limit created using PushLimit. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool IsAtEnd(ref ReadOnlySpan buffer, ref ParserInternalState state) + { + return state.bufferPos == state.bufferSize && !state.segmentedBufferHelper.RefillBuffer(ref buffer, ref state, false); + } + + private bool RefillFromReadOnlySequence(ref ReadOnlySpan buffer, ref ParserInternalState state, bool mustSucceed) + { + CheckCurrentBufferIsEmpty(ref state); + + if (state.totalBytesRetired + state.bufferSize == state.currentLimit) + { + // Oops, we hit a limit. + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + + state.totalBytesRetired += state.bufferSize; + + state.bufferPos = 0; + state.bufferSize = 0; + while (readOnlySequenceEnumerator.MoveNext()) + { + + buffer = readOnlySequenceEnumerator.Current.Span; + state.bufferSize = buffer.Length; + if (buffer.Length != 0) + { + break; + } + } + + if (state.bufferSize == 0) + { + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + else + { + RecomputeBufferSizeAfterLimit(ref state); + int totalBytesRead = + state.totalBytesRetired + state.bufferSize + state.bufferSizeAfterLimit; + if (totalBytesRead < 0 || totalBytesRead > state.sizeLimit) + { + throw InvalidProtocolBufferException.SizeLimitExceeded(); + } + return true; + } + } + + private bool RefillFromCodedInputStream(ref ReadOnlySpan buffer, ref ParserInternalState state, bool mustSucceed) + { + CheckCurrentBufferIsEmpty(ref state); + + if (state.totalBytesRetired + state.bufferSize == state.currentLimit) + { + // Oops, we hit a limit. + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + + Stream input = codedInputStream.InternalInputStream; + + state.totalBytesRetired += state.bufferSize; + + state.bufferPos = 0; + state.bufferSize = (input == null) ? 0 : input.Read(codedInputStream.InternalBuffer, 0, buffer.Length); + if (state.bufferSize < 0) + { + throw new InvalidOperationException("Stream.Read returned a negative count"); + } + if (state.bufferSize == 0) + { + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + else + { + RecomputeBufferSizeAfterLimit(ref state); + int totalBytesRead = + state.totalBytesRetired + state.bufferSize + state.bufferSizeAfterLimit; + if (totalBytesRead < 0 || totalBytesRead > state.sizeLimit) + { + throw InvalidProtocolBufferException.SizeLimitExceeded(); + } + return true; + } + } + + private static void RecomputeBufferSizeAfterLimit(ref ParserInternalState state) + { + state.bufferSize += state.bufferSizeAfterLimit; + int bufferEnd = state.totalBytesRetired + state.bufferSize; + if (bufferEnd > state.currentLimit) + { + // Limit is in current buffer. + state.bufferSizeAfterLimit = bufferEnd - state.currentLimit; + state.bufferSize -= state.bufferSizeAfterLimit; + } + else + { + state.bufferSizeAfterLimit = 0; + } + } + + private static void CheckCurrentBufferIsEmpty(ref ParserInternalState state) + { + if (state.bufferPos < state.bufferSize) + { + throw new InvalidOperationException("RefillBuffer() called when buffer wasn't empty."); + } + } + } +} \ No newline at end of file From ea605381e60501c848ec6bc20942d159cdd144b2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 31 Mar 2020 18:56:05 +0200 Subject: [PATCH 02/36] make everything build --- .../Google.Protobuf.Test.TestProtos.csproj | 2 +- .../CodedInputStreamTest.cs | 124 +++++++-------- .../CodedOutputStreamTest.cs | 24 +-- .../Google.Protobuf.Test/FieldCodecTest.cs | 6 +- csharp/src/Google.Protobuf/ByteString.cs | 4 +- .../src/Google.Protobuf/CodedInputStream.cs | 5 +- .../Collections/RepeatedField.cs | 34 ++++- csharp/src/Google.Protobuf/ExtensionValue.cs | 57 ++++--- csharp/src/Google.Protobuf/FieldCodec.cs | 144 ++++++++++++------ .../Google.Protobuf/Google.Protobuf.csproj | 26 ++-- csharp/src/Google.Protobuf/IBufferMessage.cs | 16 +- csharp/src/Google.Protobuf/ParseContext.cs | 5 + .../ParsingPrimitivesMessages.cs | 86 +++++------ csharp/src/Google.Protobuf/UnknownFieldSet.cs | 62 +++++--- 14 files changed, 343 insertions(+), 252 deletions(-) diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj b/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj index 5b705804aa..1af85e0a54 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj +++ b/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj @@ -6,7 +6,7 @@ and without the internal visibility from the test project (all of which have caused issues in the past). --> - net45;netstandard1.0;netstandard2.0 + net45;netstandard1.1;netstandard2.0 3.0 ../../keys/Google.Protobuf.snk true diff --git a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs index 5f360ff46e..46f8d01e37 100644 --- a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs +++ b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs @@ -202,29 +202,29 @@ namespace Google.Protobuf [Test] public void DecodeZigZag32() { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0)); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1)); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2)); - Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3)); - Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE)); - Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF)); - Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE)); - Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF)); + Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag32(0)); + Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag32(1)); + Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag32(2)); + Assert.AreEqual(-2, ParsingPrimitives.DecodeZigZag32(3)); + Assert.AreEqual(0x3FFFFFFF, ParsingPrimitives.DecodeZigZag32(0x7FFFFFFE)); + Assert.AreEqual(unchecked((int) 0xC0000000), ParsingPrimitives.DecodeZigZag32(0x7FFFFFFF)); + Assert.AreEqual(0x7FFFFFFF, ParsingPrimitives.DecodeZigZag32(0xFFFFFFFE)); + Assert.AreEqual(unchecked((int) 0x80000000), ParsingPrimitives.DecodeZigZag32(0xFFFFFFFF)); } [Test] public void DecodeZigZag64() { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0)); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1)); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2)); - Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3)); - Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL)); - Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL)); - Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL)); - Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL)); - Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); - Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); + Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag64(0)); + Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag64(1)); + Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag64(2)); + Assert.AreEqual(-2, ParsingPrimitives.DecodeZigZag64(3)); + Assert.AreEqual(0x000000003FFFFFFFL, ParsingPrimitives.DecodeZigZag64(0x000000007FFFFFFEL)); + Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), ParsingPrimitives.DecodeZigZag64(0x000000007FFFFFFFL)); + Assert.AreEqual(0x000000007FFFFFFFL, ParsingPrimitives.DecodeZigZag64(0x00000000FFFFFFFEL)); + Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), ParsingPrimitives.DecodeZigZag64(0x00000000FFFFFFFFL)); + Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, ParsingPrimitives.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); + Assert.AreEqual(unchecked((long) 0x8000000000000000L), ParsingPrimitives.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); } [Test] @@ -339,64 +339,64 @@ namespace Google.Protobuf Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(input)); } - private static byte[] MakeMaliciousRecursionUnknownFieldsPayload(int recursionDepth) - { - // generate recursively nested groups that will be parsed as unknown fields - int unknownFieldNumber = 14; // an unused field number - MemoryStream ms = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(ms); - for (int i = 0; i < recursionDepth; i++) - { - output.WriteTag(WireFormat.MakeTag(unknownFieldNumber, WireFormat.WireType.StartGroup)); - } - for (int i = 0; i < recursionDepth; i++) - { - output.WriteTag(WireFormat.MakeTag(unknownFieldNumber, WireFormat.WireType.EndGroup)); - } - output.Flush(); - return ms.ToArray(); + private static byte[] MakeMaliciousRecursionUnknownFieldsPayload(int recursionDepth) + { + // generate recursively nested groups that will be parsed as unknown fields + int unknownFieldNumber = 14; // an unused field number + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + for (int i = 0; i < recursionDepth; i++) + { + output.WriteTag(WireFormat.MakeTag(unknownFieldNumber, WireFormat.WireType.StartGroup)); + } + for (int i = 0; i < recursionDepth; i++) + { + output.WriteTag(WireFormat.MakeTag(unknownFieldNumber, WireFormat.WireType.EndGroup)); + } + output.Flush(); + return ms.ToArray(); } [Test] public void MaliciousRecursion_UnknownFields() { - byte[] payloadAtRecursiveLimit = MakeMaliciousRecursionUnknownFieldsPayload(CodedInputStream.DefaultRecursionLimit); - byte[] payloadBeyondRecursiveLimit = MakeMaliciousRecursionUnknownFieldsPayload(CodedInputStream.DefaultRecursionLimit + 1); - - Assert.DoesNotThrow(() => TestRecursiveMessage.Parser.ParseFrom(payloadAtRecursiveLimit)); + byte[] payloadAtRecursiveLimit = MakeMaliciousRecursionUnknownFieldsPayload(CodedInputStream.DefaultRecursionLimit); + byte[] payloadBeyondRecursiveLimit = MakeMaliciousRecursionUnknownFieldsPayload(CodedInputStream.DefaultRecursionLimit + 1); + + Assert.DoesNotThrow(() => TestRecursiveMessage.Parser.ParseFrom(payloadAtRecursiveLimit)); Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(payloadBeyondRecursiveLimit)); } [Test] public void ReadGroup_WrongEndGroupTag() - { - int groupFieldNumber = Proto2.TestAllTypes.OptionalGroupFieldNumber; - - // write Proto2.TestAllTypes with "optional_group" set, but use wrong EndGroup closing tag - MemoryStream ms = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(ms); - output.WriteTag(WireFormat.MakeTag(groupFieldNumber, WireFormat.WireType.StartGroup)); - output.WriteGroup(new Proto2.TestAllTypes.Types.OptionalGroup { A = 12345 }); - // end group with different field number - output.WriteTag(WireFormat.MakeTag(groupFieldNumber + 1, WireFormat.WireType.EndGroup)); - output.Flush(); - var payload = ms.ToArray(); - - Assert.Throws(() => Proto2.TestAllTypes.Parser.ParseFrom(payload)); + { + int groupFieldNumber = Proto2.TestAllTypes.OptionalGroupFieldNumber; + + // write Proto2.TestAllTypes with "optional_group" set, but use wrong EndGroup closing tag + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + output.WriteTag(WireFormat.MakeTag(groupFieldNumber, WireFormat.WireType.StartGroup)); + output.WriteGroup(new Proto2.TestAllTypes.Types.OptionalGroup { A = 12345 }); + // end group with different field number + output.WriteTag(WireFormat.MakeTag(groupFieldNumber + 1, WireFormat.WireType.EndGroup)); + output.Flush(); + var payload = ms.ToArray(); + + Assert.Throws(() => Proto2.TestAllTypes.Parser.ParseFrom(payload)); } [Test] public void ReadGroup_UnknownFields_WrongEndGroupTag() - { - MemoryStream ms = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(ms); - output.WriteTag(WireFormat.MakeTag(14, WireFormat.WireType.StartGroup)); - // end group with different field number - output.WriteTag(WireFormat.MakeTag(15, WireFormat.WireType.EndGroup)); - output.Flush(); - var payload = ms.ToArray(); - - Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(payload)); + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + output.WriteTag(WireFormat.MakeTag(14, WireFormat.WireType.StartGroup)); + // end group with different field number + output.WriteTag(WireFormat.MakeTag(15, WireFormat.WireType.EndGroup)); + output.Flush(); + var payload = ms.ToArray(); + + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(payload)); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs index 98cabd55ad..b9ff51521f 100644 --- a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs +++ b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs @@ -247,26 +247,26 @@ namespace Google.Protobuf { // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1) // were chosen semi-randomly via keyboard bashing. - Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0))); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1))); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1))); - Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927))); - Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612))); + Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0))); + Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1))); + Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1))); + Assert.AreEqual(14927, ParsingPrimitives.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927))); + Assert.AreEqual(-3612, ParsingPrimitives.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612))); } [Test] public void RoundTripZigZag64() { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0))); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1))); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1))); - Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927))); - Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612))); + Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0))); + Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1))); + Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1))); + Assert.AreEqual(14927, ParsingPrimitives.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927))); + Assert.AreEqual(-3612, ParsingPrimitives.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612))); Assert.AreEqual(856912304801416L, - CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L))); + ParsingPrimitives.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L))); Assert.AreEqual(-75123905439571256L, - CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L))); + ParsingPrimitives.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L))); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs index b20ecccde2..5be0cecd99 100644 --- a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs +++ b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs @@ -128,7 +128,7 @@ namespace Google.Protobuf codedOutput.Flush(); stream.Position = 0; var codedInput = new CodedInputStream(stream); - Assert.AreEqual(sampleValue, codec.ValueReader(codedInput)); + Assert.AreEqual(sampleValue, codec.Read(codedInput)); Assert.IsTrue(codedInput.IsAtEnd); } @@ -158,7 +158,7 @@ namespace Google.Protobuf { // WriteTagAndValue ignores default values var stream = new MemoryStream(); - CodedOutputStream codedOutput; + CodedOutputStream codedOutput; #if !NET35 codedOutput = new CodedOutputStream(stream); codec.WriteTagAndValue(codedOutput, codec.DefaultValue); @@ -181,7 +181,7 @@ namespace Google.Protobuf Assert.AreEqual(stream.Position, codec.ValueSizeCalculator(codec.DefaultValue)); stream.Position = 0; var codedInput = new CodedInputStream(stream); - Assert.AreEqual(codec.DefaultValue, codec.ValueReader(codedInput)); + Assert.AreEqual(codec.DefaultValue, codec.Read(codedInput)); } } diff --git a/csharp/src/Google.Protobuf/ByteString.cs b/csharp/src/Google.Protobuf/ByteString.cs index 3eb00e5bb5..8e7d03fea0 100644 --- a/csharp/src/Google.Protobuf/ByteString.cs +++ b/csharp/src/Google.Protobuf/ByteString.cs @@ -160,7 +160,7 @@ namespace Google.Protobuf int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0; var memoryStream = new MemoryStream(capacity); stream.CopyTo(memoryStream); -#if NETSTANDARD1_0 || NETSTANDARD2_0 +#if NETSTANDARD1_1 || NETSTANDARD2_0 byte[] bytes = memoryStream.ToArray(); #else // Avoid an extra copy if we can. @@ -186,7 +186,7 @@ namespace Google.Protobuf // We have to specify the buffer size here, as there's no overload accepting the cancellation token // alone. But it's documented to use 81920 by default if not specified. await stream.CopyToAsync(memoryStream, 81920, cancellationToken); -#if NETSTANDARD1_0 || NETSTANDARD2_0 +#if NETSTANDARD1_1 || NETSTANDARD2_0 byte[] bytes = memoryStream.ToArray(); #else // Avoid an extra copy if we can. diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs index 248f7e4a3d..3235cca2d6 100644 --- a/csharp/src/Google.Protobuf/CodedInputStream.cs +++ b/csharp/src/Google.Protobuf/CodedInputStream.cs @@ -431,15 +431,14 @@ namespace Google.Protobuf public void ReadMessage(IMessage builder) { var span = new ReadOnlySpan(buffer); - var ctx = new CodedInputReader(ref span, ref state); + var ctx = new ParseContext(ref span, ref state); try { ParsingPrimitivesMessages.ReadMessage(ref ctx, builder); } finally { - // store the state - state = ctx.state; + ctx.CopyStateTo(this); } } diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs index 0e8bb61764..c1b34eafdb 100644 --- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs +++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs @@ -94,23 +94,41 @@ namespace Google.Protobuf.Collections /// The input stream to read from. /// The codec to use in order to read each entry. public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) + { + var ctx = new ParseContext(input); + try + { + AddEntriesFrom(ref ctx, codec); + } + finally + { + ctx.CopyStateTo(input); + } + } + + /// + /// Adds the entries from the given parse context, decoding them with the specified codec. + /// + /// The input to read from. + /// The codec to use in order to read each entry. + public void AddEntriesFrom(ref ParseContext ctx, FieldCodec codec) { // TODO: Inline some of the Add code, so we can avoid checking the size on every // iteration. - uint tag = input.LastTag; + uint tag = ctx.state.lastTag; var reader = codec.ValueReader; // Non-nullable value types can be packed or not. if (FieldCodec.IsPackedRepeatedField(tag)) { - int length = input.ReadLength(); + int length = ctx.ReadLength(); if (length > 0) { - int oldLimit = input.PushLimit(length); - while (!input.ReachedLimit) + int oldLimit = SegmentedBufferHelper.PushLimit(ref ctx.state, length); + while (!SegmentedBufferHelper.IsReachedLimit(ref ctx.state)) { - Add(reader(input)); + Add(reader(ref ctx)); } - input.PopLimit(oldLimit); + SegmentedBufferHelper.PopLimit(ref ctx.state, oldLimit); } // Empty packed field. Odd, but valid - just ignore. } @@ -119,8 +137,8 @@ namespace Google.Protobuf.Collections // Not packed... (possibly not packable) do { - Add(reader(input)); - } while (input.MaybeConsumeTag(tag)); + Add(reader(ref ctx)); + } while (ParsingPrimitives.MaybeConsumeTag(ref ctx.buffer, ref ctx.state, tag)); } } diff --git a/csharp/src/Google.Protobuf/ExtensionValue.cs b/csharp/src/Google.Protobuf/ExtensionValue.cs index 6ee737a7b0..74bd62c8e2 100644 --- a/csharp/src/Google.Protobuf/ExtensionValue.cs +++ b/csharp/src/Google.Protobuf/ExtensionValue.cs @@ -93,14 +93,27 @@ namespace Google.Protobuf public void MergeFrom(CodedInputStream input) { - codec.ValueMerger(input, ref field); + var ctx = new ParseContext(input); + try + { + codec.ValueMerger(ref ctx, ref field); + } + finally + { + ctx.CopyStateTo(input); + } + } + + public void MergeFrom(ref ParseContext ctx) + { + codec.ValueMerger(ref ctx, ref field); } public void MergeFrom(IExtensionValue value) { if (value is ExtensionValue) { - var extensionValue = value as ExtensionValue; + var extensionValue = value as ExtensionValue; codec.FieldMerger(ref field, extensionValue.field); } } @@ -124,13 +137,13 @@ namespace Google.Protobuf public bool IsInitialized() { - if (field is IMessage) - { - return (field as IMessage).IsInitialized(); + if (field is IMessage) + { + return (field as IMessage).IsInitialized(); } - else - { - return true; + else + { + return true; } } } @@ -202,20 +215,20 @@ namespace Google.Protobuf public bool IsInitialized() { - for (int i = 0; i < field.Count; i++) - { - var element = field[i]; - if (element is IMessage) - { - if (!(element as IMessage).IsInitialized()) - { - return false; - } - } - else - { - break; - } + for (int i = 0; i < field.Count; i++) + { + var element = field[i]; + if (element is IMessage) + { + if (!(element as IMessage).IsInitialized()) + { + return false; + } + } + else + { + break; + } } return true; diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs index 1971261649..50cf8f3716 100644 --- a/csharp/src/Google.Protobuf/FieldCodec.cs +++ b/csharp/src/Google.Protobuf/FieldCodec.cs @@ -218,7 +218,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForString(uint tag, string defaultValue) { - return new FieldCodec(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag, defaultValue); } /// @@ -229,7 +229,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForBytes(uint tag, ByteString defaultValue) { - return new FieldCodec(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag, defaultValue); } /// @@ -240,7 +240,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForBool(uint tag, bool defaultValue) { - return new FieldCodec(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.BoolSize, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.BoolSize, tag, defaultValue); } /// @@ -251,7 +251,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForInt32(uint tag, int defaultValue) { - return new FieldCodec(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag, defaultValue); } /// @@ -262,7 +262,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForSInt32(uint tag, int defaultValue) { - return new FieldCodec(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag, defaultValue); } /// @@ -273,7 +273,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForFixed32(uint tag, uint defaultValue) { - return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag, defaultValue); } /// @@ -284,7 +284,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForSFixed32(uint tag, int defaultValue) { - return new FieldCodec(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag, defaultValue); } /// @@ -295,7 +295,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForUInt32(uint tag, uint defaultValue) { - return new FieldCodec(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag, defaultValue); } /// @@ -306,7 +306,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForInt64(uint tag, long defaultValue) { - return new FieldCodec(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag, defaultValue); } /// @@ -317,7 +317,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForSInt64(uint tag, long defaultValue) { - return new FieldCodec(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag, defaultValue); } /// @@ -328,7 +328,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForFixed64(uint tag, ulong defaultValue) { - return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag, defaultValue); } /// @@ -339,7 +339,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForSFixed64(uint tag, long defaultValue) { - return new FieldCodec(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag, defaultValue); } /// @@ -350,7 +350,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForUInt64(uint tag, ulong defaultValue) { - return new FieldCodec(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag, defaultValue); } /// @@ -361,7 +361,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForFloat(uint tag, float defaultValue) { - return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag, defaultValue); } /// @@ -372,7 +372,7 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForDouble(uint tag, double defaultValue) { - return new FieldCodec(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag, defaultValue); + return new FieldCodec((ref ParseContext ctx) => ctx.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag, defaultValue); } // Enums are tricky. We can probably use expression trees to build these delegates automatically, @@ -388,8 +388,8 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32, T defaultValue) { - return new FieldCodec(input => fromInt32( - input.ReadEnum()), + return new FieldCodec((ref ParseContext ctx) => fromInt32( + ctx.ReadEnum()), (output, value) => output.WriteEnum(toInt32(value)), value => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag, defaultValue); } @@ -403,21 +403,21 @@ namespace Google.Protobuf public static FieldCodec ForMessage(uint tag, MessageParser parser) where T : class, IMessage { return new FieldCodec( - input => + (ref ParseContext ctx) => { T message = parser.CreateTemplate(); - input.ReadMessage(message); + ctx.ReadMessage(message); return message; }, (output, value) => output.WriteMessage(value), - (CodedInputStream i, ref T v) => + (ref ParseContext ctx, ref T v) => { if (v == null) { v = parser.CreateTemplate(); } - i.ReadMessage(v); + ctx.ReadMessage(v); }, (ref T v, T v2) => { @@ -448,21 +448,21 @@ namespace Google.Protobuf public static FieldCodec ForGroup(uint startTag, uint endTag, MessageParser parser) where T : class, IMessage { return new FieldCodec( - input => + (ref ParseContext ctx) => { T message = parser.CreateTemplate(); - input.ReadGroup(message); + ctx.ReadGroup(message); return message; }, (output, value) => output.WriteGroup(value), - (CodedInputStream i, ref T v) => + (ref ParseContext ctx, ref T v) => { if (v == null) { v = parser.CreateTemplate(); } - i.ReadGroup(v); + ctx.ReadGroup(v); }, (ref T v, T v2) => { @@ -490,9 +490,9 @@ namespace Google.Protobuf { var nestedCodec = WrapperCodecs.GetCodec(); return new FieldCodec( - input => WrapperCodecs.Read(input, nestedCodec), + (ref ParseContext ctx) => WrapperCodecs.Read(ref ctx, nestedCodec), (output, value) => WrapperCodecs.Write(output, value, nestedCodec), - (CodedInputStream i, ref T v) => v = WrapperCodecs.Read(i, nestedCodec), + (ref ParseContext ctx, ref T v) => v = WrapperCodecs.Read(ref ctx, nestedCodec), (ref T v, T v2) => { v = v2; return v == null; }, value => WrapperCodecs.CalculateSize(value, nestedCodec), tag, 0, @@ -509,7 +509,7 @@ namespace Google.Protobuf return new FieldCodec( WrapperCodecs.GetReader(), (output, value) => WrapperCodecs.Write(output, value.Value, nestedCodec), - (CodedInputStream i, ref T? v) => v = WrapperCodecs.Read(i, nestedCodec), + (ref ParseContext ctx, ref T? v) => v = WrapperCodecs.Read(ref ctx, nestedCodec), (ref T? v, T? v2) => { if (v2.HasValue) { v = v2; } return v.HasValue; }, value => value == null ? 0 : WrapperCodecs.CalculateSize(value.Value, nestedCodec), tag, 0, @@ -542,17 +542,17 @@ namespace Google.Protobuf private static readonly Dictionary Readers = new Dictionary { // TODO: Provide more optimized readers. - { typeof(bool), (Func)CodedInputStream.ReadBoolWrapper }, - { typeof(int), (Func)CodedInputStream.ReadInt32Wrapper }, - { typeof(long), (Func)CodedInputStream.ReadInt64Wrapper }, - { typeof(uint), (Func)CodedInputStream.ReadUInt32Wrapper }, - { typeof(ulong), (Func)CodedInputStream.ReadUInt64Wrapper }, + { typeof(bool), (ValueReader)ParsingPrimitivesWrappers.ReadBoolWrapper }, + { typeof(int), (ValueReader)ParsingPrimitivesWrappers.ReadInt32Wrapper }, + { typeof(long), (ValueReader)ParsingPrimitivesWrappers.ReadInt64Wrapper }, + { typeof(uint), (ValueReader)ParsingPrimitivesWrappers.ReadUInt32Wrapper }, + { typeof(ulong), (ValueReader)ParsingPrimitivesWrappers.ReadUInt64Wrapper }, { typeof(float), BitConverter.IsLittleEndian ? - (Func)CodedInputStream.ReadFloatWrapperLittleEndian : - (Func)CodedInputStream.ReadFloatWrapperSlow }, + (ValueReader)ParsingPrimitivesWrappers.ReadFloatWrapperLittleEndian : + (ValueReader)ParsingPrimitivesWrappers.ReadFloatWrapperSlow }, { typeof(double), BitConverter.IsLittleEndian ? - (Func)CodedInputStream.ReadDoubleWrapperLittleEndian : - (Func)CodedInputStream.ReadDoubleWrapperSlow }, + (ValueReader)ParsingPrimitivesWrappers.ReadDoubleWrapperLittleEndian : + (ValueReader)ParsingPrimitivesWrappers.ReadDoubleWrapperSlow }, // `string` and `ByteString` less performance-sensitive. Do not implement for now. { typeof(string), null }, { typeof(ByteString), null }, @@ -572,7 +572,7 @@ namespace Google.Protobuf return (FieldCodec) value; } - internal static Func GetReader() where T : struct + internal static ValueReader GetReader() where T : struct { object value; if (!Readers.TryGetValue(typeof(T), out value)) @@ -583,10 +583,10 @@ namespace Google.Protobuf { // Return default unoptimized reader for the wrapper type. var nestedCoded = GetCodec(); - return input => Read(input, nestedCoded); + return (ref ParseContext ctx) => Read(ref ctx, nestedCoded); } // Return optimized read for the wrapper type. - return (Func)value; + return (ValueReader)value; } internal static T Read(CodedInputStream input, FieldCodec codec) @@ -614,6 +614,31 @@ namespace Google.Protobuf return value; } + internal static T Read(ref ParseContext ctx, FieldCodec codec) + { + int length = ctx.ReadLength(); + int oldLimit = SegmentedBufferHelper.PushLimit(ref ctx.state, length); + + uint tag; + T value = codec.DefaultValue; + while ((tag = ctx.ReadTag()) != 0) + { + if (tag == codec.Tag) + { + value = codec.Read(ref ctx); + } + else + { + ParsingPrimitivesMessages.SkipLastField(ref ctx.buffer, ref ctx.state); + } + + } + ParsingPrimitivesMessages.CheckReadEndOfStreamTag(ref ctx.state); + SegmentedBufferHelper.PopLimit(ref ctx.state, oldLimit); + + return value; + } + internal static void Write(CodedOutputStream output, T value, FieldCodec codec) { output.WriteLength(codec.CalculateSizeWithTag(value)); @@ -628,6 +653,8 @@ namespace Google.Protobuf } } + internal delegate TValue ValueReader(ref ParseContext ctx); + /// /// /// An encode/decode pair for a single field. This effectively encapsulates @@ -653,7 +680,7 @@ namespace Google.Protobuf /// /// Merges an input stream into a value /// - internal delegate void InputMerger(CodedInputStream input, ref T value); + internal delegate void InputMerger(ref ParseContext ctx, ref T value); /// /// Merges a value into a reference to another value, returning a boolean if the value was set @@ -692,7 +719,7 @@ namespace Google.Protobuf /// Returns a delegate to read a value from a coded input stream. It is assumed that /// the stream is already positioned on the appropriate tag. /// - internal Func ValueReader { get; } + internal ValueReader ValueReader { get; } /// /// Returns a delegate to merge a value from a coded input stream. @@ -739,7 +766,7 @@ namespace Google.Protobuf private readonly int tagSize; internal FieldCodec( - Func reader, + ValueReader reader, Action writer, int fixedSize, uint tag, @@ -749,16 +776,16 @@ namespace Google.Protobuf } internal FieldCodec( - Func reader, + ValueReader reader, Action writer, Func sizeCalculator, uint tag, - T defaultValue) : this(reader, writer, (CodedInputStream i, ref T v) => v = reader(i), (ref T v, T v2) => { v = v2; return true; }, sizeCalculator, tag, 0, defaultValue) + T defaultValue) : this(reader, writer, (ref ParseContext ctx, ref T v) => v = reader(ref ctx), (ref T v, T v2) => { v = v2; return true; }, sizeCalculator, tag, 0, defaultValue) { } internal FieldCodec( - Func reader, + ValueReader reader, Action writer, InputMerger inputMerger, ValuesMerger valuesMerger, @@ -769,7 +796,7 @@ namespace Google.Protobuf } internal FieldCodec( - Func reader, + ValueReader reader, Action writer, InputMerger inputMerger, ValuesMerger valuesMerger, @@ -815,7 +842,28 @@ namespace Google.Protobuf /// /// The input stream to read from. /// The value read from the stream. - public T Read(CodedInputStream input) => ValueReader(input); + public T Read(CodedInputStream input) + { + var ctx = new ParseContext(input); + try + { + return ValueReader(ref ctx); + } + finally + { + ctx.CopyStateTo(input); + } + } + + /// + /// Reads a value of the codec type from the given . + /// + /// The parse context to read from. + /// The value read. + public T Read(ref ParseContext ctx) + { + return ValueReader(ref ctx); + } /// /// Calculates the size required to write the given value, with a tag, diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 53f45febc7..ab1df4aa3c 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -1,13 +1,14 @@ - + C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers 3.11.4 - 6 + + 7.2 Google Inc. - netstandard1.0;netstandard2.0;net45 + netstandard1.1;netstandard2.0;net45 true ../../keys/Google.Protobuf.snk true @@ -18,25 +19,26 @@ https://github.com/protocolbuffers/protobuf/blob/master/LICENSE git https://github.com/protocolbuffers/protobuf.git + $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + True $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + + $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_FAST_STRING - - - - - + + + - - + + + diff --git a/csharp/src/Google.Protobuf/IBufferMessage.cs b/csharp/src/Google.Protobuf/IBufferMessage.cs index ddd49b1bb4..5fccc87048 100644 --- a/csharp/src/Google.Protobuf/IBufferMessage.cs +++ b/csharp/src/Google.Protobuf/IBufferMessage.cs @@ -35,29 +35,15 @@ namespace Google.Protobuf #if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY /// /// Interface for a Protocol Buffers message, supporting - /// and - /// serialization operations. + /// parsing from . /// public interface IBufferMessage : IMessage { - /// - /// Merges the data from the specified with the current message. - /// - /// See the user guide for precise merge semantics. - /// to read data from. Must not be null. - void MergeFrom(ref CodedInputReader input); - /// /// Internal implementation of merging data from given parse context into this message. /// Users should never invoke this method directly. /// void MergeFrom_Internal(ref ParseContext ctx); - - /// - /// Writes the data to the given . - /// - /// to write the data to. Must not be null. - void WriteTo(ref CodedOutputWriter output); } #endif } diff --git a/csharp/src/Google.Protobuf/ParseContext.cs b/csharp/src/Google.Protobuf/ParseContext.cs index 4b0b76d453..4d0c140f01 100644 --- a/csharp/src/Google.Protobuf/ParseContext.cs +++ b/csharp/src/Google.Protobuf/ParseContext.cs @@ -318,5 +318,10 @@ namespace Google.Protobuf { input.InternalState = state; } + + internal void LoadStateFrom(CodedInputStream input) + { + state = input.InternalState; + } } } \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs b/csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs index 5be010cc44..d2a88e51bd 100644 --- a/csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs +++ b/csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs @@ -110,28 +110,6 @@ namespace Google.Protobuf state.recursionDepth--; } - public static void ReadMessage(ref CodedInputReader ctx, IMessage message) - { - int length = ParsingPrimitives.ParseLength(ref ctx.buffer, ref ctx.state); - if (ctx.state.recursionDepth >= ctx.state.recursionLimit) - { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); - } - int oldLimit = SegmentedBufferHelper.PushLimit(ref ctx.state, length); - ++ctx.state.recursionDepth; - - ReadRawMessage(ref ctx, message); - - CheckReadEndOfStreamTag(ref ctx.state); - // Check that we've read exactly as much data as expected. - if (!SegmentedBufferHelper.IsReachedLimit(ref ctx.state)) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - --ctx.state.recursionDepth; - SegmentedBufferHelper.PopLimit(ref ctx.state, oldLimit); - } - public static void ReadMessage(ref ParseContext ctx, IMessage message) { int length = ParsingPrimitives.ParseLength(ref ctx.buffer, ref ctx.state); @@ -154,7 +132,7 @@ namespace Google.Protobuf SegmentedBufferHelper.PopLimit(ref ctx.state, oldLimit); } - public static void ReadGroup(ref CodedInputReader ctx, IMessage message) + public static void ReadGroup(ref ParseContext ctx, IMessage message) { if (ctx.state.recursionDepth >= ctx.state.recursionLimit) { @@ -162,55 +140,66 @@ namespace Google.Protobuf } ++ctx.state.recursionDepth; + uint tag = ctx.state.lastTag; + int fieldNumber = WireFormat.GetTagFieldNumber(tag); ReadRawMessage(ref ctx, message); + CheckLastTagWas(ref ctx.state, WireFormat.MakeTag(fieldNumber, WireFormat.WireType.EndGroup)); --ctx.state.recursionDepth; } - public static void ReadGroup(ref ParseContext ctx, IMessage message) + public static void ReadGroup(ref ParseContext ctx, int fieldNumber, UnknownFieldSet set) { if (ctx.state.recursionDepth >= ctx.state.recursionLimit) { throw InvalidProtocolBufferException.RecursionLimitExceeded(); } ++ctx.state.recursionDepth; - - ReadRawMessage(ref ctx, message); + + set.MergeGroupFrom(ref ctx); + CheckLastTagWas(ref ctx.state, WireFormat.MakeTag(fieldNumber, WireFormat.WireType.EndGroup)); --ctx.state.recursionDepth; } - public static void ReadRawMessage(ref CodedInputReader ctx, IMessage message) + public static void ReadRawMessage(ref ParseContext ctx, IMessage message) { if (message is IBufferMessage bufferMessage) { - bufferMessage.MergeFrom(ref ctx); + bufferMessage.MergeFrom_Internal(ref ctx); } else { + // If we reached here, it means we've ran into a nested message with older generated code + // which doesn't provide the MergeFrom_Internal method that takes a ParseContext. + // With a slight performance overhead, we can still parse this message just fine, + // but we need to find the original CodedInputStream instance that initiated this + // parsing process and make sure its internal state is up to date. + // Note that this performance overhead is not very high (basically copying contents of a struct) + // and it will only be incurred in case the application mixes older and newer generated code. + // Regenerating the code from .proto files will remove this overhead because it will + // generate the MergeFrom_Internal method we need. + if (ctx.state.codedInputStream == null) { - // TODO: improve the msg - throw new InvalidProtocolBufferException("Cannot parse message with current parse context. Do you need to regenerate the code?"); + // This can only happen when the parsing started without providing a CodedInputStream instance + // (e.g. ParseContext was created directly from a ReadOnlySequence). + // That also means that one of the new parsing APIs was used at the top level + // and in such case it is reasonable to require that all the nested message provide + // up-to-date generated code with ParseContext support (and fail otherwise). + throw new InvalidProtocolBufferException($"Message ${message.GetType()} doesn't provide the generated method that enables ParseContext-based parsing. You might need to regenerate the generated protobuf code."); } - message.MergeFrom(ctx.state.codedInputStream); - } - } - public static void ReadRawMessage(ref ParseContext ctx, IMessage message) - { - if (message is IBufferMessage bufferMessage) - { - bufferMessage.MergeFrom_Internal(ref ctx); - } - else - { - if (ctx.state.codedInputStream == null) + ctx.CopyStateTo(ctx.state.codedInputStream); + try { - // TODO: improve the msg - throw new InvalidProtocolBufferException("Cannot parse message with current parse context. Do you need to regenerate the code?"); + // fallback parse using the CodedInputStream that started current parsing tree + message.MergeFrom(ctx.state.codedInputStream); + } + finally + { + ctx.LoadStateFrom(ctx.state.codedInputStream); } - message.MergeFrom(ctx.state.codedInputStream); } } @@ -227,5 +216,12 @@ namespace Google.Protobuf throw InvalidProtocolBufferException.MoreDataAvailable(); } } + + private static void CheckLastTagWas(ref ParserInternalState state, uint expectedTag) + { + if (state.lastTag != expectedTag) { + throw InvalidProtocolBufferException.InvalidEndTag(); + } + } } } \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/UnknownFieldSet.cs b/csharp/src/Google.Protobuf/UnknownFieldSet.cs index 7a2b6a00d2..fbdf30445d 100644 --- a/csharp/src/Google.Protobuf/UnknownFieldSet.cs +++ b/csharp/src/Google.Protobuf/UnknownFieldSet.cs @@ -176,47 +176,48 @@ namespace Google.Protobuf fields[number] = field; return this; } - + /// - /// Parse a single field from and merge it + /// Parse a single field from and merge it /// into this set. /// - /// The coded input stream containing the field + /// The parse context from which to read the field /// false if the tag is an "end group" tag, true otherwise - private bool MergeFieldFrom(CodedInputStream input) + private bool MergeFieldFrom(ref ParseContext ctx) { - uint tag = input.LastTag; + // TODO: deduplicate MergeFieldFrom implementations + uint tag = ctx.LastTag; int number = WireFormat.GetTagFieldNumber(tag); switch (WireFormat.GetTagWireType(tag)) { case WireFormat.WireType.Varint: { - ulong uint64 = input.ReadUInt64(); + ulong uint64 = ctx.ReadUInt64(); GetOrAddField(number).AddVarint(uint64); return true; } case WireFormat.WireType.Fixed32: { - uint uint32 = input.ReadFixed32(); + uint uint32 = ctx.ReadFixed32(); GetOrAddField(number).AddFixed32(uint32); return true; } case WireFormat.WireType.Fixed64: { - ulong uint64 = input.ReadFixed64(); + ulong uint64 = ctx.ReadFixed64(); GetOrAddField(number).AddFixed64(uint64); return true; } case WireFormat.WireType.LengthDelimited: { - ByteString bytes = input.ReadBytes(); + ByteString bytes = ctx.ReadBytes(); GetOrAddField(number).AddLengthDelimited(bytes); return true; } case WireFormat.WireType.StartGroup: { UnknownFieldSet set = new UnknownFieldSet(); - input.ReadGroup(number, set); + ParsingPrimitivesMessages.ReadGroup(ref ctx, number, set); GetOrAddField(number).AddGroup(set); return true; } @@ -229,16 +230,16 @@ namespace Google.Protobuf } } - internal void MergeGroupFrom(CodedInputStream input) + internal void MergeGroupFrom(ref ParseContext ctx) { while (true) { - uint tag = input.ReadTag(); + uint tag = ctx.ReadTag(); if (tag == 0) { break; } - if (!MergeFieldFrom(input)) + if (!MergeFieldFrom(ref ctx)) { break; } @@ -257,21 +258,44 @@ namespace Google.Protobuf public static UnknownFieldSet MergeFieldFrom(UnknownFieldSet unknownFields, CodedInputStream input) { - if (input.DiscardUnknownFields) + var ctx = new ParseContext(input); + try + { + return MergeFieldFrom(unknownFields, ref ctx); + } + finally { - input.SkipLastField(); + ctx.CopyStateTo(input); + } + } + + /// + /// 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 parse context from which to read the field + /// The merged UnknownFieldSet + public static UnknownFieldSet MergeFieldFrom(UnknownFieldSet unknownFields, + ref ParseContext ctx) + { + if (ctx.DiscardUnknownFields) + { + ParsingPrimitivesMessages.SkipLastField(ref ctx.buffer, ref ctx.state); return unknownFields; } if (unknownFields == null) { unknownFields = new UnknownFieldSet(); } - 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 + if (!unknownFields.MergeFieldFrom(ref ctx)) + { + 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; - } + } /// /// Merges the fields from into this set. From 6d5bc90d486d02d881a9147e8325953b10f4f3a3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 2 Apr 2020 15:00:34 +0200 Subject: [PATCH 03/36] add ParseFrom(ReadOnlySequence) methods --- .../src/Google.Protobuf/MessageExtensions.cs | 12 ++++++++ csharp/src/Google.Protobuf/MessageParser.cs | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs index 06e0980ec2..97a58c75eb 100644 --- a/csharp/src/Google.Protobuf/MessageExtensions.cs +++ b/csharp/src/Google.Protobuf/MessageExtensions.cs @@ -31,9 +31,11 @@ #endregion using Google.Protobuf.Reflection; +using System.Buffers; using System.Collections; using System.IO; using System.Linq; +using System.Security; namespace Google.Protobuf { @@ -248,6 +250,16 @@ namespace Google.Protobuf codedInput.CheckReadEndOfStreamTag(); } + [SecuritySafeCritical] + internal static void MergeFrom(this IMessage message, ReadOnlySequence data, bool discardUnknownFields, ExtensionRegistry registry) + { + var ctx = new ParseContext(data); + ctx.DiscardUnknownFields = discardUnknownFields; + ctx.ExtensionRegistry = registry; + ParsingPrimitivesMessages.ReadRawMessage(ref ctx, message); + ParsingPrimitivesMessages.CheckReadEndOfStreamTag(ref ctx.state); + } + internal static void MergeDelimitedFrom(this IMessage message, Stream input, bool discardUnknownFields, ExtensionRegistry registry) { ProtoPreconditions.CheckNotNull(message, "message"); diff --git a/csharp/src/Google.Protobuf/MessageParser.cs b/csharp/src/Google.Protobuf/MessageParser.cs index 06d0f1059c..f8b26c2348 100644 --- a/csharp/src/Google.Protobuf/MessageParser.cs +++ b/csharp/src/Google.Protobuf/MessageParser.cs @@ -31,7 +31,9 @@ #endregion using System; +using System.Buffers; using System.IO; +using System.Security; namespace Google.Protobuf { @@ -113,6 +115,19 @@ namespace Google.Protobuf return message; } + /// + /// Parses a message from the given sequence. + /// + /// The data to parse. + /// The parsed message. + [SecuritySafeCritical] + public IMessage ParseFrom(ReadOnlySequence data) + { + IMessage message = factory(); + message.MergeFrom(data, DiscardUnknownFields, Extensions); + return message; + } + /// /// Parses a length-delimited message from the given stream. /// @@ -287,6 +302,19 @@ namespace Google.Protobuf return message; } + /// + /// Parses a message from the given sequence. + /// + /// The data to parse. + /// The parsed message. + [SecuritySafeCritical] + public new T ParseFrom(ReadOnlySequence data) + { + T message = factory(); + message.MergeFrom(data, DiscardUnknownFields, Extensions); + return message; + } + /// /// Parses a length-delimited message from the given stream. /// From 220e7be708a84239d6ae48faa480dd1e7cf73367 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 2 Apr 2020 15:35:03 +0200 Subject: [PATCH 04/36] make things build after codegen change --- .../Google.Protobuf/Collections/MapField.cs | 54 ++++++++++++++++++- .../src/Google.Protobuf/ExtensionRegistry.cs | 4 +- csharp/src/Google.Protobuf/ExtensionSet.cs | 32 ++++++++++- csharp/src/Google.Protobuf/ExtensionValue.cs | 8 +++ .../src/Google.Protobuf/ParsingPrimitives.cs | 4 +- 5 files changed, 96 insertions(+), 6 deletions(-) diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 1924439e5c..3ea2a68fef 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -33,6 +33,7 @@ using Google.Protobuf.Compatibility; using Google.Protobuf.Reflection; using System; +using System.Buffers; using System.Collections; using System.Collections.Generic; using System.IO; @@ -431,6 +432,28 @@ namespace Google.Protobuf.Collections } while (input.MaybeConsumeTag(codec.MapTag)); } + /// + /// Adds entries to the map from the given parse context. + /// + /// + /// It is assumed that the input is initially positioned after the tag specified by the codec. + /// This method will continue reading entries from the input until the end is reached, or + /// a different tag is encountered. + /// + /// Input to read from + /// Codec describing how the key/value pairs are encoded + public void AddEntriesFrom(ref ParseContext ctx, Codec codec) + { + // TODO: deduplicate code? + var adapter = new Codec.MessageAdapter(codec); + do + { + adapter.Reset(); + ctx.ReadMessage(adapter); + this[adapter.Key] = adapter.Value; + } while (ParsingPrimitives.MaybeConsumeTag(ref ctx.buffer, ref ctx.state, codec.MapTag)); + } + /// /// Writes the contents of this map to the given coded output stream, using the specified codec /// to encode each entry. @@ -620,7 +643,7 @@ namespace Google.Protobuf.Collections /// This is nested inside Codec as it's tightly coupled to the associated codec, /// and it's simpler if it has direct access to all its fields. /// - internal class MessageAdapter : IMessage + internal class MessageAdapter : IMessage, IBufferMessage { private static readonly byte[] ZeroLengthMessageStreamData = new byte[] { 0 }; @@ -666,6 +689,35 @@ namespace Google.Protobuf.Collections } } + public void MergeFrom_Internal(ref ParseContext ctx) + { + // TODO(jtattermusch): deduplicate code + uint tag; + while ((tag = ctx.ReadTag()) != 0) + { + if (tag == codec.keyCodec.Tag) + { + Key = codec.keyCodec.Read(ref ctx); + } + else if (tag == codec.valueCodec.Tag) + { + Value = codec.valueCodec.Read(ref ctx); + } + else + { + ParsingPrimitivesMessages.SkipLastField(ref ctx.buffer, ref ctx.state); + } + } + + // Corner case: a map entry with a key but no value, where the value type is a message. + // Read it as if we'd seen input with no data (i.e. create a "default" message). + if (Value == null) + { + var zeroLengthCtx = new ParseContext(new ReadOnlySequence(ZeroLengthMessageStreamData)); + Value = codec.valueCodec.Read(ref zeroLengthCtx); + } + } + public void WriteTo(CodedOutputStream output) { codec.keyCodec.WriteTagAndValue(output, Key); diff --git a/csharp/src/Google.Protobuf/ExtensionRegistry.cs b/csharp/src/Google.Protobuf/ExtensionRegistry.cs index d3d7ebdc5d..e72314b22c 100644 --- a/csharp/src/Google.Protobuf/ExtensionRegistry.cs +++ b/csharp/src/Google.Protobuf/ExtensionRegistry.cs @@ -80,9 +80,9 @@ namespace Google.Protobuf /// bool ICollection.IsReadOnly => false; - internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension) + internal bool ContainsInputField(uint lastTag, Type target, out Extension extension) { - return extensions.TryGetValue(new ObjectIntPair(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension); + return extensions.TryGetValue(new ObjectIntPair(target, WireFormat.GetTagFieldNumber(lastTag)), out extension); } /// diff --git a/csharp/src/Google.Protobuf/ExtensionSet.cs b/csharp/src/Google.Protobuf/ExtensionSet.cs index d1bbf69102..2de0b40a25 100644 --- a/csharp/src/Google.Protobuf/ExtensionSet.cs +++ b/csharp/src/Google.Protobuf/ExtensionSet.cs @@ -192,7 +192,7 @@ namespace Google.Protobuf extensionValue.MergeFrom(stream); return true; } - else if (stream.ExtensionRegistry != null && stream.ExtensionRegistry.ContainsInputField(stream, typeof(TTarget), out extension)) + else if (stream.ExtensionRegistry != null && stream.ExtensionRegistry.ContainsInputField(stream.LastTag, typeof(TTarget), out extension)) { IExtensionValue value = extension.CreateValue(); value.MergeFrom(stream); @@ -206,6 +206,36 @@ namespace Google.Protobuf } } + /// + /// Tries to merge a field from the coded input, returning true if the field was merged. + /// If the set is null or the field was not otherwise merged, this returns false. + /// + public static bool TryMergeFieldFrom(ref ExtensionSet set, ref ParseContext ctx) where TTarget : IExtendableMessage + { + // TODO(jtattermusch): deduplicate code + Extension extension; + int lastFieldNumber = WireFormat.GetTagFieldNumber(ctx.LastTag); + + IExtensionValue extensionValue; + if (set != null && set.ValuesByNumber.TryGetValue(lastFieldNumber, out extensionValue)) + { + extensionValue.MergeFrom(ref ctx); + return true; + } + else if (ctx.ExtensionRegistry != null && ctx.ExtensionRegistry.ContainsInputField(ctx.LastTag, typeof(TTarget), out extension)) + { + IExtensionValue value = extension.CreateValue(); + value.MergeFrom(ref ctx); + set = (set ?? new ExtensionSet()); + set.ValuesByNumber.Add(extension.FieldNumber, value); + return true; + } + else + { + return false; + } + } + /// /// Merges the second set into the first set, creating a new instance if first is null /// diff --git a/csharp/src/Google.Protobuf/ExtensionValue.cs b/csharp/src/Google.Protobuf/ExtensionValue.cs index 74bd62c8e2..497ae4f166 100644 --- a/csharp/src/Google.Protobuf/ExtensionValue.cs +++ b/csharp/src/Google.Protobuf/ExtensionValue.cs @@ -39,6 +39,9 @@ namespace Google.Protobuf internal interface IExtensionValue : IEquatable, IDeepCloneable { void MergeFrom(CodedInputStream input); + + void MergeFrom(ref ParseContext ctx); + void MergeFrom(IExtensionValue value); void WriteTo(CodedOutputStream output); int CalculateSize(); @@ -198,6 +201,11 @@ namespace Google.Protobuf field.AddEntriesFrom(input, codec); } + public void MergeFrom(ref ParseContext ctx) + { + field.AddEntriesFrom(ref ctx, codec); + } + public void MergeFrom(IExtensionValue value) { if (value is RepeatedExtensionValue) diff --git a/csharp/src/Google.Protobuf/ParsingPrimitives.cs b/csharp/src/Google.Protobuf/ParsingPrimitives.cs index 93852344ed..8966490a1c 100644 --- a/csharp/src/Google.Protobuf/ParsingPrimitives.cs +++ b/csharp/src/Google.Protobuf/ParsingPrimitives.cs @@ -138,8 +138,8 @@ namespace Google.Protobuf } /// - /// Peeks at the next field tag. This is like calling , but the - /// tag is not consumed. (So a subsequent call to will return the + /// Peeks at the next field tag. This is like calling , but the + /// tag is not consumed. (So a subsequent call to will return the /// same value.) /// public static uint PeekTag(ref ReadOnlySpan buffer, ref ParserInternalState state) From f6bdd7d479f59e37490b00d3a1c2dac5b3ef13a5 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 2 Apr 2020 15:35:20 +0200 Subject: [PATCH 05/36] codegen changes --- .../protobuf/compiler/csharp/csharp_map_field.cc | 2 +- .../protobuf/compiler/csharp/csharp_message.cc | 14 +++++++++++--- .../compiler/csharp/csharp_repeated_enum_field.cc | 2 +- .../csharp/csharp_repeated_message_field.cc | 2 +- .../csharp/csharp_repeated_primitive_field.cc | 2 +- .../compiler/csharp/csharp_wrapper_field.cc | 4 ++-- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index f3f09ea454..9f3db76851 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -96,7 +96,7 @@ void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) { void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$name$_.AddEntriesFrom(input, _map_$name$_codec);\n"); + "$name$_.AddEntriesFrom(ref input, _map_$name$_codec);\n"); } void MapFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 67f2892919..35a3e66856 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -132,6 +132,7 @@ void MessageGenerator::Generate(io::Printer* printer) { else { printer->Print(vars, "pb::IMessage<$class_name$>"); } + printer->Print(", pb::IBufferMessage"); printer->Print(" {\n"); printer->Indent(); @@ -634,6 +635,13 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); printer->Print("public void MergeFrom(pb::CodedInputStream input) {\n"); printer->Indent(); + printer->Print("input.ReadRawMessage(this);\n"); + printer->Outdent(); + printer->Print("}\n\n"); + + WriteGeneratedCodeAttributes(printer); + printer->Print("public void MergeFrom_Internal(ref pb::ParseContext input) {\n"); + printer->Indent(); printer->Print( "uint tag;\n" "while ((tag = input.ReadTag()) != 0) {\n" @@ -649,14 +657,14 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { if (has_extension_ranges_) { printer->Print( "default:\n" - " if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) {\n" - " _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);\n" + " if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) {\n" + " _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);\n" " }\n" " break;\n"); } else { printer->Print( "default:\n" - " _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);\n" + " _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);\n" " break;\n"); } for (int i = 0; i < fields_by_number().size(); i++) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 73309a7edd..aae7091c6f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -80,7 +80,7 @@ void RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n"); + "$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 4b4b37de1b..2e2cfa8fae 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -95,7 +95,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n"); + "$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index c1444ea124..d4ff302543 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -80,7 +80,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n"); + "$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc index add20ab9fe..fb067abfc9 100644 --- a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc @@ -116,7 +116,7 @@ void WrapperFieldGenerator::GenerateMergingCode(io::Printer* printer) { void WrapperFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$type_name$ value = _single_$name$_codec.Read(input);\n" + "$type_name$ value = _single_$name$_codec.Read(ref input);\n" "if ($has_not_property_check$ || value != $default_value$) {\n" " $property_name$ = value;\n" "}\n"); @@ -250,7 +250,7 @@ void WrapperOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) { void WrapperOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$property_name$ = _oneof_$name$_codec.Read(input);\n"); + "$property_name$ = _oneof_$name$_codec.Read(ref input);\n"); } void WrapperOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) { From 3196ef9b5ca271dfefcd1ee75345cca66917cebd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 2 Apr 2020 15:36:16 +0200 Subject: [PATCH 06/36] regenerate C# protos --- csharp/src/AddressBook/Addressbook.cs | 31 +- .../BenchmarkMessage1Proto3.cs | 20 +- .../Google.Protobuf.Benchmarks/Benchmarks.cs | 11 +- .../WrapperBenchmarkMessages.cs | 236 ++-- .../Conformance.cs | 38 +- .../MapUnittestProto3.cs | 137 ++- .../TestMessagesProto2.cs | 223 ++-- .../TestMessagesProto3.cs | 213 ++-- .../Unittest.cs | 1024 ++++++++++++----- .../UnittestCustomOptionsProto3.cs | 193 +++- .../UnittestImport.cs | 9 +- .../UnittestImportProto3.cs | 9 +- .../UnittestImportPublic.cs | 9 +- .../UnittestImportPublicProto3.cs | 9 +- .../UnittestIssue6936B.cs | 9 +- .../UnittestIssue6936C.cs | 9 +- .../UnittestIssues.cs | 127 +- .../UnittestProto3.cs | 475 +++++--- .../UnittestWellKnownTypes.cs | 144 ++- .../Google.Protobuf/Reflection/Descriptor.cs | 333 ++++-- .../src/Google.Protobuf/WellKnownTypes/Any.cs | 9 +- .../src/Google.Protobuf/WellKnownTypes/Api.cs | 35 +- .../WellKnownTypes/Duration.cs | 9 +- .../Google.Protobuf/WellKnownTypes/Empty.cs | 9 +- .../WellKnownTypes/FieldMask.cs | 11 +- .../WellKnownTypes/SourceContext.cs | 9 +- .../Google.Protobuf/WellKnownTypes/Struct.cs | 31 +- .../WellKnownTypes/Timestamp.cs | 9 +- .../Google.Protobuf/WellKnownTypes/Type.cs | 59 +- .../WellKnownTypes/Wrappers.cs | 81 +- 30 files changed, 2408 insertions(+), 1113 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index cbd9772696..52bbd4266b 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -49,7 +49,7 @@ namespace Google.Protobuf.Examples.AddressBook { /// /// [START messages] /// - public sealed partial class Person : pb::IMessage { + public sealed partial class Person : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Person()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -256,11 +256,16 @@ namespace Google.Protobuf.Examples.AddressBook { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -275,7 +280,7 @@ namespace Google.Protobuf.Examples.AddressBook { break; } case 34: { - phones_.AddEntriesFrom(input, _repeated_phones_codec); + phones_.AddEntriesFrom(ref input, _repeated_phones_codec); break; } case 42: { @@ -299,7 +304,7 @@ namespace Google.Protobuf.Examples.AddressBook { [pbr::OriginalName("WORK")] Work = 2, } - public sealed partial class PhoneNumber : pb::IMessage { + public sealed partial class PhoneNumber : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PhoneNumber()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -436,11 +441,16 @@ namespace Google.Protobuf.Examples.AddressBook { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Number = input.ReadString(); @@ -464,7 +474,7 @@ namespace Google.Protobuf.Examples.AddressBook { /// /// Our address book file is just one of these. /// - public sealed partial class AddressBook : pb::IMessage { + public sealed partial class AddressBook : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AddressBook()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -569,14 +579,19 @@ namespace Google.Protobuf.Examples.AddressBook { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - people_.AddEntriesFrom(input, _repeated_people_codec); + people_.AddEntriesFrom(ref input, _repeated_people_codec); break; } } diff --git a/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs b/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs index 9e8c330a2b..dcd772598f 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs @@ -64,7 +64,7 @@ namespace Benchmarks.Proto3 { } #region Messages - public sealed partial class GoogleMessage1 : pb::IMessage { + public sealed partial class GoogleMessage1 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GoogleMessage1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1132,11 +1132,16 @@ namespace Benchmarks.Proto3 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Field1 = input.ReadString(); @@ -1156,7 +1161,7 @@ namespace Benchmarks.Proto3 { } case 42: case 41: { - field5_.AddEntriesFrom(input, _repeated_field5_codec); + field5_.AddEntriesFrom(ref input, _repeated_field5_codec); break; } case 48: { @@ -1312,7 +1317,7 @@ namespace Benchmarks.Proto3 { } - public sealed partial class GoogleMessage1SubMessage : pb::IMessage { + public sealed partial class GoogleMessage1SubMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GoogleMessage1SubMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1881,11 +1886,16 @@ namespace Benchmarks.Proto3 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Field1 = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs b/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs index 01dfcd72dc..e9491c3797 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs @@ -38,7 +38,7 @@ namespace Benchmarks { } #region Messages - public sealed partial class BenchmarkDataset : pb::IMessage { + public sealed partial class BenchmarkDataset : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BenchmarkDataset()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -219,11 +219,16 @@ namespace Benchmarks { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -234,7 +239,7 @@ namespace Benchmarks { break; } case 26: { - payload_.AddEntriesFrom(input, _repeated_payload_codec); + payload_.AddEntriesFrom(ref input, _repeated_payload_codec); break; } } diff --git a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs index 0cc86e2ad4..a634fe7f1f 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs @@ -237,7 +237,7 @@ namespace Google.Protobuf.Benchmarks { /// a message that has a large number of wrapper fields /// obfuscated version of an internal message /// - public sealed partial class ManyWrapperFieldsMessage : pb::IMessage { + public sealed partial class ManyWrapperFieldsMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ManyWrapperFieldsMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3303,434 +3303,439 @@ namespace Google.Protobuf.Benchmarks { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - double? value = _single_doubleField1_codec.Read(input); + double? value = _single_doubleField1_codec.Read(ref input); if (doubleField1_ == null || value != 0D) { DoubleField1 = value; } break; } case 18: { - long? value = _single_int64Field2_codec.Read(input); + long? value = _single_int64Field2_codec.Read(ref input); if (int64Field2_ == null || value != 0L) { Int64Field2 = value; } break; } case 26: { - long? value = _single_int64Field3_codec.Read(input); + long? value = _single_int64Field3_codec.Read(ref input); if (int64Field3_ == null || value != 0L) { Int64Field3 = value; } break; } case 34: { - long? value = _single_int64Field4_codec.Read(input); + long? value = _single_int64Field4_codec.Read(ref input); if (int64Field4_ == null || value != 0L) { Int64Field4 = value; } break; } case 58: { - double? value = _single_doubleField7_codec.Read(input); + double? value = _single_doubleField7_codec.Read(ref input); if (doubleField7_ == null || value != 0D) { DoubleField7 = value; } break; } case 66: { - double? value = _single_doubleField8_codec.Read(input); + double? value = _single_doubleField8_codec.Read(ref input); if (doubleField8_ == null || value != 0D) { DoubleField8 = value; } break; } case 74: { - double? value = _single_doubleField9_codec.Read(input); + double? value = _single_doubleField9_codec.Read(ref input); if (doubleField9_ == null || value != 0D) { DoubleField9 = value; } break; } case 82: { - double? value = _single_doubleField10_codec.Read(input); + double? value = _single_doubleField10_codec.Read(ref input); if (doubleField10_ == null || value != 0D) { DoubleField10 = value; } break; } case 90: { - double? value = _single_doubleField11_codec.Read(input); + double? value = _single_doubleField11_codec.Read(ref input); if (doubleField11_ == null || value != 0D) { DoubleField11 = value; } break; } case 114: { - double? value = _single_doubleField14_codec.Read(input); + double? value = _single_doubleField14_codec.Read(ref input); if (doubleField14_ == null || value != 0D) { DoubleField14 = value; } break; } case 122: { - double? value = _single_doubleField15_codec.Read(input); + double? value = _single_doubleField15_codec.Read(ref input); if (doubleField15_ == null || value != 0D) { DoubleField15 = value; } break; } case 154: { - long? value = _single_int64Field19_codec.Read(input); + long? value = _single_int64Field19_codec.Read(ref input); if (int64Field19_ == null || value != 0L) { Int64Field19 = value; } break; } case 162: { - double? value = _single_doubleField20_codec.Read(input); + double? value = _single_doubleField20_codec.Read(ref input); if (doubleField20_ == null || value != 0D) { DoubleField20 = value; } break; } case 170: { - double? value = _single_doubleField21_codec.Read(input); + double? value = _single_doubleField21_codec.Read(ref input); if (doubleField21_ == null || value != 0D) { DoubleField21 = value; } break; } case 178: { - double? value = _single_doubleField22_codec.Read(input); + double? value = _single_doubleField22_codec.Read(ref input); if (doubleField22_ == null || value != 0D) { DoubleField22 = value; } break; } case 202: { - double? value = _single_doubleField25_codec.Read(input); + double? value = _single_doubleField25_codec.Read(ref input); if (doubleField25_ == null || value != 0D) { DoubleField25 = value; } break; } case 210: { - long? value = _single_int64Field26_codec.Read(input); + long? value = _single_int64Field26_codec.Read(ref input); if (int64Field26_ == null || value != 0L) { Int64Field26 = value; } break; } case 226: { - double? value = _single_doubleField28_codec.Read(input); + double? value = _single_doubleField28_codec.Read(ref input); if (doubleField28_ == null || value != 0D) { DoubleField28 = value; } break; } case 234: { - double? value = _single_doubleField29_codec.Read(input); + double? value = _single_doubleField29_codec.Read(ref input); if (doubleField29_ == null || value != 0D) { DoubleField29 = value; } break; } case 242: { - double? value = _single_doubleField30_codec.Read(input); + double? value = _single_doubleField30_codec.Read(ref input); if (doubleField30_ == null || value != 0D) { DoubleField30 = value; } break; } case 250: { - double? value = _single_doubleField31_codec.Read(input); + double? value = _single_doubleField31_codec.Read(ref input); if (doubleField31_ == null || value != 0D) { DoubleField31 = value; } break; } case 258: { - long? value = _single_int64Field32_codec.Read(input); + long? value = _single_int64Field32_codec.Read(ref input); if (int64Field32_ == null || value != 0L) { Int64Field32 = value; } break; } case 298: { - long? value = _single_int64Field37_codec.Read(input); + long? value = _single_int64Field37_codec.Read(ref input); if (int64Field37_ == null || value != 0L) { Int64Field37 = value; } break; } case 306: { - double? value = _single_doubleField38_codec.Read(input); + double? value = _single_doubleField38_codec.Read(ref input); if (doubleField38_ == null || value != 0D) { DoubleField38 = value; } break; } case 314: { - long? value = _single_interactions_codec.Read(input); + long? value = _single_interactions_codec.Read(ref input); if (interactions_ == null || value != 0L) { Interactions = value; } break; } case 322: { - double? value = _single_doubleField40_codec.Read(input); + double? value = _single_doubleField40_codec.Read(ref input); if (doubleField40_ == null || value != 0D) { DoubleField40 = value; } break; } case 330: { - long? value = _single_int64Field41_codec.Read(input); + long? value = _single_int64Field41_codec.Read(ref input); if (int64Field41_ == null || value != 0L) { Int64Field41 = value; } break; } case 338: { - double? value = _single_doubleField42_codec.Read(input); + double? value = _single_doubleField42_codec.Read(ref input); if (doubleField42_ == null || value != 0D) { DoubleField42 = value; } break; } case 346: { - long? value = _single_int64Field43_codec.Read(input); + long? value = _single_int64Field43_codec.Read(ref input); if (int64Field43_ == null || value != 0L) { Int64Field43 = value; } break; } case 354: { - long? value = _single_int64Field44_codec.Read(input); + long? value = _single_int64Field44_codec.Read(ref input); if (int64Field44_ == null || value != 0L) { Int64Field44 = value; } break; } case 362: { - double? value = _single_doubleField45_codec.Read(input); + double? value = _single_doubleField45_codec.Read(ref input); if (doubleField45_ == null || value != 0D) { DoubleField45 = value; } break; } case 370: { - double? value = _single_doubleField46_codec.Read(input); + double? value = _single_doubleField46_codec.Read(ref input); if (doubleField46_ == null || value != 0D) { DoubleField46 = value; } break; } case 378: { - double? value = _single_doubleField47_codec.Read(input); + double? value = _single_doubleField47_codec.Read(ref input); if (doubleField47_ == null || value != 0D) { DoubleField47 = value; } break; } case 386: { - double? value = _single_doubleField48_codec.Read(input); + double? value = _single_doubleField48_codec.Read(ref input); if (doubleField48_ == null || value != 0D) { DoubleField48 = value; } break; } case 394: { - double? value = _single_doubleField49_codec.Read(input); + double? value = _single_doubleField49_codec.Read(ref input); if (doubleField49_ == null || value != 0D) { DoubleField49 = value; } break; } case 402: { - double? value = _single_doubleField50_codec.Read(input); + double? value = _single_doubleField50_codec.Read(ref input); if (doubleField50_ == null || value != 0D) { DoubleField50 = value; } break; } case 410: { - double? value = _single_doubleField51_codec.Read(input); + double? value = _single_doubleField51_codec.Read(ref input); if (doubleField51_ == null || value != 0D) { DoubleField51 = value; } break; } case 418: { - double? value = _single_doubleField52_codec.Read(input); + double? value = _single_doubleField52_codec.Read(ref input); if (doubleField52_ == null || value != 0D) { DoubleField52 = value; } break; } case 426: { - double? value = _single_doubleField53_codec.Read(input); + double? value = _single_doubleField53_codec.Read(ref input); if (doubleField53_ == null || value != 0D) { DoubleField53 = value; } break; } case 434: { - double? value = _single_doubleField54_codec.Read(input); + double? value = _single_doubleField54_codec.Read(ref input); if (doubleField54_ == null || value != 0D) { DoubleField54 = value; } break; } case 442: { - double? value = _single_doubleField55_codec.Read(input); + double? value = _single_doubleField55_codec.Read(ref input); if (doubleField55_ == null || value != 0D) { DoubleField55 = value; } break; } case 450: { - double? value = _single_doubleField56_codec.Read(input); + double? value = _single_doubleField56_codec.Read(ref input); if (doubleField56_ == null || value != 0D) { DoubleField56 = value; } break; } case 458: { - double? value = _single_doubleField57_codec.Read(input); + double? value = _single_doubleField57_codec.Read(ref input); if (doubleField57_ == null || value != 0D) { DoubleField57 = value; } break; } case 466: { - double? value = _single_doubleField58_codec.Read(input); + double? value = _single_doubleField58_codec.Read(ref input); if (doubleField58_ == null || value != 0D) { DoubleField58 = value; } break; } case 474: { - long? value = _single_int64Field59_codec.Read(input); + long? value = _single_int64Field59_codec.Read(ref input); if (int64Field59_ == null || value != 0L) { Int64Field59 = value; } break; } case 482: { - long? value = _single_int64Field60_codec.Read(input); + long? value = _single_int64Field60_codec.Read(ref input); if (int64Field60_ == null || value != 0L) { Int64Field60 = value; } break; } case 498: { - double? value = _single_doubleField62_codec.Read(input); + double? value = _single_doubleField62_codec.Read(ref input); if (doubleField62_ == null || value != 0D) { DoubleField62 = value; } break; } case 522: { - double? value = _single_doubleField65_codec.Read(input); + double? value = _single_doubleField65_codec.Read(ref input); if (doubleField65_ == null || value != 0D) { DoubleField65 = value; } break; } case 530: { - double? value = _single_doubleField66_codec.Read(input); + double? value = _single_doubleField66_codec.Read(ref input); if (doubleField66_ == null || value != 0D) { DoubleField66 = value; } break; } case 538: { - double? value = _single_doubleField67_codec.Read(input); + double? value = _single_doubleField67_codec.Read(ref input); if (doubleField67_ == null || value != 0D) { DoubleField67 = value; } break; } case 546: { - double? value = _single_doubleField68_codec.Read(input); + double? value = _single_doubleField68_codec.Read(ref input); if (doubleField68_ == null || value != 0D) { DoubleField68 = value; } break; } case 554: { - double? value = _single_doubleField69_codec.Read(input); + double? value = _single_doubleField69_codec.Read(ref input); if (doubleField69_ == null || value != 0D) { DoubleField69 = value; } break; } case 562: { - double? value = _single_doubleField70_codec.Read(input); + double? value = _single_doubleField70_codec.Read(ref input); if (doubleField70_ == null || value != 0D) { DoubleField70 = value; } break; } case 570: { - double? value = _single_doubleField71_codec.Read(input); + double? value = _single_doubleField71_codec.Read(ref input); if (doubleField71_ == null || value != 0D) { DoubleField71 = value; } break; } case 578: { - double? value = _single_doubleField72_codec.Read(input); + double? value = _single_doubleField72_codec.Read(ref input); if (doubleField72_ == null || value != 0D) { DoubleField72 = value; } break; } case 586: { - string value = _single_stringField73_codec.Read(input); + string value = _single_stringField73_codec.Read(ref input); if (stringField73_ == null || value != "") { StringField73 = value; } break; } case 594: { - string value = _single_stringField74_codec.Read(input); + string value = _single_stringField74_codec.Read(ref input); if (stringField74_ == null || value != "") { StringField74 = value; } break; } case 602: { - double? value = _single_doubleField75_codec.Read(input); + double? value = _single_doubleField75_codec.Read(ref input); if (doubleField75_ == null || value != 0D) { DoubleField75 = value; } break; } case 618: { - double? value = _single_doubleField77_codec.Read(input); + double? value = _single_doubleField77_codec.Read(ref input); if (doubleField77_ == null || value != 0D) { DoubleField77 = value; } break; } case 626: { - double? value = _single_doubleField78_codec.Read(input); + double? value = _single_doubleField78_codec.Read(ref input); if (doubleField78_ == null || value != 0D) { DoubleField78 = value; } break; } case 634: { - double? value = _single_doubleField79_codec.Read(input); + double? value = _single_doubleField79_codec.Read(ref input); if (doubleField79_ == null || value != 0D) { DoubleField79 = value; } @@ -3745,7 +3750,7 @@ namespace Google.Protobuf.Benchmarks { break; } case 658: { - long? value = _single_int64Field82_codec.Read(input); + long? value = _single_int64Field82_codec.Read(ref input); if (int64Field82_ == null || value != 0L) { Int64Field82 = value; } @@ -3756,112 +3761,112 @@ namespace Google.Protobuf.Benchmarks { break; } case 674: { - double? value = _single_doubleField84_codec.Read(input); + double? value = _single_doubleField84_codec.Read(ref input); if (doubleField84_ == null || value != 0D) { DoubleField84 = value; } break; } case 682: { - long? value = _single_int64Field85_codec.Read(input); + long? value = _single_int64Field85_codec.Read(ref input); if (int64Field85_ == null || value != 0L) { Int64Field85 = value; } break; } case 690: { - long? value = _single_int64Field86_codec.Read(input); + long? value = _single_int64Field86_codec.Read(ref input); if (int64Field86_ == null || value != 0L) { Int64Field86 = value; } break; } case 698: { - long? value = _single_int64Field87_codec.Read(input); + long? value = _single_int64Field87_codec.Read(ref input); if (int64Field87_ == null || value != 0L) { Int64Field87 = value; } break; } case 706: { - double? value = _single_doubleField88_codec.Read(input); + double? value = _single_doubleField88_codec.Read(ref input); if (doubleField88_ == null || value != 0D) { DoubleField88 = value; } break; } case 714: { - double? value = _single_doubleField89_codec.Read(input); + double? value = _single_doubleField89_codec.Read(ref input); if (doubleField89_ == null || value != 0D) { DoubleField89 = value; } break; } case 722: { - double? value = _single_doubleField90_codec.Read(input); + double? value = _single_doubleField90_codec.Read(ref input); if (doubleField90_ == null || value != 0D) { DoubleField90 = value; } break; } case 730: { - double? value = _single_doubleField91_codec.Read(input); + double? value = _single_doubleField91_codec.Read(ref input); if (doubleField91_ == null || value != 0D) { DoubleField91 = value; } break; } case 738: { - double? value = _single_doubleField92_codec.Read(input); + double? value = _single_doubleField92_codec.Read(ref input); if (doubleField92_ == null || value != 0D) { DoubleField92 = value; } break; } case 746: { - double? value = _single_doubleField93_codec.Read(input); + double? value = _single_doubleField93_codec.Read(ref input); if (doubleField93_ == null || value != 0D) { DoubleField93 = value; } break; } case 754: { - double? value = _single_doubleField94_codec.Read(input); + double? value = _single_doubleField94_codec.Read(ref input); if (doubleField94_ == null || value != 0D) { DoubleField94 = value; } break; } case 762: { - double? value = _single_doubleField95_codec.Read(input); + double? value = _single_doubleField95_codec.Read(ref input); if (doubleField95_ == null || value != 0D) { DoubleField95 = value; } break; } case 770: { - double? value = _single_doubleField96_codec.Read(input); + double? value = _single_doubleField96_codec.Read(ref input); if (doubleField96_ == null || value != 0D) { DoubleField96 = value; } break; } case 778: { - double? value = _single_doubleField97_codec.Read(input); + double? value = _single_doubleField97_codec.Read(ref input); if (doubleField97_ == null || value != 0D) { DoubleField97 = value; } break; } case 786: { - double? value = _single_doubleField98_codec.Read(input); + double? value = _single_doubleField98_codec.Read(ref input); if (doubleField98_ == null || value != 0D) { DoubleField98 = value; } break; } case 794: { - double? value = _single_doubleField99_codec.Read(input); + double? value = _single_doubleField99_codec.Read(ref input); if (doubleField99_ == null || value != 0D) { DoubleField99 = value; } @@ -3869,207 +3874,207 @@ namespace Google.Protobuf.Benchmarks { } case 802: case 800: { - repeatedIntField100_.AddEntriesFrom(input, _repeated_repeatedIntField100_codec); + repeatedIntField100_.AddEntriesFrom(ref input, _repeated_repeatedIntField100_codec); break; } case 810: { - double? value = _single_doubleField101_codec.Read(input); + double? value = _single_doubleField101_codec.Read(ref input); if (doubleField101_ == null || value != 0D) { DoubleField101 = value; } break; } case 818: { - double? value = _single_doubleField102_codec.Read(input); + double? value = _single_doubleField102_codec.Read(ref input); if (doubleField102_ == null || value != 0D) { DoubleField102 = value; } break; } case 826: { - double? value = _single_doubleField103_codec.Read(input); + double? value = _single_doubleField103_codec.Read(ref input); if (doubleField103_ == null || value != 0D) { DoubleField103 = value; } break; } case 834: { - double? value = _single_doubleField104_codec.Read(input); + double? value = _single_doubleField104_codec.Read(ref input); if (doubleField104_ == null || value != 0D) { DoubleField104 = value; } break; } case 842: { - double? value = _single_doubleField105_codec.Read(input); + double? value = _single_doubleField105_codec.Read(ref input); if (doubleField105_ == null || value != 0D) { DoubleField105 = value; } break; } case 850: { - double? value = _single_doubleField106_codec.Read(input); + double? value = _single_doubleField106_codec.Read(ref input); if (doubleField106_ == null || value != 0D) { DoubleField106 = value; } break; } case 858: { - long? value = _single_int64Field107_codec.Read(input); + long? value = _single_int64Field107_codec.Read(ref input); if (int64Field107_ == null || value != 0L) { Int64Field107 = value; } break; } case 866: { - double? value = _single_doubleField108_codec.Read(input); + double? value = _single_doubleField108_codec.Read(ref input); if (doubleField108_ == null || value != 0D) { DoubleField108 = value; } break; } case 874: { - double? value = _single_doubleField109_codec.Read(input); + double? value = _single_doubleField109_codec.Read(ref input); if (doubleField109_ == null || value != 0D) { DoubleField109 = value; } break; } case 882: { - long? value = _single_int64Field110_codec.Read(input); + long? value = _single_int64Field110_codec.Read(ref input); if (int64Field110_ == null || value != 0L) { Int64Field110 = value; } break; } case 890: { - double? value = _single_doubleField111_codec.Read(input); + double? value = _single_doubleField111_codec.Read(ref input); if (doubleField111_ == null || value != 0D) { DoubleField111 = value; } break; } case 898: { - long? value = _single_int64Field112_codec.Read(input); + long? value = _single_int64Field112_codec.Read(ref input); if (int64Field112_ == null || value != 0L) { Int64Field112 = value; } break; } case 906: { - double? value = _single_doubleField113_codec.Read(input); + double? value = _single_doubleField113_codec.Read(ref input); if (doubleField113_ == null || value != 0D) { DoubleField113 = value; } break; } case 914: { - long? value = _single_int64Field114_codec.Read(input); + long? value = _single_int64Field114_codec.Read(ref input); if (int64Field114_ == null || value != 0L) { Int64Field114 = value; } break; } case 922: { - long? value = _single_int64Field115_codec.Read(input); + long? value = _single_int64Field115_codec.Read(ref input); if (int64Field115_ == null || value != 0L) { Int64Field115 = value; } break; } case 930: { - double? value = _single_doubleField116_codec.Read(input); + double? value = _single_doubleField116_codec.Read(ref input); if (doubleField116_ == null || value != 0D) { DoubleField116 = value; } break; } case 938: { - long? value = _single_int64Field117_codec.Read(input); + long? value = _single_int64Field117_codec.Read(ref input); if (int64Field117_ == null || value != 0L) { Int64Field117 = value; } break; } case 946: { - double? value = _single_doubleField118_codec.Read(input); + double? value = _single_doubleField118_codec.Read(ref input); if (doubleField118_ == null || value != 0D) { DoubleField118 = value; } break; } case 954: { - double? value = _single_doubleField119_codec.Read(input); + double? value = _single_doubleField119_codec.Read(ref input); if (doubleField119_ == null || value != 0D) { DoubleField119 = value; } break; } case 962: { - double? value = _single_doubleField120_codec.Read(input); + double? value = _single_doubleField120_codec.Read(ref input); if (doubleField120_ == null || value != 0D) { DoubleField120 = value; } break; } case 970: { - double? value = _single_doubleField121_codec.Read(input); + double? value = _single_doubleField121_codec.Read(ref input); if (doubleField121_ == null || value != 0D) { DoubleField121 = value; } break; } case 978: { - double? value = _single_doubleField122_codec.Read(input); + double? value = _single_doubleField122_codec.Read(ref input); if (doubleField122_ == null || value != 0D) { DoubleField122 = value; } break; } case 986: { - double? value = _single_doubleField123_codec.Read(input); + double? value = _single_doubleField123_codec.Read(ref input); if (doubleField123_ == null || value != 0D) { DoubleField123 = value; } break; } case 994: { - double? value = _single_doubleField124_codec.Read(input); + double? value = _single_doubleField124_codec.Read(ref input); if (doubleField124_ == null || value != 0D) { DoubleField124 = value; } break; } case 1002: { - long? value = _single_int64Field125_codec.Read(input); + long? value = _single_int64Field125_codec.Read(ref input); if (int64Field125_ == null || value != 0L) { Int64Field125 = value; } break; } case 1010: { - long? value = _single_int64Field126_codec.Read(input); + long? value = _single_int64Field126_codec.Read(ref input); if (int64Field126_ == null || value != 0L) { Int64Field126 = value; } break; } case 1018: { - long? value = _single_int64Field127_codec.Read(input); + long? value = _single_int64Field127_codec.Read(ref input); if (int64Field127_ == null || value != 0L) { Int64Field127 = value; } break; } case 1026: { - double? value = _single_doubleField128_codec.Read(input); + double? value = _single_doubleField128_codec.Read(ref input); if (doubleField128_ == null || value != 0D) { DoubleField128 = value; } break; } case 1034: { - double? value = _single_doubleField129_codec.Read(input); + double? value = _single_doubleField129_codec.Read(ref input); if (doubleField129_ == null || value != 0D) { DoubleField129 = value; } @@ -4085,7 +4090,7 @@ namespace Google.Protobuf.Benchmarks { /// same as ManyWrapperFieldsMessages, but with primitive fields /// for comparison. /// - public sealed partial class ManyPrimitiveFieldsMessage : pb::IMessage { + public sealed partial class ManyPrimitiveFieldsMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ManyPrimitiveFieldsMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6830,11 +6835,16 @@ namespace Google.Protobuf.Benchmarks { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 9: { DoubleField1 = input.ReadDouble(); @@ -7162,7 +7172,7 @@ namespace Google.Protobuf.Benchmarks { } case 802: case 800: { - repeatedIntField100_.AddEntriesFrom(input, _repeated_repeatedIntField100_codec); + repeatedIntField100_.AddEntriesFrom(ref input, _repeated_repeatedIntField100_codec); break; } case 809: { diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs index 23894ad3ba..3b8b191ac4 100644 --- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs +++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs @@ -107,7 +107,7 @@ namespace Conformance { /// This will be known by message_type == "conformance.FailureSet", a conformance /// test should return a serialized FailureSet in protobuf_payload. /// - public sealed partial class FailureSet : pb::IMessage { + public sealed partial class FailureSet : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FailureSet()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -212,14 +212,19 @@ namespace Conformance { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - failure_.AddEntriesFrom(input, _repeated_failure_codec); + failure_.AddEntriesFrom(ref input, _repeated_failure_codec); break; } } @@ -235,7 +240,7 @@ namespace Conformance { /// 2. parse the protobuf or JSON payload in "payload" (which may fail) /// 3. if the parse succeeded, serialize the message in the requested format. /// - public sealed partial class ConformanceRequest : pb::IMessage { + public sealed partial class ConformanceRequest : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ConformanceRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -603,11 +608,16 @@ namespace Conformance { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { ProtobufPayload = input.ReadBytes(); @@ -657,7 +667,7 @@ namespace Conformance { /// /// Represents a single test case's output. /// - public sealed partial class ConformanceResponse : pb::IMessage { + public sealed partial class ConformanceResponse : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ConformanceResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1025,11 +1035,16 @@ namespace Conformance { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { ParseError = input.ReadString(); @@ -1072,7 +1087,7 @@ namespace Conformance { /// /// Encoding options for jspb format. /// - public sealed partial class JspbEncodingConfig : pb::IMessage { + public sealed partial class JspbEncodingConfig : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new JspbEncodingConfig()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1188,11 +1203,16 @@ namespace Conformance { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { UseJspbArrayAnyFormat = input.ReadBool(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs index 197b197d0e..1a395caa67 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs @@ -176,7 +176,7 @@ namespace Google.Protobuf.TestProtos { /// /// Tests maps. /// - public sealed partial class TestMap : pb::IMessage { + public sealed partial class TestMap : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -537,78 +537,83 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); break; } case 18: { - mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); break; } case 26: { - mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); break; } case 34: { - mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); break; } case 42: { - mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); break; } case 50: { - mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); break; } case 58: { - mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); break; } case 66: { - mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); break; } case 74: { - mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); break; } case 82: { - mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); break; } case 90: { - mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); break; } case 98: { - mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); break; } case 106: { - mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); break; } case 114: { - mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); + mapStringString_.AddEntriesFrom(ref input, _map_mapStringString_codec); break; } case 122: { - mapInt32Bytes_.AddEntriesFrom(input, _map_mapInt32Bytes_codec); + mapInt32Bytes_.AddEntriesFrom(ref input, _map_mapInt32Bytes_codec); break; } case 130: { - mapInt32Enum_.AddEntriesFrom(input, _map_mapInt32Enum_codec); + mapInt32Enum_.AddEntriesFrom(ref input, _map_mapInt32Enum_codec); break; } case 138: { - mapInt32ForeignMessage_.AddEntriesFrom(input, _map_mapInt32ForeignMessage_codec); + mapInt32ForeignMessage_.AddEntriesFrom(ref input, _map_mapInt32ForeignMessage_codec); break; } } @@ -617,7 +622,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestMapSubmessage : pb::IMessage { + public sealed partial class TestMapSubmessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMapSubmessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -733,11 +738,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (testMap_ == null) { @@ -752,7 +762,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestMessageMap : pb::IMessage { + public sealed partial class TestMessageMap : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMessageMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -857,14 +867,19 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec); + mapInt32Message_.AddEntriesFrom(ref input, _map_mapInt32Message_codec); break; } } @@ -876,7 +891,7 @@ namespace Google.Protobuf.TestProtos { /// /// Two map fields share the same entry default instance. /// - public sealed partial class TestSameTypeMap : pb::IMessage { + public sealed partial class TestSameTypeMap : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestSameTypeMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -997,18 +1012,23 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - map1_.AddEntriesFrom(input, _map_map1_codec); + map1_.AddEntriesFrom(ref input, _map_map1_codec); break; } case 18: { - map2_.AddEntriesFrom(input, _map_map2_codec); + map2_.AddEntriesFrom(ref input, _map_map2_codec); break; } } @@ -1017,7 +1037,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestArenaMap : pb::IMessage { + public sealed partial class TestArenaMap : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestArenaMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1346,70 +1366,75 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); break; } case 18: { - mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); break; } case 26: { - mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); break; } case 34: { - mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); break; } case 42: { - mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); break; } case 50: { - mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); break; } case 58: { - mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); break; } case 66: { - mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); break; } case 74: { - mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); break; } case 82: { - mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); break; } case 90: { - mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); break; } case 98: { - mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); break; } case 106: { - mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); break; } case 114: { - mapInt32Enum_.AddEntriesFrom(input, _map_mapInt32Enum_codec); + mapInt32Enum_.AddEntriesFrom(ref input, _map_mapInt32Enum_codec); break; } case 122: { - mapInt32ForeignMessage_.AddEntriesFrom(input, _map_mapInt32ForeignMessage_codec); + mapInt32ForeignMessage_.AddEntriesFrom(ref input, _map_mapInt32ForeignMessage_codec); break; } } @@ -1422,7 +1447,7 @@ namespace Google.Protobuf.TestProtos { /// Previously, message containing enum called Type cannot be used as value of /// map field. /// - public sealed partial class MessageContainingEnumCalledType : pb::IMessage { + public sealed partial class MessageContainingEnumCalledType : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingEnumCalledType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1527,14 +1552,19 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - type_.AddEntriesFrom(input, _map_type_codec); + type_.AddEntriesFrom(ref input, _map_type_codec); break; } } @@ -1557,7 +1587,7 @@ namespace Google.Protobuf.TestProtos { /// /// Previously, message cannot contain map field called "entry". /// - public sealed partial class MessageContainingMapCalledEntry : pb::IMessage { + public sealed partial class MessageContainingMapCalledEntry : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingMapCalledEntry()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1662,14 +1692,19 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - entry_.AddEntriesFrom(input, _map_entry_codec); + entry_.AddEntriesFrom(ref input, _map_entry_codec); break; } } diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs index 350fb7cde7..8828d34ef3 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs @@ -244,7 +244,7 @@ namespace ProtobufTestMessages.Proto2 { /// could trigger bugs that occur in any message type in this file. We verify /// this stays true in a unit test. /// - public sealed partial class TestAllTypesProto2 : pb::IExtendableMessage { + public sealed partial class TestAllTypesProto2 : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypesProto2()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -3353,12 +3353,17 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 8: { @@ -3460,317 +3465,317 @@ namespace ProtobufTestMessages.Proto2 { } case 250: case 248: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } case 258: case 256: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); break; } case 266: case 264: { - repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); break; } case 274: case 272: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); break; } case 282: case 280: { - repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); break; } case 290: case 288: { - repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); break; } case 298: case 301: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); break; } case 306: case 305: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); break; } case 314: case 317: { - repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); break; } case 322: case 321: { - repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); break; } case 330: case 333: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); break; } case 338: case 337: { - repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); break; } case 346: case 344: { - repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); break; } case 354: { - repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); break; } case 362: { - repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); break; } case 386: { - repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); break; } case 394: { - repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); break; } case 410: case 408: { - repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); break; } case 418: case 416: { - repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); break; } case 434: { - repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec); + repeatedStringPiece_.AddEntriesFrom(ref input, _repeated_repeatedStringPiece_codec); break; } case 442: { - repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec); + repeatedCord_.AddEntriesFrom(ref input, _repeated_repeatedCord_codec); break; } case 450: { - mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); break; } case 458: { - mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); break; } case 466: { - mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); break; } case 474: { - mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); break; } case 482: { - mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); break; } case 490: { - mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); break; } case 498: { - mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); break; } case 506: { - mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); break; } case 514: { - mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); break; } case 522: { - mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); break; } case 530: { - mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); break; } case 538: { - mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); break; } case 546: { - mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); break; } case 554: { - mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); + mapStringString_.AddEntriesFrom(ref input, _map_mapStringString_codec); break; } case 562: { - mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec); + mapStringBytes_.AddEntriesFrom(ref input, _map_mapStringBytes_codec); break; } case 570: { - mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec); + mapStringNestedMessage_.AddEntriesFrom(ref input, _map_mapStringNestedMessage_codec); break; } case 578: { - mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec); + mapStringForeignMessage_.AddEntriesFrom(ref input, _map_mapStringForeignMessage_codec); break; } case 586: { - mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec); + mapStringNestedEnum_.AddEntriesFrom(ref input, _map_mapStringNestedEnum_codec); break; } case 594: { - mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec); + mapStringForeignEnum_.AddEntriesFrom(ref input, _map_mapStringForeignEnum_codec); break; } case 602: case 600: { - packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec); + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); break; } case 610: case 608: { - packedInt64_.AddEntriesFrom(input, _repeated_packedInt64_codec); + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); break; } case 618: case 616: { - packedUint32_.AddEntriesFrom(input, _repeated_packedUint32_codec); + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); break; } case 626: case 624: { - packedUint64_.AddEntriesFrom(input, _repeated_packedUint64_codec); + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); break; } case 634: case 632: { - packedSint32_.AddEntriesFrom(input, _repeated_packedSint32_codec); + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); break; } case 642: case 640: { - packedSint64_.AddEntriesFrom(input, _repeated_packedSint64_codec); + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); break; } case 650: case 653: { - packedFixed32_.AddEntriesFrom(input, _repeated_packedFixed32_codec); + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); break; } case 658: case 657: { - packedFixed64_.AddEntriesFrom(input, _repeated_packedFixed64_codec); + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); break; } case 666: case 669: { - packedSfixed32_.AddEntriesFrom(input, _repeated_packedSfixed32_codec); + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); break; } case 674: case 673: { - packedSfixed64_.AddEntriesFrom(input, _repeated_packedSfixed64_codec); + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); break; } case 682: case 685: { - packedFloat_.AddEntriesFrom(input, _repeated_packedFloat_codec); + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); break; } case 690: case 689: { - packedDouble_.AddEntriesFrom(input, _repeated_packedDouble_codec); + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); break; } case 698: case 696: { - packedBool_.AddEntriesFrom(input, _repeated_packedBool_codec); + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); break; } case 706: case 704: { - packedNestedEnum_.AddEntriesFrom(input, _repeated_packedNestedEnum_codec); + packedNestedEnum_.AddEntriesFrom(ref input, _repeated_packedNestedEnum_codec); break; } case 714: case 712: { - unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec); + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); break; } case 722: case 720: { - unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec); + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); break; } case 730: case 728: { - unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec); + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); break; } case 738: case 736: { - unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec); + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); break; } case 746: case 744: { - unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec); + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); break; } case 754: case 752: { - unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec); + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); break; } case 762: case 765: { - unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec); + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); break; } case 770: case 769: { - unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec); + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); break; } case 778: case 781: { - unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec); + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); break; } case 786: case 785: { - unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec); + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); break; } case 794: case 797: { - unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec); + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); break; } case 802: case 801: { - unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec); + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); break; } case 810: case 808: { - unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec); + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); break; } case 818: case 816: { - unpackedNestedEnum_.AddEntriesFrom(input, _repeated_unpackedNestedEnum_codec); + unpackedNestedEnum_.AddEntriesFrom(ref input, _repeated_unpackedNestedEnum_codec); break; } case 888: { @@ -3934,7 +3939,7 @@ namespace ProtobufTestMessages.Proto2 { [pbr::OriginalName("NEG")] Neg = -1, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4099,11 +4104,16 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -4125,7 +4135,7 @@ namespace ProtobufTestMessages.Proto2 { /// /// groups /// - public sealed partial class Data : pb::IMessage { + public sealed partial class Data : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Data()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4290,13 +4300,18 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 1612: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 1616: { GroupInt32 = input.ReadInt32(); @@ -4315,7 +4330,7 @@ namespace ProtobufTestMessages.Proto2 { /// /// message_set test case. /// - public sealed partial class MessageSetCorrect : pb::IExtendableMessage { + public sealed partial class MessageSetCorrect : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageSetCorrect()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -4420,12 +4435,17 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; } @@ -4456,7 +4476,7 @@ namespace ProtobufTestMessages.Proto2 { } - public sealed partial class MessageSetCorrectExtension1 : pb::IMessage { + public sealed partial class MessageSetCorrectExtension1 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageSetCorrectExtension1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4581,11 +4601,16 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 202: { Str = input.ReadString(); @@ -4606,7 +4631,7 @@ namespace ProtobufTestMessages.Proto2 { } - public sealed partial class MessageSetCorrectExtension2 : pb::IMessage { + public sealed partial class MessageSetCorrectExtension2 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageSetCorrectExtension2()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4734,11 +4759,16 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 72: { I = input.ReadInt32(); @@ -4764,7 +4794,7 @@ namespace ProtobufTestMessages.Proto2 { } - public sealed partial class ForeignMessageProto2 : pb::IMessage { + public sealed partial class ForeignMessageProto2 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessageProto2()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4892,11 +4922,16 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { C = input.ReadInt32(); @@ -4908,7 +4943,7 @@ namespace ProtobufTestMessages.Proto2 { } - public sealed partial class UnknownToTestAllTypes : pb::IMessage { + public sealed partial class UnknownToTestAllTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UnknownToTestAllTypes()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5200,11 +5235,16 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8008: { OptionalInt32 = input.ReadInt32(); @@ -5234,7 +5274,7 @@ namespace ProtobufTestMessages.Proto2 { } case 8090: case 8088: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } } @@ -5245,7 +5285,7 @@ namespace ProtobufTestMessages.Proto2 { /// Container for nested types declared in the UnknownToTestAllTypes message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5373,13 +5413,18 @@ namespace ProtobufTestMessages.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 8036: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs index 064d0c0ace..e0a48a18ec 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs @@ -259,7 +259,7 @@ namespace ProtobufTestMessages.Proto3 { /// could trigger bugs that occur in any message type in this file. We verify /// this stays true in a unit test. /// - public sealed partial class TestAllTypesProto3 : pb::IMessage { + public sealed partial class TestAllTypesProto3 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypesProto3()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3383,11 +3383,16 @@ namespace ProtobufTestMessages.Proto3 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { OptionalInt32 = input.ReadInt32(); @@ -3492,317 +3497,317 @@ namespace ProtobufTestMessages.Proto3 { } case 250: case 248: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } case 258: case 256: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); break; } case 266: case 264: { - repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); break; } case 274: case 272: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); break; } case 282: case 280: { - repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); break; } case 290: case 288: { - repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); break; } case 298: case 301: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); break; } case 306: case 305: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); break; } case 314: case 317: { - repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); break; } case 322: case 321: { - repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); break; } case 330: case 333: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); break; } case 338: case 337: { - repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); break; } case 346: case 344: { - repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); break; } case 354: { - repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); break; } case 362: { - repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); break; } case 386: { - repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); break; } case 394: { - repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); break; } case 410: case 408: { - repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); break; } case 418: case 416: { - repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); break; } case 434: { - repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec); + repeatedStringPiece_.AddEntriesFrom(ref input, _repeated_repeatedStringPiece_codec); break; } case 442: { - repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec); + repeatedCord_.AddEntriesFrom(ref input, _repeated_repeatedCord_codec); break; } case 450: { - mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); break; } case 458: { - mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); break; } case 466: { - mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); break; } case 474: { - mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); break; } case 482: { - mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); break; } case 490: { - mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); break; } case 498: { - mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); break; } case 506: { - mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); break; } case 514: { - mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); break; } case 522: { - mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); break; } case 530: { - mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); break; } case 538: { - mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); break; } case 546: { - mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); break; } case 554: { - mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); + mapStringString_.AddEntriesFrom(ref input, _map_mapStringString_codec); break; } case 562: { - mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec); + mapStringBytes_.AddEntriesFrom(ref input, _map_mapStringBytes_codec); break; } case 570: { - mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec); + mapStringNestedMessage_.AddEntriesFrom(ref input, _map_mapStringNestedMessage_codec); break; } case 578: { - mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec); + mapStringForeignMessage_.AddEntriesFrom(ref input, _map_mapStringForeignMessage_codec); break; } case 586: { - mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec); + mapStringNestedEnum_.AddEntriesFrom(ref input, _map_mapStringNestedEnum_codec); break; } case 594: { - mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec); + mapStringForeignEnum_.AddEntriesFrom(ref input, _map_mapStringForeignEnum_codec); break; } case 602: case 600: { - packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec); + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); break; } case 610: case 608: { - packedInt64_.AddEntriesFrom(input, _repeated_packedInt64_codec); + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); break; } case 618: case 616: { - packedUint32_.AddEntriesFrom(input, _repeated_packedUint32_codec); + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); break; } case 626: case 624: { - packedUint64_.AddEntriesFrom(input, _repeated_packedUint64_codec); + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); break; } case 634: case 632: { - packedSint32_.AddEntriesFrom(input, _repeated_packedSint32_codec); + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); break; } case 642: case 640: { - packedSint64_.AddEntriesFrom(input, _repeated_packedSint64_codec); + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); break; } case 650: case 653: { - packedFixed32_.AddEntriesFrom(input, _repeated_packedFixed32_codec); + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); break; } case 658: case 657: { - packedFixed64_.AddEntriesFrom(input, _repeated_packedFixed64_codec); + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); break; } case 666: case 669: { - packedSfixed32_.AddEntriesFrom(input, _repeated_packedSfixed32_codec); + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); break; } case 674: case 673: { - packedSfixed64_.AddEntriesFrom(input, _repeated_packedSfixed64_codec); + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); break; } case 682: case 685: { - packedFloat_.AddEntriesFrom(input, _repeated_packedFloat_codec); + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); break; } case 690: case 689: { - packedDouble_.AddEntriesFrom(input, _repeated_packedDouble_codec); + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); break; } case 698: case 696: { - packedBool_.AddEntriesFrom(input, _repeated_packedBool_codec); + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); break; } case 706: case 704: { - packedNestedEnum_.AddEntriesFrom(input, _repeated_packedNestedEnum_codec); + packedNestedEnum_.AddEntriesFrom(ref input, _repeated_packedNestedEnum_codec); break; } case 714: case 712: { - unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec); + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); break; } case 722: case 720: { - unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec); + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); break; } case 730: case 728: { - unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec); + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); break; } case 738: case 736: { - unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec); + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); break; } case 746: case 744: { - unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec); + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); break; } case 754: case 752: { - unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec); + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); break; } case 762: case 765: { - unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec); + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); break; } case 770: case 769: { - unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec); + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); break; } case 778: case 781: { - unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec); + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); break; } case 786: case 785: { - unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec); + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); break; } case 794: case 797: { - unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec); + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); break; } case 802: case 801: { - unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec); + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); break; } case 810: case 808: { - unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec); + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); break; } case 818: case 816: { - unpackedNestedEnum_.AddEntriesFrom(input, _repeated_unpackedNestedEnum_codec); + unpackedNestedEnum_.AddEntriesFrom(ref input, _repeated_unpackedNestedEnum_codec); break; } case 888: { @@ -3848,102 +3853,102 @@ namespace ProtobufTestMessages.Proto3 { break; } case 1610: { - bool? value = _single_optionalBoolWrapper_codec.Read(input); + bool? value = _single_optionalBoolWrapper_codec.Read(ref input); if (optionalBoolWrapper_ == null || value != false) { OptionalBoolWrapper = value; } break; } case 1618: { - int? value = _single_optionalInt32Wrapper_codec.Read(input); + int? value = _single_optionalInt32Wrapper_codec.Read(ref input); if (optionalInt32Wrapper_ == null || value != 0) { OptionalInt32Wrapper = value; } break; } case 1626: { - long? value = _single_optionalInt64Wrapper_codec.Read(input); + long? value = _single_optionalInt64Wrapper_codec.Read(ref input); if (optionalInt64Wrapper_ == null || value != 0L) { OptionalInt64Wrapper = value; } break; } case 1634: { - uint? value = _single_optionalUint32Wrapper_codec.Read(input); + uint? value = _single_optionalUint32Wrapper_codec.Read(ref input); if (optionalUint32Wrapper_ == null || value != 0) { OptionalUint32Wrapper = value; } break; } case 1642: { - ulong? value = _single_optionalUint64Wrapper_codec.Read(input); + ulong? value = _single_optionalUint64Wrapper_codec.Read(ref input); if (optionalUint64Wrapper_ == null || value != 0UL) { OptionalUint64Wrapper = value; } break; } case 1650: { - float? value = _single_optionalFloatWrapper_codec.Read(input); + float? value = _single_optionalFloatWrapper_codec.Read(ref input); if (optionalFloatWrapper_ == null || value != 0F) { OptionalFloatWrapper = value; } break; } case 1658: { - double? value = _single_optionalDoubleWrapper_codec.Read(input); + double? value = _single_optionalDoubleWrapper_codec.Read(ref input); if (optionalDoubleWrapper_ == null || value != 0D) { OptionalDoubleWrapper = value; } break; } case 1666: { - string value = _single_optionalStringWrapper_codec.Read(input); + string value = _single_optionalStringWrapper_codec.Read(ref input); if (optionalStringWrapper_ == null || value != "") { OptionalStringWrapper = value; } break; } case 1674: { - pb::ByteString value = _single_optionalBytesWrapper_codec.Read(input); + pb::ByteString value = _single_optionalBytesWrapper_codec.Read(ref input); if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) { OptionalBytesWrapper = value; } break; } case 1690: { - repeatedBoolWrapper_.AddEntriesFrom(input, _repeated_repeatedBoolWrapper_codec); + repeatedBoolWrapper_.AddEntriesFrom(ref input, _repeated_repeatedBoolWrapper_codec); break; } case 1698: { - repeatedInt32Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt32Wrapper_codec); + repeatedInt32Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedInt32Wrapper_codec); break; } case 1706: { - repeatedInt64Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt64Wrapper_codec); + repeatedInt64Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedInt64Wrapper_codec); break; } case 1714: { - repeatedUint32Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint32Wrapper_codec); + repeatedUint32Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedUint32Wrapper_codec); break; } case 1722: { - repeatedUint64Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint64Wrapper_codec); + repeatedUint64Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedUint64Wrapper_codec); break; } case 1730: { - repeatedFloatWrapper_.AddEntriesFrom(input, _repeated_repeatedFloatWrapper_codec); + repeatedFloatWrapper_.AddEntriesFrom(ref input, _repeated_repeatedFloatWrapper_codec); break; } case 1738: { - repeatedDoubleWrapper_.AddEntriesFrom(input, _repeated_repeatedDoubleWrapper_codec); + repeatedDoubleWrapper_.AddEntriesFrom(ref input, _repeated_repeatedDoubleWrapper_codec); break; } case 1746: { - repeatedStringWrapper_.AddEntriesFrom(input, _repeated_repeatedStringWrapper_codec); + repeatedStringWrapper_.AddEntriesFrom(ref input, _repeated_repeatedStringWrapper_codec); break; } case 1754: { - repeatedBytesWrapper_.AddEntriesFrom(input, _repeated_repeatedBytesWrapper_codec); + repeatedBytesWrapper_.AddEntriesFrom(ref input, _repeated_repeatedBytesWrapper_codec); break; } case 2410: { @@ -3989,31 +3994,31 @@ namespace ProtobufTestMessages.Proto3 { break; } case 2490: { - repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec); + repeatedDuration_.AddEntriesFrom(ref input, _repeated_repeatedDuration_codec); break; } case 2498: { - repeatedTimestamp_.AddEntriesFrom(input, _repeated_repeatedTimestamp_codec); + repeatedTimestamp_.AddEntriesFrom(ref input, _repeated_repeatedTimestamp_codec); break; } case 2506: { - repeatedFieldmask_.AddEntriesFrom(input, _repeated_repeatedFieldmask_codec); + repeatedFieldmask_.AddEntriesFrom(ref input, _repeated_repeatedFieldmask_codec); break; } case 2522: { - repeatedAny_.AddEntriesFrom(input, _repeated_repeatedAny_codec); + repeatedAny_.AddEntriesFrom(ref input, _repeated_repeatedAny_codec); break; } case 2530: { - repeatedValue_.AddEntriesFrom(input, _repeated_repeatedValue_codec); + repeatedValue_.AddEntriesFrom(ref input, _repeated_repeatedValue_codec); break; } case 2538: { - repeatedListValue_.AddEntriesFrom(input, _repeated_repeatedListValue_codec); + repeatedListValue_.AddEntriesFrom(ref input, _repeated_repeatedListValue_codec); break; } case 2594: { - repeatedStruct_.AddEntriesFrom(input, _repeated_repeatedStruct_codec); + repeatedStruct_.AddEntriesFrom(ref input, _repeated_repeatedStruct_codec); break; } case 3208: { @@ -4115,7 +4120,7 @@ namespace ProtobufTestMessages.Proto3 { [pbr::OriginalName("bAz", PreferredAlias = false)] BAz = 2, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4255,11 +4260,16 @@ namespace ProtobufTestMessages.Proto3 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -4283,7 +4293,7 @@ namespace ProtobufTestMessages.Proto3 { } - public sealed partial class ForeignMessage : pb::IMessage { + public sealed partial class ForeignMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4396,11 +4406,16 @@ namespace ProtobufTestMessages.Proto3 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { C = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs index a35b6e0fe3..f6e0a26045 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs @@ -1120,7 +1120,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// This proto includes every type of field in both singular and repeated /// forms. /// - public sealed partial class TestAllTypes : pb::IMessage { + public sealed partial class TestAllTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -3504,11 +3504,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { OptionalInt32 = input.ReadInt32(); @@ -3634,118 +3639,118 @@ namespace Google.Protobuf.TestProtos.Proto2 { } case 250: case 248: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } case 258: case 256: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); break; } case 266: case 264: { - repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); break; } case 274: case 272: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); break; } case 282: case 280: { - repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); break; } case 290: case 288: { - repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); break; } case 298: case 301: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); break; } case 306: case 305: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); break; } case 314: case 317: { - repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); break; } case 322: case 321: { - repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); break; } case 330: case 333: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); break; } case 338: case 337: { - repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); break; } case 346: case 344: { - repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); break; } case 354: { - repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); break; } case 362: { - repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); break; } case 371: { - repeatedGroup_.AddEntriesFrom(input, _repeated_repeatedGroup_codec); + repeatedGroup_.AddEntriesFrom(ref input, _repeated_repeatedGroup_codec); break; } case 386: { - repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); break; } case 394: { - repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); break; } case 402: { - repeatedImportMessage_.AddEntriesFrom(input, _repeated_repeatedImportMessage_codec); + repeatedImportMessage_.AddEntriesFrom(ref input, _repeated_repeatedImportMessage_codec); break; } case 410: case 408: { - repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); break; } case 418: case 416: { - repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); break; } case 426: case 424: { - repeatedImportEnum_.AddEntriesFrom(input, _repeated_repeatedImportEnum_codec); + repeatedImportEnum_.AddEntriesFrom(ref input, _repeated_repeatedImportEnum_codec); break; } case 434: { - repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec); + repeatedStringPiece_.AddEntriesFrom(ref input, _repeated_repeatedStringPiece_codec); break; } case 442: { - repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec); + repeatedCord_.AddEntriesFrom(ref input, _repeated_repeatedCord_codec); break; } case 458: { - repeatedLazyMessage_.AddEntriesFrom(input, _repeated_repeatedLazyMessage_codec); + repeatedLazyMessage_.AddEntriesFrom(ref input, _repeated_repeatedLazyMessage_codec); break; } case 488: { @@ -3867,7 +3872,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { [pbr::OriginalName("NEG")] Neg = -1, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4000,11 +4005,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Bb = input.ReadInt32(); @@ -4016,7 +4026,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4144,13 +4154,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 132: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 136: { A = input.ReadInt32(); @@ -4162,7 +4177,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class RepeatedGroup : pb::IMessage { + public sealed partial class RepeatedGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4290,13 +4305,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 372: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 376: { A = input.ReadInt32(); @@ -4316,7 +4336,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// This proto includes a recursively nested message. /// - public sealed partial class NestedTestAllTypes : pb::IMessage { + public sealed partial class NestedTestAllTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4495,11 +4515,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasChild) { @@ -4516,7 +4541,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { break; } case 26: { - repeatedChild_.AddEntriesFrom(input, _repeated_repeatedChild_codec); + repeatedChild_.AddEntriesFrom(ref input, _repeated_repeatedChild_codec); break; } } @@ -4525,7 +4550,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestDeprecatedFields : pb::IMessage { + public sealed partial class TestDeprecatedFields : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4723,11 +4748,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { DeprecatedInt32 = input.ReadInt32(); @@ -4744,7 +4774,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } [global::System.ObsoleteAttribute] - public sealed partial class TestDeprecatedMessage : pb::IMessage { + public sealed partial class TestDeprecatedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4833,11 +4863,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -4849,7 +4884,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Define these after TestAllTypes to make sure the compiler can handle /// that. /// - public sealed partial class ForeignMessage : pb::IMessage { + public sealed partial class ForeignMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5014,11 +5049,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { C = input.ReadInt32(); @@ -5034,7 +5074,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestReservedFields : pb::IMessage { + public sealed partial class TestReservedFields : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5123,11 +5163,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -5135,7 +5180,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestAllExtensions : pb::IExtendableMessage { + public sealed partial class TestAllExtensions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -5240,12 +5285,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; } @@ -5276,7 +5326,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class OptionalGroup_extension : pb::IMessage { + public sealed partial class OptionalGroup_extension : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup_extension()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5404,13 +5454,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 132: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 136: { A = input.ReadInt32(); @@ -5422,7 +5477,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class RepeatedGroup_extension : pb::IMessage { + public sealed partial class RepeatedGroup_extension : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedGroup_extension()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5550,13 +5605,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 372: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 376: { A = input.ReadInt32(); @@ -5568,7 +5628,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestGroup : pb::IMessage { + public sealed partial class TestGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5734,11 +5794,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 131: { if (!HasOptionalGroup) { @@ -5759,7 +5824,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestGroup message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5887,13 +5952,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 132: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 136: { A = input.ReadInt32(); @@ -5910,7 +5980,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestGroupExtension : pb::IExtendableMessage { + public sealed partial class TestGroupExtension : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestGroupExtension()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -6015,12 +6085,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; } @@ -6051,7 +6126,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestNestedExtension : pb::IMessage { + public sealed partial class TestNestedExtension : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestNestedExtension()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6140,11 +6215,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -6154,7 +6234,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestNestedExtension message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup_extension : pb::IMessage { + public sealed partial class OptionalGroup_extension : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup_extension()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -6282,13 +6362,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 132: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 136: { A = input.ReadInt32(); @@ -6335,7 +6420,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// required filed because the code output is basically identical to /// optional fields for all types. /// - public sealed partial class TestRequired : pb::IMessage { + public sealed partial class TestRequired : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequired()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7653,11 +7738,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -7808,7 +7898,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestRequiredForeign : pb::IMessage { + public sealed partial class TestRequiredForeign : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredForeign()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7989,11 +8079,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasOptionalMessage) { @@ -8003,7 +8098,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { break; } case 18: { - repeatedMessage_.AddEntriesFrom(input, _repeated_repeatedMessage_codec); + repeatedMessage_.AddEntriesFrom(ref input, _repeated_repeatedMessage_codec); break; } case 24: { @@ -8016,7 +8111,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestRequiredMessage : pb::IMessage { + public sealed partial class TestRequiredMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8195,11 +8290,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasOptionalMessage) { @@ -8209,7 +8309,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { break; } case 18: { - repeatedMessage_.AddEntriesFrom(input, _repeated_repeatedMessage_codec); + repeatedMessage_.AddEntriesFrom(ref input, _repeated_repeatedMessage_codec); break; } case 26: { @@ -8228,7 +8328,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Test that we can use NestedMessage from outside TestAllTypes. /// - public sealed partial class TestForeignNested : pb::IMessage { + public sealed partial class TestForeignNested : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8354,11 +8454,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasForeignNested) { @@ -8376,7 +8481,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// TestEmptyMessage is used to test unknown field support. /// - public sealed partial class TestEmptyMessage : pb::IMessage { + public sealed partial class TestEmptyMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEmptyMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8465,11 +8570,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -8481,7 +8591,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Like above, but declare all field numbers as potential extensions. No /// actual extensions should ever be defined for this type. /// - public sealed partial class TestEmptyMessageWithExtensions : pb::IExtendableMessage { + public sealed partial class TestEmptyMessageWithExtensions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEmptyMessageWithExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -8586,12 +8696,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; } @@ -8622,7 +8737,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestMultipleExtensionRanges : pb::IExtendableMessage { + public sealed partial class TestMultipleExtensionRanges : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMultipleExtensionRanges()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -8727,12 +8842,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; } @@ -8766,7 +8886,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Test that really large tag numbers don't break anything. /// - public sealed partial class TestReallyLargeTagNumber : pb::IMessage { + public sealed partial class TestReallyLargeTagNumber : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -8935,11 +9055,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -8955,7 +9080,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestRecursiveMessage : pb::IMessage { + public sealed partial class TestRecursiveMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -9120,11 +9245,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasA) { @@ -9146,7 +9276,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Test that mutual recursion works. /// - public sealed partial class TestMutualRecursionA : pb::IMessage { + public sealed partial class TestMutualRecursionA : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9310,11 +9440,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasBb) { @@ -9338,7 +9473,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestMutualRecursionA message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class SubMessage : pb::IMessage { + public sealed partial class SubMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9464,11 +9599,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasB) { @@ -9483,7 +9623,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class SubGroup : pb::IMessage { + public sealed partial class SubGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubGroup()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9649,13 +9789,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 20: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 26: { if (!HasSubMessage) { @@ -9682,7 +9827,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestMutualRecursionB : pb::IMessage { + public sealed partial class TestMutualRecursionB : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -9847,11 +9992,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasA) { @@ -9870,7 +10020,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestIsInitialized : pb::IMessage { + public sealed partial class TestIsInitialized : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestIsInitialized()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9996,11 +10146,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasSubMessage) { @@ -10017,7 +10172,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestIsInitialized message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class SubMessage : pb::IMessage { + public sealed partial class SubMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -10144,11 +10299,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 11: { if (!HasSubGroup) { @@ -10165,7 +10325,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the SubMessage message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class SubGroup : pb::IMessage { + public sealed partial class SubGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10293,13 +10453,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 12: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 16: { I = input.ReadInt32(); @@ -10327,7 +10492,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// to compile with proto1, this will emit an error; so we only include it /// in protobuf_unittest_proto. /// - public sealed partial class TestDupFieldNumber : pb::IMessage { + public sealed partial class TestDupFieldNumber : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDupFieldNumber()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10534,11 +10699,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -10566,7 +10736,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestDupFieldNumber message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Foo : pb::IMessage { + public sealed partial class Foo : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Foo()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10694,13 +10864,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 20: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -10712,7 +10887,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class Bar : pb::IMessage { + public sealed partial class Bar : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Bar()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10840,13 +11015,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 28: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -10866,7 +11046,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Additional messages for testing lazy fields. /// - public sealed partial class TestEagerMessage : pb::IMessage { + public sealed partial class TestEagerMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEagerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -10992,11 +11172,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasSubMessage) { @@ -11011,7 +11196,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestLazyMessage : pb::IMessage { + public sealed partial class TestLazyMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestLazyMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -11137,11 +11322,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasSubMessage) { @@ -11159,7 +11349,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Needed for a Python test. /// - public sealed partial class TestNestedMessageHasBits : pb::IMessage { + public sealed partial class TestNestedMessageHasBits : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestNestedMessageHasBits()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -11285,11 +11475,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (!HasOptionalNestedMessage) { @@ -11306,7 +11501,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestNestedMessageHasBits message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -11427,19 +11622,24 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: case 8: { - nestedmessageRepeatedInt32_.AddEntriesFrom(input, _repeated_nestedmessageRepeatedInt32_codec); + nestedmessageRepeatedInt32_.AddEntriesFrom(ref input, _repeated_nestedmessageRepeatedInt32_codec); break; } case 18: { - nestedmessageRepeatedForeignmessage_.AddEntriesFrom(input, _repeated_nestedmessageRepeatedForeignmessage_codec); + nestedmessageRepeatedForeignmessage_.AddEntriesFrom(ref input, _repeated_nestedmessageRepeatedForeignmessage_codec); break; } } @@ -11457,7 +11657,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Test message with CamelCase field names. This violates Protocol Buffer /// standard style. /// - public sealed partial class TestCamelCaseFieldNames : pb::IMessage { + public sealed partial class TestCamelCaseFieldNames : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -11863,11 +12063,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { PrimitiveField = input.ReadInt32(); @@ -11898,28 +12103,28 @@ namespace Google.Protobuf.TestProtos.Proto2 { } case 58: case 56: { - repeatedPrimitiveField_.AddEntriesFrom(input, _repeated_repeatedPrimitiveField_codec); + repeatedPrimitiveField_.AddEntriesFrom(ref input, _repeated_repeatedPrimitiveField_codec); break; } case 66: { - repeatedStringField_.AddEntriesFrom(input, _repeated_repeatedStringField_codec); + repeatedStringField_.AddEntriesFrom(ref input, _repeated_repeatedStringField_codec); break; } case 74: case 72: { - repeatedEnumField_.AddEntriesFrom(input, _repeated_repeatedEnumField_codec); + repeatedEnumField_.AddEntriesFrom(ref input, _repeated_repeatedEnumField_codec); break; } case 82: { - repeatedMessageField_.AddEntriesFrom(input, _repeated_repeatedMessageField_codec); + repeatedMessageField_.AddEntriesFrom(ref input, _repeated_repeatedMessageField_codec); break; } case 90: { - repeatedStringPieceField_.AddEntriesFrom(input, _repeated_repeatedStringPieceField_codec); + repeatedStringPieceField_.AddEntriesFrom(ref input, _repeated_repeatedStringPieceField_codec); break; } case 98: { - repeatedCordField_.AddEntriesFrom(input, _repeated_repeatedCordField_codec); + repeatedCordField_.AddEntriesFrom(ref input, _repeated_repeatedCordField_codec); break; } } @@ -11932,7 +12137,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// We list fields out of order, to ensure that we're using field number and not /// field index to determine serialization order. /// - public sealed partial class TestFieldOrderings : pb::IExtendableMessage { + public sealed partial class TestFieldOrderings : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -12186,12 +12391,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 8: { @@ -12243,7 +12453,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestFieldOrderings message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -12413,11 +12623,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Bb = input.ReadInt32(); @@ -12438,7 +12653,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestExtensionOrderings1 : pb::IMessage { + public sealed partial class TestExtensionOrderings1 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionOrderings1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12563,11 +12778,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { MyString = input.ReadString(); @@ -12588,7 +12808,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestExtensionOrderings2 : pb::IMessage { + public sealed partial class TestExtensionOrderings2 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionOrderings2()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12713,11 +12933,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { MyString = input.ReadString(); @@ -12731,7 +12956,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestExtensionOrderings2 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class TestExtensionOrderings3 : pb::IMessage { + public sealed partial class TestExtensionOrderings3 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionOrderings3()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12856,11 +13081,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { MyString = input.ReadString(); @@ -12895,7 +13125,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestExtremeDefaultValues : pb::IMessage { + public sealed partial class TestExtremeDefaultValues : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtremeDefaultValues()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -14001,11 +14231,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { EscapedBytes = input.ReadBytes(); @@ -14121,7 +14356,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class SparseEnumMessage : pb::IMessage { + public sealed partial class SparseEnumMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -14249,11 +14484,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { SparseEnum = (global::Google.Protobuf.TestProtos.Proto2.TestSparseEnum) input.ReadEnum(); @@ -14268,7 +14508,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Test String and Bytes: string is for valid UTF-8 strings /// - public sealed partial class OneString : pb::IMessage { + public sealed partial class OneString : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14393,11 +14633,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Data = input.ReadString(); @@ -14409,7 +14654,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class MoreString : pb::IMessage { + public sealed partial class MoreString : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14514,14 +14759,19 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - data_.AddEntriesFrom(input, _repeated_data_codec); + data_.AddEntriesFrom(ref input, _repeated_data_codec); break; } } @@ -14530,7 +14780,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class OneBytes : pb::IMessage { + public sealed partial class OneBytes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14655,11 +14905,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Data = input.ReadBytes(); @@ -14671,7 +14926,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class MoreBytes : pb::IMessage { + public sealed partial class MoreBytes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14776,14 +15031,19 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - data_.AddEntriesFrom(input, _repeated_data_codec); + data_.AddEntriesFrom(ref input, _repeated_data_codec); break; } } @@ -14795,7 +15055,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Test int32, uint32, int64, uint64, and bool are all compatible /// - public sealed partial class Int32Message : pb::IMessage { + public sealed partial class Int32Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -14923,11 +15183,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadInt32(); @@ -14939,7 +15204,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class Uint32Message : pb::IMessage { + public sealed partial class Uint32Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15067,11 +15332,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadUInt32(); @@ -15083,7 +15353,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class Int64Message : pb::IMessage { + public sealed partial class Int64Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15211,11 +15481,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadInt64(); @@ -15227,7 +15502,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class Uint64Message : pb::IMessage { + public sealed partial class Uint64Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15355,11 +15630,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadUInt64(); @@ -15371,7 +15651,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class BoolMessage : pb::IMessage { + public sealed partial class BoolMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15499,11 +15779,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadBool(); @@ -15518,7 +15803,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Test oneofs. /// - public sealed partial class TestOneof : pb::IMessage { + public sealed partial class TestOneof : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15797,11 +16082,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FooInt = input.ReadInt32(); @@ -15837,7 +16127,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestOneof message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class FooGroup : pb::IMessage { + public sealed partial class FooGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -16001,13 +16291,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 36: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 40: { A = input.ReadInt32(); @@ -16028,7 +16323,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestOneofBackwardsCompatible : pb::IMessage { + public sealed partial class TestOneofBackwardsCompatible : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneofBackwardsCompatible()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -16267,11 +16562,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FooInt = input.ReadInt32(); @@ -16303,7 +16603,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestOneofBackwardsCompatible message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class FooGroup : pb::IMessage { + public sealed partial class FooGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -16467,13 +16767,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 36: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 40: { A = input.ReadInt32(); @@ -16494,7 +16799,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestOneof2 : pb::IMessage { + public sealed partial class TestOneof2 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof2()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -17303,11 +17608,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FooInt = input.ReadInt32(); @@ -17408,7 +17718,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { [pbr::OriginalName("BAZ")] Baz = 3, } - public sealed partial class FooGroup : pb::IMessage { + public sealed partial class FooGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -17572,13 +17882,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 68: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 72: { A = input.ReadInt32(); @@ -17594,7 +17909,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -17738,11 +18053,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { QuxInt = input.ReadInt64(); @@ -17750,7 +18070,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } case 18: case 16: { - corgeInt_.AddEntriesFrom(input, _repeated_corgeInt_codec); + corgeInt_.AddEntriesFrom(ref input, _repeated_corgeInt_codec); break; } } @@ -17764,7 +18084,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestRequiredOneof : pb::IMessage { + public sealed partial class TestRequiredOneof : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredOneof()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -18000,11 +18320,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FooInt = input.ReadInt32(); @@ -18031,7 +18356,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestRequiredOneof message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -18159,11 +18484,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 9: { RequiredDouble = input.ReadDouble(); @@ -18180,7 +18510,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestRequiredMap : pb::IMessage { + public sealed partial class TestRequiredMap : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -18285,14 +18615,19 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - foo_.AddEntriesFrom(input, _map_foo_codec); + foo_.AddEntriesFrom(ref input, _map_foo_codec); break; } } @@ -18303,7 +18638,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestRequiredMap message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -18431,11 +18766,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { RequiredInt32 = input.ReadInt32(); @@ -18452,7 +18792,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestPackedTypes : pb::IMessage { + public sealed partial class TestPackedTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -18765,80 +19105,85 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 722: case 720: { - packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec); + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); break; } case 730: case 728: { - packedInt64_.AddEntriesFrom(input, _repeated_packedInt64_codec); + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); break; } case 738: case 736: { - packedUint32_.AddEntriesFrom(input, _repeated_packedUint32_codec); + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); break; } case 746: case 744: { - packedUint64_.AddEntriesFrom(input, _repeated_packedUint64_codec); + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); break; } case 754: case 752: { - packedSint32_.AddEntriesFrom(input, _repeated_packedSint32_codec); + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); break; } case 762: case 760: { - packedSint64_.AddEntriesFrom(input, _repeated_packedSint64_codec); + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); break; } case 770: case 773: { - packedFixed32_.AddEntriesFrom(input, _repeated_packedFixed32_codec); + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); break; } case 778: case 777: { - packedFixed64_.AddEntriesFrom(input, _repeated_packedFixed64_codec); + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); break; } case 786: case 789: { - packedSfixed32_.AddEntriesFrom(input, _repeated_packedSfixed32_codec); + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); break; } case 794: case 793: { - packedSfixed64_.AddEntriesFrom(input, _repeated_packedSfixed64_codec); + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); break; } case 802: case 805: { - packedFloat_.AddEntriesFrom(input, _repeated_packedFloat_codec); + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); break; } case 810: case 809: { - packedDouble_.AddEntriesFrom(input, _repeated_packedDouble_codec); + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); break; } case 818: case 816: { - packedBool_.AddEntriesFrom(input, _repeated_packedBool_codec); + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); break; } case 826: case 824: { - packedEnum_.AddEntriesFrom(input, _repeated_packedEnum_codec); + packedEnum_.AddEntriesFrom(ref input, _repeated_packedEnum_codec); break; } } @@ -18851,7 +19196,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// A message with the same fields as TestPackedTypes, but without packing. Used /// to test packed <-> unpacked wire compatibility. /// - public sealed partial class TestUnpackedTypes : pb::IMessage { + public sealed partial class TestUnpackedTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -19164,80 +19509,85 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 722: case 720: { - unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec); + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); break; } case 730: case 728: { - unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec); + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); break; } case 738: case 736: { - unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec); + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); break; } case 746: case 744: { - unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec); + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); break; } case 754: case 752: { - unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec); + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); break; } case 762: case 760: { - unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec); + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); break; } case 770: case 773: { - unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec); + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); break; } case 778: case 777: { - unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec); + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); break; } case 786: case 789: { - unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec); + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); break; } case 794: case 793: { - unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec); + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); break; } case 802: case 805: { - unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec); + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); break; } case 810: case 809: { - unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec); + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); break; } case 818: case 816: { - unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec); + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); break; } case 826: case 824: { - unpackedEnum_.AddEntriesFrom(input, _repeated_unpackedEnum_codec); + unpackedEnum_.AddEntriesFrom(ref input, _repeated_unpackedEnum_codec); break; } } @@ -19246,7 +19596,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestPackedExtensions : pb::IExtendableMessage { + public sealed partial class TestPackedExtensions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -19351,12 +19701,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; } @@ -19387,7 +19742,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestUnpackedExtensions : pb::IExtendableMessage { + public sealed partial class TestUnpackedExtensions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -19492,12 +19847,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; } @@ -19533,7 +19893,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// a set of extensions to TestAllExtensions dynamically, based on the fields /// of this message type. /// - public sealed partial class TestDynamicExtensions : pb::IMessage { + public sealed partial class TestDynamicExtensions : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDynamicExtensions()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -19841,11 +20201,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 16005: { ScalarExtension = input.ReadFixed32(); @@ -19874,12 +20239,12 @@ namespace Google.Protobuf.TestProtos.Proto2 { break; } case 16042: { - repeatedExtension_.AddEntriesFrom(input, _repeated_repeatedExtension_codec); + repeatedExtension_.AddEntriesFrom(ref input, _repeated_repeatedExtension_codec); break; } case 16050: case 16048: { - packedExtension_.AddEntriesFrom(input, _repeated_packedExtension_codec); + packedExtension_.AddEntriesFrom(ref input, _repeated_packedExtension_codec); break; } } @@ -19896,7 +20261,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { [pbr::OriginalName("DYNAMIC_BAZ")] DynamicBaz = 2202, } - public sealed partial class DynamicMessageType : pb::IMessage { + public sealed partial class DynamicMessageType : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DynamicMessageType()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -20024,11 +20389,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 16800: { DynamicField = input.ReadInt32(); @@ -20045,7 +20415,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { + public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -20244,40 +20614,45 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 98: case 101: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); break; } case 106: case 104: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } case 16370: case 16369: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); break; } case 16378: case 16376: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); break; } case 2097138: case 2097141: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); break; } case 2097146: case 2097144: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); break; } } @@ -20290,7 +20665,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Test that if an optional or required message/group field appears multiple /// times in the input, they need to be merged. /// - public sealed partial class TestParsingMerge : pb::IExtendableMessage { + public sealed partial class TestParsingMerge : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestParsingMerge()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -20539,12 +20914,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 10: { @@ -20562,7 +20942,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { break; } case 26: { - repeatedAllTypes_.AddEntriesFrom(input, _repeated_repeatedAllTypes_codec); + repeatedAllTypes_.AddEntriesFrom(ref input, _repeated_repeatedAllTypes_codec); break; } case 83: { @@ -20573,7 +20953,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { break; } case 163: { - repeatedGroup_.AddEntriesFrom(input, _repeated_repeatedGroup_codec); + repeatedGroup_.AddEntriesFrom(ref input, _repeated_repeatedGroup_codec); break; } } @@ -20613,7 +20993,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Repeated fields in RepeatedFieldsGenerator are expected to be merged into /// the corresponding required/optional fields in TestParsingMerge. /// - public sealed partial class RepeatedFieldsGenerator : pb::IMessage { + public sealed partial class RepeatedFieldsGenerator : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedFieldsGenerator()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -20814,38 +21194,43 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - field1_.AddEntriesFrom(input, _repeated_field1_codec); + field1_.AddEntriesFrom(ref input, _repeated_field1_codec); break; } case 18: { - field2_.AddEntriesFrom(input, _repeated_field2_codec); + field2_.AddEntriesFrom(ref input, _repeated_field2_codec); break; } case 26: { - field3_.AddEntriesFrom(input, _repeated_field3_codec); + field3_.AddEntriesFrom(ref input, _repeated_field3_codec); break; } case 83: { - group1_.AddEntriesFrom(input, _repeated_group1_codec); + group1_.AddEntriesFrom(ref input, _repeated_group1_codec); break; } case 163: { - group2_.AddEntriesFrom(input, _repeated_group2_codec); + group2_.AddEntriesFrom(ref input, _repeated_group2_codec); break; } case 8002: { - ext1_.AddEntriesFrom(input, _repeated_ext1_codec); + ext1_.AddEntriesFrom(ref input, _repeated_ext1_codec); break; } case 8010: { - ext2_.AddEntriesFrom(input, _repeated_ext2_codec); + ext2_.AddEntriesFrom(ref input, _repeated_ext2_codec); break; } } @@ -20856,7 +21241,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the RepeatedFieldsGenerator message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Group1 : pb::IMessage { + public sealed partial class Group1 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Group1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -20982,13 +21367,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 84: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 90: { if (!HasField1) { @@ -21003,7 +21393,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class Group2 : pb::IMessage { + public sealed partial class Group2 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Group2()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21129,13 +21519,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 164: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 170: { if (!HasField1) { @@ -21155,7 +21550,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21281,13 +21676,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 84: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 90: { if (!HasOptionalGroupAllTypes) { @@ -21302,7 +21702,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class RepeatedGroup : pb::IMessage { + public sealed partial class RepeatedGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedGroup()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21428,13 +21828,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 164: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 170: { if (!HasRepeatedGroupAllTypes) { @@ -21465,7 +21870,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestCommentInjectionMessage : pb::IMessage { + public sealed partial class TestCommentInjectionMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21593,11 +21998,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { A = input.ReadString(); @@ -21612,7 +22022,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// /// Test that RPC services work. /// - public sealed partial class FooRequest : pb::IMessage { + public sealed partial class FooRequest : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21701,11 +22111,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -21713,7 +22128,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class FooResponse : pb::IMessage { + public sealed partial class FooResponse : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21802,11 +22217,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -21814,7 +22234,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class FooClientMessage : pb::IMessage { + public sealed partial class FooClientMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21903,11 +22323,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -21915,7 +22340,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class FooServerMessage : pb::IMessage { + public sealed partial class FooServerMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -22004,11 +22429,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -22016,7 +22446,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class BarRequest : pb::IMessage { + public sealed partial class BarRequest : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -22105,11 +22535,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -22117,7 +22552,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class BarResponse : pb::IMessage { + public sealed partial class BarResponse : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -22206,11 +22641,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -22218,7 +22658,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestJsonName : pb::IMessage { + public sealed partial class TestJsonName : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonName()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -22531,11 +22971,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FieldName1 = input.ReadInt32(); @@ -22567,7 +23012,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestHugeFieldNumbers : pb::IExtendableMessage { + public sealed partial class TestHugeFieldNumbers : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestHugeFieldNumbers()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -23164,12 +23609,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 4294960000: { @@ -23182,12 +23632,12 @@ namespace Google.Protobuf.TestProtos.Proto2 { } case 4294960018: case 4294960016: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } case 4294960026: case 4294960024: { - packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec); + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); break; } case 4294960032: { @@ -23217,7 +23667,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { break; } case 4294960082: { - stringStringMap_.AddEntriesFrom(input, _map_stringStringMap_codec); + stringStringMap_.AddEntriesFrom(ref input, _map_stringStringMap_codec); break; } case 4294960088: { @@ -23271,7 +23721,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { /// Container for nested types declared in the TestHugeFieldNumbers message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -23399,13 +23849,18 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 4294960068: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 4294960072: { GroupA = input.ReadInt32(); @@ -23422,7 +23877,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } - public sealed partial class TestExtensionInsideTable : pb::IExtendableMessage { + public sealed partial class TestExtensionInsideTable : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionInsideTable()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -23862,12 +24317,17 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 8: { diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs index cb5edf7547..f78881788a 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs @@ -257,7 +257,7 @@ namespace UnitTest.Issues.TestProtos { /// A test message with custom options at all possible locations (and also some /// regular options, to make sure they interact nicely). /// - public sealed partial class TestMessageWithCustomOptions : pb::IMessage { + public sealed partial class TestMessageWithCustomOptions : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMessageWithCustomOptions()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -422,11 +422,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Field1 = input.ReadString(); @@ -459,7 +464,7 @@ namespace UnitTest.Issues.TestProtos { /// A test RPC service with custom options at all possible locations (and also /// some regular options, to make sure they interact nicely). /// - public sealed partial class CustomOptionFooRequest : pb::IMessage { + public sealed partial class CustomOptionFooRequest : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -548,11 +553,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -560,7 +570,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class CustomOptionFooResponse : pb::IMessage { + public sealed partial class CustomOptionFooResponse : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -649,11 +659,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -661,7 +676,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class CustomOptionFooClientMessage : pb::IMessage { + public sealed partial class CustomOptionFooClientMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooClientMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -750,11 +765,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -762,7 +782,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class CustomOptionFooServerMessage : pb::IMessage { + public sealed partial class CustomOptionFooServerMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooServerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -851,11 +871,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -863,7 +888,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class DummyMessageContainingEnum : pb::IMessage { + public sealed partial class DummyMessageContainingEnum : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DummyMessageContainingEnum()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -952,11 +977,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -977,7 +1007,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class DummyMessageInvalidAsOptionType : pb::IMessage { + public sealed partial class DummyMessageInvalidAsOptionType : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DummyMessageInvalidAsOptionType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1066,11 +1096,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -1078,7 +1113,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class CustomOptionMinIntegerValues : pb::IMessage { + public sealed partial class CustomOptionMinIntegerValues : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionMinIntegerValues()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1167,11 +1202,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -1179,7 +1219,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class CustomOptionMaxIntegerValues : pb::IMessage { + public sealed partial class CustomOptionMaxIntegerValues : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionMaxIntegerValues()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1268,11 +1308,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -1280,7 +1325,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class CustomOptionOtherValues : pb::IMessage { + public sealed partial class CustomOptionOtherValues : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionOtherValues()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1369,11 +1414,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -1381,7 +1431,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class SettingRealsFromPositiveInts : pb::IMessage { + public sealed partial class SettingRealsFromPositiveInts : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SettingRealsFromPositiveInts()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1470,11 +1520,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -1482,7 +1537,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class SettingRealsFromNegativeInts : pb::IMessage { + public sealed partial class SettingRealsFromNegativeInts : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SettingRealsFromNegativeInts()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1571,11 +1626,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -1583,7 +1643,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class ComplexOptionType1 : pb::IMessage { + public sealed partial class ComplexOptionType1 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1760,11 +1820,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Foo = input.ReadInt32(); @@ -1780,7 +1845,7 @@ namespace UnitTest.Issues.TestProtos { } case 34: case 32: { - foo4_.AddEntriesFrom(input, _repeated_foo4_codec); + foo4_.AddEntriesFrom(ref input, _repeated_foo4_codec); break; } } @@ -1789,7 +1854,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class ComplexOptionType2 : pb::IMessage { + public sealed partial class ComplexOptionType2 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType2()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1972,11 +2037,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (bar_ == null) { @@ -1997,7 +2067,7 @@ namespace UnitTest.Issues.TestProtos { break; } case 34: { - barney_.AddEntriesFrom(input, _repeated_barney_codec); + barney_.AddEntriesFrom(ref input, _repeated_barney_codec); break; } } @@ -2008,7 +2078,7 @@ namespace UnitTest.Issues.TestProtos { /// Container for nested types declared in the ComplexOptionType2 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class ComplexOptionType4 : pb::IMessage { + public sealed partial class ComplexOptionType4 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType4()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2121,11 +2191,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Waldo = input.ReadInt32(); @@ -2151,7 +2226,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class ComplexOptionType3 : pb::IMessage { + public sealed partial class ComplexOptionType3 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType3()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2264,11 +2339,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Qux = input.ReadInt32(); @@ -2283,7 +2363,7 @@ namespace UnitTest.Issues.TestProtos { /// /// Note that we try various different ways of naming the same extension. /// - public sealed partial class VariousComplexOptions : pb::IMessage { + public sealed partial class VariousComplexOptions : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new VariousComplexOptions()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2372,11 +2452,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -2387,7 +2472,7 @@ namespace UnitTest.Issues.TestProtos { /// /// A helper type used to test aggregate option parsing /// - public sealed partial class Aggregate : pb::IMessage { + public sealed partial class Aggregate : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Aggregate()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2554,11 +2639,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { I = input.ReadInt32(); @@ -2581,7 +2671,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class AggregateMessage : pb::IMessage { + public sealed partial class AggregateMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AggregateMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2694,11 +2784,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Fieldname = input.ReadInt32(); @@ -2713,7 +2808,7 @@ namespace UnitTest.Issues.TestProtos { /// /// Test custom options for nested type. /// - public sealed partial class NestedOptionType : pb::IMessage { + public sealed partial class NestedOptionType : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOptionType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2802,11 +2897,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -2821,7 +2921,7 @@ namespace UnitTest.Issues.TestProtos { [pbr::OriginalName("NESTED_ENUM_VALUE")] Value = 1, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2934,11 +3034,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { NestedField = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs index d5f8589315..64e5c7a6fa 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs @@ -59,7 +59,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { #endregion #region Messages - public sealed partial class ImportMessage : pb::IMessage { + public sealed partial class ImportMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -187,11 +187,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { D = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs index 19a1a34634..c64a5592f3 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs @@ -50,7 +50,7 @@ namespace Google.Protobuf.TestProtos { #endregion #region Messages - public sealed partial class ImportMessage : pb::IMessage { + public sealed partial class ImportMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -163,11 +163,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { D = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs index 77f2121760..4a1409c1bb 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs @@ -37,7 +37,7 @@ namespace Google.Protobuf.TestProtos.Proto2 { } #region Messages - public sealed partial class PublicImportMessage : pb::IMessage { + public sealed partial class PublicImportMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -165,11 +165,16 @@ namespace Google.Protobuf.TestProtos.Proto2 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { E = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs index a455655469..19542bdd9b 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs @@ -38,7 +38,7 @@ namespace Google.Protobuf.TestProtos { } #region Messages - public sealed partial class PublicImportMessage : pb::IMessage { + public sealed partial class PublicImportMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -151,11 +151,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { E = input.ReadInt32(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs index 6b816f739b..23bee639ff 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs @@ -37,7 +37,7 @@ namespace UnitTest.Issues.TestProtos { } #region Messages - public sealed partial class Foo : pb::IMessage { + public sealed partial class Foo : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Foo()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -126,11 +126,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs index a8a73f6cb6..d4bc74df65 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs @@ -39,7 +39,7 @@ namespace UnitTest.Issues.TestProtos { } #region Messages - public sealed partial class Bar : pb::IMessage { + public sealed partial class Bar : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Bar()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -155,11 +155,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (foo_ == null) { diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs index f3f40c6a70..786cfdfbd4 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs @@ -88,7 +88,7 @@ namespace UnitTest.Issues.TestProtos { /// Issue 307: when generating doubly-nested types, any references /// should be of the form A.Types.B.Types.C. /// - public sealed partial class Issue307 : pb::IMessage { + public sealed partial class Issue307 : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Issue307()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -177,11 +177,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -191,7 +196,7 @@ namespace UnitTest.Issues.TestProtos { /// Container for nested types declared in the Issue307 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedOnce : pb::IMessage { + public sealed partial class NestedOnce : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOnce()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -280,11 +285,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -294,7 +304,7 @@ namespace UnitTest.Issues.TestProtos { /// Container for nested types declared in the NestedOnce message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedTwice : pb::IMessage { + public sealed partial class NestedTwice : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTwice()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -383,11 +393,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -405,7 +420,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class NegativeEnumMessage : pb::IMessage { + public sealed partial class NegativeEnumMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NegativeEnumMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -550,11 +565,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Value = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum(); @@ -562,12 +582,12 @@ namespace UnitTest.Issues.TestProtos { } case 18: case 16: { - values_.AddEntriesFrom(input, _repeated_values_codec); + values_.AddEntriesFrom(ref input, _repeated_values_codec); break; } case 26: case 24: { - packedValues_.AddEntriesFrom(input, _repeated_packedValues_codec); + packedValues_.AddEntriesFrom(ref input, _repeated_packedValues_codec); break; } } @@ -576,7 +596,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class DeprecatedChild : pb::IMessage { + public sealed partial class DeprecatedChild : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedChild()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -665,11 +685,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -677,7 +702,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class DeprecatedFieldsMessage : pb::IMessage { + public sealed partial class DeprecatedFieldsMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedFieldsMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -895,11 +920,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { PrimitiveValue = input.ReadInt32(); @@ -907,7 +937,7 @@ namespace UnitTest.Issues.TestProtos { } case 18: case 16: { - primitiveArray_.AddEntriesFrom(input, _repeated_primitiveArray_codec); + primitiveArray_.AddEntriesFrom(ref input, _repeated_primitiveArray_codec); break; } case 26: { @@ -918,7 +948,7 @@ namespace UnitTest.Issues.TestProtos { break; } case 34: { - messageArray_.AddEntriesFrom(input, _repeated_messageArray_codec); + messageArray_.AddEntriesFrom(ref input, _repeated_messageArray_codec); break; } case 40: { @@ -927,7 +957,7 @@ namespace UnitTest.Issues.TestProtos { } case 50: case 48: { - enumArray_.AddEntriesFrom(input, _repeated_enumArray_codec); + enumArray_.AddEntriesFrom(ref input, _repeated_enumArray_codec); break; } } @@ -939,7 +969,7 @@ namespace UnitTest.Issues.TestProtos { /// /// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 /// - public sealed partial class ItemField : pb::IMessage { + public sealed partial class ItemField : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ItemField()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1052,11 +1082,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Item = input.ReadInt32(); @@ -1068,7 +1103,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class ReservedNames : pb::IMessage { + public sealed partial class ReservedNames : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedNames()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1205,11 +1240,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Types_ = input.ReadInt32(); @@ -1230,7 +1270,7 @@ namespace UnitTest.Issues.TestProtos { /// /// Force a nested type called Types /// - public sealed partial class SomeNestedType : pb::IMessage { + public sealed partial class SomeNestedType : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SomeNestedType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1319,11 +1359,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -1348,7 +1393,7 @@ namespace UnitTest.Issues.TestProtos { /// Alternatively, consider just adding this to /// unittest_proto3.proto if multiple platforms want it. /// - public sealed partial class TestJsonFieldOrdering : pb::IMessage { + public sealed partial class TestJsonFieldOrdering : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonFieldOrdering()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1643,11 +1688,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { PlainString = input.ReadString(); @@ -1679,7 +1729,7 @@ namespace UnitTest.Issues.TestProtos { } - public sealed partial class TestJsonName : pb::IMessage { + public sealed partial class TestJsonName : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonName()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1843,11 +1893,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -1872,7 +1927,7 @@ namespace UnitTest.Issues.TestProtos { /// oneof case, which is itself a message type, the submessages should /// be merged. /// - public sealed partial class OneofMerging : pb::IMessage { + public sealed partial class OneofMerging : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofMerging()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2043,11 +2098,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Text = input.ReadString(); @@ -2070,7 +2130,7 @@ namespace UnitTest.Issues.TestProtos { /// Container for nested types declared in the OneofMerging message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Nested : pb::IMessage { + public sealed partial class Nested : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Nested()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2207,11 +2267,16 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); 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 3f01e38bb9..7fae655f7e 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs @@ -254,7 +254,7 @@ namespace Google.Protobuf.TestProtos { /// This proto includes every type of field in both singular and repeated /// forms. /// - public sealed partial class TestAllTypes : pb::IMessage { + public sealed partial class TestAllTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1383,11 +1383,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { SingleInt32 = input.ReadInt32(); @@ -1491,106 +1496,106 @@ namespace Google.Protobuf.TestProtos { } case 250: case 248: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } case 258: case 256: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); break; } case 266: case 264: { - repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); break; } case 274: case 272: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); break; } case 282: case 280: { - repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); break; } case 290: case 288: { - repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); break; } case 298: case 301: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); break; } case 306: case 305: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); break; } case 314: case 317: { - repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); break; } case 322: case 321: { - repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); break; } case 330: case 333: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); break; } case 338: case 337: { - repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); break; } case 346: case 344: { - repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); break; } case 354: { - repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); break; } case 362: { - repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); break; } case 386: { - repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); break; } case 394: { - repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); break; } case 402: { - repeatedImportMessage_.AddEntriesFrom(input, _repeated_repeatedImportMessage_codec); + repeatedImportMessage_.AddEntriesFrom(ref input, _repeated_repeatedImportMessage_codec); break; } case 410: case 408: { - repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); break; } case 418: case 416: { - repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); break; } case 426: case 424: { - repeatedImportEnum_.AddEntriesFrom(input, _repeated_repeatedImportEnum_codec); + repeatedImportEnum_.AddEntriesFrom(ref input, _repeated_repeatedImportEnum_codec); break; } case 434: { - repeatedPublicImportMessage_.AddEntriesFrom(input, _repeated_repeatedPublicImportMessage_codec); + repeatedPublicImportMessage_.AddEntriesFrom(ref input, _repeated_repeatedPublicImportMessage_codec); break; } case 888: { @@ -1633,7 +1638,7 @@ namespace Google.Protobuf.TestProtos { [pbr::OriginalName("NEG")] Neg = -1, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1751,11 +1756,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Bb = input.ReadInt32(); @@ -1775,7 +1785,7 @@ namespace Google.Protobuf.TestProtos { /// /// This proto includes a recursively nested message. /// - public sealed partial class NestedTestAllTypes : pb::IMessage { + public sealed partial class NestedTestAllTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1934,11 +1944,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (child_ == null) { @@ -1955,7 +1970,7 @@ namespace Google.Protobuf.TestProtos { break; } case 26: { - repeatedChild_.AddEntriesFrom(input, _repeated_repeatedChild_codec); + repeatedChild_.AddEntriesFrom(ref input, _repeated_repeatedChild_codec); break; } } @@ -1964,7 +1979,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestDeprecatedFields : pb::IMessage { + public sealed partial class TestDeprecatedFields : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2078,11 +2093,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { DeprecatedInt32 = input.ReadInt32(); @@ -2098,7 +2118,7 @@ namespace Google.Protobuf.TestProtos { /// Define these after TestAllTypes to make sure the compiler can handle /// that. /// - public sealed partial class ForeignMessage : pb::IMessage { + public sealed partial class ForeignMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2211,11 +2231,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { C = input.ReadInt32(); @@ -2227,7 +2252,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestReservedFields : pb::IMessage { + public sealed partial class TestReservedFields : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2316,11 +2341,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -2331,7 +2361,7 @@ namespace Google.Protobuf.TestProtos { /// /// Test that we can use NestedMessage from outside TestAllTypes. /// - public sealed partial class TestForeignNested : pb::IMessage { + public sealed partial class TestForeignNested : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2447,11 +2477,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (foreignNested_ == null) { @@ -2469,7 +2504,7 @@ namespace Google.Protobuf.TestProtos { /// /// Test that really large tag numbers don't break anything. /// - public sealed partial class TestReallyLargeTagNumber : pb::IMessage { + public sealed partial class TestReallyLargeTagNumber : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2610,11 +2645,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -2630,7 +2670,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestRecursiveMessage : pb::IMessage { + public sealed partial class TestRecursiveMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2770,11 +2810,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (a_ == null) { @@ -2796,7 +2841,7 @@ namespace Google.Protobuf.TestProtos { /// /// Test that mutual recursion works. /// - public sealed partial class TestMutualRecursionA : pb::IMessage { + public sealed partial class TestMutualRecursionA : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2912,11 +2957,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (bb_ == null) { @@ -2931,7 +2981,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestMutualRecursionB : pb::IMessage { + public sealed partial class TestMutualRecursionB : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3071,11 +3121,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (a_ == null) { @@ -3094,7 +3149,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestEnumAllowAlias : pb::IMessage { + public sealed partial class TestEnumAllowAlias : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEnumAllowAlias()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3207,11 +3262,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Value = (global::Google.Protobuf.TestProtos.TestEnumWithDupValue) input.ReadEnum(); @@ -3227,7 +3287,7 @@ namespace Google.Protobuf.TestProtos { /// Test message with CamelCase field names. This violates Protocol Buffer /// standard style. /// - public sealed partial class TestCamelCaseFieldNames : pb::IMessage { + public sealed partial class TestCamelCaseFieldNames : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3479,11 +3539,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { PrimitiveField = input.ReadInt32(); @@ -3506,20 +3571,20 @@ namespace Google.Protobuf.TestProtos { } case 58: case 56: { - repeatedPrimitiveField_.AddEntriesFrom(input, _repeated_repeatedPrimitiveField_codec); + repeatedPrimitiveField_.AddEntriesFrom(ref input, _repeated_repeatedPrimitiveField_codec); break; } case 66: { - repeatedStringField_.AddEntriesFrom(input, _repeated_repeatedStringField_codec); + repeatedStringField_.AddEntriesFrom(ref input, _repeated_repeatedStringField_codec); break; } case 74: case 72: { - repeatedEnumField_.AddEntriesFrom(input, _repeated_repeatedEnumField_codec); + repeatedEnumField_.AddEntriesFrom(ref input, _repeated_repeatedEnumField_codec); break; } case 82: { - repeatedMessageField_.AddEntriesFrom(input, _repeated_repeatedMessageField_codec); + repeatedMessageField_.AddEntriesFrom(ref input, _repeated_repeatedMessageField_codec); break; } } @@ -3532,7 +3597,7 @@ namespace Google.Protobuf.TestProtos { /// We list fields out of order, to ensure that we're using field number and not /// field index to determine serialization order. /// - public sealed partial class TestFieldOrderings : pb::IMessage { + public sealed partial class TestFieldOrderings : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3720,11 +3785,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { MyInt = input.ReadInt64(); @@ -3753,7 +3823,7 @@ namespace Google.Protobuf.TestProtos { /// Container for nested types declared in the TestFieldOrderings message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3895,11 +3965,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Bb = input.ReadInt32(); @@ -3920,7 +3995,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class SparseEnumMessage : pb::IMessage { + public sealed partial class SparseEnumMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4033,11 +4108,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { SparseEnum = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum(); @@ -4052,7 +4132,7 @@ namespace Google.Protobuf.TestProtos { /// /// Test String and Bytes: string is for valid UTF-8 strings /// - public sealed partial class OneString : pb::IMessage { + public sealed partial class OneString : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4165,11 +4245,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Data = input.ReadString(); @@ -4181,7 +4266,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class MoreString : pb::IMessage { + public sealed partial class MoreString : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4286,14 +4371,19 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - data_.AddEntriesFrom(input, _repeated_data_codec); + data_.AddEntriesFrom(ref input, _repeated_data_codec); break; } } @@ -4302,7 +4392,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class OneBytes : pb::IMessage { + public sealed partial class OneBytes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4415,11 +4505,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Data = input.ReadBytes(); @@ -4431,7 +4526,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class MoreBytes : pb::IMessage { + public sealed partial class MoreBytes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4544,11 +4639,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Data = input.ReadBytes(); @@ -4563,7 +4663,7 @@ namespace Google.Protobuf.TestProtos { /// /// Test int32, uint32, int64, uint64, and bool are all compatible /// - public sealed partial class Int32Message : pb::IMessage { + public sealed partial class Int32Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4676,11 +4776,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadInt32(); @@ -4692,7 +4797,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class Uint32Message : pb::IMessage { + public sealed partial class Uint32Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4805,11 +4910,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadUInt32(); @@ -4821,7 +4931,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class Int64Message : pb::IMessage { + public sealed partial class Int64Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4934,11 +5044,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadInt64(); @@ -4950,7 +5065,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class Uint64Message : pb::IMessage { + public sealed partial class Uint64Message : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5063,11 +5178,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadUInt64(); @@ -5079,7 +5199,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class BoolMessage : pb::IMessage { + public sealed partial class BoolMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5192,11 +5312,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadBool(); @@ -5211,7 +5336,7 @@ namespace Google.Protobuf.TestProtos { /// /// Test oneofs. /// - public sealed partial class TestOneof : pb::IMessage { + public sealed partial class TestOneof : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5409,11 +5534,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FooInt = input.ReadInt32(); @@ -5438,7 +5568,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestPackedTypes : pb::IMessage { + public sealed partial class TestPackedTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5751,80 +5881,85 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 722: case 720: { - packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec); + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); break; } case 730: case 728: { - packedInt64_.AddEntriesFrom(input, _repeated_packedInt64_codec); + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); break; } case 738: case 736: { - packedUint32_.AddEntriesFrom(input, _repeated_packedUint32_codec); + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); break; } case 746: case 744: { - packedUint64_.AddEntriesFrom(input, _repeated_packedUint64_codec); + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); break; } case 754: case 752: { - packedSint32_.AddEntriesFrom(input, _repeated_packedSint32_codec); + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); break; } case 762: case 760: { - packedSint64_.AddEntriesFrom(input, _repeated_packedSint64_codec); + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); break; } case 770: case 773: { - packedFixed32_.AddEntriesFrom(input, _repeated_packedFixed32_codec); + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); break; } case 778: case 777: { - packedFixed64_.AddEntriesFrom(input, _repeated_packedFixed64_codec); + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); break; } case 786: case 789: { - packedSfixed32_.AddEntriesFrom(input, _repeated_packedSfixed32_codec); + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); break; } case 794: case 793: { - packedSfixed64_.AddEntriesFrom(input, _repeated_packedSfixed64_codec); + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); break; } case 802: case 805: { - packedFloat_.AddEntriesFrom(input, _repeated_packedFloat_codec); + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); break; } case 810: case 809: { - packedDouble_.AddEntriesFrom(input, _repeated_packedDouble_codec); + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); break; } case 818: case 816: { - packedBool_.AddEntriesFrom(input, _repeated_packedBool_codec); + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); break; } case 826: case 824: { - packedEnum_.AddEntriesFrom(input, _repeated_packedEnum_codec); + packedEnum_.AddEntriesFrom(ref input, _repeated_packedEnum_codec); break; } } @@ -5837,7 +5972,7 @@ namespace Google.Protobuf.TestProtos { /// A message with the same fields as TestPackedTypes, but without packing. Used /// to test packed <-> unpacked wire compatibility. /// - public sealed partial class TestUnpackedTypes : pb::IMessage { + public sealed partial class TestUnpackedTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6150,80 +6285,85 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 722: case 720: { - unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec); + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); break; } case 730: case 728: { - unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec); + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); break; } case 738: case 736: { - unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec); + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); break; } case 746: case 744: { - unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec); + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); break; } case 754: case 752: { - unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec); + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); break; } case 762: case 760: { - unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec); + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); break; } case 770: case 773: { - unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec); + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); break; } case 778: case 777: { - unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec); + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); break; } case 786: case 789: { - unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec); + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); break; } case 794: case 793: { - unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec); + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); break; } case 802: case 805: { - unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec); + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); break; } case 810: case 809: { - unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec); + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); break; } case 818: case 816: { - unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec); + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); break; } case 826: case 824: { - unpackedEnum_.AddEntriesFrom(input, _repeated_unpackedEnum_codec); + unpackedEnum_.AddEntriesFrom(ref input, _repeated_unpackedEnum_codec); break; } } @@ -6232,7 +6372,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { + public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6431,40 +6571,45 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 98: case 101: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); break; } case 106: case 104: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); break; } case 16370: case 16369: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); break; } case 16378: case 16376: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); break; } case 2097138: case 2097141: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); break; } case 2097146: case 2097144: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); break; } } @@ -6473,7 +6618,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestCommentInjectionMessage : pb::IMessage { + public sealed partial class TestCommentInjectionMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6589,11 +6734,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { A = input.ReadString(); @@ -6608,7 +6758,7 @@ namespace Google.Protobuf.TestProtos { /// /// Test that RPC services work. /// - public sealed partial class FooRequest : pb::IMessage { + public sealed partial class FooRequest : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6697,11 +6847,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -6709,7 +6864,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class FooResponse : pb::IMessage { + public sealed partial class FooResponse : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6798,11 +6953,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -6810,7 +6970,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class FooClientMessage : pb::IMessage { + public sealed partial class FooClientMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6899,11 +7059,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -6911,7 +7076,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class FooServerMessage : pb::IMessage { + public sealed partial class FooServerMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7000,11 +7165,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -7012,7 +7182,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class BarRequest : pb::IMessage { + public sealed partial class BarRequest : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7101,11 +7271,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -7113,7 +7288,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class BarResponse : pb::IMessage { + public sealed partial class BarResponse : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7202,11 +7377,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -7214,7 +7394,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class TestEmptyMessage : pb::IMessage { + public sealed partial class TestEmptyMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEmptyMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7303,11 +7483,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } @@ -7318,7 +7503,7 @@ namespace Google.Protobuf.TestProtos { /// /// This is a leading comment /// - public sealed partial class CommentMessage : pb::IMessage { + public sealed partial class CommentMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CommentMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7434,11 +7619,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Text = input.ReadString(); @@ -7465,7 +7655,7 @@ namespace Google.Protobuf.TestProtos { /// /// Leading nested message comment /// - public sealed partial class NestedCommentMessage : pb::IMessage { + public sealed partial class NestedCommentMessage : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedCommentMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7581,11 +7771,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { NestedText = input.ReadString(); diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs index 90b338436b..1435027026 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs @@ -179,7 +179,7 @@ namespace Google.Protobuf.TestProtos { /// Each wrapper type is included separately, as languages /// map handle different wrappers in different ways. /// - public sealed partial class TestWellKnownTypes : pb::IMessage { + public sealed partial class TestWellKnownTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -784,11 +784,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { if (anyField_ == null) { @@ -854,63 +859,63 @@ namespace Google.Protobuf.TestProtos { break; } case 82: { - double? value = _single_doubleField_codec.Read(input); + double? value = _single_doubleField_codec.Read(ref input); if (doubleField_ == null || value != 0D) { DoubleField = value; } break; } case 90: { - float? value = _single_floatField_codec.Read(input); + float? value = _single_floatField_codec.Read(ref input); if (floatField_ == null || value != 0F) { FloatField = value; } break; } case 98: { - long? value = _single_int64Field_codec.Read(input); + long? value = _single_int64Field_codec.Read(ref input); if (int64Field_ == null || value != 0L) { Int64Field = value; } break; } case 106: { - ulong? value = _single_uint64Field_codec.Read(input); + ulong? value = _single_uint64Field_codec.Read(ref input); if (uint64Field_ == null || value != 0UL) { Uint64Field = value; } break; } case 114: { - int? value = _single_int32Field_codec.Read(input); + int? value = _single_int32Field_codec.Read(ref input); if (int32Field_ == null || value != 0) { Int32Field = value; } break; } case 122: { - uint? value = _single_uint32Field_codec.Read(input); + uint? value = _single_uint32Field_codec.Read(ref input); if (uint32Field_ == null || value != 0) { Uint32Field = value; } break; } case 130: { - bool? value = _single_boolField_codec.Read(input); + bool? value = _single_boolField_codec.Read(ref input); if (boolField_ == null || value != false) { BoolField = value; } break; } case 138: { - string value = _single_stringField_codec.Read(input); + string value = _single_stringField_codec.Read(ref input); if (stringField_ == null || value != "") { StringField = value; } break; } case 146: { - pb::ByteString value = _single_bytesField_codec.Read(input); + pb::ByteString value = _single_bytesField_codec.Read(ref input); if (bytesField_ == null || value != pb::ByteString.Empty) { BytesField = value; } @@ -932,7 +937,7 @@ namespace Google.Protobuf.TestProtos { /// /// A repeated field for each well-known type. /// - public sealed partial class RepeatedWellKnownTypes : pb::IMessage { + public sealed partial class RepeatedWellKnownTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1312,82 +1317,87 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - anyField_.AddEntriesFrom(input, _repeated_anyField_codec); + anyField_.AddEntriesFrom(ref input, _repeated_anyField_codec); break; } case 18: { - apiField_.AddEntriesFrom(input, _repeated_apiField_codec); + apiField_.AddEntriesFrom(ref input, _repeated_apiField_codec); break; } case 26: { - durationField_.AddEntriesFrom(input, _repeated_durationField_codec); + durationField_.AddEntriesFrom(ref input, _repeated_durationField_codec); break; } case 34: { - emptyField_.AddEntriesFrom(input, _repeated_emptyField_codec); + emptyField_.AddEntriesFrom(ref input, _repeated_emptyField_codec); break; } case 42: { - fieldMaskField_.AddEntriesFrom(input, _repeated_fieldMaskField_codec); + fieldMaskField_.AddEntriesFrom(ref input, _repeated_fieldMaskField_codec); break; } case 50: { - sourceContextField_.AddEntriesFrom(input, _repeated_sourceContextField_codec); + sourceContextField_.AddEntriesFrom(ref input, _repeated_sourceContextField_codec); break; } case 58: { - structField_.AddEntriesFrom(input, _repeated_structField_codec); + structField_.AddEntriesFrom(ref input, _repeated_structField_codec); break; } case 66: { - timestampField_.AddEntriesFrom(input, _repeated_timestampField_codec); + timestampField_.AddEntriesFrom(ref input, _repeated_timestampField_codec); break; } case 74: { - typeField_.AddEntriesFrom(input, _repeated_typeField_codec); + typeField_.AddEntriesFrom(ref input, _repeated_typeField_codec); break; } case 82: { - doubleField_.AddEntriesFrom(input, _repeated_doubleField_codec); + doubleField_.AddEntriesFrom(ref input, _repeated_doubleField_codec); break; } case 90: { - floatField_.AddEntriesFrom(input, _repeated_floatField_codec); + floatField_.AddEntriesFrom(ref input, _repeated_floatField_codec); break; } case 98: { - int64Field_.AddEntriesFrom(input, _repeated_int64Field_codec); + int64Field_.AddEntriesFrom(ref input, _repeated_int64Field_codec); break; } case 106: { - uint64Field_.AddEntriesFrom(input, _repeated_uint64Field_codec); + uint64Field_.AddEntriesFrom(ref input, _repeated_uint64Field_codec); break; } case 114: { - int32Field_.AddEntriesFrom(input, _repeated_int32Field_codec); + int32Field_.AddEntriesFrom(ref input, _repeated_int32Field_codec); break; } case 122: { - uint32Field_.AddEntriesFrom(input, _repeated_uint32Field_codec); + uint32Field_.AddEntriesFrom(ref input, _repeated_uint32Field_codec); break; } case 130: { - boolField_.AddEntriesFrom(input, _repeated_boolField_codec); + boolField_.AddEntriesFrom(ref input, _repeated_boolField_codec); break; } case 138: { - stringField_.AddEntriesFrom(input, _repeated_stringField_codec); + stringField_.AddEntriesFrom(ref input, _repeated_stringField_codec); break; } case 146: { - bytesField_.AddEntriesFrom(input, _repeated_bytesField_codec); + bytesField_.AddEntriesFrom(ref input, _repeated_bytesField_codec); break; } } @@ -1396,7 +1406,7 @@ namespace Google.Protobuf.TestProtos { } - public sealed partial class OneofWellKnownTypes : pb::IMessage { + public sealed partial class OneofWellKnownTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2023,11 +2033,16 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any(); @@ -2111,39 +2126,39 @@ namespace Google.Protobuf.TestProtos { break; } case 82: { - DoubleField = _oneof_doubleField_codec.Read(input); + DoubleField = _oneof_doubleField_codec.Read(ref input); break; } case 90: { - FloatField = _oneof_floatField_codec.Read(input); + FloatField = _oneof_floatField_codec.Read(ref input); break; } case 98: { - Int64Field = _oneof_int64Field_codec.Read(input); + Int64Field = _oneof_int64Field_codec.Read(ref input); break; } case 106: { - Uint64Field = _oneof_uint64Field_codec.Read(input); + Uint64Field = _oneof_uint64Field_codec.Read(ref input); break; } case 114: { - Int32Field = _oneof_int32Field_codec.Read(input); + Int32Field = _oneof_int32Field_codec.Read(ref input); break; } case 122: { - Uint32Field = _oneof_uint32Field_codec.Read(input); + Uint32Field = _oneof_uint32Field_codec.Read(ref input); break; } case 130: { - BoolField = _oneof_boolField_codec.Read(input); + BoolField = _oneof_boolField_codec.Read(ref input); break; } case 138: { - StringField = _oneof_stringField_codec.Read(input); + StringField = _oneof_stringField_codec.Read(ref input); break; } case 146: { - BytesField = _oneof_bytesField_codec.Read(input); + BytesField = _oneof_bytesField_codec.Read(ref input); break; } } @@ -2157,7 +2172,7 @@ namespace Google.Protobuf.TestProtos { /// need to worry about the value part of the map being the /// well-known types, as messages can't be map keys. /// - public sealed partial class MapWellKnownTypes : pb::IMessage { + public sealed partial class MapWellKnownTypes : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MapWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2534,82 +2549,87 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - anyField_.AddEntriesFrom(input, _map_anyField_codec); + anyField_.AddEntriesFrom(ref input, _map_anyField_codec); break; } case 18: { - apiField_.AddEntriesFrom(input, _map_apiField_codec); + apiField_.AddEntriesFrom(ref input, _map_apiField_codec); break; } case 26: { - durationField_.AddEntriesFrom(input, _map_durationField_codec); + durationField_.AddEntriesFrom(ref input, _map_durationField_codec); break; } case 34: { - emptyField_.AddEntriesFrom(input, _map_emptyField_codec); + emptyField_.AddEntriesFrom(ref input, _map_emptyField_codec); break; } case 42: { - fieldMaskField_.AddEntriesFrom(input, _map_fieldMaskField_codec); + fieldMaskField_.AddEntriesFrom(ref input, _map_fieldMaskField_codec); break; } case 50: { - sourceContextField_.AddEntriesFrom(input, _map_sourceContextField_codec); + sourceContextField_.AddEntriesFrom(ref input, _map_sourceContextField_codec); break; } case 58: { - structField_.AddEntriesFrom(input, _map_structField_codec); + structField_.AddEntriesFrom(ref input, _map_structField_codec); break; } case 66: { - timestampField_.AddEntriesFrom(input, _map_timestampField_codec); + timestampField_.AddEntriesFrom(ref input, _map_timestampField_codec); break; } case 74: { - typeField_.AddEntriesFrom(input, _map_typeField_codec); + typeField_.AddEntriesFrom(ref input, _map_typeField_codec); break; } case 82: { - doubleField_.AddEntriesFrom(input, _map_doubleField_codec); + doubleField_.AddEntriesFrom(ref input, _map_doubleField_codec); break; } case 90: { - floatField_.AddEntriesFrom(input, _map_floatField_codec); + floatField_.AddEntriesFrom(ref input, _map_floatField_codec); break; } case 98: { - int64Field_.AddEntriesFrom(input, _map_int64Field_codec); + int64Field_.AddEntriesFrom(ref input, _map_int64Field_codec); break; } case 106: { - uint64Field_.AddEntriesFrom(input, _map_uint64Field_codec); + uint64Field_.AddEntriesFrom(ref input, _map_uint64Field_codec); break; } case 114: { - int32Field_.AddEntriesFrom(input, _map_int32Field_codec); + int32Field_.AddEntriesFrom(ref input, _map_int32Field_codec); break; } case 122: { - uint32Field_.AddEntriesFrom(input, _map_uint32Field_codec); + uint32Field_.AddEntriesFrom(ref input, _map_uint32Field_codec); break; } case 130: { - boolField_.AddEntriesFrom(input, _map_boolField_codec); + boolField_.AddEntriesFrom(ref input, _map_boolField_codec); break; } case 138: { - stringField_.AddEntriesFrom(input, _map_stringField_codec); + stringField_.AddEntriesFrom(ref input, _map_stringField_codec); break; } case 146: { - bytesField_.AddEntriesFrom(input, _map_bytesField_codec); + bytesField_.AddEntriesFrom(ref input, _map_bytesField_codec); break; } } diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index 8b39573d7c..6b031cfbfc 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -194,7 +194,7 @@ namespace Google.Protobuf.Reflection { /// The protocol compiler can output a FileDescriptorSet containing the .proto /// files it parses. /// - public sealed partial class FileDescriptorSet : pb::IMessage { + public sealed partial class FileDescriptorSet : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorSet()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -299,14 +299,19 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - file_.AddEntriesFrom(input, _repeated_file_codec); + file_.AddEntriesFrom(ref input, _repeated_file_codec); break; } } @@ -318,7 +323,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes a complete .proto file. /// - public sealed partial class FileDescriptorProto : pb::IMessage { + public sealed partial class FileDescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -730,11 +735,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -745,23 +755,23 @@ namespace Google.Protobuf.Reflection { break; } case 26: { - dependency_.AddEntriesFrom(input, _repeated_dependency_codec); + dependency_.AddEntriesFrom(ref input, _repeated_dependency_codec); break; } case 34: { - messageType_.AddEntriesFrom(input, _repeated_messageType_codec); + messageType_.AddEntriesFrom(ref input, _repeated_messageType_codec); break; } case 42: { - enumType_.AddEntriesFrom(input, _repeated_enumType_codec); + enumType_.AddEntriesFrom(ref input, _repeated_enumType_codec); break; } case 50: { - service_.AddEntriesFrom(input, _repeated_service_codec); + service_.AddEntriesFrom(ref input, _repeated_service_codec); break; } case 58: { - extension_.AddEntriesFrom(input, _repeated_extension_codec); + extension_.AddEntriesFrom(ref input, _repeated_extension_codec); break; } case 66: { @@ -780,12 +790,12 @@ namespace Google.Protobuf.Reflection { } case 82: case 80: { - publicDependency_.AddEntriesFrom(input, _repeated_publicDependency_codec); + publicDependency_.AddEntriesFrom(ref input, _repeated_publicDependency_codec); break; } case 90: case 88: { - weakDependency_.AddEntriesFrom(input, _repeated_weakDependency_codec); + weakDependency_.AddEntriesFrom(ref input, _repeated_weakDependency_codec); break; } case 98: { @@ -801,7 +811,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes a message type. /// - public sealed partial class DescriptorProto : pb::IMessage { + public sealed partial class DescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1095,34 +1105,39 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); break; } case 18: { - field_.AddEntriesFrom(input, _repeated_field_codec); + field_.AddEntriesFrom(ref input, _repeated_field_codec); break; } case 26: { - nestedType_.AddEntriesFrom(input, _repeated_nestedType_codec); + nestedType_.AddEntriesFrom(ref input, _repeated_nestedType_codec); break; } case 34: { - enumType_.AddEntriesFrom(input, _repeated_enumType_codec); + enumType_.AddEntriesFrom(ref input, _repeated_enumType_codec); break; } case 42: { - extensionRange_.AddEntriesFrom(input, _repeated_extensionRange_codec); + extensionRange_.AddEntriesFrom(ref input, _repeated_extensionRange_codec); break; } case 50: { - extension_.AddEntriesFrom(input, _repeated_extension_codec); + extension_.AddEntriesFrom(ref input, _repeated_extension_codec); break; } case 58: { @@ -1133,15 +1148,15 @@ namespace Google.Protobuf.Reflection { break; } case 66: { - oneofDecl_.AddEntriesFrom(input, _repeated_oneofDecl_codec); + oneofDecl_.AddEntriesFrom(ref input, _repeated_oneofDecl_codec); break; } case 74: { - reservedRange_.AddEntriesFrom(input, _repeated_reservedRange_codec); + reservedRange_.AddEntriesFrom(ref input, _repeated_reservedRange_codec); break; } case 82: { - reservedName_.AddEntriesFrom(input, _repeated_reservedName_codec); + reservedName_.AddEntriesFrom(ref input, _repeated_reservedName_codec); break; } } @@ -1152,7 +1167,7 @@ namespace Google.Protobuf.Reflection { /// Container for nested types declared in the DescriptorProto message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class ExtensionRange : pb::IMessage { + public sealed partial class ExtensionRange : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRange()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -1360,11 +1375,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Start = input.ReadInt32(); @@ -1392,7 +1412,7 @@ namespace Google.Protobuf.Reflection { /// fields or extension ranges in the same message. Reserved ranges may /// not overlap. /// - public sealed partial class ReservedRange : pb::IMessage { + public sealed partial class ReservedRange : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedRange()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -1563,11 +1583,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Start = input.ReadInt32(); @@ -1588,7 +1613,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class ExtensionRangeOptions : pb::IExtendableMessage { + public sealed partial class ExtensionRangeOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRangeOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -1712,16 +1737,21 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -1755,7 +1785,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes a field within a message. /// - public sealed partial class FieldDescriptorProto : pb::IMessage { + public sealed partial class FieldDescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldDescriptorProto()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -2292,11 +2322,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -2421,7 +2456,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes a oneof. /// - public sealed partial class OneofDescriptorProto : pb::IMessage { + public sealed partial class OneofDescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2583,11 +2618,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -2609,7 +2649,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes an enum type. /// - public sealed partial class EnumDescriptorProto : pb::IMessage { + public sealed partial class EnumDescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2828,18 +2868,23 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); break; } case 18: { - value_.AddEntriesFrom(input, _repeated_value_codec); + value_.AddEntriesFrom(ref input, _repeated_value_codec); break; } case 26: { @@ -2850,11 +2895,11 @@ namespace Google.Protobuf.Reflection { break; } case 34: { - reservedRange_.AddEntriesFrom(input, _repeated_reservedRange_codec); + reservedRange_.AddEntriesFrom(ref input, _repeated_reservedRange_codec); break; } case 42: { - reservedName_.AddEntriesFrom(input, _repeated_reservedName_codec); + reservedName_.AddEntriesFrom(ref input, _repeated_reservedName_codec); break; } } @@ -2873,7 +2918,7 @@ namespace Google.Protobuf.Reflection { /// is inclusive such that it can appropriately represent the entire int32 /// domain. /// - public sealed partial class EnumReservedRange : pb::IMessage { + public sealed partial class EnumReservedRange : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumReservedRange()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -3044,11 +3089,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Start = input.ReadInt32(); @@ -3072,7 +3122,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes a value within an enum. /// - public sealed partial class EnumValueDescriptorProto : pb::IMessage { + public sealed partial class EnumValueDescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueDescriptorProto()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -3273,11 +3323,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -3303,7 +3358,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes a service. /// - public sealed partial class ServiceDescriptorProto : pb::IMessage { + public sealed partial class ServiceDescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3481,18 +3536,23 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); break; } case 18: { - method_.AddEntriesFrom(input, _repeated_method_codec); + method_.AddEntriesFrom(ref input, _repeated_method_codec); break; } case 26: { @@ -3511,7 +3571,7 @@ namespace Google.Protobuf.Reflection { /// /// Describes a method of a service. /// - public sealed partial class MethodDescriptorProto : pb::IMessage { + public sealed partial class MethodDescriptorProto : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodDescriptorProto()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -3831,11 +3891,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -3870,7 +3935,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class FileOptions : pb::IExtendableMessage { + public sealed partial class FileOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -4823,12 +4888,17 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 10: { @@ -4912,7 +4982,7 @@ namespace Google.Protobuf.Reflection { break; } case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -4968,7 +5038,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class MessageOptions : pb::IExtendableMessage { + public sealed partial class MessageOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -5296,12 +5366,17 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 8: { @@ -5321,7 +5396,7 @@ namespace Google.Protobuf.Reflection { break; } case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -5352,7 +5427,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class FieldOptions : pb::IExtendableMessage { + public sealed partial class FieldOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -5764,12 +5839,17 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 8: { @@ -5797,7 +5877,7 @@ namespace Google.Protobuf.Reflection { break; } case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -5859,7 +5939,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class OneofOptions : pb::IExtendableMessage { + public sealed partial class OneofOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -5983,16 +6063,21 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -6023,7 +6108,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class EnumOptions : pb::IExtendableMessage { + public sealed partial class EnumOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6233,12 +6318,17 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 16: { @@ -6250,7 +6340,7 @@ namespace Google.Protobuf.Reflection { break; } case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -6281,7 +6371,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class EnumValueOptions : pb::IExtendableMessage { + public sealed partial class EnumValueOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6450,12 +6540,17 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 8: { @@ -6463,7 +6558,7 @@ namespace Google.Protobuf.Reflection { break; } case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -6494,7 +6589,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class ServiceOptions : pb::IExtendableMessage { + public sealed partial class ServiceOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6663,12 +6758,17 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 264: { @@ -6676,7 +6776,7 @@ namespace Google.Protobuf.Reflection { break; } case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -6707,7 +6807,7 @@ namespace Google.Protobuf.Reflection { } - public sealed partial class MethodOptions : pb::IExtendableMessage { + public sealed partial class MethodOptions : pb::IExtendableMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6913,12 +7013,17 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); } break; case 264: { @@ -6930,7 +7035,7 @@ namespace Google.Protobuf.Reflection { break; } case 7994: { - uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); break; } } @@ -6993,7 +7098,7 @@ namespace Google.Protobuf.Reflection { /// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions /// in them. /// - public sealed partial class UninterpretedOption : pb::IMessage { + public sealed partial class UninterpretedOption : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UninterpretedOption()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7323,14 +7428,19 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 18: { - name_.AddEntriesFrom(input, _repeated_name_codec); + name_.AddEntriesFrom(ref input, _repeated_name_codec); break; } case 26: { @@ -7372,7 +7482,7 @@ namespace Google.Protobuf.Reflection { /// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents /// "foo.(bar.baz).qux". /// - public sealed partial class NamePart : pb::IMessage { + public sealed partial class NamePart : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamePart()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7536,11 +7646,16 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { NamePart_ = input.ReadString(); @@ -7565,7 +7680,7 @@ namespace Google.Protobuf.Reflection { /// Encapsulates information about the original source file from which a /// FileDescriptorProto was generated. /// - public sealed partial class SourceCodeInfo : pb::IMessage { + public sealed partial class SourceCodeInfo : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceCodeInfo()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7715,14 +7830,19 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - location_.AddEntriesFrom(input, _repeated_location_codec); + location_.AddEntriesFrom(ref input, _repeated_location_codec); break; } } @@ -7733,7 +7853,7 @@ namespace Google.Protobuf.Reflection { /// Container for nested types declared in the SourceCodeInfo message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Location : pb::IMessage { + public sealed partial class Location : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Location()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8023,20 +8143,25 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: case 8: { - path_.AddEntriesFrom(input, _repeated_path_codec); + path_.AddEntriesFrom(ref input, _repeated_path_codec); break; } case 18: case 16: { - span_.AddEntriesFrom(input, _repeated_span_codec); + span_.AddEntriesFrom(ref input, _repeated_span_codec); break; } case 26: { @@ -8048,7 +8173,7 @@ namespace Google.Protobuf.Reflection { break; } case 50: { - leadingDetachedComments_.AddEntriesFrom(input, _repeated_leadingDetachedComments_codec); + leadingDetachedComments_.AddEntriesFrom(ref input, _repeated_leadingDetachedComments_codec); break; } } @@ -8067,7 +8192,7 @@ namespace Google.Protobuf.Reflection { /// file. A GeneratedCodeInfo message is associated with only one generated /// source file, but may contain references to different source .proto files. /// - public sealed partial class GeneratedCodeInfo : pb::IMessage { + public sealed partial class GeneratedCodeInfo : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GeneratedCodeInfo()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8176,14 +8301,19 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - annotation_.AddEntriesFrom(input, _repeated_annotation_codec); + annotation_.AddEntriesFrom(ref input, _repeated_annotation_codec); break; } } @@ -8194,7 +8324,7 @@ namespace Google.Protobuf.Reflection { /// Container for nested types declared in the GeneratedCodeInfo message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Annotation : pb::IMessage { + public sealed partial class Annotation : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Annotation()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -8427,15 +8557,20 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: case 8: { - path_.AddEntriesFrom(input, _repeated_path_codec); + path_.AddEntriesFrom(ref input, _repeated_path_codec); break; } case 18: { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index 09e0e29f0d..f7ffbc6608 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -119,7 +119,7 @@ namespace Google.Protobuf.WellKnownTypes { /// "value": "1.212s" /// } /// - public sealed partial class Any : pb::IMessage { + public sealed partial class Any : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Any()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -288,11 +288,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); 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 06a9905919..1556eba87f 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -64,7 +64,7 @@ namespace Google.Protobuf.WellKnownTypes { /// this message itself. See https://cloud.google.com/apis/design/glossary for /// detailed terminology. /// - public sealed partial class Api : pb::IMessage { + public sealed partial class Api : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Api()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -341,22 +341,27 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); break; } case 18: { - methods_.AddEntriesFrom(input, _repeated_methods_codec); + methods_.AddEntriesFrom(ref input, _repeated_methods_codec); break; } case 26: { - options_.AddEntriesFrom(input, _repeated_options_codec); + options_.AddEntriesFrom(ref input, _repeated_options_codec); break; } case 34: { @@ -371,7 +376,7 @@ namespace Google.Protobuf.WellKnownTypes { break; } case 50: { - mixins_.AddEntriesFrom(input, _repeated_mixins_codec); + mixins_.AddEntriesFrom(ref input, _repeated_mixins_codec); break; } case 56: { @@ -387,7 +392,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// Method represents a method of an API interface. /// - public sealed partial class Method : pb::IMessage { + public sealed partial class Method : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Method()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -657,11 +662,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -684,7 +694,7 @@ namespace Google.Protobuf.WellKnownTypes { break; } case 50: { - options_.AddEntriesFrom(input, _repeated_options_codec); + options_.AddEntriesFrom(ref input, _repeated_options_codec); break; } case 56: { @@ -777,7 +787,7 @@ namespace Google.Protobuf.WellKnownTypes { /// ... /// } /// - public sealed partial class Mixin : pb::IMessage { + public sealed partial class Mixin : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Mixin()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -921,11 +931,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); 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 f0078c4dd4..9208bd057a 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -100,7 +100,7 @@ namespace Google.Protobuf.WellKnownTypes { /// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 /// microsecond should be expressed in JSON format as "3.000001s". /// - public sealed partial class Duration : pb::IMessage { + public sealed partial class Duration : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Duration()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -250,11 +250,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); 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 fa435cd23e..d517e8ee0d 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs @@ -50,7 +50,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// The JSON representation for `Empty` is empty JSON object `{}`. /// - public sealed partial class Empty : pb::IMessage { + public sealed partial class Empty : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Empty()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -139,11 +139,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index 00e1e9faa4..8bd779ee99 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -240,7 +240,7 @@ namespace Google.Protobuf.WellKnownTypes { /// request should verify the included field paths, and return an /// `INVALID_ARGUMENT` error if any path is unmappable. /// - public sealed partial class FieldMask : pb::IMessage { + public sealed partial class FieldMask : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldMask()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -348,14 +348,19 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - paths_.AddEntriesFrom(input, _repeated_paths_codec); + paths_.AddEntriesFrom(ref input, _repeated_paths_codec); break; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs index d7076196e0..baf5687dfe 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs @@ -44,7 +44,7 @@ namespace Google.Protobuf.WellKnownTypes { /// `SourceContext` represents information about the source of a /// protobuf element, like the file in which it is defined. /// - public sealed partial class SourceContext : pb::IMessage { + public sealed partial class SourceContext : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceContext()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -161,11 +161,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); 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 b1dbe239cc..182b7bad85 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -77,7 +77,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// The JSON representation for `Struct` is JSON object. /// - public sealed partial class Struct : pb::IMessage { + public sealed partial class Struct : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Struct()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -185,14 +185,19 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - fields_.AddEntriesFrom(input, _map_fields_codec); + fields_.AddEntriesFrom(ref input, _map_fields_codec); break; } } @@ -209,7 +214,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// The JSON representation for `Value` is JSON value. /// - public sealed partial class Value : pb::IMessage { + public sealed partial class Value : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Value()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -509,11 +514,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { kind_ = input.ReadEnum(); @@ -561,7 +571,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// The JSON representation for `ListValue` is JSON array. /// - public sealed partial class ListValue : pb::IMessage { + public sealed partial class ListValue : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ListValue()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -669,14 +679,19 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - values_.AddEntriesFrom(input, _repeated_values_codec); + values_.AddEntriesFrom(ref input, _repeated_values_codec); break; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs index 12f4812af3..4c1927a474 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs @@ -123,7 +123,7 @@ namespace Google.Protobuf.WellKnownTypes { /// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D /// ) to obtain a formatter capable of generating timestamps in this format. /// - public sealed partial class Timestamp : pb::IMessage { + public sealed partial class Timestamp : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Timestamp()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -271,11 +271,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); 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 bfd4b8ec82..f476a14f58 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -94,7 +94,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// A protocol buffer message type. /// - public sealed partial class Type : pb::IMessage { + public sealed partial class Type : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Type()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -324,26 +324,31 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); break; } case 18: { - fields_.AddEntriesFrom(input, _repeated_fields_codec); + fields_.AddEntriesFrom(ref input, _repeated_fields_codec); break; } case 26: { - oneofs_.AddEntriesFrom(input, _repeated_oneofs_codec); + oneofs_.AddEntriesFrom(ref input, _repeated_oneofs_codec); break; } case 34: { - options_.AddEntriesFrom(input, _repeated_options_codec); + options_.AddEntriesFrom(ref input, _repeated_options_codec); break; } case 42: { @@ -366,7 +371,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// A single field of a message type. /// - public sealed partial class Field : pb::IMessage { + public sealed partial class Field : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Field()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -719,11 +724,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Kind = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum(); @@ -754,7 +764,7 @@ namespace Google.Protobuf.WellKnownTypes { break; } case 74: { - options_.AddEntriesFrom(input, _repeated_options_codec); + options_.AddEntriesFrom(ref input, _repeated_options_codec); break; } case 82: { @@ -885,7 +895,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// Enum type definition. /// - public sealed partial class Enum : pb::IMessage { + public sealed partial class Enum : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Enum()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1096,22 +1106,27 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); break; } case 18: { - enumvalue_.AddEntriesFrom(input, _repeated_enumvalue_codec); + enumvalue_.AddEntriesFrom(ref input, _repeated_enumvalue_codec); break; } case 26: { - options_.AddEntriesFrom(input, _repeated_options_codec); + options_.AddEntriesFrom(ref input, _repeated_options_codec); break; } case 34: { @@ -1134,7 +1149,7 @@ namespace Google.Protobuf.WellKnownTypes { /// /// Enum value definition. /// - public sealed partial class EnumValue : pb::IMessage { + public sealed partial class EnumValue : pb::IMessage, pb::IBufferMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValue()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1296,11 +1311,16 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { + input.ReadRawMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom_Internal(ref pb::ParseContext input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Name = input.ReadString(); @@ -1311,7 +1331,7 @@ namespace Google.Protobuf.WellKnownTypes { break; } case 26: { - options_.AddEntriesFrom(input, _repeated_options_codec); + options_.AddEntriesFrom(ref input, _repeated_options_codec); break; } } @@ -1324,7 +1344,7 @@ namespace Google.Protobuf.WellKnownTypes { /// A protocol buffer option, which can be attached to a message, field, /// enumeration, etc. /// - public sealed partial class Option : pb::IMessage