Planning for Unity vNext?

Sep 1, 2010 at 10:00 AM

Hi,

out of curiosity: is there any planning for the next version of Unity going on? Any announcements? A wishlist? A roadmap?

Cheers

Sep 1, 2010 at 10:39 PM

We're not planning a major revision yet, other than my "fix all the open bugs in the bug tracker" and maybe "clean up the Interception internals."

So, if you want to start giving wishes, now's a good time!

 

Sep 2, 2010 at 6:39 AM
ctavares wrote:

So, if you want to start giving wishes, now's a good time!

WP7 :) 

Sep 2, 2010 at 8:02 AM

Perfect :-)

My number one biggest wish would be an updated registration mechanism. There is an [extension for automatic/convention based registration] available here on CodePlex. Castle Windsor and StructureMap provide something similar as part of their core API.

Having to register all the mappings and dependencies one by one is really cumbersome.

Support for automatic factories using Lazy<T> and Lazy<T, TMetadata> like [Autofac] has would also be great. Again, there is an [extension available] that adds this support but I would definitely prefer to have it as part of Unity itself.

Sep 5, 2010 at 7:06 AM

Oh and one more thing;

It would be great if I could "partially" specify a list of constructor arguments. I.e. give a constructor like this


public
MyCtorSample(string connectionString, ILogger logger) {...}

I would prefer if I could just tell Unity what the value of "connectionString" should be. I know you can do this with


new
InjectionConstructor("myConnectionString", typeof(ILogger))

or work around the issue by providing the connectionString at resolve time, but it is not that convenient when you have to do it over and over again. A way to solve this could be inspired by StructureMap


container.RegisterType<IMyCtorSample, MyCtorSample>().WithCtorArg("connectionString").EqualTo("abc...xyz")

Sep 7, 2010 at 6:12 PM

So what would the conventions be when only partial constructor parameters are given? This is why we didn't do it - there's a lot of ambiguity here.

Lazy<T> support would be pretty simple; it's not in there now in order to avoid taking a dependency on .NET 4.0; future versions will probably include this.

And a final question - what are the default conventions for "convention-based registration?"

 

 

Sep 7, 2010 at 6:15 PM

A WP7 version will need to be seriously, seriously cut down. WP7 is not really Silverlight.  It's built on top of the compact framework, so it lacks some important stuff we depend on. In particular, there's no reflection emit system, so we can't do the optimizations we do to make object creation perf decent. Also means no interception system. And to add to the pain, the performance of the reflection API really sucks.

To get actual usable perf, you'd have to remove all the auto-wiring and do everything with InjectionFactory. Maybe that's ok?

 

Sep 7, 2010 at 6:47 PM

@partial ctor support: Identify parameters by name and matching Type (e.g. 'arg1' of Type string is specified but 'arg1' of Type int is not). If there are primitive ctor args that are not satisfied by the specified parameters a ctor is not a valid candidate. Take the ctor from the candidate list with the most/least arguments (perfect sample of a convention) and you are done. Throw an exception when no ctor is left after filtering. I implemented a sample which I can send you if you are interested.

@conventions: Conventions are what YOU, the designers, architects and developers of the Unity team define. Nothing more, nothing less.

I am working on a sample for an enhanced registration setup engine. Its based on the API of the UnityAutoRegistration project I linked in my earlier post but with quite different structure under the hood.

Sep 7, 2010 at 8:42 PM
Edited Sep 7, 2010 at 8:43 PM

Improved support for explicit interface implementation would be nice.

Currently, any property decorated with a DependencyAttribute must be public for the container to set it. This has the effect of forcing me to implement interfaces implicitly. I'd like the option of explicit implementation + injection (currently not supported).

Sep 8, 2010 at 12:10 PM
ctavares wrote:

A WP7 version will need to be seriously, seriously cut down. WP7 is not really Silverlight.  It's built on top of the compact framework, so it lacks some important stuff we depend on. In particular, there's no reflection emit system, so we can't do the optimizations we do to make object creation perf decent. Also means no interception system. And to add to the pain, the performance of the reflection API really sucks.

To get actual usable perf, you'd have to remove all the auto-wiring and do everything with InjectionFactory. Maybe that's ok?

 

@ctavares

The mobile.codeplex.com site had Unity source in its project back in Change Set 15313 (Spikes\PerfComparison\UnitySource).   I was excited to see it in there but dismayed because at the time I was still on Mobile 5 framework, by the time I got my IPAQ (Mobile 6.1) for a new project it was phased out of the mobile.codeplex.com project and the CompactContainer was getting the job done for me (after I added UnityExtensions so it would feel more natural to me).  

I don't know if this was your creation but at the time the CompactContainer boasted (and demonstrated) better performance than other containers, to include unity, but I chalked this up to the fact that performance for the CompactContainer was being specifically addressed for the mobile framework.   I trust if you did the same you could tweak comparable performance out of Unity.

I for one don't expect "Silverlight" feature support from a WPF mobile framework, no more than I would expect "Desktop" support from Silverlight framework (perhaps Scotts comments on the matter were a wee bit overzealous).   To have neither MEF nor Unity support in WP7 leaves us no alternative than to use the existing CompactContainer.   I'd rather have a watered down version of Unity.....

 

 

Sep 10, 2010 at 10:49 PM

I didn't have anything to do with the mobile project. We had some internal discussions around building a mobile version of Unity, but decided against it due to the performance issues. We felt that the compact framework was enough of its own beast to merit a solution tailored to that environment. I think part of that was previous (very painful) experiences in p&p on trying to get ObjectBuilder 1 even remotely usable on the mobile framework. It wasn't pretty. :-)

