Table of Contents

Interface IMethodShape

Namespace
PolyType.Abstractions
Assembly
PolyType.dll

Provides a strongly typed shape model for a given .NET method.

public interface IMethodShape

Properties

AttributeProvider

Gets the provider used for method-level attribute resolution.

IGenericCustomAttributeProvider AttributeProvider { get; }

Property Value

IGenericCustomAttributeProvider

Remarks

Provides fast attribute resolution when using the source generator, otherwise this is wrapping standard reflection-based attribute resolution.

When using the source generator, the following categories of attributes are excluded to reduce trimmed application size:

  • System.Runtime.CompilerServices.* - Compiler-generated attributes
  • System.Runtime.InteropServices.* - COM interop attributes
  • System.Diagnostics.* - Diagnostic attributes
  • System.Reflection.DefaultMemberAttribute - Default member metadata
  • System.CLSCompliantAttribute - CLS compliance marker
  • Microsoft.FSharp.Core.* - F# compiler generated attributes
  • Attributes marked with unmet ConditionalAttribute annotations
Users requiring complete attribute resolution can use the MethodBase property to access standard reflection-based attribute APIs, though this will be slower.

DeclaringType

Gets the shape of the declaring type for the method.

ITypeShape DeclaringType { get; }

Property Value

ITypeShape

IsAsync

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

bool IsAsync { get; }

Property Value

bool

IsPublic

Gets a value indicating whether the method is declared public.

bool IsPublic { get; }

Property Value

bool

IsStatic

Gets a value indicating whether the method is static.

bool IsStatic { get; }

Property Value

bool

IsVoidLike

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

bool IsVoidLike { get; }

Property Value

bool

Remarks

When true the ReturnType is reported as Unit,

MethodBase

Gets the underlying MethodBase corresponding to the method, if applicable.

MethodBase? MethodBase { get; }

Property Value

MethodBase

Name

Gets the name of the method.

string Name { get; }

Property Value

string

Parameters

Gets the shapes of the parameters accepted by the method.

IReadOnlyList<IParameterShape> Parameters { get; }

Property Value

IReadOnlyList<IParameterShape>

ReturnType

Gets the shape of the return type of the method.

ITypeShape ReturnType { get; }

Property Value

ITypeShape

Methods

Accept(TypeShapeVisitor, object?)

Accepts an TypeShapeVisitor for strongly-typed traversal.

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.