Skip to content

Commit

Permalink
[#474] [add] impl
Browse files Browse the repository at this point in the history
  • Loading branch information
i4004 committed Dec 14, 2022
1 parent 36c0219 commit b7db525
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [1.4.2] - 2022-12-14

### Fixed

- Ignore open generic types and types without implementation in container graph verification (#474)

## [1.4.1] - 2022-10-16

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;

namespace Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -48,10 +49,7 @@ public IServiceProvider ServiceProvider
/// </summary>
/// <param name="serviceType">Type of the service.</param>
/// <returns></returns>
public object Resolve(Type serviceType)
{
return ServiceProvider.GetRequiredService(serviceType);
}
public object Resolve(Type serviceType) => ServiceProvider.GetRequiredService(serviceType);

/// <summary>
/// Registers the specified service type with corresponding implementation type.
Expand Down Expand Up @@ -130,10 +128,14 @@ public void Dispose()
/// </summary>
public void Verify()
{
var filtered = Services
.Where(x => !IsOpenGeneric(x.ServiceType))
.Where(x => x.ImplementationType is not null);

using (var scope = BeginLifetimeScope())
{
foreach (var service in Services)
foreach (var service in filtered)
scope.Resolver.Resolve(service.ServiceType);
}
}

private static bool IsOpenGeneric(Type type) => type.IsGenericType && type.ContainsGenericParameters;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<Version>1.4.1</Version>
<Version>1.4.2</Version>

<Authors>Alexander Krylkov</Authors>
<Product>Simplify</Product>
Expand Down

0 comments on commit b7db525

Please sign in to comment.