MessagePackWriter Write(in ReadOnlySpan<byte> src) input should be scoped

Author: ShadowMarker789Created Mar 20, 2026Updated Mar 25, 2026

Bug description

  • CS8350 -

MessagePackWriter Write(in ReadOnlySequence) does not have scoped, prevents stackalloc usage without unsafe (turns the error into a warning)

Image

Repro steps

Try to use MessagePackWriter Write(in ReadOnlySpan) with a stackallocated span

Expected behavior

This is acceptable

Actual behavior

This is not acceptable

  • Version used:
  • Runtime: .Net Framework v 4.7.2

Additional context

I had to write custom serializers in the first place because our messages are proto defined, even though we're using MessagePack for the transport in .Net clients

Source: MessagePack-CSharp/MessagePack-CSharp