RedirectToSynthesizedMethod(string)
Redirects the calls to a method synthesized from the template of the given name.
Declaration
ITemplateInterception RedirectToSynthesizedMethod(string template)Parameters
| Type | Name | Description |
|---|---|---|
| string | template | The name of the template. |
Returns
| Type | Description |
|---|---|
| ITemplateInterception |
Remarks
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
RedirectToSynthesizedMethod(in MethodTemplateSelector)
Redirects the calls to a method synthesized from a template given as a MethodTemplateSelector.
Declaration
ITemplateInterception RedirectToSynthesizedMethod(in MethodTemplateSelector template)Parameters
| Type | Name | Description |
|---|---|---|
| MethodTemplateSelector | template | The template. |
Returns
| Type | Description |
|---|---|
| ITemplateInterception |
Remarks
The options of the synthesized method are set on the returned ITemplateInterception. By default, the method is
synthesized in the class MetalamaInterceptors, with the Global granularity, so that it is
shared by all the call sites that have the same template, arguments, tags and signature. The template is then expanded once, for the
representative call site and with its aspect instance, as described in InterceptorGranularity.
When the template has run-time type parameters, they bind to the type parameters of the intercepted method, and the synthesized method is generic over them, so that calls with different type arguments share it. Otherwise, the synthesized method is specialized for the type arguments of the call site, which the compile-time parameters of the template can receive through WithArgs(object).
The run-time parameters of the template bind to the parameters of the synthesized method by name, or else by position after the receiver
parameter. A run-time parameter that binds to no parameter and has a default value receives its default value. The template reads the
description of the interception through meta.Interception.
The synthesized methods and classes are not visible in the code model to aspects, in any stage of the pipeline, and they are not in the code that the IDE generates, because they are added when the code is linked, after all aspects have executed.
RedirectToSynthesizedMethod(TemplateInvocation)
Redirects the calls to a method synthesized from a template given as a TemplateInvocation, which also gives the arguments and the template provider.
Declaration
ITemplateInterception RedirectToSynthesizedMethod(TemplateInvocation template)Parameters
| Type | Name | Description |
|---|---|---|
| TemplateInvocation | template | The template, its arguments and its provider. |
Returns
| Type | Description |
|---|---|
| ITemplateInterception |
Remarks
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|