public static async Task<CompletionDescription> CreateDescriptionAsync( Workspace workspace, SemanticModel semanticModel, int position, IReadOnlyList<ISymbol> symbols, SupportedPlatformData supportedPlatforms, CancellationToken cancellationToken) { var symbolDisplayService = workspace.Services.GetLanguageServices(semanticModel.Language).GetService<ISymbolDisplayService>(); var formatter = workspace.Services.GetLanguageServices(semanticModel.Language).GetService<IDocumentationCommentFormattingService>(); // TODO(cyrusn): Figure out a way to cancel this. var symbol = symbols[0]; var sections = await symbolDisplayService.ToDescriptionGroupsAsync(workspace, semanticModel, position, ImmutableArray.Create(symbol), cancellationToken).ConfigureAwait(false); if (!sections.ContainsKey(SymbolDescriptionGroups.MainDescription)) { return CompletionDescription.Empty; } var textContentBuilder = new List<SymbolDisplayPart>(); textContentBuilder.AddRange(sections[SymbolDescriptionGroups.MainDescription]); switch (symbol.Kind) { case SymbolKind.Method: case SymbolKind.NamedType: if (symbols.Count > 1) { var overloadCount = symbols.Count - 1; var isGeneric = symbol.GetArity() > 0; textContentBuilder.AddSpace(); textContentBuilder.AddPunctuation("("); textContentBuilder.AddPunctuation("+"); textContentBuilder.AddText(NonBreakingSpaceString + overloadCount.ToString()); AddOverloadPart(textContentBuilder, overloadCount, isGeneric); textContentBuilder.AddPunctuation(")"); } break; } AddDocumentationPart(textContentBuilder, symbol, semanticModel, position, formatter, cancellationToken); if (sections.ContainsKey(SymbolDescriptionGroups.AwaitableUsageText)) { textContentBuilder.AddRange(sections[SymbolDescriptionGroups.AwaitableUsageText]); } if (sections.ContainsKey(SymbolDescriptionGroups.AnonymousTypes)) { var parts = sections[SymbolDescriptionGroups.AnonymousTypes]; if (!parts.IsDefaultOrEmpty) { textContentBuilder.AddLineBreak(); textContentBuilder.AddLineBreak(); textContentBuilder.AddRange(parts); } } if (supportedPlatforms != null) { textContentBuilder.AddLineBreak(); textContentBuilder.AddRange(supportedPlatforms.ToDisplayParts()); } return CompletionDescription.Create(textContentBuilder.Select(p => new TaggedText(SymbolDisplayPartKindTags.GetTag(p.Kind), p.ToString())).ToImmutableArray()); }
public static string Description(int count, List<string> toppings, Size size) { return string.Format("{0} {1}, {2} Topping Pizza - {3}", count, size, toppings.Count.ToHumanReadable(), toppings.AddPunctuation(), size); }