Code Monkey home page Code Monkey logo

Comments (11)

kirodge avatar kirodge commented on August 23, 2024 1

@dadhi Set milestone 3.1.0?

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

@kirodge, Thanks for posting.

Yes, it is probably a cache, but it should not be there because of arguments. I will check.

from dryioc.

kirodge avatar kirodge commented on August 23, 2024

Thanks, I created a PR for testing the issue

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

The fix is available in DryIoc v3.1.0-preview-03

from dryioc.

kirodge avatar kirodge commented on August 23, 2024

Thanks a lot for the quick fix @dadhi.
The issue is resolved in DryIoc v3.1.0-preview-03

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

yep.

from dryioc.

kirodge avatar kirodge commented on August 23, 2024

I would set milestone myself, if I was able to.

Any due date for 3.1?

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

It will be a v4. Currently in a preview. Soonish I hope.

from dryioc.

Leszek-Kowalski avatar Leszek-Kowalski commented on August 23, 2024

This issue is a show stopper for my project as well.
Any timelines for v4 ?
Maybe it could be back-ported to 3.1 in the mean time ?
Thanks.

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

V4 will be here soon. If you are watching the repo, you see that I am closing the last bugs.

Regarding back ports, I am open for PRs.

from dryioc.

rdeago avatar rdeago commented on August 23, 2024

EDIT: Actually, it appears to be another issue. Please see #105.


It appears that the issue is still there in v4.0.1.

I've prepared the tiniest use case I could come up with and placed it in a .NET fiddle.

Here's the code, for completeness:

// @nuget: DryIoc.dll -Version 4.0.1

using System;
using DryIoc;

public class Program
{
	public static void Main()
	{
		using (var container = new Container(ConfigureContainer))
		{
			container.Register<IAlpha, Alpha>();
			container.Register<IBravo, Bravo>();
			
			using (var scope = container.OpenScope())
			{
				Console.WriteLine("--- Scope #1");
				scope.ResolveNamed<IAlpha>("Alice");
				scope.ResolveNamed<IBravo>("Bob");
			}
			
			using (var scope = container.OpenScope())
			{
				Console.WriteLine("--- Scope #2");
				// I would expect the Container to throw on the following line,
				// because it doesn't know how to create an instance of Alpha.
				// Instead, it happily creates an Alpha named Bob!
				scope.ResolveNamed<IBravo>("Bob");
			}
		}
	}
	
	static Rules ConfigureContainer(Rules rules)
	{
		return rules
            .With(FactoryMethod.ConstructorWithResolvableArguments)
            .WithDefaultReuse(Reuse.ScopedOrSingleton);
	}
}

public static class ResolverExtensions
{
	public static TService ResolveNamed<TService>(this IResolver @this, string name)
	{
		return @this.Resolve<TService>(args: new object[] { name });
	}
}

public abstract class Service
{
	protected Service(string name)
	{
		Console.WriteLine("This is an instance of {0} called {1}.", GetType().Name, name);
	}
}

public interface IAlpha { }

public interface IBravo { }

public sealed class Alpha : Service, IAlpha
{
	public Alpha(string name)
		: base(name) { }
}

public sealed class Bravo : Service, IBravo
{
	public Bravo(string name, IAlpha alpha)
		: base(name) { }
}

from dryioc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.