Table of Contents

Interface IConstructorParameterShape

Namespace
PolyType.Abstractions
Assembly
PolyType.dll

Provides a strongly typed shape model for a given .NET constructor parameter, representing either an actual constructor parameter or a member initializer.

public interface IConstructorParameterShape

Properties

AttributeProvider

Gets the provider used for parameter-level attribute resolution.

ICustomAttributeProvider? AttributeProvider { get; }

Property Value

ICustomAttributeProvider

DefaultValue

Gets the default value specified by the parameter, if applicable.

object? DefaultValue { get; }

Property Value

object

HasDefaultValue

Gets a value indicating whether the parameter has a default value.

bool HasDefaultValue { get; }

Property Value

bool

IsNonNullable

Gets a value indicating whether the parameter requires non-null values.

bool IsNonNullable { get; }

Property Value

bool

Remarks

Returns true if the parameter type is a non-nullable struct, a non-nullable reference type or the parameter has been annotated with the DisallowNullAttribute.

Conversely, it could return false if a non-nullable parameter has been annotated with AllowNullAttribute.

IsPublic

Gets a value indicating whether the parameter is a public property or field initializer.

bool IsPublic { get; }

Property Value

bool

IsRequired

Gets a value indicating whether a value is required for the current parameter.

bool IsRequired { get; }

Property Value

bool

Remarks

A parameter is reported as required if it is either a constructor parameter without a default value or a required property.

Kind

Gets specifies the kind of the current parameter.

ConstructorParameterKind Kind { get; }

Property Value

ConstructorParameterKind

Name

Gets the name of the constructor parameter.

string Name { get; }

Property Value

string

ParameterType

Gets the shape of the constructor parameter type.

ITypeShape ParameterType { get; }

Property Value

ITypeShape

Position

Gets the 0-indexed position of the current constructor parameter.

int Position { get; }

Property Value

int

Methods

Accept(ITypeShapeVisitor, object?)

Accepts an ITypeShapeVisitor for strongly-typed traversal.

object? Accept(ITypeShapeVisitor visitor, object? state = null)

Parameters

visitor ITypeShapeVisitor

The visitor to accept.

state object

The state parameter to pass to the underlying visitor.

Returns

object

The object result returned by the visitor.