53.1. The Anatomy of a Macro

A Visual Studio macro (it's actually called VSMacro but is commonly known just as a macro among developers) is a stand-alone package of uncompiled code that can be run by the Visual Studio IDE to automate a task.

In fact, a macro is a piece of code and nothing else. Visual Studio has a specific extension for macro packages. A file with the .vsmacros extension is a macro package and is a known extension to Visual Studio.

A .vsmacros file can contain several components. One of these components is code modules. A code module can contain one or more macros, so you can include as many macros as you like in a .vsmacros file.

A macro itself is a public method in a module that takes no parameter and returns nothing and applies the Development Tools Extensibility (DTE) API to automate something in the IDE.

The nature of macros (which are code packages) makes their deployment a little difficult. You need to move and import the package in order to deploy a macro. This is covered later in the chapter.

You saw that a macro is a subroutine without parameters but can apply any object-oriented programming concept like class or enumeration types to get its job done. You can include other classes and modules to divide your code into smaller pieces and make your job easier.

When working with macros you don't have to deal with the same concepts like solutions and projects as you have to in the Visual Studio IDE. Instead, you have to deal with a Visual Studio macros system ...

Get Professional Visual Studio® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.