That old CompactContainer later evolved into Funq, by the way.

Bob Brumfield did a spike on cutting Unity down to fit on WP7 a while ago, but that project also decided to go the Funq route for pretty much the same reasons.

 

Oct 30, 2010 at 10:07 PM

OK, after several really late nights I definitely vote for a blow-by-blow documentation of how Unity strategies and policies interact and which of the default strategies does what.

Jan 10, 2011 at 1:09 PM
Edited Jan 18, 2011 at 6:28 AM

Hi, me again.

Several months went by and I found one more key-feature I am missing.

In NInject its called "ContextualBinding". It allows you to specify multiple mapping targets depending on the context of a resolution. e.g. if you resolve a component from the MyApp.Data namespace the interface IFoo will be mapped to class Foo. But if you have a component from MyApp.Business then IFoo will be mapped to class Bar.

It is somewhat possible to do that with the 2.0 version of Unity but the extension is really cumbersome. [Update] Its not that difficult, I just used the wrong approach [/Update]


Jan 11, 2011 at 3:26 AM
Edited Jan 11, 2011 at 3:26 AM

If contextual binding is a must-have feature, then you're going to have to use ninject - it's the only container that has that explicit feature.

You can accomplish the same thing via use of named registrations, but I agree it's not as elegant as contextual binding. We haven't had a ton of user requests for it so probably won't make it into the core.

 

 

Mar 31, 2011 at 1:42 PM

 Interception for interfaces without implementations (http://unity.codeplex.com/discussions/244932) would be great for WCF client scenarios where you are sharing contracts.

Mar 31, 2011 at 2:04 PM

@ctavares: Is there any roadmap for vNext?

Mar 31, 2011 at 6:57 PM

You will have to ask grigori - I recently left p&p for a new opportunity inside Microsoft and I'm no longer on the project.

Apr 1, 2011 at 6:37 AM

@ctavares: Sorry to hear that you left Unity. All the best for your new job!

Oct 28, 2011 at 2:32 AM

@Damien80 and other Unity fans, sorry, I didn't see this thread. Take a look at my team's roadmap for this year.

Also, we've just released a preview of Unity 3.0 for .NET4.5. Take a look. It's just a port of Unity 2.1 to .NET4.5. All new features will be worked on as a part of the Enterprise Library 6.0 project.

For all your feature requests, please submit and vote on them here.

Thanks,

Grigori

 

Oct 30, 2011 at 10:07 AM

Hi Grigori,

thanks for the info. Are there any technical reasons why the CommonServiceLocator is not available for the WinRT profile or is it just "nobody migrated it yet"?

Thanks

Sebastian

Oct 31, 2011 at 7:02 PM

The latter.

Jan 11, 2012 at 12:40 AM

Any plans on the horizon for IOC with Metro Style applications?  

Jan 12, 2012 at 3:38 AM
Edited Jan 12, 2012 at 3:39 AM

Unity 3.0 preview is out and I don't see anything specifically targeting Metro Style applications.  You could submit a feature request on the uservoice site.

Jan 16, 2012 at 3:52 PM

My request is simple. Better exceptions. I can't tell you how infuriating it is to try and figure out what the underlying cause of an exception is when given the lovely "x is an interface and cannot be constructed". It could be type registration, it could be a dependency failure, it could be a host of other things, but the manner in which the exceptions are handled internally masks any useful information.

Feb 2, 2012 at 10:25 PM
Edited Feb 2, 2012 at 10:26 PM

Hi,

Definitely : proper object graph disposal on TearDown. Rory Primrose has developed a Unity Extension that seems to do just that, as part of the Neovolve Tookit, and written multiple articles about it (http://www.neovolve.com/post/2010/06/18/Unity-Extension-For-Disposing-Build-Trees-On-TearDown.aspx). I would really love to see this integrated into Unity, as properly disposing the object graph is something a DI container should be able to do. Creating and disposing child containers feels inappropriate in design, and HierarchicalLifetimeManager prevents from using any other lifestyle.

Feb 2, 2012 at 10:40 PM

@SFence,

Thank you for your suggestion. We'll put this on the backlog. Also, you may want to post this on our uservoice to let other people vote on this.

Also, it would be great if Rory considered submitting his Unity extension via the EntLibContrib site.

Regards,

Grigori

Feb 3, 2012 at 6:44 AM

@SFence,

There already is a suggestion for that

http://entlib.uservoice.com/forums/89245-general/suggestions/1672391-unity-lifetimes-teardown-should-dispose-objects-c

Feb 13, 2012 at 3:46 AM

Thanks for the thoughts about my IDisposable teardown extension.

I have previously thought about putting my extension in the contrib project. I'm reluctant to do this as it is already in my toolkit assembly. Granted this means that people need to add another assembly reference, but it means that the code exists in only one place. I would definitely put it in the contrib project if that was some kind of path towards getting it put into the Unity core itself, but am otherwise reluctant.

Thoughts?

Feb 13, 2012 at 10:43 AM

The last checkin for the contrib project was done in 02/2009. Before I would put any effort or code in that project I would like to know

  • How are contributions to that project handled? Can you checkin anything as soon as you are a developer on that project?
  • Can you change your code later as you see fit?
  • Is there some kind of release planning you need to follow?
  • Is there some kind of QA in place? E.g. code reviews?

And I agree with @rprimrose: Are there any plans that features from the contrib project will find their way into the Unity core?

Mar 12, 2013 at 11:40 PM
We are adding support for Lazy<T> and registration by convention in Unity 3.0
Please see the description of the conventions and provide your feedback.

Thanks,
Grigori