IntroduceParameterAndPull(string, IType, IExpression?, IExpression?, ImmutableArray<AttributeConstruction>, bool)
Creates a PullAction that means that the dependency should be pulled from a new parameter of the calling constructor.
Declaration
public static PullAction IntroduceParameterAndPull(string parameterName, IType parameterType, IExpression? parameterDefaultValue, IExpression? forwarderExpression = null, ImmutableArray<AttributeConstruction> parameterAttributes = default, bool materializeOnRecord = false)Parameters
| Type | Name | Description |
|---|---|---|
| string | parameterName | Name of the new parameter. |
| IType | parameterType | Type of the new parameter. |
| IExpression | parameterDefaultValue | Optional default value for the new parameter. Must be a compile-time constant
(or |
| IExpression | forwarderExpression | Optional expression to pass for the introduced parameter in the framework-emitted
forwarding constructor (the stub that preserves the pre-mutation signature when the required-parameter overload
is used). Unlike |
| ImmutableArray<AttributeConstruction> | parameterAttributes | Optional attributes to apply to the new parameter. |
| bool | materializeOnRecord | When |
Returns
| Type | Description |
|---|---|
| PullAction | A PullAction that introduces a new parameter and pulls from it. |
Remarks
This action propagates the parameter requirement to child constructors. A new parameter with the specified name, type, and default value will be added to each child constructor, and its value will be passed to the base/this constructor.
Cross-Project Support: This pull action operates across project boundaries. When a parameter is introduced to a base class in one project, all derived classes in referencing projects will automatically have the parameter added to their constructors. This makes it ideal for framework-level dependency injection.
This is the most common pull action for dependency injection scenarios where derived classes should also receive and forward the dependency.