From 87ddfd76dc72805bea62a9667d13b05ee6e76bef Mon Sep 17 00:00:00 2001 From: dadhi Date: Thu, 16 Feb 2023 11:09:26 +0100 Subject: [PATCH] fixed: #557 --- src/DryIoc/Container.cs | 2 +- ...elector_allows_to_Resolve_the_keyed_service_as_non_keyed.cs | 3 +-- test/DryIoc.TestRunner/Program.cs | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DryIoc/Container.cs b/src/DryIoc/Container.cs index f7b71036..ccbc5025 100644 --- a/src/DryIoc/Container.cs +++ b/src/DryIoc/Container.cs @@ -1176,7 +1176,7 @@ private Factory GetRuleSelectedServiceFactoryOrDefault(Rules rules, // optimize for the case with the single factory if (factories.Length == 1) return request.MatchFactoryConditionAndMetadata(details, factories[0].Value) - ? rules.FactorySelector(request, factories[0].Value, null) + ? rules.FactorySelector(request, null, factories) : null; // Sort in registration order diff --git a/test/DryIoc.IssuesTests/GHIssue557_WithFactorySelector_allows_to_Resolve_the_keyed_service_as_non_keyed.cs b/test/DryIoc.IssuesTests/GHIssue557_WithFactorySelector_allows_to_Resolve_the_keyed_service_as_non_keyed.cs index 7c3042c5..6ddb8385 100644 --- a/test/DryIoc.IssuesTests/GHIssue557_WithFactorySelector_allows_to_Resolve_the_keyed_service_as_non_keyed.cs +++ b/test/DryIoc.IssuesTests/GHIssue557_WithFactorySelector_allows_to_Resolve_the_keyed_service_as_non_keyed.cs @@ -1,4 +1,3 @@ -using System; using NUnit.Framework; namespace DryIoc.IssuesTests @@ -16,7 +15,7 @@ public int Run() public void Test1() { var rules = Rules.Default - // .WithFactorySelector(Rules.SelectLastRegisteredFactory()) + .WithFactorySelector(Rules.SelectLastRegisteredFactory()) .WithConcreteTypeDynamicRegistrations(reuse: Reuse.Transient) .With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments)) .WithFuncAndLazyWithoutRegistration() diff --git a/test/DryIoc.TestRunner/Program.cs b/test/DryIoc.TestRunner/Program.cs index a5327401..eb97fd1b 100644 --- a/test/DryIoc.TestRunner/Program.cs +++ b/test/DryIoc.TestRunner/Program.cs @@ -69,7 +69,8 @@ void Run(Func run, string name = null) new GHIssue532_WithUseInterpretation_still_use_DynamicMethod_and_ILEmit(), new GHIssue536_DryIoc_Exception_in_a_Constructor_of_a_Dependency_does_tunnel_through_Resolve_call(), new GHIssue546_Generic_type_constraint_resolution_doesnt_see_arrays_as_IEnumerable(), - new GHIssue554_System_NullReferenceException_Object_reference_not_set_to_an_instance_of_an_object() + new GHIssue554_System_NullReferenceException_Object_reference_not_set_to_an_instance_of_an_object(), + new GHIssue557_WithFactorySelector_allows_to_Resolve_the_keyed_service_as_non_keyed(), }; // Parallel.ForEach(tests, x => Run(x.Run)); // todo: @perf enable and test when more tests are added