【发布时间】: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