diff --git a/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs b/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs index 0a309b778a2fc88eead96339b7c7ddd2525f4309..b35ae54b6afd5b120a7dea5b72e23ef95eb5cfad 100644 --- a/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs @@ -2,6 +2,7 @@ using System; using System.Composition; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -171,12 +172,14 @@ private TextSpan ExpandSpan(SourceText sourceText, TextSpan span, bool fullyQual var start = span.Start; var end = span.Start; - while (start > 0 && ExpandBackward(sourceText, start, fullyQualifiedName)) + while (start > 0 && + ShouldExpandSpanBackwardOneCharacter(sourceText, start, fullyQualifiedName)) { start--; } - while (end < sourceText.Length && ExpandForward(sourceText, end, fullyQualifiedName)) + while (end < sourceText.Length && + ShouldExpandSpanForwardOneCharacter(sourceText, end, fullyQualifiedName)) { end++; } @@ -184,7 +187,7 @@ private TextSpan ExpandSpan(SourceText sourceText, TextSpan span, bool fullyQual return TextSpan.FromBounds(start, end); } - private bool ExpandForward(SourceText sourceText, int end, bool fullyQualifiedName) + private bool ShouldExpandSpanForwardOneCharacter(SourceText sourceText, int end, bool fullyQualifiedName) { var currentChar = sourceText[end]; @@ -204,9 +207,11 @@ private bool ExpandForward(SourceText sourceText, int end, bool fullyQualifiedNa return false; } - private bool ExpandBackward( + private bool ShouldExpandSpanBackwardOneCharacter( SourceText sourceText, int start, bool fullyQualifiedName) { + Debug.Assert(start > 0); + var previousCharacter = sourceText[start - 1]; if (char.IsLetterOrDigit(previousCharacter)) {