Implementing and Using Automation Extenders

The Automation Extenders portion of the Visual Studio .NET automation model provides the ability to add or filter properties that are displayed in a specified project type. For example, Visual Studio .NET includes a Visual Basic .NET code model with an object that represents a Visual Basic .NET class; when an ISV creates a wizard for building middle-tier business objects, they might decide to extend the Visual Basic .NET class model to provide a model of the kind of business object the Visual Basic .NET class implements.

When an enterprise developer selects the class item in Solution Explorer and modifies the code that the wizard creates, or places the editor's insertion point inside the class definition, then the ISV might want the Properties window to show additional properties of the class — properties that are pertinent because it is a middle-tier business object definition. Automation Extenders allow you to do this, and more.

The objects in the Automation Extenders object model are:

Object Name Description
IExtenderProvider interface Represents an Extender Provider.
IExtenderProviderUnk interface Represents an unknown Extender Provider.
IExtenderSite interface Site object for an Automation Extender.
IFilterProperties interface When implemented, allows an Extender to prevent properties from displaying in the Properties window.
ObjectExtenders object Provides access to Automation Extenders.

Using these objects, you can:

  • Add additional properties to objects in Visual Studio .NET, accessible either through the Properties window or through code.
  • Hide properties so that they do not appear in the Properties window.
  • Replace a property with one of the same name, but one that accepts only a narrowed domain of values.

Automation Extenders Example

For an example of how to use Automation Extenders to add additional properties and methods to a Visual Studio .NET object, see the sample "Solution Extender Add-in" on the Automation Samples for Visual Studio .NET web page.

The SolutionExtender sample extends both the Solution Properties window display object as well as the DTE.Solution automation object and adds four new properties: Notes, Created, LastAccessed, and LastModified. You can reference the new properties by using DTE.Solution as shown in this macro:

Sub ShowNotes()
    Dim extender As Object
    extender = DTE.Solution.Extender("SolutionMisc")
    MsgBox(extender.Notes)
End Sub

To run the sample

  1. Build and deploy the SolutionExtender solution.
  2. Add the registration entries in the SolutionExtender.reg using the command line regedit file SolutionExtender.reg.
  3. Run devenv.exe and either open or create a new solution.
  4. Select the Solution node in Solution Explorer to view the new properties.

See Also

Adding and Handling Commands | Creating and Controlling Environment Windows | Creating Add-Ins and Wizards | Creating an Add-In | Creating a Wizard | Extensibility Reference | Automation Object Model Chart