views:

925

answers:

4

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?

+3  A: 

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.

DeletedAccount
I see, I didn't pay attention to the "warnings" tab as it is normally only littered with "missing css classes". Which is a non-functional warning to begin with (VS doesn't find half of your CSS files and not all classes are for CSS)
borisCallens
I also find this annoying but, if you have css classes that are used purely for marking the HTML, rather than for styling it, why not add an empty CSS rule (In a section that is commented to explain the reason for the rules being empty)
belugabob
+2  A: 

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

Joe R
+1  A: 

You can also use the tool NDepend to write your rules and harness some of the 200 default rules. The cool fact about NDepend compare to FxCop, is that NDepend comes with a dedicated language to write your own rule: Code Query Language (CQL)

For example the following CQL rule will warn if it finds method with more than 20 lines of code:
WARN IF Count > 0 IN SELECT METHODS WHERE NbLinesOfCdoe > 20

As with FxCop, NDepend might generate tons of warning. The difference is that NDepend lets you specify a particular snapshot of your code base, and then do your analysis on the diff since this snapshot. Then you'll be advised of problem introduced since a particular date. More explanation about this feature can be found here: Ensure the quality of the code that will be developed this year

Patrick Smacchia - NDepend dev
sounds interesting. Might suggest this to my boss
borisCallens
+2  A: 

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.

Chris Ammerman
but have standalone version
Avram
Thanks Avram, I was able to find version 1.36 of FxCop as a standalone application. Careful searching though, people, because the beta actually shows up higher in the Google results.
Chris Ammerman