I have created my own way to essentially set ConfigureAwait(false) just once at the top of each async method which allows me to not have to append ConfigureAwait(false) at the end of each await call. Now I can just do something like:
public async Task MyMethod()
{
await ConfigureAwait.Off;
var data = await _client.GetDataAsync();
}
Here's the problem: I have a very large solution and I'm now trying to find an efficient way to add this to any async method and remove any redundant .ConfigureAwait(false) calls. I've tried Resharper's search for pattern without any luck at all. Any ideas or suggestions are greatly appreciated.
This below doesn't work good at all using resharpers Search for Pattern:
Search Pattern:
public async Task $method$($args1$) { $stmt$ }
Replace Pattern:
public async Task $method$($args1$)
{
await ConfigureAwait.Off;
$stmt$
}
Note: This also doesn't account for async methods that may already have it defined already as well as removing any redundant .ConfigureAwait(false);