Gendarme.Rules.Performance.AvoidUnsealedUninheritedInternalTypeRule Class
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.

See Also: AvoidUnsealedUninheritedInternalTypeRule Members

Syntax

[Gendarme.Framework.Problem("Due to performance issues, types which are not visible outside of the assembly and which have no derived types should be sealed.")]
[Gendarme.Framework.Solution("You should seal this type, unless you plan to inherit from this type in the near-future.")]
public class AvoidUnsealedUninheritedInternalTypeRule : Gendarme.Framework.Rule, Gendarme.Framework.ITypeRule

Remarks

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

Example

Bad example:

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 {
            }
            

Example

Good example:

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 {
            }
            

Requirements

Namespace: Gendarme.Rules.Performance
Assembly: Gendarme.Rules.Performance (in Gendarme.Rules.Performance.dll)
Assembly Versions: 2.8.0.0