Open sandboxFocus

Method IntroduceInterface

IntroduceInterface(INamespaceOrNamedType, string, OverrideStrategy, Action<INamedTypeBuilder>?)

Introduces a new interface to the target namespace or type.

Declaration
IIntroductionAdviceResult<INamedType> IntroduceInterface(INamespaceOrNamedType targetNamespaceOrType, string name, OverrideStrategy whenExists = OverrideStrategy.Default, Action<INamedTypeBuilder>? buildType = null)
Parameters
Type Name Description
INamespaceOrNamedType targetNamespaceOrType

The namespace or type into which the interface must be introduced.

string name

The name of the introduced interface.

OverrideStrategy whenExists

Determines the implementation strategy when a type of the same name is already declared in the target namespace or type. The default strategy is to fail with a compile-time error.

Action<INamedTypeBuilder> buildType

An optional callback that allows you to configure the introduced interface, such as adding members, base interfaces, or custom attributes.

Returns
Type Description
IIntroductionAdviceResult<INamedType>

An IIntroductionAdviceResult<T> representing the result of the advice. The Declaration property provides access to the introduced interface. The IIntroductionAdviceResult<T> interface itself implements IAdviser<T> and can be used to introduce members to the type.