ICompositeType.PrimaryConstructor Property

Namespace
Kampute.DocToolkit.Metadata
Assembly
  • Kampute.DocToolkit.dll

Definition

Gets the primary constructor of the type if it is a positional record.
IConstructor PrimaryConstructor { get; }
This property has a default implementation in the interface.

Property Value

IConstructor
The constructor whose parameters form the parameter list of the record declaration, or null if the type is not a positional record or its primary constructor cannot be identified.

Remarks

Metadata does not mark a constructor as primary. The primary constructor is identified as the user-declared constructor whose parameters match, by position, name, and type, the parameters of the Deconstruct method that the compiler synthesizes for a positional record. Therefore, this property is null for a record without a parameter list, and for a positional record whose Deconstruct method is declared in source code.