dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 653 forks source link

Language Server stops working #7283

Open nelson-m-ferreira-sibs opened 6 days ago

nelson-m-ferreira-sibs commented 6 days ago

Type: Bug

Issue Description

Language Server and Intellisense both stop working after some time. I'm unable to determine if the bug occurs after stopping and restarting debug sessions, or after an error is introduced by myself (mistyped something in code or Xaml), or a mix of both.

I've also tried to use the commands .NET: Restart Language Server and Developer: Reload Window in multiple occasions when the bug happens, but without success. Only starts working again if I close the app and re-open it.

Steps to Reproduce

Unsure of the steps since it looks intermitent, but frequent.

  1. Open a Solution containing a MAUI project;
  2. Debug the app;
    • In my case I'm porting a project from Xamarin.Forms to MAUI, and I'm updating layouts, changing code and then restarting debug several times to reflect code changes.

Expected Behavior

Actual Behavior

Logs

vscode_logs.zip

C# log

csharp_log.log

C# LSP Trace Logs

csharp_lsp_trace_logs.log

Environment information

VSCode version: 1.90.2 C# Extension: 2.34.12 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 8.0.204 Commit: c338c7548c Workload version: 8.0.200-manifests.1f2e3bea Runtime Environment: OS Name: Mac OS X OS Version: 14.1 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/8.0.204/ .NET workloads installed: [maui-maccatalyst] Installation Source: SDK 8.0.200 Manifest Version: 8.0.7/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.7/WorkloadManifest.json Install Type: FileBased [maui-ios] Installation Source: SDK 8.0.200 Manifest Version: 8.0.7/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.7/WorkloadManifest.json Install Type: FileBased Host: Version: 8.0.4 Architecture: arm64 Commit: 2d7eea2529 .NET SDKs installed: 6.0.413 [/usr/local/share/dotnet/sdk] 6.0.416 [/usr/local/share/dotnet/sdk] 6.0.417 [/usr/local/share/dotnet/sdk] 6.0.418 [/usr/local/share/dotnet/sdk] 6.0.419 [/usr/local/share/dotnet/sdk] 6.0.420 [/usr/local/share/dotnet/sdk] 7.0.307 [/usr/local/share/dotnet/sdk] 7.0.310 [/usr/local/share/dotnet/sdk] 7.0.311 [/usr/local/share/dotnet/sdk] 7.0.312 [/usr/local/share/dotnet/sdk] 7.0.313 [/usr/local/share/dotnet/sdk] 7.0.314 [/usr/local/share/dotnet/sdk] 8.0.204 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.24 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.25 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.26 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.27 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.28 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.24 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.25 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.26 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.27 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.28 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.4 [/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| |---|---|---|---| |csdevkit|ms-dotnettools|1.7.27|ms-dotnettools.csdevkit-1.7.27-darwin-arm64| |csharp|ms-dotnettools|2.34.12|ms-dotnettools.csharp-2.34.12-darwin-arm64| |dart-code|Dart-Code|3.90.0|dart-code.dart-code-3.90.0| |dotnet-maui|ms-dotnettools|1.0.6|ms-dotnettools.dotnet-maui-1.0.6-darwin-arm64| |flutter|Dart-Code|3.90.0|dart-code.flutter-3.90.0| |githistory|donjayamanne|0.6.20|donjayamanne.githistory-0.6.20| |jbockle-format-files|jbockle|3.4.0|jbockle.jbockle-format-files-3.4.0| |material-icon-theme|PKief|5.4.2|pkief.material-icon-theme-5.4.2| |nugetpackagemanagergui|aliasadidev|2.1.0|aliasadidev.nugetpackagemanagergui-2.1.0| |prettier-vscode|esbenp|10.4.0|esbenp.prettier-vscode-10.4.0| |vscode-diff|fabiospampinato|2.1.2|fabiospampinato.vscode-diff-2.1.2| |vscode-dotnet-runtime|ms-dotnettools|2.0.7|ms-dotnettools.vscode-dotnet-runtime-2.0.7|;

