Skip to content

Commit

Permalink
Releasing v4.0.6 with the fixed #171
Browse files Browse the repository at this point in the history
removing the direct parameter injection of IContainer (and implemented interfaces) and always rely on registration - perf reason is not applied anymore - it is fast enough
  • Loading branch information
dadhi committed Aug 29, 2019
1 parent 559b587 commit 39a1a2e
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 21 deletions.
6 changes: 3 additions & 3 deletions BuildScripts/NuGetPublish.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set PACKAGES=..\.dist\packages
set SOURCE=https://api.nuget.org/v3/index.json
set /p APIKEY=<"..\ApiKey.txt"

dotnet nuget push "%PACKAGES%\DryIoc.dll.4.0.5.nupkg" -k %APIKEY% -s %SOURCE%
dotnet nuget push "%PACKAGES%\DryIoc.4.0.5.nupkg" -k %APIKEY% -s %SOURCE%
dotnet nuget push "%PACKAGES%\DryIoc.Internal.4.0.5.nupkg" -k %APIKEY% -s %SOURCE%
dotnet nuget push "%PACKAGES%\DryIoc.dll.4.0.6.nupkg" -k %APIKEY% -s %SOURCE%
dotnet nuget push "%PACKAGES%\DryIoc.4.0.6.nupkg" -k %APIKEY% -s %SOURCE%
dotnet nuget push "%PACKAGES%\DryIoc.Internal.4.0.6.nupkg" -k %APIKEY% -s %SOURCE%

rem dotnet nuget push "%PACKAGES%\DryIocZero.4.1.0.nupkg" -k %APIKEY% -s %SOURCE%

Expand Down
4 changes: 4 additions & 0 deletions docs/DryIoc.Docs/VersionHistory.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Version History
---------------

## v4.0.6 Release notes / 2019-08-29

- fixed: #171 Wrong IContainer resolved

## v4.0.5 Release notes / 2019-06-08

- fixed: #133 Validate method call hangs
Expand Down
6 changes: 5 additions & 1 deletion nuspecs/DryIoc.Internal.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="3.3.0">
<id>DryIoc.Internal</id>
<version>4.0.5</version>
<version>4.0.6</version>
<authors>Maksim Volkau</authors>
<copyright>Copyright © 2013-2019 Maksim Volkau</copyright>
<projectUrl>https://github.com/dadhi/DryIoc</projectUrl>
Expand All @@ -13,6 +13,10 @@
<tags>IoC Container Inversion-of-Control DI Dependency-Injection DRY Service-Provider Factory</tags>
<releaseNotes>
<![CDATA[
## v4.0.6 Release notes
- fixed: #171 Wrong IContainer resolved
## v4.0.5 Release notes
- fixed: #133 Validate method call hangs
Expand Down
4 changes: 4 additions & 0 deletions nuspecs/DryIoc.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<tags>IoC Container Inversion-of-Control DI Dependency-Injection DRY Service-Provider Factory</tags>
<releaseNotes>
<![CDATA[
## v4.0.6 Release notes
- fixed: #171 Wrong IContainer resolved
## v4.0.5 Release notes
- fixed: #133 Validate method call hangs
Expand Down
16 changes: 0 additions & 16 deletions src/DryIoc/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8419,22 +8419,6 @@ public static Expression[] TryResolveParameterExpressions(

if (paramInfo.Details == DryIoc.ServiceDetails.Default)
{
if (paramServiceType == typeof(IResolverContext) || paramServiceType == typeof(IResolver)
// todo: replace framework targets with feature toggle
#if SUPPORTS_ISERVICE_PROVIDER
|| paramServiceType == typeof(IServiceProvider)
#endif
)
{
paramExprs[i] = ResolverContext.GetRootOrSelfExpr(paramRequest);
continue;
}
else if (paramServiceType == typeof(IRegistrator) || paramServiceType == typeof(IContainer))
{
paramExprs[i] = Convert(ResolverContext.GetRootOrSelfExpr(paramRequest), paramServiceType);
continue;
}

if (request.Container.TryGetUsedInstance(paramServiceType, out var instance))
{
// Generate the fast resolve call for used instances
Expand Down
6 changes: 5 additions & 1 deletion src/DryIoc/DryIoc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks Condition="'$(DevMode)' != 'true'">net35;net40;net45;netstandard1.0;netstandard1.3;netstandard2.0;portable-net45+win8+wpa81+wp8;portable-net40+win8+wpa81+wp8+sl5</TargetFrameworks>

<Product>DryIoc</Product>
<VersionPrefix>4.0.5</VersionPrefix>
<VersionPrefix>4.0.6</VersionPrefix>
<VersionSuffix></VersionSuffix>

<AssemblyName>$(Product)</AssemblyName>
Expand All @@ -16,6 +16,10 @@
<PackageTags>IoC Container Inversion-of-Control DI Dependency-Injection DRY Service-Provider Factory FastExpressionCompiler ImTools</PackageTags>
<PackageReleaseNotes>
<![CDATA[
## v4.0.6 Release notes
- fixed: #171 Wrong IContainer resolved
## v4.0.5 Release notes
- fixed: #133 Validate method call hangs
Expand Down
62 changes: 62 additions & 0 deletions test/DryIoc.IssuesTests/GHIssue171_Wrong_IContainer_resolved.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using NUnit.Framework;

namespace DryIoc.IssuesTests
{
[TestFixture]
public class GHIssue171_Wrong_IContainer_resolved
{
[Test]
public void Should_resolve_correct_registered_container_with_RegisterDelegate()
{
var mainContainer = new Container();
var configureContainer = new Container();

configureContainer.RegisterDelegate<IContainer>(r => mainContainer, ifAlreadyRegistered: IfAlreadyRegistered.Replace);

configureContainer.Register<Module>();

// init code ...
configureContainer.Resolve<Module>().Register();

Assert.False(configureContainer.IsRegistered<IFoo>());
Assert.True(mainContainer.IsRegistered<IFoo>());
Assert.AreSame(configureContainer.Resolve<IContainer>(), mainContainer);
}

[Test]
public void Should_resolve_correct_registered_container_with_Use()
{
var mainContainer = new Container();
var configureContainer = new Container();

configureContainer.Use<IContainer>(mainContainer);

configureContainer.Register<Module>();

// init code ...
configureContainer.Resolve<Module>().Register();

Assert.False(configureContainer.IsRegistered<IFoo>());
Assert.True(mainContainer.IsRegistered<IFoo>());
Assert.AreSame(configureContainer.Resolve<IContainer>(), mainContainer);
}

class Module
{
private readonly IContainer _container;
public Module(IContainer container) =>
_container = container;

public void Register() =>
_container.Register<IFoo, Foo>();
}

public interface IFoo
{
}

public class Foo : IFoo
{
}
}
}

0 comments on commit 39a1a2e

Please sign in to comment.