本文整理汇总了C#中ISymbol.GetDocumentationComment方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.GetDocumentationComment方法的具体用法?C# ISymbol.GetDocumentationComment怎么用?C# ISymbol.GetDocumentationComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbol
的用法示例。
在下文中一共展示了ISymbol.GetDocumentationComment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddExceptions
private void AddExceptions(ISymbol symbol)
{
var exceptionTypes = symbol.GetDocumentationComment().ExceptionTypes;
if (exceptionTypes.Any())
{
var parts = new List<SymbolDisplayPart>();
parts.Add(new SymbolDisplayPart(kind: SymbolDisplayPartKind.Text, symbol: null, text: $"\r\n{WorkspacesResources.Exceptions_colon}"));
foreach (var exceptionString in exceptionTypes)
{
parts.AddRange(LineBreak());
parts.AddRange(Space(count: 2));
parts.AddRange(AbstractDocumentationCommentFormattingService.CrefToSymbolDisplayParts(exceptionString, _position, _semanticModel));
}
AddToGroup(SymbolDescriptionGroups.Exceptions, parts);
}
}
开发者ID:jkotas,项目名称:roslyn,代码行数:17,代码来源:AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs
示例2: GetAutoCompleteItem
private static IEnumerable<AutoCompleteItem> GetAutoCompleteItem(ISymbol symbol, bool showClassesAsStatic)
{
var result = new List<AutoCompleteItem>();
var item = new AutoCompleteItem {Name = symbol.Name};
var itemDoc = symbol.GetDocumentationComment(CultureInfo.GetCultureInfo("en-US"));
if (itemDoc != null)
item.Description = itemDoc.SummaryTextOpt;
switch (symbol.Kind)
{
case CommonSymbolKind.Method:
item.ItemType = AutoCompleteItemType.Method;
var methodSymbol = (IMethodSymbol) symbol;
item.IsExtension = methodSymbol.IsExtensionMethod;
item.IsStatic = methodSymbol.IsStatic;
item.Type = methodSymbol.ReturnsVoid ? "void" : methodSymbol.ReturnType.Name;
//args
item.Params = GetSymbolParameters(methodSymbol.Parameters, itemDoc);
item.IsGeneric = methodSymbol.IsGenericMethod;
break;
case CommonSymbolKind.Local:
item.ItemType = AutoCompleteItemType.Variable;
var localSymbol = (ILocalSymbol) symbol;
item.Type = localSymbol.Type.Name;
break;
case CommonSymbolKind.Field:
item.ItemType = AutoCompleteItemType.Variable;
var fieldSymbol = (IFieldSymbol) symbol;
item.Type = fieldSymbol.Type.Name;
break;
case CommonSymbolKind.Property:
item.ItemType = AutoCompleteItemType.Property;
var propertySymbol = (IPropertySymbol) symbol;
item.Type = propertySymbol.Type.Name;
break;
case CommonSymbolKind.Namespace:
item.ItemType = AutoCompleteItemType.Namespace;
var namespaceSymbol = (INamespaceSymbol) symbol;
item.Name = namespaceSymbol.Name;
break;
case CommonSymbolKind.NamedType:
item.ItemType = AutoCompleteItemType.Class;
var classSymbol = (INamedTypeSymbol) symbol;
item.Name = classSymbol.Name;
item.IsStatic = showClassesAsStatic || classSymbol.IsStatic;
item.IsGeneric = classSymbol.IsGenericType;
if (!showClassesAsStatic)
{
var constructors = classSymbol.GetConstructors();
foreach (var constructor in constructors)
{
itemDoc = constructor.GetDocumentationComment(CultureInfo.GetCultureInfo("en-US"));
var consItem = (AutoCompleteItem) item.Clone();
if (itemDoc != null)
consItem.Description = itemDoc.SummaryTextOpt;
consItem.Params = GetSymbolParameters(constructor.Parameters, itemDoc);
result.Add(consItem);
}
}
break;
}
if (result.Count == 0)
result.Add(item);
return result;
}
示例3: GetDocumentation
private static string GetDocumentation(ISymbol symbol, CancellationToken cancellationToken)
{
switch (symbol)
{
case IParameterSymbol parameter: return parameter.ContainingSymbol.OriginalDefinition.GetDocumentationComment(cancellationToken: cancellationToken).GetParameterText(symbol.Name);
case ITypeParameterSymbol typeParam: return typeParam.ContainingSymbol.GetDocumentationComment(cancellationToken: cancellationToken).GetTypeParameterText(symbol.Name);
case IMethodSymbol method: return GetMethodDocumentation(method);
case IAliasSymbol alias: return alias.Target.GetDocumentationComment(cancellationToken: cancellationToken).SummaryText;
default: return symbol.GetDocumentationComment(cancellationToken: cancellationToken).SummaryText;
}
}
示例4: BuildXmlDocumentation
private void BuildXmlDocumentation(ISymbol symbol, Compilation compilation, _VSOBJDESCOPTIONS options)
{
var documentationComment = symbol.GetDocumentationComment(expandIncludes: true, cancellationToken: CancellationToken.None);
if (documentationComment == null)
{
return;
}
var formattingService = _project.LanguageServices.GetService<IDocumentationCommentFormattingService>();
if (formattingService == null)
{
return;
}
var emittedDocs = false;
if (documentationComment.SummaryText != null)
{
AddLineBreak();
AddName(ServicesVSResources.Library_Summary);
AddLineBreak();
AddText(formattingService.Format(documentationComment.SummaryText, compilation));
emittedDocs = true;
}
if (documentationComment.TypeParameterNames.Length > 0)
{
if (emittedDocs)
{
AddLineBreak();
}
AddLineBreak();
AddName(ServicesVSResources.Library_TypeParameters);
foreach (var typeParameterName in documentationComment.TypeParameterNames)
{
AddLineBreak();
var typeParameterText = documentationComment.GetTypeParameterText(typeParameterName);
if (typeParameterText != null)
{
AddParam(typeParameterName);
AddText(": ");
AddText(formattingService.Format(typeParameterText, compilation));
emittedDocs = true;
}
}
}
if (documentationComment.ParameterNames.Length > 0)
{
if (emittedDocs)
{
AddLineBreak();
}
AddLineBreak();
AddName(ServicesVSResources.Library_Parameters);
foreach (var parameterName in documentationComment.ParameterNames)
{
AddLineBreak();
var parameterText = documentationComment.GetParameterText(parameterName);
if (parameterText != null)
{
AddParam(parameterName);
AddText(": ");
AddText(formattingService.Format(parameterText, compilation));
emittedDocs = true;
}
}
}
if (ShowReturnsDocumentation(symbol) && documentationComment.ReturnsText != null)
{
if (emittedDocs)
{
AddLineBreak();
}
AddLineBreak();
AddName(ServicesVSResources.Library_Returns);
AddLineBreak();
AddText(formattingService.Format(documentationComment.ReturnsText, compilation));
emittedDocs = true;
}
if (documentationComment.RemarksText != null)
{
if (emittedDocs)
{
AddLineBreak();
}
//.........这里部分代码省略.........