roslyn: Writing code to call a function using identifiers that don’t exist yet.

Source: Scenario 1 at https://developercommunity.visualstudio.com/content/problem/465732/vs-2019-preview-3-intellisense-auto-selecting-para.html

Writing code to call a function using identifiers that don’t exist yet.

class Program
{
    static void Main ( string[] args )
    {
        var mySvc = new MyService(10, otherSvc, $$);
    }        
}

class MyService
{
    public MyService (int id, OtherService otherService, string name)
    {
    }
}

class OtherService
{
}

In this scenario I’ve just put the comma in the call to new MyService in Main. I now enter a variable name name that doesn’t exist yet. As soon as you hit space or a dot (because this is an object) then IS autocompletes to the name: parameter name. This isn’t what I wanted so I have to stop my typing, go back and correct to the variable (I haven’t defined yet) and then continue typing. In VS 2017 it doesn’t autocomplete to the parameter name. It does recognize that the parameter name is the best choice, it just doesn’t auto complete it.

Expected by user var mySvc = new MyService(10, otherSvc, name); Actual var mySvc = new MyService(10, otherSvc, name:); The behavior is the same with the old completion and the new completion. It seems it is caused by https://github.com/dotnet/roslyn/pull/26764

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

I still hit this all the time.