Feb 26 Weekly Drop

Rating: No reviews yet
Downloads: 534
Released: Feb 26, 2008
Updated: Feb 27, 2008 by ctavares
Dev status: -not yet defined by owner-

Recommended Download

Source Code Unity-08-02-26-A-Drop.zip
source code, 759K, uploaded Feb 27, 2008 - 534 downloads

Release Notes

Unity release notes

This is the Unity weekly drop for Feb 26, 2008. There have been a lot of internal changes and some useful new features added.

Important Update As usual with these drops, I found a nasty bug about three minutes after uploading the release (you'll hit it as soon as you try to get a dependency twice). This release download has been updated with the fixed code. If you've already downloaded, I strongly recommend re-downloading to get the fix.

New Features

  • SetLifetime method allows you to specify a LifetimeManager object for a particular dependency. LifetimeManagers are included for the existing singleton and instance lifestyles, and it's easy to write your own. This provides the underlying support needed to implement per-ASP.NET-request semantics, for example.
The current SetSingleton and RegisterInstance APIs are still available; internally they now use a LifetimeManager.
  • Teardown: The opposite of BuildUp, the container now has a Teardown method which objects can be run through to shut down / clean up / whatever you want. The existing container behavior does nothing at Teardown time, but extensions can be written to take advantage of this.
  • Extensions can implement IDisposable: If an extension object implements IDisposable, it now gets disposed when the container does.

User Visible Changes

  • The container will now throw an exception if attempting to resolve a dependency that it cannot construct, instead of returning null.
  • NotPresentBehavior is gone. It wasn't used much, and the existing implemention does not work in the presence of LifetimeManagers. All dependencies will now act like NotPresentBehavior.Build, which was the default anyway.
  • New exceptions: Any failure will result in a ResolutionFailedException, containing the name and type requested. Inner exceptions contain the actual exception, which now provides much more detail on exactly what was being built at the time of failure, and where the failure occurred.

Internal Changes

  • The IL generation steps to resolve parameters have been rewritten. Instead of having attributes generating IL, to resolve a parameter value a call to an IDependencyResolverPolicy is emitted. The various selector policies are responsible for placing the resolvers into the policy list when selecting targets. This provides the infrastructure needed to configure dependencies on types without using attributes. As part of this, the ResolveAttribute and related classes have been deleted.
  • Transient policies: Older versions of ObjectBuilder had transient policies only. Any policies that strategies added to the policy list were deleted at the end of the buildup process. As a performance improvement, our initial release changed this to only have peristent policies. It turns out transient policies were still useful, so the current IBuilderContext has TWO policy list objects: Policies and PersistentPolicies. If you add to PersistentPolicies the policy sticks around after the buildup, while adding to Policies creates a transient policy. In general, when looking up a policy, you should continue to use Policies, since a lookup there will search both transient and persistent policies.
  • and of course the inevitable tweaks and fixes.
The docs have not yet been updated to the current state, so be aware they are out of sync with the current release.
-The Unity team

Reviews for this release

No reviews yet for this release.