private static AutoCompleteItemParameter[] GetSymbolParameters(ReadOnlyArray <IParameterSymbol> paramsArray, DocumentationComment docComment, bool includeThis = false) { var result = paramsArray.Where(p => !includeThis || !p.IsThis) .Select(p => new AutoCompleteItemParameter() { Name = p.Name, Type = GetparameterTypeName(p.Type), Description = docComment != null ? docComment.GetParameterText(p.Name) : null }) .ToArray(); return(result.Length == 0 ? null : result); }
internal static ImmutableArray <string> Format(IDocumentationCommentFormattingService docCommentFormattingService, DocumentationComment docComment) { var formattedCommentLinesBuilder = ArrayBuilder <string> .GetInstance(); var lineBuilder = new StringBuilder(); var formattedSummaryText = docCommentFormattingService.Format(docComment.SummaryText); if (!string.IsNullOrWhiteSpace(formattedSummaryText)) { formattedCommentLinesBuilder.Add(s_summaryHeader); formattedCommentLinesBuilder.AddRange(CreateWrappedTextFromRawText(formattedSummaryText)); } var parameterNames = docComment.ParameterNames; if (parameterNames.Length > 0) { formattedCommentLinesBuilder.Add(string.Empty); formattedCommentLinesBuilder.Add(s_paramHeader); for (var i = 0; i < parameterNames.Length; i++) { if (i != 0) { formattedCommentLinesBuilder.Add(string.Empty); } lineBuilder.Clear(); lineBuilder.Append(' ', s_indentSize); lineBuilder.Append(string.Format(s_labelFormat, parameterNames[i])); formattedCommentLinesBuilder.Add(lineBuilder.ToString()); var rawParameterText = docComment.GetParameterText(parameterNames[i]); var formattedParameterText = docCommentFormattingService.Format(rawParameterText); if (!string.IsNullOrWhiteSpace(formattedParameterText)) { formattedCommentLinesBuilder.AddRange(CreateWrappedTextFromRawText(formattedParameterText)); } } } var typeParameterNames = docComment.TypeParameterNames; if (typeParameterNames.Length > 0) { formattedCommentLinesBuilder.Add(string.Empty); formattedCommentLinesBuilder.Add(s_typeParameterHeader); for (var i = 0; i < typeParameterNames.Length; i++) { if (i != 0) { formattedCommentLinesBuilder.Add(string.Empty); } lineBuilder.Clear(); lineBuilder.Append(' ', s_indentSize); lineBuilder.Append(string.Format(s_labelFormat, typeParameterNames[i])); formattedCommentLinesBuilder.Add(lineBuilder.ToString()); var rawTypeParameterText = docComment.GetTypeParameterText(typeParameterNames[i]); var formattedTypeParameterText = docCommentFormattingService.Format(rawTypeParameterText); if (!string.IsNullOrWhiteSpace(formattedTypeParameterText)) { formattedCommentLinesBuilder.AddRange(CreateWrappedTextFromRawText(formattedTypeParameterText)); } } } var formattedReturnsText = docCommentFormattingService.Format(docComment.ReturnsText); if (!string.IsNullOrWhiteSpace(formattedReturnsText)) { formattedCommentLinesBuilder.Add(string.Empty); formattedCommentLinesBuilder.Add(s_returnsHeader); formattedCommentLinesBuilder.AddRange(CreateWrappedTextFromRawText(formattedReturnsText)); } var formattedValueText = docCommentFormattingService.Format(docComment.ValueText); if (!string.IsNullOrWhiteSpace(formattedValueText)) { formattedCommentLinesBuilder.Add(string.Empty); formattedCommentLinesBuilder.Add(s_valueHeader); formattedCommentLinesBuilder.AddRange(CreateWrappedTextFromRawText(formattedValueText)); } var exceptionTypes = docComment.ExceptionTypes; if (exceptionTypes.Length > 0) { formattedCommentLinesBuilder.Add(string.Empty); formattedCommentLinesBuilder.Add(s_exceptionsHeader); for (var i = 0; i < exceptionTypes.Length; i++) { var rawExceptionTexts = docComment.GetExceptionTexts(exceptionTypes[i]); for (var j = 0; j < rawExceptionTexts.Length; j++) { if (i != 0 || j != 0) { formattedCommentLinesBuilder.Add(string.Empty); } lineBuilder.Clear(); lineBuilder.Append(' ', s_indentSize); lineBuilder.Append(string.Format(s_labelFormat, exceptionTypes[i])); formattedCommentLinesBuilder.Add(lineBuilder.ToString()); var formattedExceptionText = docCommentFormattingService.Format(rawExceptionTexts[j]); if (!string.IsNullOrWhiteSpace(formattedExceptionText)) { formattedCommentLinesBuilder.AddRange(CreateWrappedTextFromRawText(formattedExceptionText)); } } } } var formattedRemarksText = docCommentFormattingService.Format(docComment.RemarksText); if (!string.IsNullOrWhiteSpace(formattedRemarksText)) { formattedCommentLinesBuilder.Add(string.Empty); formattedCommentLinesBuilder.Add(s_remarksHeader); formattedCommentLinesBuilder.AddRange(CreateWrappedTextFromRawText(formattedRemarksText)); } // Eliminate any blank lines at the beginning. while (formattedCommentLinesBuilder.Count > 0 && formattedCommentLinesBuilder[0].Length == 0) { formattedCommentLinesBuilder.RemoveAt(0); } // Eliminate any blank lines at the end. while (formattedCommentLinesBuilder.Count > 0 && formattedCommentLinesBuilder[^ 1].Length == 0) { formattedCommentLinesBuilder.RemoveAt(formattedCommentLinesBuilder.Count - 1); } return(formattedCommentLinesBuilder.ToImmutableAndFree()); }
public string?GetParameterTextOpt(string parameterName) => _underlyingObject?.GetParameterText(parameterName);
private static AutoCompleteItemParameter[] GetSymbolParameters(ReadOnlyArray<IParameterSymbol> paramsArray, DocumentationComment docComment, bool includeThis = false) { var result = paramsArray.Where(p => !includeThis || !p.IsThis) .Select(p => new AutoCompleteItemParameter() { Name = p.Name, Type = GetparameterTypeName(p.Type), Description = docComment != null ? docComment.GetParameterText(p.Name) : null }) .ToArray(); return result.Length == 0 ? null : result; }
private static void ParseMethod(NamedTypeDocumentData parent, IMethodSymbol symbol, string rootName, string id) { if (symbol.AssociatedSymbol != null) { // We don't want to include methods that are associated with // events or properties. return; } if (IsNotVisibleInGeneratedDocumentation(symbol)) { return; } var data = CreateDocumentData <MethodDocumentData>(symbol, rootName, id); DocumentationComment comment = null; try { var commentXml = symbol.GetDocumentationCommentXml(); comment = DocumentationComment.FromXmlFragment(commentXml); } catch { } var parameters = symbol.Parameters; foreach (var parameter in parameters) { var parameterData = CreateDocumentData <MethodParameterData>(parameter, null, string.Empty); parameterData.Summary = comment.GetParameterText(parameterData.Name) ?? string.Empty; parameterData.Type = CreateDocumentData <DocumentDataObject>(parameter.Type, null, string.Empty); data.Parameters.Add(parameterData); } var typeArguments = symbol.TypeArguments; foreach (var typeArgument in typeArguments) { var typeArgumentData = CreateDocumentData <MethodTypeArgumentData>(typeArgument, null, string.Empty); data.TypeArguments.Add(typeArgumentData); } data.GenerateId(); if (symbol.MethodKind == MethodKind.Constructor || symbol.MethodKind == MethodKind.StaticConstructor) { var existingConstructor = parent.GetConstructor(data.Id); if (existingConstructor == null) { data.ReturnType = null; parent.AddConstructor(data); } else { existingConstructor.SupportedProjects.Add(id); } } else { var existingMethod = parent.GetMethod(data.Id); if (existingMethod == null) { data.ReturnType = CreateDocumentData <DocumentDataObject>(symbol.ReturnType, null, string.Empty); parent.AddMethod(data); } else { existingMethod.SupportedProjects.Add(id); } } }