Open sandboxFocus

Method ImplementInterface

ImplementInterface(INamedType, INamedType, OverrideStrategy, object?)

Makes a type implement a new interface specified as an INamedType. Interface members can be introduced by marking an aspect member by InterfaceMemberAttribute, IntroduceAttribute(IDeclaration, IAttributeData, OverrideStrategy) or programmatically using Introduce methods.

Declaration
IImplementInterfaceAdviceResult ImplementInterface(INamedType targetType, INamedType interfaceType, OverrideStrategy whenExists = OverrideStrategy.Default, object? tags = null)
Parameters
Type Name Description
INamedType targetType

The type that must implement the new interface.

INamedType interfaceType

The type of the implemented interface.

OverrideStrategy whenExists

Determines the implementation strategy when the interface is already implemented by the target type. The default strategy is to fail with a compile-time error.

object tags

An optional opaque object of anonymous type passed to InterfaceMemberAttribute templates and exposed under the Tags property of the meta API. This parameter does not affect members introduced using IntroduceAttribute(IDeclaration, IAttributeData, OverrideStrategy) or programmatically.

Returns
Type Description
IImplementInterfaceAdviceResult
See Also

ImplementInterface(INamedType, Type, OverrideStrategy, object?)

Makes a type implement a new interface specified as a reflection Type. Interface members can be introduced by marking an aspect member by InterfaceMemberAttribute, IntroduceAttribute(IDeclaration, IAttributeData, OverrideStrategy) or programmatically using Introduce methods.

Declaration
IImplementInterfaceAdviceResult ImplementInterface(INamedType targetType, Type interfaceType, OverrideStrategy whenExists = OverrideStrategy.Default, object? tags = null)
Parameters
Type Name Description
INamedType targetType

The type that must implement the new interface.

Type interfaceType

The type of the implemented interface.

OverrideStrategy whenExists

Determines the implementation strategy when the interface is already implemented by the target type. The default strategy is to fail with a compile-time error.

object tags

An optional opaque object of anonymous type passed to InterfaceMemberAttribute templates and exposed under the Tags property of the meta API. This parameter does not affect members introduced using IntroduceAttribute(IDeclaration, IAttributeData, OverrideStrategy) or programmatically.

Returns
Type Description
IImplementInterfaceAdviceResult
See Also