This is an implementation of a ReSharper Plugin that converts your synchronous code to its asynchronous version and helps you to write your own asynchronous applications.
AsyncConverter can:
- Replace a returning type with generic or non-generic
Task<T>
orTask
- Rename a hierarchy of overridden methods from <MethodName> to <MethodName>Async
- Add the
System.Threading.Tasks
to a usings declaration - Analyze a method body and replace the every synchronous call with its
async
implementation if exists. - Analyze a method body and replace the every
.Result
call with theawait
call. - Analyze usage of a processed method. If the method is called from
async
context the AsyncConverter will replace its call with theawait
expression, otherwise it will just call.Result
or.Wait()
Converter method to async demo
![Converter method to async](ReadMe/MethodToAsyncConverter.gif)
Under async
method replace Wait()
and Result
to await
.
Replace wait to await demo
![Replace wait to await](ReadMe/ReplaceWait.gif)
Replace result to await demo
![Replace result to await](ReadMe/ReplaceResult.gif)
If expected returning type is Task
or Task<T>
but null is returned instead, AsyncConverter warn you that execution point can await expected 'Task' and get NullReferenceException
.
Return null as task demo
![Return null as task](ReadMe/ReturnNullAsTask.gif)
AsyncConverter will suggest you to add the Async
suffix to an asynchronous method name in all cases except:
- Classes inherited from
Controller
orApiController
- Methods of test classes. NUnit, XUnit and MsUnit are supported. This may be turn off in Resharper → Options → Code Inspection → Async Converter → Async Suffix
Suggesting method name with Async suffix demo
![Suggesting method name with Async suffix](ReadMe/Naming.gif)
Suggesting ConfigureAwait demo
![Suggesting ConfigureAwait](ReadMe/ConfigureAwait.gif)
If a synchronous method is called in the async context and its asynchronous implementation exists (e.g method has same signature Async
suffix and Task
or Task<T>
as the returning type) AsyncConverter will suggest you to use this asynchronous implementation.
Do not suggest to use obsolete async methods.
Suggesting method name with Async suffix demo
![Suggesting method name with Async suffix](ReadMe/CanBeUseAsyncMethod.gif)
An await
expression can be ignored if this await
expression is the single in a method and awaited value is returned from a method.
Async/await ignoring demo
![Async/await ignoring](ReadMe/AsyncAwaitMayBeElided.gif)