Skip to content

Fixing CS7036 (generate constructor based on base class) should give an option to use Primary Constructor #74602

Open
@CyrusNajmabadi

Description

Discussed in #74598

Originally posted by datvm July 30, 2024
I am not sure if this is a duplicate because I think this is a very popular scenario. Assume we have this code:

class BaseClass(CancellationToken ct)
{

}

class DerivedClass : BaseClass
{
}

VS would suggest to "Generate constructor 'DerivedClass(ct)'":

image

After that, VS continues to suggest to use Primary Constructor instead which gives this code:

class DerivedClass(CancellationToken ct) : BaseClass(ct)
{
}

I think the analyzer should merge the two steps into one?

Metadata

Assignees

No one assigned

    Labels

    Area-IDEFeature Requesthelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    • Status

      InQueue

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions