dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 654 forks source link

Intellisense does not correctly scope enum values in method parameters #4001

Open andymads opened 3 years ago

andymads commented 3 years ago

Issue Description

If I use intellisense to fill in an enum method parameter it does not add the class before the enum.

Steps to Reproduce

Invoke intellisense to auto fill the enum parameter

Expected Behavior

SomeMethod(SomeClass.SomeEnum.SomeValue);// Ok

Actual Behavior

SomeMethod(SomeEnum.SomeValue);// Compile error

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.48.0 C# Extension: 1.23.0

Mono Information OmniSharp using global mono :6.6.0
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.101 Commit: b377529961 Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.101/ Host (useful for support): Version: 3.1.1 Commit: a1388f194c .NET Core SDKs installed: 2.1.302 [/usr/local/share/dotnet/sdk] 2.2.104 [/usr/local/share/dotnet/sdk] 3.1.101 [/usr/local/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |azure-account|ms-vscode|0.9.2| |binary-plist|dnicolson|0.4.0| |csharp|ms-dotnettools|1.23.0| |playfab-explorer|Playfab|0.1.11| |quicktype|quicktype|12.0.46| |syntax-project-pbxproj|mariomatheu|0.1.3| |unity-debug|Unity|2.7.5| |vscode-azurefunctions|ms-azuretools|0.23.0|;

om your clipboard

JoeRobich commented 3 years ago

@333fred Does new the completion implementation handle this case?

333fred commented 3 years ago

I don't think I understand this question. @andymads can you please provide a complete repro? Namely, full steps to reproduce the issue you're seeing.

andymads commented 3 years ago

When using ctrl-space Intellisense is suggesting SomeEnum but it should be SomeClass.SomeEnum. If I accept the suggestion then I have to prefix it with SomeClass manually before the enum value suggestion will work.

Screenshot 2020-08-24 at 18 20 36

Screenshot 2020-08-24 at 18 27 48

public class SomeClass
{
    public enum SomeEnum
    {
        Item1,
    }

    static public void SomeMethod(SomeEnum e)
    {
    }
}
333fred commented 3 years ago

Ah, I see. @JoeRobich I'd have to test it but I don't believe the new completion changes will fix this. Because we can't do async completion around the current cursor location, we can't lazily resolve the necessary SomeClass. prefix here unless we were to call GetChangeAsync on every single completion item up front, which would be expensive. /cc @dibarbet as another case to consider for Roslyn's LSP provider.