-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Analyzer warnings disappear from Error List when the file with the warning is opened #26817
Comments
Hm, this sounds familiar...I saw similar behavior running static analysis while having the error list set to "Build & Intellisense". As soon as I selected a message/warning/error in the list that caused a new file to open, it would re-populate the error list with Intellisense messages there were already there from the build, ultimately changing the order making it impossible to go thru them from top to bottom. |
I can confirm this using Visual Studio 15.9.2 and Microsoft .NET core 2.1.5.00 (x64). In our team and repo, this can make people push commits that fail the build on the buildserver, which is of course not good. Is there any hope for progress on this? |
I confirm this behaviour on 15.9.7. It only appears to happen with one of our analysers (PumaScan). The behaviour is as described above:
If I change the dropdown to "Build Only" it re-appears. Switching back to "Build + IntelliSense" it disappears again. |
I can also confirm this still happening with Visual Studio 16.4.3 and .NET Core 3.1, and in my case it has been some (but not all) warnings from FxCop analyzers. FWIW, the specific warnings that I've noticed disappearing when the corresponding file is opened are CA1008, CA1027, and CA1813. A warning in the same file/class that does not disappear is CA1018. It might also be worth noting that in addition to not listing these warnings in the Error List, there doesn't appear to be any visual indication of any problems in the IDE (ex. nothing with "squiggle underlines", no colors in the scrollbar, etc.). As others have stated, switching from "Build + IntelliSense" to "Build Only" will bring the "missing" warnings back, and switching back to "Build + IntelliSense" will make them disappear again. This specific problem is covered in issue #19693. |
Reproduction of IssueReproduced:
Resolved: Add an associated CodeFixProvider handle to the DiagnosticAnalyzer. TheoryI'm not too aware of Roslyn and IntelliSense from a systems PoV, but it seems to me that if IntelliSense does not identify a solution it can suggest, it will suppress the error/warning/message. This would explain why when you're not using IntelliSense (e.g. CLI compiling, "Show issues generated" is "Build Only") it shows up, but disappears when you try to incorporate IntelliSense. If this is all true, then I think we should consider moving this issue over to IntelliSense, unless I.S. get's it's queues from Roslyn (again, I don't claim to understand the core of the technologies). |
For the specific case where a diagnostic is reported by a Compilation End analyzer and Full Solution Analysis is disabled, I'm not sure what the current expected behavior is. For other cases, this issue should be fixed by 16.8 Preview 3. /cc @mavasani for FSA expectations |
Compilation end actions for analyzers are executed only if Full solution analysis is enabled. So, in the default VS mode (Full solution analysis is disabled), these compilation end actions are never executed in live analysis. These are essentially build only diagnostics. |
@mavasani it's also possible to trigger the Compilation End actions via the Run Code Analysis command in Solution Explorer |
Unfortunately still happening in VS 2022, making it very impractical to do "one-off" code analyses: |
yep, I came here searching about the same error, VS Community 2022 17.3.6 |
Visual Studio 2022 17.4.2 same issue. Run Code Analysis on Project or Solution and issues listed. Providing you leave as is the list remains but double click an item to fix, file opens and after a few seconds all items disappear (no modifications made to any files). |
Any update on this? I was running Code Analysis on my project in VS 17.4.2, but every time I click on a message the list disappears, I thought was my issue and I was going crazy, but looks like it's a long-lasting issue... it's useless to run Code Analysis like this :( |
@kiwiant @Panda-Sharp Are you able to provide a simple repro for the issues you are seeing? I just ran |
Alright - I can at least repro one bug: Making any edit in the active file clears out all the code analysis violations reported from prior |
@mavasani Thank you for your reply, here you'll can find everything you need, if you need some more details feel free to ask, thanks! |
Fixes dotnet#26817 This PR fixes the regression where in diagnostics reported for a project/solution after executing `Run Code Analysis` command were getting cleared out after editing source files and/or switching active file tabs. While fixing the above, I also enhanced the `Run Code Analysis` to handle multi-tfm projects so that now we run analysis for all tfm flavors of a multi-tfm project instead of just the current tfm.
Fixes dotnet#26817 Fixes [AB#1698190](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1698190) This PR fixes the regression where in diagnostics reported for a project/solution after executing `Run Code Analysis` command were getting cleared out after editing source files and/or switching active file tabs. While fixing the above, I also enhanced the `Run Code Analysis` to handle multi-tfm projects so that now we run analysis for all tfm flavors of a multi-tfm project instead of just the current tfm.
Thanks! I have a PR out with the fix: #66010 |
Hi, the problem still exists in VS 2022 Version 17.5.3 when using the analyzer sonar https://marketplace.visualstudio.com/items?itemName=SonarSource.SonarLintforVisualStudio2022 |
Just updated to Visual Studio Pro Version 17.7.3 and this issue seems to be persisting. As soon as I start clicking on warnings, I'm looking for 'C++ Core Guidelines' type issues today, the list of intellisense warnings starts whittling itself away until 2200 warning items have vanished before I've fixed a single one. Since running code-analysis "on a single project", which actually causes it to run on several including the primary library in the solution, took > 14 minutes on a Xeon based workstation, the erratic behavior of the warnings disappearing in the error-list makes this feature unusable. Was the merged fix included in 17.7.3? |
I think I noticed the same last day, but I was not 100% sure, now I'm... with C# |
@Sand2Silicon This issue only relates to managed code analysis (C# and Visual Basic). For C++ analysis, you would need to file feedback with the Report a Problem tool in Visual Studio. |
Version Used: VS 15.8.0 Preview 1.1, .Net Core SDK 2.1.4
Steps to Reproduce:
dotnet new classlib
dotnet add package Microsoft.CodeQuality.Analyzers
Change code in Class1.cs to:
Open the csproj in VS.
Build Solution.
Open Class1.cs.
Wait a few seconds.
Expected Behavior: Whether the analyzer warning "CA1040 Avoid empty interfaces" appears in the Error List should not depend on whether the relevant file is open.
Actual Behavior: When I Build Solution, the analyzer warning "CA1040 Avoid empty interfaces" appears in the Error List. When I open the relevant file, the warning disappears from the Error List after few seconds.
This only happens in the Build + IntelliSense mode. In the Build Only mode, the warning is always visible
I'm assuming this is a general issue. If it's actually an issue with the specific analyzer, I can move this issue to the dotnet/roslyn-analyzers repo.
The text was updated successfully, but these errors were encountered: