Ignore missing XML comments

When Visual Studio is set to generate XML comment files it will print out warnings for each public member that has no comment. Sometimes you want to ignore some of the warnings (say you have a bunch of pretty much self explaining enum entries. Even worse: you have some generator that creates code without comments) What I have seen many times is that someone decides it’s not worth fixing 100 warnings and disables the creation of XML comment files for the whole project.

You don’t have to do that: Simply use a #Pragma statement to tell the compiler to stop issue warning for a certain Type:

#pragma warning disable 1591

When the section finishes and the warnings should be produced again use the following:

#pragma warning restore 1591

Of course you can do this with any other warning. The example uses the warning CS1591 (Missing XML comment for publicly visible type or member) but you can apply this to any warning, just ignore the CS prefix.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>