IntroduceConversionOperator(INamedType, string, IType, IType, bool, bool, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
Introduces a new conversion operator or overrides the implementation of the existing one.
Declaration
IIntroductionAdviceResult<IMethod> IntroduceConversionOperator(INamedType targetType, string template, IType fromType, IType toType, bool isImplicit = false, bool isChecked = false, 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 conversion 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 | fromType | The source type of the conversion. |
| IType | toType | The target type of the conversion. |
| bool | isImplicit |
|
| bool | isChecked |
|
| OverrideStrategy | whenExists | Determines the implementation strategy when a conversion 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 conversion operator. |