Visual Studio .NET Code Generation Macros

I'm a programmer and I write allot of redundant code, e.g. modules, classes, templates, etc.   This tends to waste allot of my time since it's mostly infrastructure and not the actual business logic that makes the program do its work.  So, I've made some Visual Studio .NET macros (written in VB, of course) that read and process source code templates (text documents) and insert the result at the current cursor position in the active text document.  You can download both the macro code and [my] source code templates below.

Download the Visual Studio .NET macros and C++ source code templates here.

Installation is easy.  Microsoft Visual Studio .NET places its macros in your local profile, specifically in your "My Documents" directory where it creates the sub-directory "Visual Studio Projects\VSMacros".  Extract the contents of the zip file into that directory.  After extracting you should have a sub-directory named "SourceCodeTemplates" in "Visual Studio Projects\VSMacros".  Next you need to load the macros into Microsoft Visual Studio .NET.  Start by selecting "Tools"+"Macros"+"Macro Explorer" from the menu.   Then, in the macro explorer, right-click the mouse on "Macros" in the tree and select "Load Macro Project ..." on the resulting popup-menu.  Finally, browse to and open "My Documents\Visual Studio Projects\VSMacros\SourceCodeTemplates\SourceCodeTemplates.vsmacros".  That's it! :-)

The template files, in "Visual Studio Projects\VSMacros\SourceCodeTemplates\Templates", are nothing more than plain text documents with embedded template macros.   A template macro has the form:

$(<cmd> "<param1>" "<param2>" ...)

Where <cmd> is the template macro command and "<param>" is a command parameter.  Following is a list of currently implemented commands:

$(SetVar <var_name> <var_value>) Assign <var_name> = <var_value>.  Nothing is inserted into the active document.
$(GetVar <var_name>) Insert the value of <var_name> into the active document.
$(QueryUser <prompt> <default_response>) Prompt the user for text input with the prompt <prompt>.  The text entered by the user is inserted into the active document.  Note that the text is subject to template macro preprocessing so the metacharacters '\', '$', and ')' need to be escaped with '\'.
$(ToUpper <text>) Convert <text> to uppercase and insert it into the active document.
$(ToLower <text>) Convert <text> to lowercase and insert it into the active document.
$(Replace <regex_search_spec> <replace_text> <text_to_search>) Replace all occurances of <regex_search_spec> in <text_to_search> with <replace_text> and insert the result into the active document.
$(ModuleName) Inserts the filename of the active document without the extension into the active document.
$(ModuleExt) Inserts the filename extension of the active document into the active document.
$(UUID) Inserts a UUID/GUID (via uuidgen.exe) into the active document.
$(DateTime <format>) Inserts the current date/time into the active document.  See System.Globalization.DateTimeFormatInfo in the .NET help for the format of the <format> field.
$(Exec <command_line> <stdout_var_name> <stderr_var_name>) Execute <command_line> in a command shell and put the result from standard output into <stdout_var_name> and standard error into <stderr_var_name>.  Nothing is inserted into the active document.

Commands can be nested.  This allows commands to be used in a compound fashion in order to implement more complex operations.  For example, suppose you want to Ask the user for a filename, convert it to uppercase, and stick it in a variable.  Here's how you would do it:

$(SetVar "FilenameVar" "$(ToUpper "$(QueryUser "Please enter filename")")")

Now suppose you want to insert the filename somewhere in the document.  Here's how you would do it:

$(GetVar "FilenameVar")