Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

Suppress missing comments warning

Modified: 2009/06/19 17:09 by vanthoog - Categorized as: Csharp, Visual Studio
A great feature of C# is the ability to automatically generate documentation for public classes, methods, properties etcetera. You can enable this feature by going to the properties of your Visual Studio project and specifying a XML documentation file:
Xml documentation specification

Xml documentation specification


After doing this when rebuilding your solution warnings will be generated for every public item (i.e. class, method, property etc.) without proper comments:

"Missing comments" warning


These warnings are a great feature because it helps you to remember to add valid and proper comments. However, sometimes it can be annoying, e.g. when you have temporarily added some code that will be removed later. Fortunately you can suppress these warnings by surrounding your temporary code by “#pragma warning disable 1591” and “#pragma warning restore 1591”.

For example:

        #pragma warning disable 1591

        //TODO: Remove this temporary code.

        public Aanduidingen GetAanduidingen(IVestiaContext vestiaContext)
        {
            try
            {
                LogHelper.LogInformation(vestiaContext.Username);

                // Some code….

                return (aanduidingen);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex);
                throw;
            }
        }

        #pragma warning restore 1591

Now if you rebuild your solution, no warnings will be generated:

No

No "missing comments" warning



 © Evident Interactive BV