AsyncGenerator icon indicating copy to clipboard operation
AsyncGenerator copied to clipboard

Convert boolean expression to if statements to reduce async/await generation

Open hazzik opened this issue 6 years ago • 0 comments

public bool AMethod() 
{
      return someSimpleCondition || AnotherMethod();
}

Now would be generated to:

public async Task<bool> AMethodAsync() 
{
      return someSimpleCondition || await AnotherMethodAsync();
}

Would be nice to generate following:

public Task<bool> AMethodAsync() 
{
      // wrapped in cancellation token & exception handling bolierplate code.
      if (someSimpleCondition)
           return Task.FromResult(true);
      return AnotherMethodAsync();
}

hazzik avatar Apr 12 '19 00:04 hazzik