Skip to content

Releases: unitycontainer/unity

5.8.7.517

22 Aug 21:37
Compare
Choose a tag to compare

Fixed Issues

#55 - Added support for Net Core 2.0
#57 - Override loading optimization during resolve
#87 - Fixed enumerable resolution with regard to generic constraints
#88 - Fixed edge case where hierarchical containers resolve with overrides
#92 - Fixed array resolution with regard to generic constraints
#94 - Minor optimization during resolution
#95 - Fixed bug related to resolving registered array
#96 - Fixed bug related to resolving registered enumerable
#233 - PDB Causing TFS Build to "Partially Succeed"

5.8.6.508

19 Apr 02:17
Compare
Choose a tag to compare
Releasing 5.8.6

5.8.5.506

06 Apr 03:01
Compare
Choose a tag to compare
Releasing v5.8.5

5.8.4.502

31 Mar 20:34
Compare
Choose a tag to compare
Releasing v5.8.4

5.8.3.499

30 Mar 23:46
Compare
Choose a tag to compare
Releasing v5.8.3

5.8.2.496

30 Mar 17:15
Compare
Choose a tag to compare

Minor optimizations

Fixed #211

5.8.1.490

28 Mar 21:35
Compare
Choose a tag to compare
Minor optimizations

5.8.0.488

27 Mar 23:00
Compare
Choose a tag to compare

This release

This release fixes #72 issue.

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.485

26 Mar 23:12
Compare
Choose a tag to compare

This release was rolled back because of breaking changes

See v5.8.0 for the new release

5.7.3.481

03 Mar 20:15
Compare
Choose a tag to compare
Releasing 5.7.3

- Fixed unitycontainer/microsoft-dependency-injection#12