抑制资源中字符串的 StyleCop 错误

发布于 2024-11-10 01:58:25 字数 674 浏览 5 评论 0原文

我收到了数十个 CA1703:Microsoft.Naming 错误

resource Resources.resx', referenced by name 'code', correct the spelling of 
'addfile' in string value '#set ...'

这很荒谬,因为 StyleCop 对代码运行拼写检查以产生拼写错误。

我怎样才能抑制这个 StyleCop 错误?

我尝试使用此提示中的 SuppressMessage,但再次出错 - 错误 70 找不到类型或命名空间名称“SuppressMessageAttribute”(您是否缺少 using 指令或程序集引用?)

[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "CA1703:Microsoft.Naming", Justification = "This is tcl script, spelling check is meaningless")] 
        public static void Generate(string clientDirectory, string topLevelTestbench, string doFileName)

I got tens of CA1703:Microsoft.Naming error

resource Resources.resx', referenced by name 'code', correct the spelling of 
'addfile' in string value '#set ...'

It's ridiculous, as StyleCop's running spelling check on the code to make spelling error.

How can I suppress this StyleCop error?

I tried to use the SuppressMessage from this hint, but I got error again - Error 70 The type or namespace name 'SuppressMessageAttribute' could not be found (are you missing a using directive or an assembly reference?)

[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "CA1703:Microsoft.Naming", Justification = "This is tcl script, spelling check is meaningless")] 
        public static void Generate(string clientDirectory, string topLevelTestbench, string doFileName)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

毁我热情 2024-11-17 01:58:25

您是否使用了正确的 using 指令:

using System.Diagnostics.CodeAnalysis;

以确保它可以找到 SuppressMessage 类?

Are you using the correct using directive:

using System.Diagnostics.CodeAnalysis;

To make sure it can find the SuppressMessage class?

同尘 2024-11-17 01:58:25

CA1703 是 FxCop 规则,而不是 StyleCop 规则。由于您似乎没有意识到您正在使用 FxCop,因此我猜测您正在使用与某些 Visual Studio 版本集成的代码分析版本。如果是这样,您只需右键单击 Visual Studio 错误列表中的问题,然后选择抑制消息 -> 在项目抑制文件 上下文菜单项中自动添加针对资源文件中的问题正确填充的 SuppressMessage 属性。 (仅添加 System.Diagnostics.CodeAnalysis using 指令是不够的,因为示例属性实例中的类别和检查 ID 对于 CA1703 规则来说都不正确。)

CA1703 is an FxCop rule, not a StyleCop rule. Since you seem to be unaware that you are using FxCop, I'm guessing that you are using the Code Analysis version that is integrated with certain Visual Studio editions. If so, you can simply right-click the issue(s) in the Visual Studio error list, then select the Suppress Message(s) -> In Project Suppression File context menu item to automatically add SuppressMessage attribute(s) that are correctly populated for the issue(s) in your resource files. (Simply adding the System.Diagnostics.CodeAnalysis using directive will not be enough since neither the category nor the check ID in your sample attribute instance is correct for the CA1703 rule.)

痕至 2024-11-17 01:58:25

正如 Nicole Calinoiu 所说,这是 FxCop 的规则。以下是规则说明 http://msdn.microsoft.com/en-us/library /bb264483.aspx 您可以轻松地将单词添加到您自己的词典中,以避免 FxCop 不认识的单词出现错误(例如您公司的名称或一些技术单词),请参阅http://msdn.microsoft.com/en-us/library/bb264492.aspx

As Nicole Calinoiu said it's a FxCop rule. Here's the rule description http://msdn.microsoft.com/en-us/library/bb264483.aspx You can easily add words to your own dictionary to avoid having errors for words FxCop doesn't know (like the name of your company or some tech words), see http://msdn.microsoft.com/en-us/library/bb264492.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文