提交 01915211 编写于 作者: R Ravi Chande

Fix #12818

Unwrap arrays when determining whether to show the builder for lambda
expressions.
上级 ae034955
......@@ -630,6 +630,20 @@ public async Task PartialInterfaceName()
await VerifyBuilderAsync(markup);
}
[WorkItem(12818, "https://github.com/dotnet/roslyn/issues/12818")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UnwrapParamsArray()
{
var markup = @"
using System;
class C {
C(params Action<int>[] a) {
new C($$
}
}";
await VerifyBuilderAsync(markup);
}
private async Task VerifyNotBuilderAsync(string markup)
{
await VerifyWorkerAsync(markup, isBuilder: false);
......
......@@ -159,7 +159,17 @@ private bool IsLambdaExpression(SemanticModel semanticModel, int position, Synta
// open the builder if any overload takes a delegate at our argument position
var inferredTypes = typeInferrer.InferTypes(semanticModel, position, cancellationToken: cancellationToken);
return inferredTypes.Any(type => type.GetDelegateType(semanticModel.Compilation).IsDelegateType());
return inferredTypes.Any(type => GetDelegateType(type, semanticModel.Compilation).IsDelegateType());
}
private ITypeSymbol GetDelegateType(ITypeSymbol type, Compilation compilation)
{
if (type.IsArrayType())
{
type = ((IArrayTypeSymbol)type).ElementType;
}
return type.GetDelegateType(compilation);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册