IntroduceBinaryOperator(INamedType, string, IType, IType, IType, OperatorKind, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
Introduces a new binary operator or overrides the implementation of the existing one.
Declaration
IIntroductionAdviceResult<IMethod> IntroduceBinaryOperator(INamedType targetType, string template, IType leftType, IType rightType, 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 binary 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 | leftType | The type of the operator's left-hand parameter. |
| IType | rightType | The type of the operator's right-hand parameter. |
| IType | resultType | The return type of the operator. |
| OperatorKind | kind | The kind of binary operator to introduce (e.g., Addition, Multiplication, ...). |
| OverrideStrategy | whenExists | Determines the implementation strategy when a binary 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 binary operator. |