在声明C#中声明无效变量时,VSCODE语法突出显示了断裂

发布于 2025-01-22 19:19:49 字数 807 浏览 5 评论 0原文

我正在Blazor开发,并且正在遇到无效变量和VSCODE的问题。尝试创建Razor组件参数并使其无效时,VSCODE下面的所有行停止显示正确的C#语法突出显示。

问题的人都建议在设置中设置以下内容。

"editor.semanticHighlighting.enabled": true,
"csharp.semanticHighlighting.enabled": true

遇到类似 我正在为VSCODE使用最新版本的C#/OmnishArp。

代码的相关部分如下:(虽然可能没有什么有用)

@code{
    private bool isChecked = false;

    [Parameter] public int? area { get; set; } 
    [Parameter] public double? val { get; set; } 
    [Parameter] public double dist { get; set; } 

    private void toggleChecked()
    {
        isChecked = !isChecked;
    }
}

是否有任何已知方法来解决此问题,或者我应该以其他方式宣布无效的变量?

I'm developing in Blazor and am running into an issue with nullable variables and VSCode. When trying to create razor component parameters and make them nullable, all lines below in VSCode stop showing correct C# syntax highlighting.

gif showing the syntax highlighting issue

People having similar issues have suggested setting the following in settings.json in VSCode:

"editor.semanticHighlighting.enabled": true,
"csharp.semanticHighlighting.enabled": true

but this doesn't appear to fix the problem for me.
I'm using the latest version of C#/Omnisharp for VSCode.

Relevant part of the code is as follows: (though it might not be that useful)

@code{
    private bool isChecked = false;

    [Parameter] public int? area { get; set; } 
    [Parameter] public double? val { get; set; } 
    [Parameter] public double dist { get; set; } 

    private void toggleChecked()
    {
        isChecked = !isChecked;
    }
}

Is there any known way to fix this or should I be declaring nullable variables some other way perhaps?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文