Time flies when you’re having fun. It’s been almost a year since I’ve made an official StructureMap release, so I guess it’s about time. This morning I uploaded the binaries for the 2.6 release. This release just adds some bug fixes and a couple minor additions to the 2.5.4 release that I made in December but didn’t really publicize. The release notes below are long, but that’s because they represent almost a year’s worth of development. As I said yesterday, StructureMap is most likely moving to GitHub with the documentation going as well. After a massive effort to write documentation early last year, huge chunks of it is already obsolete and there’s been a lot of addition since. I’m hoping that the move to the Wiki will make it easier to keep the docs up. In the meantime, I’ll try to blog a bit about the newer pieces starting tomorrow.
A tiny bit of history. This is the 11th StructureMap release since it debuted way back in June of 2004. Almost nothing is the same. We use it differently, the expectations are different, and very, very little of the original code survives today. At QCon San Francisco in 2008 I talked about what I’d learned from evolving this codebase over so many years and changes.
This release includes a lot of patches from the community, and I’d like to thank all of you for that – especially Frank Quednau and Andreas Ohlund for taking on some nastier things. Josh and Kevin Miller do yeoman duty answering StackOverflow questions (so I don’t have to).
What’s Changed?
- New terse, “jQuery-esque” syntax for the Registry DSL. Let’s just write off “ForRequestedType<IFoo>().TheDefault.Is.OfConcreteType<Foo>()” as a well meant experiment, shall we? It’s still in the codebase, but it’s marked as [Obsolete]. Nobody liked it and I thought it was annoying in real life usage. Now, just do: For<IFoo>().Use<Foo>(); My whole goal was to reduce friction. Needs a big blog post
- Changed the Registry DSL to make inline dependency configuration be more consistent. Definitely a blog post.
- The “CreateProfile” syntax has gotten a lot of complaints for being inconsistent with the rest of the Registry DSL. I basically rewrote it to now be consistent with the “For<>().Use()” syntax in the main Registry DSL. Blog post coming soon….
- Nested Container feature for short lived transactional requests. I built this for Dovetail usage, but I think it’s my preferred way to manage object scoping in certain circumstances. I mentioned it just a little bit in my NHibernate w/ StructureMap post a couple weeks back. Blog post coming soon…
- The “Model” feature was completely redone. There’s a lot more power, and you can use it to pull services out of the Container and completely remove services from the Container as well. Sigh. Needs a blog post.
- Convention based type registration got a lot of work. People are pushing this feature very hard and it had to grow. You can now use the Registry DSL to write conventions. This was improved farther in the latest code drop. Yeah, blog post coming…
- Better support for registering services by Type objects for cases when you don’t necessarily know the Type upfront. Big request from several framework authors like Caliburn.
- A helluva lot of new features to make working with open generic types easier. Jimmy Bogard blogged about some of it here. I’d like to show how StructureMap’s new features would make writing something like Davy Brion’s Agatha framework a snap. I use this stuff extensively inside of StoryTeller.
- Added the lazy Func<T> feature from Autofac. A really great (and cheap) way to support lazily initialized components. Blog post coming.
- Completely ditched all Reflection.Emit code. StructureMap now strictly uses dynamically constructed Expression’s that are pre-compiled into cached Func’s. I don’t know if that really makes much difference to users, but it makes StructureMap much, much easier to extend. The container does spin up faster with this mechanism. Makes me happy.
- Supports IList<T> and List<T> arguments. It works just like Arrays. That’s been a while coming.
- You can set the lifecycle from <AddInstance> if you happen to still use Xml configuration.
- The “Lifecycle” code was completely reworked to eliminate shared code
- Container.Dispose() was introduced. I’ve put a lot of effort into making StructureMap clean up after itself. Definitely a blog post coming.
- ObjectFactory.Container. Slowly, but surely, I’d like to wean people away from using ObjectFactory too much in favor of scoped Container objects. I will NOT be further extending the ObjectFactory static methods to synchronize it with IContainer. Instead, I’m just exposing the ObjectFactory.Container property.
- New abilities for IContext like BuildUp() (thanks to Kyle Malloy), getting all instances, and TryGetInstance
- TryGetInstance() from Josh
- Killed StructureMapConfiguration. Good riddance.
- “Forwarding” requests for IFoo to whatever IBar is