Lengthproperty, which tracks number of elements written, should be more clearly documented as such so that it's not misinterpreted as bytes written? Is that what you're saying?
countis the number of items written
Lengthbecause it wasn't needed, but in a common case you will need it, and the doc should show that off.
Span<byte> data = stackalloc byte; if (!BitConverter.TryWriteBytes(data, nanos)) throw new InvalidOperationException("Failed to write nanoseconds."); if (!BitConverter.TryWriteBytes(data.Slice(4), seconds)) throw new InvalidOperationException("Failed to write seconds"); writer.WriteExtensionFormatHeader(new ExtensionHeader(typeCode: -1, length: 12)); writer.WriteRaw(data);
CS8350 This combination of arguments to 'MessagePackWriter.WriteRaw(ReadOnlySpan<byte>)' is disallowed because it may expose variables referenced by parameter 'rawMessagePackBlock' outside of their declaration scope
Spans in that method
MessagePackWritershould be a readonly struct