0

I used Ghostdoc Free, a year ago in Visual Studio 2015, and really liked what it did, and decided to purchase it. I now have to use Visual Studio 2012 and noticed that comments for classes are not as good as before.

It now just says:

/// The ClassName class.

whereas before it would distinguish between classes that implements interfaces with something like:

/// Implements the <see cref="IInterfaceName"

I looked into the Rules, but I'm not sure how to extract the name(s) of the interfaces. I now have this:

/// Generates the summary documentation of the class.
private void GenerateSummaryDocumentation()
{
    // Assign the current code element.
    var codeElement = Context.CurrentCodeElement;

    // If the class appears to be a base class.
    if (codeElement.Name.EndsWith("Base"))
    {
        // Write the summary documentation of the class.
        this.WriteLine("Provides a base class to derive {0} of.", Context.ExecMacro("$(TypeName.Words.All)"));
    }
    else
    {
        if (codeElement.HasBaseTypes)
        {
            var baseType = codeElement.BaseTypes[0];
            baseType = baseType.Substring(baseType.LastIndexOf(".") + 1);
            this.WriteLine("Implementation of {0}", baseType);
        }
        else
        {
            // Write the summary documentation of the class.
            this.WriteLine("Provides a class that implements a {0}", Context.ExecMacro("$(TypeName.Words.All)"));               
        }
    }

    return;
}

Which results in this:

/// Provides a class that implements a class name which is just taking the class name and splitting it. And /// Implementation of IInterfaceName which is a bit blunt (in case of multiple interfaces)

Any examples out there that would insert the interface name here?

reckface
  • 5,678
  • 4
  • 36
  • 62

1 Answers1

0

The codeElement.BaseTypes[0] in the rule's Template should have returned the interface name for the generated comment.

We are happy to help you troubleshoot this issue, please email us at support at submain dot com

Thanks!

sergeb
  • 2,484
  • 3
  • 22
  • 20
  • Thanks! Has something changed in the default rules template? I liked how it used to generate comments, but it's a bit simplistic now. Do you have a template repository for class rules? – reckface Feb 13 '18 at 17:35
  • Yes, we keep improving the templates but they would get sophisticated, not simplistic. The template repository effort wasn't very successful due to the IP/licensing complexities of the legal world. If you have any particular recommendations, please let us know - here or at support at submain dot com and we will either make it part of the template or help you create your custom template. – sergeb Feb 13 '18 at 22:41