You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code will throw even though IfUnresolved is set to ReturnDefaultIfNotRegistered:
classProgram{staticvoidMain(string[]args){varcontainer=newContainer();using(varscope=container.OpenScope()){varfoo=scope.Resolve<Foo>(IfUnresolved.ReturnDefaultIfNotRegistered);// Does not throwscope.UseInstance<Foo>(newFoo());// Do a registration within the scope}using(varscope=container.OpenScope()){varfoo=scope.Resolve<Foo>(IfUnresolved.ReturnDefaultIfNotRegistered);// Throws}}}
Since the registration happened within the first scope, I'd expect the second scope to simple be empty and not throw. Looking at the stack trace, the IfUnresolved parameter seems to get discarded half way through, and the code simply throws instead of checking if it should actually throw.
The text was updated successfully, but these errors were encountered:
I have fixed the issue in the upcoming v4.8.4 but going forward please use Use instead of UseInstance as the later will be removed in the next major version.
The following code will throw even though
IfUnresolved
is set toReturnDefaultIfNotRegistered
:Since the registration happened within the first scope, I'd expect the second scope to simple be empty and not throw. Looking at the stack trace, the
IfUnresolved
parameter seems to get discarded half way through, and the code simply throws instead of checking if it should actually throw.The text was updated successfully, but these errors were encountered: