How to fix "Request textDocument/semanticTokens/range failed" and "Request textDocument/hover failed" in my blazor v8 project

Bracho Yanez, Karol 5 Reputation points
2024-07-11T10:12:19.4533333+00:00

It displays endless message from the gold bar:
"Request textDocument/semanticTokens/range failed"

"Request textDocument/hover failed"


[Error - 12:02:57 PM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=57, Character=0 }, End={ Line=229, Character=0 } }. text.Length=6402. text.Lines.Count=75
 ---> System.ArgumentOutOfRangeException: The requested line number 229 must be less than the number of lines 75. (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/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/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335
   at Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintHandler.HandleRequestAsync(InlayHintParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/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=57, Character=0 }, End={ Line=229, Character=0 } }. text.Length=6402. text.Lines.Count=75
[Error - 12:02:57 PM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=57, Character=0 }, End={ Line=229, Character=0 } }. text.Length=6402. text.Lines.Count=75
 ---> System.ArgumentOutOfRangeException: The requested line number 229 must be less than the number of lines 75. (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/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/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 335
   at Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintHandler.HandleRequestAsync(InlayHintParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/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=57, Character=0 }, End={ Line=229, Character=0 } }. text.Length=6402. text.Lines.Count=75
[Error - 12:02:57 PM] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 152 must be less than the number of lines 75. (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/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/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/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 46
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 44
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
[Error - 12:02:57 PM] Request textDocument/semanticTokens/range failed.
  Message: The requested line number 152 must be less than the number of lines 75. (Parameter 'Line')
  Code: -32000 
[object Object]

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,598 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.