Skip to content

"Add parameters to constructor" context action should maintain constructor parameter wrapping #49040

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


When adding a new field/property to a class, the "Add parameters to constructor" context action is very useful (especially when designing the class for DI). However, it does not maintain parameter wrapping of the constructor. For example:

Before:

private readonly MyType1 _myThing1;
private readonly MyType2 _myThing2;
private readonly MyType3 _myThing3;

public MyClass(
    MyType1 myThing1,
    MyType2 myThing2,
    MyType3 myThing3)
{
    _myThing1 = myThing1;
    _myThing2 = myThing2;
    _myThing3 = myThing3;
}

After adding _myThing4 and using the "Add parameters to constructor" context action:

private readonly MyType1 _myThing1;
private readonly MyType2 _myThing2;
private readonly MyType3 _myThing3;
private readonly MyType4 _myThing4;

public MyClass(
    MyType1 myThing1,
    MyType2 myThing2,
    MyType3 myThing3, MyType4 myThing4)
{
    _myThing1 = myThing1;
    _myThing2 = myThing2;
    _myThing3 = myThing3;
    _myThing4 = myThing4;
}

As such, when using "Add parameters to constructor", I must always navigate to the constructor and add a new line.


Original Comments

Feedback Bot on 10/28/2020, 01:29 AM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.

Metadata

Metadata

Assignees

No one assigned

    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