MEF Re-factored, Preview 3 has shipped.

We just dropped another release of MEF source. This one includes some significant changes that we’re excited about.


1. We’re now completely MS-PL!!! The StructuredValues dll dependency is now removed. You’re free to use the source how you like on Windows and beyond.


2. Container re-factoring – We’ve done an overhaul of the composition container. Outwardly this slightly affects the public API, internally it makes our design cleaner, and easier to extend. I’ll discuss more details on this in my next post, but the diagram below shows the changes. What should be apparent is that we’ve reduced greatly the bi-directional tight coupling :-( between the various components. (all the wacky lines)


Before:


image_thumb20


After:


image_thumb24


3. ExportProvider - We’ve replaced the Value Resolver with a new Export Provider. Export Providers are easier to author, and can be used for integrating with external systems. Export Providers can be chained together through using a new AggregatingExportProvider. This allows you to apply custom policies to the container for how exports are discovered.


4. Defaults – The new AggregatingExportProvider is prioritized with Export Provider’s at the top of the chain having higher priority over those at the back. This means you can have defaults such as a default logger which are overridable. These defaults take on a secondary role, which is they allow you to have single imports (like importing a single logger) succeed even if multiple loggers are present. Supporting default behavior is something that the community has been requested repeatedly.


5. Catalog Cache – The catalog now builds a persistent cache of all the metadata for parts in the catalog. Until the part is instantiated, it’s assembly will not get loaded. For lazy loading this means if a part imports an Export<IFoo>  then the Foo  assembly will not be loaded until GetExportedObject is called.


6. Performance tweaks – We’ve done a bunch of significant perf enhancements to the container / composition.


7. Unit Tests – We heard you loud and clear that you wanted to see them, well now we’ve included our full suite of unit tests.


As I mentioned above, I’ll be doing some follow up posts to talk about the changes in detail.


You can get the bits here.

This entry was posted in MEF. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Bnaya Eshet

    Congratulations :-)

  • http://www.codebetter.com/blogs/glenn.block/ Glenn Block

    @Kyle

    It was the earlier bits. Not any major difference it what was shown except that in the demo I call CreateResolver() when I pass the catalog to the contianer. You won’t do that anymore.

  • http://www.codebetter.com/blogs/glenn.block/ Glenn Block

    Scott

    Licensing is no issue as MS-PL has no platform restriction. In terms of compiling under mono, we haven’t tried it. The one thing MEF depends on is LINQ. I spoke to Miguel De Icaza and he said Mono 2.0 supports LINQ. So….you can surely try it. Let us know if it works :)

    We actually have chatted with Miguel about mono guys using it.

  • scott fluto

    Do you know if this compiles under mono also and is licensed to be run under mono since our application runs under windows and mono?

  • http://home.infusionblogs.com/kszklenski/default.aspx Kyle Szklenski

    You used the older version in the DNR TV from Oredev, right? It looks more like it, although it’s hard to tell since what you did was fairly simple.

    I really like this, anyway. I’m going to start playing around with implementing a nice business rules engine that imports its rules on the fly – so that a person can provide an assembly that adds to the list of rules. I’ve already implemented the engine, actually – now I just need to put in the MEF, which I wish I could have thought of first. Oh well.

  • Bryan Watts

    Great! Congrats on the release.

    So many times you see frameworks violating the very rules they are in place to facilitate, i.e. composition engines not being very decoupled.

    Looking forward to learning about the new concepts!

  • http://www.sidarok.com Sidar Ok

    Congratulations ! I am especially happy to see the tests.