Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Contravariant singletons not working quite as expected #53
Building on the contravariance examples (ordered enumerables example in the contravariance docs on rezolver.co.uk) - if you register a type as a singleton against a contravariant type, then I would expect only one instance to be created for requested type.
container.RegisterSingleton(typeof(ShapeAreaComparer), typeof(IComparer<I2DShape>)); var a = container.Resolve<IComparer<Rectangle>>(); var b = container.Resolve<IComparer<Square>>(); var c = container.Resolve<IComparer<Circle>>(); // currently fails Assert.Same(a, b); Assert.Same(b, c);
Currently, Rezolver will create singletons, but one per unique requested type - i.e.
Ideally, Rezolver should create one single instance for all these types.
The same should probably also be true if these were scoped.