IntelliSense 在 Visual Studio 上的代码中不起作用 Mac

IntelliSense doesn't work in Visual Studio Code on Mac

我正在使用 Visual Studio 代码在 Mac 上开发 ASP.NET 5 应用程序。我遇到的问题是,除了我之前输入的方法和变量名称的简单自动完成之外,我没有得到任何 IntelliSense 支持(例如可用的 class 方法)。

该应用程序以 DNX Core 5.0 为目标:

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

并且我通过 DNVM 安装了 CoreCLR 1.0.0-rc1-update1:​​

$dnvm list

Active Version Runtime Architecture OperatingSystem Alias

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

  • 1.0.0-rc1-update1 coreclr x64 darwin default

我尝试了以下方法来解决问题,但没有成功:

如有任何建议,我们将不胜感激。

简而言之,问题是,虽然我的机器上安装了 Mono,但我没有 DNX Mono。通过 DNVM 在本地安装它 (dnvm upgrade -r mono) 解决了这个问题,现在我在 Visual Studio 代码中获得了很好的 IntelliSense 支持。

说来话长。

Visual Studio 代码使用 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)。

我没有得到任何 IntelliSense,因为 OmniSharp 运行 有错误,如果我更注意 Visual Studio 代码输出 window (Cmd+L L 在 Mac 上)。 OmniSharp 日志(见下文)显示它尝试使用 dnx-mono.1.0.0-rc1-update1 运行时然后抛出异常,因为它不存在。

据我了解,OmniSharp 不能使用 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.

运行 dnvm upgrade -r mono 并重新启动 Visual Studio 代码解决了这个问题。我的 DNVM 设置现在如下所示:

请注意,您不必使用 DNX Mono 进行开发即可让 IntelliSense 工作。你只需要安装它。

OmniSharp 日志

[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