Consider the following interface:
public interface IProvider
{
Task<bool> Contains(string key);
}
This is implementation satisfies Visual Studio
public Task<bool> Contains(string key)
{
return Task.FromResult(false);
}
This implementation is convenient to write and would seem to achieve the same thing:
public async Task<bool> Contains(string key)
{
return false;
}
However, Visual Studio throws a hissy-fit and insists:
This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await TaskEx.Run(...)' to do CPU-bound work on a background thread.
I'd love to just ignore that warning and avoid using Task.FromResult(...).
Are there any negative consequences to using the latter option?