# TestBufferWriterStruct Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization.testkit/orleans.serialization.testkit.testbufferwriterstruct/)

## Advance(int) {#advance-int-3e32ce97}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization.testkit/orleans.serialization.testkit.testbufferwriterstruct/methods/advance-int-3e32ce97/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization.TestKit/TestBufferWriterStruct.cs#L21)

```csharp
public void Advance(int bytes)
```

Notifies the `System.Buffers.IBufferWriter-1` that `count` data items were written to the output `System.Span-1` or `System.Memory-1`.

### Parameters

- `bytes` (`int`): The number of data items written to the `System.Span-1` or `System.Memory-1`.

## GetMemory(int) {#getmemory-int-11217455}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization.testkit/orleans.serialization.testkit.testbufferwriterstruct/methods/getmemory-int-11217455/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization.TestKit/TestBufferWriterStruct.cs#L24)

```csharp
public readonly Memory<byte> GetMemory(int sizeHint = 0)
```

Returns a `System.Memory-1` to write to that is at least the requested size (specified by `sizeHint`).

### Parameters

- `sizeHint` (`int`): The minimum length of the returned `System.Memory-1`. If 0, a non-empty buffer is returned.

### Returns

A `System.Memory-1` of at least the size `sizeHint`. If `sizeHint` is 0, returns a non-empty buffer.

### Exceptions

- `System.OutOfMemoryException`: The requested buffer size is not available.

## GetReadOnlySequence(int) {#getreadonlysequence-int-5ebbe952}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization.testkit/orleans.serialization.testkit.testbufferwriterstruct/methods/getreadonlysequence-int-5ebbe952/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization.TestKit/TestBufferWriterStruct.cs#L30)

```csharp
public readonly ReadOnlySequence<byte> GetReadOnlySequence(int maxSegmentSize)
```

### Parameters

- `maxSegmentSize` (`int`)

## GetSpan(int) {#getspan-int-99d02e66}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization.testkit/orleans.serialization.testkit.testbufferwriterstruct/methods/getspan-int-99d02e66/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization.TestKit/TestBufferWriterStruct.cs#L27)

```csharp
public readonly Span<byte> GetSpan(int sizeHint)
```

Returns a `System.Span-1` to write to that is at least the requested size (specified by `sizeHint`).

### Parameters

- `sizeHint` (`int`): The minimum length of the returned `System.Span-1`. If 0, a non-empty buffer is returned.

### Returns

A `System.Span-1` of at least the size `sizeHint`. If `sizeHint` is 0, returns a non-empty buffer.
