Question

Throughout or C# sourcecode we have a lot of comments that miss the actual content such like this:

/// <summary>
/// </summary>

or this:

/// <summary>
///
/// </summary>

or this:

/// <param Name="flag"></param>

Unfortunately Visual Studio does not generate warnings for this type of missing comments. But for us it would be nice if we could just klick on an item in a list (eg. the warings list) inside visual studio and then be taken to the faulty location in source code to correct it. Also it would be nice to see the list of missing xml comment content upon each build of the xml files. Do you have any idea on how to achieve this?

Was it helpful?

Solution 2

ReSharper is the answer to this (as many other) shortcoming of Visual Studio. I have nothing but pity for anyone who does not use it. ;)

OTHER TIPS

Try XML Comment Checker:

XML Comment Checker is an application that will check the XML documentation for a .Net assembly for omissions. It offers a more comprehensive checking than the C# compiler itself, and is ideal for when you wish to check your comments before compiling them into real documentation, e.g using Microsoft Sandcastle.

From the feature list:

Check for empty sections. Optionally, XML Comment Checker will warn if any of the required sections or elements are present, but empty. This is not enabled by default

Usage from Visual Studio:

XML Comment Checker can be set as the post-build event in Visual Studio to check an assembly automatically. The warnings emitted by XML Comment Checker have been formatted so that Visual Studio will recognize them and display them in the Error List. An example post-build command line: "PathToCommentChecker\CommentChecker.exe" "$(TargetPath)" -nologo -warnemptysections

FxCop and a custom rule?

You can use an XSLT file and debug the xml against the XSLT file and then it will throw error if the xml is not well formed showing you the exact line number against which the xml is not well formed. This simple XSLT file works-

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top