Roslyn: 'Add parameter to method' Quick Action can add wrong parameter

Created on 14 Oct 2019  路  2Comments  路  Source: dotnet/roslyn

_This issue has been moved from a ticket on Developer Community._


The 'Add parameter' Quick Action can add the wrong parameter in specific situations.
For instance, this will happen when an existing parameter accepts a base class of the passed argument type.
Is this behaviour by design, or can this be fixed/improved?

Here is some code sample to reproduce the problem:

class BaseClass { }

class MyClass : BaseClass
{
    void TestFunc()
    {
        MyClass param1 = new MyClass();
        int newparam = 1;

// The 'Add parameter' Quick Action on the following method call adds the wrong parameter.
        // It should add an 'int newparam' parameter.
        // But instead it adds a 'MyClass param11' parameter.
        MyFunc(param1, newparam);
    }

void MyFunc(BaseClass param1) { }
}


Original Comments

Visual Studio Feedback System on 10/10/2019, 08:06 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

Area-IDE Bug Developer Community

Most helpful comment

Seems just like a bug to me.

All 2 comments

I have reproduced the issue. @CyrusNajmabadi do you know if it is by design or just a bug?

Seems just like a bug to me.

Was this page helpful?
0 / 5 - 0 ratings