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

Omnisharp does not display all errors/warnings in VSCode #812

Closed
HalfVoxel opened this issue Oct 11, 2016 · 61 comments
Closed

Omnisharp does not display all errors/warnings in VSCode #812

HalfVoxel opened this issue Oct 11, 2016 · 61 comments

Comments

@HalfVoxel
Copy link

Environment data

dotnet --info output:
.NET Command Line Tools (1.0.0-preview2-003131)

Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40e58

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64

VS Code version:
1.6.0

C# Extension version:
1.4.1

Steps to reproduce

Open a project with several errors/warnings in it (a project that you can replicate this bug in is available upon request).

Expected behavior

Omnisharp displays all errors/warnings in the Problems window in VSCode

Actual behavior

Omnisharp only displays a few or no messages even though in the omnisharp log I can clearly see them and have verified that they are valid errors/warnings (or... at least sometimes the log contains all warnings/errors, sometimes it does not). I have uploaded my omnisharp log here.
This is in a clean install with no other extensions. The project is a Unity project, but I doubt that should matter.

VSCode also logs "Some projects have trouble loading. Please review the output for more details." however I cannot see anything suspicious in the log even with verbose logging enabled. Though it is pretty large so I might have missed something.

Restarting VSCode or the Omnisharp server does not solve it.

I have not tried to reduce my project to a smaller size and checked if it still happens, but I am more than happy to share my project with anyone to try to debug it.

For a while it would simply display one or sometimes a few warnings (I was fixing a lot of unused 'using' declarations) and I had to fix the single warning that was displayed, wait while it re-processed everything and then fix the next warning that would then show up.

@DustinCampbell
Copy link
Member

Hi, if this is a largeish Unity project (e.g. >= 1000 .cs source files), this is generally expected. In that case, the extension will only retrieve errors and warnings for open files to avoid constantly chewing CPU.

FYI, the link to your omnisharp log does not work me.

@HalfVoxel
Copy link
Author

Hi

It is large, but nowhere near that large.

$ ls **/*.cs | wc
273

@HalfVoxel
Copy link
Author

In any case, the files were open.
Huh, that's odd, it works just fine for me.

@DustinCampbell
Copy link
Member

I'd love to take a look at your project if you're able to provide it. Perhaps we broke something. Also, you might consider trying the latest beta of the C# extension available here and see if that improves the issue.

@HalfVoxel
Copy link
Author

Here are some screenshots and the log that is visible in them

screenshot 2016-10-11 19 44 07
screenshot 2016-10-11 19 43 53

http://pastebin.com/Us51C8Us

@HalfVoxel
Copy link
Author

Also, you might consider trying the latest beta of the C# extension available here and see if that improves the issue.

Ok, is it possible to install that from within VSCode or do I have to do some manual work here? (this is literally the first time I have tried using VSCode, so I am not very familiar with how the plugins work yet).

I will send you an email.

@DustinCampbell
Copy link
Member

FWIW, the warnings in the log are produced when OmniSharp uses MSBuild to perform a design-time compilation of your project in order to gather up source files and references. However, OmniSharp does not return those. There's a separate endpoint that requires errors and warnings live from your code.

@DustinCampbell
Copy link
Member

Ok, is it possible to install that from within VSCode or do I have to do some manual work here? (this is literally the first time I have tried using VSCode, so I am not very familiar with how the plugins work yet).

You can install it within VS Code. Go to the Extensions pane, click the three dots at the top-right of the pane and select "Install from VSIX..."

@HalfVoxel
Copy link
Author

FWIW, the warnings in the log are produced when OmniSharp uses MSBuild to perform a design-time compilation of your project in order to gather up source files and references. However, OmniSharp does not return those. There's a separate endpoint that requires errors and warnings live from your code.

Ok, but it is supposed to be able to get those warnings/errors from the other endpoint as well, right?

@HalfVoxel
Copy link
Author

HalfVoxel commented Oct 11, 2016

You can install it within VS Code. Go to the Extensions pane, click the three dots at the top-right of the pane and select "Install from VSIX..."

Installing the beta did not seem to resolve the problem unfortunately. Here is the log for the beta version: http://pastebin.com/r7gh70Bd

I sent you an email with the project.

@bsell93
Copy link

bsell93 commented Oct 11, 2016

I think I am experiencing something similar. I attempted to install the previously mentioned beta version with no change. For me the errors show up for a second after saving and then disappear. I have a short video of it (please forgive the watermark). I found that this bug came about after updating to the just released version of VSCode (v1.6)
omnisharp bug

@HalfVoxel
Copy link
Author

@bsell93 I also saw that once. The errors were not valid however, I think it was because I had just deleted some files and Unity had not rewritten the project file, so omnisharp was logging errors about that. I don't think it is related to this issue however.

@bsell93
Copy link

bsell93 commented Oct 11, 2016

I see. Yeah, I am not sure what is going on. They are definitely errors, because I intentionally made them 😁.

@shlapkoff
Copy link

I have the same problem. This happened after the update VS Code to version 1.6

@shlapkoff
Copy link

I found a solution: in v.1.5.3 all working.

https://code.visualstudio.com/updates/v1_5

@HalfVoxel
Copy link
Author

@shlapkoff were you referring to mine or @bsell93's problem?

@bsell93
Copy link

bsell93 commented Oct 12, 2016

@shlapkoff thanks! That fixed my issue!

@DustinCampbell
Copy link
Member

I see, so this is a recent regression with 1.6? @jrieken, have you heard any other reports of the Problems pane not displaying all errors & warnings?

@HalfVoxel
Copy link
Author

HalfVoxel commented Oct 12, 2016

@DustinCampbell For me downgrading to 1.5.3 did not work unfortunately.
As you can see in the screenshot, warnings are still not displayed.
I verified that it does check for some thing though, if I make an obvious syntax error like removing a semicolon, then it will complain.
image

@HalfVoxel
Copy link
Author

Is there anything else I could try to help you debug this issue?
Did you manage to replicate it in the project that I sent you?

@leafi
Copy link

leafi commented Oct 13, 2016

I'm getting this constantly with a .NET core solution as of VSCode 1.6, too. Errors appear for a second, then totally disappear.

But e.g. dotnet build in the terminal fails because those errors are actually totally valid.

@jrieken
Copy link
Contributor

jrieken commented Oct 13, 2016

@HalfVoxel Can you check the output of the developer console in VS Code? That might contain some useful data to let me understand this better/

@shlapkoff
Copy link

@HalfVoxel I have in mind the problem @bsell93

@jrieken
Copy link
Contributor

jrieken commented Oct 13, 2016

@HalfVoxel re #812 (comment) - just to clarify: you see this with 1.6 and also 1.5.x? or only with 1.6?

@HalfVoxel
Copy link
Author

HalfVoxel commented Oct 13, 2016

@jrieken I see this with both 1.5.3 and 1.6.
It is primarily warnings that I am concerned about though, it seems to handle errors better (but I haven't tested it extensively). Sometimes when it initially shows no warnings, I can make an error in the file and then it will show me both the error and an unrelated warning that didn't show up before (I might have to double check this one, but I am pretty sure that was what happened).

@leafi
Copy link

leafi commented Oct 13, 2016

Sounds like it's under control, but just in case:
Extensions:
EditorConfig for VS Code 0.3.3 (latest)
Nomo Dark Icon Theme 1.1.4 (latest)
ESLint 1.0.8 (latest)
C# 1.4.1 (latest)
Vim 0.3.7 (latest)

VS Code: 1.6.0, on Arch Linux x64 using visual-studio-code from the AUR, package version 1.6.0-2
(The visual-studio-code package grabs a debian/ubuntu release, strips symbols from the official binaries, and repackages them.)

Shot of developer tools on re-opening VS Code, introducing a syntax error which quickly disappears, with a bunch of tabs open:
2016-10-13-162442_793x991_scrot

Slightly cut-down (unrunnable but buildable) version of my pure C# project which shows the issue (1.7MB):
https://calpol.us/files/public/Blamalama-minim.zip

Repro:

  1. Download and extract this .zip file somewhere
  2. Open the root folder in VS Code. The one that contains .vscode, the one that is one level above 'src', not 'src' itself.
  3. Click the little OmniSharp button in the bottom right, and change it to 'src'. (For some reason, OmniSharp just keeps saying 'Running' when the root folder is selected with the cut-down project for some reason, though I swear it works fine in my real workspace...)
  4. Introduce a syntax error in e.g. src/Blim/TextBox.cs. Wait a few seconds, and it then disappears.

Potentially of interest here: I use a few extensions, I have a .sln file and a global.json and a .xproj file I don't actually use, and there is a fair bit of C# in here using dynamic and unsafe and plenty of PInvoke declarations.

In my recent attempt, I got no console errors doing this. Even though I reproduced the 'syntax error disappears' issue successfully. shrugs

Above project is not open source, and is not licensed for wider distribution except in aid of fixing VS Code & Omnisharp issues. I will remove the link once this issue is solved.

If you need any help, ask. If needed I can try specific VS Code builds, or provide more files, or potentially remote desktop access.

edit OmniSharp log: http://pastebin.com/u8i0ivJj

Given this is affecting Unity workspaces too, perhaps this is related to having >1 project in a workspace?

@HalfVoxel
Copy link
Author

@HalfVoxel Can you check the output of the developer console in VS Code? That might contain some useful data to let me understand this better/

The developer console (assuming you mean the chrome dev tools) unfortunately logs exactly nothing. I watched it while restarting omnisharp and having a file opened which contains things it should warn about.
image

@HalfVoxel
Copy link
Author

Does Omnisharp actually check for those warnings at all (assigned but not used private fields)?

@leafi
Copy link

leafi commented Oct 13, 2016

Don't think so. But my repro steps require the user to specifically introduce a syntax error; the .zip as-is is buildable.

@leafi
Copy link

leafi commented Oct 14, 2016

Thanks lads. Hacking my local, already-transpiled copy of the extension (in diagnosticsProvider.js) to remove the lines proposed by PR #820 does indeed fix the issue for me.

I look forward to getting my squigglies back on an official basis. Thanks again for looking into this.

@DustinCampbell
Copy link
Member

@leafi: Glad to hear it!

@DustinCampbell DustinCampbell added this to the 1.5 milestone Oct 14, 2016
@DustinCampbell
Copy link
Member

v1.5-beta4 of the extension is now available containing this fix.

@leafi
Copy link

leafi commented Oct 14, 2016

File on that release is called -beta3.vsix

@DustinCampbell
Copy link
Member

Sigh... it's early. 😄 Will fix shortly.

@DustinCampbell
Copy link
Member

Fixed 😄

@nakedpony
Copy link

Thx. v1.5-beta4 indeed fixes the issue.

@dijitalmunky
Copy link

Confirmed working for me as well! Good job!

@masaeedu
Copy link

@DustinCampbell Not sure if I'm seeing a different issue, or this is just how its supposed to work, but I'm not seeing errors where I expect to see them. Here's what I'm doing:

  1. Set up a folder with:
    1. Multiple folders containing project.json files and code
    2. A global.json file with a projects array pointing to each proejct folder
    3. Code in one of the project folders that produces compile errors with dotnet build
  2. Start VS Code 1.6.1 with omnisharp-vscode 1.5-beta4 installed
  3. Open the folder containing global.json

At this point, I don't see any of the errors I see from dotnet build in the bottom ribbon or the "Problems" pane.

I assumed this was because I need to somehow explicitly trigger a build through Omnisharp, but I can't find a way to do so. The only two Omnisharp related options I have available in the command palette are: "Omnisharp: Restart Omnisharp", and "Omnisharp: Select Project", and I've already used the latter to select the project containing the errors. I also tried running "Tasks: Run Build Task", but this results in the output:

Couldn't find 'project.json' in current directory

Here's what the Omnisharp generated tasks.json looks like:

{
    "version": "0.1.0",
    "command": "dotnet",
    "isShellCommand": true,
    "args": [],
    "tasks": [
        {
            "taskName": "build",
            "args": [
                ""
            ],
            "isBuildCommand": true,
            "problemMatcher": "$msCompile"
        }
    ]
}

I'd appreciate any guidance on whether I should be expecting errors to pop up as I work (and so there is a bug), or if I need to build the projects through VS Code using some approach I've missed.

The project I'm working with is a Github fork, so if this is an actual bug rather than PEBKAC, I can push up all my work and give you a link.

@aggieben
Copy link

I tried to install the 1.5-beta4 version, and this was the result:

image

@gregg-miskelly
Copy link
Contributor

gregg-miskelly commented Oct 20, 2016

@aggieben installing .vsix's by hand is sadly pretty confusing. You can NOT double click them. Instead you need to open them as a file from VS Code.

@DustinCampbell
Copy link
Member

That's right. In VS Code, select View->Extensions. Then, at the top-right of Extensions pane click the [...] and select "Install from VSIX..."

@masaeedu
Copy link

@DustinCampbell Any thoughts on my earlier comment? Is the discrepancy between dotnet build and the Omnisharp errors log as intended, or is there some action you need to take for Omnisharp to show you the same errors?

@DustinCampbell
Copy link
Member

@masaeeedu: Sorry for the delay. What you described doesn't look like the same problem that everyone else was experiencing in this thread. Could you file a separate issue? Also, if you have a project that reproduces the problem, that'd be helpful too.

@aggieben
Copy link

aggieben commented Oct 25, 2016

I have the beta4 extension installed now, and after the last code update (1.6.1), this issue is manifesting again. Update: it seems to only be happening for some files. Not sure what's going on.

@matthewjcooper
Copy link

I still have this issue and I'm using VS Code 1.6.1 and Omnisharp 1.5.0-beta4. I have multiple projects with a global.json file.

@DustinCampbell
Copy link
Member

The issue as originally filed was about .csproj/.sln on Unity projects. For any experiencing this issue on project.json, could you please file a separate issue?

@ccbentlee
Copy link

I'm using VS Code 1.6.1 and and Omnisharp 1.5.0-beta4 for my Unity project, the issue here was solved but the flame icon used to show "xxxx.sln" now says "0 projects" even through I select the .sln in the list. Other than that everything is fine.

@Novack
Copy link

Novack commented Nov 4, 2016

Today installed 1.7.1 and the issue is back again. Need help guys cant really work like this. (Tried uninstalling and reinstalling 1.5.0beta4 without result).

@masaeedu
Copy link

masaeedu commented Nov 8, 2016

@DustinCampbell I've put up repro steps for a project.json codebase in #843.

@DustinCampbell
Copy link
Member

OK. I'm going to close this issue. The latest bits are working for most folks and new issues have been opened for further work.

@HawkenKing
Copy link

HawkenKing commented Nov 15, 2016

same here, 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 ;)

I tried the patch csharp-1.5.0-future-preview1.vsix but same issue

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