dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.91k stars 4.01k forks source link

Visual Studio - Error List: `Build + IntelliSense` does not contain an error shown in `Build` #19693

Open tom-dudley opened 7 years ago

tom-dudley commented 7 years ago

visual-studio-error-list

The above happens after a failed build. The Output pane correctly gives the project and analyzer ID.

Version Used: I can reproduce this issue with both Visual Studio 2015 14.0.25431.01 Update 3 and Visual Studio 2017 15.0.0+26228.10

Steps to Reproduce: Unfortunately I can't reliably reproduce this (sometimes the errors do appear in Build + IntelliSense). I'm encountering it while running some SonarLint rules. The rule is available here. The class violating the rule is part of a WinForms application.

If someone can provide some steps to take to try and nail down a repro I'd be happy to help.

Expected Behavior: Build + IntelliSense is the union of the results on the Build option and the IntelliSense option.

Actual Behavior:

tom-dudley commented 7 years ago

This is a duplicate of https://github.com/dotnet/roslyn/issues/11462 which itself is a duplicate of https://github.com/dotnet/roslyn/issues/11378

Closing.

tom-dudley commented 7 years ago

Re-opened since apparently the root issue, https://github.com/dotnet/roslyn/issues/11378 was fixed, but I'm still getting this in VS 2017.

tom-dudley commented 7 years ago

Perhaps someone could clarify, does Build + IntelliSense mean the intersection of the two sets? So the reason I'm not seeing the error on Build + IntelliSense is that the IntelliSense squiggles aren't working?

If this is the case, is this still a Roslyn / Microsoft issue, or is it handled by a user setting / analyzer package? As far as I'm aware, whenever a cs file is open, and the corresponding project has analyzers with some rules set to error, then any violations of that rule (in open files) should get picked up by IntelliSense. This should happen out of the box, regardless of the analyzer used and without having to configure any settings.

soerenBoisen commented 6 years ago

I too face this critical bug in VS2017. For me, it was a lack of casting a parameter of type dynamic to the type expected by the method. It seems to be reproducible since I rebuilt a bunch of times and restarted VS. After restart the error shortly appeared on the normal "Build + Intellisense" list but then disappeared. Switching to "Build Only" shows the error. Adding the cast made the project build again.

frozenprakash commented 4 years ago

Wasted almost a day due to this issue !! Founded out this issue at last from stackoverflow, kindly fix it ASAP !

CyrusNajmabadi commented 4 years ago

@mavasani do you know what's going o here? I think i've also run into this occasionally? Maybe some sort of race between listening to build events and whatever solution crawler is producing?

mavasani commented 4 years ago

@CyrusNajmabadi There could be multiple reasons:

  1. Diagnostics which are reported during build, but not during live analysis. This happens for compilation level compiler diagnostics, such as unused or unassigned field diagnostics - we never run these in live analysis (it is only reported on compilation.GetDiagnostics, which is an expensive operation). This also happens for diagnostics reported from analyzers in CompilationEnd actions, unless user has explicitly changed the background analysis scope to full solution.
  2. Bugs in de-duping logic, where we replace build diagnostics with diagnostics from live analysis whenever we analyze a specific document or project.
  3. Bugs in IDE analyzer executing logic, diagnostics caching logic, etc. etc.

Unfortunately, there is no easy way to tackle this problem other then work off each repro. Also tagging @vatsalyaagrawal as we discussed issues in this space a bit today.

janseris commented 2 years ago

This seems fixed now in 17.3.0 and maybe was already in 17.2.5

wilfriedb commented 1 year ago

Unfortunately this issue still exists in VS 17.5.1. Actually, sometimes the missing warnings do pop-up for a short time, only to disappear after a few seconds. I've only noticed this issue with RSnnnn code warnings.

vzarytovskii commented 1 year ago

We see it in F# too (which uses Roslyn's ExternalAccess to report live, document diagnostics). Is there a workaround for it, we can implement?

shaneharper commented 1 year ago

https://github.com/shaneharper/Visual_Studio_Warning_Not_Shown_In_Error_List is a very small project that demonstrates that Build + IntelliSense isn't always the union of the results on the Build option and the IntelliSense option.

Note that the unexpected behaviour occurs only when the source file for which a compiler warning is generated was open in an editor window at the time it was compiled.

I've observed this happening with Visual Studio 2022 v17.5.4 and with v17.10.5. I've reported it here: https://developercommunity.visualstudio.com/t/Error-List:-Build--IntelliSense-pane/10712993.