From ef70ab5fa1e7747443e33768f35fcaf6dfeb2876 Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Sat, 26 Sep 2020 20:26:10 +0200 Subject: [PATCH] Add test for IAsyncEnumerable --- .../GenerateMethod/GenerateMethodTests.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs index e4a36ac2757..42d95259485 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs @@ -2621,6 +2621,42 @@ interface ISomeInterface " + IAsyncEnumerable); } + [WorkItem(48064, "https://github.com/dotnet/roslyn/issues/48064")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)] + public async Task TestInvocationWithinAsynchronousForEach_IAsyncEnumerableExists_UseIAsyncEnumerableOfString() + { + await TestInRegularAndScriptAsync( +@"class C +{ + async void M(ISomeInterface _someInterface) + { + await foreach (string item in _someInterface.[|GetItems|]()) + { + } + } +} + +interface ISomeInterface +{ +} +" + IAsyncEnumerable, +@"class C +{ + async void M(ISomeInterface _someInterface) + { + await foreach (string item in _someInterface.GetItems()) + { + } + } +} + +interface ISomeInterface +{ + System.Collections.Generic.IAsyncEnumerable GetItems(); +} +" + IAsyncEnumerable); + } + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)] public async Task TestInvocationOffOfAnotherMethodCall() { -- GitLab