/// <summary> /// handle the case of a constructor, and associated parameters. /// </summary> /// <param name="context">the constructor declaration context.</param> private void HandleMemberDeclaration(SyntaxNodeAnalysisContext context) { if (!context.IsDocumentationModeOn()) return; var declaration = (FieldDeclarationSyntax)context.Node; if (declaration.SyntaxTree.IsGeneratedCode(context.CancellationToken)) return; var variable = declaration .DescendantNodesAndSelf() .OfType<VariableDeclaratorSyntax>() .FirstOrDefault(); if (variable != null && !declaration.HasDocumentation()) { var diagnostic = Diagnostic.Create(this.Descriptor, variable.Identifier.GetLocation()); context.ReportDiagnostic(diagnostic); } }
/// <summary> /// Handle the property declaration, adding a diagnostic for properties /// that are not documented. /// </summary> /// <param name="context">the analysis context.</param> private void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context) { if (!context.IsDocumentationModeOn()) return; var declaration = (PropertyDeclarationSyntax)context.Node; { if (declaration.SyntaxTree.IsGeneratedCode(context.CancellationToken)) return; var hasDocumentation = declaration.HasDocumentation(); if (!hasDocumentation || !this.ValidDocumentation(declaration)) { var diagnosis = !hasDocumentation ? "no documentation" : $"does not start with '{this._commentTextFactory.BuildSummaryTextPrefixForProperty(declaration)}'"; var diagnostic = Diagnostic.Create(this.Descriptor, declaration.Identifier.GetLocation(), diagnosis); context.ReportDiagnostic(diagnostic); } } }
/// <summary> /// Handle the property declaration, adding a diagnostic for properties /// that are not documented. /// </summary> /// <param name="context">the analysis context.</param> private void HandleMethodDeclaration(SyntaxNodeAnalysisContext context) { if (!context.IsDocumentationModeOn()) return; var declaration = (MethodDeclarationSyntax)context.Node; if (declaration.SyntaxTree.IsGeneratedCode(context.CancellationToken)) return; var hasDocumentation = declaration.HasDocumentation(); var hasSummary = declaration.HasSummary(); if (!hasDocumentation || !hasSummary || !this.ValidateParameters(declaration) || !this.ValidateTypeParameters(declaration) || !this.ValidateReturnValue(declaration)) { var description = hasDocumentation ? hasSummary ? this.GetUndocumentedDescription(declaration) : "no summary" : "no documentation"; var diagnostic = Diagnostic.Create(this.Descriptor, declaration.Identifier.GetLocation(), description); context.ReportDiagnostic(diagnostic); } }
/// <summary> /// Handle the property declaration, adding a diagnostic for properties /// that are not documented. /// </summary> /// <param name="context">the analysis context.</param> private void HandleClassOrInterfaceDeclaration(SyntaxNodeAnalysisContext context) { if (!context.IsDocumentationModeOn()) return; this.AnalyseClassDeclaration(context); this.AnalyseInterfaceDeclaration(context); }