I've got an interface with some async functions. Some of the classes that implements the interface does not have anything to await, and some might just throw. It's a bit annoying with all the warnings.
When not using await in a async function.
Is it possible to suppress the message?
public async Task<object> test()
{
throw new NotImplementedException();
}
warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
Another way to preserve the async keyword (in case you want to keep it) is to use:
Once you populate the method you can simply remove the statement. I use this a lot especially when a method might await something but not every implementation actually does.