dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.85k stars 667 forks source link

Blazor unsupported? #4997

Open akkgr opened 2 years ago

akkgr commented 2 years ago

Working with a Blazor project is practical immpossible,

After clean and build project and restart vscode all might work until a file save then again nothing works. Really does anyone is working blazor projects with vscode ?

JoeRobich commented 2 years ago

@akkgr Can you please share the OmniSharp Log from the VS Code Output pane?

akkgr commented 2 years ago

@akkgr Can you please share the OmniSharp Log from the VS Code Output pane?

One example... this is the log when I open vscode, in the blazor project all razor files are red indicating errors although project builds successfully

Starting OmniSharp server at 12/1/2022, 10:45:19 π.μ. Target: d:\work\github\myEstia\myEstia.sln

OmniSharp server started. Path: c:\Users\tasos.vscode\extensions\ms-dotnettools.csharp-1.23.17.omnisharp\1.37.17\OmniSharp.exe PID: 5640

    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    Using the 'dotnet' on the PATH.
    DotNetPath set to dotnet
    Located 2 MSBuild instance(s)
        1: Visual Studio Community 2022 17.0.32014.148 17.0.0 - "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
        2: StandAlone 17.0.0 - "c:\Users\tasos\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.37.17\.msbuild\Current\Bin"
    Registered MSBuild instance: Visual Studio Community 2022 17.0.32014.148 17.0.0 - "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
    Detecting Cake files in 'd:\work\github\myEstia'.
    Could not find any Cake files
    Detecting projects in 'd:\work\github\myEstia\myEstia.sln'.
    Queue project update for 'd:\work\github\myEstia\Server\Estia.Server.csproj'
    Queue project update for 'd:\work\github\myEstia\Shared\Estia.Shared.csproj'
    Queue project update for 'd:\work\github\myEstia\Client\Estia.Client.csproj'
    Detecting CSX files in 'd:\work\github\myEstia'.
    Could not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'd:\work\github\myEstia' on host 5900.
    Loading project: d:\work\github\myEstia\Server\Estia.Server.csproj
    Miscellaneous file: d:\work\github\myEstia\Client\Pages\Buildings\ApartmentEdit.razor__virtual.cs added to workspace
    Successfully loaded project file 'd:\work\github\myEstia\Server\Estia.Server.csproj'.
    Adding project 'd:\work\github\myEstia\Server\Estia.Server.csproj'
    Loading project: d:\work\github\myEstia\Shared\Estia.Shared.csproj
    Successfully loaded project file 'd:\work\github\myEstia\Shared\Estia.Shared.csproj'.
    Adding project 'd:\work\github\myEstia\Shared\Estia.Shared.csproj'
    Loading project: d:\work\github\myEstia\Client\Estia.Client.csproj
    Successfully loaded project file 'd:\work\github\myEstia\Client\Estia.Client.csproj'.
    Adding project 'd:\work\github\myEstia\Client\Estia.Client.csproj'
    Update project: Estia.Server
    Update project: Estia.Shared
    Update project: Estia.Client
    Solution initialized -> queue all documents for code analysis. Initial document count: 188.
JoeRobich commented 2 years ago

Well this is a good sign that the Razor support is recognizing the project.

info: OmniSharp.OmniSharpWorkspace
Miscellaneous file: d:\work\github\myEstia\Client\Pages\Buildings\ApartmentEdit.razor__virtual.cs added to workspace

Do you see these same errors with a new Blazor project? If so, what is the workflow that gets it into the broken state?

CC: @ryanbrandenburg in case you have questions.

ryanbrandenburg commented 2 years ago

@akkgr the log you pasted doesn't indicate anything out of the ordinary that I noticed, and I wasn't able to repro what you describe. What kind of errors are you seeing when they're "red indicating errors"? Could you copy-paste or screenshot those errors?

Edit: Removed my request to check against a "basic" project since @JoeRobich beat me to it.

travisnielsen commented 2 years ago

I can reproduce this error with a multi-root workspace in VS Code. I created a sample here, which includes two projects initialized using dotnet new. This is what I see:

image

OmniSharp logs don't say much out of the ordinary. I do see errors in the Razor logs.

OmniSharp Log

Starting OmniSharp server at 1/22/2022, 10:31:52 AM
    Target: /Users/travisnielsen/repos/omnitest/blazordemo

OmniSharp server started with .NET 6.0.101
.
    Path: /Users/travisnielsen/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.0-net6.0/OmniSharp.dll
    PID: 16972

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
        Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
        Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: .NET Core SDK 6.0.101 17.0.0 - "/usr/local/share/dotnet/sdk/6.0.101/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: .NET Core SDK 6.0.101 17.0.0 - "/usr/local/share/dotnet/sdk/6.0.101/"
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/Users/travisnielsen/repos/omnitest/blazordemo'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/travisnielsen/repos/omnitest/blazordemo/blazordemo.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/travisnielsen/repos/omnitest/blazordemo'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/travisnielsen/repos/omnitest/blazordemo' on host 16613.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/travisnielsen/repos/omnitest/blazordemo/blazordemo.csproj
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: /Users/travisnielsen/repos/omnitest/blazordemo/App.razor__virtual.cs added to workspace
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/Users/travisnielsen/repos/omnitest/blazordemo/blazordemo.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/travisnielsen/repos/omnitest/blazordemo/blazordemo.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: blazordemo
Razor Log


OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Finished: Routing Request (2) textDocument/codeAction in 56ms | Id='2' Method='textDocument/codeAction' ElapsedMilliseconds='56'
[Error - 6:08:12 PM] OmniSharp.Extensions.JsonRpc.InputHandler: Failed to handle request textDocument/codeAction 2 - OmniSharp.Extensions.JsonRpc.Server.MethodNotSupportedException: Method not found: 'razor/provideCodeActions'.
   at OmniSharp.Extensions.JsonRpc.ResponseRouter.ResponseRouterReturnsImpl.Returning[TResponse](CancellationToken cancellationToken) in OmniSharp.Extensions.JsonRpc.dll:token 0x6000b4d+0x16f
   at Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.CodeActionEndpoint.GetCSharpCodeActionsFromLanguageServerAsync(RazorCodeActionContext context, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs:line 263
   at Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.CodeActionEndpoint.GetCSharpCodeActionsAsync(RazorCodeActionContext context, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs:line 184
   at Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.CodeActionEndpoint.Handle(RazorCodeActionParams request, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs:line 99
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in OmniSharp.Extensions.LanguageServer.dll:token 0x60000a0+0x2a6
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in OmniSharp.Extensions.LanguageServer.dll:token 0x600009f+0x0
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000058+0x0
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000056+0x0
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000053+0x0
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000053+0x25c
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x600004a+0x0
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x600004a+0x1cd
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.g__InnerRoute|5_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger) in OmniSharp.Extensions.JsonRpc.dll:token 0x600022a+0xfc
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token) in OmniSharp.Extensions.JsonRpc.dll:token 0x6000221+0x49f
   at OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass38_0.<b__5>d.MoveNext() in OmniSharp.Extensions.JsonRpc.dll:token 0x6001089+0xf2 | Method='textDocument/codeAction' RequestId='2'
OmniSharp.Extensions.JsonRpc.InputHandler: Finished: Processing request textDocument/codeAction 2 in 119ms | Method='textDocument/codeAction' ResponseId='2' ElapsedMilliseconds='119'
[Error - 6:08:12 PM] Request textDocument/codeAction failed.
  Message: Internal Error - OmniSharp.Extensions.JsonRpc.Server.MethodNotSupportedException: Method not found: 'razor/provideCodeActions'.
   at OmniSharp.Extensions.JsonRpc.ResponseRouter.ResponseRouterReturnsImpl.Returning[TResponse](CancellationToken cancellationToken) in OmniSharp.Extensions.JsonRpc.dll:token 0x6000b4d+0x16f
   at Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.CodeActionEndpoint.GetCSharpCodeActionsFromLanguageServerAsync(RazorCodeActionContext context, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs:line 263
   at Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.CodeActionEndpoint.GetCSharpCodeActionsAsync(RazorCodeActionContext context, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs:line 184
   at Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.CodeActionEndpoint.Handle(RazorCodeActionParams request, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs:line 99
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in OmniSharp.Extensions.LanguageServer.dll:token 0x60000a0+0x2a6
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in OmniSharp.Extensions.LanguageServer.dll:token 0x600009f+0x0
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000058+0x0
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000056+0x0
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000053+0x0
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x6000053+0x25c
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x600004a+0x0
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in MediatR.dll:token 0x600004a+0x1cd
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.g__InnerRoute|5_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger) in OmniSharp.Extensions.JsonRpc.dll:token 0x600022a+0xfc
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token) in OmniSharp.Extensions.JsonRpc.dll:token 0x6000221+0x49f
   at OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass38_0.<b__5>d.MoveNext() in OmniSharp.Extensions.JsonRpc.dll:token 0x6001089+0xf2
  Code: -32603 
OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Finding descriptors for textDocument/hover | Method='textDocument/hover'
OmniSharp.Extensions.LanguageServer.Server.Matchers.TextDocumentMatcher: Found attributes 1, razor::file:///Users/travisnielsen/repos/gift-tracker/Client/Pages/EditItem.razor | Count='1' Attributes='razor::file:///Users/travisnielsen/repos/gift-tracker/Client/Pages/EditItem.razor'
OmniSharp.Extensions.LanguageServer.Server.Matchers.TextDocumentMatcher: Looking for handler for descriptors textDocument/hover | Method='textDocument/hover'
OmniSharp.Extensions.LanguageServer.Server.Matchers.TextDocumentMatcher: Checking handler textDocument/hover:Microsoft.AspNetCore.Razor.LanguageServer.Hover.RazorHoverEndpoint | Method='textDocument/hover' Handler='Microsoft.AspNetCore.Razor.LanguageServer.Hover.RazorHoverEndpoint'
OmniSharp.Extensions.LanguageServer.Server.Matchers.TextDocumentMatcher: Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverRegistrationOptions | OptionsName='OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverRegistrationOptions'
OmniSharp.Extensions.LanguageServer.Server.Matchers.TextDocumentMatcher: Document Selector [**/*.{cshtml,razor}] | DocumentSelector='[**/*.{cshtml,razor}]'
OmniSharp.Extensions.LanguageServer.Server.Matchers.TextDocumentMatcher: Handler Selected: Microsoft.AspNetCore.Razor.LanguageServer.Hover.RazorHoverEndpoint  via [**/*.{cshtml,razor}] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams, OmniSharp.Extensions.LanguageProtocol, Version=0.18.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.18.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]) | Handler='Microsoft.AspNetCore.Razor.LanguageServer.Hover.RazorHoverEndpoint' Id='' DocumentSelector='[**/*.{cshtml,razor}]' HandlerInterface='OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams, OmniSharp.Extensions.LanguageProtocol, Version=0.18.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.18.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]'
OmniSharp.Extensions.JsonRpc.ProcessScheduler: Queueing Parallel:textDocument/hover:3 request for processing | Type='Parallel' Name='textDocument/hover:3'
OmniSharp.Extensions.JsonRpc.InputHandler: Starting: Processing request textDocument/hover 3 | Method='textDocument/hover' ResponseId='3'
OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Starting: Routing Request (3) textDocument/hover | Id='3' Method='textDocument/hover'
OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Converting params for Request (3) textDocument/hover to OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams | Id='3' Method='textDocument/hover' Type='OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams'
OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Converting params for Notification textDocument/hover to OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams | Method='textDocument/hover' Type='OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams'
Microsoft.AspNetCore.Razor.LanguageServer.Hover.RazorHoverEndpoint: Found hover info items. | 
OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Response value was (null) | Type='(null)'
OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Finished: Routing Request (3) textDocument/hover in 41ms | Id='3' Method='textDocument/hover' ElapsedMilliseconds='41'
OmniSharp.Extensions.JsonRpc.InputHandler: Finished: Processing request textDocument/hover 3 in 41ms | Method='textDocument/hover' ResponseId='3' ElapsedMilliseconds='41'
travisnielsen commented 2 years ago

This issue appears to be very similar to: https://github.com/dotnet/razor-tooling/issues/5517

tthiery commented 9 months ago

@mikadumont @dibarbet Is anyone working on this? Blazor is such an amazing platform (as SPA, as SSR, and soonish especially as Hybrid App) but the VS Code razor file editing experience is is up until today a mess. And AFAIR it was better with O#.

I am currently editing a blazor app and I am basically back in the old school experience of vi on text screen how it was back when I learned programming in the 90s.

tthiery commented 9 months ago

Current Stack Trace for me. These range errors are all over the place when editing razor files.

Error - 10:55:07 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=140, Character=0 }, End={ Line=1043, Character=0 } }. text.Length=39. text.Lines.Count=3
 ---> System.ArgumentOutOfRangeException: The requested line number 140 must be less than the number of lines 3. (Parameter 'Line')
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78
   at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 300
   --- 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 300
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(ClientCapabilities capabilities, Document document, Range[] ranges, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 104
   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 64
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 47
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 10:55:07 AM] Request textDocument/semanticTokens/range failed.
  Message: Range={ Start={ Line=140, Character=0 }, End={ Line=1043, Character=0 } }. text.Length=39. text.Lines.Count=3
  Code: -32000 
[object Object]
[Error - 10:55:07 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=988, Character=33 }, End={ Line=988, Character=33 } }. text.Length=39. text.Lines.Count=3
 ---> System.ArgumentOutOfRangeException: The requested line number 988 must be less than the number of lines 3. (Parameter 'Line')
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78
   at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 300
   --- 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 300
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions.CodeActionHelpers.GetActionSetsAsync(Document document, CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, Range selection, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs:line 417
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions.CodeActionHelpers.GetVSCodeActionsAsync(CodeActionParams request, Document document, CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, Boolean hasVsLspCapability, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs:line 93
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActionsHandler.HandleRequestAsync(CodeActionParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs:line 67
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 10:55:07 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=140, Character=0 }, End={ Line=1043, Character=0 } }. text.Length=74. text.Lines.Count=4
 ---> System.ArgumentOutOfRangeException: The requested line number 140 must be less than the number of lines 4. (Parameter 'Line')
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78
   at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 300
   --- 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 300
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(ClientCapabilities capabilities, Document document, Range[] ranges, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 104
   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 64
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 47
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 10:55:07 AM] Request textDocument/semanticTokens/range failed.
  Message: Range={ Start={ Line=140, Character=0 }, End={ Line=1043, Character=0 } }. text.Length=74. text.Lines.Count=4
  Code: -32000 
[object Object]
[Error - 10:55:07 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=988, Character=34 }, End={ Line=988, Character=34 } }. text.Length=74. text.Lines.Count=4
 ---> System.ArgumentOutOfRangeException: The requested line number 988 must be less than the number of lines 4. (Parameter 'Line')
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78
   at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 300
   --- 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 300
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions.CodeActionHelpers.GetActionSetsAsync(Document document, CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, Range selection, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs:line 417
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions.CodeActionHelpers.GetVSCodeActionsAsync(CodeActionParams request, Document document, CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, Boolean hasVsLspCapability, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs:line 93
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActionsHandler.HandleRequestAsync(CodeActionParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs:line 67
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 10:55:13 AM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=395, Character=33 }, End={ Line=1043, Character=0 } }. text.Length=74. text.Lines.Count=4
 ---> System.ArgumentOutOfRangeException: The requested line number 395 must be less than the number of lines 4. (Parameter 'Line')
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67
   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78
   at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 300
   --- 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 300
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(ClientCapabilities capabilities, Document document, Range[] ranges, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 104
   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 64
   at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 47
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 10:55:13 AM] Request textDocument/semanticTokens/range failed.
  Message: Range={ Start={ Line=395, Character=33 }, End={ Line=1043, Character=0 } }. text.Length=74. text.Lines.Count=4
  Code: -32000 
dibarbet commented 9 months ago

@tthiery that issue is tracked here on the Razor side - https://github.com/dotnet/razor/issues/9637 cc @davidwengier

tthiery commented 9 months ago

Sounds good to have found the right place. Does this other issue also cover the bad formatting and the other issues of the original issue here?

dibarbet commented 9 months ago

@tthiery please file new issues with details for specific problems - this issue is fairly old and applies to O# (not necessarily the new version).