Skip to content

Gendarme.Rules.Performance.AvoidUnsealedUninheritedInternalTypeRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

AvoidUnsealedUninheritedInternalTypeRule

Assembly: Gendarme.Rules.Performance
Version: git

Description

This rule will fire for classes which are internal to the assembly and have no derived classes, but are not sealed. Sealing the type clarifies the type hierarchy and allows the compiler/JIT to perform optimizations such as eliding virtual method calls.

Examples

Bad example:

// this one is correct since MyInheritedStuff inherits from this class
internal class MyBaseStuff {
}
// this one is bad, since no other class inherit from MyConcreteStuff
internal class MyInheritedStuff : MyBaseStuff {
}

Good example:

// this one is correct since the class is abstract
internal abstract class MyAbstractStuff {
}
// this one is correct since the class is sealed
internal sealed class MyConcreteStuff : MyAbstractStuff {
}

Notes

  • This rule is available since Gendarme 2.0 and, before 2.2, was named AvoidUnsealedUninheritedInternalClassesRule

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally