_From @Figbash on April 29, 2016 17:30_
Will somebody please give this bug some attention? There are many of us that haven't been able to move from version 0.10.3 in December. I would very much like to run an up to date version of VSCode.
https://github.com/OmniSharp/omnisharp-roslyn/issues/371
https://github.com/OmniSharp/omnisharp-vscode/issues/6
_Copied from original issue: Microsoft/vscode#5993_
This bug is still in the latest release. Any updates?
Sorry to chase @jrieken, but do you guys have any kind of ETA on this? Is there anything we can do to help diagnose the issue? Cheers
I am also experiencing painfully slow, if non existent intellisense support on VS Code running in a Ubuntu VM.
The project having issues is just a blank .NET Console application - typing "args." does nothing, and hitting ctrl+space pops open the "Loading..." and _sometimes_ it loads.
Attached is my VSCode output.
@DustinCampbell will know
Honestly I have given up on this being looked at, I even emailed dustin directly offering to help figure it out and got no response. There doesn't seem to be any interest in making C# functional again ever since this was split into a separate plugin :( It's very frustrating, as it worked so perfectly before that.
@VinditCo My gut feeling is that it has something to do with either precompiled DLL plugins or just very large projects, as it doesn't seem to occur on any of my simpler projects. I have been trying to narrow it down so at least we could pull offending files out of the solution to allow us to work, but I have not had any luck. I will let you know if I ever find anything that helps.
@Figbash -- don't give up hope! I actually never received your email.
The OmniSharp log you provided indicated that you're using a project.json-based project. Is this a project targeting ASP .NET RC1 (e.g. DNX), or a newer .NET CLI project?
@DustinCampbell thanks for getting back to us! I'm running Unity 5.3.4p5 - how would I check if it's using a json-based project?
@DustinCampbell I apologize for venting, I sent the email a couple weeks ago. I am running Unity as well and believe the problem generally affects Unity projects (I'm thinking misnor has a different issue).
Unity targets Mono that is equivalent to .NET 2.
The startup log in version .10.3 of VSCode always shows:
[INFORMATION:OmniSharp.Dnx.DnxPaths] Using runtime '/Users/raymondbritton/.dnx/runtimes/dnx-mono.1.0.0-beta4'.
[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Scanning 'AJMobile_Trunk' for DNX projects
[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] No project.json based projects found
The solution file/csproj files seem to be an XML format for visual studio 12 rather than JSON.
I have uploaded the solution from my broken project:
Assembly.zip
The solution files are generated by Unity.
Sorry, I was looking at the OmniSharp log that @misnor posted -- that one is project.json-based. I'll take a look at the project you provided.
I'm not entirely sure if the output log is even related, I often get the same issue without the log appearing.
For instance I have just used command click on to jump around some files in VSCode 1.1.0-insider, and did not receive any logs in output. The first few jumps were quick, but the third one brings up the "Loading..." tooltip for around 6 seconds before working again, and there was nothing in the output besides:
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 627ms
I did get this in the output a little before the slowdown:
[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Detecting CSX files in '/Users/raymondbritton/Desktop/AJMobile_Trunk'.
[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Could not find any CSX files
[INFORMATION:OmniSharp.Startup] Solution has finished loading
[ERROR:Microsoft.AspNet.Diagnostics.ErrorHandlerMiddleware] An unhandled exception has occurred: Diagnostic must have span '[1505..1505)'
Parameter name: diagnostics
System.ArgumentException: Diagnostic must have span '[1505..1505)'
Parameter name: diagnostics
at Microsoft.CodeAnalysis.CodeFixes.CodeFixContext.VerifyDiagnosticsArgument (ImmutableArray1 diagnostics, TextSpan span) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.CodeFixes.CodeFixContext..ctor (Microsoft.CodeAnalysis.Document document, TextSpan span, ImmutableArray1 diagnostics, System.Action2 registerCodeFix, Boolean verifyArguments, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.CodeFixes.CodeFixContext..ctor (Microsoft.CodeAnalysis.Document document, TextSpan span, ImmutableArray1 diagnostics, System.Action2 registerCodeFix, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0
at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CodeActionHelper+<GetCodeFixContext>d__2.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter1[System.Nullable1[Microsoft.CodeAnalysis.CodeFixes.CodeFixContext]].GetResult () [0x00000] in <filename unknown>:0
at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CodeActionHelper+<GetActions>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter1[System.Collections.Generic.IEnumerable1[Microsoft.CodeAnalysis.CodeActions.CodeAction]].GetResult () [0x00000] in <filename unknown>:0
at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService+<Handle>d__4.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter1[OmniSharp.Models.V2.GetCodeActionsResponse].GetResult () [0x00000] in
at OmniSharp.Middleware.Endpoint.EndpointHandler2+<HandleSingleRequest>d__18[OmniSharp.Models.V2.GetCodeActionsRequest,OmniSharp.Models.V2.GetCodeActionsResponse].MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter1[System.Object].GetResult () [0x00000] in
at OmniSharp.Middleware.Endpoint.EndpointHandler2+<Process>d__16[OmniSharp.Models.V2.GetCodeActionsRequest,OmniSharp.Models.V2.GetCodeActionsResponse].MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter1[System.Object].GetResult () [0x00000] in
at OmniSharp.Middleware.EndpointMiddleware+
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
at Microsoft.AspNet.Diagnostics.ErrorHandlerMiddleware+
Hmmm... Could you try this? Grab the latest omnisharp.linux-mono.tar.gz from https://github.com/OmniSharp/omnisharp-roslyn/releases/tag/v1.9-alpha13 and untar it to a directory. Then, set the "csharp.omnisharp" preference in VS Code to point to "/directory/you/just/created/OmniSharp.exe". Restart VS Code and see if this addresses the issue.
I am running OSX BTW. Attempting to do what you said shows:
/Users/raymondbritton/Desktop/omnisharp-linux-mono/OmniSharp.exe: cannot execute binary file
:grumble: ok. Give me a day or two to get set up to try and repro. If you have anymore you could share to reproduce the problem that'd be helpful.
Note that I've never actually installed Unity before so this is new territory for me :blush:
Ok, thank you. I cannot share the project unfortunately as it is my companies and is enormous, perhaps @VinditCo has something shareable? If it would help figure it out I would be willing to screen share.
I have gotten the alpha to start using a bash script with mono OmniSharp.exe, but it gives me:
[INFO] Starting OmniSharp at '/Users/raymondbritton/Desktop/AJMobile_Trunk/AJMobile_Trunk.sln'...
[INFO] Started OmniSharp from '/Users/raymondbritton/Desktop/omnisharp-linux-mono/omnisharp' with process id 17707...
OmniSharp:
info: OmniSharp.Startup[0]
Omnisharp server running on port '2000' at location '/Users/raymondbritton/Desktop/AJMobile_Trunk' on host -1.
info: OmniSharp.DotNet.DotNetProjectSystem[0]
Initializing in /Users/raymondbritton/Desktop/AJMobile_Trunk
info: OmniSharp.DotNet.DotNetProjectSystem[0]
Auto package restore: True
fail: OmniSharp.Startup[0]
The project system 'DotNetProjectSystem' threw exception during initialization.
Failed to initialize Microsoft.DotNet.ProjectModel.WorkspaceContext at /Users/raymondbritton/Desktop/AJMobile_Trunk.
at OmniSharp.DotNet.DotNetProjectSystem.Initalize (IConfiguration configuration) [0x00000] in
at OmniSharp.Startup.Configure (IApplicationBuilder app, IServiceProvider serviceProvider, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ISharedTextWriter writer, IOmnisharpAssemblyLoader loader, IOptions`1 optionsAccessor) [0x00000] in
info: OmniSharp.MSBuild.MSBuildProjectSystem[0]
Detecting projects in '/Users/raymondbritton/Desktop/AJMobile_Trunk/AJMobile_Trunk.sln'.
info: OmniSharp.MSBuild.MSBuildProjectSystem[0]
Loading project from '/Users/raymondbritton/Desktop/AJMobile_Trunk/Assembly-CSharp-firstpass.csproj'.
info: OmniSharp.MSBuild.MSBuildProjectSystem[0]
Loading project from '/Users/raymondbritton/Desktop/AJMobile_Trunk/Assembly-CSharp.csproj'.
info: OmniSharp.MSBuild.MSBuildProjectSystem[0]
Loading project from '/Users/raymondbritton/Desktop/AJMobile_Trunk/Assembly-CSharp-Editor-firstpass.csproj'.
info: OmniSharp.MSBuild.MSBuildProjectSystem[0]
Loading project from '/Users/raymondbritton/Desktop/AJMobile_Trunk/Assembly-CSharp-Editor.csproj'.
info: OmniSharp.ScriptCs.ScriptCsProjectSystem[0]
Detecting CSX files in '/Users/raymondbritton/Desktop/AJMobile_Trunk'.
info: OmniSharp.ScriptCs.ScriptCsProjectSystem[0]
Could not find any CSX files
info: OmniSharp.Startup[0]
Configuration finished.
[ERROR] Error: Failed to start OmniSharp
If you have any ideas on that exception I can try again.
OK. I'm also adding @troydai, who might have some ideas as well. It seems suspicious that the DotNetProjectSystem is throwing. Do you have project.json files in your project at all?
I can walk you through Unity:
Install Unity Free, tell it to include the demo project
Open the demo project in Unity
Grab https://github.com/dotBunny/VSCode and put it under the demo project dir /Assets/Editor
In Unity open Assets menu, Open C# Project In Code
This will generate the solution and open it in Code.
Then just try using it a little bit and the issue will either be very apparent or the demo project won't have the issue, hopefully the former :)
I don't see any project.json files in the project.
I'm also on OSX and don't have any project.json files. Sadly I also cant post a copy of the project.
Are there any logs you'd like me to post?
I am trying to reproduce this on a smaller project but I'm not having any luck. It definitely seems to have something to do with project size or complexity...
Good to know. I'm still looking at this. Thanks for the update!
I also think it's something to do with the project size. Perhaps something to do with 3rd party DLL's? @Figbash are you using much from the Asset Store?
Small-ish by itself project in unity with EmguCV's managed part in source files copied to project broke omnisharp for me. We're talking about 400 classes there. Once it's all compiled to class library, however, issue is gone.
@Taugeshtu when you say 'compiled to class library' are you referring to the recompile VSCode triggers on code change? If so, that's the same me :)
@VinditCo No, I'm referring to "pack all those classes into managed .dll"
@DustinCampbell Hello! Did you have any success looking into this?
We've been focused on getting Unity support back up and running in the C# extension (note the breaking change on our readme. Once that is working again, I'll be taking a look at the performance and flakiness of IntelliSense. Sorry for the delay!
Can we set up a few sample Unity projects as test samples?
@StaceyHaffner recommended trying this project to see if it works: https://github.com/staceyhaffner/SuperSpaceShooter
Here's another project we can use: https://github.com/staceyhaffner/ExtremeMonsterTruck
I'll try loop these projects in automation
Hi @DustinCampbell, I tested this out - Intellisense works for me on both SuperSpaceShooter and ExtremeMonsterTruck. References are not shown though.
On my own project I don't have Intellisense or references.
Tried the latest VSCode with a fresh mono install - still having the same issue. Anyone recently had any success solving the issue?
@VinditCo As I understand it Unity support is broken completely in the newest version of the omnisharp plugin and they are going to look at that first. I sure would like to use the new VSCode with tabs though!
Very slow, not always but happens very frequently.
VSCode 1.3.1
I've given up on VSCode for the time being. They should really stop advertising it as functional with Unity.
The open source branch of Project Rider (https://www.jetbrains.com/rider/) called Consulo (https://github.com/consulo/consulo/wiki/Downloads) is fully Unity compatible and a pleasure to use. It's does everything VSCode does and more. Until this is fixed I'd advise people giving it a whirl
@VinditCo there's a dedicate Consulo branch for Unity, btw: https://github.com/consulo/consulo-unity3d
All these things aside, I hope VSCode C# plugin goes stable in the nearest future, as its much better usability-wise (IMHO).
@VinditCo Thanks, as much as I love VSCode I think it's time for me to switch as well.
I hope it gets fixed eventually for the other Unity users out there.
Here is a video of the issue using 1.3.0b1 and Code Insiders 1.4.0. I am holding the command key the entire time:
VSCodeBug.mov.zip
@VinditCo @sumanx How many warnings do you both have? I'm wondering if it's somehow related, as my working copy .10.3 says 0 warnings but my broken versions always say 99+ because of unused using directives. I also notice the warning number increases directly after the pause, and that most warnings have multiple entries in the list (at least when using the beta of omnisharp).
Hey @Figbash, from your video it looks like OmniSharp didn't even attempt to start. Any chance you could try Code 1.3.1?
I've uploaded a new release: v1.3.0-beta2. This should fix the problem of many duplicate diagnostics.
@DustinCampbell I had cleared the Omnisharp output to show that it was not showing any errors or anything when it pauses, but Omnisharp had started before I cleared it. 1.3.1 does the exact same thing.
Are you seeing the same behavior with C# Extension v1.3.0-beta2? I believe there're a number of problems due to duplicate diagnostics being created, including significant slow downs. This version should alleviate that specific problem.
@DustinCampbell I just tried fresh install of Code 1.3.1 with beta2 extension, same issue is occurring :(
Very sorry to hear that. :disappointed: I'll continue digging into this. If you have a failing project that you can share, please let me know.
@DustinCampbell I really wish I could share my project, but I cannot. I'm willing to try any tests you want though. If it helps any it seems to occur 100% when I modify a cs file and then save, and the task "mono-sgen" will take 100% in my activity monitor for the entire time it's paused.
The same issue also occurred in I believe .10.2 and you guys fixed it for .10.3, I don't know know if it was the exact same cause obviously but maybe that would be a hint?
It seems to only occur on rather large Unity projects. I have 1791 "unnecessary using directives" which is why I was thinking that might be related, most Unity projects would have these as well (as Unity auto puts some using lines in new cs files and it ignores that warning type in the compiler)
I will see if I have the issue with the above staceyhaffner projects.
Yes, the 1791 unnecessary using directives was what I was thinking as well. The latest beta addresses an issue where diagnostics would accumulate and duplicate with each edit. That's why I was hopeful that would fix this.
@DustinCampbell OK I have a brand new install of El Capitan and I'm running Code 1.3.1 + the C# 1.3.0 that you just released. A new thing I noticed as I have default settings is that if you have the References links showing they disappear when this bug occurs, and come back a little bit after it starts working again, so it seems like Omnisharp is rebooting. I usually don't get any logs in the output but this time I got:
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 224ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 449ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 20ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 18ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 25ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 20ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 19ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 26ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 19ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 19ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 24ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 18ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 20ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 26ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 19ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 1232ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 108ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 176ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 25ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 24ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 300ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 19ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 23ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 36ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 9ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 21ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 432ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 144ms
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /v2/getcodeactions: 200 113ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Object reference not set to an instance of an object
@DustinCampbell I have managed to make a project that exhibits this behavior by taking a free project and duplicating it's scripts into different namespaces to make it large. Steps to follow:
Thanks a ton @Figbash! I will take a look.
Is there any documentation on how to debug OmniSharp itself?
@Figbash large number of, 28000+
The current version of VSCode is basically unusable right now with Unity c# as it keeps rebuilding intellisense as you code.
Is there a way to revert to a previously working version? I'd rather keep using VSCode, does anyone know what was the last version that didn't have this bug?
None sadly. The last working release for me was November last year (10.3) - I think I reported this issue sometime December/January. Disappointing.
I'd advise switching to Consulo. It's v.impressive and devs are responsive :
https://github.com/consulo/consulo-unity3d
https://github.com/consulo/consulo/wiki/Downloads
Any updates on this one?
BTW, It works well on VSCode 9.3, but I cannot disable auto update. I put in settings:
"update.channel": "none"
but VSC is still updating to v1.4, which does not work... So annoying.
Maybe somebody disabled auto update on 9.3?
@trafcio none of us work on the VS Code team, so we don't know anything about their auto update.
Hey @trafcio, try changing the update channel to none in %APPDATA%\code (Windows) or ~/Library/"Application Support"/Code (Mac).
"update.channel": "none"
doesn't work on 0.10.3 either.
It just updates anyway.
@Figbash: Sorry for the delay, I just got back from vacation. To provide you with an update, I can definitely repro the problem you described with your project. Thanks _very_ much for the repo!
No worries, hope it's easy to fix :)
Running 1.4.0, same problem. VSCode is completely unusable after a couple of minutes editing a unity project. Intellisense keeps rebuilding, throwing tons of duplicates of the same Warnings.
I have a pretty good sense of what's happening now, at least, with the project that @Figbash provided. In that project, there are a lot of files in the project with loads of warnings (mostly unnecessary usings). After a few seconds, the extension calls out to OmniSharp to provide the warnings, and it returns a few seconds later. During that time, the extension is responsive. However, the extension then tries to add the warnings into the VS Code, and VS Code locks up processing them.
There's code in the extension that is supposed to stop collecting errors and warnings for large projects. However, there are bugs in that code which I should have fixed shortly. I expect this to fix the problem.
I've drafted a new release here, which should help this issue somewhat. There's much more to do, but it should no longer lock up if you have a larger solution (i.e. 1000+ source files).
Let me know if this solution works for you. I'm not expecting it to work for everybody, but it's definitely working for the project @Figbash provided.
This version seems to make things a bit better and I no longer have huge logs of the same warnings but still, after a while mono-sgen takes about 70 cpu then Code Helper peeks and the whole things is still really slow.
For me it went from completely unusable to usable but with a bit of pain. Battery wise it's much better also. It still drains fast, but not like it's going off a cliff as it was before.
For reference, 2 hours (2 1 hour train trips at the start and end of day) was enough to drain my mac book pro to 10-20% from 100%, it hasn't been draining as fast as then, but I will need to wait till I try a few more times to know for sure.
@DustinCampbell My project is working now! Thanks so much.
Now I am getting "Some projects have trouble loading. Please review the output for more details." every time I open any Unity project or it reloads, but everything else seems to be perfect for my particular project.
I'm seeing the same problem, even with the latest beta6 release:
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Index was outside the bounds of the array.
I'm trying to use Unity as well, with a moderately sized project. Lots of "Unnecessary using directive" warnings. Not sure if it's relevant, but I also see this just before the exceptions:
[WARNING:OmniSharp#MSBuild] Failed to process project file '/<myprojectpath>/Assembly-CSharp-Editor.csproj'.
/<myprojectpath>/Assembly-CSharp-Editor.csproj
I can't provide the project, but happy to help if I can.
We're going to ship 1.4 soon, so I'm going to move this issue forward to milestone 1.5. We've made progress here (and fixed the situation for some folks), but it's not done yet.
@DustinCampbell Just another spot I noticed, if you click on the errors/warnings button that shows all the issues in the project it will start acting badly again and never repair itself until you quit.
I can confirm that there is still a massive slowdown in 1.5.1 when working in projects with loads of warnings (especially unnecessary usings) as described by @DustinCampbell.
After a few minutes the editor becomes unresponsive taking a few seconds to recover allowing me to type a few characters before stalling again.
The problem seems to stem from duplication happening in the warnings and errors view.
After typing a few characters all the projects warnings are entered into the list along with the original list.
After a short session I have thousands of warnings in the lists making the delays longer each time.
Please do let me know if there is something I can do to help diagnose these issues.
@Figbash, @nixbb: I just wanted to let you know that I dug into the issue and it appears that the VS Code diagnostic system doesn't scale as well as it should, especially in the scenario where there are lots of files containing at least 1 diagnostic. I've produced a repro and filed an issue for the VS Code folks to take a look at here: https://github.com/Microsoft/vscode/issues/11976.
The VS Code team has dug into https://github.com/Microsoft/vscode/issues/11976 and has fixes that should address this problem. Hopefully, we'll see improvements soon when it comes down the VS Code Insiders channel.
Hey all -- VS Code 1.6 is out and includes performance fixes that should fix this issue. Are folks still experiencing this issue with the latest VS Code release?
@DustinCampbell I've been using it all week, I haven't experienced any problems. I think it's fixed.
w00t! Note that there was also a problem with diagnostics not getting reported properly with VS Code 1.6 that has also been fixed in the latest C# extension beta.
Excellent work, I've used 1.6.x for a week now and the slow down issues I was experiencing seems to be solved. The duplicates entries are gone as well.
Thank you.
These improvements optimizations sound really impressive...
... but I'm now getting some other problems with Intellisense when I try to use VSCode and Unity. I only have ~1 second to see and correct any errors before they disappear from the screen. Here is a gif:

I'm going to try and gather some more information, try out some other Unity projects, and then I will open up another issue. In the meantime, I thought I would mention it here in case it is related to the update and others wanted to chime in.
Ohh yes this is an issue with every unity project that has any plugins in it. the hints and suggestion take a lot of time to show up. more over changing anything in the file results in re counting of references across the file [the reference count that is shown above every method and variable]
@heyalistair I doubt this is helpful, but I am not experiencing this at all with multiple problematic Unity projects :)
@ChicK00o Actually hints and suggestions don't really take much time to show up at all, everything seems super fast thanks to the work that was put in on this issue. It's just that these error keep disappearing!
When I switch back to VSCode 1.5.3, the errors stay on the screen like they should. It's something that I am experiencing only in 1.6.x. In 1.6.x, I only have two plugins installed C# 1.4.1 and Mono Debug 0.11.0.
@Figbash Thanks! Any info is helpful, no matter how envy-inducing. :)
@heyalistair I am seeing the exact same behavior. I'm using 1.6.1, working in a .NET Core project, any errors disappear after about a second. I don't know how to fix it, but it's been extremely frustrating. Have you found a workaround other that downgrading to 1.5?
@perfectsquircle: This should be fixed by install 1.5-beta4 of the C# extension from here. Once you have it downloaded, installing it is pretty easy:
1. In VS Code, select View->Extensions from the menu to open the Extensions pane.
2. At the top-right corner of the Extension pane, click the [...] and select "Install from VSIX..."
3. Locate the file you downloaded.
@DustinCampbell I'm trying out 1.5-beta4 now and it appears to have fixed my issue! Thanks for your quick response, this problem has been puzzling me for the last couple of weeks. I hope 1.5.0 goes live soon.
We're working on it. :smile:
This is still happening for me, intellisense only shows errors for a couple of seconds and then stops working. I'm using version 1.7.1 of VS Code. 2 extensions: "C#" version 1.4.1 and "Mono Debug" version 0.11.0 and Windows 7, I'm working on a new unity project but it seems to not work for any unity project regardless of if it's large or not. I'm also using Unity 5.5.0b8 which is supposed to have inbuilt VS Code support but I've also tried it on 5.4 and it makes no difference. Hopefully this can be properly fixed as it makes it completely unusable at the moment.
Hi @CyanSlinky, could you try the new 1.5-future-preview1 release and let me know if that helps? Here are instructions to install it cleanly:
OK. I expect this to be greatly improved if not completely fixed in the 1.5 release. I'm going to _gasp_ close this issue. If this continues to be an problem for anyone, let's start a new issue.
Hi @DustinCampbell,
I tried the manual install of C# extension you linked to (1.5-future-preview1) and the current release (1.5.2) via the VS Code marketplace, and neither have resolved my issue. I still have disappearing errors. I will try to recreate in a sample project and if I can do that, I will open a new issue.
But anyway, thanks so much for fixing #269. It was epic.
Thanks a ton @heyalistair. The disappearing errors issue has been a bit of a thorn in my side because I've not been able to reproduce yet.
This was bothering me in Visual Studio Code working with Unity but I'd say check that you do not still have the "Legacy C#" extension installed. I uninstalled both and reinstalled the normal C# extension; the "mono.osx" process (it says this instead of "mono-sgen" for some reason now) still uses a lot of CPU in the ActivityMonitor but the completion problems and delays I had been seeing have gone away.
It says "mono.osx" because OmniSharp now runs on its own Mono runtime. I'm glad to hear that the delays have gone away. That's fantastic. How much CPU activity are you seeing?
Like, between 60% and 200%. It doesn't seem to slow anything down though, just makes the fan on my MacBook Pro spin kinda loudly.
yeah, that seems pretty significant. Do you have a particularly large project?
@BrianHubble Definitely didn't have the "Legacy C#" extension. Thanks tho.
@DustinCampbell So... I tried to come up with a reproducible project. I started off by making sure I had fresh, recent installs of Unity and the little VSCode plugin by dotbunny and I opened an open source project. But I didn't see the bug there, and everything worked fine.
Then, I switched back to my original configuration (Unity 5.4.1p4 and previous VSCode plugin) and opened my private project, where I usually see the bug. And the bug was not there. Errors do NOT disappear anymore.
Maybe rewriting workspace settings helped? (In Unity -> Preferences -> VSCode tab -> Write Workspace Settings)
Maybe VSCode was caching something and it finally got cleared?
@DustinCampbell Actually, this morning I installed the Visual Studio Preview for Mac that was just announced at Connect()... It looks like it might have bumped my mono version! That might have done it
FWIW, we _just_ discovered the caused of errors disappearing in larger projects. The necessary fix has been made to VS Code and should hopefully start showing up in VS Code Insiders builds soon. Details are here: https://github.com/Microsoft/vscode/issues/15585.
@DustinCampbell It's a fairly large Unity project and the slowness will still come and go. (I should mention it also shows like 99+ errors in VS Code that are not errors in Unity).
Anyway, I will try the Insiders update channel.
Most helpful comment
The VS Code team has dug into https://github.com/Microsoft/vscode/issues/11976 and has fixes that should address this problem. Hopefully, we'll see improvements soon when it comes down the VS Code Insiders channel.