A strategy that defines how the value of an introduced constructor parameter is obtained in two contexts: (a) the framework-emitted forwarding constructor that preserves the pre-mutation signature when IntroduceParameter(IConstructor, string, IType, IPullStrategy?, ImmutableArray<AttributeConstruction>, IConstructorOverloadingStrategy?) introduces a required parameter; and (b) chained constructors (in the same class) and derived constructors (in the same project or in referencing projects) that must pass a value to the mutated base constructor. For standard implementations, see PullStrategy.
Namespace: Metalama.Framework.Advising
Assembly: Metalama.Framework.dll
Syntax
public interface IPullStrategy : ICompileTimeSerializableRemarks
When you introduce a parameter to a base constructor using IntroduceParameter(IAdviser<IConstructor>, string, IType, IPullStrategy?, ImmutableArray<AttributeConstruction>, IConstructorOverloadingStrategy?) or the corresponding extension methods in AdviserExtensions, this strategy determines how chained and derived constructors (plus the forwarding constructor, when one is emitted) obtain the value for the newly introduced parameter.
Cross-Project Operation: Pull strategies operate across project boundaries. Custom implementations must be serializable (implement ICompileTimeSerializable) because the strategy needs to be persisted and applied in projects that reference the project where the parameter was introduced. For example, if you introduce a parameter to a base class in Project A using IntroduceParameterAndPull(string?, IType?, IExpression?, IExpression?, bool, bool), and Project B references Project A and has derived classes, those derived classes will automatically have the parameter added to their constructors.
Methods
| Name | Description |
|---|---|
| GetPullAction(IParameter, IHasParameters) | Gets the PullAction that specifies how to obtain the value for an introduced parameter when it needs to be passed from a child constructor to the constructor where it was introduced. |