Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/ignorecase opengenerics #471

Merged
merged 2 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/LightInject.Tests/OpenGenericTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ public void GetInstance_NoMatchingOpenGeneric_ThrowsException()
var container = CreateContainer();

Assert.Throws<InvalidOperationException>(() => container.GetInstance<IFoo<int>>());


}

[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<IFoo<int>>("somefoo");

Assert.IsType<Foo<int>>(instance);
}
}
}
2 changes: 1 addition & 1 deletion src/LightInject/LightInject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4462,7 +4462,7 @@ private Action<IEmitter> CreateEmitMethodBasedOnClosedGenericServiceRequest(Type
var openGenericServiceRegistrations =
GetOpenGenericServiceRegistrations(openGenericServiceType);

Dictionary<string, (Type closedGenericImplentingType, ILifetime lifetime)> candidates = new Dictionary<string, (Type closedGenericImplentingType, ILifetime lifetime)>();
Dictionary<string, (Type closedGenericImplentingType, ILifetime lifetime)> candidates = new Dictionary<string, (Type closedGenericImplentingType, ILifetime lifetime)>(StringComparer.OrdinalIgnoreCase);

foreach (var openGenericServiceRegistration in openGenericServiceRegistrations.Values)
{
Expand Down
2 changes: 1 addition & 1 deletion src/LightInject/LightInject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- <TargetFrameworks>net46;netstandard1.1;netstandard1.3;netstandard1.6;netstandard2.0;netcoreapp2.0;net452</TargetFrameworks> -->
<TargetFrameworks>netcoreapp2.0;netstandard2.0;netstandard1.6;netstandard1.3;netstandard1.1;net46;net452</TargetFrameworks>
<Version>5.3.0</Version>
<Version>5.4.0</Version>
<Authors>Bernhard Richter</Authors>
<PackageProjectUrl>http//www.lightinject.net</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
Expand Down