You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our legacy code has many syncronous operations that can be made asyncronous. For example:
var result = someHttpService.DoOperation();
can be refactored with TAP:
var result = await someHttpService.DoOperationAsync().ConfigureAwait(false);
AsyncConverter does best job here.
But we cannot fully refactor that code to async code automatically for now because of all our methods should be rewritten with async/await.
We decided to refactor with TAP where possible:
string SomeLegacySynchronousCodeThatCannotBeRefactoredToTapForTheMoment()
{
var result = someHttpService.DoOperationAsync().GetAwaiter().GetResult();
return result;
}
When containing method SomeLegacySynchronousCodeThatCannotBeRefactoredToTapForTheMoment will be refactored in future with TAP, it is possible to detect method calls GetAwaiter().GetResult() stuff and suggest to change it to await Method().ConfigureAwait(false).
Task<string> SomeRewrittenLegacyAsync()
{
var result = someHttpService.DoOperationAsync().GetAwaiter().GetResult();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
suggest to remove GetAwaiter().GetResult(), add await instead
return result;
}
What do you think?
Is it hard to implement?
The text was updated successfully, but these errors were encountered:
Hi! Thanks for great plugin!
Our legacy code has many syncronous operations that can be made asyncronous. For example:
can be refactored with TAP:
AsyncConverter does best job here.
But we cannot fully refactor that code to async code automatically for now because of all our methods should be rewritten with async/await.
We decided to refactor with TAP where possible:
When containing method
SomeLegacySynchronousCodeThatCannotBeRefactoredToTapForTheMoment
will be refactored in future with TAP, it is possible to detect method callsGetAwaiter().GetResult()
stuff and suggest to change it toawait Method().ConfigureAwait(false)
.What do you think?
Is it hard to implement?
The text was updated successfully, but these errors were encountered: