What happened to IUnityContainer generic overloads?

Oct 14, 2009 at 3:37 PM

The IUnityContainer interface changed between drop 28516 (July 13) and 33465 (Sep. 10).  It probably changes more than just then, but that is when the generic overloads for RegisterType<> and Resolve<> were removed.  I looked in the Discussions to see if I could find out why, but didn't find anything.

We've started a project with Unity1.2/EntLib4.1.  I jumped to the Unity 28516 drop because it was supposed to have better description of resolution exceptions.  Later I went to the latest (at that time) drop and noticed the generic overloads were not on the interface any longer.  Does anyone know why this was done?  It's not that I can't get around it, but was just curious at to the reason.




Oct 14, 2009 at 5:51 PM

They haven't been removed. Well, they've been removed from the interface, but if you look a little lower in IUnityContainer.cs, you'll see a set of extension methods.

Basically, we took all the overloads off the interface and moved them to extension methods. You can continue to call the generic versions without any issues at all.

Oct 14, 2009 at 6:28 PM
Edited Oct 14, 2009 at 7:15 PM

Ah.  Thanks, Chris.  I see them in the UnityContainerExtensions.cs (not IUnityContainer.cs) when I browse the 3346*6* source online, but it is not in the 33465 drop or browsable online.  The 33466 and 33899 drops have them in there.


There must have been a hiccup with the 33465 drop because the zip does not contain lots of (new?) files for the Unity.csproj project.



Oct 15, 2009 at 12:14 AM

If you look at the posting times for 33465 & 33466, you'll see they're about an hour apart. Yes, there was a glitch on the upload on that one.


Oct 27, 2009 at 6:18 AM

Hello Chris,

What is the advantage of moving those methods from Interface to Extension?  Is it for those who like to create a custom container that implements to IUnityContainers so that they don't need to implement so many methods?

Oct 28, 2009 at 7:37 PM

It cleans up the interface and the implementation. The core Unity interface has about six methods on it, but after adding all the overloads we end up with over 40. It was just getting ridiculous. It helps make our testing easier becuase when we mock out a container it's not as much of an impact.

And I got yelled at for not using extension methods. So now we are. :-)

Oct 29, 2009 at 2:17 AM

Yes. I got the idea when I was writing my previous thread.. Yes.. it's also good idea to use extension methods since it helps us make our interface as thin as possible..