Skip to content

Commit 951bb50

Browse files
Allow null langword fixer at the end of an XML tag (#76552)
2 parents df75ee9 + 96392cc commit 951bb50

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

src/Features/CSharpTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,44 @@ class C<TKey>
7575
""");
7676
}
7777

78+
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")]
79+
public async Task TestEndOfKeyword_XmlCloseTagFollowing()
80+
{
81+
await TestInRegularAndScriptAsync(
82+
"""
83+
/// <summary>Testing keyword null[||]</summary>
84+
class C<TKey>
85+
{
86+
}
87+
""",
88+
89+
"""
90+
/// <summary>Testing keyword <see langword="null"/></summary>
91+
class C<TKey>
92+
{
93+
}
94+
""");
95+
}
96+
97+
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")]
98+
public async Task TestEndOfKeyword_XmlOpenTagPreceding()
99+
{
100+
await TestInRegularAndScriptAsync(
101+
"""
102+
/// <summary>[||]null is an option.</summary>
103+
class C<TKey>
104+
{
105+
}
106+
""",
107+
108+
"""
109+
/// <summary><see langword="null"/> is an option.</summary>
110+
class C<TKey>
111+
{
112+
}
113+
""");
114+
}
115+
78116
[Fact]
79117
public async Task TestSelectedKeyword()
80118
{

src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
2828
var token = root.FindToken(span.Start, findInsideTrivia: true);
2929

3030
if (!IsXmlTextToken(token))
31-
return;
31+
{
32+
token = root.FindTokenFromEnd(span.Start, findInsideTrivia: true);
33+
if (!IsXmlTextToken(token))
34+
{
35+
return;
36+
}
37+
}
3238

3339
if (!token.FullSpan.Contains(span))
3440
return;

src/Features/VisualBasicTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.vb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,32 @@ class C(Of TKey)
6868
end class")
6969
End Function
7070

71+
<Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")>
72+
Public Async Function TestEndOfKeyword_XmlCloseTagFollowing() As Task
73+
Await TestInRegularAndScriptAsync(
74+
"
75+
''' <summary>Testing keyword MustInherit[||]</summary>
76+
class C(Of TKey)
77+
end class",
78+
"
79+
''' <summary>Testing keyword <see langword=""MustInherit""/></summary>
80+
class C(Of TKey)
81+
end class")
82+
End Function
83+
84+
<Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")>
85+
Public Async Function TestEndOfKeyword_XmlOpenTagPreceding() As Task
86+
Await TestInRegularAndScriptAsync(
87+
"
88+
''' <summary>[||]MustInherit is a thing</summary>
89+
class C(Of TKey)
90+
end class",
91+
"
92+
''' <summary>[||]<see langword=""MustInherit""/> is a thing</summary>
93+
class C(Of TKey)
94+
end class")
95+
End Function
96+
7197
<Fact>
7298
Public Async Function TestSelectedKeyword() As Task
7399
Await TestInRegularAndScriptAsync(

0 commit comments

Comments
 (0)