views:

415

answers:

6
+7  Q: 

Checkstyle for C#?

I'm looking to find something along the lines of Checkstyle for Visual Studio. I've recently started a new gig doing .NET work and realized that coding standards here are a bit lacking. While I'm still a young guy and far from the most experienced developer I'm trying to lead by example and get things going in the right direction.

I loved the ability to use Checkstyle with Eclipse and examine code before reviews so I'd like to do the same thing with Visual Studio. Anyone have any good suggestions?

Another thing I'd be somewhat interested in is a plug-in for SVN that disallows check-in until the main coding standards are met. I do not want people checking in busted code that's going to wind up in a code review.

Any suggestions at this point would be great.

+6  A: 

Have you tried StyleCop?

JaredPar
+7  A: 

Take a look at resharper.

lexu
+1 for my favorite tool
Chris Marisic
resharper rocks (mostly)
stmax
+4  A: 

What you're looking for is called Static Code Analysis.

FxCop is one option. I think Resharper can check this kind of thing as well.

Joel Coehoorn
Thanks for letting me know the proper term, I feel a bit silly at times not knowing the right name for stuff.
PSU_Kardi
Isn't CheckStyle just for coding style? FxCop actually looks for errors and mistakes which clearly falls into static code analysis. But coding style is more token/whitespace analysis than dealing with actual code ...
Joey
I think you mean StyleCop..? FxCop only looks at IL-code (thus cannot check indentation, braces and so on), StyleCop looks at C# code.
stmax
+4  A: 

We use StyleCop to enforce our coding standards. It is free and integrates nicely with Visual Studio

John Myczek
could you tell me if you use stylecop's rules or if you implemented your own set of rules?what i don't like about stylecop is that its rules aren't configurable (like in resharper) and that it kind of forces its rules upon you.. unless you want to go through the trouble of changing and maintaining the set of rules described in c# code..
stmax
For the most part we use StyleCop's rules. There are a few that we disable. I have not tried it, but it is possible to write custom rules using the StyleCop SDK. Here is a tutorial: http://www.lovethedot.net/2008/05/creating-custom-rules-for-microsoft.html
John Myczek
+1  A: 

Here are some of the great tools you can use

FxCop is a code analysis tool that checks .NET managed code assemblies for conformance to the Microsoft .NET Framework Design Guidelines


ReSharper is a refactoring and productivity plugin by JetBrains that extends native functionality of Microsoft Visual Studio .NET 2003, 2005 and 2008.


StyleCop is a free static code analysis tool from Microsoft that checks C# code for conformance to StyleCop's recommended coding styles and a subset of Microsoft's .NET Framework Design Guidelines

ref: http://blogs.msdn.com/fxcop/

Asad Butt
A: 

Have you had a chance to review StyleCop

Digicoder