Skip to content

Gendarme.Rules.Naming.AvoidRedundancyInTypeNameRule(2.10)

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

AvoidRedundancyInTypeNameRule

Assembly: Gendarme.Rules.Naming
Version: 2.10

Description

This rule will fire if a type is prefixed with the last component of its namespace. Using prefixes like this makes type names more verbose than they need to be and makes them harder to use with tools like auto-complete. Note that an exception is made if removal of the prefix would cause an ambiguity with another type. If this is the case the rule will not report a defect.

Examples

Bad example:

namespace Foo.Lang.Compiler {
    public class CompilerContext {
    }
}
using Foo.Lang;
...
Compiler.CompilerContext context = new Compiler.CompilerContext ();
using Foo.Lang.Compiler;
...
CompilerContext context = new CompilerContext ();

Good example:

namespace Foo.Lang.Compiler {
    public class Context {
    }
}
using Foo.Lang;
...
Compiler.Context context = new Compiler.Context ();
using Foo.Lang.Compiler;
...
Context context = new Context ();

Another good example (more meaningful term in the context of the namespace):

namespace Foo.Lang.Compiler {
    public class CompilationContext {
    }
}
Clone this wiki locally