从资源中的字符串中消除StyleCop错误

| 我收到数十个CA1703:Microsoft.Naming错误
resource Resources.resx\', referenced by name \'code\', correct the spelling of 
\'addfile\' in string value \'#set ...\'
这很荒谬,因为StyleCop正在对代码进行拼写检查,以使拼写错误。 如何抑制此StyleCop错误? 我尝试从此提示中使用SuppressMessage,但再次遇到错误-
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)
    
已邀请:
CA1703是FxCop规则,而不是StyleCop规则。由于您似乎不知道自己在使用FxCop,因此我猜测您使用的是与某些Visual Studio版本集成的代码分析版本。如果是这样,您可以简单地右键单击Visual Studio错误列表中的问题,然后选择
Suppress Message(s)
->
In Project Suppression File
上下文菜单项以自动添加针对其中的问题正确填充的
SuppressMessage
属性。您的资源文件。 (仅使用System.Diagnostics.CodeAnalysis使用指令添加是不够的,因为样本属性实例中的类别或检查ID都不适合CA1703规则。)     
您是否使用正确的using指令:
using System.Diagnostics.CodeAnalysis;
确保可以找到SuppressMessage类?     
正如Nicole Calinoiu所说,这是FxCop规则。这是规则说明http://msdn.microsoft.com/zh-cn/library/bb264483.aspx您可以轻松地将单词添加到自己的字典中,以避免FxCop不知道的单词出现错误(例如公司名称或一些技术用语),请参见http://msdn.microsoft.com/zh-cn/library/bb264492.aspx     

要回复问题请先登录注册