コード例 #1
0
        public static async Task <Document> RefactorAsync(
            Document document,
            DocumentationCommentTriviaSyntax documentationComment,
            CancellationToken cancellationToken)
        {
            SyntaxList <XmlNodeSyntax> content = documentationComment.Content;

            SourceText sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

            TextLine line = sourceText.Lines[documentationComment.GetFullSpanStartLine(cancellationToken)];

            string indent = StringUtility.GetIndent(line.ToString());

            TextChange textChange;

            if (content.Count == 1 &&
                content[0].IsKind(SyntaxKind.XmlText))
            {
                string text = content[0].ToString().Trim();

                string newText = CreateSummaryElement(indent, text);

                textChange = new TextChange(documentationComment.FullSpan, newText);
            }
            else
            {
                string newText = CreateSummaryElement(indent);

                textChange = new TextChange(new TextSpan(documentationComment.FullSpan.Start, 0), newText);
            }

            return(await document.WithTextChangeAsync(textChange).ConfigureAwait(false));
        }
コード例 #2
0
        public static async Task <Document> RefactorAsync(
            Document document,
            DocumentationCommentTriviaSyntax documentationComment,
            CancellationToken cancellationToken)
        {
            XmlElementSyntax summaryElement = documentationComment.SummaryElement();

            if (summaryElement == null)
            {
                SyntaxList <XmlNodeSyntax> content = documentationComment.Content;

                SourceText text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

                TextLine line = text.Lines[documentationComment.GetFullSpanStartLine(cancellationToken)];

                string indent = StringUtility.GetIndent(line.ToString());

                string newText = CreateSummaryElement(indent);

                var textChange = new TextChange(new TextSpan(documentationComment.FullSpan.Start, 0), newText);

                return(await document.WithTextChangeAsync(textChange).ConfigureAwait(false));
            }

            Debug.Assert(false, "");

            return(document);
        }