MEF, IServiceProvider and Testing Visual Studio Extensions
Posted
by Daniel Cazzulino
on ASP.net Weblogs
See other posts from ASP.net Weblogs
or by Daniel Cazzulino
Published on Tue, 08 Jun 2010 23:43:15 GMT
Indexed on
2010/06/08
23:53 UTC
Read the original article
Hit count: 346
.NET
|All Technology
In the latest and greatest version of Visual Studio, MEF plays a critical role, one that makes extending VS much more fun than it ever was.
So typically, you just [Export] something, and then someone [Import]s it and that's it. MEF in all its glory kicks in and gets all your dependencies satisfied.
Cool, you say, so let's now import ITextTemplating and have some T4-based codegen going! Ah, if only it was that easy. Turns out by default, none of the VS built-in services are exposed to MEF, apparently because there wasn't enough time to analyze the lifetime, initialization, dependencies, etc. for each one before launch, which makes perfect sense. You don't want to blindly export everything now just in case. There's also the whole VS package initialization thing which in this version of VS is not so transparently integrated with the MEF publishing side (i.e. a MEF export from a package can get instantiated before its owning package, and in fact, the package can remain unloaded forever and the export will continue to be visible to anyone)....
© ASP.net Weblogs or respective owner