Giter VIP home page Giter VIP logo

asyncconverter's Introduction

AsyncConverter

This is an implementation of a ReSharper Plugin that converts your synchronous code to it's asynchronous version and helps you to write your own asynchronous applications.

Convert Any Method to It's Async Implementation

AsyncConverter can:

  1. Replace a returning type with generic or non-generic Task<T> 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 it's 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 it's call with the await expression, otherwise it will just call .Result or .Wait()

Replacing Value

Highlightings

Value Replacement

In case that an expected returning type is Task<int> but an actual returning type is int, AsyncConverter will notice you that you can wrap a returning value with Task.FromResult().

Replacing Value

Return null as Task

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

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

Suggesting to configure an every await expression with ConfigureAwait

Suggesting ConfigureAwait

Suggesting to use the async method if exists

If a synchronous method is called in the async context and it's asynchronous implementation is 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

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.

Suggesting method name with Async suffix

asyncconverter's People

Contributors

bigbabay avatar bbrandt avatar jeremymorton avatar citizenmatt avatar obkdev avatar

Stargazers

高亚斌 avatar

Watchers

高亚斌 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.