ActiveSnippets Configuration

ActiveSnippet Configuration

This menu option allows you to view all ActiveSnippets, Add/Remove an ActiveSnippet, and Configure ActiveSnippets. Once you've created a template for usage as an ActiveSnippet, you must add the ActiveSnippet which maps to a CodeSmith Template.

Adding a new ActiveSnippet

The first step to creating a new ActiveSnippet is to click the Add button, and use the Template Chooser Window to browse to the CodeSmith template that will be serving as your ActiveSnippet. Once you select the template, you must configure at minimum the Template Options for the template.

Template Options

The template options tab holds the mapping information about your CodeSmith template. This information is required to allow you to have access to this template from within Visual Studio.

Example:

This example shows a TableProperties CodeSmith Template that prefers to be used in .cs (CSharp) files. The alias command to execute this ActiveSnippet is "tp".

Template:

The full path to the CodeSmith template.

Alias:

The ActiveSnippet Alias is the command to be used as the alias representing the selected CodeSmith template.

Description:

Specifies the friendly name description of the ActiveSnippet. It will be shown during the Output Usage information.

Target Extensions:

The template target language is used as a hint for ActiveSnippets that have the same name.

Template Language:

The template language shows the selected CodeSmith Template Output Language.

Argument Mapping

Configuring the arguments for an ActiveSnippet is a powerful feature because it does not force you to have to always pass all properties in for the selected CodeSmith Template as arguments.

This tab is a dual pane select box which shows all template properties to the left, and all arguments to the right. Control arrows are used to move properties to and from the Arguments window. The up and down arrows are used to setup the argument order of the ActiveSnippet.

Template Properties Box:

A window of all the property names in a template.

Arguments Box:

A window of all the arguments that will be required to use your ActiveSnippet

Example:

Given a template with two properties, SourceTable, UseCamelCasing.

SourceTable is a TableSchema property used as the base meta-data object to use for the template.

UseCamelCasing is a boolean property representing whether or not to use CamelCasing for the field.

You would then only really want to expose SourceTable as a required argument since UseCamelCasing is a fairly static property that only changes by developer style preference.

Default Property Values

The Default Property Values tab will allow you to enter possible default values for your CodeSmith Templates' Property Sheet. This will show all the properties for the ActiveSnippet based CodeSmith Template.

IMPORTANT: Values that you want to be required properties for ActiveSnippet arguments would not be filled in as a default value.

Example:

Using the example above, I would set the value of UseCamelCasing since it's a static property value.