In VS2019, is it possible to change a method's signature to return a Task or Task<T> and make all upstream callers async as well in a cascading manner?
In VS2019, is it possible to change a method's signature to return a Task or Task<T> and make all upstream callers async as well in a cascading manner?
In VS2019, is it possible to change a method's signature to return a Task or Task...
Short answer is No.
For one can refactor the name of the method and if you choose the intellisense option to rename, the name will be changed for the callers, but it will not handle any of the async needs you are wanting. In other words the refactoring is not async aware.
In order to be asynchronous, a method needs to be marked as async and to return either a Task or a Task. We could change it like this:
//previously:
public int Something()
{
int something = ...;
return something;
}
//now
public async Task<int> Something()
{
int something = ...;
return await Task.FromResult(something);
}
Mind you, this does not make it inherently asynchronous, it just takes care of the signature of it.