IntroduceRecord(INamespaceOrNamedType, string, RecordKind, OverrideStrategy, Action<IRecordBuilder>?)
Introduces a new record to the target namespace or type.
Declaration
IIntroductionAdviceResult<INamedType> IntroduceRecord(INamespaceOrNamedType targetNamespaceOrType, string name, RecordKind recordKind = RecordKind.Class, OverrideStrategy whenExists = OverrideStrategy.Default, Action<IRecordBuilder>? buildRecord = null)Parameters
| Type | Name | Description |
|---|---|---|
| INamespaceOrNamedType | targetNamespaceOrType | The namespace or type into which the record must be introduced. |
| string | name | The name of the introduced record. |
| RecordKind | recordKind | Whether the record is a record class or a record struct. The default is a record class. |
| 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<IRecordBuilder> | buildRecord | An optional callback that allows you to configure the introduced record, such as adding positional parameters, members, base types, 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 record. The IIntroductionAdviceResult<T> interface itself implements IAdviser<T> and can be used to introduce members to the record. |