Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BigBabay/AsyncConverter
Plugin for resharper, for converting code for async.
https://github.com/BigBabay/AsyncConverter
Last synced: 7 days ago
JSON representation
Plugin for resharper, for converting code for async.
- Host: GitHub
- URL: https://github.com/BigBabay/AsyncConverter
- Owner: BigBabay
- License: mit
- Created: 2016-10-16T08:28:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-07T21:39:44.000Z (over 1 year ago)
- Last Synced: 2024-08-02T16:53:22.729Z (3 months ago)
- Language: C#
- Size: 1.12 MB
- Stars: 176
- Watchers: 14
- Forks: 30
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AsyncConverter
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.
## Convert Any Method to Its Async Implementation
AsyncConverter can:
1. Replace a returning type with generic or non-generic `Task` or `Task`
2. Rename a hierarchy of overridden methods from _<MethodName>_ to _<MethodName>Async_
3. Add the `System.Threading.Tasks` to a usings declaration
4. Analyze a method body and replace the every synchronous call with its `async` implementation if exists.
5. Analyze a method body and replace the every `.Result` call with the `await` call.
6. Analyze usage of a processed method. If the method is called from `async` context the AsyncConverter will replace its call with the `await` expression, otherwise it will just call `.Result` or `.Wait()`Converter method to async demo
![Converter method to async](ReadMe/MethodToAsyncConverter.gif)
## Highlightings
### Convert `Wait()` and `Result` to `await`
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)
### Return `null` as `Task`
If expected returning type is `Task` or `Task` 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)
### Async suffix in a method name
AsyncConverter will suggest you to add the `Async` suffix to an asynchronous method name in all cases except:
1. Classes inherited from `Controller` or `ApiController`
2. 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 to configure an every await expression with ConfigureAwait
Suggesting ConfigureAwait demo
![Suggesting ConfigureAwait](ReadMe/ConfigureAwait.gif)
### Suggesting to use the async method if exists
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` 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)
### Async/await ignoring
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)