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
When dealing with scoped instance resolution and dependency overrides, an inconsistency arises when attempting to resolve a service for the second time with different overrides. In the following example, I would expect both m2 and m3 to either throw an exception (the value of the dependency should be associated with the scope, and the override must match) or resolve to the first successful result. Perhaps a resolution option could be introduced to either ignore overrides if resolution is possible or throw on mismatch.
var c = new StashboxContainer();
c.RegisterScoped<Service>();
using (c.BeginScope())
{
var m = c.Resolve<Service>(["d1"]);
var m2 = c.Resolve<Service>(["d2"]); // returns instance with "d1"
var m3 = c.Resolve<Service>(); // ResolutionFailedException
var eq = m == m2;
}
public class Service
{
[Stashbox.Attributes.Dependency] // dependency is passed as a dependency override
public string Name;
}
The text was updated successfully, but these errors were encountered:
When dealing with scoped instance resolution and dependency overrides, an inconsistency arises when attempting to resolve a service for the second time with different overrides. In the following example, I would expect both m2 and m3 to either throw an exception (the value of the dependency should be associated with the scope, and the override must match) or resolve to the first successful result. Perhaps a resolution option could be introduced to either ignore overrides if resolution is possible or throw on mismatch.
The text was updated successfully, but these errors were encountered: