Open sandboxFocus
  • TOC

Metalama Documentation

Getting started

Conceptual documentation

Commented examples

API documentation

Aspect API

Metalama.​Framework.​Advising

Metalama.​Framework.​Aspects

Metalama.​Framework.​Code

Metalama.​Framework.​Code.​Collections

Metalama.​Framework.​Code.​Comparers

Metalama.​Framework.​Code.​Declaration­Builders

Metalama.​Framework.​Code.​Invokers

Metalama.​Framework.​Code.​Syntax­Builders

Metalama.​Framework.​Code.​Types

Metalama.​Framework.​Diagnostics

Metalama.​Framework.​Eligibility

Metalama.​Framework.​Fabrics

Metalama.​Framework.​Metrics

Metalama.​Framework.​Options

Metalama.​Framework.​Project

Metalama.​Framework.​Run­Time

Metalama.​Framework.​Serialization

Metalama.​Framework.​Services

Metalama.​Framework.​Utilities

Extensions API

Patterns API

Flashtrace API

Introspection API

Advanced API

Post­Sharp API migration

  • Article

Method ImplementInterface

ImplementInterface(IAdviser<INamedType>, INamedType, OverrideStrategy, object?)

Makes a type implement a new interface specified as an INamedType. Interface members can be introduced declaratively by marking an aspect member by InterfaceMemberAttribute or IntroduceAttribute, or programmatically using Introduce methods for public implementations of result.ExplicitImplementations.Introduce for private implementations. Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to another declaration than the current one.

Declaration
public static IImplementInterfaceAdviceResult ImplementInterface(this IAdviser<INamedType> adviser, INamedType interfaceType, OverrideStrategy whenExists = OverrideStrategy.Default, object? tags = null)
Parameters
Type Name Description
IAdviser<INamedType> adviser

An adviser for a named type.

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 or programmatically.

Returns
Type Description
IImplementInterfaceAdviceResult
See Also

ImplementInterface(IAdviser<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 or programmatically using Introduce methods. Use the With<TNewDeclaration>(TNewDeclaration) method to apply the advice to another declaration than the current one.

Declaration
public static IImplementInterfaceAdviceResult ImplementInterface(this IAdviser<INamedType> adviser, Type interfaceType, OverrideStrategy whenExists = OverrideStrategy.Default, object? tags = null)
Parameters
Type Name Description
IAdviser<INamedType> adviser

An adviser for a named type.

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 or programmatically.

Returns
Type Description
IImplementInterfaceAdviceResult
See Also