private void HandleDeclaration(SyntaxNodeAnalysisContext context, SyntaxNode node, params Location[] locations) { var documentation = node.GetDocumentationCommentTriviaSyntax(); if (documentation == null) { // missing documentation is reported by SA1600, SA1601, and SA1602 return; } if (documentation.Content.GetFirstXmlElement(XmlCommentHelper.InheritdocXmlTag) != null) { // Ignore nodes with an <inheritdoc/> tag. return; } var valueXmlElement = documentation.Content.GetFirstXmlElement(XmlCommentHelper.ValueXmlTag); this.HandleXmlElement(context, valueXmlElement, locations); }
private static void HandleMemberDeclaration(SyntaxNodeAnalysisContext context, SyntaxNode node, TypeParameterListSyntax typeParameterList) { if (typeParameterList == null) { // The member does not have a type parameter list return; } var documentation = node.GetDocumentationCommentTriviaSyntax(); if (documentation == null) { // Don't report if the documentation is missing return; } if (documentation.Content.GetFirstXmlElement(XmlCommentHelper.InheritdocXmlTag) != null) { // Ignore nodes with an <inheritdoc/> tag. return; } var xmlParameterNames = documentation.Content.GetXmlElements(XmlCommentHelper.TypeParamXmlTag) .Select(XmlCommentHelper.GetFirstAttributeOrDefault<XmlNameAttributeSyntax>) .Where(x => x != null) .ToImmutableArray(); foreach (var parameter in typeParameterList.Parameters) { if (!xmlParameterNames.Any(x => x.Identifier.Identifier.ValueText == parameter.Identifier.ValueText)) { context.ReportDiagnostic(Diagnostic.Create(Descriptor, parameter.Identifier.GetLocation(), parameter.Identifier.ValueText)); } } }
private void HandleDeclaration(SyntaxNodeAnalysisContext context, SyntaxNode node, params Location[] locations) { var documentation = node.GetDocumentationCommentTriviaSyntax(); if (documentation == null) { // missing documentation is reported by SA1600, SA1601, and SA1602 return; } XElement completeDocumentation = null; var relevantXmlElement = documentation.Content.GetFirstXmlElement(XmlCommentHelper.SummaryXmlTag); if (relevantXmlElement == null) { relevantXmlElement = documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag); if (relevantXmlElement != null) { var declaration = context.SemanticModel.GetDeclaredSymbol(node, context.CancellationToken); if (declaration == null) { return; } var rawDocumentation = declaration.GetDocumentationCommentXml(expandIncludes: true, cancellationToken: context.CancellationToken); completeDocumentation = XElement.Parse(rawDocumentation, LoadOptions.None); } } this.HandleXmlElement(context, documentation, relevantXmlElement, completeDocumentation, locations); }