Skip to content

Gendarme.Rules.Performance.AvoidUncalledPrivateCodeRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

AvoidUncalledPrivateCodeRule

Assembly: Gendarme.Rules.Performance
Version: 2.10

Description

This rule will check for internally visible methods which are never called. The rule will warn you if a private method isn't called in its declaring type or if an internal method doesn't have any callers in the assembly or isn't invoked by the runtime or a delegate.

Examples

Bad example:

public class MyClass {
    private void MakeSuff ()
    {
        // ...
    }
    public void Method ()
    {
        Console.WriteLine ("Foo");
    }
}

Good example (removing unused code):

public class MyClass {
    public void Method ()
    {
        Console.WriteLine ("Foo");
    }
}

Good example (use the code):

public class MyClass {
    private void MakeSuff ()
    {
        // ...
    }
    public void Method ()
    {
        Console.WriteLine ("Foo");
        MakeSuff ();
    }
}
Clone this wiki locally