Export (0) Print
Expand All

Implementing and Using Automation Extenders

The Automation Extenders portion of the Visual Studio automation model provides the ability to add or filter properties that are displayed in a specified project type. For example, Visual Studio includes a Visual Basic code model with an object that represents a Visual Basic class.

You can use automation extenders to add new properties to the existing properties in an object. You can also use extenders to filter the properties that display in the project's property page.

You can use an extender to allow users to select a class item in Solution Explorer and modify the code that the wizard creates. You can also use an extender to allow users to place the editor's insertion point inside the class definition and have the Properties window display additional properties of the class.

Caution noteCaution:

The extender manager maintains an internal cache of extender objects, and must be notified when they are being destroyed. You must call NotifyDelete immediately upon destroying extender objects. You must not wait for the application to become idle, because other Visual Studio components may try to access the destroyed extender object before you call the method. If this happens, Visual Studio may crash.

The following are the objects in the Automation Extenders object model.

Automation Extender Interfaces

Description

IExtenderProvider

A specific extender provider.

IExtenderProviderUnk interface

Any extender provider.

IExtenderSite

The site object that hosts the Automation Extender.

IFilterProperties interface

When implemented, allows an extender to prevent specified properties from being displayed in the Properties window.

ObjectExtenders object

Provides access to automation extenders.

By using these objects, you can:

  • Add properties to objects in Visual Studio, 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 specific set of values.

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

The SolutionExtender sample extends both the solution Properties window display object as well as the DTE.Solution automation object. It 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 by using the command line registry 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 newly-added properties.

Date

History

Reason

Added warning about calling NotifyDelete

Content bug fix.

Community Additions

ADD
Show:
© 2015 Microsoft