Visual Studio Team System
Identifiers should not contain underscores

TypeName

IdentifiersShouldNotContainUnderscores

CheckId

CA1707

Category

Microsoft.Naming

Breaking Change

Breaking - when fired on assemblies

Non Breaking - when fired on type parameters

Cause

The name of an identifier contains the underscore (_) character.

Rule Description

By convention, identifier names do not contain the underscore (_) character. The rule checks namespaces, types, members, and parameters.

Naming conventions provide a common look for libraries that target the common language runtime. This reduces the learning curve required for new software libraries, and increases customer confidence that the library was developed by someone with expertise in developing managed code.

How to Fix Violations

Remove all underscore characters from the name.

When to Suppress Warnings

Do not suppress a warning from this rule.

Related Rules

Identifiers should be cased correctly

Identifiers should differ by more than case

Tags :


Community Content

CamyDee
This rule stinks
Honestly, how does removing underscores increase the readability of the code? How does it lend confidence to others that it was written by professionals?

What if we remove all letter 'z' from our code? Will that improve readability?

This is a great example of a fairly arbitrary and unuseful FxCop rule.

Tags :

Don_H
This rule really does stink
We have been using '_' for years as a prefix for parameter names in function headers. It serves two purposes

1. You avoid confusing code like this.minute = minute; //minute if a function parameter. This is especially confusing if your function is very long where you might not see the function header.
2. You can easily identify which variables in your code might be altered on the return call if called by reference.

for example: (C#)
public void Foo(Bar _bar, ref int _count)
{
bar = _bar;
_count++; //this var will be altered on the return
}
Tags :

Page view tracker