{"id":2899,"date":"2009-09-04T16:54:50","date_gmt":"2009-09-04T16:54:50","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/disable-xml-comment-warnings-for-a-file\/"},"modified":"2016-07-28T10:49:44","modified_gmt":"2016-07-28T10:49:44","slug":"disable-xml-comment-warnings-for-a-file","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/disable-xml-comment-warnings-for-a-file\/","title":{"rendered":"Disable XML Comment Warnings for a File"},"content":{"rendered":"<p>I&#8217;m a big fan of enabling XML comments when you&#8217;re working on a project (either alone or as a team) because it helps you quickly identify what has and what has not been documented.&#160; When you have XML comments enabled, the compiler will show warnings for any public and protected classes \/ class members that do not have XML comments.&#160; To enable XML comments you just check the <strong>XML documentation file<\/strong> option in the build tab of the project properties page.&#160; <\/p>\n<p>One of the issues that you run into, however, is that there can be a number of code generated files in your projects, and you have no control over that code.&#160; But, if that file is no re-generated often, then you can insert a bit of code to suppress XML comment warnings from that file:<\/p>\n<p> <code>\/\/ Disable all XML Comment warnings in this file \/\/     <br \/>#pragma warning disable 1591<\/code>  <\/p>\n<p>The next time you compile, XML comment warnings from the file will not be display.&#160; If you&#8217;re wondering, the 1591 is the specific warning number for XML comments.&#160; If you remove the XML comment warning number from the pragma statement, then all warnings from the file are suppressed, not just XML comment warnings.&#160; no warnings will come from the file.&#160; You can also tack on additional warning codes to suppress additional types of warnings, if desired.&#160; How do you figure out what the numbers are?&#160; I find one of the easiest ways to go about it is to read the output window (<strong>NOT <\/strong>the Error List window).&#160; When a warning is generated, it normally looks something like the following:<\/p>\n<p>[filename]: warning CS1591: Missing XML comment for publicly visible type or member &#8216;VSeWSS.TargetListAttribute&#8217;<\/p>\n<p>Notice there is a number right after the warning (in this case its CS1591)?&#160; Just drop the alpha prefix and you&#8217;ve got your warning number.&#160; Since this is in the output window, you may have to scroll through the text a bit to actually find the warning, but it should be in there somewhere.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a big fan of enabling XML comments when you&#8217;re working on a project (either alone or as a team) because it helps you quickly identify what has and what has not been documented.&#160; When you have XML comments enabled, the compiler will show warnings for any public and protected classes \/ class members that&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-2899","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=2899"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2899\/revisions"}],"predecessor-version":[{"id":41799,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2899\/revisions\/41799"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=2899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=2899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=2899"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=2899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}