diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
index 968dd83fb7ec0..6237c865efa18 100644
--- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
+++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
@@ -75,7 +75,6 @@
-
@@ -85,8 +84,6 @@
-
-
@@ -193,4 +190,4 @@
-
\ No newline at end of file
+
diff --git a/src/Analyzers/CSharp/CodeFixes/MakeMethodSynchronous/CSharpMakeMethodSynchronousCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeMethodSynchronous/CSharpMakeMethodSynchronousCodeFixProvider.cs
deleted file mode 100644
index de80287f51aa6..0000000000000
--- a/src/Analyzers/CSharp/CodeFixes/MakeMethodSynchronous/CSharpMakeMethodSynchronousCodeFixProvider.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Collections.Immutable;
-using System.Composition;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.RemoveAsyncModifier;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.MakeMethodSynchronous;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace Microsoft.CodeAnalysis.CSharp.MakeMethodSynchronous;
-
-using static CSharpSyntaxTokens;
-
-[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.MakeMethodSynchronous), Shared]
-[ExtensionOrder(After = PredefinedCodeFixProviderNames.AddImport)]
-[method: ImportingConstructor]
-[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
-internal sealed class CSharpMakeMethodSynchronousCodeFixProvider() : AbstractMakeMethodSynchronousCodeFixProvider
-{
- private const string CS1998 = nameof(CS1998); // This async method lacks 'await' operators and will run synchronously.
-
- public override ImmutableArray FixableDiagnosticIds { get; } = [CS1998];
-
- protected override bool IsAsyncSupportingFunctionSyntax(SyntaxNode node)
- => node.IsAsyncSupportingFunctionSyntax();
-
- protected override SyntaxNode RemoveAsyncTokenAndFixReturnType(IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes)
- {
- switch (node)
- {
- case MethodDeclarationSyntax method: return FixMethod(methodSymbol, method, knownTypes);
- case LocalFunctionStatementSyntax localFunction: return FixLocalFunction(methodSymbol, localFunction, knownTypes);
- case AnonymousMethodExpressionSyntax method: return RemoveAsyncModifierHelpers.WithoutAsyncModifier(method);
- case ParenthesizedLambdaExpressionSyntax lambda: return RemoveAsyncModifierHelpers.WithoutAsyncModifier(lambda);
- case SimpleLambdaExpressionSyntax lambda: return RemoveAsyncModifierHelpers.WithoutAsyncModifier(lambda);
- default: return node;
- }
- }
- private static SyntaxNode FixMethod(IMethodSymbol methodSymbol, MethodDeclarationSyntax method, KnownTaskTypes knownTypes)
- {
- var newReturnType = FixMethodReturnType(methodSymbol, method.ReturnType, knownTypes);
- return RemoveAsyncModifierHelpers.WithoutAsyncModifier(method, newReturnType);
- }
-
- private static SyntaxNode FixLocalFunction(IMethodSymbol methodSymbol, LocalFunctionStatementSyntax localFunction, KnownTaskTypes knownTypes)
- {
- var newReturnType = FixMethodReturnType(methodSymbol, localFunction.ReturnType, knownTypes);
- return RemoveAsyncModifierHelpers.WithoutAsyncModifier(localFunction, newReturnType);
- }
-
- private static TypeSyntax FixMethodReturnType(IMethodSymbol methodSymbol, TypeSyntax returnTypeSyntax, KnownTaskTypes knownTypes)
- {
- var newReturnType = returnTypeSyntax;
-
- var returnType = methodSymbol.ReturnType;
- if (returnType.OriginalDefinition.Equals(knownTypes.TaskType))
- {
- // If the return type is Task, then make the new return type "void".
- newReturnType = SyntaxFactory.PredefinedType(VoidKeyword).WithTriviaFrom(returnTypeSyntax);
- }
- else if (returnType.OriginalDefinition.Equals(knownTypes.TaskOfTType))
- {
- // If the return type is Task, then make the new return type "T".
- newReturnType = returnType.GetTypeArguments()[0].GenerateTypeSyntax().WithTriviaFrom(returnTypeSyntax);
- }
- else if (returnType.OriginalDefinition.Equals(knownTypes.IAsyncEnumerableOfTType) &&
- knownTypes.IEnumerableOfTType != null)
- {
- // If the return type is IAsyncEnumerable, then make the new return type IEnumerable.
- newReturnType = knownTypes.IEnumerableOfTType.Construct(methodSymbol.ReturnType.GetTypeArguments()[0]).GenerateTypeSyntax();
- }
- else if (returnType.OriginalDefinition.Equals(knownTypes.IAsyncEnumeratorOfTType) &&
- knownTypes.IEnumeratorOfTType != null)
- {
- // If the return type is IAsyncEnumerator, then make the new return type IEnumerator.
- newReturnType = knownTypes.IEnumeratorOfTType.Construct(methodSymbol.ReturnType.GetTypeArguments()[0]).GenerateTypeSyntax();
- }
-
- return newReturnType;
- }
-}
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/CSharpRemoveAsyncModifierCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/CSharpRemoveAsyncModifierCodeFixProvider.cs
deleted file mode 100644
index 9c5c3e275524b..0000000000000
--- a/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/CSharpRemoveAsyncModifierCodeFixProvider.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Collections.Immutable;
-using System.Composition;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.RemoveAsyncModifier;
-
-namespace Microsoft.CodeAnalysis.CSharp.RemoveAsyncModifier;
-
-using static CSharpSyntaxTokens;
-
-[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.RemoveAsyncModifier), Shared]
-[ExtensionOrder(After = PredefinedCodeFixProviderNames.MakeMethodSynchronous)]
-[method: ImportingConstructor]
-[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
-internal sealed partial class CSharpRemoveAsyncModifierCodeFixProvider() : AbstractRemoveAsyncModifierCodeFixProvider
-{
- private const string CS1998 = nameof(CS1998); // This async method lacks 'await' operators and will run synchronously.
-
- public override ImmutableArray FixableDiagnosticIds { get; } = [CS1998];
-
- protected override bool IsAsyncSupportingFunctionSyntax(SyntaxNode node)
- => node.IsAsyncSupportingFunctionSyntax();
-
- protected override SyntaxNode? ConvertToBlockBody(SyntaxNode node, ExpressionSyntax expressionBody)
- {
- var semicolonToken = SemicolonToken;
- if (expressionBody.TryConvertToStatement(semicolonToken, createReturnStatementForExpression: false, out var statement))
- {
- var block = SyntaxFactory.Block(statement);
- return node switch
- {
- MethodDeclarationSyntax method => method.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default),
- LocalFunctionStatementSyntax localFunction => localFunction.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default),
- AnonymousFunctionExpressionSyntax anonymousFunction => anonymousFunction.WithBody(block).WithExpressionBody(null),
- _ => throw ExceptionUtilities.Unreachable()
- };
- }
-
- return null;
- }
-
- protected override SyntaxNode RemoveAsyncModifier(SyntaxGenerator generator, SyntaxNode methodLikeNode)
- => methodLikeNode switch
- {
- MethodDeclarationSyntax method => RemoveAsyncModifierHelpers.WithoutAsyncModifier(method, method.ReturnType),
- LocalFunctionStatementSyntax localFunction => RemoveAsyncModifierHelpers.WithoutAsyncModifier(localFunction, localFunction.ReturnType),
- AnonymousMethodExpressionSyntax method => AnnotateBlock(generator, RemoveAsyncModifierHelpers.WithoutAsyncModifier(method)),
- ParenthesizedLambdaExpressionSyntax lambda => AnnotateBlock(generator, RemoveAsyncModifierHelpers.WithoutAsyncModifier(lambda)),
- SimpleLambdaExpressionSyntax lambda => AnnotateBlock(generator, RemoveAsyncModifierHelpers.WithoutAsyncModifier(lambda)),
- _ => methodLikeNode,
- };
-
- // Block bodied lambdas and anonymous methods need to be formatted after changing their modifiers, or their indentation is broken
- private static SyntaxNode AnnotateBlock(SyntaxGenerator generator, SyntaxNode node)
- => generator.GetExpression(node) == null
- ? node.WithAdditionalAnnotations(Formatter.Annotation)
- : node;
-}
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/RemoveAsyncModifierHelpers.cs b/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/RemoveAsyncModifierHelpers.cs
deleted file mode 100644
index 1df3eefea5e0c..0000000000000
--- a/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/RemoveAsyncModifierHelpers.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace Microsoft.CodeAnalysis.CSharp.RemoveAsyncModifier;
-
-internal static class RemoveAsyncModifierHelpers
-{
- internal static SyntaxNode WithoutAsyncModifier(MethodDeclarationSyntax method, TypeSyntax returnType)
- {
- var newModifiers = RemoveAsyncModifier(method.Modifiers, ref returnType);
- return method.WithReturnType(returnType).WithModifiers(newModifiers);
- }
-
- internal static SyntaxNode WithoutAsyncModifier(LocalFunctionStatementSyntax localFunction, TypeSyntax returnType)
- {
- var newModifiers = RemoveAsyncModifier(localFunction.Modifiers, ref returnType);
- return localFunction.WithReturnType(returnType).WithModifiers(newModifiers);
- }
-
- internal static SyntaxNode WithoutAsyncModifier(ParenthesizedLambdaExpressionSyntax lambda)
- => lambda.WithAsyncKeyword(default).WithPrependedLeadingTrivia(lambda.AsyncKeyword.LeadingTrivia);
-
- internal static SyntaxNode WithoutAsyncModifier(SimpleLambdaExpressionSyntax lambda)
- => lambda.WithAsyncKeyword(default).WithPrependedLeadingTrivia(lambda.AsyncKeyword.LeadingTrivia);
-
- internal static SyntaxNode WithoutAsyncModifier(AnonymousMethodExpressionSyntax method)
- => method.WithAsyncKeyword(default).WithPrependedLeadingTrivia(method.AsyncKeyword.LeadingTrivia);
-
- private static SyntaxTokenList RemoveAsyncModifier(SyntaxTokenList modifiers, ref TypeSyntax newReturnType)
- {
- var asyncTokenIndex = modifiers.IndexOf(SyntaxKind.AsyncKeyword);
- SyntaxTokenList newModifiers;
- if (asyncTokenIndex == 0)
- {
- // Have to move the trivia on the async token appropriately.
- var asyncLeadingTrivia = modifiers[0].LeadingTrivia;
-
- if (modifiers.Count > 1)
- {
- // Move the trivia to the next modifier;
- newModifiers = modifiers.Replace(
- modifiers[1],
- modifiers[1].WithPrependedLeadingTrivia(asyncLeadingTrivia));
- newModifiers = newModifiers.RemoveAt(0);
- }
- else
- {
- // move it to the return type.
- newModifiers = default;
- newReturnType = newReturnType.WithPrependedLeadingTrivia(asyncLeadingTrivia);
- }
- }
- else
- {
- newModifiers = modifiers.RemoveAt(asyncTokenIndex);
- }
-
- return newModifiers;
- }
-}
diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
index 72ee2cbca32ab..ea632d2d4b2fc 100644
--- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
+++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
@@ -50,8 +50,6 @@
-
-
@@ -66,7 +64,6 @@
-
@@ -205,4 +202,4 @@
-
\ No newline at end of file
+
diff --git a/src/Analyzers/CSharp/Tests/MakeMethodAsynchronous/MakeMethodAsynchronousTests.cs b/src/Analyzers/CSharp/Tests/MakeMethodAsynchronous/MakeMethodAsynchronousTests.cs
deleted file mode 100644
index ac66ce324df27..0000000000000
--- a/src/Analyzers/CSharp/Tests/MakeMethodAsynchronous/MakeMethodAsynchronousTests.cs
+++ /dev/null
@@ -1,1522 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.MakeMethodAsynchronous;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
-using Microsoft.CodeAnalysis.Test.Utilities;
-using Roslyn.Test.Utilities;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.MakeMethodAsynchronous;
-
-[Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
-public sealed partial class MakeMethodAsynchronousTests(ITestOutputHelper logger)
- : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor(logger)
-{
- internal override (DiagnosticAnalyzer?, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
- => (null, new CSharpMakeMethodAsynchronousCodeFixProvider());
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task AwaitInVoidMethodWithModifiers()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public static void Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public static async void Test()
- {
- await Task.Delay(1);
- }
- }
- """, index: 1);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/26312")]
- public async Task AwaitInTaskMainMethodWithModifiers()
- {
- var initial =
- """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public static void Main()
- {
- [|await Task.Delay(1);|]
- }
- }
- """;
- await TestAsync(initial, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public static async Task Main()
- {
- await Task.Delay(1);
- }
- }
- """, new(parseOptions: CSharpParseOptions.Default,
- compilationOptions: new CSharpCompilationOptions(OutputKind.ConsoleApplication)));
-
- // no option offered to keep void
- await TestActionCountAsync(initial, count: 1, new TestParameters(compilationOptions: new CSharpCompilationOptions(OutputKind.ConsoleApplication)));
- }
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/26312")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task AwaitInVoidMainMethodWithModifiers_NotEntryPoint()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public void Main()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public async void Main()
- {
- await Task.Delay(1);
- }
- }
- """, index: 1);
-
- [Fact]
- public Task AwaitInVoidMethodWithModifiers2()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public static void Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public static async Task TestAsync()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task AwaitInTaskMethodNoModifiers()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- Task Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- async Task Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task AwaitInTaskMethodWithModifiers()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public/*Comment*/static/*Comment*/Task/*Comment*/Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- public/*Comment*/static/*Comment*/async Task/*Comment*/Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public Task AwaitInLambdaFunction()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- static void Main(string[] args)
- {
- Action a = () => Console.WriteLine();
- Func b = () => [|await Task.Run(a);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- static void Main(string[] args)
- {
- Action a = () => Console.WriteLine();
- Func b = async () => await Task.Run(a);
- }
- }
- """);
-
- [Fact]
- public Task AwaitInLambdaAction()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- static void Main(string[] args)
- {
- Action a = () => [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- static void Main(string[] args)
- {
- Action a = async () => await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task BadAwaitInNonAsyncMethod()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- class Program
- {
- void Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System.Threading.Tasks;
- class Program
- {
- async void Test()
- {
- await Task.Delay(1);
- }
- }
- """, index: 1);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task BadAwaitInNonAsyncMethod2()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- class Program
- {
- Task Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System.Threading.Tasks;
- class Program
- {
- async Task Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task BadAwaitInNonAsyncMethod3()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- class Program
- {
- Task Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System.Threading.Tasks;
- class Program
- {
- async Task Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public Task BadAwaitInNonAsyncMethod4()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- class Program
- {
- int Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System.Threading.Tasks;
- class Program
- {
- async Task TestAsync()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task BadAwaitInNonAsyncMethod5()
- => TestInRegularAndScriptAsync("""
- class Program
- {
- void Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- class Program
- {
- async void Test()
- {
- await Task.Delay(1);
- }
- }
- """, index: 1);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task BadAwaitInNonAsyncMethod6()
- => TestInRegularAndScriptAsync("""
- class Program
- {
- Task Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- class Program
- {
- async Task Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task BadAwaitInNonAsyncMethod7()
- => TestInRegularAndScriptAsync("""
- class Program
- {
- Task Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- class Program
- {
- async Task Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public Task BadAwaitInNonAsyncMethod8()
- => TestInRegularAndScriptAsync("""
- class Program
- {
- int Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System.Threading.Tasks;
-
- class Program
- {
- async Task TestAsync()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public Task BadAwaitInNonAsyncMethod9()
- => TestInRegularAndScriptAsync("""
- class Program
- {
- Program Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System.Threading.Tasks;
-
- class Program
- {
- async Task TestAsync()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public Task BadAwaitInNonAsyncMethod10()
- => TestInRegularAndScriptAsync("""
- class Program
- {
- asdf Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- class Program
- {
- async System.Threading.Tasks.Task TestAsync()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public async Task BadAwaitInEnumerableMethod()
- {
- var initial =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerable Test()
- {
- yield return 1;
- [|await Task.Delay(1);|]
- }
- }
- """ + IAsyncEnumerable;
-
- var expected =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async IAsyncEnumerable TestAsync()
- {
- yield return 1;
- await Task.Delay(1);
- }
- }
- """ + IAsyncEnumerable;
- await TestInRegularAndScriptAsync(initial, expected);
- }
-
- [Fact]
- public Task BadAwaitInEnumerableMethodMissingIAsyncEnumerableType()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerable Test()
- {
- yield return 1;
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async IAsyncEnumerable TestAsync()
- {
- yield return 1;
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public Task BadAwaitInEnumerableMethodWithReturn()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerable Test()
- {
- [|await Task.Delay(1);|]
- return null;
- }
- }
- """, """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async Task> TestAsync()
- {
- await Task.Delay(1);
- return null;
- }
- }
- """);
-
- [Fact]
- public Task BadAwaitInEnumerableMethodWithYieldInsideLocalFunction()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerable Test()
- {
- [|await Task.Delay(1);|]
- return local();
-
- IEnumerable local()
- {
- yield return 1;
- }
- }
- }
- """, """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async Task> TestAsync()
- {
- await Task.Delay(1);
- return local();
-
- IEnumerable local()
- {
- yield return 1;
- }
- }
- }
- """);
-
- [Fact]
- public Task BadAwaitInEnumeratorMethodWithReturn()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerator Test()
- {
- [|await Task.Delay(1);|]
- return null;
- }
- }
- """, """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async Task> TestAsync()
- {
- await Task.Delay(1);
- return null;
- }
- }
- """);
-
- [Fact]
- public async Task BadAwaitInEnumeratorMethod()
- {
- var initial =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerator Test()
- {
- yield return 1;
- [|await Task.Delay(1);|]
- }
- }
- """ + IAsyncEnumerable;
-
- var expected =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async IAsyncEnumerator TestAsync()
- {
- yield return 1;
- await Task.Delay(1);
- }
- }
- """ + IAsyncEnumerable;
- await TestInRegularAndScriptAsync(initial, expected);
- }
-
- [Fact]
- public async Task BadAwaitInEnumeratorLocalFunction()
- {
- var initial =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- void M()
- {
- IEnumerator Test()
- {
- yield return 1;
- [|await Task.Delay(1);|]
- }
- }
- }
- """ + IAsyncEnumerable;
-
- var expected =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- void M()
- {
- async IAsyncEnumerator TestAsync()
- {
- yield return 1;
- await Task.Delay(1);
- }
- }
- }
- """ + IAsyncEnumerable;
- await TestInRegularAndScriptAsync(initial, expected);
- }
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public async Task BadAwaitInIAsyncEnumerableMethod()
- {
- var initial =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IAsyncEnumerable Test()
- {
- yield return 1;
- [|await Task.Delay(1);|]
- }
- }
- """ + IAsyncEnumerable;
-
- var expected =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async IAsyncEnumerable Test()
- {
- yield return 1;
- await Task.Delay(1);
- }
- }
- """ + IAsyncEnumerable;
- await TestInRegularAndScriptAsync(initial, expected);
- }
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public async Task BadAwaitInIAsyncEnumeratorMethod()
- {
- var initial =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IAsyncEnumerator Test()
- {
- yield return 1;
- [|await Task.Delay(1);|]
- }
- }
- """ + IAsyncEnumerable;
-
- var expected =
- """
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async IAsyncEnumerator Test()
- {
- yield return 1;
- await Task.Delay(1);
- }
- }
- """ + IAsyncEnumerable;
- await TestInRegularAndScriptAsync(initial, expected);
- }
-
- [Fact]
- public Task AwaitInMember()
- => TestMissingInRegularAndScriptAsync("""
- using System.Threading.Tasks;
-
- class Program
- {
- var x = [|await Task.Delay(3)|];
- }
- """);
-
- [Fact]
- public Task AddAsyncInDelegate()
- => TestInRegularAndScriptAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- private async void method()
- {
- string content = await Task.Run(delegate () {
- [|await Task.Delay(1000)|];
- return "Test";
- });
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- private async void method()
- {
- string content = await Task.Run(async delegate () {
- await Task.Delay(1000);
- return "Test";
- });
- }
- }
- """);
-
- [Fact]
- public Task AddAsyncInDelegate2()
- => TestInRegularAndScriptAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- private void method()
- {
- string content = await Task.Run(delegate () {
- [|await Task.Delay(1000)|];
- return "Test";
- });
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- private void method()
- {
- string content = await Task.Run(async delegate () {
- await Task.Delay(1000);
- return "Test";
- });
- }
- }
- """);
-
- [Fact]
- public Task AddAsyncInDelegate3()
- => TestInRegularAndScriptAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- private void method()
- {
- string content = await Task.Run(delegate () {
- [|await Task.Delay(1000)|];
- return "Test";
- });
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class Program
- {
- private void method()
- {
- string content = await Task.Run(async delegate () {
- await Task.Delay(1000);
- return "Test";
- });
- }
- }
- """);
-
- [Fact, WorkItem(6477, @"https://github.com/dotnet/roslyn/issues/6477")]
- public Task NullNodeCrash()
- => TestMissingInRegularAndScriptAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- static async void Main()
- {
- try
- {
- [|await|] await Task.Delay(100);
- }
- finally
- {
- }
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/17470")]
- public Task AwaitInValueTaskMethod()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- namespace System.Threading.Tasks {
- struct ValueTask
- {
- }
- }
-
- class Program
- {
- ValueTask Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- namespace System.Threading.Tasks {
- struct ValueTask
- {
- }
- }
-
- class Program
- {
- async ValueTask Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact]
- public Task AwaitInValueTaskWithoutGenericMethod()
- => TestInRegularAndScriptAsync("""
- using System;
- using System.Threading.Tasks;
-
- namespace System.Threading.Tasks {
- struct ValueTask
- {
- }
- }
-
- class Program
- {
- ValueTask Test()
- {
- [|await Task.Delay(1);|]
- }
- }
- """, """
- using System;
- using System.Threading.Tasks;
-
- namespace System.Threading.Tasks {
- struct ValueTask
- {
- }
- }
-
- class Program
- {
- async ValueTask Test()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/14133")]
- public Task AddAsyncInLocalFunction()
- => TestInRegularAndScriptAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- void M2()
- {
- [|await M3Async();|]
- }
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- async Task M2Async()
- {
- await M3Async();
- }
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/14133")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task AddAsyncInLocalFunctionKeepVoidReturn()
- => TestInRegularAndScriptAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- void M2()
- {
- [|await M3Async();|]
- }
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- async void M2()
- {
- await M3Async();
- }
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """,
- index: 1);
-
- [Theory]
- [InlineData(0, "void", "Task", "M2Async")]
- [InlineData(1, "void", "void", "M2")]
- [InlineData(0, "int", "Task", "M2Async")]
- [InlineData(0, "Task", "Task", "M2")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/18307")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task AddAsyncInLocalFunctionKeepsTrivia(int codeFixIndex, string initialReturn, string expectedReturn, string expectedName)
- => TestInRegularAndScriptAsync(
- $$"""
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- // Leading trivia
- /*1*/ {{initialReturn}} /*2*/ M2/*3*/() /*4*/
- {
- [|await M3Async();|]
- }
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """,
- $$"""
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- // Leading trivia
- /*1*/ async {{expectedReturn}} /*2*/ {{expectedName}}/*3*/() /*4*/
- {
- await M3Async();
- }
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """,
- index: codeFixIndex);
-
- [Theory]
- [InlineData("", 0, "Task", "M2Async")]
- [InlineData("", 1, "void", "M2")]
- [InlineData("public", 0, "Task", "M2Async")]
- [InlineData("public", 1, "void", "M2")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/18307")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/33082")]
- public Task AddAsyncKeepsTrivia(string modifiers, int codeFixIndex, string expectedReturn, string expectedName)
- => TestInRegularAndScriptAsync(
- $$"""
- using System.Threading.Tasks;
-
- class C
- {
- // Leading trivia
- {{modifiers}}/*1*/ void /*2*/ M2/*3*/() /*4*/
- {
- [|await M3Async();|]
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """,
- $$"""
- using System.Threading.Tasks;
-
- class C
- {
- // Leading trivia
- {{modifiers}}/*1*/ async {{expectedReturn}} /*2*/ {{expectedName}}/*3*/() /*4*/
- {
- await M3Async();
- }
-
- async Task M3Async()
- {
- return 1;
- }
- }
- """,
- index: codeFixIndex);
-
- [Fact]
- public Task MethodWithAwaitUsing()
- => TestInRegularAndScriptAsync(
- """
- class C
- {
- void M()
- {
- [|await using (var x = new object())|]
- {
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task MAsync()
- {
- await using (var x = new object())
- {
- }
- }
- }
- """);
-
- [Fact]
- public Task MethodWithRegularUsing()
- => TestMissingInRegularAndScriptAsync(
- """
- class C
- {
- void M()
- {
- [|using (var x = new object())|]
- {
- }
- }
- }
- """);
-
- [Fact]
- public Task MethodWithAwaitForEach()
- => TestInRegularAndScriptAsync(
- """
- class C
- {
- void M()
- {
- [|await foreach (var n in new int[] { })|]
- {
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task MAsync()
- {
- await foreach (var n in new int[] { })
- {
- }
- }
- }
- """);
-
- [Fact]
- public Task MethodWithRegularForEach()
- => TestMissingInRegularAndScriptAsync(
- """
- class C
- {
- void M()
- {
- [|foreach (var n in new int[] { })|]
- {
- }
- }
- }
- """);
-
- [Fact]
- public Task MethodWithAwaitForEachVariable()
- => TestInRegularAndScriptAsync(
- """
- class C
- {
- void M()
- {
- [|await foreach (var (a, b) in new(int, int)[] { })|]
- {
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task MAsync()
- {
- await foreach (var (a, b) in new(int, int)[] { })
- {
- }
- }
- }
- """);
-
- [Fact]
- public Task MethodWithRegularForEachVariable()
- => TestMissingInRegularAndScriptAsync(
- """
- class C
- {
- void M()
- {
- [|foreach (var (a, b) in new(int, int)[] { })|]
- {
- }
- }
- }
- """);
-
- [Fact]
- public Task MethodWithNullableReturn()
- => TestInRegularAndScriptAsync(
- """
- #nullable enable
- using System.Threading.Tasks;
- class C
- {
- string? M()
- {
- [|await Task.Delay(1);|]
- return null;
- }
- }
- """,
- """
- #nullable enable
- using System.Threading.Tasks;
- class C
- {
- async Task MAsync()
- {
- await Task.Delay(1);
- return null;
- }
- }
- """);
-
- [Fact]
- public async Task EnumerableMethodWithNullableType()
- {
- var initial =
- """
- #nullable enable
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerable Test()
- {
- yield return string.Empty;
- [|await Task.Delay(1);|]
- }
- }
- """ + IAsyncEnumerable;
-
- var expected =
- """
- #nullable enable
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async IAsyncEnumerable TestAsync()
- {
- yield return string.Empty;
- await Task.Delay(1);
- }
- }
- """ + IAsyncEnumerable;
- await TestInRegularAndScriptAsync(initial, expected);
- }
-
- [Fact]
- public async Task EnumeratorMethodWithNullableType()
- {
- var initial =
- """
- #nullable enable
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- IEnumerator Test()
- {
- yield return string.Empty;
- [|await Task.Delay(1);|]
- }
- }
- """ + IAsyncEnumerable;
-
- var expected =
- """
- #nullable enable
- using System.Threading.Tasks;
- using System.Collections.Generic;
- class Program
- {
- async IAsyncEnumerator TestAsync()
- {
- yield return string.Empty;
- await Task.Delay(1);
- }
- }
- """ + IAsyncEnumerable;
- await TestInRegularAndScriptAsync(initial, expected);
- }
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/25446")]
- public Task TestOnAwaitParsedAsType()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
-
- class C
- {
- void M()
- {
- Task task = null;
- [|await|] task;
- }
- }
- """, """
- using System.Threading.Tasks;
-
- class C
- {
- async Task MAsync()
- {
- Task task = null;
- await task;
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/63404")]
- public Task PartialMethod1()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
-
- public partial class C
- {
- partial void M();
- }
-
- public partial class C
- {
- partial void M()
- {
- [|await|] Task.Delay(1);
- }
- }
- """, """
- using System.Threading.Tasks;
-
- public partial class C
- {
- partial Task MAsync();
- }
-
- public partial class C
- {
- async partial Task MAsync()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/63404")]
- public Task PartialMethod2()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
-
- public partial class C
- {
- public partial void M();
- }
-
- public partial class C
- {
- public partial void M()
- {
- [|await|] Task.Delay(1);
- }
- }
- """, """
- using System.Threading.Tasks;
-
- public partial class C
- {
- public partial Task MAsync();
- }
-
- public partial class C
- {
- public async partial Task MAsync()
- {
- await Task.Delay(1);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/63404")]
- public Task PartialMethod3()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
-
- public partial class C
- {
- partial void M();
- }
-
- public partial class C
- {
- partial void M()
- {
- [|await|] Task.Delay(1);
- }
- }
- """, """
- using System.Threading.Tasks;
-
- public partial class C
- {
- partial void M();
- }
-
- public partial class C
- {
- async partial void M()
- {
- await Task.Delay(1);
- }
- }
- """, index: 1);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/63404")]
- public Task PartialMethod4()
- => TestInRegularAndScriptAsync("""
- using System.Threading.Tasks;
-
- public partial class C
- {
- public partial void M();
- }
-
- public partial class C
- {
- public partial void M()
- {
- [|await|] Task.Delay(1);
- }
- }
- """, """
- using System.Threading.Tasks;
-
- public partial class C
- {
- public partial void M();
- }
-
- public partial class C
- {
- public async partial void M()
- {
- await Task.Delay(1);
- }
- }
- """, index: 1);
-}
diff --git a/src/Analyzers/CSharp/Tests/MakeMethodSynchronous/MakeMethodSynchronousTests.cs b/src/Analyzers/CSharp/Tests/MakeMethodSynchronous/MakeMethodSynchronousTests.cs
deleted file mode 100644
index 2ab8c1bf6b9fa..0000000000000
--- a/src/Analyzers/CSharp/Tests/MakeMethodSynchronous/MakeMethodSynchronousTests.cs
+++ /dev/null
@@ -1,1045 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.MakeMethodSynchronous;
-using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
-using Microsoft.CodeAnalysis.Test.Utilities;
-using Microsoft.CodeAnalysis.Testing;
-using Roslyn.Test.Utilities;
-using Xunit;
-
-namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.MakeMethodSynchronous;
-
-using VerifyCS = CSharpCodeFixVerifier<
- EmptyDiagnosticAnalyzer,
- CSharpMakeMethodSynchronousCodeFixProvider>;
-
-[Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodSynchronous)]
-public sealed class MakeMethodSynchronousTests
-{
- [Fact]
- public Task TestTaskReturnType()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- }
- }
- """);
-
- [Fact]
- public Task TestTaskOfTReturnType()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- return 1;
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- int {|#0:Goo|}()
- {
- return 1;
- }
- }
- """);
-
- [Fact]
- public Task TestSecondModifier()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- public async Task {|CS1998:Goo|}()
- {
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void Goo()
- {
- }
- }
- """);
-
- [Fact]
- public Task TestFirstModifier()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async public Task {|CS1998:Goo|}()
- {
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void Goo()
- {
- }
- }
- """);
-
- [Fact]
- public Task TestTrailingTrivia()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async // comment
- Task {|CS1998:Goo|}()
- {
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- }
- }
- """);
-
- [Fact]
- public Task TestRenameMethod()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:GooAsync|}()
- {
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- }
- }
- """);
-
- [Fact]
- public Task TestRenameMethod1()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:GooAsync|}()
- {
- }
-
- void Bar()
- {
- GooAsync();
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- }
-
- void Bar()
- {
- Goo();
- }
- }
- """);
-
- [Fact]
- public async Task TestParenthesizedLambda()
- {
- var expected =
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func f =
- () {|#0:=>|} { };
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func f =
- async () {|CS1998:=>|} { };
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(10,16): error CS1643: Not all code paths return a value in lambda expression of type 'Func'
- DiagnosticResult.CompilerError("CS1643").WithLocation(0),
- },
- },
- }.RunAsync();
- }
-
- [Fact]
- public async Task TestSimpleLambda()
- {
- var expected =
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func f =
- a {|#0:=>|} { };
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func f =
- async a {|CS1998:=>|} { };
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(10,15): error CS1643: Not all code paths return a value in lambda expression of type 'Func'
- DiagnosticResult.CompilerError("CS1643").WithLocation(0),
- },
- },
- }.RunAsync();
- }
-
- [Fact]
- public async Task TestLambdaWithExpressionBody()
- {
- var expected =
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func> f =
- a => {|#0:1|};
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func> f =
- async a {|CS1998:=>|} 1;
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(10,18): error CS0029: Cannot implicitly convert type 'int' to 'System.Threading.Tasks.Task'
- DiagnosticResult.CompilerError("CS0029").WithLocation(0).WithArguments("int", "System.Threading.Tasks.Task"),
- // /0/Test0.cs(10,18): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
- DiagnosticResult.CompilerError("CS1662").WithLocation(0),
- },
- },
- }.RunAsync();
- }
-
- [Fact]
- public async Task TestAnonymousMethod()
- {
- var expected =
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func f =
- {|#0:delegate|} { };
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void Goo()
- {
- Func f =
- async {|CS1998:delegate|} { };
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(10,13): error CS1643: Not all code paths return a value in anonymous method of type 'Func'
- DiagnosticResult.CompilerError("CS1643").WithLocation(0),
- },
- },
- }.RunAsync();
- }
-
- [Fact]
- public Task TestFixAll()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- async Task {|CS1998:GooAsync|}()
- {
- BarAsync();
- }
-
- async Task {|#0:{|CS1998:BarAsync|}|}()
- {
- GooAsync();
- return 1;
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- void Goo()
- {
- Bar();
- }
-
- int {|#0:Bar|}()
- {
- Goo();
- return 1;
- }
- }
- """);
-
- [Fact]
- [WorkItem("https://github.com/dotnet/roslyn/issues/13961")]
- public async Task TestRemoveAwaitFromCaller1()
- {
- var expected =
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- void Goo()
- {
- }
-
- async void {|CS1998:BarAsync|}()
- {
- Goo();
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System.Threading.Tasks;
-
- public class Class1
- {
- async Task {|CS1998:GooAsync|}()
- {
- }
-
- async void BarAsync()
- {
- await GooAsync();
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- MarkupHandling = MarkupMode.Allow,
- },
- CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- }.RunAsync();
- }
-
- [Fact]
- [WorkItem("https://github.com/dotnet/roslyn/issues/13961")]
- public async Task TestRemoveAwaitFromCaller2()
- {
- var expected =
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- void Goo()
- {
- }
-
- async void {|CS1998:BarAsync|}()
- {
- Goo();
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System.Threading.Tasks;
-
- public class Class1
- {
- async Task {|CS1998:GooAsync|}()
- {
- }
-
- async void BarAsync()
- {
- await GooAsync().ConfigureAwait(false);
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- MarkupHandling = MarkupMode.Allow,
- },
- CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- }.RunAsync();
- }
-
- [Fact]
- [WorkItem("https://github.com/dotnet/roslyn/issues/13961")]
- public async Task TestRemoveAwaitFromCaller3()
- {
- var expected =
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- void Goo()
- {
- }
-
- async void {|CS1998:BarAsync|}()
- {
- this.Goo();
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System.Threading.Tasks;
-
- public class Class1
- {
- async Task {|CS1998:GooAsync|}()
- {
- }
-
- async void BarAsync()
- {
- await this.GooAsync();
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- MarkupHandling = MarkupMode.Allow,
- },
- CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- }.RunAsync();
- }
-
- [Fact]
- [WorkItem("https://github.com/dotnet/roslyn/issues/13961")]
- public async Task TestRemoveAwaitFromCaller4()
- {
- var expected =
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- void Goo()
- {
- }
-
- async void {|CS1998:BarAsync|}()
- {
- this.Goo();
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System.Threading.Tasks;
-
- public class Class1
- {
- async Task {|CS1998:GooAsync|}()
- {
- }
-
- async void BarAsync()
- {
- await this.GooAsync().ConfigureAwait(false);
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- MarkupHandling = MarkupMode.Allow,
- },
- CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- }.RunAsync();
- }
-
- [Fact]
- [WorkItem("https://github.com/dotnet/roslyn/issues/13961")]
- public async Task TestRemoveAwaitFromCallerNested1()
- {
- var expected =
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- int Goo(int i)
- {
- return 1;
- }
-
- async void {|CS1998:BarAsync|}()
- {
- this.Goo(this.Goo(0));
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System.Threading.Tasks;
-
- public class Class1
- {
- async Task {|CS1998:GooAsync|}(int i)
- {
- return 1;
- }
-
- async void BarAsync()
- {
- await this.GooAsync(await this.GooAsync(0));
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- MarkupHandling = MarkupMode.Allow,
- },
- CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- }.RunAsync();
- }
-
- [Fact]
- [WorkItem("https://github.com/dotnet/roslyn/issues/13961")]
- public async Task TestRemoveAwaitFromCallerNested()
- {
- var expected =
- """
- using System.Threading.Tasks;
-
- public class Class1
- {
- int Goo(int i)
- {
- return 1;
- }
-
- async void {|CS1998:BarAsync|}()
- {
- this.Goo(this.Goo(0));
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- TestCode = """
- using System.Threading.Tasks;
-
- public class Class1
- {
- async Task {|CS1998:GooAsync|}(int i)
- {
- return 1;
- }
-
- async void BarAsync()
- {
- await this.GooAsync(await this.GooAsync(0).ConfigureAwait(false)).ConfigureAwait(false);
- }
- }
- """,
- FixedState =
- {
- Sources = { expected },
- MarkupHandling = MarkupMode.Allow,
- },
- CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- }.RunAsync();
- }
-
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/14133")]
- public Task RemoveAsyncInLocalFunction()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- async Task {|CS1998:M2Async|}()
- {
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- void M2()
- {
- }
- }
- }
- """);
-
- [Theory]
- [InlineData("Task", "C")]
- [InlineData("Task", "int")]
- [InlineData("Task", "void")]
- [InlineData("void", "void")]
- [Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/18307")]
- public Task RemoveAsyncInLocalFunctionKeepsTrivia(string asyncReturn, string expectedReturn)
- => VerifyCS.VerifyCodeFixAsync(
- $$"""
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- // Leading trivia
- /*1*/ async {{asyncReturn}} /*2*/ {|CS1998:M2Async|}/*3*/() /*4*/
- {
- throw new NotImplementedException();
- }
- }
- }
- """,
- $$"""
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- // Leading trivia
- /*1*/
- {{expectedReturn}} /*2*/ M2/*3*/() /*4*/
- {
- throw new NotImplementedException();
- }
- }
- }
- """);
-
- [Theory]
- [InlineData("", "Task", "\r\n C")]
- [InlineData("", "Task", "\r\n int")]
- [InlineData("", "Task", "\r\n void")]
- [InlineData("", "void", "\r\n void")]
- [InlineData("public", "Task", " C")]
- [InlineData("public", "Task", " int")]
- [InlineData("public", "Task", " void")]
- [InlineData("public", "void", " void")]
- [Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/18307")]
- public Task RemoveAsyncKeepsTrivia(string modifiers, string asyncReturn, string expectedReturn)
- => VerifyCS.VerifyCodeFixAsync(
- $$"""
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- // Leading trivia
- {{modifiers}}/*1*/ async {{asyncReturn}} /*2*/ {|CS1998:M2Async|}/*3*/() /*4*/
- {
- throw new NotImplementedException();
- }
- }
- """,
- $$"""
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- // Leading trivia
- {{modifiers}}/*1*/{{expectedReturn}} /*2*/ M2/*3*/() /*4*/
- {
- throw new NotImplementedException();
- }
- }
- """);
-
- [Fact]
- public async Task MethodWithUsingAwait()
- {
- var source =
- """
- class C
- {
- async System.Threading.Tasks.Task MAsync()
- {
- await using ({|#0:var x = new object()|})
- {
- }
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = source,
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(5,22): error CS8410: 'object': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method.
- DiagnosticResult.CompilerError("CS8410").WithLocation(0).WithArguments("object"),
- },
- FixedCode = source,
- }.RunAsync();
- }
-
- [Fact]
- public Task MethodWithUsingNoAwait()
- => VerifyCS.VerifyCodeFixAsync(
- """
- class C
- {
- async System.Threading.Tasks.Task {|CS1998:MAsync|}()
- {
- using ({|#0:var x = new object()|})
- {
- }
- }
- }
- """,
- // /0/Test0.cs(5,16): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'.
- DiagnosticResult.CompilerError("CS1674").WithLocation(0).WithArguments("object"),
- """
- class C
- {
- void M()
- {
- using ({|#0:var x = new object()|})
- {
- }
- }
- }
- """);
-
- [Fact]
- public async Task MethodWithAwaitForEach()
- {
- var source =
- """
- class C
- {
- async System.Threading.Tasks.Task MAsync()
- {
- await foreach (var n in {|#0:new int[] { }|})
- {
- }
- }
- }
- """;
-
- await VerifyCS.VerifyCodeFixAsync(
- source,
- // /0/Test0.cs(5,33): error CS1061: 'bool' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)
- DiagnosticResult.CompilerError("CS1061").WithLocation(0).WithArguments("bool", "GetAwaiter"),
- source);
- }
-
- [Fact]
- public Task MethodWithForEachNoAwait()
- => VerifyCS.VerifyCodeFixAsync(
- """
- class C
- {
- async System.Threading.Tasks.Task {|CS1998:MAsync|}()
- {
- foreach (var n in new int[] { })
- {
- }
- }
- }
- """,
- """
- class C
- {
- void M()
- {
- foreach (var n in new int[] { })
- {
- }
- }
- }
- """);
-
- [Fact]
- public async Task MethodWithForEachVariableAwait()
- {
- var source =
- """
- class C
- {
- async System.Threading.Tasks.Task MAsync()
- {
- await foreach (var (a, b) in {|#0:new(int, int)[] { }|})
- {
- }
- }
- }
- """;
-
- await VerifyCS.VerifyCodeFixAsync(
- source,
- // /0/Test0.cs(5,38): error CS1061: 'bool' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)
- DiagnosticResult.CompilerError("CS1061").WithLocation(0).WithArguments("bool", "GetAwaiter"),
- source);
- }
-
- [Fact]
- public Task MethodWithForEachVariableNoAwait()
- => VerifyCS.VerifyCodeFixAsync(
- """
- class C
- {
- async System.Threading.Tasks.Task {|CS1998:MAsync|}()
- {
- foreach (var (a, b) in new(int, int)[] { })
- {
- }
- }
- }
- """,
- """
- class C
- {
- void M()
- {
- foreach (var (a, b) in new (int, int)[] { })
- {
- }
- }
- }
- """);
-
- [Fact]
- public Task TestIAsyncEnumerableReturnType()
- => new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = """
- using System.Threading.Tasks;
- using System.Collections.Generic;
-
- class C
- {
- async IAsyncEnumerable {|CS1998:MAsync|}()
- {
- yield return 1;
- }
- }
- """,
- FixedCode = """
- using System.Threading.Tasks;
- using System.Collections.Generic;
-
- class C
- {
- IEnumerable M()
- {
- yield return 1;
- }
- }
- """,
- }.RunAsync();
-
- [Fact]
- public Task TestIAsyncEnumeratorReturnTypeOnLocalFunction()
- => new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = """
- using System.Threading.Tasks;
- using System.Collections.Generic;
-
- class C
- {
- void Method()
- {
- async IAsyncEnumerator {|CS1998:MAsync|}()
- {
- yield return 1;
- }
- }
- }
- """,
- FixedCode = """
- using System.Threading.Tasks;
- using System.Collections.Generic;
-
- class C
- {
- void Method()
- {
- IEnumerator M()
- {
- yield return 1;
- }
- }
- }
- """,
- }.RunAsync();
-}
diff --git a/src/Analyzers/CSharp/Tests/RemoveAsyncModifier/RemoveAsyncModifierTests.cs b/src/Analyzers/CSharp/Tests/RemoveAsyncModifier/RemoveAsyncModifierTests.cs
deleted file mode 100644
index 59c4359e89360..0000000000000
--- a/src/Analyzers/CSharp/Tests/RemoveAsyncModifier/RemoveAsyncModifierTests.cs
+++ /dev/null
@@ -1,1224 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.RemoveAsyncModifier;
-using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
-using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
-using Microsoft.CodeAnalysis.Test.Utilities;
-using Microsoft.CodeAnalysis.Testing;
-using Roslyn.Test.Utilities;
-using Xunit;
-
-namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.RemoveAsyncModifier;
-
-using VerifyCS = CSharpCodeFixVerifier<
- EmptyDiagnosticAnalyzer,
- CSharpRemoveAsyncModifierCodeFixProvider>;
-
-[Trait(Traits.Feature, Traits.Features.CodeActionsRemoveAsyncModifier)]
-public sealed class RemoveAsyncModifierTests
-{
- [Fact]
- public Task Method_Task_MultipleAndNested()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- if (DateTime.Now.Ticks > 0)
- {
- return;
- }
- }
-
- async Task {|CS1998:Foo|}()
- {
- Console.WriteLine(1);
- }
-
- async Task {|CS1998:Bar|}()
- {
- async Task {|CS1998:Baz|}()
- {
- Func> g = async () {|CS1998:=>|} 5;
- }
- }
-
- async Task {|CS1998:Tur|}()
- {
- async Task {|CS1998:Duck|}()
- {
- async Task {|CS1998:En|}()
- {
- return "Developers!";
- }
-
- return "Developers! Developers!";
- }
-
- return "Developers! Developers! Developers!";
- }
-
- async Task {|CS1998:Nurk|}()
- {
- Func> f = async () {|CS1998:=>|} 4;
-
- if (DateTime.Now.Ticks > f().Result)
- {
- }
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- if (DateTime.Now.Ticks > 0)
- {
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- }
-
- Task Foo()
- {
- Console.WriteLine(1);
- return Task.CompletedTask;
- }
-
- Task Bar()
- {
- Task Baz()
- {
- Func> g = () => Task.FromResult(5);
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- }
-
- Task Tur()
- {
- Task Duck()
- {
- Task En()
- {
- return Task.FromResult("Developers!");
- }
-
- return Task.FromResult("Developers! Developers!");
- }
-
- return Task.FromResult("Developers! Developers! Developers!");
- }
-
- Task Nurk()
- {
- Func> f = () => Task.FromResult(4);
-
- if (DateTime.Now.Ticks > f().Result)
- {
- }
-
- return Task.CompletedTask;
- }
- }
- """);
-
- [Fact]
- public Task Method_Task_EmptyBlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}(){}
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- return Task.CompletedTask;
- }
- }
- """);
-
- [Fact]
- public Task Method_Task_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- }
- }
- """);
-
- [Fact]
- public Task Method_ValueTask_BlockBody()
- => new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = """
- using System.Threading.Tasks;
-
- class C
- {
- async ValueTask {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
- }
- }
- """,
- FixedCode = """
- using System.Threading.Tasks;
-
- class C
- {
- ValueTask Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return new ValueTask();
- }
-
- return new ValueTask();
- }
- }
- """,
- }.RunAsync();
-
- [Fact]
- public Task Method_ValueTaskOfT_BlockBody()
- => new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = """
- using System.Threading.Tasks;
-
- class C
- {
- async ValueTask {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return 2;
- }
-
- return 3;
- }
- }
- """,
- FixedCode = """
- using System.Threading.Tasks;
-
- class C
- {
- ValueTask Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return new ValueTask(2);
- }
-
- return new ValueTask(3);
- }
- }
- """,
- }.RunAsync();
-
- [Fact]
- public Task Method_ValueTask_ExpressionBody()
- => new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = """
- using System.Threading.Tasks;
-
- class C
- {
- async ValueTask {|CS1998:Goo|}() => System.Console.WriteLine(1);
- }
- """,
- FixedCode = """
- using System.Threading.Tasks;
-
- class C
- {
- ValueTask Goo()
- {
- System.Console.WriteLine(1);
- return new ValueTask();
- }
- }
- """,
- }.RunAsync();
-
- [Fact]
- public Task Method_ValueTaskOfT_ExpressionBody()
- => new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = """
- using System.Threading.Tasks;
-
- class C
- {
- async ValueTask {|CS1998:Goo|}() => 3;
- }
- """,
- FixedCode = """
- using System.Threading.Tasks;
-
- class C
- {
- ValueTask Goo() => new ValueTask(3);
- }
- """,
- }.RunAsync();
-
- [Fact]
- public Task Method_Task_BlockBody_Throws()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
-
- throw new System.ApplicationException();
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return Task.CompletedTask;
- }
-
- throw new System.ApplicationException();
- }
- }
- """);
-
- [Fact]
- public Task Method_Task_BlockBody_WithLocalFunction()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- if (GetTicks() > 0)
- {
- return;
- }
-
- long GetTicks()
- {
- return System.DateTime.Now.Ticks;
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- if (GetTicks() > 0)
- {
- return Task.CompletedTask;
- }
-
- long GetTicks()
- {
- return System.DateTime.Now.Ticks;
- }
-
- return Task.CompletedTask;
- }
- }
- """);
-
- [Fact]
- public Task Method_Task_BlockBody_WithLambda()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- System.Func getTicks = () => {
- return System.DateTime.Now.Ticks;
- };
-
- if (getTicks() > 0)
- {
- return;
- }
-
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- System.Func getTicks = () => {
- return System.DateTime.Now.Ticks;
- };
-
- if (getTicks() > 0)
- {
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- }
- }
- """);
-
- [Fact]
- public Task Method_TaskOfT_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return 2;
- }
-
- return 3;
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return Task.FromResult(2);
- }
-
- return Task.FromResult(3);
- }
- }
- """);
-
- [Fact]
- public Task Method_TaskOfT_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}() => 2;
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo() => Task.FromResult(2);
- }
- """);
-
- [Fact]
- public Task Method_Task_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- async Task {|CS1998:Goo|}() => Console.WriteLine("Hello");
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- Task Goo()
- {
- Console.WriteLine("Hello");
- return Task.CompletedTask;
- }
- }
- """);
-
- [Fact]
- public Task LocalFunction_Task_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- async Task {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Task Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- }
- }
- }
- """);
-
- [Fact]
- public Task LocalFunction_Task_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- async Task {|CS1998:Goo|}() => Console.WriteLine(1);
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Task Goo() { Console.WriteLine(1); return Task.CompletedTask; }
- }
- }
- """);
-
- [Fact]
- public Task LocalFunction_TaskOfT_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- async Task {|CS1998:Goo|}()
- {
- return 1;
- }
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Task Goo()
- {
- return Task.FromResult(1);
- }
- }
- }
- """);
-
- [Fact]
- public Task LocalFunction_TaskOfT_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- async Task {|CS1998:Goo|}() => 1;
- }
- }
- """,
- """
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Task Goo() => Task.FromResult(1);
- }
- }
- """);
-
- [Fact]
- public Task AnonymousFunction_Task_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = (Func)async {|CS1998:delegate|} {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
- };
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = (Func)delegate
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- };
- }
- }
- """);
-
- [Fact]
- public Task AnonymousFunction_TaskOfT_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = (Func>)async {|CS1998:delegate|}
- {
- return 1;
- };
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = (Func>)delegate
- {
- return Task.FromResult(1);
- };
- }
- }
- """);
-
- [Fact]
- public Task SimpleLambda_TaskOfT_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = async x {|CS1998:=>|} 1;
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = x => Task.FromResult(1);
- }
- }
- """);
-
- [Fact]
- public Task SimpleLambda_TaskOfT_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = async x {|CS1998:=>|} {
- return 1;
- };
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = x =>
- {
- return Task.FromResult(1);
- };
- }
- }
- """);
-
- [Fact]
- public Task SimpleLambda_Task_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = async x {|CS1998:=>|} Console.WriteLine(1);
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = x => { Console.WriteLine(1); return Task.CompletedTask; };
- }
- }
- """);
-
- [Fact]
- public Task SimpleLambda_Task_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = async x {|CS1998:=>|}
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
- };
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = x =>
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- };
- }
- }
- """);
-
- [Fact]
- public Task ParenthesizedLambda_TaskOfT_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = async () {|CS1998:=>|} 1;
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = () => Task.FromResult(1);
- }
- }
- """);
-
- [Fact]
- public Task ParenthesizedLambda_TaskOfT_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = async () {|CS1998:=>|} {
- return 1;
- };
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func> foo = () =>
- {
- return Task.FromResult(1);
- };
- }
- }
- """);
-
- [Fact]
- public Task ParenthesizedLambda_Task_ExpressionBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = async () {|CS1998:=>|} Console.WriteLine(1);
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = () => { Console.WriteLine(1); return Task.CompletedTask; };
- }
- }
- """);
-
- [Fact]
- public Task ParenthesizedLambda_Task_BlockBody()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = async () {|CS1998:=>|}
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
- };
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- public void M1()
- {
- Func foo = () =>
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return Task.CompletedTask;
- }
-
- return Task.CompletedTask;
- };
- }
- }
- """);
-
- [Fact]
- public Task Method_Task_BlockBody_FullyQualified()
- => VerifyCS.VerifyCodeFixAsync(
- """
- class C
- {
- async System.Threading.Tasks.Task {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return;
- }
- }
- }
- """,
- """
- class C
- {
- System.Threading.Tasks.Task Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return System.Threading.Tasks.Task.CompletedTask;
- }
-
- return System.Threading.Tasks.Task.CompletedTask;
- }
- }
- """);
-
- [Fact]
- public Task Method_TaskOfT_BlockBody_FullyQualified()
- => VerifyCS.VerifyCodeFixAsync(
- """
- class C
- {
- async System.Threading.Tasks.Task {|CS1998:Goo|}()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return 1;
- }
-
- return 2;
- }
- }
- """,
- """
- class C
- {
- System.Threading.Tasks.Task Goo()
- {
- if (System.DateTime.Now.Ticks > 0)
- {
- return System.Threading.Tasks.Task.FromResult(1);
- }
-
- return System.Threading.Tasks.Task.FromResult(2);
- }
- }
- """);
-
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/65536")]
- public Task Method_TaskOfT_BlockBody_QualifyTaskFromResultType()
- => VerifyCS.VerifyCodeFixAsync("""
- using System.Threading.Tasks;
- using System.Collections.Generic;
-
- class C
- {
- public async Task> {|CS1998:M|}()
- {
- return new int[0];
- }
- }
- """, """
- using System.Threading.Tasks;
- using System.Collections.Generic;
-
- class C
- {
- public Task> M()
- {
- return Task.FromResult>(new int[0]);
- }
- }
- """);
-
- [Fact]
- public async Task IAsyncEnumerable_Missing()
- {
- var source = """
- using System.Threading.Tasks;
- using System.Collections.Generic;
-
- class C
- {
- async IAsyncEnumerable M()
- {
- yield return 1;
- }
- }
- """ + CSharpTestBase.AsyncStreamsTypes;
-
- await new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = source,
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(7,33): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- DiagnosticResult.CompilerWarning("CS1998").WithSpan(6, 33, 6, 34),
- },
- FixedCode = source,
- }.RunAsync();
- }
-
- [Fact]
- public async Task Method_AsyncVoid_Missing()
- {
- var source = """
- using System.Threading.Tasks;
-
- class C
- {
- async void M()
- {
- System.Console.WriteLine(1);
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = source,
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(6,16): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- DiagnosticResult.CompilerWarning("CS1998").WithSpan(5, 16, 5, 17),
- },
- FixedCode = source,
- }.RunAsync();
- }
-
- [Fact]
- public async Task ParenthesizedLambda_AsyncVoid_Missing()
- {
- var source = """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void M()
- {
- Action a = async () => Console.WriteLine(1);
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = source,
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(9,29): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- DiagnosticResult.CompilerWarning("CS1998").WithSpan(8, 29, 8, 31),
- },
- FixedCode = source,
- }.RunAsync();
- }
-
- [Fact]
- public async Task SimpleLambda_AsyncVoid_Missing()
- {
- var source = """
- using System;
- using System.Threading.Tasks;
-
- class C
- {
- void M()
- {
- Action a = async x => Console.WriteLine(x);
- }
- }
- """;
-
- await new VerifyCS.Test
- {
- ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard21,
- TestCode = source,
- ExpectedDiagnostics =
- {
- // /0/Test0.cs(9,33): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- DiagnosticResult.CompilerWarning("CS1998").WithSpan(8, 33, 8, 35),
- },
- FixedCode = source,
- }.RunAsync();
- }
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/65380")]
- public Task TestCloseBraceTrivia()
- => VerifyCS.VerifyCodeFixAsync(
- """
- using System;
- using System.Threading.Tasks;
-
- public class Class1
- {
- public async Task {|CS1998:Goo|}()
- {
- //Hello
- Console.WriteLine("Goo");
- //World
- }
- }
- """,
- """
- using System;
- using System.Threading.Tasks;
-
- public class Class1
- {
- public Task Goo()
- {
- //Hello
- Console.WriteLine("Goo");
- return Task.CompletedTask;
- //World
- }
- }
- """);
-}
diff --git a/src/Analyzers/Core/CodeFixes/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs
index 7ef21eba865d1..28b0e34db30ba 100644
--- a/src/Analyzers/Core/CodeFixes/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs
@@ -515,6 +515,7 @@ private static async ValueTask IsWrittenToOutsideOfConstructorOrPropertyAs
// We do need a setter
return true;
+ // Remove after .NET 10, https://github.com/dotnet/roslyn/issues/80198
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
async ValueTask IsWrittenToAsync(ReferenceLocation loc)
{
diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index 4987775354d49..6d4974fc38042 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -3833,12 +3833,6 @@ Give the compiler some way to differentiate the methods. For example, you can gi
The 'await' operator may only be used in a query expression within the first collection expression of the initial 'from' clause or within the collection expression of a 'join' clause
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
-
-
- Async method lacks 'await' operators and will run synchronously
-
Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
index d231de7a68dc8..8ec23581e5a27 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
@@ -1024,7 +1024,7 @@ internal enum ErrorCode
ERR_BadAwaitInQuery = 1995,
ERR_BadAwaitInLock = 1996,
ERR_TaskRetNoObjectRequired = 1997,
- WRN_AsyncLacksAwaits = 1998,
+ // WRN_AsyncLacksAwaits = 1998,
ERR_FileNotFound = 2001,
WRN_FileAlreadyIncluded = 2002,
//ERR_DuplicateResponseFile = 2003,
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
index cd31fd621ca2b..75f0ef998b9da 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
@@ -411,7 +411,6 @@ internal static int GetWarningLevel(ErrorCode code)
case ErrorCode.WRN_CallerLineNumberPreferredOverCallerFilePath:
case ErrorCode.WRN_DelaySignButNoKey:
case ErrorCode.WRN_UnimplementedCommandLineSwitch:
- case ErrorCode.WRN_AsyncLacksAwaits:
case ErrorCode.WRN_BadUILang:
case ErrorCode.WRN_RefCultureMismatch:
case ErrorCode.WRN_ConflictingMachineAssembly:
@@ -1485,7 +1484,6 @@ or ErrorCode.ERR_BadAsyncLacksBody
or ErrorCode.ERR_BadAwaitInQuery
or ErrorCode.ERR_BadAwaitInLock
or ErrorCode.ERR_TaskRetNoObjectRequired
- or ErrorCode.WRN_AsyncLacksAwaits
or ErrorCode.ERR_FileNotFound
or ErrorCode.WRN_FileAlreadyIncluded
or ErrorCode.ERR_NoFileSpec
diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs
index 3eff3de5721b5..4b835ee748f53 100644
--- a/src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs
+++ b/src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs
@@ -403,55 +403,6 @@ protected override ImmutableArray Scan(ref bool badRegion)
return pendingReturns;
}
- protected override ImmutableArray RemoveReturns()
- {
- var result = base.RemoveReturns();
-
- if (CurrentSymbol is MethodSymbol currentMethod && currentMethod.IsAsync && !currentMethod.IsImplicitlyDeclared)
- {
- var foundAwait = result.Any(static pending => HasAwait(pending));
- if (!foundAwait)
- {
- // If we're on a LambdaSymbol, then use its 'DiagnosticLocation'. That will be
- // much better than using its 'Location' (which is the entire span of the lambda).
- var diagnosticLocation = CurrentSymbol is LambdaSymbol lambda
- ? lambda.DiagnosticLocation
- : CurrentSymbol.GetFirstLocationOrNone();
-
- Diagnostics.Add(ErrorCode.WRN_AsyncLacksAwaits, diagnosticLocation);
- }
- }
-
- return result;
- }
-
- private static bool HasAwait(PendingBranch pending)
- {
- var pendingBranch = pending.Branch;
- if (pendingBranch is null)
- {
- return false;
- }
-
- BoundKind kind = pendingBranch.Kind;
- switch (kind)
- {
- case BoundKind.AwaitExpression:
- return true;
- case BoundKind.UsingStatement:
- var usingStatement = (BoundUsingStatement)pendingBranch;
- return usingStatement.AwaitOpt != null;
- case BoundKind.ForEachStatement:
- var foreachStatement = (BoundForEachStatement)pendingBranch;
- return foreachStatement.AwaitOpt != null;
- case BoundKind.UsingLocalDeclarations:
- var localDeclaration = (BoundUsingLocalDeclarations)pendingBranch;
- return localDeclaration.AwaitOpt != null;
- default:
- return false;
- }
- }
-
// For purpose of definite assignment analysis, awaits create pending branches, so async usings and foreachs do too
public sealed override bool AwaitUsingAndForeachAddsPendingBranch => true;
@@ -594,7 +545,7 @@ public static void Analyze(
compatDiagnostics.Free();
foreach (var diagnostic in strictDiagnostics.AsEnumerable())
{
- // If it is a warning (e.g. WRN_AsyncLacksAwaits), or an error that would be reported by the compatible analysis, just report it.
+ // If it is a warning, or an error that would be reported by the compatible analysis, just report it.
if (diagnostic.Severity != DiagnosticSeverity.Error || compatDiagnosticSet.Contains(diagnostic))
{
diagnostics.Add(diagnostic);
diff --git a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
index 35a3f0182d26b..34056cc7577b9 100644
--- a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
+++ b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
@@ -116,7 +116,6 @@ public static bool IsWarning(ErrorCode code)
case ErrorCode.WRN_MultipleRuntimeOverrideMatches:
case ErrorCode.WRN_DynamicDispatchToConditionalMethod:
case ErrorCode.WRN_IsDynamicIsConfusing:
- case ErrorCode.WRN_AsyncLacksAwaits:
case ErrorCode.WRN_FileAlreadyIncluded:
case ErrorCode.WRN_NoSources:
case ErrorCode.WRN_NoConfigNotOnCommandLine:
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
index 12b1d41ed666c..9c850f22643e7 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
@@ -11125,17 +11125,7 @@ Poskytněte kompilátoru nějaký způsob, jak metody rozlišit. Můžete např
Operátor await jde použít jenom ve výrazu dotazu v rámci první kolekce výrazu počáteční klauzule from nebo v rámci výrazu kolekce klauzule join.
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- V této asynchronní metodě chybí operátory await a spustí se synchronně. Zvažte použití operátoru await pro čekání na neblokující volání rozhraní API nebo vykonání činnosti vázané na procesor ve vlákně na pozadí pomocí výrazu await Task.Run(...).
-
-
-
- Async method lacks 'await' operators and will run synchronously
- V této asynchronní metodě chybí operátory await a spustí se synchronně.
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Protože se toto volání neočekává, vykonávání aktuální metody pokračuje před dokončením volání. Zvažte použití operátoru await na výsledek volání.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
index 33e73c90849ae..71d7f9101a204 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
@@ -11125,17 +11125,7 @@ Unterstützen Sie den Compiler bei der Unterscheidung zwischen den Methoden. Daz
Der await-Operator kann in einem Abfrageausdruck nur innerhalb des ersten Sammlungsausdrucks der ursprünglichen from-Klausel oder innerhalb des Sammlungsausdrucks einer join-Klausel verwendet werden.
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- In dieser Async-Methode fehlen die "await"-Operatoren, weshalb sie synchron ausgeführt wird. Sie sollten die Verwendung des "await"-Operators oder von "await Task.Run(...)" in Betracht ziehen, um auf nicht blockierende API-Aufrufe zu warten bzw. CPU-gebundene Aufgaben auf einem Hintergrundthread auszuführen.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- Bei der asynchronen Methode fehlen "await"-Operatoren. Die Methode wird synchron ausgeführt.
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Da auf diesen Aufruf nicht gewartet wird, wird die Ausführung der aktuellen Methode vor Abschluss des Aufrufs fortgesetzt. Ziehen Sie ein Anwenden des "Await"-Operators auf das Ergebnis des Aufrufs in Betracht.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
index 9ffcdf65762d1..5db9dd0dc9f8c 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
@@ -11125,17 +11125,7 @@ Indique al compilador alguna forma de diferenciar los métodos. Por ejemplo, pue
El operador 'await' solo se puede usar en una expresión de consulta dentro de la primera expresión de colección de la cláusula 'from' inicial o de la expresión de colección de una cláusula 'join'
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- El método asincrónico carece de operadores "await" y se ejecutará de forma sincrónica. Puede usar el operador 'await' para esperar llamadas API que no sean de bloqueo o 'await Task.Run(...)' para hacer tareas enlazadas a la CPU en un subproceso en segundo plano.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- El método asincrónico carece de operadores "await" y se ejecutará de forma sincrónica
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Como esta llamada no es 'awaited', la ejecución del método actual continuará antes de que se complete la llamada. Puede aplicar el operador 'await' al resultado de la llamada.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
index f8d246e2fd9a6..ae96cc2518f8e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
@@ -11125,17 +11125,7 @@ Permettez au compilateur de différencier les méthodes. Par exemple, vous pouve
L'opérateur 'await' peut seulement être utilisé dans une expression de requête dans la première expression de collection de la clause 'from' initiale ou dans l'expression de collection d'une clause 'join'
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- Cette méthode async n'a pas d'opérateur 'await' et elle s'exécutera de façon synchrone. Utilisez l'opérateur 'await' pour attendre les appels d'API non bloquants ou 'await Task.Run(…)' pour effectuer un travail utilisant le processeur sur un thread d'arrière-plan.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- Cette méthode async n'a pas d'opérateur 'await' et elle s'exécutera de façon synchrone
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Dans la mesure où cet appel n'est pas attendu, l'exécution de la méthode actuelle continue avant la fin de l'appel. Envisagez d'appliquer l'opérateur 'await' au résultat de l'appel.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
index aa84307549eac..6e78268ea250b 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
@@ -11125,17 +11125,7 @@ Impostare il compilatore in modo tale da distinguere i metodi, ad esempio assegn
È possibile usare l'operatore 'await' solo in espressioni di query all'interno della prima espressione di raccolta della clausola 'from' iniziale o all'interno dell'espressione di raccolta di una clausola 'join'
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- In questo metodo asincrono non sono presenti operatori 'await', pertanto verrà eseguito in modo sincrono. Provare a usare l'operatore 'await' per attendere chiamate ad API non di blocco oppure 'await Task.Run(...)' per effettuare elaborazioni basate sulla CPU in un thread in background.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- Il metodo asincrono non contiene operatori 'await', pertanto verrà eseguito in modo sincrono
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Non è possibile attendere la chiamata, pertanto l'esecuzione del metodo corrente continuerà prima del completamento della chiamata. Provare ad applicare l'operatore 'await' al risultato della chiamata.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
index 1957a0a41ab03..a347b60bb32d5 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
@@ -11125,17 +11125,7 @@ C# では out と ref を区別しますが、CLR では同じと認識します
await' 演算子は、最初の 'from' 句の最初のコレクション式、または 'join' 句のコレクション式に含まれるクエリ式でのみ使用できます
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- この非同期メソッドには 'await' 演算子がないため、同期的に実行されます。'await' 演算子を使用して非ブロッキング API 呼び出しを待機するか、'await Task.Run(...)' を使用してバックグラウンドのスレッドに対して CPU 主体の処理を実行することを検討してください。
-
-
-
- Async method lacks 'await' operators and will run synchronously
- 非同期メソッドは、'await' 演算子がないため、同期的に実行されます
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.この呼び出しを待たないため、現在のメソッドの実行は、呼び出しが完了するまで続行します。呼び出しの結果に 'await' 演算子を適用することを検討してください。
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
index 7e8470f61ca12..4c63f7186ef26 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
@@ -11125,17 +11125,7 @@ C#에서는 out과 ref를 구분하지만 CLR에서는 동일한 것으로 간
await' 연산자는 초기 'from' 절의 첫 번째 Collection 식이나 'join' 절의 Collection 식 내의 쿼리 식에서만 사용할 수 있습니다.
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. 'await' 연산자를 사용하여 비블로킹 API 호출을 대기하거나, 'await Task.Run(...)'을 사용하여 백그라운드 스레드에서 CPU 바인딩된 작업을 수행하세요.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다.
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.이 호출이 대기되지 않으므로 호출이 완료되기 전에 현재 메서드가 계속 실행됩니다. 호출 결과에 'await' 연산자를 적용해 보세요.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
index 67744cdeb7235..acbc21435604b 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
@@ -11125,17 +11125,7 @@ Musisz umożliwić kompilatorowi rozróżnienie metod. Możesz na przykład nada
Operatora „await” można użyć tylko w wyrażeniu zapytania w pierwszym wyrażeniu kolekcji początkowej klauzuli „from” albo w wyrażeniu kolekcji klauzuli „join”.
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- W tej metodzie asynchronicznej brakuje operatorów „await”, dlatego będzie wykonywana synchronicznie. Rozważ możliwość użycia operatora „await” w celu zdefiniowania oczekiwania na nieblokujące wywołania interfejsów API albo wyrażenia „await Task.Run(...)” w celu przeniesienia wykonywania zadań intensywnie angażujących procesor do wątku w tle.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- Metoda asynchroniczna nie zawiera operatorów „await” i zostanie uruchomiona synchronicznie
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Ponieważ to wywołanie nie jest oczekiwane, wykonywanie bieżącej metody będzie kontynuowane bez oczekiwania na ukończenie wywołania. Rozważ możliwość zastosowania operatora „await” do wyniku wywołania.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
index 5b8ccc1307308..a76920c10429b 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
@@ -11125,17 +11125,7 @@ Forneça ao compilador alguma forma de diferenciar os métodos. Por exemplo, voc
O operador 'await' só pode ser usado em uma expressão de consulta na primeira expressão de coleção da cláusula 'from' inicial ou na expressão de coleção de uma cláusula 'join'
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- Este método assíncrono não possui operadores 'await' e será executado de modo síncrono. É recomendável o uso do operador 'await' para aguardar chamadas à API desbloqueadas ou do operador 'await Task.Run(...)' para realizar um trabalho associado à CPU em um thread em segundo plano.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- O método assíncrono não possui operadores 'await' e será executado de forma síncrona
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Como esta chamada não é aguardada, a execução do método atual continua antes da conclusão da chamada. Considere aplicar o operador 'await' ao resultado da chamada.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
index f56eb82ad4048..b823fcf193c1e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
@@ -11126,17 +11126,7 @@ Give the compiler some way to differentiate the methods. For example, you can gi
Оператор await можно использовать только в выражении запроса в первом выражении коллекции начального предложения From или в выражении коллекции предложения Join.
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- В данном асинхронном методе отсутствуют операторы await, поэтому метод будет выполняться синхронно. Воспользуйтесь оператором await для ожидания неблокирующих вызовов API или оператором await Task.Run(...) для выполнения связанных с ЦП заданий в фоновом потоке.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- В асинхронном методе отсутствуют операторы await, будет выполнен синхронный метод
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Поскольку этот вызов не ожидается, выполнение текущего метода продолжается до завершения вызова. Попробуйте применить оператор await к результату вызова.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
index f3db96e5519af..b31cd0fa52b16 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
@@ -11125,17 +11125,7 @@ Derleyiciye yöntemleri ayrıştırma yolu verin. Örneğin, bunlara farklı adl
await' işleci yalnızca başlangıçtaki 'from' yan tümcesinin ilk koleksiyon ifadesinin içindeki ya da bir 'join' yan tümcesinin toplama ifadesinin içindeki bir sorgu ifadesinde kullanılabilir
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- Bu zaman uyumsuz yöntemde 'await' işleçleri yok ve zaman uyumlu çalışacak. 'await' işlecini kullanarak engelleyici olmayan API çağrılarını beklemeyi veya 'await Task.Run(...)' kullanarak bir arka plan iş parçacığında CPU bağlantılı iş yapmayı düşünün.
-
-
-
- Async method lacks 'await' operators and will run synchronously
- Zaman uyumsuz yöntemde 'await' işleçleri yok ve zaman uyumlu çalışacak
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.Bu çağrı beklenmediğinden, çağrı tamamlanmadan geçerli yöntemin yürütülmesi devam eder. Çağrının sonucuna 'await' işlecini eklemeyi düşünün.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
index 028a50115067e..5a9c1affb06d1 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
@@ -11125,17 +11125,7 @@ Give the compiler some way to differentiate the methods. For example, you can gi
"await" 运算符只能用在初始 "from" 子句的第一个集合表达式或 "join" 子句的集合表达式内的查询表达式中
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- 此异步方法缺少 "await" 运算符,将以同步方式运行。请考虑使用 "await" 运算符等待非阻止的 API 调用,或者使用 "await Task.Run(...)" 在后台线程上执行占用大量 CPU 的工作。
-
-
-
- Async method lacks 'await' operators and will run synchronously
- 异步方法缺少 "await" 运算符,将以同步方式运行
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.由于此调用不会等待,因此在此调用完成之前将会继续执行当前方法。请考虑将 "await" 运算符应用于调用结果。
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
index cda34345fb095..5b004ca8054fc 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
@@ -11125,17 +11125,7 @@ Give the compiler some way to differentiate the methods. For example, you can gi
await' 運算子只能用在初始 'from' 子句的第一個集合運算式或 'join' 子句的集合運算式中的查詢運算式
-
- This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- 這個非同步方法缺少 'await' 運算子,因此將以同步方式執行。請考慮使用 'await' 運算子等候未封鎖的應用程式開發介面呼叫,或使用 'await Task.Run(...)' 在背景執行緒上執行 CPU-bound 工作。
-
-
-
- Async method lacks 'await' operators and will run synchronously
- Async 方法缺乏 'await' 運算子,將同步執行
-
-
-
+ Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.因為未等候此呼叫,所以在呼叫完成之前會繼續執行目前的方法。請考慮將 'await' 運算子套用至呼叫的結果。
diff --git a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
index 0b5da55168742..92201963a4ebd 100644
--- a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
+++ b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
@@ -8717,9 +8717,7 @@ public void CS1691WRN_BadWarningNumber_Bug15905()
string source = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(@"
class Program
{
-#pragma warning disable 1998
public static void Main() { }
-#pragma warning restore 1998
} ").Path;
var outWriter = new StringWriter(CultureInfo.InvariantCulture);
diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncEHTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncEHTests.cs
index 3ce646e6931db..979dd03270bed 100644
--- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncEHTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncEHTests.cs
@@ -688,11 +688,7 @@ public static void Main()
[G]: Unexpected type on the stack. { Offset = 0x13, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (7,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(7, 28)
- );
+ verifier.VerifyDiagnostics();
}
[Fact]
@@ -739,11 +735,7 @@ public static void Main()
[H]: Unexpected type on the stack. { Offset = 0xa, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (7,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(7, 28)
- );
+ verifier.VerifyDiagnostics();
}
[Fact]
@@ -904,11 +896,7 @@ .locals init (int V_0,
[G]: Unexpected type on the stack. { Offset = 0x29, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (7,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(7, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G()", """
{
@@ -1008,11 +996,7 @@ public static void Main()
[F]: Unexpected type on the stack. { Offset = 0xb, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (7,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(7, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G()", """
{
@@ -1368,11 +1352,7 @@ .locals init (int V_0,
[G]: Unexpected type on the stack. { Offset = 0x48, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (7,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(7, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G()", """
{
@@ -1489,11 +1469,7 @@ public static void Main()
[G]: Unexpected type on the stack. { Offset = 0x3e, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (7,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(7, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G()", """
{
@@ -1773,11 +1749,7 @@ .locals init (int V_0,
[F]: Unexpected type on the stack. { Offset = 0x1, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (6,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(6, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G()", """
{
// Code size 72 (0x48)
@@ -2051,11 +2023,7 @@ .locals init (int V_0,
[F]: Unexpected type on the stack. { Offset = 0x1, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (6,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(6, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G(System.Threading.SemaphoreSlim)", """
{
// Code size 43 (0x2b)
@@ -2304,11 +2272,7 @@ .locals init (int V_0,
[F]: Unexpected type on the stack. { Offset = 0x1, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (6,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(6, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G(System.Threading.SemaphoreSlim)", """
{
// Code size 43 (0x2b)
@@ -2386,11 +2350,7 @@ public static void Main()
[G]: Unexpected type on the stack. { Offset = 0x45, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (5,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(5, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G()", """
{
// Code size 70 (0x46)
@@ -2859,11 +2819,7 @@ .locals init (int V_0,
[G]: Unexpected type on the stack. { Offset = 0x1f, Found = Int32, Expected = ref '[System.Runtime]System.Threading.Tasks.Task`1' }
"""
});
- verifier.VerifyDiagnostics(
- // (7,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task F()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(7, 28)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.G()", """
{
@@ -4013,7 +3969,6 @@ class Exception2 : Exception { }
public void NestedRethrow_02(bool await1, bool await2, bool await3)
{
var source = $$"""
- #pragma warning disable 1998 // async method lacks 'await' operators
using System;
using System.Threading.Tasks;
diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncIteratorTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncIteratorTests.cs
index 435e3bd64c3d0..d745bf90704cf 100644
--- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncIteratorTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncIteratorTests.cs
@@ -1713,9 +1713,6 @@ async System.Collections.Generic.IAsyncEnumerable M2()
// (8,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return 1;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(8, 9),
- // (10,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerable M2()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M2").WithLocation(10, 60),
// (12,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return 4;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(12, 9)
@@ -1744,9 +1741,6 @@ async System.Collections.Generic.IAsyncEnumerable M2()
// (8,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return null;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(8, 9),
- // (10,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerable M2()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M2").WithLocation(10, 60),
// (12,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return null;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(12, 9)
@@ -1781,9 +1775,6 @@ async System.Collections.Generic.IAsyncEnumerable M2(ref string s2)
// (8,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return ref s;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(8, 9),
- // (10,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerable M2(ref string s2)
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M2").WithLocation(10, 60),
// (10,74): error CS1988: Async methods cannot have ref, in or out parameters
// async System.Collections.Generic.IAsyncEnumerable M2(ref string s2)
Diagnostic(ErrorCode.ERR_BadAsyncArgType, "s2").WithLocation(10, 74),
@@ -1815,9 +1806,6 @@ async System.Collections.Generic.IAsyncEnumerable M2()
// (8,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return default;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(8, 9),
- // (10,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerable M2()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M2").WithLocation(10, 60),
// (12,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return default;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(12, 9)
@@ -1943,9 +1931,6 @@ async System.Collections.Generic.IAsyncEnumerator M()
}";
var comp = CreateCompilationWithAsyncIterator(source);
comp.VerifyDiagnostics(
- // (4,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerator M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 60),
// (6,9): error CS1622: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
// return null;
Diagnostic(ErrorCode.ERR_ReturnInIterator, "return").WithLocation(6, 9)
@@ -2054,15 +2039,8 @@ public static async System.Collections.Generic.IAsyncEnumerable M()
}
}";
var comp = CreateCompilationWithAsyncIterator(source);
- comp.VerifyDiagnostics(
- // (4,74): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 74)
- );
+ comp.VerifyDiagnostics();
comp.VerifyEmitDiagnostics(
- // (4,74): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 74),
// (4,74): error CS8420: The body of an async-iterator method must contain a 'yield' statement. Consider removing 'async' from the method declaration or adding a 'yield' statement.
// public static async System.Collections.Generic.IAsyncEnumerable M()
Diagnostic(ErrorCode.ERR_PossibleAsyncIteratorWithoutYieldOrAwait, "M").WithLocation(4, 74)
@@ -2086,15 +2064,8 @@ public static async System.Collections.Generic.IAsyncEnumerator M()
}
}";
var comp = CreateCompilationWithAsyncIterator(source);
- comp.VerifyDiagnostics(
- // (4,74): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async System.Collections.Generic.IAsyncEnumerator M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 74)
- );
+ comp.VerifyDiagnostics();
comp.VerifyEmitDiagnostics(
- // (4,74): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async System.Collections.Generic.IAsyncEnumerator M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 74),
// (4,74): error CS8420: The body of an async-iterator method must contain a 'yield' statement. Consider removing `async` from the method declaration.
// public static async System.Collections.Generic.IAsyncEnumerator M()
Diagnostic(ErrorCode.ERR_PossibleAsyncIteratorWithoutYieldOrAwait, "M").WithLocation(4, 74)
@@ -2137,15 +2108,8 @@ async System.Collections.Generic.IAsyncEnumerator M()
}
}";
var comp = CreateCompilationWithAsyncIterator(source);
- comp.VerifyDiagnostics(
- // (4,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerator M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 60)
- );
+ comp.VerifyDiagnostics();
comp.VerifyEmitDiagnostics(
- // (4,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerator M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 60),
// (4,60): error CS8420: The body of an async-iterator method must contain a 'yield' statement. Consider removing `async` from the method declaration.
// async System.Collections.Generic.IAsyncEnumerator M()
Diagnostic(ErrorCode.ERR_PossibleAsyncIteratorWithoutYieldOrAwait, "M").WithLocation(4, 60)
@@ -2165,9 +2129,6 @@ public static async System.Collections.Generic.IAsyncEnumerable M()
}";
var comp = CreateCompilationWithAsyncIterator(source);
comp.VerifyDiagnostics(
- // (4,74): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 74),
// (4,74): error CS0161: 'C.M()': not all code paths return a value
// public static async System.Collections.Generic.IAsyncEnumerable M()
Diagnostic(ErrorCode.ERR_ReturnExpected, "M").WithArguments("C.M()").WithLocation(4, 74)
@@ -2187,11 +2148,7 @@ public static async System.Collections.Generic.IAsyncEnumerable M()
}
}";
var comp = CreateCompilationWithAsyncIterator(new[] { Run(iterations: 2), source }, options: TestOptions.DebugExe);
- comp.VerifyDiagnostics(
- // (4,74): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 74)
- );
+ comp.VerifyDiagnostics();
CompileAndVerify(comp, expectedOutput: "1 END DISPOSAL DONE");
}
@@ -2258,10 +2215,7 @@ static async System.Collections.Generic.IEnumerable M()
comp.VerifyDiagnostics(
// (4,62): error CS1983: The return type of an async method must be void, Task, Task, a task-like type, IAsyncEnumerable, or IAsyncEnumerator
// static async System.Collections.Generic.IEnumerable M()
- Diagnostic(ErrorCode.ERR_BadAsyncReturn, "M").WithLocation(4, 62),
- // (4,62): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async System.Collections.Generic.IEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 62)
+ Diagnostic(ErrorCode.ERR_BadAsyncReturn, "M").WithLocation(4, 62)
);
}
@@ -2278,9 +2232,6 @@ public static async System.Collections.Generic.IAsyncEnumerator M()
}";
var comp = CreateCompilationWithAsyncIterator(source);
comp.VerifyDiagnostics(
- // (4,74): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 74),
// (4,74): error CS0161: 'C.M()': not all code paths return a value
// public static async System.Collections.Generic.IAsyncEnumerable M()
Diagnostic(ErrorCode.ERR_ReturnExpected, "M").WithArguments("C.M()").WithLocation(4, 74)
@@ -2300,11 +2251,7 @@ static async System.Collections.Generic.IAsyncEnumerator M(int value)
}
}";
var comp = CreateCompilationWithAsyncIterator(source);
- comp.VerifyDiagnostics(
- // (4,67): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async System.Collections.Generic.IAsyncEnumerator M(int value)
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 67)
- );
+ comp.VerifyDiagnostics();
}
[Fact]
@@ -6618,11 +6565,7 @@ public static async System.Threading.Tasks.Task Main()
}
}";
var comp = CreateCompilationWithAsyncIterator(source, options: TestOptions.DebugExe);
- comp.VerifyDiagnostics(
- // (4,67): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 67)
- );
+ comp.VerifyDiagnostics();
CompileAndVerify(comp, expectedOutput: "1");
}
@@ -6646,11 +6589,7 @@ public static async System.Threading.Tasks.Task Main()
}
}";
var comp = CreateCompilationWithAsyncIterator(source, options: TestOptions.DebugExe);
- comp.VerifyDiagnostics(
- // (4,67): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 67)
- );
+ comp.VerifyDiagnostics();
CompileAndVerify(comp, expectedOutput: "none");
}
@@ -6666,9 +6605,6 @@ async System.Collections.Generic.IAsyncEnumerable M()
}";
var comp = CreateCompilationWithAsyncIterator(source);
comp.VerifyDiagnostics(
- // (4,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 60),
// (4,60): error CS0161: 'C.M()': not all code paths return a value
// async System.Collections.Generic.IAsyncEnumerable M()
Diagnostic(ErrorCode.ERR_ReturnExpected, "M").WithArguments("C.M()").WithLocation(4, 60)
@@ -6694,10 +6630,7 @@ async System.Collections.Generic.IAsyncEnumerable M()
Diagnostic(ErrorCode.ERR_EmptyYield, "return").WithLocation(7, 15),
// (6,22): error CS0029: Cannot implicitly convert type 'string' to 'int'
// yield return "hello";
- Diagnostic(ErrorCode.ERR_NoImplicitConv, @"""hello""").WithArguments("string", "int").WithLocation(6, 22),
- // (4,60): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async System.Collections.Generic.IAsyncEnumerable M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 60)
+ Diagnostic(ErrorCode.ERR_NoImplicitConv, @"""hello""").WithArguments("string", "int").WithLocation(6, 22)
);
}
@@ -8895,7 +8828,6 @@ static async System.Threading.Tasks.Task Main()
public void LambdaWithBindingErrorInYieldReturn()
{
var src = """
-#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -8916,7 +8848,6 @@ static async IAsyncEnumerable>> BarAsync()
comp.VerifyDiagnostics();
src = """
-#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -8937,21 +8868,22 @@ static async IAsyncEnumerable>> BarAsync()
comp = CreateCompilation(src, targetFramework: TargetFramework.Net80);
comp.VerifyDiagnostics(
- // (12,13): error CS0118: 's' is a variable but is used like a type
+ // (11,13): error CS0118: 's' is a variable but is used like a type
// s // 1
- Diagnostic(ErrorCode.ERR_BadSKknown, "s").WithArguments("s", "variable", "type").WithLocation(12, 13),
- // (13,13): error CS4003: 'await' cannot be used as an identifier within an async method or lambda expression
+ Diagnostic(ErrorCode.ERR_BadSKknown, "s").WithArguments("s", "variable", "type").WithLocation(11, 13),
+ // (12,13): error CS4003: 'await' cannot be used as an identifier within an async method or lambda expression
// await Task.CompletedTask;
- Diagnostic(ErrorCode.ERR_BadAwaitAsIdentifier, "await").WithLocation(13, 13),
- // (13,13): warning CS0168: The variable 'await' is declared but never used
+ Diagnostic(ErrorCode.ERR_BadAwaitAsIdentifier, "await").WithLocation(12, 13),
+ // (12,13): warning CS0168: The variable 'await' is declared but never used
// await Task.CompletedTask;
- Diagnostic(ErrorCode.WRN_UnreferencedVar, "await").WithArguments("await").WithLocation(13, 13),
- // (13,19): error CS1002: ; expected
+ Diagnostic(ErrorCode.WRN_UnreferencedVar, "await").WithArguments("await").WithLocation(12, 13),
+ // (12,19): error CS1002: ; expected
// await Task.CompletedTask;
- Diagnostic(ErrorCode.ERR_SemicolonExpected, "Task").WithLocation(13, 19),
- // (13,19): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
+ Diagnostic(ErrorCode.ERR_SemicolonExpected, "Task").WithLocation(12, 19),
+ // (12,19): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
// await Task.CompletedTask;
- Diagnostic(ErrorCode.ERR_IllegalStatement, "Task.CompletedTask").WithLocation(13, 19));
+ Diagnostic(ErrorCode.ERR_IllegalStatement, "Task.CompletedTask").WithLocation(12, 19)
+ );
var tree = comp.SyntaxTrees.Single();
var model = comp.GetSemanticModel(tree);
@@ -8964,7 +8896,6 @@ static async IAsyncEnumerable>> BarAsync()
public void LambdaWithBindingErrorInReturn()
{
var src = """
-#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously
using System;
using System.Threading.Tasks;
@@ -8984,7 +8915,6 @@ static async Task>> BarAsync()
comp.VerifyDiagnostics();
src = """
-#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously
using System;
using System.Threading.Tasks;
@@ -9003,21 +8933,22 @@ static async Task>> BarAsync()
""";
comp = CreateCompilation(src, targetFramework: TargetFramework.Net80);
comp.VerifyDiagnostics(
- // (11,13): error CS0118: 's' is a variable but is used like a type
+ // (10,13): error CS0118: 's' is a variable but is used like a type
// s // 1
- Diagnostic(ErrorCode.ERR_BadSKknown, "s").WithArguments("s", "variable", "type").WithLocation(11, 13),
- // (12,13): error CS4003: 'await' cannot be used as an identifier within an async method or lambda expression
+ Diagnostic(ErrorCode.ERR_BadSKknown, "s").WithArguments("s", "variable", "type").WithLocation(10, 13),
+ // (11,13): error CS4003: 'await' cannot be used as an identifier within an async method or lambda expression
// await Task.CompletedTask;
- Diagnostic(ErrorCode.ERR_BadAwaitAsIdentifier, "await").WithLocation(12, 13),
- // (12,13): warning CS0168: The variable 'await' is declared but never used
+ Diagnostic(ErrorCode.ERR_BadAwaitAsIdentifier, "await").WithLocation(11, 13),
+ // (11,13): warning CS0168: The variable 'await' is declared but never used
// await Task.CompletedTask;
- Diagnostic(ErrorCode.WRN_UnreferencedVar, "await").WithArguments("await").WithLocation(12, 13),
- // (12,19): error CS1002: ; expected
+ Diagnostic(ErrorCode.WRN_UnreferencedVar, "await").WithArguments("await").WithLocation(11, 13),
+ // (11,19): error CS1002: ; expected
// await Task.CompletedTask;
- Diagnostic(ErrorCode.ERR_SemicolonExpected, "Task").WithLocation(12, 19),
- // (12,19): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
+ Diagnostic(ErrorCode.ERR_SemicolonExpected, "Task").WithLocation(11, 19),
+ // (11,19): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
// await Task.CompletedTask;
- Diagnostic(ErrorCode.ERR_IllegalStatement, "Task.CompletedTask").WithLocation(12, 19));
+ Diagnostic(ErrorCode.ERR_IllegalStatement, "Task.CompletedTask").WithLocation(11, 19)
+ );
var tree = comp.SyntaxTrees.Single();
var model = comp.GetSemanticModel(tree);
@@ -10870,9 +10801,7 @@ public void Repro_78640()
static class C
{
- #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public static async IAsyncEnumerable AsAsyncEnumerable(this IEnumerable enumerable, [EnumeratorCancellation] CancellationToken cancellationToken)
- #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
ArgumentNullException.ThrowIfNull(enumerable);
diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs
index 379636e59b2f5..a13a3dca71467 100644
--- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMainTests.cs
@@ -1271,12 +1271,6 @@ async static Task Main(string[] args)
}
}";
var compilation = CreateCompilationWithMscorlib461(source, options: TestOptions.ReleaseDebugExe, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7)).VerifyDiagnostics(
- // (6,28): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async static Task Main()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Main").WithLocation(6, 28),
- // (12,30): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async static Task Main(string[] args)
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Main").WithLocation(12, 30),
// (6,18): error CS8107: Feature 'async main' is not available in C# 7. Please use language version 7.1 or greater.
// async static Task Main()
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "Task").WithArguments("async main", "7.1").WithLocation(6, 18),
diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs
index bc5f8f01cddba..ca2758c661b01 100644
--- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs
@@ -554,7 +554,6 @@ .maxstack 2
public void SpillNestedUnary()
{
var source = @"
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
using System;
using System.Threading.Tasks;
@@ -2029,10 +2028,7 @@ Not Valid!
verifier.VerifyDiagnostics(
// (23,17): warning CS8073: The result of the expression is always 'true' since a value of type 'Guid' is never equal to 'null' of type 'Guid?'
// if (item.Item2 != null || await IsValid(item.Item2))
- Diagnostic(ErrorCode.WRN_NubExprIsConstBool2, "item.Item2 != null").WithArguments("true", "System.Guid", "System.Guid?").WithLocation(23, 17),
- // (29,41): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // private static async Task IsValid(Guid id)
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "IsValid").WithLocation(29, 41)
+ Diagnostic(ErrorCode.WRN_NubExprIsConstBool2, "item.Item2 != null").WithArguments("true", "System.Guid", "System.Guid?").WithLocation(23, 17)
);
verifier.VerifyIL("AsyncConditionalBug.Program.DoSomething(System.Tuple)", """
{
@@ -4313,7 +4309,6 @@ .locals init (int V_0)
public void SpillArrayAssign2()
{
var source = @"
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
using System.Threading.Tasks;
class Program
@@ -8417,9 +8412,6 @@ static async Task Main()
});
verifier.VerifyDiagnostics(
- // (14,23): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // static async Task Main()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Main").WithLocation(14, 23),
// (16,9): warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
// M();
Diagnostic(ErrorCode.WRN_UnobservedAwaitableExpression, "M()").WithLocation(16, 9)
@@ -8511,11 +8503,7 @@ static async Task Main()
"""
});
- verifier.VerifyDiagnostics(
- // (7,16): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async Task M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(7, 16)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("S.M()", """
{
// Code size 16 (0x10)
@@ -8583,11 +8571,7 @@ public async Task M()
"""
});
- verifier.VerifyDiagnostics(
- // (26,27): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public async Task M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(26, 27)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Extensions.M(this T)", """
{
// Code size 15 (0xf)
@@ -8642,10 +8626,7 @@ public async Task M()
var expectedDiagnostics = new[] {
// (26,27): error CS1988: Async methods cannot have ref, in or out parameters
// public async Task M()
- Diagnostic(ErrorCode.ERR_BadAsyncArgType, "M").WithLocation(26, 27),
- // (26,27): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public async Task M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(26, 27)
+ Diagnostic(ErrorCode.ERR_BadAsyncArgType, "M").WithLocation(26, 27)
};
var comp = CreateCompilation(source, parseOptions: TestOptions.Regular14);
@@ -8699,10 +8680,7 @@ public async Task M()
Diagnostic(ErrorCode.ERR_RefExtensionParameterMustBeValueTypeOrConstrainedToOne, "T").WithLocation(24, 22),
// (26,27): error CS1988: Async methods cannot have ref, in or out parameters
// public async Task M()
- Diagnostic(ErrorCode.ERR_BadAsyncArgType, "M").WithLocation(26, 27),
- // (26,27): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public async Task M()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(26, 27)
+ Diagnostic(ErrorCode.ERR_BadAsyncArgType, "M").WithLocation(26, 27)
};
var comp = CreateCompilation(source, parseOptions: TestOptions.Regular14);
diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs
index aae7c293df18c..b1ef2381ff792 100644
--- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs
@@ -373,11 +373,7 @@ public static async Task Main()
{ReturnValueMissing("g__Impl|1_0", "0x7")}
"""
}, symbolValidator: verify);
- verifier.VerifyDiagnostics(
- // (13,25): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async ValueTask Impl()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "Impl").WithLocation(13, 25)
- );
+ verifier.VerifyDiagnostics();
verifier.VerifyIL("Test.F", """
{
@@ -2111,7 +2107,6 @@ public void AddressOf_Fixed()
var source = """
using System.Threading.Tasks;
// This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- #pragma warning disable 1998
class Program
{
int F;
@@ -2150,41 +2145,41 @@ struct S { public int F; }
""";
CreateCompilation(source, options: TestOptions.UnsafeDebugExe).VerifyDiagnostics(
- // (11,20): error CS0212: You can only take the address of an unfixed expression inside of a fixed statement initializer
+ // (10,20): error CS0212: You can only take the address of an unfixed expression inside of a fixed statement initializer
// int* ptr = &prog.F; // 1
- Diagnostic(ErrorCode.ERR_FixedNeeded, "&prog.F").WithLocation(11, 20),
- // (15,26): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
+ Diagnostic(ErrorCode.ERR_FixedNeeded, "&prog.F").WithLocation(10, 20),
+ // (14,26): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
// int* localPtr = &local; // 2
- Diagnostic(ErrorCode.WRN_AddressOfInAsync, "local").WithLocation(15, 26),
- // (16,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
+ Diagnostic(ErrorCode.WRN_AddressOfInAsync, "local").WithLocation(14, 26),
+ // (15,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
// fixed (int* localPtr1 = &local) { } // 3, 4
- Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&local").WithLocation(16, 33),
- // (16,34): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
+ Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&local").WithLocation(15, 33),
+ // (15,34): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
// fixed (int* localPtr1 = &local) { } // 3, 4
- Diagnostic(ErrorCode.WRN_AddressOfInAsync, "local").WithLocation(16, 34),
- // (19,26): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
+ Diagnostic(ErrorCode.WRN_AddressOfInAsync, "local").WithLocation(15, 34),
+ // (18,26): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
// int* innerPtr = &structLocal.F; // 5
- Diagnostic(ErrorCode.WRN_AddressOfInAsync, "structLocal.F").WithLocation(19, 26),
- // (20,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
+ Diagnostic(ErrorCode.WRN_AddressOfInAsync, "structLocal.F").WithLocation(18, 26),
+ // (19,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
// fixed (int* innerPtr1 = &structLocal.F) { } // 6, 7
- Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&structLocal.F").WithLocation(20, 33),
- // (20,34): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
+ Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&structLocal.F").WithLocation(19, 33),
+ // (19,34): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
// fixed (int* innerPtr1 = &structLocal.F) { } // 6, 7
- Diagnostic(ErrorCode.WRN_AddressOfInAsync, "structLocal.F").WithLocation(20, 34),
- // (33,39): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
+ Diagnostic(ErrorCode.WRN_AddressOfInAsync, "structLocal.F").WithLocation(19, 34),
+ // (32,39): warning CS9123: The '&' operator should not be used on parameters or local variables in async methods.
// int* localFuncLocalPtr = &localFuncLocal; // 8
- Diagnostic(ErrorCode.WRN_AddressOfInAsync, "localFuncLocal").WithLocation(33, 39));
+ Diagnostic(ErrorCode.WRN_AddressOfInAsync, "localFuncLocal").WithLocation(32, 39));
CreateCompilation(source, options: TestOptions.UnsafeDebugExe.WithWarningLevel(7)).VerifyDiagnostics(
- // (11,20): error CS0212: You can only take the address of an unfixed expression inside of a fixed statement initializer
+ // (10,20): error CS0212: You can only take the address of an unfixed expression inside of a fixed statement initializer
// int* ptr = &prog.F; // 1
- Diagnostic(ErrorCode.ERR_FixedNeeded, "&prog.F").WithLocation(11, 20),
- // (16,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
+ Diagnostic(ErrorCode.ERR_FixedNeeded, "&prog.F").WithLocation(10, 20),
+ // (15,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
// fixed (int* localPtr1 = &local) { } // 3, 4
- Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&local").WithLocation(16, 33),
- // (20,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
+ Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&local").WithLocation(15, 33),
+ // (19,33): error CS0213: You cannot use the fixed statement to take the address of an already fixed expression
// fixed (int* innerPtr1 = &structLocal.F) { } // 6, 7
- Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&structLocal.F").WithLocation(20, 33));
+ Diagnostic(ErrorCode.ERR_FixedNotNeeded, "&structLocal.F").WithLocation(19, 33));
}
[Fact]
@@ -4905,9 +4900,6 @@ async void M() {}
// CONSIDER: It would be nice if we didn't squiggle the whole method body, but this is a corner case.
comp.VerifyEmitDiagnostics(
- // (4,16): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async void M() {}
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 16),
// (4,20): error CS0518: Predefined type 'System.Runtime.CompilerServices.AsyncVoidMethodBuilder' is not defined or imported
// async void M() {}
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "{}").WithArguments("System.Runtime.CompilerServices.AsyncVoidMethodBuilder").WithLocation(4, 20),
@@ -4933,9 +4925,6 @@ async Task M() {}
}";
var comp = CSharpTestBase.CreateEmptyCompilation(source, new[] { Net40.References.mscorlib }, TestOptions.ReleaseDll); // NOTE: 4.0, not 4.5, so it's missing the async helpers.
comp.VerifyEmitDiagnostics(
- // (4,16): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async Task M() {}
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "M").WithLocation(4, 16),
// (4,20): error CS0518: Predefined type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder' is not defined or imported
// async Task M() {}
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "{}").WithArguments("System.Runtime.CompilerServices.AsyncTaskMethodBuilder").WithLocation(4, 20),
@@ -4964,9 +4953,6 @@ class C
}";
var comp = CSharpTestBase.CreateEmptyCompilation(source, new[] { Net40.References.mscorlib }, TestOptions.ReleaseDll); // NOTE: 4.0, not 4.5, so it's missing the async helpers.
comp.VerifyEmitDiagnostics(
- // (4,21): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // async Task F() => 3;
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "F").WithLocation(4, 21),
// (4,25): error CS0518: Predefined type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1' is not defined or imported
// async Task F() => 3;
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "=> 3").WithArguments("System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1").WithLocation(4, 25),
@@ -7521,15 +7507,8 @@ private static ref long ReadMemory()
}
}
";
- var diags = new[]
- {
- // (12,30): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
- // public static async Task CompletedTask()
- Diagnostic(ErrorCode.WRN_AsyncLacksAwaits, "CompletedTask").WithLocation(12, 30)
- };
-
- CompileAndVerify(source, options: TestOptions.DebugExe, verify: Verification.Skipped, expectedOutput: "0123").VerifyDiagnostics(diags);
- CompileAndVerify(source, options: TestOptions.ReleaseExe, verify: Verification.Skipped, expectedOutput: "0123").VerifyDiagnostics(diags);
+ CompileAndVerify(source, options: TestOptions.DebugExe, verify: Verification.Skipped, expectedOutput: "0123").VerifyDiagnostics();
+ CompileAndVerify(source, options: TestOptions.ReleaseExe, verify: Verification.Skipped, expectedOutput: "0123").VerifyDiagnostics();
}
[Fact, WorkItem(40251, "https://github.com/dotnet/roslyn/issues/40251")]
@@ -9205,7 +9184,6 @@ public static async Task Handler()
}
}
- #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public static async Task Throw(int value) => throw new IntegerException(value);
}
@@ -9312,7 +9290,6 @@ public static Task