Skip to content

GenerateOverride should sometimes add where T : default constraint #53012

@jcouv

Description

@jcouv

As the screenshot below illustrates, if you start with a virtual method void M<T>(T? t) and generate an override for it in some other type, the generated override doesn't have any type parameter constraints, but that results in compilation errors.
We should generate a where T : default constraint, which tells the compiler that T? in the override doesn't mean System.Nullable<T>.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions