Fix: 889 DryIoC creating instances at point of registration #934
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Closes #889, but needs a look at as it feels dirty.
It stops the instant creation of objects during registration
But it also needs to use a cast because the factory func returns object, and DryIoC throws. So there's an expression used to do the casting.
The alternative might be to break the interface and add a generic Register method? (instead of the static extension that does to typeof(T) and ultimately ends up as Func<object?>)
I have also removed the NullServiceType registration as I can't see a way out of any pain of using it with DryIoC.
What is the current behavior?
objects registered via splat into DryIoc are instantly instantiated
What is the new behavior?
Delayed creation
What might this PR break?
Usages of null type registrations with DryIoC (but did it ever work correctly?)
Please check if the PR fulfills these requirements
Other information: