【问题标题】:Visual Studio 2022 - Razor view is not formatting correctlyVisual Studio 2022 - Razor 视图格式不正确
【发布时间】:2023-01-14 07:58:17
【问题描述】:

当我在 VS2022 中打开一个 .cshtml 文件时,其中嵌套了 taghelpers,该文件的格式不起作用,我在输出中出现以下错误Razor 语言服务器客户端.

Warning: OmniSharp.Extensions.LanguageServer.Server.Configuration.DidChangeConfigurationProvider: No ConfigurationItems have been defined, configuration won't surface any configuration from the client! | 
Error: Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService: Error thrown while retrieving CSharp semantic range - OmniSharp.Extensions.JsonRpc.Server.JsonRpcException: 'end' must not be less than 'start'
Parameter name: end
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Extensions.JsonRpc.ResponseRouter.ResponseRouterReturnsImpl.<Returning>d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService.<GetMatchingCSharpResponseAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService.<GetCSharpSemanticRangesAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService.<GetSemanticTokensAsync>d__10.MoveNext() |

一旦我开始输入新的 html 元素,智能感知就会起作用,但属性是纯黑色的。我在这里找到了一些相关信息:https://developercommunity.visualstudio.com/t/vs-2022-razor-editor-not-formatting-html/1625350

嵌套的 taghelper 是 kendo-grid。我已经向开发人员提出了一张票,他们无法复制它。

有没有人有类似的东西?

【问题讨论】:

    标签: visual-studio-2022 tag-helpers asp.net-core-tag-helpers


    【解决方案1】:

    格式化对我不起作用,因为我没有注意到我是如何将属性插入到结束标记中的 enter image description here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-05
      • 2022-09-30
      • 2022-10-24
      • 1970-01-01
      • 2022-01-02
      • 2011-05-08
      相关资源
      最近更新 更多