C # validate or force naming

I inherited several programs from a previous developer, which was a little careless with variable names, methods, and classes with different capitalization, and sometimes underscores.

Is there a program or method in visual studio to check the name of each variable, method, property, constant, class ... I would be fine with the standard C # conventions.

+4
source share
9 answers

You can look at Microsoft StyleCop and FXCop

+15
source

I am using ReSharper 4.5 for this, which has the advantage that it allows you to see inappropriate code when writing it.

You can also use NDepend and CQL to test your conventions in a very granular and flexible way. This is great as part of your build script.

Both tools cost money, both are worth it.

+7
source

What you are looking for is StyleCop .

He reads the source code to ensure that certain rules are followed.

FxCop is used to read compiled code and is usually not used for this kind of stylistic check.

+2
source

Take a look at StyleCop / CodeStyleEnforcer

They will give out carts, but you yourself will fix them.

http://code.msdn.microsoft.com/sourceanalysis

http://joel.fjorden.se/static.php?page=CodeStyleEnforcer

+2
source

FXCop has this and more.

+1
source

FXCop and StyleCop can be used to verify compliance with best practices and standards.

+1
source

FxCop will do the job (or more modern code analysis ).

0
source

This sounds like an assignment for:

Stylecop

From the website:

StyleCop parses C # source code to provide a set of style rules and consistency. It can be run from within Visual Studio or integrated into an MSBuild project.

0
source

As others said: FxCop and StyleCop. ReSharper 4.5 also has custom naming conventions. The beauty is that it will highlight the unnamed elements and give you a popup with the suggested name. I am not 100% sure, but I think it can also be run during the ReSharper Code Cleanup function (if it is not, it would be great if it could be!)

Of course, as soon as you edit and correct the names, they will be correct only at that moment in time. To ensure that they are true now and forever, integrate FxCop / StyleCop into a continuous integration environment. This will catch the naughty anti-social developers who flaunt the rules and regulations (that the public service you give them is up to you, but this is often because he is a buyer of donuts and / or coffee "more screws!)

0
source

All Articles