如何让GhostDoc正确记录接口实现?

时间:2018-02-09 10:28:06

标签: c# visual-studio visual-studio-2012 ghostdoc

我在一年前的Visual Studio 2015中使用过Ghostdoc Free,并且非常喜欢它的功能,并决定购买它。我现在必须使用Visual Studio 2012,并注意到类的注释不像以前那么好。

现在只是说:

/// The ClassName class.

之前它会区分实现接口的类,如:

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

我查看了规则,但我不确定如何提取接口的名称。我现在有这个:

/// 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;
}

结果如下:

/// Provides a class that implements a class name只是取了类名并拆分它。并且/// Implementation of IInterfaceName有点生硬(在多个接口的情况下)

那里会插入接口名称的任何例子吗?

1 个答案:

答案 0 :(得分:0)

规则模板中的codeElement.BaseTypes [0]应该返回生成的注释的接口名称。

我们很乐意帮助您解决此问题,请发送电子邮件至submain dot com的支持

谢谢!