VSX: Visual Studio Extensibility Architecture Part 1

Doug Hodges, one of two original architects who built the first, extensible IDE shell from MSFT (Visual Studio 6.0), took up the challenge of two, back-to-back afternoon sessions and launched into "fundamental" (lower-level) architectural concepts. He shared his considerable context, motivating the current design and reflecting a long history of careful attention to detail.

Themes: delay load assemblies, mature COM model, thoughtful versioning story, support many styles of Windows programming including managed interop assemblies and helper libraries.

VsPackage

  • The initial starting point for a logical set of features in the IDE. Co-created, given a pointer to the IDE for services ("sited"), and used as a factory for its features.
  • Loading is delayed until functionality is needed, so package must expose metadata (using registry) so IDE knows when to load it.

(COM) Services

  • The Site call includes an IServiceProvider, and it has a QueryService interface (similar to QueryInterface), and requests to this interface may be routed to another object which actually provides the service.
  • The Managed Package Framework (MPF) are helpers over blessed interop assemblies to the native IDE.

Note: The language services and shell parts of the MPF are shipped as DLLs, but the project base classes are provided only in source code form, and you compile them into your package.

Sidebar about versioning: Versions ship using an interop assembly and a helper library to facilitate development. When they have to break backwards compatibility, they ship exactly the previous interop assemby plus a new interop assembly that contains only new changes ("delta assembly"); both interop assemblies can be loaded in the same application domain; a new helper library bridges across both interop assemblies. With a few exceptions (e.g., WinForms), these guarantees allow customers to write a single binary that works in two successive versions, either targetting the lowest-common denominator by using the previous helper library, or "light up" on the newest version by using the newer helper library.

Tool Windows/Document Windows

  • The window architecture supports a broad range of existing UI (which makes adding WPF support less surprising).
  • Tool windows are typically single instance and can float, doc, tab, or be an MDI child.
  • Document windows (editor windows) are multi instanced, MDI child, always owned by a project, and associated with a document.

CommandBars/Command Routing

  • Data and interfaces are similar to Office (branched a while back); using metadata from packages, the IDE merges commands into a complete UI -- without loading the packages. See *.vsct (XML) for definitions of menus, commands, toolbars, and context menus.
  • Routing determines which commands are visible / enabled in a given context: add-ins first, active window, active project and its parents, and then finally, the global environment and packages.

Standard Editors/Custom Editors

  • Editor is a document window.
  • The factory is not the package itself, but another "editor factory". In the simple one view case, you pass an editor document to the service that shows the editor view. In a more general multi-view data vs. view case, there are "document data" and "document view" objects to manage.
  • Register for your format and use priority to indicate how well you can handle the format. (Highest priority of 50 is default; lowest priority will be lowest on the list.)
  • There's a range of integration between the editor and the IDE. At least, the editor can be an external EXE, and VS will launch it. At the most integrated, be a hierarchy in a tool window, like the VC Resource Editor. There are examples of nearly each of the 7 ratchets of integration.

Running Document Table

  • May not need to think about this, but its here to handle the fact that the user might want to edit a document in an incompatible editor, and while the IDE can shut down the views, it needs to talk to the editors, so they can shut down and clean up the document object.

http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=vsxconf&DownloadId=3136

 


Posted Sep 15 2008, 06:26 PM by jeffrey-schlimmer

Comments

Jason Haley wrote Interesting Finds: September 16, 2008
on 09-16-2008 8:09 AM

Add a Comment

(required)  
(optional)
(required)  
Remember Me?