roslyn: Analyzer warnings disappear from Error List when the file with the warning is opened

Version Used: VS 15.8.0 Preview 1.1, .Net Core SDK 2.1.4

Steps to Reproduce:

  1. dotnet new classlib

  2. dotnet add package Microsoft.CodeQuality.Analyzers

  3. Change code in Class1.cs to:

    namespace Foo
    {
        public interface IFoo { }
    }
    
  4. Open the csproj in VS.

  5. Build Solution.

  6. Open Class1.cs.

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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 20 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Unfortunately still happening in VS 2022, making it very impractical to do “one-off” code analyses: Analyze menu > Run Code Analysis > On Solution Microsoft Visual Studio Community 2022, Version 17.3.6, VisualStudio.17.Release/17.3.6+32929.385

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?

Thanks! I have a PR out with the fix: https://github.com/dotnet/roslyn/pull/66010

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

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

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

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 😦

Unfortunately still happening in VS 2022, making it very impractical to do “one-off” code analyses: Analyze menu > Run Code Analysis > On Solution Microsoft Visual Studio Community 2022, Version 17.3.6, VisualStudio.17.Release/17.3.6+32929.385

yep, I came here searching about the same error, VS Community 2022 17.3.6