Roslyn Diagnostics and Code Fixes

Together with my colleague Ricardo, I put together a set of Roslyn code diagnostics that enforce some best practices when dealing with async code in C#/.NET.

To make use of them, you need the latest CTP of Visual Studio 2015.

The source code for the diagnostics and fixes is over at GitHub: https://github.com/olohmann/AsyncAwaitAnalyzer

You can pull in a NuGet Package to use them directly in a VS2015 project:

Install-Package AsyncAwaitAnalyzer -Pre

When things have stablized (i.e. VS2015 goes RTM), I will push a VSIX to the Visual Studio Gallery, too.

Included Diagnostics

  • ASYNC-0001 - Avoid async void signatures. This diagnostic verifies that async void method declarations are only used on event handlers.
  • ASYNC-0002 - Use async method naming style. This diagnostic enforces a ‘Async’ suffix for methods doing async work.
  • ASYNC-0003 - Use ConfigureAwait in library code. This diagnostic verifies that CongfigureAwait(false) is used in library code.

Included Code Fixes

  • Fix for ASYNC-0002.
 
comments powered by Disqus