提交 1c667195 编写于 作者: R Ravi Chande 提交者: GitHub

Merge pull request #20975 from rchande/fix20937

Show builder for async lambda
......@@ -761,6 +761,42 @@ class C {
await VerifyNotBuilderAsync(markup);
}
[WorkItem(20937, "https://github.com/dotnet/roslyn/issues/20937")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task AsyncLambda()
{
var markup = @"
using System;
using System.Threading.Tasks;
class Program
{
public void B(Func<int, int, Task<int>> f) { }
void A()
{
B(async($$";
await VerifyBuilderAsync(markup);
}
[WorkItem(20937, "https://github.com/dotnet/roslyn/issues/20937")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task AsyncLambdaAfterComma()
{
var markup = @"
using System;
using System.Threading.Tasks;
class Program
{
public void B(Func<int, int, Task<int>> f) { }
void A()
{
B(async(p1, $$";
await VerifyBuilderAsync(markup);
}
private async Task VerifyNotBuilderAsync(string markup)
{
await VerifyWorkerAsync(markup, isBuilder: false);
......
......@@ -168,6 +168,19 @@ private bool IsLambdaExpression(SemanticModel semanticModel, int position, Synta
return false;
}
// async lambda:
// Foo(async($$
// Foo(async(p1, $$
if (token.IsKind(SyntaxKind.OpenParenToken, SyntaxKind.CommaToken) && token.Parent.IsKind(SyntaxKind.ArgumentList)
&& token.Parent.Parent is InvocationExpressionSyntax invocation
&& invocation.Expression is IdentifierNameSyntax identifier)
{
if (identifier.Identifier.IsKindOrHasMatchingText(SyntaxKind.AsyncKeyword))
{
return true;
}
}
// If we're an argument to a function with multiple overloads,
// open the builder if any overload takes a delegate at our argument position
var inferredTypeInfo = typeInferrer.GetTypeInferenceInfo(semanticModel, position, cancellationToken: cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册