private void AnalyzeMethodSyntaxNode(SyntaxNodeAnalysisContext context) { var node = (MethodDeclarationSyntax)context.Node; if (!IsPublicType(node.Modifiers)) { return; } if (!IsAllParentsValid(node)) { return; } var xmlTrivia = GetXmlTrivia(node); if (xmlTrivia == null) { context.ReportDiagnostic(Diagnostic.Create(NoCommentMethodRule, node.Identifier.GetLocation(), node.Identifier.Text)); return; } if (!(AnalyzerUtil.IsVoidReturnType(node) || HasXmlNameTag(xmlTrivia, returnTag))) { context.ReportDiagnostic(Diagnostic.Create(NoReturnsRule, node.Identifier.GetLocation(), node.Identifier.Text)); } ReportNoParamDiagnostics(context, node, xmlTrivia); ReportNoExceptionDiagnostics(context, node, xmlTrivia); }
private IEnumerable <string> GetReturnComments(BaseMethodDeclarationSyntax declaration) { var methodDeclaration = declaration as MethodDeclarationSyntax; if (methodDeclaration == null) { yield break; } if (!AnalyzerUtil.IsVoidReturnType(methodDeclaration)) { yield return("/// <returns> </returns>"); } }