抑制资源中字符串的 StyleCop 错误
我收到了数十个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否使用了正确的 using 指令:
以确保它可以找到 SuppressMessage 类?
Are you using the correct using directive:
To make sure it can find the SuppressMessage class?
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 addSuppressMessage
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.)正如 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