Pablo Galiano : VS 10 beta 1 extensibility model (Part 1)

Subscriptions

<September 2010>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

News

Subscribe to Pablo Galiano by Email

Post Categories

VS 10 beta 1 extensibility model (Part 1)

***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***

These series of posts will cover two types of Visual Studio 10 Beta 1 extensions:

  1. MEF component (assembly that contains exports and imports)
  2. VSPackage

In the previous post we said that Visual Studio is a host for MEF components. This is being done by the introduction of a new VS core package called Microsoft.VisualStudio.ComponentModelHost.HostPackage

The host package is declares the following two core services:

  1. Microsoft.VisualStudio.ComponentModelHost.IComponentModel service
  2. Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost service

 

Microsoft.VisualStudio.ComponentModelHost.IComponentModel service

This service has the following responsibilities:

  • Get MEF catalog by name
  • Get MEF export / exports
  • Creates and maintains a list of available catalogs
  • Declares the GlobalCompositionContainer

 

The VsCatalogProvider, AssemblyListCatalog and VSCatalogName classes:

The GetCatalog method returns a catalog by name by searching the list of available catalogs that is maintained by the service itself.

If the catalog doesn’t exist it is created and then added to the list. To create a catalog the Microsoft.VisualStudio.ExtensibilityHosting.VsCatalogProvider class is used. This class has the following responsibility:

  • Build and return an AssemblyListCatalog

The Microsoft.VisualStudio.ExtensibilityHosting.AssemblyListCatalog class derives from the MEF ComposablePartCatalog and it is basically a list of AssemblyCatalogs.

The AssemblyListCatalog is constructed by adding every MEF component assembly found in the system filtered by the catalog name. To find the MEF component assemblies, the Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost service is used.

To specify a catalog name for a MEF component assembly there is a VsCatalogName attribute:

[assembly: VsCatalogName("Microsoft.VisualStudio.Editor")]

 

Multiple MEF composition containers:

Visual studio supports multiple MEF composition containers. A core component is responsible for creating its own container. For example the Visual Studio editor creates its own container. There is a service that maintains the list of available containers and it is the Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService class.

 

The GlobalCompositionContainer:

The GlobalCompositionContainer acts as the root MEF composition container. This container is used by the IComponentModel service to get MEF export / exports.

Behind the scenes the GlobalCompositionContainer uses the VsExportProviderService to search in all available containers.

 

The VsCompositionContainer class:

A container in Visual Studio derives from the MEF CompositionContainer class and adds features such as export providing settings, export sharing policies, export provisioning scope, etc. And it modeled by the Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer class

 

In the next post I will cover the details for the Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost service.

 

Pablo

posted on Thursday, July 02, 2009 8:50 AM by pga