Skip to content

Releases: unitycontainer/container

5.8.0.519

27 Mar 22:56
Compare
Choose a tag to compare

This release

This release fixes how collections are resolved by the container. See #72 issue for more information.

Problem

Unity has build in support for IEnumerable, Array, and Lazy. Theoretically it should be able to distinguish these types and properly resolve them individually and in combination. Unfortunately it did not do so.

container.Resolve<Lazy<IEnumenrable<type>>>  - will resolve correctly
container.Resolve<IEnumenrable<Lazy<type>>>  - will resolve empty

Fix

This release fixes resolution of collections of generic and array types and Lazy collections of items. This will now work fine:

Resolve<Lazy<IEnumenrable<type>>>
Resolve<IEnumenrable<Lazy<type>>>

Resolve<Lazy<type[]>>
Resolve<Lazy<type>[]>

Resolve<IEnumerable<Lazy<Func<IService>>>>()
Resolve<IEnumerable<Func<Lazy<IService>>>>()

Resolve<Lazy<Func<IService>>[]>()
Resolve<Func<Lazy<IService>>[]>()

The logic behind resolving collections is to find enumerable type and get all registrations for it no matter how deep in generics tree. Enumerated type could be:

  • Non generic (Constructed Generic) type
  • Explicitly registered with container type

So, in this example

RegisterType<IService, Service>("1", new ContainerControlledLifetimeManager());
RegisterType<IService, Service>("2", new ContainerControlledLifetimeManager());
RegisterType<IService, Service>("3", new ContainerControlledLifetimeManager());
RegisterType<IService, Service>();

Resolve<IEnumerable<Func<Lazy<IService>>>>();

enumerable will return four instances of method which returns Lazy<IService>. But in this example:

RegisterType<IService, Service>("1", new ContainerControlledLifetimeManager());
RegisterType<IService, Service>("2", new ContainerControlledLifetimeManager());
RegisterType<IService, Service>("3", new ContainerControlledLifetimeManager());
RegisterType<IService, Service>();

RegisterInstance(new Lazy<IService>(() => new Service()));  <-- note this registraton

Resolve<IEnumerable<Func<Lazy<IService>>>>();

Enumerable will return only one item.

For more information see this wiki

5.7.4.513

26 Mar 23:09
Compare
Choose a tag to compare

This release was rolled back because of breaking changes

5.7.3.487

03 Mar 20:11
7ee44ca
Compare
Choose a tag to compare
Releasing 5.7.3

Fixed unitycontainer/microsoft-dependency-injection#12

5.7.0.473

01 Mar 00:03
Compare
Choose a tag to compare
Releasing v5.7.0

5.6.1.380

22 Feb 18:40
77d10e1
Compare
Choose a tag to compare
Releasing v5.6.1

Includes minor performance optimizations

5.6.0.369

13 Feb 20:46
Compare
Choose a tag to compare

Significant engine optimization

This release introduces significant rework of v5 engine. The optimization it provides decreases access times by 30 - 40%.

5.5.8.365

09 Feb 01:21
Compare
Choose a tag to compare
  • Minor speed optimizations

5.5.7.362

08 Feb 23:17
Compare
Choose a tag to compare
Releasing v5.5.7

- Minor speed optimizations

5.5.6.359

23 Jan 19:43
2dcea05
Compare
Choose a tag to compare

New Feature

Bug Fixes

5.5.5.355

11 Jan 00:24
Compare
Choose a tag to compare

Maintenance release

  • Added minor optimizations to enable integration with Microsoft.Extensions.DependencyInjection.2.*
  • Skipping v5.5.4 to sync up with Unity package