views:

907

answers:

8

Here in Brazil we call it "Padrão de Codificação", probably in English this is called Coding Pattern or Code Style, a set of constraints to developers build their code following rules for naming variables, methods, classes, for instance. Another constraints can be written, not only for naming things.

Our company has a coding pattern for our .NET projects, and I'd like to know if there is a Visual Studio add-in or a standalone application that can apply these constraints against written code, to check if they're being respected, possibly warning the developer when he is not following the specified pattern.

+5  A: 

FxCop is one from microsoft that features a rule engine and checks your code for common mistakes against the Framework design guidelines from MS

But to have FxCop check for your casing and stuff you'd probably need some extra rules.

Tigraine
Uh, your link is to a picture... At least on my browser.
George Stocker
Damnit.. My clipboard went rogue.. fixed that.. thanks!
Tigraine
It's a really funny picture nonetheless.
George Stocker
Great; missed it.
Chris Lively
It has his picture with his reputation below it. At the time, his reputation was '666'.
George Stocker
+9  A: 

This is what I use: http://code.msdn.microsoft.com/sourceanalysis

preston
+4  A: 

ReSharper does just that. From the website:

Code Cleanup enables you to run a dozen of useful ReSharper features in one go — specifically, reformat your code according to custom style settings, arrange usages of 'this' qualifier, remove code redundancies, convert properties with backup fields to auto-properties, make fields read-only if possible, optimize using directives, shorten qualified references, update file header, replace explicit types with vars, and revamp your code with many more settings.

Having used it, I can say that it is the best add-in for Visual Studio that I've seen.

George Stocker
+2  A: 

Tigraine has mentioned FXCop - there's also NDepend which is somewhat different - a code analysis package which can identify design issues.

Jon Skeet
A: 

As @George S mentions, ReSharper does some of that; you can also use the Agent Smith plugin for some further control.

We also use StyleCop as @preston mentions.

bdukes
+2  A: 

There is a lot as mentioned in the other answers.

  • Fxcop does some rules, you can also extend it to fit your own needs.
  • Resharper detects and corrects some rules
  • Stylecop also is nice and together with the resharper plugin it gets even better. You can also extend it with your own rules.
  • CodeIt.Right is also very powerfull ( http://submain.com/ ) It not only tests, but gives you refactorings to refactor the most common violations (talk to the owner through twitter ) Also extendible !

If you just want a good list of coding guidelines Idesign has a pretty good list Idesign, also microsoft just released a new version of new framework design guidelines microsoft.

KeesDijk
+2  A: 

Code Style Enforcer is a plugin for Visual Studio 2005/2008 which you should take a look at.

Code Style Enforcer is a DXCore plug-in for Visual Studio 2005 / 2008 that checks the code against a configurable code standard and best practices. It is developed for C#, but some of the rules will also work for VB .NET, though not tested. The code standard is currently configurable with the following rules:

• Name rules, where it is possible to have different rules for different members, i.e. fields, constants, variables, methods, properties and so on.

• Visibility rules, where you can specify the visibility that is valid for different members. It is also possible to specify that the visibility has to be specified explicitly.

• Implementation rules, where it is possible to specify that interface implementations are to be made explicitly or implicitly.

It displays warnings when the developer is not following the guidelines..

Magnus Hytten
A: 

There are several, Resharper is my favourite

Steve Sheldon