public static DeclarationItemDescription Parse(SyntaxNode node) { // wywalili SyntaxKind.DocumentationCommentTrivia var documentationCommentTrivia = node.GetLeadingTrivia() .SingleOrDefault(t => t.Kind() == (SyntaxKind)0 /* SyntaxKind.DocumentationCommentTrivia */); if (documentationCommentTrivia.Kind() == SyntaxKind.None) { return(null); } var result = new DeclarationItemDescription(); { var doc = (StructuredTriviaSyntax)documentationCommentTrivia.GetStructure(); var docChilds = doc.ChildNodes().OfType <XmlElementSyntax>().ToArray(); foreach (var child in docChilds) { var xmlNameSyntax = child.StartTag.Name; var text = xmlNameSyntax.GetText().ToString(); switch (text) { case "summary": result.Summary = GetText(child); break; case "param": { var xmlAttributeSyntax = child.StartTag.Attributes.SingleOrDefault(i => i.Name.ToString() == "name"); if (xmlAttributeSyntax == null) { continue; } var name = xmlAttributeSyntax.Name.ToString(); var p = GetText(child); if (p != "") { result.Parameters[name] = p; } } break; case "returns": result.Returns = GetText(child); break; default: throw new NotSupportedException(); } } } return(result); }
public static DeclarationItemDescription Parse(SyntaxNode node) { // wywalili SyntaxKind.DocumentationCommentTrivia var documentationCommentTrivia = node.GetLeadingTrivia() .SingleOrDefault(t => t.CSharpKind() == (SyntaxKind)0/* SyntaxKind.DocumentationCommentTrivia */); if (documentationCommentTrivia.CSharpKind() == SyntaxKind.None) return null; var result = new DeclarationItemDescription(); { var doc = (StructuredTriviaSyntax)documentationCommentTrivia.GetStructure(); var docChilds = doc.ChildNodes().OfType<XmlElementSyntax>().ToArray(); foreach (var child in docChilds) { var xmlNameSyntax = child.StartTag.Name; var text = xmlNameSyntax.GetText().ToString(); switch (text) { case "summary": result.Summary = GetText(child); break; case "param": { var xmlAttributeSyntax = child.StartTag.Attributes.SingleOrDefault(i => i.Name.ToString() == "name"); if (xmlAttributeSyntax == null) continue; var name = xmlAttributeSyntax.Name.ToString(); var p = GetText(child); if (p != "") result.Parameters[name] = p; } break; case "returns": result.Returns = GetText(child); break; default: throw new NotSupportedException(); } } } return result; }