Skip to content

NDLRGEN058: Record constructor-overload type shape is unsupported

Cause

[RecordConstructorOverloadParameter] is used outside a supported top-level partial positional record class.

Rule Description

Ordinary classes, record structs, body-only records, file-local records, nested records, and inherited records cannot use this feature. A positional record whose primary constructor declares a pointer-typed parameter is also unsupported, because the generated file is not compiled in an unsafe context.

How to Fix

// WRONG
public partial class Request
{
    [RecordConstructorOverloadParameter]
    public int Revision { get; init; }
}
// CORRECT
public partial record Request(string Name)
{
    [RecordConstructorOverloadParameter]
    public int Revision { get; init; }
}

Use [GenerateConstructor] for field-derived constructors on ordinary partial classes.

See Also