Allows generating run-time code that invokes a method when you have its compile-time IMethod representation.
Namespace: Metalama.Framework.Code.Invokers
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IMethodInvokerRemarks
Invokers are APIs that allow you to generate run-time code from compile-time declarations. When you have an IMethod object (a compile-time representation of a method), you can use its invoker methods to create IExpression objects that represent method calls. 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(params IEnumerable<IExpression>) returns an IExpression for use in compile-time APIs.
Use WithObject(dynamic?) to specify the target instance and WithOptions(InvokerOptions) to control nullability behavior and
which implementation layer (base, current, or final) to invoke.
The invoker API is not type-safe. It will generate code even with mismatched argument types, which will only be caught when the transformed code is compiled. Always verify that generated code matches actual member signatures.
Methods
| Name | Description |
|---|---|
| CreateInvokeExpression(params IEnumerable<IExpression>) | Creates an IExpression that represents the invocation of the method with specific arguments represented by IExpression objects. |
| CreateInvokeExpression(params IEnumerable<dynamic?>) | Creates an IExpression that represents the invocation of the method with specific arguments represented by C# expressions. |
| Invoke(IEnumerable<IExpression>) | Generates run-time code that invokes the current method with a given list of argument expressions. |
| Invoke(params dynamic?[]) | Generates run-time code that invokes the current method with a given list of arguments. |
| With(InvokerOptions) | |
| With(dynamic?, InvokerOptions) | |
| WithObject(IExpression?) | Gets an IMethodInvoker for the same method but with a different object, provided as an IExpression. |
| WithObject(dynamic?) | Gets an IMethodInvoker for the same method but with a different object, provided as a C# expression. |
| WithOptions(InvokerOptions) | Gets an IMethodInvoker for the same method and target with different options. |