microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
216 stars 8 forks source link

[BUG] Error: `Request textDocument/hover` failed #1261

Open Apollo3zehn opened 1 month ago

Apollo3zehn commented 1 month ago

Describe the Issue

I am working on this personal Blazor project (https://github.com/nexus-main/nexus) and I get many false-positive errors/warnings in general working with Blazor + Visual Studio Code. This is very annoying and I hope this extension (C# Dev Kit or whatever powering Blazor/Razor) will improve on that front. You are surely aware of the disappointment in the the Visual Studio Marketplace and something needs to happen, otherwise developers will orient towards other solutions (languages or toolkits) which would be very sad for Blazor as it is a great technology.

So yes, I am also very annoyed but I want to help resolve these randomly occuring problems by reporting a specific error I just encountered right after opening the above mentioned project:

[Error - 10:11:40] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 355 must be less than the number of lines 348. (Parameter 'Line')
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
   at Microsoft.CodeAnalysis.LanguageServer.Extensions.GetPositionFromLinePositionAsync(TextDocument document, LinePosition linePosition, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Extensions/Extensions.cs:line 163
   at Microsoft.CodeAnalysis.LanguageServer.Handler.HoverHandler.HandleRequestAsync(TextDocumentPositionParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs:line 47
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
[Error - 10:11:40] Request textDocument/hover failed.
  Message: The requested line number 355 must be less than the number of lines 348. (Parameter 'Line')
  Code: -32000 
[object Object]

grafik

Steps To Reproduce

I am not sure you will be able to reproduce the exact error as everything with Razor language support is very flaky. But if you try to work with the project you will encounter some other misbehaviour after short time, for sure.

But maybe I have just discovered a way to reproduce:

  1. Clone https://github.com/nexus-main/nexus
  2. Check out tag vscode-dotnettools
  3. Open the project in vscode
  4. Wait until everything loaded
  5. Open file CatalogAboutView.razor
  6. Uncomment lines 39 to 46
  7. Try to hover over ProjectUrl in line 52 or any other property

I think uncommenting the code causes the error. Before doing so, it works fine (except that now during testing on my side everything is red underlined :-():

grafik

grafik

I hope you see that this is quite annoying and hard to use at all.

Expected Behavior

Hover should work, no red underlining, no tons of RZ10012 warnings

Environment Information

Octanoz commented 1 month ago

Same, Windows 11, C# Dev Kit 1.7.27