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
19.12k stars 4.04k forks source link

Filtering error list does not update. #37599

Closed JohanLarsson closed 1 year ago

JohanLarsson commented 5 years ago

Animation

I expected the warnings to show up here.

CyrusNajmabadi commented 5 years ago

if you click and wait longer, do they eventually show up?

JohanLarsson commented 5 years ago

I tried waiting for a couple of minutes now and they did not show up.

JohanLarsson commented 5 years ago

Not sure if it has anything to do with it but there are a couple of:

Severity    Code    Description Project File    Line    Suppression State   Detail Description
Warning AD0001  Analyzer 'Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers.CSharpDiagnosticAnalyzerApiUsageAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.  Gu.Roslyn.AnalyzerExtensions.Tests      1   Active  Analyzer 'Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers.CSharpDiagnosticAnalyzerApiUsageAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: Gu.Roslyn.AnalyzerExtensions.Tests
ISymbol: INamedTypeSymbolExtensionsTests (NamedType)

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.DiagnosticAnalyzerApiUsageAnalyzer`1.AddUsedNamedTypeCore(ITypeSymbol typeOpt, Builder builder, Boolean& hasAccessToTypeFromWorkspaceAssemblies)
   at Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.DiagnosticAnalyzerApiUsageAnalyzer`1.AddUsedNamedTypeCore(ITypeSymbol typeOpt, Builder builder, Boolean& hasAccessToTypeFromWorkspaceAssemblies)
   at Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.DiagnosticAnalyzerApiUsageAnalyzer`1.GetUsedNamedTypes(INamedTypeSymbol namedType, Compilation compilation, CancellationToken cancellationToken, Boolean& hasAccessToTypeFromWorkspaceAssemblies)
   at Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.DiagnosticAnalyzerApiUsageAnalyzer`1.<>c__DisplayClass11_0.<Initialize>b__1(SymbolAnalysisContext symbolContext)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSymbolActionsCore>b__40_1(ValueTuple`2 data)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----
'.
CyrusNajmabadi commented 5 years ago

Tagging @mavasani @heejaechang @jinujoseph . A couple of issues.

  1. the filtering numbers should never get out of sync with teh error list like this. that just indicates corruption somewhere in teh system. because the filtering UI thinks we have the items, but the actual list does not. that's just bad and broken no matter what.
  2. it's possible the analyzer warnings are causing this, but i'm not sure how. But maybe it's a good place to start looking to see if we could somehow get desynced here?

Thanks!

JohanLarsson commented 5 years ago

I closed VS and git clean -dxf When opening the sln and rebuild only the 2 NU1603 errors were in the list, waited a couple of minutes but saw no late arrivals. Then I opened a random document and did another rebuild and then 255 warnings showed up but most of them could not be filtered like in the gif.

JohanLarsson commented 5 years ago

Solution used is here

Chances are this csproj triggers a bunch of edge cases.

JohanLarsson commented 5 years ago
Microsoft Visual Studio Enterprise 2019
Version 16.1.6
VisualStudio.16.Release/16.1.6+29102.190
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Enterprise

Visual C++ 2019   00435-60000-00000-AA947
Microsoft Visual C++ 2019

Application Insights Tools for Visual Studio Package   9.1.00429.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019   16.1.429.50124
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019   16.1.429.50124
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.1.429.50124
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   16.1.429.50124
Azure Functions and Web Jobs Tools

C# Tools   3.1.1-beta4-19281-06+58a4b1e79aea28115e66b06f850c83a3f1fcb6d3
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

EZ-GIT   1.9.0

File Nesting   2.6.85
Automatically nest files based on file name and enables developers to nest and unnest any file manually

JetBrains ReSharper Ultimate 2019.1.3   Build 191.0.20190704.212735
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2019 JetBrains, Inc.

Kill the WPF Designer   1.0
Helper for killing the WPF designer. Kills all instances of XDesProc.exe.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.20419.2

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

NuGet Package Manager   5.1.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension   1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.61904.23160
Microsoft SQL Server Data Tools

StylerPackage Extension   1.0
StylerPackage Visual Stuido Extension Detailed Info

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

TypeScript Tools   16.0.10506.2004
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.1.1-beta4-19281-06+58a4b1e79aea28115e66b06f850c83a3f1fcb6d3
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6   16.1.0-beta.19253.3+42526fe359672a05fd562dc16a91a43d0fe047a7
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Spell Check Everywhere   VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers
mavasani commented 5 years ago

@JohanLarsson Did the repro involve doing an explicit build sometime before? Seems likely that all those diagnostics were reported first from intellisense, then cleared out from error list when you triggered an explicit build, but the filters still did not get updated. Eventually the build diagnostics to get populated in the error list, and then slowly get replaced/deduped with intellisense diagnostics, giving you correct error list and filters state.

mavasani commented 5 years ago

Ah, reading your comments above, it seems you did indeed invoke rebuild, which probably matches my assumption. @heejaechang - would this be something that the error list team needs to look at to ensure the filter numbers/check boxes are updated as soon as error list entries are removed?

mavasani commented 5 years ago

@JohanLarsson The AD0001 is like dupe of https://github.com/dotnet/roslyn-analyzers/issues/1888#issuecomment-454969167.

CyrusNajmabadi commented 5 years ago

@mavasani

giving you correct error list and filters state.

Note: regardless of how things are updating, it just seems 100% to me that it would be a bug for the error-list filter-state to ever be out of sync (or, at least, they should only be out of sync for a tiny amount of time).

The reason for this is that both should be views over a single source of data that acts as the truth. i.e. the numbers in the filter should exactly correspond to rows that woudl appear if the item is checked, or dissapear if unchecked. I would really expect the filters to be exactly built out of the virtual items of the list.

About the only thing i could accept was if the filters were computed slightly asynchronously just for perf. but even then, they would only trail the error list by an extremely small time window.

Having them be different for long periods of time (minutes for Johan), indicates that they're using separate sources of truth, which just seems busted.

mavasani commented 5 years ago

I followed up with David Pugh from the error list team offline, and he had the following comment:

Looking at the gif, that looks like it might be a problem we’ve seen before (and is a error provider problem). Specifically:

  1. Someone reports a snapshot with, say, some SA1313 warnings. We populate the error list filter with that count.
  2. Because all errors are turned off, at the end of an update, we release the error list snapshots (we remember that we had, say snapshot 13 from a particular error list factory but not the snapshot itself).
  3. The error list filter change and we try and go through all the error list factories and ask the factory above for snapshot 13.
  4. It says either I can’t recreate that snapshot or it returns a snapshot with different data.
  5. We end up not being able to display an errors because we were not able to get the errors we were originally given.

There is a brief race condition where we, for example, step 4 happens between updates (and we clean things up on the next update) but that shouldn’t be a problem. The problem comes if someone can't rehydrate the old snapshot but hasn't triggered an update.

Effectively we are counting on the ability to release snapshots and get the original data back from the version number later. If a provider can’t do that, then it needs to be able to give us the snapshot for the latest version (and have told us to do an update).

@heejaechang Do you have more context on this?

CyrusNajmabadi commented 5 years ago

Effectively we are counting on the ability to release snapshots and get the original data back from the version number later. If a provider can’t do that, then it needs to be able to give us the snapshot for the latest version (and have told us to do an update).

Interesting. That said, if it can't get back a snapshot, shouldn't it repopulate the filter accordingly?

Effectively we are counting on the ability to release snapshots and get the original data back from the version number later.

Is this a helpful optimization? Effectively, you're going to need that data. So why not hold onto it? What's the value in removing it?

CyrusNajmabadi commented 1 year ago

I don't repro this. it works fine for me currently.

Ironeer commented 1 year ago

I got the same error in VS 22 Version 17.3.4. The error filter list contains codes that are not occuring anymore. Deleting the .vs folder and reopening the project did not fix it. grafik