Extension version: 2.34.12 VS Code version: Code 1.90.2 (Universal) (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:37:41.291Z) OS version: Darwin arm64 23.1.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 (8 x 2400)| |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
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|2, 2, 2| |Memory (System)|8.00GB (0.49GB free)| |Process Argv|--crash-reporter-id 2c2604eb-9cf2-4b38-8bf3-5a110699c0bb| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscorecescf:30445987 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 jchc7451:31067544 chatpanelt:31048053 dsvsc021:30996838 01bff139:31013167 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 legacy_priority:31082724 ```
dibarbet commented 5 days ago

@nelson-m-ferreira-sibs since you're using C# devkit .NET: Restart Language Server won't work (there is a known bug with that). However I would expect Reload window to function exactly the same as closing / re-opening.

Nothing looks like its going incredibly wrong from the logs. I do see that the language server restarted, which as above has a bug which will cause the language server to lose the project information, so definitely try reloading the window.

A couple of other questions

  1. To confirm, you're losing colorization / completion suggestions in both .cs and .xaml files? If you can share a screenshot of the incorrect behavior that might help.
  2. Is there any specific kind of change that triggers the behavior? For example does it always happen after making a change to a .csproj?
  3. Are there any other popup warnings saying anything went wrong?
danosted commented 5 days ago

I was in the middle of writing a long comment with me having this issue as well. Meanwhile I left vscode running in the background - the state was as described in this issue - no colorization / completion suggestions. The logs indicated that everything was loaded and running, no errors or anything indicating something was wrong (even though the case was clearly the opposite).

Right before I hit send, I went back to vscode to confirm. And voilà, suddenly intellisense had kicked in. Not sure what the take from this should be, but maybe there is missing an indicator that things are still loading?

nelson-m-ferreira-sibs commented 5 days ago

Hi @dibarbet

Yesterday after posting the issue I've updated the .NET MAUI VS Code extension to the v1.1.14 (pre-release) version and I haven't used it enough today to provide a complete feedback, but I'll try to answer as far as I'm able to:

  1. Yes, I'm losing both colorization and completion in both .cs and .xaml files, having only the basic auto-completion present on VS Code (the one that has the "abc" icon);
  2. I'm still unable to provide a single point that causes this error to occur but I can guarantee that no .csproj changes are being made (both manually or automatically, since I'm only editing the current files and not adding/removing/renaming files). One thing I haven't mentioned previously is that I'm using the Hot Reload to edit some layouts on the fly and doing some changes in the code while running a debug session and is in-between debug sessions that the error has been occurring. I'll try to be aware of my actions to see if I can provide a more meaningful report later.
  3. There was an error that would popup when I tried to navigate to a definition of a class or element. When everything is okay I'm able to navigate to the correct definition, but when the bug is occurs I'm unable to do it, be it from a .xaml file or a .cs file. I'll keep an eye on any popup warnings that might appear and will try to capture screenshots when they happen.

I apologize for not being able to provide more information for now, will keep an eye next Monday to see if I can make it happen again.

nelson-m-ferreira-sibs commented 1 day ago

Hi @dibarbet

Since I've reported this issue I tried to update the .NET MAUI Extension to version v1.1.14 (pre-release) and in this version the issue hasn't happened so far. Unfortunately since this speeds up a bit things on my side I can't revert to the previous version for some time.

Meanwhile I've managed to catch the error that happened at the same time before: Screenshot 2024-07-02 at 09 42 49

Unsure if it's 100% the same error, but I do remember being very similar to this one (when trying to go to definition of an element in .xaml, for example a custom element, it would popup the error message and wouldn't navigate).

dibarbet commented 23 hours ago

Right before I hit send, I went back to vscode to confirm. And voilà, suddenly intellisense had kicked in. Not sure what the take from this should be, but maybe there is missing an indicator that things are still loading?

@danosted by any chance was the Projects spinner in the bottom left spinning? Or was it displaying a static list of projects image

dibarbet commented 23 hours ago

Hi @dibarbet

Since I've reported this issue I tried to update the .NET MAUI Extension to version v1.1.14 (pre-release) and in this version the issue hasn't happened so far. Unfortunately since this speeds up a bit things on my side I can't revert to the previous version for some time.

Meanwhile I've managed to catch the error that happened at the same time before: Screenshot 2024-07-02 at 09 42 49

Unsure if it's 100% the same error, but I do remember being very similar to this one (when trying to go to definition of an element in .xaml, for example a custom element, it would popup the error message and wouldn't navigate).

Interesting - that error message is helpful. Looks like its trying to navigate to a source generated file which isn't supported yet, see https://github.com/dotnet/vscode-csharp/issues/6426

However I don't think that should cause colorization and everything else to disappear. I'm glad 1.1.14 is working better so far, but let me know if the issue occurs again. I'd also be interested if you see it again. There are some project load issues we're working on as well which might be contributing. Hope to have those fixed next week.