I spend a large part of my day reviewing other people’s code. Seeing all this code over the years has brought me to at least one conclusion; software development is hard and multithreaded programming is even harder.
Although the introduction of the Task Parallel Library and the async/await keywords has helped to simplify multithreaded programming a lot, I still see developers making a lot of mistakes when using async/await.
A good code analyzer that I can recommend to avoid some of these mistakes is AsyncFixer.
It will help you to avoid the following anti-patterns:
- Unnecessary async/await Methods
- Using Long-running Operations under Async Methods
- Fire & Forget Async void Methods
- Fire & Forget Async Call In the Using Block
- Implicit Downcasting from Task<T> to Task
If you want to learn more about these and other mistakes, have a look at http://www.learnasync.net/.
Usage
The easiest way to start using it is by adding the AsyncFixer nuget package to your project.
After installing it, you get another code analyzer in your list of analyzers:
Now when you make a mistake, the refactoring tools in Visual Studio will prompt you to correct it: