Tech Blech

Thursday, December 27, 2007

Suppressing VS.NET Compiler Warnings (2005, 2008)

"1591" was the magic string that I needed, and this is the sorry tale of how to find that out.

As a rule, I don't like suppressing compiler warnings, but there is a time for everything. My time came when I inherited a huge mass of ill-behaving C# code and began adding XML comments. I was immediately overwhelmed by hundreds of warnings that said "Missing XML comment for publicly visible type". I wanted to compile the comments that I had added without being nagged by the compiler for not having added the remaining 300 possible XML comments as well.

I knew that Visual Studio 2005 would let me suppress specific warnings in the project build properties. However, I didn't know the warning number that I needed to supply. Microsoft, in their great goodness, has suppressed showing of warning numbers--they only show the text. A few googles later, I knew that it was either 1591 or CS1591, but no one told me anywhere, in general, now to find the full list of warning numbers. I've wanted this list many a time in the past, so I set out to find out, once and for all.

Eventually, I found that I needed to start at the top-level C# Reference page in MSDN2 (for the appropriate version of VS.NET), then search on "compiler warning " + "warning text". So searching on "compiler warning missing XML comment" got me the precious warning number that I needed, which is CS1591. But then I had to psychically understand, of course, that the CS must be left off, and only the 1591 entered.

See my glorious build screen which finally suppressed the evil hundreds of unwanted warnings:


UPDATE in Oct 2008: Now that I am using Visual Studio 2008, I have learned that I can right-click over a warning in the Error List pane, and it will pop up documentation about the warning that includes its error level and number, and from that, I can derive the 4 digits to place in the suppress box of the project Build properties. It is not necessary to search on the Microsoft website. I don't know if this feature was present in Visual Studio 2005 (and I just didn't know it), or not.

Labels: ,


  • If you run MSBuild from a command prompt, the compiler warning numbers are displayed.

    By Anonymous Anonymous, at 5:25 AM  


    By Anonymous Anonymous, at 12:22 AM  

  • Or, you can read the M$ page using programming language of your choice and parse out the compiler errors. For each one, read the related error text page and parse out the primary error text and first paragraph of description. Write your results to a table and you have a complete, dynamically generated reference.

    Took about 45 minutes...

    By Anonymous Anonymous, at 10:24 AM  

  • Thanks, now I know how to suppress specific warning.

    BTW, you can view warning number in Output panel (when you build)

    By Blogger LockeVN, at 6:29 AM  

  • In principle, a good happen, support the views of the author

    By Anonymous generic cialis, at 12:09 AM  

  • Very nice post. I simply stumbled upon your bpog and
    wanted to mention that I have really enjoyed surfing around your weblog posts.
    In any case I'll be subscribing on your feed and I am hoping you write again soon!

    Take a look at my webpage Steven McIntire

    By Anonymous Anonymous, at 1:23 PM  

  • This site is excellent for advertising your product online
    Advertise online free

    By Blogger Unknown, at 2:56 AM  

Post a Comment

<< Home