views:

735

answers:

4
+10  Q: 

FxCop for .NET 4.0

I know Visual Studio 2010 has a new Code Analysis tool built in, but that is only for the premium and ultimate editions. From what I can see the latest FxCop supports .NET 3.5 SP1. Searching I wasn't able to find any references to an FxCop for .NET 4.0. Is there plans to continue to offer FxCop and for it to support .NET 4.0? Where would I find more information about it and download it?

+2  A: 

I googled for FXcop 4.0 and found the following a helpful links:

http://social.msdn.microsoft.com/Forums/en/vstscode/thread/74b2815a-626d-4aef-a08a-14c2fa72b506

Looks like its not yet out but FXCop support for .NET 4.0 is planned.

CrimsonX
It has traditionally lagged behind with previous Framework releases, as well. What will be interesting to see is how much of a lag there is with 4.0, because the entire Code Analysis engine has been rewritten from the ground up according to their blog. http://blogs.msdn.com/codeanalysis/archive/2010/04/14/data-flow-analysis-rules-in-visual-studio-2010.aspx
joseph.ferris
I had read both of those links. Should have included them in my question. The forum post was in January for Beta 2. I was hoping for something newer.
Jim McKeeth
+7  A: 

The latest version of FXCop (v10) is bundled with the install of the latest Windows SDK for Windows 7 and .Net 4, released on 5/19/2010. From Microsoft - Full ISOs

Once the SDK is installed you can find the FXCop installer EXE under %programfiles%\Microsoft SDKs\Windows\v7.1\Bin\FXCop (This assumes you kept the default install directory when installing the SDK).

Enjoy.

GMariakis
A: 

FxCop is now enhanced to work with .NET 4.0. You can find it here: http://blogs.msdn.com/b/codeanalysis/archive/2010/07/26/fxcop-10-0-is-available.aspx

New version is marked with 10.0 just like Visual Studio.

TySu
A: 

An alternative to FxCop would be to use NDepend and its Code Query language (CQL). CQL is dedicated to write code quality rules that can be verified live in Visual Studio, or that can be verified during build process and reported in a HTML report. Here are a few samples of CQL rules (designed to be highly customizable):

Code refactored recently should be 100% covered by test:

WARN IF Count > 0 IN SELECT METHODS WHERE CodeWasChanged AND PercentageCoverage < 100

Complex methods should be commented:

WARN IF Count > 0 IN SELECT METHODS WHERE CyclomaticComplexity > 15 AND PercentageComment < 10

I don’t want that my User Interface layer to depend directly on the DataBase layer:

WARN IF Count > 0 IN SELECT NAMESPACES WHERE IsDirectlyUsing "DataLayer" AND NameIs "UILayer"

Static fields should not be named m_XXX (Custom naming conventions):

WARN IF Count > 0 IN SELECT FIELDS WHERE NameLike "^m_" AND IsStatic

Methods out of MyAssembly and MyAssembly2 should not have more than 30 lines of code:

WARN IF Count > 0 IN SELECT METHODS OUT OF ASSEMBLIES "MyAssembly1", "MyAssembly2" WHERE NbLinesOfCode > 30

Public methods should not be removed to avoid API breaking changes:

WARN IF Count > 0 IN SELECT METHODS WHERE IsPublic AND IsInOlderBuild AND WasRemoved

Types tagged with the attribute MyNamespace.FullCoveredAttribute must be thoroughly covered by tests:

WARN IF Count > 0 IN SELECT TYPES WHERE HasAttribute "MyNamespace.FullCoveredAttribute" AND PercentageCoverage < 100

Patrick Smacchia - NDepend dev