dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.85k stars 667 forks source link

Build diagnostics not showing for large projects with Full Solution Analysis (FSA) #6606

Open beccamc opened 10 months ago

beccamc commented 10 months ago

There are two types of diagnostics reported by C#/Devkit extensions. Some are live diagnostics reported by analyzers and some are build diagnostics reported by the build. Live diagnostics may be computed for open files only, or for every file via full solution analysis.

Full solution analysis (FSA) can be slow for large projects. Due to deduping of build and live diagnostics, if FSA is on build diagnostics are ignored unless they are "build-only" (i.e. cannot be reported live). This means that for large projects, where FSA may be slow to return results, it may take a long time for legitimate problems to appear in the problem window.

Steps to reproduce

  1. Open a large project. Modify dotnet.backgroundAnalysis.analyzerDiagnosticsScope and dotnet.backgroundAnalysis.compilerDiagnosticsScope to "fullSolution"
  2. Reload the project
  3. Run the build

Expected behavior

I should see diagnostics as soon as they are available. If the build completes before FSA, I see all the build diagnostics. If FSA finishes first, I see all the live diagnostics.

Actual behavior

Although the build has completed, I don't see problems until they are reported by FSA.   Related to work https://github.com/dotnet/vscode-csharp/issues/5728

ivansalazar commented 10 months ago

I might be impacted by this. Are there any suggested workarounds? I had to downgrade to ms-dotnettools.csharp-1.25.9@win32-x64. as all versions after 2.0 broke the Problems Window in a different way or another.

JoeRobich commented 10 months ago

@ivansalazar Disabling the DevKit extension and setting dotnet.server.useOmnisharp to true in settings should give an experience similar to downgrading to 1.x without having to downgrade.

ivansalazar commented 10 months ago

@JoeRobich That doesn’t seem to work for me. I still need to open files for Problems to be found.

dibarbet commented 10 months ago

@ivansalazar can you check the values of these settings? You'll need to switch them to 'fullSolution' to get diagnostics in closed files.

image
ivansalazar commented 10 months ago

@dibarbet

Checked with v2.10.28. Both settings set to fullSolution, true on use omnisharp.

Still broken.

The easiest example I have is having an EF Core data model and a set of Razor Pages doing CRUD for said model. Changing the name of one of the entities in a mode file breaks the razor pages, but given that those are located in different files, they are only analyzed when opened. And this is not a large project by any means. I have like 50 files, tops. 10 entities, 5 pages (index, create, details, update, delete) each.

dibarbet commented 10 months ago

Ah are the missing diagnostics in Razor files? @davidwengier does Razor report full solution diagnostics? Or only open files

davidwengier commented 10 months ago

Generally speaking, only open files. I think we report some issues for closed files in VS Code when UseOmniSharp is false, but thats a happy accident rather than deliberate choice.

ivansalazar commented 10 months ago

@dibarbet

Not only on razor files (I meant the page model file rather than the html page file, anyways).

That was the closest example I could think of, but even across non-razor files this is happening. For example, closed files in my data model aren’t being analyzed. Say, I edit the name of a class that’s used in other closed files in the data model, I would expect errors being reported as the class can’t be found anymore, but nothing happens until I open the other files, one by one.

And as I said, downgrading to 1.x works, as I just downgraded today and errors are reported in mere seconds, as expected.

benjaminmillhouse commented 8 months ago

I am seeing the same behavior. Full-Solution Analysis is not working. If I make a change in a file, I see the "Analyzing Files" icon flash briefly in the footer, but it goes away immediately and the "problems" count only updates for the file that I have open. I have Full Solution set on both of the values mentioned above, and have it set to use OmniSharp.

Environment information

VSCode version: 1.85.1 C# Extension: 2.15.30 Using OmniSharp: true

Mono Information OmniSharp using mono: 6.12.0
Dotnet Information .NET SDK: Version: 7.0.101 Commit: bb24aafa11 Runtime Environment: OS Name: Mac OS X OS Version: 14.2 OS Platform: Darwin RID: osx-x64 Base Path: /usr/local/share/dotnet/sdk/7.0.101/ Host: Version: 7.0.1 Architecture: x64 Commit: 97203d38ba .NET SDKs installed: 1.0.0-preview1-002702 [/usr/local/share/dotnet/sdk] 1.0.0-preview2-003121 [/usr/local/share/dotnet/sdk] 1.0.0-preview2-1-003177 [/usr/local/share/dotnet/sdk] 2.1.301 [/usr/local/share/dotnet/sdk] 2.1.302 [/usr/local/share/dotnet/sdk] 2.1.504 [/usr/local/share/dotnet/sdk] 2.1.505 [/usr/local/share/dotnet/sdk] 3.1.201 [/usr/local/share/dotnet/sdk] 3.1.409 [/usr/local/share/dotnet/sdk] 3.1.422 [/usr/local/share/dotnet/sdk] 3.1.426 [/usr/local/share/dotnet/sdk] 5.0.203 [/usr/local/share/dotnet/sdk] 5.0.408 [/usr/local/share/dotnet/sdk] 6.0.400 [/usr/local/share/dotnet/sdk] 6.0.404 [/usr/local/share/dotnet/sdk] 7.0.101 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.28 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.32 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.0-rc2-3002702 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.28 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.32 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |al|ms-dynamics-smb|12.5.914975|ms-dynamics-smb.al-12.5.914975| |al-code-outline|andrzejzwierzchowski|3.0.56|andrzejzwierzchowski.al-code-outline-3.0.56| |al-object-designer|martonsagi|0.2.4|martonsagi.al-object-designer-0.2.4| |azure-account|ms-vscode|0.11.6|ms-vscode.azure-account-0.11.6| |code-runner|formulahendry|0.12.1|formulahendry.code-runner-0.12.1| |code-spell-checker|streetsidesoftware|3.0.1|streetsidesoftware.code-spell-checker-3.0.1| |copilot|GitHub|1.148.0|github.copilot-1.148.0| |copilot-chat|GitHub|0.11.1|github.copilot-chat-0.11.1| |crs-al-language-extension|waldo|1.5.31|waldo.crs-al-language-extension-1.5.31| |csharp|ms-dotnettools|2.15.30|ms-dotnettools.csharp-2.15.30-darwin-x64| |csharpextensions|kreativ-software|1.7.3|kreativ-software.csharpextensions-1.7.3| |git-graph|mhutchie|1.30.0|mhutchie.git-graph-1.30.0| |github-vscode-theme|GitHub|6.3.4|github.github-vscode-theme-6.3.4| |gitlens|eamodio|14.6.1|eamodio.gitlens-14.6.1| |html-css-class-completion|Zignd|1.20.0|zignd.html-css-class-completion-1.20.0| |json-escaper|joshuapoehls|1.1.2|joshuapoehls.json-escaper-1.1.2| |material-icon-theme|PKief|4.33.0|pkief.material-icon-theme-4.33.0| |material-theme|zhuangtongfa|3.16.2|zhuangtongfa.material-theme-3.16.2| |prettier-vscode|esbenp|10.1.0|esbenp.prettier-vscode-10.1.0| |rainbow-csv|mechatroner|3.11.0|mechatroner.rainbow-csv-3.11.0| |sort-json|Thinker|19.1.1|thinker.sort-json-19.1.1| |todo-tree|Gruntfuggly|0.0.226|gruntfuggly.todo-tree-0.0.226| |vscode-azureappservice|ms-azuretools|0.25.1|ms-azuretools.vscode-azureappservice-0.25.1| |vscode-azurefunctions|ms-azuretools|1.13.1|ms-azuretools.vscode-azurefunctions-1.13.1| |vscode-azureresourcegroups|ms-azuretools|0.8.3|ms-azuretools.vscode-azureresourcegroups-0.8.3| |vscode-cosmosdb|ms-azuretools|0.20.0|ms-azuretools.vscode-cosmosdb-0.20.0| |vscode-dotnet-runtime|ms-dotnettools|2.0.0|ms-dotnettools.vscode-dotnet-runtime-2.0.0| |vscode-eslint|dbaeumer|2.4.2|dbaeumer.vscode-eslint-2.4.2| |vscode-github-actions|github|0.26.2|github.vscode-github-actions-0.26.2| |vscode-nuget-gallery|patcx|0.0.24|patcx.vscode-nuget-gallery-0.0.24| |vscode-theme-onedark|akamud|2.3.0|akamud.vscode-theme-onedark-2.3.0| |xml|DotJoshJohnson|2.5.1|dotjoshjohnson.xml-2.5.1|;