【问题标题】:How can I get GhostDoc to properly document interface implementation?如何让 GhostDoc 正确记录接口实现?
【发布时间】:2018-07-20 02:26:49
【问题描述】:

一年前,我在 Visual Studio 2015 中使用过 Ghostdoc Free,我非常喜欢它的功能,并决定购买它。我现在必须使用 Visual Studio 2012,发现类的 cmets 不如以前好。

现在只是说:

/// 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有点生硬(多接口的情况下)

有没有可以在此处插入接口名称的示例?

【问题讨论】:

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


    【解决方案1】:

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

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

    谢谢!

    【讨论】:

    • 谢谢!默认规则模板有什么变化吗?我喜欢它用来生成 cmets 的方式,但现在有点简单化了。你有类规则的模板库吗?
    • 是的,我们不断改进模板,但它们会变得复杂,而不是简单化。由于法律界的知识产权/许可复杂性,模板存储库的工作并不十分成功。如果您有任何特别的建议,请在此处或在 submain dot com 的支持处告知我们,我们将使其成为模板的一部分或帮助您创建自定义模板。
    猜你喜欢
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 2016-02-15
    • 2011-04-04
    • 1970-01-01
    • 2016-06-10
    • 2017-12-13
    • 1970-01-01
    相关资源
    最近更新 更多