作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的项目中有以下命名空间。
我想禁用特定命名空间上的特定警告(比如说 Project.ViewModels)。我可以通过在GlobalSuppression.cs
中执行此操作来禁用对一个文件的警告
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Formatting", "RCS1057:Add empty line between declarations.", Justification = "<Pending>", Scope = "type", Target = "~T:Project.ViewModels.MainViewModel.cs")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Formatting", "RCS1057:Add empty line between declarations.", Justification = "<Pending>", Scope = "type", Target = "~T:Project.ViewModels.TreeViewModel.cs")]
我尝试更改Scope
来自type
至namespace
和namespaceanddescendants
但没有成功。
[assembly: SuppressMessage("Formatting", "RCS1057:Add empty line between declarations.", Justification = "<Pending>", Scope = "namespace", Target = "~T:Project.ViewModels")]
知道如何解决这个问题吗?我使用的是 Visual Studio 2017。
最佳答案
您不应该将 ~T:
用于命名空间,这似乎仅适用于类型。对于使用示例,您可以看到它如何不被用于 the .NET Core code here 中的命名空间。 。另外,from the docs仅命名空间
:
suppresses warnings against the namespace itself. It does not suppress warnings against types within the namespace as shown below:
根据您的文件层次结构,您可能需要使用namespaceanddescendants
,如下所示:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Formatting", "RCS1057:Add empty line between declarations.", Justification = "<Pending>", Scope = "namespaceanddescendants", Target = "Project.ViewModels")]
关于c# - Visual Studio : Suppress warnings for all files in a namespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56164904/
我是一名优秀的程序员,十分优秀!