IntelliSense doesn't work in Visual Studio Code on Mac

会有一股神秘感。 提交于 2019-12-08 09:41:38

问题


I am using Visual Studio Code to develop an ASP.NET 5 application on Mac. The issue I am having is that I don't get any IntelliSense support (e.g. available class methods) beyond simple autocomplete for methods and variables names that I previously typed.

The app targets DNX Core 5.0:

"frameworks": {
    "dnxcore50": { }
},

And I have CoreCLR 1.0.0-rc1-update1 installed via DNVM:

$dnvm list

Active Version Runtime Architecture OperatingSystem Alias

------ ------- ------- ------------ --------------- -----

  • 1.0.0-rc1-update1 coreclr x64 darwin default

I tried the following to resolve the issue, but with no luck:

  • Made sure that a project is selected (fire icon in the bottom right corner)
  • Explicitly turned suggestions in settings.json

    {
        "editor.quickSuggestions": true`
    }
    

Any suggestions will be much appreciated.


回答1:


In short, the problem was that, while I had Mono installed on my machine, I didn't have DNX Mono. Installing it via DNVM locally (dnvm upgrade -r mono) resolved the issue and now I am having nice IntelliSense support in Visual Studio Code.

Now the long story.

Visual Studio Code uses OmniSharp to provide IntelliSense support. OmniSharp is a set of tools that provides C# code analysis services through a Nancy-based web API that runs on your machine (great posts on it here and here).

I didn't not get any IntelliSense because OmniSharp ran with errors which I could have easily caught if I paid more attention to Visual Studio Code Output window (Cmd+L L on Mac). OmniSharp Log (see below) shows that it tried to use dnx-mono.1.0.0-rc1-update1 runtime and then threw an exception because it was not there.

From what I understand, OmniSharp can't use DNX CoreCLR (because it doesn't support sockets?) and needs DNX Mono to run. There is some discussion on this topic in VS Code GitHub repo here.

Running dnvm upgrade -r mono and restarting Visual Studio Code fixed the issue. My DNVM set up now looks like this:

Please note that you don't have to use DNX Mono for development in order to get IntelliSense to work. You just need to have it installed.

OmniSharp Log

[INFO] Starting OmniSharp at APP_PATH...

[INFO] Started OmniSharp from '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/jrieken.vscode-omnisharp/bin/omnisharp' with process id 34893...

[INFORMATION:OmniSharp.Startup] Omnisharp server running using stdio at location APP_PATH on host 34884.

[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Scanning APP_PATH for DNX projects

[INFORMATION:OmniSharp.Dnx.DnxPaths] Using runtime '/Users/nsamteladze/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-rc1-update1'.

[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Found project APP_PATH/project.json.

[INFORMATION:OmniSharp.Dnx.DesignTimeHostManager] Using '/Users/nsamteladze/.dnx/runtimes/dnx-mono.1.0.0-rc1-update1' for design time host.

[ERROR:OmniSharp.Startup] The project system 'DnxProjectSystem' threw an exception. System.InvalidOperationException: File name has not been set at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in :0 at System.Diagnostics.Process.Start () [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start () at OmniSharp.Dnx.DesignTimeHostManager.Start (System.String hostId, System.Action`1 onConnected) [0x00000] in :0 at OmniSharp.Dnx.DnxProjectSystem.Initalize (IConfiguration configuration) [0x00000] in :0 at OmniSharp.Startup.Configure (IApplicationBuilder app, IServiceProvider serviceProvider, ILibraryManager manager, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ISharedTextWriter writer, IOptions'1 optionsAccessor) [0x00000] in :0

[INFORMATION:OmniSharp.MSBuild.MSBuildProjectSystem] No solution files found in APP_PATH

[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Detecting CSX files in APP_PATH.

[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Could not find any CSX files

[INFORMATION:OmniSharp.Startup] Solution has finished loading



来源:https://stackoverflow.com/questions/34467249/intellisense-doesnt-work-in-visual-studio-code-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!