Question

FxCops is something new to me, but as always I would like to get to know the new things.. From what I've read, FxCops is already included in VS2008. I guess it's the "Code Analysis" function. Whenever I try to run it though, it seems to start a rebuild and end in the "Finished Rebuilding" state.
I checked the output window and there are a bunch of warnings there. But if I'm not mistaking, there should be more of a GUI for this then the wall of text in my output window, right?
Am I missing a window that should have popped up? Can I open it somewhere? Or is there anything else I'm missing?

Was it helpful?

Solution

Yes, Code Analysis is the nice friendly name for FxCop. However, I'm not aware of a friendly window beyond the errors / warning list where they should appear, prefixed CA.

On the project properties screen there is a Code analysis tab where you can treat warnings as errors to enforce the rules you care about.

OTHER TIPS

You're not missing anything - there isn't a pop-up window.

The list of issues in the output window is pretty much all you'd get in FxCop. It's just that FxCop is a standalone application.

Here's a decent article on FxCop and Code Analysis:

http://geekswithblogs.net/sdorman/archive/2008/08/19/visual-studio-and-code-analysis.aspx

Just so everyone knows, because it took me a long time to figure this out.... Code Analysis / FxCop is only included in Team System and Team Suite versions of VS 2008, not in the Professional Edition.

An alternative to FxCop would be to use the tool NDepend that lets write Code Rules over C# LINQ Queries (namely CQLinq). NDepend is integrated in VS 2012, 2010 and 2008. Disclaimer: I am one of the developers of the tool

More than 200 code rules are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.

NDepend code rules can be verified live in Visual Studio and at build process time, in a generated HTML+javascript report.

You seems concerned by the number of false-positive. To keep the number of false-positives low, CQLinq offers the unique capabilities to define what is the set JustMyCode through special code queries prefixed with notmycode. More explanations about this feature can be found here. Here are for example two notmycode default queries:

To keep the number of false-positives low, with CQLinq you can also focus rules result only on code added or code refactored, since a defined baseline in the past. See the following rule, that detect methods too complex added or refactored since the baseline:

warnif count > 0 
from m in Methods
where m.CyclomaticComplexity > 20 &&
      m.WasAdded() || m.CodeWasChanged()
select new { m, m.CyclomaticComplexity }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top