Open sandboxFocus

Struct PullAction

Represents a way to pull a constructor parameter value from child constructors when propagating introduced parameters.

Namespace: Metalama.Framework.Advising
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public readonly struct PullAction
Remarks

When a parameter is introduced to a constructor using IntroduceParameter(IAdviser<IConstructor>, string, IType, IPullStrategy?, ImmutableArray<AttributeConstruction>, IConstructorOverloadingStrategy?), child constructors (those that call the modified constructor via : base(...) or : this(...)) need to provide a value for this new parameter. A PullAction specifies how to obtain that value.

Common scenarios:

<ul><li><xref href="Metalama.Framework.Advising.PullAction.None" data-throw-if-not-resolved="false"></xref> - Use the default value of the introduced parameter</li><li><xref href="Metalama.Framework.Advising.PullAction.UseExistingParameter(Metalama.Framework.Code.IParameter)" data-throw-if-not-resolved="false"></xref> - Forward an existing parameter from the child constructor</li><li><xref href="Metalama.Framework.Advising.PullAction.IntroduceParameterAndPull(System.String%2cMetalama.Framework.Code.IType%2cMetalama.Framework.Code.IExpression%2cMetalama.Framework.Code.IExpression%2cSystem.Collections.Immutable.ImmutableArray%7bMetalama.Framework.Code.DeclarationBuilders.AttributeConstruction%7d%2cSystem.Boolean)" data-throw-if-not-resolved="false"></xref> - Add a new parameter to the child constructor and forward its value</li><li><xref href="Metalama.Framework.Advising.PullAction.UseExpression(Metalama.Framework.Code.IExpression)" data-throw-if-not-resolved="false"></xref> - Pass a custom expression (e.g., a constant or field access)</li></ul></p>

Properties

Name Description
Expression

Gets the expression to use for pulling the dependency when UseExpression(IExpression) or UseConstant(TypedConstant) is used.

None

Gets a PullAction that means that the dependency has to be set to its default value.

Methods

Name Description
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.

UseConstant(TypedConstant)

Creates a PullAction that means that the dependency should be assigned to a given TypedConstant.

UseExistingParameter(IParameter)

Creates a PullAction that means that the dependency should be pulled from an existing constructor parameter.

UseExpression(IExpression)

Creates a PullAction that means that the dependency should be assigned to a given IExpression.

See Also