-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.BadPractice.DisableDebuggingCodeRule(2.10)
Assembly: Gendarme.Rules.BadPractice
Version: 2.10
This rule checks for non-console applications which contain calls to Console.WriteLine. These are often used as debugging aids but such code should be removed or disabled in the released version. If you don't want to remove it altogether you can place it inside a method decorated with Conditional ("DEBUG"), use Debug.WriteLine, use Trace.WriteLine, or use the preprocessor. But note that TRACE is often enabled in release builds so if you do use that you'll probably want to use a config file to remove the default trace listener.
Bad example:
private byte[] GenerateKey ()
{
byte[] key = new byte[16];
rng.GetBytes (key);
Console.WriteLine ("debug key = {0}", BitConverter.ToString (key));
return key;
}
Good example (removed):
private byte[] GenerateKey ()
{
byte[] key = new byte[16];
rng.GetBytes (key);
return key;
}
Good example (changed):
private byte[] GenerateKey ()
{
byte[] key = new byte[16];
rng.GetBytes (key);
Debug.WriteLine ("debug key = {0}", BitConverter.ToString (key));
return key;
}
- This rule is available since Gendarme 2.0
Note that this page was autogenerated (3/17/2011 9:31:58 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!