提交 7c5b47ea 编写于 作者: J Joey Robichaud

Fix AddImport to not error on awaited extension methods

上级 cf91608b
...@@ -4989,5 +4989,64 @@ public class Awaiter : INotifyCompletion ...@@ -4989,5 +4989,64 @@ public class Awaiter : INotifyCompletion
} }
}"); }");
} }
[WorkItem(745490, "https://devdiv.visualstudio.com/DevDiv/_workitems/edit/745490")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)]
public async Task TestAddUsingForAwaitableReturningExtensionMethod()
{
await TestAsync(
@"
namespace A
{
using System;
using System.Threading.Tasks;
class C
{
C Instance { get; } => null;
async Task M() => await Instance.[|Foo|]();
}
}
namespace B
{
using System;
using System.Threading.Tasks;
using A;
static class Extensions
{
public static Task Foo(this C instance) => null;
}
}",
@"
namespace A
{
using System;
using System.Threading.Tasks;
using B;
class C
{
C Instance { get; } => null;
async Task M() => await Instance.Foo();
}
}
namespace B
{
using System;
using System.Threading.Tasks;
using A;
static class Extensions
{
public static Task Foo(this C instance) => null;
}
}");
}
} }
} }
...@@ -546,7 +546,7 @@ private ITypeSymbol GetAwaitInfo(SemanticModel semanticModel, ISyntaxFactsServic ...@@ -546,7 +546,7 @@ private ITypeSymbol GetAwaitInfo(SemanticModel semanticModel, ISyntaxFactsServic
{ {
var awaitExpression = FirstAwaitExpressionAncestor(syntaxFactsService, node); var awaitExpression = FirstAwaitExpressionAncestor(syntaxFactsService, node);
var innerExpression = syntaxFactsService.GetExpressionOfAwaitExpression(node); var innerExpression = syntaxFactsService.GetExpressionOfAwaitExpression(awaitExpression);
return semanticModel.GetTypeInfo(innerExpression).Type; return semanticModel.GetTypeInfo(innerExpression).Type;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册