未验证 提交 a846c93f 编写于 作者: J Julien Couvreur 提交者: GitHub

Fix completion after null-coalescing assignment (#34348)

上级 8880698e
......@@ -44,6 +44,60 @@ private void Goo()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task TestOnRightOfNullCoalescingAssignment_NullableBool()
{
await TestInRegularAndScriptAsync(
@"class Class
{
void Method(bool? b)
{
b ??= [|Goo|]();
}
}",
@"using System;
class Class
{
void Method(bool? b)
{
b ??= Goo();
}
private bool? Goo()
{
throw new NotImplementedException();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task TestOnRightOfNullCoalescingAssignment_String()
{
await TestInRegularAndScriptAsync(
@"class Class
{
void Method(string s)
{
s ??= [|Goo|]();
}
}",
@"using System;
class Class
{
void Method(string s)
{
s ??= Goo();
}
private string Goo()
{
throw new NotImplementedException();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task TestSimpleInvocationIntoSameType_CodeStyle1()
{
......
......@@ -117,6 +117,14 @@ public async Task TestStartOfExpression()
@"var q = $$"));
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(34324, "https://github.com/dotnet/roslyn/issues/34324")]
public async Task TestAfterNullCoalescingAssignment()
{
await VerifyKeywordAsync(AddInsideMethod(
@"q ??= $$"));
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
public async Task TestInParenthesizedExpression()
{
......
......@@ -2023,6 +2023,7 @@ public static bool IsLabelContext(this SyntaxTree syntaxTree, int position, Canc
// q |= |
// q <<= |
// q >>= |
// q ??= |
if (token.IsKind(SyntaxKind.EqualsToken) ||
token.IsKind(SyntaxKind.MinusEqualsToken) ||
token.IsKind(SyntaxKind.AsteriskEqualsToken) ||
......@@ -2034,7 +2035,8 @@ public static bool IsLabelContext(this SyntaxTree syntaxTree, int position, Canc
token.IsKind(SyntaxKind.BarEqualsToken) ||
token.IsKind(SyntaxKind.PercentEqualsToken) ||
token.IsKind(SyntaxKind.LessThanLessThanEqualsToken) ||
token.IsKind(SyntaxKind.GreaterThanGreaterThanEqualsToken))
token.IsKind(SyntaxKind.GreaterThanGreaterThanEqualsToken) ||
token.IsKind(SyntaxKind.QuestionQuestionEqualsToken))
{
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册