dotnet / dotnet/roslynator

Detect implicit conversion of async delegates

Open
#614 4 comments 0 reactions 0 assignees View on GitHub
Area-Analyzers Feature Request
Dominant language
C#
Stars
3.5k
Forks
294
Avg merge
2h 30m
Merged PRs (30d)
4

Description

To complement [CS4014](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs4014) that detects `async` calls not `await`'ed, it could be nice to have an analyzer to detect implicit conversions from async delegates to sync ones.

```csharp
async Task FooAsync(Func func)
{
await Task.Delay(0);
func(); // the async delegate is not await'ed!
}

Task BarAsync(Func func)
{
return FooAsync(func); // implicit conversion to Func
}
```

It's not always easily detectable using Intellisense
![image](https://user-images.githubusercontent.com/919634/67692328-489f6500-f9a0-11e9-829e-77f1aa60d50a.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.