Allows generating run-time code that invokes a constructor when you have its compile-time IConstructor representation.
Namespace: Metalama.Framework.Code.Invokers
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IConstructorInvokerRemarks
Invokers are APIs that allow you to generate run-time code from compile-time declarations. When you have an IConstructor object (a compile-time representation of a constructor), you can use its invoker methods to create IObjectCreationExpression objects that represent object instantiation. These expressions can then be used in templates and will be expanded into actual C# code.
The Invoke(params dynamic?[]) method returns a dynamic value that can be used directly in template code, while
CreateInvokeExpression() and its overloads return an IObjectCreationExpression for use in compile-time APIs.
Unlike other invokers, constructors do not support WithObject or WithOptions since they always create new instances
and do not have implementation layers or nullability concerns in the same way as member access.
Methods
| Name | Description |
|---|---|
| CreateInvokeExpression() | Creates an IExpression that represents the invocation of constructor without arguments. |
| CreateInvokeExpression(params IEnumerable<IExpression>) | Creates an IExpression that represents the invocation of constructor, where arguments are represented by IExpression. |
| CreateInvokeExpression(params dynamic?[]) | Creates an IExpression that represents the invocation of constructor, where arguments are passed as C# expressions. |
| Invoke(IEnumerable<IExpression>) | Generates run-time code that invokes the current constructor with a given list of argument expressions. |
| Invoke(params dynamic?[]) | Generates run-time code that invokes the current constructor with a given list of arguments. |