Interface IParameterShape
- Namespace
- PolyType.Abstractions
- Assembly
- PolyType.dll
Provides a strongly typed shape model for a given .NET method parameter, representing either an actual parameter or a member initializer.
public interface IParameterShape
Properties
AttributeProvider
Gets the provider used for parameter-level attribute resolution.
IGenericCustomAttributeProvider AttributeProvider { get; }
Property Value
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 attributesSystem.Runtime.InteropServices.*- COM interop attributesSystem.Diagnostics.*- Diagnostic attributesSystem.Reflection.DefaultMemberAttribute- Default member metadataSystem.CLSCompliantAttribute- CLS compliance markerMicrosoft.FSharp.Core.*- F# compiler generated attributes- Attributes marked with unmet ConditionalAttribute annotations
DefaultValue
Gets the default value specified by the parameter, if applicable.
object? DefaultValue { get; }
Property Value
HasDefaultValue
Gets a value indicating whether the parameter has a default value.
bool HasDefaultValue { get; }
Property Value
IsNonNullable
Gets a value indicating whether the parameter requires non-null values.
bool IsNonNullable { get; }
Property Value
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
IsRequired
Gets a value indicating whether a value is required for the current parameter.
bool IsRequired { get; }
Property Value
Remarks
A parameter is reported as required if it is either a parameter without a default value or related to a property declared with the required modifier where the constructor is not annotated with SetsRequiredMembersAttribute. This value will switch to the value set by IsRequired or IsRequired (successively) if they are set.
Kind
Gets specifies the kind of the current parameter.
ParameterKind Kind { get; }
Property Value
MemberInfo
Gets the underlying MemberInfo representing the parameter, if available.
MemberInfo? MemberInfo { get; }
Property Value
Remarks
Returns a PropertyInfo or FieldInfo when the parameter kind is MemberInitializer, or null otherwise.
Name
Gets the name of the method parameter.
string Name { get; }
Property Value
ParameterInfo
Gets the underlying ParameterInfo representing the parameter, if available.
ParameterInfo? ParameterInfo { get; }
Property Value
Remarks
Returns a value when the parameter kind is MethodParameter, or null otherwise.
ParameterType
Gets the shape of the method parameter type.
ITypeShape ParameterType { get; }
Property Value
Position
Gets the 0-indexed position of the current method parameter.
int Position { get; }
Property Value
Methods
Accept(TypeShapeVisitor, object?)
Accepts an TypeShapeVisitor for strongly-typed traversal.
object? Accept(TypeShapeVisitor visitor, object? state = null)
Parameters
visitorTypeShapeVisitorThe visitor to accept.
stateobjectThe state parameter to pass to the underlying visitor.