Skip to content

Gendarme.Rules.Performance.AvoidUninstantiatedInternalClassesRule(2.10)

Sebastien Pouliot edited this page Feb 9, 2011 · 3 revisions

AvoidUninstantiatedInternalClassesRule

Assembly: Gendarme.Rules.Performance
Version: 2.10

Description

This rule will fire if a type is only visible within its assembly, can be instantiated, but is not instantiated. Such types are often leftover (dead code) or are debugging/testing code and not required. However in some case the types might by needed, e.g. when accessed thru reflection or if the InternalsVisibleTo attribute is used on the assembly.

Examples

Bad example:

// defined, but never instantiated
internal class MyInternalClass {
    // ...
}
public class MyClass {
    static void Main ()
    {
        // ...
    }
}

Good example:

internal class MyInternalClass {
    // ...
}
public class MyClass {
    static void Main ()
    {
        MyInternalClass c = new MyInternalClass ();
        // ...
    }
}
Clone this wiki locally