Warning are Errors!

I haven’t talked much about my project here on the blog, but it has been growing and growing over the last year. I am now the lead on a project including three teams and a total of sixteen developers, which can be quite tough to manage. One of the main challenges is ensuring that the code being written is high quality. We use some automated procedures like CruiseControl.NET, FxCop, and Code Coverage and whenever possible the good old fashioned code review.

One of the things that has always bothered me though is compiler warnings, these are simple things that are usually easy to fix and just represent complete laziness when they start cropping up. I would notice these on the build reports and it always drove me crazy. Well, apparently I am the last person to know that you can tell Visual Studio to treat all warnings as errors. A quick change to all of our project files:

and no more warnings (at least not in builds that work).

In the future I will blog more about some of what I have found that works and doesn’t work.

Reader comment: Ayende Rahien says,

In general, I would agree, but there are a number of things that you know that the compiler doesn't that makes the warning useless in some cases.

A field with read only property that it being set by reflection will trigger a warning, but you know that this is silly.

The worst part, though, is that you get warnings from valid/invalid HTML in aspx

When needed you can turn off individual warnings for the entire project using the suppress warnings option shown above, or even better just turn it off for the specific place that you need it:

#pragma warning disable 1591

and

#pragma warning restore 1591

You can find a list of all the compiler errors and warnings here: http://msdn2.microsoft.com/en-us/library/ms228296.aspx (wait for the tree to load on the left)

-James

Comments

#1 Ayende Rahien on 9.01.2006 at 9:11 AM

In general, I would agree, but there are a number of things that you know that the compiler doesn't that makes the warning useless in some cases.

A field with read only property that it being set by reflection will trigger a warning, but you know that this is silly.

The worst part, though, is that you get warnings from valid/invalid HTML in aspx

#2 James Avery on 9.03.2006 at 6:26 PM

Well, if you aren't concerned about invalid HTML you can always suppress those warnings. The read-only property being set through reflection is a little tougher. (although you can also suspend a specific warning just for a single file)

#3 Andy on 9.05.2006 at 7:59 PM

Don't tell Josh about this... In fact please remove this post from your blog. I don't feel like having to fix all the warnings in our project... 99% of them stem from the method summary not having all the params listed.

#4 Brian H. Madsen on 9.06.2006 at 3:46 PM

Hey James,
how have you found using CruiseControl.NET?

i have been considering getting it for the team i manage, but so far i haven't made a decision yet.

Leave a Comment