Ejemplo n.º 1
0
        private void AnalyzeDocumentationComment(SyntaxNodeAnalysisContext context)
        {
            if (GeneratedCodeAnalyzer?.IsGeneratedCode(context) == true)
            {
                return;
            }

            var documentationComment = (DocumentationCommentTriviaSyntax)context.Node;

            XmlElementSyntax summaryElement = FormatSummaryRefactoring.GetSummaryElement(documentationComment);

            if (summaryElement?.StartTag?.IsMissing == false &&
                summaryElement.EndTag?.IsMissing == false &&
                summaryElement.IsSingleLine(includeExteriorTrivia: false, trim: false))
            {
                context.ReportDiagnostic(
                    DiagnosticDescriptors.FormatDocumentationSummaryOnMultipleLines,
                    summaryElement.GetLocation());
            }
        }
        private void AnalyzeDocumentationComment(SyntaxNodeAnalysisContext context)
        {
            if (GeneratedCodeAnalyzer?.IsGeneratedCode(context) == true)
            {
                return;
            }

            var documentationComment = (DocumentationCommentTriviaSyntax)context.Node;

            XmlElementSyntax summaryElement = FormatSummaryRefactoring.GetSummaryElement(documentationComment);

            if (summaryElement != null)
            {
                XmlElementStartTagSyntax startTag = summaryElement?.StartTag;

                if (startTag?.IsMissing == false)
                {
                    XmlElementEndTagSyntax endTag = summaryElement.EndTag;

                    if (endTag?.IsMissing == false &&
                        startTag.GetSpanEndLine() < endTag.GetSpanStartLine())
                    {
                        Match match = FormatSummaryRefactoring.Regex.Match(
                            summaryElement.ToString(),
                            startTag.Span.End - summaryElement.Span.Start,
                            endTag.Span.Start - startTag.Span.End);

                        if (match.Success)
                        {
                            context.ReportDiagnostic(
                                DiagnosticDescriptors.FormatDocumentationSummaryOnSingleLine,
                                summaryElement.GetLocation());
                        }
                    }
                }
            }
        }