Class SourceGenParameterShape<TArgumentState, TParameter>
- Namespace
- PolyType.SourceGenModel
- Assembly
- PolyType.dll
Source generator model for a constructor parameter shape.
public sealed class SourceGenParameterShape<TArgumentState, TParameter> : IParameterShape<TArgumentState, TParameter>, IParameterShape where TArgumentState : IArgumentState
Type Parameters
TArgumentStateThe mutable constructor argument state type.
TParameterThe constructor parameter type.
- Inheritance
-
SourceGenParameterShape<TArgumentState, TParameter>
- Implements
-
IParameterShape<TArgumentState, TParameter>
- Inherited Members
Properties
AttributeFactory
Gets a constructor delegate for the custom attributes of the parameter.
public Func<SourceGenAttributeInfo[]>? AttributeFactory { get; init; }
Property Value
DefaultValue
Gets the default value specified by the parameter, if applicable.
public TParameter? DefaultValue { get; init; }
Property Value
- TParameter
Getter
Gets the getter for the parameter.
public required Getter<TArgumentState, TParameter> Getter { get; init; }
Property Value
- Getter<TArgumentState, TParameter>
HasDefaultValue
Gets a value indicating whether the parameter has a default value.
public bool HasDefaultValue { get; init; }
Property Value
IsNonNullable
Gets a value indicating whether the parameter requires non-null values.
public bool IsNonNullable { get; init; }
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.
public bool IsPublic { get; init; }
Property Value
IsRequired
Gets a value indicating whether a value is required for the current parameter.
public bool IsRequired { get; init; }
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. When IsRequired or IsRequired are set, the strictest setting wins: the parameter is reported as required if either attribute marks it as required, even if it declares a default value. An explicit IsRequired of false relaxes a parameter that would otherwise be required only for lacking a default value, but a matching IsRequired of true still takes precedence.
Kind
Gets specifies the kind of the current parameter.
public required ParameterKind Kind { get; init; }
Property Value
Name
Gets the name of the method parameter.
public required string Name { get; init; }
Property Value
ParameterType
Gets the shape of the method parameter type.
public required ITypeShape<TParameter> ParameterType { get; init; }
Property Value
- ITypeShape<TParameter>
Position
Gets the 0-indexed position of the current method parameter.
public required int Position { get; init; }
Property Value
ReflectionInfoFactory
Gets the factory for retrieving the ParameterInfo or MemberInfo corresponding to the parameter.
public Func<ICustomAttributeProvider?>? ReflectionInfoFactory { get; init; }
Property Value
Setter
Gets the setter for the parameter.
public required Setter<TArgumentState, TParameter> Setter { get; init; }
Property Value
- Setter<TArgumentState, TParameter>