You are designing an interface IFoo
public interface IFoo
{
void Bar();
}
Let’s say there are five implementations of this interface. Two of those implementations should also implement IDisposable as they use unmanaged resources. From a caller’s perspective, it would be easiest if IFoo implemented IDisposable so any IFoo can be wrapped in a using block, but of course some of the implementations would then be littered with empty Dispose() methods. Just curious are there other ways of doing this?
I suspect I’d simply demand
IDisposable()– a no-opDispose()isn’t a big overhead.If you can’t be sure whether it is disposable, the following is pretty effective: