Table of Contents

Class SourceGenMethodShape<TDeclaringType, TArgumentState, TResult>

Namespace
PolyType.SourceGenModel
Assembly
PolyType.dll

Source generator model for method shapes.

public sealed class SourceGenMethodShape<TDeclaringType, TArgumentState, TResult> : IMethodShape<TDeclaringType, TArgumentState, TResult>, IMethodShape where TArgumentState : IArgumentState

Type Parameters

TDeclaringType

The type declaring the method.

TArgumentState

The mutable state type used for aggregating method arguments.

TResult

The return type of the underlying method.

Inheritance
SourceGenMethodShape<TDeclaringType, TArgumentState, TResult>
Implements
IMethodShape<TDeclaringType, TArgumentState, TResult>
Inherited Members

Properties

ArgumentStateConstructor

Gets a delegate for creating argument state constructor.

public required Func<TArgumentState> ArgumentStateConstructor { get; init; }

Property Value

Func<TArgumentState>

AttributeProvider

Gets the provider used for method-level attribute resolution.

public ICustomAttributeProvider? AttributeProvider { get; }

Property Value

ICustomAttributeProvider

AttributeProviderFunc

Gets a constructor delegate for the custom attribute provider of the method.

public Func<ICustomAttributeProvider?>? AttributeProviderFunc { get; init; }

Property Value

Func<ICustomAttributeProvider>

CreateParametersFunc

Gets a factory method for creating parameter shapes.

public Func<IEnumerable<IParameterShape>>? CreateParametersFunc { get; init; }

Property Value

Func<IEnumerable<IParameterShape>>

DeclaringType

Gets the shape of the declaring type for the method.

public required ITypeShape<TDeclaringType> DeclaringType { get; init; }

Property Value

ITypeShape<TDeclaringType>

IsAsync

Gets a value indicating whether the underlying method returns a Task or ValueTask.

public required bool IsAsync { get; init; }

Property Value

bool

IsPublic

Gets a value indicating whether the method is declared public.

public required bool IsPublic { get; init; }

Property Value

bool

IsStatic

Gets a value indicating whether the method is static.

public required bool IsStatic { get; init; }

Property Value

bool

IsVoidLike

Gets a value indicating whether the underlying method returns void, Task, or ValueTask.

public required bool IsVoidLike { get; init; }

Property Value

bool

Remarks

When true the ReturnType is reported as Unit,

MethodInvoker

Gets a delegate for invoking the method.

public required MethodInvoker<TDeclaringType, TArgumentState, TResult> MethodInvoker { get; init; }

Property Value

MethodInvoker<TDeclaringType, TArgumentState, TResult>

Name

Gets the name of the method.

public required string Name { get; init; }

Property Value

string

Parameters

Gets the shapes of the parameters accepted by the method.

public IReadOnlyList<IParameterShape> Parameters { get; }

Property Value

IReadOnlyList<IParameterShape>

ReturnType

Gets the shape of the return type of the method.

public required ITypeShape<TResult> ReturnType { get; init; }

Property Value

ITypeShape<TResult>

Methods

Accept(TypeShapeVisitor, object?)

Accepts an TypeShapeVisitor for strongly-typed traversal.

public object? Accept(TypeShapeVisitor visitor, object? state = null)

Parameters

visitor TypeShapeVisitor

The visitor to accept.

state object

The state parameter to pass to the underlying visitor.

Returns

object

The object result returned by the visitor.

GetArgumentStateConstructor()

Gets a delegate for creating a default argument state instance.

public Func<TArgumentState> GetArgumentStateConstructor()

Returns

Func<TArgumentState>

A delegate for creating an argument state instance with default parameter values.

Exceptions

InvalidOperationException

The Parameters property of the method is empty.

GetMethodInvoker()

Gets a delegate for invoking the method with the provided argument state.

public MethodInvoker<TDeclaringType, TArgumentState, TResult> GetMethodInvoker()

Returns

MethodInvoker<TDeclaringType, TArgumentState, TResult>

A MethodInvoker<TDeclaringType, TArgumentState, TResult> delegate.