Skip to content

Releases: unitycontainer/container

5.5.3.353

03 Jan 04:50
Compare
Choose a tag to compare

Maintenance Release

Fixed #183 ArgumentNullException during instance registreation

5.5.2.350

30 Dec 06:42
Compare
Choose a tag to compare

Maintenance release

Replaced Dictionary<> in HierarchicalLifetimeManager implementation with ConcurrentDictionary<>.

5.5.1.342

30 Dec 03:23
Compare
Choose a tag to compare

This release

This release adds new features and fixes one bug

New features

Bug fixes

  • #177 - Fixed rare condition where setting type interceptor on registration instead of resolving singleton instantiates new instance for each resolution.

5.5.0.330

20 Dec 22:06
578dd06
Compare
Choose a tag to compare
Releasing v5.5.0

5.4.0.318

18 Dec 02:03
Compare
Choose a tag to compare
Releasing v5.4.0

5.3.2.281

02 Dec 18:39
Compare
Choose a tag to compare

Minor bug fixes related to v5.2.1

5.3.1.266

21 Nov 20:23
1424572
Compare
Choose a tag to compare

5.3.0.254

19 Nov 17:05
Compare
Choose a tag to compare

Due to this bug fix sequence of steps during building of objects has changed. Previously strategies were called in this order:

...
TypeMapping,
Lifetime,
PreCreation,
...

Now Lifetime and TypeMapping where reversed and Lifetime is called first. Here is the modified UnityBuildStage

   public enum UnityBuildStage
    {
        /// <summary>
        /// First stage. By default, nothing happens here.
        /// </summary>
        Setup,

        /// <summary>
        /// Third stage. lifetime managers are checked here,
        /// and if they're available the rest of the pipeline is skipped.
        /// </summary>
        Lifetime,

        /// <summary>
        /// Second stage. Type mapping occurs here.
        /// </summary>
        TypeMapping,

        /// <summary>
        /// Fourth stage. Reflection over constructors, properties, etc. is
        /// performed here.
        /// </summary>
        PreCreation,

        /// <summary>
        /// Fifth stage. Instance creation happens here.
        /// </summary>
        Creation,

        /// <summary>
        /// Sixth stage. Property sets and method injection happens here.
        /// </summary>
        Initialization,

        /// <summary>
        /// Seventh and final stage. By default, nothing happens here.
        /// </summary>
        PostInitialization
    }

This change should not affect casual users of the container. Developers of Extensions that rely on this sequence of stages should verify if the change might have broken the extension.

5.2.1.235

15 Nov 00:56
Compare
Choose a tag to compare

Bug Fix

This release is a part of a fix of longest running Unity bug (almost a feature now). The problem it addresses is with registrations affecting each other when new registration is the same Type as previously registered mapping.
Following code explains the problem:

IUnityContainer uc = new UnityContainer();

uc.RegisterType<ILogger, MockLogger>(new ContainerControlledLifetimeManager());
ILogger logger = uc.Resolve<ILogger>();

Assert.IsNotNull(logger);
Assert.AreSame(uc.Resolve<ILogger>(), logger); <-- Resolves Singleton as it should

uc.RegisterType<MockLogger>(new TransientLifetimeManager()); <-- Here is the problem

Assert.AreSame(uc.Resolve<ILogger>(), logger); <-- Resolves new MockLogger and fails

The issue is described here

Impact on existing code

To demonstrate impact on existing code please look at this example:

container.RegisterType<ISomething, Something>(new ContainerControlledLifetimeManager());

var a = container.Resolve<Something>();
var b = container.Resolve<ISomething>();

Assert.AreNotSame(a, b);

Due to the this bug resolving a and b returned the same result because ContainerControlledLifetimeManager would be applied to ToType instead of FromType as it should. In other words it would be applied to Something instead of ISomething.

This fix corrects this behavior so only ISomething (FromType) registers with ContainerControlledLifetimeManager and resolution of Something type will use transient manager.

You could revert back to previous Unity behavior (before this bug fix) by simply registering mapped type with proper lifetime manager:

container.RegisterType<Something>(new ContainerControlledLifetimeManager());

For more information see: #35, 163, #164, #165, #170, #177

More strict use of InjectionFactory

This form of registration used to work for registering interface with InjectionFactory but it is no longer allowed.

RegisterType<IService, Service>(new InjectionFactory(c => new Service()));

As written, this code registers both: a mapping between IService and Service and between IService and InjectionFactory. These two are mutually exclusive and create ambiguity which Unity can not resolve.
It should be either one of these but not both:

RegisterType<IService, Service>();
RegisterType<IService>(new InjectionFactory(c => new Service()));

For more information see: #38

5.2.0.216

12 Nov 01:40
Compare
Choose a tag to compare

Minor speed improvement

This is potentially a breaking change so minor version has been increased.

Combined HierarchicalLifetimeStrategy and LifetimeStrategy into one step to eliminate one iteration in strategy chain and improve speed of objects creation. All logic is concentrated in uniform LifetimeStrategy class.