From fdeeefd918279dbd7d1b5d63c004e0e6e992cd6a Mon Sep 17 00:00:00 2001 From: Bernhard Richter Date: Thu, 24 Jan 2019 14:08:53 +0100 Subject: [PATCH 1/2] Fixed service name casing for open generics --- src/LightInject.Tests/OpenGenericTests.cs | 14 +++++++++++++- src/LightInject/LightInject.cs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/LightInject.Tests/OpenGenericTests.cs b/src/LightInject.Tests/OpenGenericTests.cs index af0b3f40..2eb24150 100644 --- a/src/LightInject.Tests/OpenGenericTests.cs +++ b/src/LightInject.Tests/OpenGenericTests.cs @@ -89,7 +89,19 @@ public void GetInstance_NoMatchingOpenGeneric_ThrowsException() var container = CreateContainer(); Assert.Throws(() => container.GetInstance>()); - + + } + + [Fact] + public void GetInstance_NamedOpenGenerics_IgnoresCaseOnServiceNames() + { + var container = CreateContainer(); + container.Register(typeof(IFoo<>), typeof(Foo<>), "SomeFoo"); + container.Register(typeof(IFoo<>), typeof(AnotherFoo<>), "AnotherFoo"); + + var instance = container.GetInstance>("somefoo"); + + Assert.IsType>(instance); } } } \ No newline at end of file diff --git a/src/LightInject/LightInject.cs b/src/LightInject/LightInject.cs index 5c16a551..1387f930 100644 --- a/src/LightInject/LightInject.cs +++ b/src/LightInject/LightInject.cs @@ -4462,7 +4462,7 @@ private Action CreateEmitMethodBasedOnClosedGenericServiceRequest(Type var openGenericServiceRegistrations = GetOpenGenericServiceRegistrations(openGenericServiceType); - Dictionary candidates = new Dictionary(); + Dictionary candidates = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var openGenericServiceRegistration in openGenericServiceRegistrations.Values) { From 3d10a34382b7baf82ee9a09c602c4894c28b1d83 Mon Sep 17 00:00:00 2001 From: Bernhard Richter Date: Thu, 24 Jan 2019 14:10:59 +0100 Subject: [PATCH 2/2] Bumped to 5.4.0 --- src/LightInject/LightInject.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LightInject/LightInject.csproj b/src/LightInject/LightInject.csproj index 700d7bda..2d6f3c0c 100644 --- a/src/LightInject/LightInject.csproj +++ b/src/LightInject/LightInject.csproj @@ -2,7 +2,7 @@ netcoreapp2.0;netstandard2.0;netstandard1.6;netstandard1.3;netstandard1.1;net46;net452 - 5.3.0 + 5.4.0 Bernhard Richter http//www.lightinject.net git