Skip to content

Commit 6817e57

Browse files
committed
fixed: #412 and adding the release notes for the v4.8.1
1 parent 3e88598 commit 6817e57

File tree

8 files changed

+45
-13
lines changed

8 files changed

+45
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DryIoc is fast, small, full-featured IoC Container for .NET
3030
- __DryIoc__ (source code) [![NuGet Badge](https://buildstats.info/nuget/DryIoc)](https://www.nuget.org/packages/DryIoc)
3131
- __DryIoc.Internal__ (source code with public types made internal) [![NuGet Badge](https://buildstats.info/nuget/DryIoc.Internal)](https://www.nuget.org/packages/DryIoc.Internal)
3232

33-
- [Release Notes](https://github.com/dadhi/DryIoc/releases/tag/v4.8.0) :: [Previous Versions](https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/VersionHistory.md)
33+
- [Release Notes](https://github.com/dadhi/DryIoc/releases/tag/v4.8.1) :: [Previous Versions](https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/VersionHistory.md)
3434
- [Extensions and Companions](Extensions.md)
3535
- [Documentation][WikiHome]
3636
- [Contribution guide](CONTRIBUTING.md)

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 4.8.0-preview-01-b{build}
1+
version: 4.8.1-preview-01-b{build}
22
os: Visual Studio 2017
33
test: off
44

docs/DryIoc.Docs/VersionHistory.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Version History
22
---------------
33

4+
## v4.8.1 Bug-fix release / 2021-07-03
5+
6+
- fixed: #412 ResolveMany not work with generics after any Unregister
7+
48
## v4.8.0 Small feature release / 2021-06-04
59

610
- added: #406 Allow the registration of the partially closed implementation type

nuspecs/DryIoc.Internal.nuspec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata minClientVersion="3.3.0">
44
<id>DryIoc.Internal</id>
5-
<version>4.8.0</version>
5+
<version>4.8.1</version>
66
<authors>Maksim Volkau</authors>
77
<copyright>Copyright © 2013-2021 Maksim Volkau</copyright>
88
<projectUrl>https://github.com/dadhi/DryIoc</projectUrl>
@@ -14,6 +14,11 @@
1414
<tags>IoC Container Inversion-of-Control DI Dependency-Injection DRY Service-Provider Factory</tags>
1515
<releaseNotes>
1616
<![CDATA[
17+
18+
## v4.8.1 Bug-fix release
19+
20+
- fixed: #412 ResolveMany not work with generics after any Unregister
21+
1722
## v4.8.0 Small feature release
1823
1924
- added: #406 Allow the registration of the partially closed implementation type

nuspecs/DryIoc.nuspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata minClientVersion="3.3.0">
44
<id>DryIoc</id>
5-
<version>4.8.0</version>
5+
<version>4.8.1</version>
66
<authors>Maksim Volkau</authors>
77
<copyright>Copyright © 2013-2021 Maksim Volkau</copyright>
88
<projectUrl>https://github.com/dadhi/DryIoc</projectUrl>
@@ -14,6 +14,10 @@
1414
<tags>IoC Container Inversion-of-Control DI Dependency-Injection DRY Service-Provider Factory</tags>
1515
<releaseNotes>
1616
<![CDATA[
17+
## v4.8.1 Bug-fix release
18+
19+
- fixed: #412 ResolveMany not work with generics after any Unregister
20+
1721
## v4.8.0 Small feature release
1822
1923
- added: #406 Allow the registration of the partially closed implementation type

src/DryIoc/Container.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ IEnumerable<object> IResolver.ResolveMany(Type serviceType, object serviceKey,
597597
requiredItemType = unwrappedType;
598598

599599
var items = container.GetAllServiceFactories(requiredItemType).ToArrayOrSelf()
600-
.Where(x => x.Value != null)
600+
.Where(x => x.Value != null) // filter out unregistered services
601601
.Select(f => new ServiceRegistrationInfo(f.Value, requiredServiceType, f.Key));
602602

603603
IEnumerable<ServiceRegistrationInfo> openGenericItems = null;
@@ -639,11 +639,9 @@ IEnumerable<object> IResolver.ResolveMany(Type serviceType, object serviceKey,
639639
{
640640
items = items.Where(x => x.Factory.Setup.MatchesMetadata(metadataKey, metadata));
641641
if (openGenericItems != null)
642-
openGenericItems = openGenericItems
643-
.Where(x => x.Factory.Setup.MatchesMetadata(metadataKey, metadata));
642+
openGenericItems = openGenericItems.Where(x => x.Factory.Setup.MatchesMetadata(metadataKey, metadata));
644643
if (variantGenericItems != null)
645-
variantGenericItems = variantGenericItems
646-
.Where(x => x.Factory.Setup.MatchesMetadata(metadataKey, metadata));
644+
variantGenericItems = variantGenericItems.Where(x => x.Factory.Setup.MatchesMetadata(metadataKey, metadata));
647645
}
648646

649647
// Exclude composite parent service from items, skip decorators
@@ -2277,11 +2275,12 @@ public IEnumerable<ServiceRegistrationInfo> GetServiceRegistrations()
22772275
{
22782276
foreach (var entry in Services.Enumerate())
22792277
{
2280-
if (entry.Value.Value is Factory factory)
2278+
var fe = entry.Value.Value;
2279+
if (fe is Factory factory)
22812280
yield return new ServiceRegistrationInfo(factory, entry.Value.Key, null);
2282-
else
2281+
else if (fe != null) // maybe `null` for the unregistered service, see #412
22832282
{
2284-
var factories = ((FactoriesEntry)entry.Value.Value).Factories;
2283+
var factories = ((FactoriesEntry)fe).Factories;
22852284
foreach (var f in factories.Enumerate())
22862285
yield return new ServiceRegistrationInfo(f.Value, entry.Value.Key, f.Key);
22872286
}

src/DryIoc/DryIoc.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFrameworks Condition="'$(NoLegacy)' == 'true'">net45;netstandard1.0;netstandard1.3;netstandard2.0</TargetFrameworks>
66

77
<Product>DryIoc</Product>
8-
<VersionPrefix>4.8.0</VersionPrefix>
8+
<VersionPrefix>4.8.1</VersionPrefix>
99
<VersionSuffix></VersionSuffix>
1010

1111
<AssemblyName>$(Product)</AssemblyName>
@@ -17,6 +17,10 @@
1717
<PackageTags>IoC Container Inversion-of-Control DI Dependency-Injection DRY Service-Provider Factory FastExpressionCompiler ImTools</PackageTags>
1818
<PackageReleaseNotes>
1919
<![CDATA[
20+
## v4.8.1 Bug-fix release
21+
22+
- fixed: #412 ResolveMany not work with generics after any Unregister
23+
2024
## v4.8.0 Small feature release
2125
2226
- added: #406 Allow the registration of the partially closed implementation type

test/DryIoc.UnitTests/UnregisterTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using DryIoc.UnitTests.CUT;
34
using NUnit.Framework;
45

@@ -472,5 +473,20 @@ public interface IN { }
472473
public class M : IM, IN { }
473474
public class N : IM, IN { }
474475

476+
[Test]
477+
public void Test_issue_412_resolving_open_generics_collection_after_Unregister()
478+
{
479+
var container = new Container();
480+
481+
container.Register<NonRelevantService>();
482+
container.Unregister<NonRelevantService>();
483+
484+
var genericHandlers = container.ResolveMany<IHandler<X>>();
485+
Assert.AreEqual(0, genericHandlers.Count());
486+
}
487+
488+
public interface IHandler<T> { }
489+
public class X { }
490+
public class NonRelevantService { }
475491
}
476492
}

0 commit comments

Comments
 (0)