提交 2930a6b2 编写于 作者: K Kevin Pilch 提交者: GitHub

Merge pull request #20882 from zaytsev-victor/Fixed18396

Fixed Make Method Asynchronous refactoring.
......@@ -684,31 +684,33 @@ async Task<int> M3Async()
}
[Theory]
[InlineData(0, "Task")]
[InlineData(1, "void", Skip = "https://github.com/dotnet/roslyn/issues/18396")]
[InlineData(0, "void", "Task")]
[InlineData(1, "void", "void")]
[InlineData(0, "int", "Task<int>")]
[InlineData(0, "Task", "Task")]
[Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
[WorkItem(18307, "https://github.com/dotnet/roslyn/issues/18307")]
public async Task AddAsyncInLocalFunctionKeepsTrivia(int codeFixIndex, string expectedReturn)
public async Task AddAsyncInLocalFunctionKeepsTrivia(int codeFixIndex, string initialReturn, string expectedReturn)
{
await TestInRegularAndScriptAsync(
@"using System.Threading.Tasks;
$@"using System.Threading.Tasks;
class C
{
{{
public void M1()
{
{{
// Leading trivia
/*1*/ void /*2*/ M2/*3*/() /*4*/
{
/*1*/ {initialReturn} /*2*/ M2/*3*/() /*4*/
{{
[|await M3Async();|]
}
}
}}
}}
async Task<int> M3Async()
{
{{
return 1;
}
}",
}}
}}",
$@"using System.Threading.Tasks;
class C
......@@ -733,7 +735,7 @@ async Task<int> M3Async()
[Theory]
[InlineData("", 0, "Task")]
[InlineData("", 1, "void", Skip = "https://github.com/dotnet/roslyn/issues/18396")]
[InlineData("", 1, "void")]
[InlineData("public", 0, "Task")]
[InlineData("public", 1, "void")]
[Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
using System.Composition;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.MakeMethodAsynchronous;
using Microsoft.CodeAnalysis.Shared.Extensions;
......@@ -73,7 +73,7 @@ protected override bool IsAsyncSupportingFunctionSyntax(SyntaxNode node)
bool keepVoid, IMethodSymbol methodSymbol, TypeSyntax returnType,
INamedTypeSymbol taskType, INamedTypeSymbol taskOfTType, INamedTypeSymbol valueTaskOfTType)
{
var newReturnType = returnType;
var newReturnType = returnType.WithAdditionalAnnotations(Formatter.Annotation);
if (methodSymbol.ReturnsVoid)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册