Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# syntax error hints disappear after a few seconds #883

Closed
aeschli opened this issue Nov 7, 2016 · 23 comments
Closed

C# syntax error hints disappear after a few seconds #883

aeschli opened this issue Nov 7, 2016 · 23 comments

Comments

@aeschli
Copy link
Contributor

aeschli commented Nov 7, 2016

From @zeyangl on November 2, 2016 10:9

  • VSCode Version: 1.6.1
  • OS Version: macOS 10.11.6 (15G1108

C# syntax error hint disappears after a few seconds.

Steps to Reproduce:

  1. make a C# file
  2. install C# plugin (1.4.1)
  3. write a simple C# class
  4. intentionally cause a syntax error.
  5. observe red hints on the syntax error.
  6. wait a couple of seconds, error hints disappear.

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

@aeschli
Copy link
Contributor Author

aeschli commented Nov 7, 2016

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.

@aeschli
Copy link
Contributor Author

aeschli commented Nov 7, 2016

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.

@aeschli
Copy link
Contributor Author

aeschli commented Nov 7, 2016

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

@HawkenKing
Copy link

I get this same issue on mac, using for unity.

@masaeedu
Copy link

masaeedu commented Nov 8, 2016

@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.

@HawkenKing
Copy link

HawkenKing commented Nov 15, 2016

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

@DustinCampbell
Copy link
Member

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.

@masaeedu
Copy link

@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" notifications@github.com
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
#883 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADgPyK1qtmHJ5EIWdJJlvE6IbFao71PMks5q-eg3gaJpZM4KrGUB
.

@DustinCampbell
Copy link
Member

What about the latest available extension? These are older than the extension we just released.

@masaeedu
Copy link

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" notifications@github.com
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
#883 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADgPyDm3spIImOijs_j1puTFWMOElYMGks5q-ek-gaJpZM4KrGUB
.

@DustinCampbell
Copy link
Member

I will try the codebase you posted. Hopefully, I can get to the bottom of this.

@CoenraadS
Copy link

CoenraadS commented Nov 16, 2016

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.

@DustinCampbell
Copy link
Member

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.

@rebornix
Copy link

@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 :)

@DustinCampbell
Copy link
Member

@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).

@CoenraadS
Copy link

CoenraadS commented Nov 16, 2016

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

@DustinCampbell
Copy link
Member

@CoenraadS: Thanks for the link. Downloading now...

@DustinCampbell
Copy link
Member

I can repro! Excellent!

@DustinCampbell
Copy link
Member

DustinCampbell commented Nov 16, 2016

@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.

@DustinCampbell
Copy link
Member

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

@DustinCampbell
Copy link
Member

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:

image

And here they are afterwards:

image

Note that elements 2 and 3 are reversed.

@DustinCampbell
Copy link
Member

I've filed microsoft/vscode#15585 to track getting this issue fixed in VS Code.

@DustinCampbell
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants