dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

After fixing an error in my ASP.NET Core C# code, it is still being marked with the red wavy underline and hovering over it still shows the old error popup #6846

Open kenny1983 opened 8 months ago

kenny1983 commented 8 months ago

Type: Bug

Issue Description

Title pretty much says it all.

Steps to Reproduce

  1. Open a C# file (.cs extension).
  2. Purposefully introduce some error, e.g. a method call to a method that doesn't exist or a reference to a variable that doesn't exist.
  3. Fix said error, e.g. define the missing method or variable.

    Expected Behavior

    Red, wavy underline disappears and building the project works.

    Actual Behavior

    Building the project works, but the red, wavy underline still appears (even after a successful build!), either in the same place as before, or at the start of the previously-erroneous line. Hovering over it still pops up the old error dialog with the details in it, even if the line has completely changed to not reference the same method/variable anymore!

The worst part of all of this is that it doesn't always happen and can be somewhat difficult to reproduce. But it usually happens to me roughly 10 - 20 times per day, and the only way I've found to resolve it is to:

  1. Delete all bin and obj directories within each project.
  2. Rebuild and run the main project again.

    Logs

    logs.zip

    C# log

    csharp.log

    Environment information

    VSCode version: 1.85.2 C# Extension: 2.15.30 Using OmniSharp: false

    Dotnet Information .NET SDK: Version: 8.0.101 Commit: 6eceda187b Workload version: 8.0.100-manifests.69afb982

Runtime Environment: OS Name: Mac OS X OS Version: 14.3 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/8.0.101/

.NET workloads installed: Workload version: 8.0.100-manifests.69afb982

Host: Version: 8.0.1 Architecture: arm64 Commit: bf5e279d92

.NET SDKs installed: 7.0.405 [/usr/local/share/dotnet/sdk] 8.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

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| |---|---|---|---| |csdevkit|ms-dotnettools|1.2.7|ms-dotnettools.csdevkit-1.2.7-darwin-arm64| |csharp|ms-dotnettools|2.15.30|ms-dotnettools.csharp-2.15.30-darwin-arm64| |csharp-format-usings|gaoshan0621|0.0.4|gaoshan0621.csharp-format-usings-0.0.4| |data-workspace-vscode|ms-mssql|0.5.0|ms-mssql.data-workspace-vscode-0.5.0| |mssql|ms-mssql|1.22.1|ms-mssql.mssql-1.22.1| |sql-bindings-vscode|ms-mssql|0.4.0|ms-mssql.sql-bindings-vscode-0.4.0| |sql-database-projects-vscode|ms-mssql|1.4.1|ms-mssql.sql-database-projects-vscode-1.4.1| |user-secrets|adrianwilczynski|2.0.1|adrianwilczynski.user-secrets-2.0.1| |vscode-dotnet-runtime|ms-dotnettools|2.0.1|ms-dotnettools.vscode-dotnet-runtime-2.0.1| |vscode-dotnet-watch|Murugaratham|1.1.8|murugaratham.vscode-dotnet-watch-1.1.8| |vscodeintellicode-csharp|ms-dotnettools|0.1.26|ms-dotnettools.vscodeintellicode-csharp-0.1.26-darwin-arm64| |vstuc|visualstudiotoolsforunity|0.9.4|visualstudiotoolsforunity.vstuc-0.9.4|;
System Info |Item|Value| |---|---| |CPUs|Apple M3 Pro (11 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|2, 2, 2| |Memory (System)|18.00GB (0.17GB free)| |Process Argv|--crash-reporter-id e0741296-fe57-436d-9555-caf2acc96e94| |Screen Reader|yes| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30951796 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 pythontbext0:30879054 accentitlementsc:30887149 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 dsvsc019bcf:30953938 3ef8e399:30949928 ```
dibarbet commented 2 months ago

@kenny1983 just want to confirm - we've made a number of fixes to the C# extension recently that may have fixed this - could you confirm if you're still seeing this issue in the latest prerelease version (v2.41.26)?