vscode-csharp
vscode-csharp copied to clipboard
Request textDocument/foo failed
Environment data
dotnet --info output: 7.0.409 VS Code version: 1.89.1 C# Extension version: 2.31.19
OmniSharp log
n/a
Steps to reproduce
Open Razor Pages cshtml file
Expected behavior
No popups.
Actual behavior
Endless series of popups on the bottom right:
Request textDocument/semanticTokens/range failed.
Additional context
Problem started after upgrading to vscode-csharp2.31.19 released today.
The "C#" log window has this:
[Error - 4:03:11 PM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=133, Character=7 }, End={ Line=932, Character=7 } }. text.Length=51894. text.Lines.Count=823
---> System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 823. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 330
--- End of inner exception stack trace ---
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335
at Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintHandler.HandleRequestAsync(InlayHintParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs:line 45
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
Error making textDocument/inlayHint request: Range={ Start={ Line=133, Character=7 }, End={ Line=932, Character=7 } }. text.Length=51894. text.Lines.Count=823
[Error - 4:03:11 PM] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 823. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 103
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(IGlobalOptionService globalOptions, SemanticTokensRefreshQueue semanticTokensRefreshQueue, Range[] ranges, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 46
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 44
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
[Error - 4:03:11 PM] Request textDocument/semanticTokens/range failed.
Message: The requested line number 932 must be less than the number of lines 823. (Parameter 'Line')
Code: -32000
[object Object]
Even after the popup shows, another then another and another (...) is shown, simply by scrolling in the document.
I restarted a few times, and the problem eventually stopped. Weird.
It's back. I can get three popups one on top of the other:
Request textDocument/definition failed.
Request textDocument/documentHighlight failed.
Request textDocument/hover failed.
The errors are all different, but it's obviously the same root problem. Only started in latest version.
[Error - 7:13:41 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=150, Character=261 }, End={ Line=932, Character=7 } }. text.Length=54132. text.Lines.Count=892
---> System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 330
--- End of inner exception stack trace ---
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335
at Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintHandler.HandleRequestAsync(InlayHintParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs:line 45
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
Error making textDocument/inlayHint request: Range={ Start={ Line=150, Character=261 }, End={ Line=932, Character=7 } }. text.Length=54132. text.Lines.Count=892
[Error - 7:13:41 AM] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 103
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(IGlobalOptionService globalOptions, SemanticTokensRefreshQueue semanticTokensRefreshQueue, Range[] ranges, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 46
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 44
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
[Error - 7:13:41 AM] Request textDocument/semanticTokens/range failed.
Message: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
Code: -32000
[object Object]
[Error - 7:13:42 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=150, Character=261 }, End={ Line=932, Character=7 } }. text.Length=54132. text.Lines.Count=892
---> System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 330
--- End of inner exception stack trace ---
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335
at Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintHandler.HandleRequestAsync(InlayHintParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs:line 45
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
Error making textDocument/inlayHint request: Range={ Start={ Line=150, Character=261 }, End={ Line=932, Character=7 } }. text.Length=54132. text.Lines.Count=892
[Error - 7:13:42 AM] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 103
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(IGlobalOptionService globalOptions, SemanticTokensRefreshQueue semanticTokensRefreshQueue, Range[] ranges, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 46
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 44
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
[Error - 7:13:42 AM] Request textDocument/semanticTokens/range failed.
Message: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
Code: -32000
[object Object]
[Error - 7:13:42 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=150, Character=261 }, End={ Line=932, Character=7 } }. text.Length=54132. text.Lines.Count=892
---> System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 330
--- End of inner exception stack trace ---
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335
at Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintHandler.HandleRequestAsync(InlayHintParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs:line 45
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
Error making textDocument/inlayHint request: Range={ Start={ Line=150, Character=261 }, End={ Line=932, Character=7 } }. text.Length=54132. text.Lines.Count=892
[Error - 7:13:42 AM] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 103
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(Document document, ImmutableArray`1 spans, Boolean supportsVisualStudioExtensions, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(IGlobalOptionService globalOptions, SemanticTokensRefreshQueue semanticTokensRefreshQueue, Range[] ranges, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 46
at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 44
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
[Error - 7:13:42 AM] Request textDocument/semanticTokens/range failed.
Message: The requested line number 932 must be less than the number of lines 892. (Parameter 'Line')
Code: -32000
[object Object]
I get the same error when working on the project for the dot.net website. I can open the project normally and I usually get this error once I start working in one of the .cshtml pages.
VS Code team, you can get the source at https://github.com/dotnet/website.
@phil-allen-msft
Same problem here, reverting to version 2.30.28 seems to be a temporary solution until a new update fixes the issue.
Extensions > c# > right-click on extension > "Install Another Version" > select "2.30.28" from dropdown.
The original error seems to appear more when also using C# Dev Kit extension, though this is not yet confirmed.
I get the errors even without the C# DevKit extension.
I found at least a temporary solution, manually cleaning everything out of of build/obj and rebuilding. It seems the c# ext relies on a bunch of files in there and things like changing file names cause it all sorts of confusion. I still have to restart the language server every once in a while but I managed to get some work done yesterday. On Friday it was basically unusable
We're sorry you are running into this. We are working on this class of issue, but in the meantime another user reported this as a potential way to get behavior more like what you may expect: https://github.com/microsoft/vscode-dotnettools/issues/722#issuecomment-2126269970
My temporary solution no longer works, this morning my vs code environment is again very broken. Walls of red/yellow squiggles on working code that weren't there yesterday. After a bit I start getting the pop-ups from the language server again. It makes it very difficult to work
@skyshaver You can downgrade to the previous version or you can use the workaround:
"dotnet.server.suppressLspErrorToasts": true
Answer from #7548 @JoeRobich Yes, this behaviour is reproducible between VS Code sessions, in fact it happens way too often and I have to restart VS Code every half an hour to get IntelliSense back. I work on a decent size Blazor solution and have Codeium activated. I can't put my finger on exactly what causes the plugin to crash, but here are some thoughts:
- It most likely will crash if I copy and paste some class or declaration which would cause a compilation error
- It takes long time, up to a minute or so, for the IntelliSense to load when I initially open my solution folder
- I have 5 projects in my solution that loads
- I have another solution within the loaded folder structure with a Unit Test project (not loaded)
This should be resolved in 2.51.17 or higher