简体   繁体   中英

IntelliSense doesn't work in Visual Studio Code on Mac

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 (eg 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM