-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Langword null fixer breaks when null
is at the end of the strinrg
#76548
Comments
What crash do you get? |
I'm assuming it's a crash or an exception somewhere down the line, because the Suggestions menu loads then abruptly disappears. Whatever the issue happens to be should be trivial to reproduce by running the above repro. |
I think I figured out the issue: when inside an XML tag and the cursor is at the end of the inner text, the located token is actually the closing XML tag. I added the following test to the fixer: [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")]
public async Task TestEndOfKeyword_XmlCloseTagFollowing()
{
await TestInRegularAndScriptAsync(
"""
/// <summary>Testing keyword null[||]</summary>
class C<TKey>
{
}
""",
"""
/// <summary>Testing keyword <see langword="null"/></summary>
class C<TKey>
{
}
""");
} Debugging through showed me that Lines 24 to 31 in 98ea496
Is this something to fix? Could it be fixed somehow? |
Opened PR #76552 for the fix, the regression tests all pass but I'm a little hesitant to make a change I don't 100% understand the consequences of. Hope it's alright, and happy to make further changes! |
Version Used: 17.13.0 Preview 2.1
Steps to Reproduce:
Move cursor to
null
and pressCtrl+.
Expected Behavior:
Fixer suggestion of
Use <see langword="null"/>
Actual Behavior:
Load and crash
Workaround: add
.
afternull
:/// <exception cref="ArgumentNullException">If x is null.</exception>
The text was updated successfully, but these errors were encountered: