Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I suppress all code analysis messages for a certain class?

Whenever I call my logger in a method, e.g.

_logger.Debug("Connecting to database...");

I get the warning:

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...".

Is there a way to suppress this warning every time I use a function of ILogger? I really don't want to suppress it in every method I'm using it.

like image 202
xsl Avatar asked Mar 26 '12 12:03

xsl


1 Answers

If you control the ILogger interface, you can leverage the Localizable attribute with a value of false to indicate the value is not localizable.

For example:

void Info([Localizable(false)] string message);
like image 199
John Koerner Avatar answered Sep 16 '22 21:09

John Koerner