Open sandboxFocus

Method IntroduceStruct

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

Introduces a new struct to the target namespace or type.

Declaration
IIntroductionAdviceResult<INamedType> IntroduceStruct(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 struct must be introduced.

string name

The name of the introduced struct.

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 struct, such as adding members, implemented 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 struct. The IIntroductionAdviceResult<T> interface itself implements IAdviser<T> and can be used to introduce members to the type.