_From @zeyangl on November 2, 2016 10:9_
C# syntax error hint disappears after a few seconds.
Steps to Reproduce:
I expect this to be a VSCode issue instead of OmniSharp, since the syntax hints did show up correctly, only to disappear in a couple of seconds.
_Copied from original issue: Microsoft/vscode#14844_
_From @rebornix on November 2, 2016 16:9_
@zeyangl I'll say let's start with OmniSharp as we don't know yet whether OmniSharp regards it as no longer an error after a couple of seconds, please file issues there and if OmniSharp confirms there is not any C# or OmniSharp related stuff, let's then take a look into it.
_From @zeyangl on November 4, 2016 5:13_
It appears to be fixed in 1.7.1 release. OmniSharp version remains the same though, so probably a nice side effect of some other fix in vscode.
_From @marcelush on November 5, 2016 21:53_
I am still having same issue on Ubuntu 14.04, insiders and stable Version 1.7.1.
Maybe is because of big projects, the problem doesn't occur when testing a small project.
Initially i was suspecting the auto save feature to have something to do about it, but i tested with all possible options.
Warnings and info remain, but errors disappear about 2 seconds after code change (saved or not).
Same project works fine in Windows with vscode 1.7.1
I get this same issue on mac, using for unity.
@aeschli I think this might be related to project analysis beginning or completing. I opened #843 with detailed repro steps, but the gist of the matter seems to be that something gets out of sync once the project finishes building. A workaround that works for me is closing and reopening the file.
I get it with all / any projects.
When I move the cursor, the red underline squiggles disappear.
Not sure why this issue keeps getting closed, it's quite an alive and real bug ;) Many threads on it now.
I tried the patch csharp-1.5.0-future-preview1.vsix but same issue
I haven't been able to reproduce the issue myself, though its not for lack of trying. Note that csharp-1.5.0-future-preview1 is older than the recently released 1.5.1 which is available from within VS Code.
@DustinCampbell did you try out the repro steps and codebase I put up?
I"?'ve been able to reproduce on two separate machines with the beta4 and
beta8 extension.
On Nov 15, 2016 12:14 PM, "Dustin Campbell" [email protected]
wrote:
I haven't been able to reproduce the issue myself, though its not for lack
of trying. Note that csharp-1.5.0-future-preview1 is older than the
recently released 1.5.1 which is available from within VS Code.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/OmniSharp/omnisharp-vscode/issues/883#issuecomment-260704095,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADgPyK1qtmHJ5EIWdJJlvE6IbFao71PMks5q-eg3gaJpZM4KrGUB
.
What about the latest available extension? These are older than the extension we just released.
Well new versions are going to keep coming out: beta8 was the latest
release only a few days ago. Unfortunately I switched back to Visual Studio
to finish what I was working on and don't have time to test with new
versions. Unless you've specifically changed anything after the beta to
address this bug I'd expect that it's still not fixed.
On Nov 15, 2016 12:17 PM, "Dustin Campbell" [email protected]
wrote:
What about the latest available extension? These are older than the
extension we just released.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/OmniSharp/omnisharp-vscode/issues/883#issuecomment-260705338,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADgPyDm3spIImOijs_j1puTFWMOElYMGks5q-ek-gaJpZM4KrGUB
.
I will try the codebase you posted. Hopefully, I can get to the bottom of this.
I also experience this with a Unity Project. I filed a report to Unity, and they told me its a VSCode issue, who says its a OmniSharp issue, so here I am now. I tested using v1.5.1, I will test on v1.5.2 now also.
If you want an Unity project that experiences this error I can provide it.
Could you provide the code base? That'd be very helpful. Note that 1.5.2 is worth trying. It includes several fixes to how diagnostics are displayed, so it could have an impact on this problem.
@CoenraadS IMHO it's a OmniSharp issue but it's just a wild suspicion. But since it's C# related, I'd like to start investigation here and then maybe we can know whether it's a common one :)
@rebornix: I'm quite certain it's a C# extension issue (note that the C# extension is not called "OmniSharp" -- that's simply a technology leveraged by the extension).
The error seems related to the project size, so unfortunately I cannot submit it as a minimum scenario, but have to upload my whole project ~100 MB, too large for inbuilt attachment. I sent a WeTransfer to @DustinCampbell email address, I hope that is ok. I tested 1.5.2 it still occurs.
To use the sample, open /Scripts/ErrorTest.cs from Unity
What I see:
VSCode opens
An error appears in problem window
... Some more analysis happens to the project
Error has dissapeared
@CoenraadS: Thanks for the link. Downloading now...
I can repro! Excellent!
@rebornix: I think this might actually be a VS Code issue. Debugging in, I can see what's happening.
When a file is opened, we request diagnostics from the OmniSharp server and then call Diagnostics.set(...) with the uri for that document and the array of diagnostics. This happens here. At that point, errors are displayed for the file.
In addition, when the file is opened, we request diagnostics for the entire solution from the OmniSharp server. This happens on a 3 second delay. When the result comes in, we process all of the diagnostics, producing an array of Uri to diagnostic array ([Uri, Diagnostic[]][]) and then call DiagnosticCollection.set(...) with the array. This happens here. Per the documentation of DiagnosticCollection.set([Uri, Diagnostic[]][]), we first push undefined for the uri to ensure previous diagnostics are cleared and then push the new set of diagnostics. This is to avoid duplicate diagnostics for a particular document. However, it appears that isn't working as expected. The documentation says, "if a diagnostics item is undefined as in [file1, undefined] all previous but not subsequent diagnostics are removed." However, it appears that subsequent diagnostics are also being removed.
I'm betting the problem is here: https://github.com/Microsoft/vscode/blob/c67ef57cda90b5f28499646f7cc94e8dcc5b0586/src/vs/workbench/api/node/extHostDiagnostics.ts#L77
I bet this is due to the fact that JavaScript's array.sort() is not necessarily stable. So, if two items appear in array for the same file name, it could reverse them. In other words, this...
[file1, undefined]
[file1, [diagnostic1, diagnostic2]]
...could become this...
[file1, [diagnostic1, diagnostic2]]
[file1, undefined]
Which would result in disappearing errors. Thoughts? cc @jrieken
Yup. That's what's happening. I just tried sorting the [Uri, Diagnostic[]][] in the extension using the same code that VS Code uses and I can see it failing.
Here they are before sorting:

And here they are afterwards:

Note that elements 2 and 3 are reversed.
I've filed https://github.com/Microsoft/vscode/issues/15585 to track getting this issue fixed in VS Code.
OK. It looks like a solid fix has been checked into VS Code. It turns out that I couldn't repro because the array.sort() function starts out stable with small sets, but becomes unstable on larger sets. So, this would have only reproduced on larger projects with lots of diagnostics.
The fix should start showing up in VS Code Insiders builds soon.