xsl*_*xsl 9 .net code-analysis suppression
每当我用一种方法调用我的记录器时,例如
_logger.Debug("Connecting to database...");
Run Code Online (Sandbox Code Playgroud)
我收到警告:
CA1303 : Microsoft.Globalization:
Method 'Database.Connect()' passes a literal
string as parameter 'message' of a call to 'ILogger.Debug(string)'.
Retrieve the following string(s) from a resource table instead:
"Connecting to database...".
Run Code Online (Sandbox Code Playgroud)
有没有办法在每次使用函数时抑制此警告ILogger?我真的不想在我使用它的每种方法中压制它.
Joh*_*ner 14
如果您控制ILogger接口,则可以Localizable使用值为false 的属性来指示该值不可本地化.
例如:
void Info([Localizable(false)] string message);
Run Code Online (Sandbox Code Playgroud)
FxCop/VS 代码分析和 CA1303 规则都无法配置为以这种方式忽略特定目标。您基本上有三个选择:
对于这类事情,我倾向于#3,但是 ymmv...此外,如果您强烈认为自己应该能够控制 CA1303 行为,则可以考虑在https://connect.microsoft请求此内容.com/VisualStudio或http://visualstudio.uservoice.com/forums/121579-visual-studio。