Skip to content

TestBufferWriterStruct Methods

Provides a fixed-capacity buffer writer 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 readonly Memory<byte> GetMemory(int sizeHint = 0)
Gets the unwritten portion of the fixed output buffer.

Parameters

sizeHintint
The requested minimum size. This fixed-buffer implementation does not allocate additional capacity.

Returns

The memory available for writing.

GetReadOnlySequence(int)

View source
public readonly 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 readonly Span<byte> GetSpan(int sizeHint)
Gets the unwritten portion of the fixed output buffer.

Parameters

sizeHintint
The requested minimum size. This fixed-buffer implementation does not allocate additional capacity.

Returns

The span available for writing.