-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace EcoCode.LiveWarnings; | ||
|
||
internal static class ReturnTaskDirectly | ||
{ | ||
public static Task DontWarnWhenReturningTask1() => Task.Delay(0); | ||
public static Task DontWarnWhenReturningTask2() | ||
{ | ||
return Task.Delay(0); | ||
} | ||
public static Task DontWarnWhenReturningTask3() | ||
{ | ||
Console.WriteLine(); | ||
return Task.Delay(0); | ||
} | ||
|
||
public static async Task DontWarnWithMultipleStatements1Async() | ||
{ | ||
Console.WriteLine(); | ||
await Task.Delay(0).ConfigureAwait(false); | ||
} | ||
public static async Task DontWarnWithMultipleStatements2Async() | ||
{ | ||
await Task.Delay(0).ConfigureAwait(false); | ||
await Task.Delay(0).ConfigureAwait(false); | ||
} | ||
|
||
public static async Task WarnOnSingleAwaitExpressionAsync() => // EC93 | ||
// Comment | ||
await Task.Delay(0).ConfigureAwait(false); | ||
|
||
public static async Task WarnOnSingleAwaitBody1Async() // EC93 | ||
{ | ||
// Comment 0 | ||
await Task.Delay(0).ConfigureAwait(false); // Comment 1 | ||
// Comment 2 | ||
} | ||
|
||
public static async Task<int> WarnOnSingleAwaitBody2Async() // EC93 | ||
{ | ||
// Comment 0 | ||
return await Task.FromResult(0).ConfigureAwait(false); // Comment 1 | ||
// Comment 2 | ||
} | ||
|
||
public static async Task DontWarnOnNestedAwaitExpressionAsync() => | ||
await Task.Delay(await Task.FromResult(0).ConfigureAwait(false)).ConfigureAwait(false); | ||
|
||
public static async Task DontWarnOnNestedAwaitBodyAsync() | ||
{ | ||
await Task.Delay(await Task.FromResult(0).ConfigureAwait(false)).ConfigureAwait(false); | ||
} | ||
} |