Fix compile-time error for Google.Protobuf in C# 11

Note that the error only affects users trying to build
Google.Protobuf directly using C# 11. It doesn't affect users who
are compiling code against the pre-built library (which is likely to
be basically everyone).

Fixes #11004.
pull/12261/head
Jon Skeet 2 years ago
parent d70ddf20d3
commit 6bf22b892b
  1. 6
      csharp/src/Google.Protobuf/ParseContext.cs

@ -64,8 +64,9 @@ namespace Google.Protobuf
state.recursionLimit = DefaultRecursionLimit;
state.currentLimit = int.MaxValue;
state.bufferSize = buffer.Length;
Initialize(buffer, ref state, out ctx);
// Equivalent to Initialize(buffer, ref state, out ctx);
ctx.buffer = buffer;
ctx.state = state;
}
/// <summary>
@ -74,6 +75,7 @@ namespace Google.Protobuf
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Initialize(ReadOnlySpan<byte> buffer, ref ParserInternalState state, out ParseContext ctx)
{
// Note: if this code ever changes, also change the initialization above.
ctx.buffer = buffer;
ctx.state = state;
}

Loading…
Cancel
Save