IntroduceUnaryOperator(INamedType, string, IType, IType, OperatorKind, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
Introduces a new unary operator or overrides the implementation of the existing one.
Declaration
IIntroductionAdviceResult<IMethod> IntroduceUnaryOperator(INamedType targetType, string template, IType inputType, IType resultType, OperatorKind kind, OverrideStrategy whenExists = OverrideStrategy.Default, Action<IMethodBuilder>? buildOperator = null, object? args = null, object? tags = null)Parameters
| Type | Name | Description |
|---|---|---|
| INamedType | targetType | The type into which the unary operator must be introduced. |
| string | template | Name of the method of the aspect class that will be used as a template for the introduced operator. This method must be annotated with TemplateAttribute. |
| IType | inputType | The type of the operator's input parameter. |
| IType | resultType | The return type of the operator. |
| OperatorKind | kind | The kind of unary operator to introduce (e.g., UnaryPlus, UnaryNegation). |
| OverrideStrategy | whenExists | Determines the implementation strategy when a unary operator of the same signature is already declared in the target type. The default strategy is to fail with a compile-time error. |
| Action<IMethodBuilder> | buildOperator | An optional callback that allows you to configure the introduced operator method, such as adding custom attributes. |
| object | args | An object (typically of anonymous type) whose properties map to parameters or type parameters of the template method. |
| object | tags | An optional opaque object of anonymous type passed to the template method and exposed under the Tags property of the meta API. |
Returns
| Type | Description |
|---|---|
| IIntroductionAdviceResult<IMethod> | An IIntroductionAdviceResult<T> representing the result of the advice. The Declaration property provides access to the introduced unary operator. |