本文整理汇总了C#中IMethodSymbol.GetDocumentationCommentXml方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.GetDocumentationCommentXml方法的具体用法?C# IMethodSymbol.GetDocumentationCommentXml怎么用?C# IMethodSymbol.GetDocumentationCommentXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodSymbol
的用法示例。
在下文中一共展示了IMethodSymbol.GetDocumentationCommentXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadSymbol
protected override void ReadSymbol(IMethodSymbol methodSymbol)
{
// we don't need to know about static members
// because they won't be delegated from child to mixin
if (methodSymbol.IsStatic)
return;
// skip methods that are not visible to the outside world
if (methodSymbol.DeclaredAccessibility == Accessibility.Private ||
methodSymbol.DeclaredAccessibility == Accessibility.Protected)
return;
// skip all property accessors and ctors
if (methodSymbol.MethodKind == MethodKind.Ordinary)
{
var isOverrideFromObject =
methodSymbol.IsOverride &&
methodSymbol.OverriddenMethod
?.ContainingType.SpecialType == SpecialType.System_Object;
var method = new Method(
methodSymbol.Name,
methodSymbol.ReturnType,
isOverrideFromObject)
{
IsAbstract = methodSymbol.IsAbstract,
IsOverride = methodSymbol.IsOverride,
IsInternal = methodSymbol.DeclaredAccessibility.HasFlag(Accessibility.Internal),
Documentation = new DocumentationComment(methodSymbol.GetDocumentationCommentXml())
};
var parameterReader = new ParameterSymbolReader(method);
parameterReader.VisitSymbol(methodSymbol);
_methods.AddMethod(method);
}
}
示例2: ForMethod
/// <summary>
/// Process a method declaration for documentation.
/// </summary>
/// <param name="symbol">The method in question.</param>
/// <returns><c>Docs</c> if the method contains any, otherwise <c>null</c>.</returns>
public static Doc ForMethod(IMethodSymbol symbol)
{
var doc = symbol.GetDocumentationCommentXml();
if (string.IsNullOrEmpty(doc))
{
return null;
}
var sections = new List<Tuple<int, string, string>>();
var xdoc = XDocument.Parse(doc).Root;
ProcessFull(xdoc, sections);
var cursor = sections.FindIndex(t => t.Item2 == "Summary");
var paramsSection = ProcessParameters(xdoc, symbol.Parameters.Select(p => p.Name).ToList());
sections.Insert(cursor + 1, paramsSection);
var returnElement = xdoc.Element("returns");
if (returnElement != null)
{
var content = ProcessContent(returnElement);
if (!string.IsNullOrEmpty(content))
{
sections.Insert(cursor + 2, Tuple.Create(2, "Return value", $"<p>{content}</p>"));
}
}
var resultString = string.Join("\n", sections.Select(t => $"<h{t.Item1 + 2}>{t.Item2}</h{t.Item1 + 2}>{t.Item3}"));
return new Doc
{
Format = "text/html",
Data = resultString
};
}
示例3: BuildSignature
private SignatureHelpItem BuildSignature(IMethodSymbol symbol)
{
var signature = new SignatureHelpItem();
signature.Documentation = symbol.GetDocumentationCommentXml();
if (symbol.MethodKind == MethodKind.Constructor)
{
signature.Name = symbol.ContainingType.Name;
signature.Label = symbol.ContainingType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
}
else
{
signature.Name = symbol.Name;
signature.Label = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
}
signature.Parameters = GetParameters(symbol).Select(parameter =>
{
return new SignatureHelpParameter()
{
Name = parameter.Name,
Label = parameter.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat),
Documentation = parameter.GetDocumentationCommentXml()
};
});
return signature;
}