Gendarme - AvoidUncalledPrivateCodeRule

48 views
Skip to first unread message

Nidhi Rawal

unread,
Aug 27, 2007, 5:11:06 AM8/27/07
to mono-soc-2007
Description:
The rule checks if there is any code that calls the private or
internal member, or if it is invoked by CLR or a delegate and raises
error if it is not called by anyone.

Examples:

1) public class UncalledPrivateMethod
{
private void method ()
{
}
public static void Main ()
{
}
}
This is bad. Compiler also raises warning for this case, but my
code will also flag an error for it.

2) internal class UncalledPublicMethodInInternalClass
{
public void method ()
{
}
}
This is bad.

3) class UncalledPublicMethodInPrivateClass
{
private class PrivateClass
{
public void method ()
{
}
}
}
This is bad.

These are just few examples. I'll add more test-cases to
AvoidUncalledPrivateCodeTest.cs

References:
http://blogs.msdn.com/fxcop/archive/2007/08/09/what-rules-do-microsoft-have-turned-on-internally.aspx

Nidhi Rawal

unread,
Aug 27, 2007, 5:25:20 AM8/27/07
to mono-soc-2007

Nidhi Rawal

unread,
Aug 30, 2007, 3:46:37 PM8/30/07
to mono-soc-2007
Reply all
Reply to author
Forward
0 new messages