AddBaseArgument(IExpression, string?)
Adds an argument that the record passes to the primary constructor of its base record, which the language
writes in the base list of the declaration, as in record Derived( int X ) : BaseRecord( X ).
Declaration
void AddBaseArgument(IExpression argument, string? parameterName = null)Parameters
| Type | Name | Description |
|---|---|---|
| IExpression | argument | The expression to pass as an argument. A positional parameter of the record is
referenced through the IParameterBuilder that |
| string | parameterName | The optional name of the parameter of the base constructor to which the argument
is assigned. When |
Remarks
A record class that derives from a record whose only constructor is a primary constructor must pass arguments to it, and the compiler reports CS1729 on the generated declaration when it does not.
Set BaseType before calling this method. The method throws a NotSupportedException on a record struct, which has no base list, and an InvalidOperationException when the base type is still object.