VSXtra Feature List (under construction)

This page contains a summary of the most important features of VSXtra improving the developer experience with Visual Studio Extensibility and Managed Package Framework. There are a few sample code extract to emphasize the features enumerated here. To see more examples and related code, go to the home page of the project.

1. Creating packages with the new PackageBase class

Instead of using the Package class of the Microsoft.VisualStudio.Shell namespace you can use the PackageBase class of VSXtra. PackageBase adds a lot of functionality without the need to write any code:
  • Automatic initialization of VSXtra services
  • Automatic command binding for VSXtra menu command handler types and command handler methods
  • Setting up the Output window to be used by System.Console
  • Providing generic functions like GetGlobalService<>, GetPackageInstance<>, GetDialogPage<> to provide compile-time type safety.
1.1 Sample code: A simple package with a menu function displaying a message box
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using VSXtra;

namespace DeepDiver.ShowMessage
  [PackageRegistration(UseManagedResourcesOnly = true)]
  [InstalledProductRegistration(false, "#110", "#112", "1.0", IconResourceID = 400)]
  [ProvideLoadKey("Standard", "1.0", "ShowMessage", "DeepDiver", 1)]
  [ProvideMenuResource(1000, 1)]
  public sealed class ShowMessagePackage : PackageBase
    [CommandId(GuidList.guidShowMessageCmdSetString, CmdIDs.cmdidDisplayMyMessage)]
    [ShowMessageAction("Hello, World from ShowMessagePackage")]
    private static void DisplayMessage()

2. Output window handling

  • VSXtra provides you the OutputWindow static class with the predefined General, Build and Debug panes. You can write to the output pane with the good old Write and WriteLine methods just as for any text writer objects (like System.Console). By default, the System.Console class writes to the General pane of OutputWindow.
  • You can create output window panes by simple type declarations setting up the new window pane properties through attributes.
2.1 Sample code: Package sending output through the System.Console and to a user-defined output window pane
  // --- Package attributes omitted for clarity
  public sealed class CustomOutputWindowPanePackage : PackageBase
    protected override void Initialize()
      Console.WriteLine("*** Turn to the CutomPane1 and CustomePane2 output panes!");
      var pane1 = OutputWindow.GetPane<CustomPane1>();
      pane1.WriteLine("Welcome on CustomPane1!");
      var pane2 = OutputWindow.GetPane<CustomPane2>();
      pane2.WriteLine("Welcome on CustomPane2!");

    class CustomPane1: OutputPaneDefinition {}

    class CustomPane2 : OutputPaneDefinition { }

3. Visual Studio Services

VSXtra uses the same "good old" pattern of creating services as the VS SDK uses from the beginning. However, there are a few types allowing your services to be handled in much more comfortable way.
  • The VsxService<TPackage, TService> class makes it easy to define services and allowing no-code service initialization.
  • Service classes can be decorated with the Promote to automatically register golobal services.
  • The AutoCreateService registers your service with creating the service instance immediately at initialization time. Leaving this attribute will create a service that creates the service instance at the first time it is about to be used.
3.1 Sample code: Simple global service declaration with initialization-time instantiation
// --- Service behavior interface definition
public interface IMyService   
  void MyServiceMethod(string firstParam);
// --- Service address interface definition
public interface SMyService { }
// --- Service class implementation
public MyService: VsxService<OwnerPackage, SMyService>, IMyService
  public void MyServiceMethod(string firstParam) { ... }

4. Window panes

  • The WindowPane<TPackage, TUIControl> abstract base class provides a lot of functionality to support easy declaration of document windows and tool windows. The TPackage parameter defines the package owning the tool window, the TUIControl associates the window pane with the control implementing the user interface.
  • You do not need to pass an IServiceProvider instance to the window pane, it automatically provides the related package's service provider object.
  • You do not need to explicitly initialize and bind window pane related commands. Instead you can use command hanlder methods. All the initilaization is done behind the scenes.
  • All window panes have a SelectionTracker property to allow cooperation with the Properties window.
  • Window panes can access their window frames through the Frame property and subscribe to window frame events.
4.1. Tool windows
  • The ToolWindowPane<TPackage, TUIControl> abstract base class derives from WindowPane<,> and so tool windows inherit all the behavior and features of window panes.
  • There are attributes the declare the initial look and behavior of the tool window: InitialCaption, BitmapResource, Toolbar and ToolbarLocation
4.2. Tool window samples (under construction)

5. Brand new command handling infrastructure (under construction)

5.1. Command handler classes (under construction)
5.2. Command handler methods (under construction)
5.3. Toolbar commands (under construction)
5.4. Combo Box Command handlers (under construction)

6. Refined Options pages (under construction)

7. Miscellaneous utility classes

VSXtra containg many classes to helpsolving common VSX related tasks.
  • ActivityLog static class allows direct interaction with th Activity Log service of Visual Studio.
  • StringResolver<TPackage> generic class to resolve string resources in the package.
  • VsxConverter class to provide conversion between common .NET BCL enumerations and their related VSX types (e.g. MessageBoxButtons and OLEMSGBUTTON enumerations)
  • VsDebug class to provide a lightweight implementation of the Debug class in order to send diagnostic messages from a VSPackage to the Debug pane of the output window.
  • UIContext type to provide type constants like SolutionBuilding, NoSolution, SolutionExists, etc. to substitute the UI context GUID constants.
  • WindowKind type to provide type constants like CodeWindow, TaskList, SolutionExplorer, etc. to substitute the window kind GUID constants.
  • EventHooker<TEvent> generic class helps you to manage the Advise and Unadvise methods of different VSX types to handle related event interfaces.

Last edited Sep 17, 2008 at 7:34 PM by INovak, version 18


No comments yet.