SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.23k stars 752 forks source link

Support IAsyncDisposable in bindings #2575

Open idg10 opened 2 years ago

idg10 commented 2 years ago

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!

SabotageAndi commented 2 years ago

Answered in the BoDi PR