diff --git a/src/Features/CSharpTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.cs b/src/Features/CSharpTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.cs index 0efcc645108c3..4e5df1d9c1577 100644 --- a/src/Features/CSharpTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.cs +++ b/src/Features/CSharpTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.cs @@ -75,6 +75,44 @@ class C """); } + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")] + public async Task TestEndOfKeyword_XmlCloseTagFollowing() + { + await TestInRegularAndScriptAsync( + """ + /// Testing keyword null[||] + class C + { + } + """, + + """ + /// Testing keyword + class C + { + } + """); + } + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")] + public async Task TestEndOfKeyword_XmlOpenTagPreceding() + { + await TestInRegularAndScriptAsync( + """ + /// [||]null is an option. + class C + { + } + """, + + """ + /// is an option. + class C + { + } + """); + } + [Fact] public async Task TestSelectedKeyword() { diff --git a/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs b/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs index c229225cdf1ca..8bc0d022fa78a 100644 --- a/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs @@ -28,7 +28,13 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte var token = root.FindToken(span.Start, findInsideTrivia: true); if (!IsXmlTextToken(token)) - return; + { + token = root.FindTokenFromEnd(span.Start, findInsideTrivia: true); + if (!IsXmlTextToken(token)) + { + return; + } + } if (!token.FullSpan.Contains(span)) return; diff --git a/src/Features/VisualBasicTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.vb b/src/Features/VisualBasicTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.vb index 3e55adbdc9bf6..949483900a25d 100644 --- a/src/Features/VisualBasicTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.vb +++ b/src/Features/VisualBasicTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.vb @@ -68,6 +68,32 @@ class C(Of TKey) end class") End Function + + Public Async Function TestEndOfKeyword_XmlCloseTagFollowing() As Task + Await TestInRegularAndScriptAsync( +" +''' Testing keyword MustInherit[||] +class C(Of TKey) +end class", +" +''' Testing keyword +class C(Of TKey) +end class") + End Function + + + Public Async Function TestEndOfKeyword_XmlOpenTagPreceding() As Task + Await TestInRegularAndScriptAsync( +" +''' [||]MustInherit is a thing +class C(Of TKey) +end class", +" +''' [||] is a thing +class C(Of TKey) +end class") + End Function + Public Async Function TestSelectedKeyword() As Task Await TestInRegularAndScriptAsync(