The entry point for the T# template language, providing compile-time APIs to inspect and transform target code.
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public static class metaRemarks
The meta class is a pseudo-keyword that serves as the gateway to Metalama's meta-programming capabilities.
It can only be used within the context of a T# template method (methods marked with TemplateAttribute).
Key capabilities provided by meta:
- Target access:Target provides metadata about the declaration being overridden or introduced
- Execution flow:Proceed() invokes the original implementation in override scenarios
- Dynamic typing:This, Base, ThisType, BaseType for accessing members dynamically
- State sharing:Tags to access data passed from BuildAspect(IAspectBuilder<T>)
- Code generation:InsertStatement(IStatement), InsertComment(params string?[]), Return() for injecting code
- Type coercion:CompileTime<T>(T?) and RunTime<T>(T?) to control compile-time/run-time interpretation
- Template invocation:InvokeTemplate(string, ITemplateProvider?, object?) for calling auxiliary templates
In T# templates, expressions beginning with meta. are evaluated at compile-time to generate run-time code.
The T# compiler separates compile-time portions from run-time portions using inference rules, with meta
serving as the marker for compile-time expressions.
Properties
| Name | Description |
|---|---|
| AspectInstance | Gets the current IAspectInstance, which gives access to the Predecessors and the SecondaryInstances of the current aspect. |
| Base | Gets a |
| BaseType | Gets a |
| Receiver | Gets a |
| Tags | Gets the dictionary of tags that were passed to the IAdviceFactory method by the BuildAspect(IAspectBuilder<T>) method. |
| Target | Gets access to the declaration being overridden or introduced. |
| This | Gets a |
| ThisType | Gets a |
Methods
| Name | Description |
|---|---|
| Cast(IType, dynamic?) | Generates the cast syntax for the specified type. |
| CompileTime<T>(T?) | Coerces an |
| DebugBreak() | Requests the debugger to break, if any debugger is attached to the current process. |
| Default(IType) | Generates the |
| Default(SpecialType) | Generates the |
| Default(Type) | Generates the |
| DefineLocalVariable(string, IExpression) | Programmatically defines a local variable in run-time code with a type inferred from the initial value expression. |
| DefineLocalVariable(string, IType) | Programmatically defines a local variable in run-time code with a specified type but no initial value. |
| DefineLocalVariable(string, IType, IExpression?) | Programmatically defines a local variable in run-time code with a specified type and initial value expression. |
| DefineLocalVariable(string, IType, dynamic) | Programmatically defines a local variable in run-time code with a specified type and initial value. |
| DefineLocalVariable(string, dynamic) | Programmatically defines a local variable in run-time code with a type inferred from the initial value. |
| DefineLocalVariable(string, Type) | Programmatically defines a local variable in run-time code with a specified reflection type but no initial value. |
| DefineLocalVariable(string, Type, IExpression?) | Programmatically defines a local variable in run-time code with a specified reflection type and initial value expression. |
| DefineLocalVariable(string, Type, dynamic) | Programmatically defines a local variable in run-time code with a specified reflection type and initial value. |
| InsertComment(params string?[]) | Injects a comment to the target code. |
| InsertStatement(IExpression) | Inserts a statement into the target code, where the statement is given as an IExpression. Note that not all expressions can be used as statements. |
| InsertStatement(IStatement) | Inserts a statement into the target code, where the statement is given as an IStatement. |
| InsertStatement(string) | Inserts a statement into the target code, where the statement is given as a string. Calling this overload is equivalent to calling the InsertStatement(IStatement) overload with the result of the Parse(string) method. |
| InvokeTemplate(TemplateInvocation, object?) | Calls another template method. |
| InvokeTemplate(string, ITemplateProvider?, object?) | Calls another template method. This overload accepts an ITemplateProvider. |
| InvokeTemplate(string, TemplateProvider, object?) | Calls another template method. This overload accepts a TemplateProvider. |
| Proceed() | Invokes the logic that has been overwritten. For instance, in an OverrideMethodAspect, calling Proceed() invokes the method being overridden. Note that the way how the logic is invoked (as a method call or inlining) is considered an implementation detail. |
| ProceedAsync() | Synonym to Proceed(), but the return type is exposed as a |
| ProceedAsyncEnumerable() | |
| ProceedAsyncEnumerator() | |
| ProceedEnumerable() | Synonym to Proceed(), but the return type is exposed as a |
| ProceedEnumerator() | Synonym to Proceed(), but the return type is exposed as a |
| Return() | Inserts a |
| Return(dynamic?) | Inserts a |
| RunTime<T>(T?) | Converts a compile-value into run-time value by serializing the compile-time value into a some syntax that will evaluate, at run time, to the same value as at compile time. |