Closed rossmasday closed 2 years ago
@gasparnagy what do you say about this PR?
Will check it tomorrow
I believe I have made the changes you require, I also did some refactoring and code improvements as well that should make it easier to extend for other scenarios and slightly easier to read, mainly that all finder methods are Func<ContainerBuilder, ContainerBuilder>
this allows for a more fluent call signature and removes the issue where I had to return Object
instead of void
quirk of MethodInfo.Invoke()
. It would have been cleaner to use Action<ContainerBuilder>
instead but that obviously doesnt work with the legacy method and I did not want to have two FindMethods that were basically Identical.
As per your suggestion the two new methods have the same signature, the old one is still available,
I noticed because the container in the original method is not registered with the internal Specflow container, it does not appear to have it's dispose method called, so I registered it and resolved it so that process is now invoked. I hope this will not introduce any issues, I would be surprised if it did, but I can remove it too if you prefer.
I added a couple of helper extension methods as well, if you're not keen on them I am happy to remove them.
I have also tagged the child scopes in line with the contexts, so if someone wanted to, they could scope registrations at any level instead of needing a new a new attribute in the future, as long as they registered these in the Global configuration. Like so:
containerBuilder.RegisterType<MyType>().InstancePerMatchingLifetimeScope(nameof(FeatureContext))
Happy to discuss more if you need, thanks
Thanks for the review, I've updated the docs as requested. Wasn't sure about the version number for the change log so guessed what it would be
Thanks for your contribution to SpecFlow. Please submit your contributions to our SpecFlow Community Heroes program at https://specflow.org/community/submit-a-contribution/
Builds should be finished overnight and I will push new packages to NuGet.org tomorrow morning.
…tional Attribute and two new method signatures.
Types of changes
Checklist: