Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -841,5 +841,122 @@ async Task<int> M3Async()
}}",
index: codeFixIndex);
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
public async Task MethodWithUsingAwait()
{
await TestInRegularAndScriptAsync(
@"class C
{
void M()
{
[|using await (var x = new object())|]
{
}
}
}",
@"class C
{
async System.Threading.Tasks.Task MAsync()
{
using await (var x = new object())
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
public async Task MethodWithUsingNoAwait()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
void M()
{
[|using (var x = new object())|]
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
public async Task MethodWithForEachAwait()
{
await TestInRegularAndScriptAsync(
@"class C
{
void M()
{
[|foreach await (var n in new int[] { })|]
{
}
}
}",
@"class C
{
async System.Threading.Tasks.Task MAsync()
{
foreach await (var n in new int[] { })
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
public async Task MethodWithForEachNoAwait()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
void M()
{
[|foreach (var n in new int[] { })|]
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
public async Task MethodWithForEachVariableAwait()
{
await TestInRegularAndScriptAsync(
@"class C
{
void M()
{
[|foreach await (var (a, b) in new(int, int)[] { })|]
{
}
}
}",
@"class C
{
async System.Threading.Tasks.Task MAsync()
{
foreach await (var (a, b) in new(int, int)[] { })
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
public async Task MethodWithForEachVariableNoAwait()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
void M()
{
[|foreach (var (a, b) in new(int, int)[] { })|]
{
}
}
}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -646,5 +646,122 @@ class C
}}
}}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodSynchronous)]
public async Task MethodWithUsingAwait()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
async System.Threading.Tasks.Task [|MAsync|]()
{
using await (var x = new object())
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodSynchronous)]
public async Task MethodWithUsingNoAwait()
{
await TestInRegularAndScriptAsync(
@"class C
{
async System.Threading.Tasks.Task [|MAsync|]()
{
using (var x = new object())
{
}
}
}",
@"class C
{
void [|M|]()
{
using (var x = new object())
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodSynchronous)]
public async Task MethodWithForEachAwait()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
async System.Threading.Tasks.Task [|MAsync|]()
{
foreach await (var n in new int[] { })
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodSynchronous)]
public async Task MethodWithForEachNoAwait()
{
await TestInRegularAndScriptAsync(
@"class C
{
async System.Threading.Tasks.Task [|MAsync|]()
{
foreach (var n in new int[] { })
{
}
}
}",
@"class C
{
void [|M|]()
{
foreach (var n in new int[] { })
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodSynchronous)]
public async Task MethodWithForEachVariableAwait()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
async System.Threading.Tasks.Task [|MAsync|]()
{
foreach await (var (a, b) in new(int, int)[] { })
{
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodSynchronous)]
public async Task MethodWithForEachVariableNoAwait()
{
await TestInRegularAndScriptAsync(
@"class C
{
async System.Threading.Tasks.Task [|MAsync|]()
{
foreach (var (a, b) in new(int, int)[] { })
{
}
}
}",
@"class C
{
void [|M|]()
{
foreach (var (a, b) in new(int, int)[] { })
{
}
}
}");
}
}
}