[英]Suppress Blazor css ::deep warning
In a css file of an asp.net Blazor app when I use ::deep
VS emits a warning "Validation (CSS 4.0): "::deep" is not a valid pseudo-element."在我使用
::deep
时,在 asp.net Blazor 应用程序的 css 文件中,VS 发出警告“验证(CSS 4.0):“::deep”不是有效的伪元素。” That might be true for regular CSS, but not in the context of a Blazor app.这可能适用于常规 CSS,但不适用于 Blazor 应用程序的上下文。
Is there a way to suppress it?有没有办法压制它?
Right-click -> Suppress -> In File / In Source
do nothing. Right-click -> Suppress -> In File / In Source
中什么都不做。
You can add deep
to the vendor specific extensions.您可以
deep
添加到供应商特定的扩展。
I've added it to the Microsoft extension and it works.我已将其添加到 Microsoft 扩展中,并且可以正常工作。
Open with an editor (in Administrator mode) the file:使用编辑器(在管理员模式下)打开文件:
C:\Program Files (x86)\Microsoft Visual Studio\2019\<your version>\Common7\IDE\Extensions\Microsoft\Web Tools\Languages\Schemas\CSS\1033\css-vendor-ms.xml C:\Program Files (x86)\Microsoft Visual Studio\2019\<您的版本>\Common7\IDE\Extensions\Microsoft\Web Tools\Languages\Schemas\CSS\1033\css-vendor-ms.xml
Go to line ~69 and add the following code:转到 ~69 行并添加以下代码:
<CssPseudo name="::deep"
_locID="ms-browse-pseudo-element"
_locAttrData="description"
version="3.0"
browsers="IE11"
description="Blazor child component support."
standard-reference="https://docs.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-5.0"/>
Restart Visual Studio.重新启动 Visual Studio。
For Resharper users, editing the css-vendor-ms.xml is needed but does not completely solve the issue.对于 Resharper 用户,需要编辑 css-vendor-ms.xml,但不能完全解决问题。 Resharper will continue to highlight ::deep elements as errors in your solution.
Resharper 将继续突出显示 ::deep 元素作为解决方案中的错误。 This is currently a known bug , which will hopefully be resolved in a future build.
这是目前已知的错误,希望在未来的构建中得到解决。
As a work around, go to Resharper Options --> Code Inspection --> Inspection Severity --> CSS --> Potential Code Quality Issues --> Unknown CSS symbol and drop the severity to Warning (or lower).作为一种解决方法,请转到 Resharper 选项 --> 代码检查 --> 检查严重性 --> CSS --> 潜在代码质量问题 --> 未知 CSS 符号并将严重性降至警告(或更低)。
This has now been fixed as of the latest preview version of Visual Studio 2022:从 Visual Studio 2022 的最新预览版开始,此问题现已得到修复:
https://developercommunity.visualstudio.com/t/Support-::deep-in-razorcss-CSS-isolati/1623976 https://developercommunity.visualstudio.com/t/Support-::deep-in-razorcss-CSS-isolati/1623976
I just downloaded 17.3 and my project is now down to zero warnings again!我刚刚下载了 17.3,我的项目现在再次降为零警告! Look forward to it being released properly.
期待它被正确发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.