More than one FxCop tip

by Matt 8. April 2007 18:02

FxCop is pretty useful. No, really. Automated code review type thing. Sort of. And here I am about to give you the best FxCop tip in the world. Well, actually the best two FxCop tips. Ok, make it three. Ah stuff it, here's a whole bunch of them.

First top tip - unless you're using the version of FxCop that's integrated into Visual Studio (I'm not), you'll want to define the CODE_ANALYSIS symbol in your project settings. This is because the SuppressMessageAttribute class is decorated with a ConditionalAttribute with the CODE_ANALYSIS symbol. In other words, the SuppressMessage attribute will be ignored unless you define CODE_ANALYSIS. (Only define it for debug projects. Consider that a bonus tip.)

(Of course, you might actually want it to be ignored to stop over-zealous/lazy programmers suppressing FxCop violations instead of fixing them. But hey, let's try and stay glass half full, eh?)

Here's one I prepared earlier - ensure your spell check language is consistent across all users. And the top up tip is to ensure that you're all on the same version (and service pack revision) of Office.

The FxCop team blog provides a way to run FxCop as part of a normal build, including a bug and workaround. But this doesn't use a project you might have set up, so you might want to give the FxCop msbuild task from the MSBuild Community Tasks Project, or just play about with the /project command line option. (This blog post has more details on FxCop/Visual Studio integration, including a link to an FxCop addin, that I'll have to have a look at.)

Speaking of projects, FxCop bizarrely saves the messages to the project file after each run. The advantage of this is that you get to see what's changed between runs, with new messages displayed in bold, but you do need to have the file checked out each time you run an analysis. If you don't want this, uncheck the option to save Active messages in the project. You still want to keep exclusions checked though - that's a change that you do want saved. Alternatively, you can save active and excluded messages to the report file and use the /import switch to FxCopCmd to get it to read those files. This way, your project file doesn't have to change at all, but managing the reports in source control could get tricky. (I feel a post analysis script coming on...)

I think that last paragraph can be summed up simpler - read the docs. Or at least, read the "Managing FxCop Projects" page. It's dead easy to get started with FxCop, but once you start to get a bit more advanced, it's not terribly obvious what's going on. And if you're putting FxCop into a build process, you'll really want to read through "Using FxCopCmd".

But the number one best FxCop tip? Simple. Run it from day one. Don't let the violations back up, or you'll never bother to clear them down.

Tags:

.net tools | FxCop

Comments (20) -

best suv 2010
best suv 2010
7/20/2011 10:20:08 PM #

Fantastic task I like your type! Would really like to right here your feedback on my website! I am also seeking for someone to help you me make websites!

Reply

luxury car
luxury car
7/22/2011 1:34:01 AM #

Una pagina sarà dedicata agli accessori, una alle giacche e ai giubbotti. Troverai le indicazioni per lo spaccio o negozio Moncler più vicino a casa tua e tutte le offerte più vantaggiose di questo prestigioso marchio.

Reply

best ipad games
best ipad games
7/24/2011 3:50:59 AM #

Per il tuo bambino scegli Moncler. Una scelta di capi, estivi ed invernali, eccezionali. Tuo figlio sarà sempre alla moda e potrà muoversi in totale comodità.

Reply

domain name coupon
domain name coupon
8/24/2011 3:26:38 AM #

Thanks for writing about something so well written. I bookmarked it on mixx - need more sites like this!

Reply

Eric
Eric
10/22/2011 10:02:46 AM #

hello there,

Interresting post here

Reply

Lisa
Lisa
10/23/2011 11:59:38 AM #

Hello

nice post here
continue updating your blog

Reply

Stephane
Stephane
10/23/2011 7:26:26 PM #

Hi

Interresting post here

Reply

Eric
Eric
10/23/2011 8:46:47 PM #

hello there,

Interresting post here may come back soon
continue updating your blog

Reply

Robert
Robert
10/23/2011 10:50:58 PM #

Hi

Interresting post here will came back
keep update

Reply

Stephane
Stephane
10/24/2011 12:25:24 AM #

Hi

Interresting post here may come back soon
Keep like this

Reply

Robert
Robert
10/24/2011 12:27:15 AM #

Hello

Interresting post here will came back
keep update

Reply

proto
proto United States
10/27/2011 4:14:28 AM #

hi, this is my comment

Reply

proto
proto United States
10/27/2011 4:26:52 AM #

hi, this is my comment

Reply

proto
proto United States
10/27/2011 4:31:12 AM #

hi, this is my comment

Reply

iPad games reviews
iPad games reviews
12/1/2011 5:02:42 AM #

Good job  , amazing Post !!!

Reply

photographe mariage paris
photographe mariage paris United States
6/8/2015 1:59:48 AM #

I have seen that today, more and more people are being attracted to cameras and the issue of images. However, like a photographer, it's important to first commit so much of your time deciding the exact model of dslr camera to buy as well as moving out of store to store just so you might buy the least expensive camera of the trademark you have decided to settle on. But it won't end generally there. You also have to take into consideration whether you should purchase a digital video camera extended warranty. Many thanks for the good suggestions I obtained from your web site.

Reply

Philix
Philix United States
11/22/2015 10:12:22 AM #

Superb Website.

Reply

Leonel Marturano
Leonel Marturano United States
1/15/2016 4:57:06 AM #

The dolphin saving you one is the best one!

Reply

Isreal Payor
Isreal Payor United States
1/15/2016 8:32:32 AM #

getting the last pair of shoes in your size AWESOME!

Reply

Andrew A. Sailer
Andrew A. Sailer United States
10/18/2016 2:44:15 AM #

Un petit message pour vous dire que votre site est vraiment excellent ! je suis vos infos r�guli�rement et j'esp�re qu'elles continueront! A bient�t !

Reply

Add comment

biuquote
  • Comment
  • Preview
Loading

Rel=Me

Month List

RecentComments

Comment RSS