Skip to content

TestMultiSegmentBufferWriter Methods

Provides a buffer writer which stores committed bytes in multiple segments for serialization tests.

Advance(int)

View source
public void Advance(int bytes)
Notifies the System.Buffers.IBufferWriter that count data items were written to the output System.Span or System.Memory.

Parameters

bytesint
The number of data items written to the System.Span or System.Memory.

GetMemory(int)

View source
public Memory<byte> GetMemory(int sizeHint = 0)
Gets writable memory, capped by the configured maximum allocation size.

Parameters

sizeHintint
The requested minimum size before applying the allocation cap.

Returns

The memory available for writing.

GetReadOnlySequence(int)

View source
public ReadOnlySequence<byte> GetReadOnlySequence(int maxSegmentSize)
Returns the written bytes as a read-only sequence.

Parameters

maxSegmentSizeint
The maximum number of bytes in each sequence segment.

Returns

A read-only sequence containing the written bytes.

GetSpan(int)

View source
public Span<byte> GetSpan(int sizeHint)
Gets a writable span, capped by the configured maximum allocation size.

Parameters

sizeHintint
The requested minimum size before applying the allocation cap.

Returns

The span available for writing.

PeekAllBuffers

View source
public ReadOnlySequence<byte> PeekAllBuffers()
Returns all committed buffers followed by the current uncommitted buffer.

Returns

A read-only sequence containing all allocated buffers.