dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.12k stars 4.04k forks source link

No second level autocompletion before await #24538

Open miloush opened 6 years ago

miloush commented 6 years ago

Version Used: 15.6.0 Preview 3 / 2.7.0.62518

Steps to Reproduce:

using System;
using System.Threading.Tasks;

class Program
{
    Task Thing;

    static void Main()
    {
        Func<Program, Task> f = async (program) =>
        {
            program.Thing.|

            await program.Thing;
        };
    }
}

(This is a stand-alone repro of what ASP.NET Core project template generates.)

Expected Behavior: Autocompletion list after typing the dot before await.

Actual Behavior: No intellisense. Commenting the await line brings it back.

CyrusNajmabadi commented 6 years ago

This looks like classic parsing ambiguity caused by 'await' being a legal name. "program.Thing.await" is a legal type name, so it looks like the declaration of a variable called "program.Thing.await program".

There is code both in the parser and in the IDE to try to detect these cases and do the right thing. But it's tricky to get right and things like this fall out.

CyrusNajmabadi commented 6 years ago

https://github.com/dotnet/roslyn/blob/master/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs#L6733 Is the code on teh compiler side to try to deal with this.

And https://github.com/dotnet/roslyn/blob/master/src/Workspaces/CSharp/Portable/Recommendations/CSharpRecommendationService.cs#L310 is the IDE code to try to handle it.