本文整理汇总了C#中ISymbol.GetDocumentationCommentXml方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.GetDocumentationCommentXml方法的具体用法?C# ISymbol.GetDocumentationCommentXml怎么用?C# ISymbol.GetDocumentationCommentXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbol
的用法示例。
在下文中一共展示了ISymbol.GetDocumentationCommentXml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
/// <summary>
/// Gets the XML documentation element for the specified entity.
/// Returns null if no documentation is found.
/// </summary>
public static XmlDocumentationElement Get(ISymbol entity, bool inheritDocIfMissing = true)
{
if (entity == null)
return null;
var documentationComment = entity.GetDocumentationCommentXml();
if (documentationComment != null) {
return Create(documentationComment, entity);
}
var member = entity as ISymbol;
if (inheritDocIfMissing && member != null) {
var method = member as IMethodSymbol;
if (method != null && method.MethodKind == MethodKind.Constructor) {
// For constructors, the documentation of the base class ctor
// isn't really suitable as constructors are not inherited.
// We'll use the type's documentation instead:
return Get(entity.ContainingType, inheritDocIfMissing);
}
// TODO
// foreach (var baseMember in InheritanceHelper.GetBaseMembers(member, includeImplementedInterfaces: true)) {
// documentationComment = baseMember.Documentation;
// if (documentationComment != null)
// return Create(documentationComment, baseMember);
//}
}
return null;
}
示例2: ParseDocumentation
public SDLanguageItemCollection<SDDocumentation> ParseDocumentation(ISymbol symbol)
{
var documentationXml = symbol.GetDocumentationCommentXml();
var docDic = new SDLanguageItemCollection<SDDocumentation>();
if (!string.IsNullOrEmpty(documentationXml))
{
var xml = XDocument.Parse($"<doc>{documentationXml}</doc>");
foreach (var child in xml.Descendants())
{
var isoCode = child.Name.LocalName.ToLower();
if (CultureInfo.GetCultures(CultureTypes.NeutralCultures).Any(c => c.TwoLetterISOLanguageName == isoCode) || isoCode == "default")
{
// TODO
//_sdRepository.AddDocumentationLanguage(child.Name.ToLower());
var languageDoc = ParseDocumentation(child.Descendants(), true);
if(!docDic.ContainsKey(isoCode)) docDic.Add(isoCode, languageDoc);
}
}
//Es wurde keine Sprachunterstützung in der Doku genutzt.
//Deswegen wird die Doku einfach als "default" geladen.
if (docDic.Count == 0)
{
var defaultDoc = ParseDocumentation(xml.Descendants());
docDic.Add("default", defaultDoc);
}
}
return docDic;
}
示例3: AddXmlDocumentation
private void AddXmlDocumentation(ISymbol symbol, MetadataItems metadata)
{
string documentationCommentXml = symbol.GetDocumentationCommentXml(expandIncludes: true);
XmlDocumentationParser xmlDocumentationParser
= new XmlDocumentationParser(symbol, _commentIdToDocument, _cssClasses, _context.Trace);
IEnumerable<string> otherHtmlElementNames = xmlDocumentationParser.Parse(documentationCommentXml);
// Add standard HTML elements
metadata.AddRange(new []
{
new MetadataItem(CodeAnalysisKeys.CommentXml, documentationCommentXml),
new MetadataItem(CodeAnalysisKeys.Example, (k, m) => xmlDocumentationParser.Process().Example),
new MetadataItem(CodeAnalysisKeys.Remarks, (k, m) => xmlDocumentationParser.Process().Remarks),
new MetadataItem(CodeAnalysisKeys.Summary, (k, m) => xmlDocumentationParser.Process().Summary),
new MetadataItem(CodeAnalysisKeys.Returns, (k, m) => xmlDocumentationParser.Process().Returns),
new MetadataItem(CodeAnalysisKeys.Value, (k, m) => xmlDocumentationParser.Process().Value),
new MetadataItem(CodeAnalysisKeys.Exceptions, (k, m) => xmlDocumentationParser.Process().Exceptions),
new MetadataItem(CodeAnalysisKeys.Permissions, (k, m) => xmlDocumentationParser.Process().Permissions),
new MetadataItem(CodeAnalysisKeys.Params, (k, m) => xmlDocumentationParser.Process().Params),
new MetadataItem(CodeAnalysisKeys.TypeParams, (k, m) => xmlDocumentationParser.Process().TypeParams),
new MetadataItem(CodeAnalysisKeys.SeeAlso, (k, m) => xmlDocumentationParser.Process().SeeAlso)
});
// Add other HTML elements with keys of [ElementName]Html
metadata.AddRange(otherHtmlElementNames.Select(x =>
new MetadataItem(FirstLetterToUpper(x) + "Comments",
(k, m) => xmlDocumentationParser.Process().OtherComments[x])));
}
示例4: MakeAutoCompleteResponse
private AutoCompleteResponse MakeAutoCompleteResponse(AutoCompleteRequest request, ISymbol symbol, bool includeOptionalParams = true)
{
var displayNameGenerator = new SnippetGenerator();
displayNameGenerator.IncludeMarkers = false;
displayNameGenerator.IncludeOptionalParameters = includeOptionalParams;
var response = new AutoCompleteResponse();
response.CompletionText = symbol.Name;
// TODO: Do something more intelligent here
response.DisplayText = displayNameGenerator.Generate(symbol);
if (request.WantDocumentationForEveryCompletionResult)
{
response.Description = DocumentationConverter.ConvertDocumentation(symbol.GetDocumentationCommentXml(), _options.FormattingOptions.NewLine);
}
if (request.WantReturnType)
{
response.ReturnType = ReturnTypeFormatter.GetReturnType(symbol);
}
if (request.WantKind)
{
response.Kind = symbol.GetKind();
}
if (request.WantSnippet)
{
var snippetGenerator = new SnippetGenerator();
snippetGenerator.IncludeMarkers = true;
snippetGenerator.IncludeOptionalParameters = includeOptionalParams;
response.Snippet = snippetGenerator.Generate(symbol);
}
if (request.WantMethodHeader)
{
response.MethodHeader = displayNameGenerator.Generate(symbol);
}
return response;
}
示例5: AddXmlDocumentation
private void AddXmlDocumentation(ISymbol symbol, List<KeyValuePair<string, object>> metadata)
{
string documentationCommentXml = symbol.GetDocumentationCommentXml(expandIncludes: true);
XmlDocumentationParser xmlDocumentationParser
= new XmlDocumentationParser(symbol, _commentIdToDocument, _cssClasses, _context.Trace);
IEnumerable<string> otherHtmlElementNames = xmlDocumentationParser.Parse(documentationCommentXml);
// Add standard HTML elements
metadata.AddRange(new []
{
Metadata.Create(MetadataKeys.DocumentationCommentXml, documentationCommentXml),
Metadata.Create(MetadataKeys.ExampleHtml, (k, m) => xmlDocumentationParser.Process().ExampleHtml),
Metadata.Create(MetadataKeys.RemarksHtml, (k, m) => xmlDocumentationParser.Process().RemarksHtml),
Metadata.Create(MetadataKeys.SummaryHtml, (k, m) => xmlDocumentationParser.Process().SummaryHtml),
Metadata.Create(MetadataKeys.ReturnsHtml, (k, m) => xmlDocumentationParser.Process().ReturnsHtml),
Metadata.Create(MetadataKeys.ValueHtml, (k, m) => xmlDocumentationParser.Process().ValueHtml),
Metadata.Create(MetadataKeys.ExceptionHtml, (k, m) => xmlDocumentationParser.Process().ExceptionHtml),
Metadata.Create(MetadataKeys.PermissionHtml, (k, m) => xmlDocumentationParser.Process().PermissionHtml),
Metadata.Create(MetadataKeys.ParamHtml, (k, m) => xmlDocumentationParser.Process().ParamHtml),
Metadata.Create(MetadataKeys.TypeParamHtml, (k, m) => xmlDocumentationParser.Process().TypeParamHtml),
Metadata.Create(MetadataKeys.SeeAlsoHtml, (k, m) => xmlDocumentationParser.Process().SeeAlsoHtml)
});
// Add other HTML elements with keys of [ElementName]Html
metadata.AddRange(otherHtmlElementNames.Select(x =>
Metadata.Create(FirstLetterToUpper(x) + "Html",
(k, m) => xmlDocumentationParser.Process().OtherHtml[x])));
}
示例6: GetDocumentation
public static string GetDocumentation (ISymbol member)
{
if (member == null)
return null;
var documentation = member.GetDocumentationCommentXml ();
if (string.IsNullOrEmpty (documentation))
documentation = MonoDocDocumentationProvider.GetDocumentation (member);
if (documentation != null)
return CleanEmpty (documentation);
return null;
}
示例7: BuildXmlDoc
private static string BuildXmlDoc(ISymbol factoryMethod)
{
var documentationCommentXml = factoryMethod.GetDocumentationCommentXml();
var relevantLines = documentationCommentXml.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.SkipWhile(line => !line.StartsWith(" "))
.TakeWhile(line => line != "</member>")
.ToArray();
var indent = relevantLines.First().Length - relevantLines.First().TrimStart().Length;
var relevantLinesAsXmlDoc = relevantLines.Select(line => " /// {0}".FormatWith(line.Substring(indent)));
return string.Join("\r\n", relevantLinesAsXmlDoc);
}
示例8: GetSummary
private static string GetSummary(ISymbol symbol)
{
var summary = "";
if (symbol != null)
{
var p = symbol as IPropertySymbol;
if (p != null)
{
summary = p.Type.ToDisplayString() + " " + p.Name;
}
else
{
var m = symbol as IMethodSymbol;
if (m != null)
{
var prefix = m.IsExtensionMethod ? "(extension) " : "";
summary = string.Concat(prefix, m.ReturnType.ToDisplayString(), " ", m.ToDisplayString());
}
else
{
summary = symbol.ToDisplayString();
}
}
summary = summary.Replace("__Typewriter.", string.Empty);
//summary = summary.Replace("__Code.", string.Empty);
var documentation = symbol.GetDocumentationCommentXml();
summary += ParseDocumentation(documentation);
}
return summary;
}
示例9: MakeAutoCompleteResponse
private AutoCompleteResponse MakeAutoCompleteResponse(AutoCompleteRequest request, ISymbol symbol, bool includeOptionalParams = true)
{
var response = new AutoCompleteResponse();
response.CompletionText = symbol.Name;
// TODO: Do something more intelligent here
response.DisplayText = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
if (request.WantDocumentationForEveryCompletionResult)
{
response.Description = symbol.GetDocumentationCommentXml();
}
if (request.WantReturnType)
{
response.ReturnType = ReturnTypeFormatter.GetReturnType(symbol);
}
if (request.WantKind)
{
response.Kind = Enum.GetName(symbol.Kind.GetType(), symbol.Kind);
}
if (request.WantSnippet)
{
var snippetGenerator = new SnippetGenerator();
snippetGenerator.IncludeMarkers = true;
snippetGenerator.IncludeOptionalParameters = includeOptionalParams;
response.Snippet = snippetGenerator.GenerateSnippet(symbol);
}
if (request.WantMethodHeader)
{
var snippetGenerator = new SnippetGenerator();
snippetGenerator.IncludeMarkers = false;
snippetGenerator.IncludeOptionalParameters = includeOptionalParams;
response.MethodHeader = snippetGenerator.GenerateSnippet(symbol);
}
return response;
}