WithExecutionContext(ICompilation, string?)
Switches the execution context to a test context for a given ICompilation, enabling APIs such as ExpressionFactory to work correctly.
Declaration
public IDisposable WithExecutionContext(ICompilation compilation, string? description = null)Parameters
| Type | Name | Description |
|---|---|---|
| ICompilation | compilation | The compilation to use as the execution context. |
| string | description | An optional description for diagnostics. |
Returns
| Type | Description |
|---|---|
| IDisposable | An IDisposable that restores the previous execution context when disposed. |
Remarks
Some Metalama APIs require an active execution context. In normal aspect execution, this context is set automatically. In unit tests, you must explicitly set it using this method before calling such APIs.