SpecFlow
SpecFlow copied to clipboard
Support IAsyncDisposable in bindings
Link to Feature Request
https://support.specflow.org/hc/en-us/community/posts/4410211637521-Support-IAsyncDisposable-in-bindings
Implementation Idea
Support for this needs to be implemented in BoDi, because that's what performs the actual disposal. To enable this, I've created https://github.com/SpecFlowOSS/BoDi/pull/51
If that PR gets accepted into BoDi, the minimal implementation of this feature in SpecFlow would just be to upgrade to the version of BoDi that supports IAsyncDisposable
.
However, it would be better to do slightly more than that, because in that minimal case, SpecFlow projects would continue to dispose containers using non-async IDisposable.Dispose
. And although https://github.com/SpecFlowOSS/BoDi/pull/51 does support disposing IAsyncDisposable
objects even when the container is disposed synchronously, this inevitably lead to "sync over async", which is best avoided.
So it would be better to modify SpecFlow so that when it disposes the BoDi container, it does so with IAsyncDisposable.DisposeAsync
, returning a Task
up to whichever test framework is in use. That way it's async
all the way up, and we avoid any risk of sync over async.
But it would be good to get a steer on whether you're actually interested in taking such a PR before I do the work!
Answered in the BoDi PR