ErrorProne.NET
ErrorProne.NET copied to clipboard
Async rules
- Warn on
async void
- Warn on
Task.Result
/Task.Wait
preferTask.GetAwaiter().GetResult
because later will unwrap exception. Question: how to catch correct cases? - Warn on incorrect preconditions in async methods
Add checks for naming rules. Wanr if async method doesn't have Async
suffic or when non-async method has it (note, EAP could have the same suffic!).
Non-synchronous preconditions in async methods.
Warn on exception from async void method.
Warn on run, Task.Factory.StartNew(async () => await Something)
Analyze if an assembly defines an attribute like RequireConfigureAwait(true/false)
and warn/enforce this thing.
Warn if TaskCompletionSource
instance is constructed without TaskCreationOptions
that forces continuation to run asynchronously.
Warn for _myStuff?.FooAsync()
. This is never a good idea, because you'll end up with null
task that you can't await or can't call GetAwaiter().GetResult()
on.
Consider implementing these rules in Microsoft/vs-threading, which includes a number of analyzers related to this space. The analyzers are intended for use with or without the supporting library.