IntroduceExtensionBlock(INamedType, IType, string?, Action<IExtensionBlockBuilder>?)
Introduces a new extension block into a static class. Extension blocks allow adding extension members (methods, properties, indexers) to a type (represented as an IType). Requires C# 14+ and Roslyn 5.0+.
Declaration
IIntroductionAdviceResult<IExtensionBlock> IntroduceExtensionBlock(INamedType targetStaticClass, IType receiverType, string? receiverParameterName = null, Action<IExtensionBlockBuilder>? buildExtensionBlock = null)Parameters
| Type | Name | Description |
|---|---|---|
| INamedType | targetStaticClass | The static class into which the extension block must be introduced. Only static classes can contain extension blocks. |
| IType | receiverType | The type being extended. Members introduced into this extension block will appear as members of this type. |
| string | receiverParameterName | The name of the receiver parameter. Set to |
| Action<IExtensionBlockBuilder> | buildExtensionBlock | An optional callback that allows you to configure the extension block, such as adding type parameters or attributes to the receiver parameter. |
Returns
| Type | Description |
|---|---|
| IIntroductionAdviceResult<IExtensionBlock> | An IIntroductionAdviceResult<T> representing the result of the advice. The Declaration property provides access to the introduced extension block. The result also implements IAdviser<T> and can be used to introduce members. |
IntroduceExtensionBlock(INamedType, Type, string?, Action<IExtensionBlockBuilder>?)
Introduces a new extension block into a static class. Extension blocks allow adding extension members (methods, properties, indexers) to a type (represented as a Type). Requires C# 14+ and Roslyn 5.0+.
Declaration
IIntroductionAdviceResult<IExtensionBlock> IntroduceExtensionBlock(INamedType targetStaticClass, Type receiverType, string? receiverParameterName = null, Action<IExtensionBlockBuilder>? buildExtensionBlock = null)Parameters
| Type | Name | Description |
|---|---|---|
| INamedType | targetStaticClass | The static class into which the extension block must be introduced. |
| Type | receiverType | The Type being extended. |
| string | receiverParameterName | The name of the receiver parameter. Set to |
| Action<IExtensionBlockBuilder> | buildExtensionBlock | An optional callback to configure the extension block. |
Returns
| Type | Description |
|---|---|
| IIntroductionAdviceResult<IExtensionBlock> |