Skip to content

Gendarme.Rules.Design.ConsiderUsingStaticTypeRule(git)

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

ConsiderUsingStaticTypeRule

Assembly: Gendarme.Rules.Design
Version: git

Description

This rule checks for types that contain only static members and, if the assembly targets the CLR version 2.0 or later, suggests that the type be made static or, for earlier versions, that the type be made sealed.

Examples

Bad example:

public class Class {
    public static void Method ()
    {
    }
}

Good example (targetting CLR 2.0 and later):

public static class Class {
    public static void Method ()
    {
    }
}

Good example (targetting CLR 1.x):

public sealed class Class {
    public static void Method ()
    {
    }
}

Source code

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

Clone this wiki locally