# OrleansGeneratedCodeHelper Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/)

## ConsumeEndBaseOrEndObject(Reader&lt;TInput&gt;) {#consumeendbaseorendobject-1-this-orleans-serialization-buffers-reader-tinput-8de6c5c1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/consumeendbaseorendobject-1-this-orleans-serialization-buffers-reader-tinput-8de6c5c1/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L161-L164)

```csharp
public static void ConsumeEndBaseOrEndObject<TInput>(this ref Reader<TInput> reader)
```

Expects empty content (a single field header of either [ExtendedWireType](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.wireprotocol.extendedwiretype/) or [ExtendedWireType](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.wireprotocol.extendedwiretype/)), but will consume any unexpected fields also.

### Parameters

- `reader` (`Reader<TInput>`)

## ConsumeEndBaseOrEndObject(Reader&lt;TInput&gt;, Field) {#consumeendbaseorendobject-1-this-orleans-serialization-buffers-reader-tinput-ref-580dc932}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/consumeendbaseorendobject-1-this-orleans-serialization-buffers-reader-tinput-ref-580dc932/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L173-L175)

```csharp
public static void ConsumeEndBaseOrEndObject<TInput>(this ref Reader<TInput> reader, scoped ref Field field)
```

Expects empty content (a single field header of either [ExtendedWireType](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.wireprotocol.extendedwiretype/) or [ExtendedWireType](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.wireprotocol.extendedwiretype/)), but will consume any unexpected fields also.

### Parameters

- `reader` (`Reader<TInput>`)
- `field` (`Field`)

## DeserializeUnexpectedType(Reader&lt;TInput&gt;, Field) {#deserializeunexpectedtype-2-this-orleans-serialization-buffers-reader-tinput-ref-28a8192b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/deserializeunexpectedtype-2-this-orleans-serialization-buffers-reader-tinput-ref-28a8192b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L213-L214)

```csharp
public static TField DeserializeUnexpectedType<TInput, TField>(this ref Reader<TInput> reader, scoped ref Field field)
```

Deserializes an unexpected value.

### Parameters

- `reader` (`Reader<TInput>`): The reader.
- `field` (`Field`): The field.

### Returns

The value.

## GetMethodInfoOrDefault(Type, string, Type[], Type[]) {#getmethodinfoordefault-system-type-string-system-type-array-1-system-type-array-960da120}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/getmethodinfoordefault-system-type-string-system-type-array-1-system-type-array-960da120/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L228-L288)

```csharp
public static MethodInfo GetMethodInfoOrDefault(Type interfaceType, string methodName, Type[] methodTypeParameters, Type[] parameterTypes)
```

Gets the `System.Reflection.MethodInfo` matching the provided values.

### Parameters

- `interfaceType` (`Type`): Type of the interface.
- `methodName` (`string`): Name of the method.
- `methodTypeParameters` (`Type[]`): The method type parameters.
- `parameterTypes` (`Type[]`): The parameter types.

### Returns

The corresponding `System.Reflection.MethodInfo`.

## GetOptionalCopier(IDeepCopier&lt;T&gt;) {#getoptionalcopier-1-orleans-serialization-cloning-ideepcopier-t-ace32f4d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/getoptionalcopier-1-orleans-serialization-cloning-ideepcopier-t-ace32f4d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L146)

```csharp
public static IDeepCopier<T> GetOptionalCopier<T>(IDeepCopier<T> copier)
```

Returns the provided copier if it's not shallow-copyable.

### Parameters

- `copier` (`IDeepCopier<T>`)

## GetService(object, ICodecProvider) {#getservice-1-object-orleans-serialization-serializers-icodecprovider-5a78d841}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/getservice-1-object-orleans-serialization-serializers-icodecprovider-5a78d841/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L58-L85)

```csharp
public static TService GetService<TService>(object caller, ICodecProvider codecProvider)
```

Unwraps the provided service if it was wrapped.

### Parameters

- `caller` (`object`): The caller.
- `codecProvider` (`ICodecProvider`): The codec provider.

### Returns

The unwrapped service.

## InvokableThrowArgumentOutOfRange(int, int) {#invokablethrowargumentoutofrange-int-int-24b5c00b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/invokablethrowargumentoutofrange-int-int-24b5c00b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L152)

```csharp
public static object InvokableThrowArgumentOutOfRange(int index, int maxArgs)
```

Generated code helper method which throws an `System.ArgumentOutOfRangeException`.

### Parameters

- `index` (`int`)
- `maxArgs` (`int`)

## SerializeUnexpectedType(Writer&lt;TBufferWriter&gt;, uint, Type, object) {#serializeunexpectedtype-1-this-orleans-serialization-buffers-writer-tbufferwrite-b2ee8e76}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/serializeunexpectedtype-1-this-orleans-serialization-buffers-writer-tbufferwrite-b2ee8e76/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L198-L200)

```csharp
public static void SerializeUnexpectedType<TBufferWriter>(this ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, object value)
```

Serializes an unexpected value.

### Parameters

- `writer` (`Writer<TBufferWriter>`): The writer.
- `fieldIdDelta` (`uint`): The field identifier delta.
- `expectedType` (`Type`): The expected type.
- `value` (`object`): The value.

## UnwrapService(object, TService) {#unwrapservice-1-object-tservice-18e87023}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.generatedcodehelpers.orleansgeneratedcodehelper/methods/unwrapservice-1-object-tservice-18e87023/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs#L96-L126)

```csharp
public static TService UnwrapService<TService>(object caller, TService service)
```

Unwraps the provided service if it was wrapped.

### Parameters

- `caller` (`object`): The caller.
- `service` (`TService`): The service.

### Returns

The unwrapped service.
