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 b
I know this is an old thread, and perhaps this won't have the right effect for all usages, but the following is as close as I can get to being able to simply throw a NotImplementedException when I haven't yet implemented a method, without altering the method signature. If it's problematic I'd be happy to know about it, but it barely matters to me: I only use this while in development anyway, so how it performs isn't all that important. Still, I'd be happy to hear about why it's a bad idea, if it is.
public async Task
Here's the type I added to make that possible.
public class AwaitableNotImplementedException : NotImplementedException
{
public AwaitableNotImplementedException() { }
public AwaitableNotImplementedException(string message) : base(message) { }
// This method makes the constructor awaitable.
public TaskAwaiter> GetAwaiter()
{
throw this;
}
}