Welcome to CodeSmith
CodeSmith's Main Features
What's New
Working with CodeSmith
Getting Started with CodeSmith
Launching CodeSmith Explorer
Opening a Template
Setting Properties
Generating Code
Inspecting the Template
Where to Go From Here
Writing Your First Template
Spotting the Need
Creating the Template
Start with the Result
Static Content in the Template
Making the Content Dynamic
Adding Property Directives
Using Properties in the Template
Compiling the Template and Generating Code
Writing a Template with Database Metadata
HTTP Endpoints in SQL Server 2005
The Desired SQL Statements
Creating the Template in CodeSmith Studio
Setting up Enumerated Properties
Setting up a SQL Property
Writing the Database Code
Testing the Final Result
What is CodeSmith Explorer?
The CodeSmith Explorer Toolbar
Managing the Folder Tree
Editing Templates
Executing Templates
Working with the Output Panel
Visual Studio Integration
CodeSmith Explorer in Visual Studio
Using a CodeSmith Project inside Visual Studio
The CodeTemplate Directive
Including Comments
Declaring and Using Properties
Declaring a Simple Property
Declaring an Enumerated Property
Property Validation
Escaping ASP.NET Tags
The CodeSmith Objects
The CodeTemplate Object
Overriding the GetFileName Method
Overriding the ParseDefaultValue Method
Overriding the Render Method
Template Events
The OnInit Event
The OnPreRender Event
The OnPostRender Event
The OnPropertyChanged Events
The Response Property
The Progress Object
The CodeTemplateInfo Object
What is CodeSmith Studio?
The CodeSmith Studio User Interface
Template Windows
The Template Tab
The Output Tab
The Compiled Source Tab
The Template Explorer
The Schema Explorer
The Properties Window
The Output Window
Menus
The File Menu
The Edit Menu
The View Menu
The Tools Menu
The Window Menu
The Help Menu
The CodeSmith Studio Toolbar
Using the CodeSmith Studio Editor
Bookmarks
Bracket Highlighting
Content Insertion
Find and Replace
Incremental Search
Keyboard Shortcuts
Line Modification Markers
Outlining
Statement Completion
Tab Groups and Split Windows
Building, Running, and Compiling Templates
Working with CodeSmith Project Files
Customizing CodeSmith Studio
Using a CodeSmith Map
Cached Property Set Values
Setting up a DataDirectory for CodeSmith Connection Strings
Using a CodeSmith Project to Generate Anywhere
Using a CodeSmith Project inside Visual Studio
Using CodeSmithProject from CodeSmith Studio
Using CodeSmith project from Windows Explorer
Using a CodeSmith Project from MSBuild
Anatomy of a CodeSmith Project File
CodeSmith Project Manage Outputs
CodeSmith Project Generate Outputs
CodeSmith Project Options
Using ActiveSnippets
ActiveSnippets Configuration
Understanding CodeSmith's Code Behind Model
Referencing Assemblies
Importing Namespaces
Including External Files
Sharing Common Code
Debugging Templates
Compiling in Debug Mode
Outputting Trace and Debug Information
Setting Breakpoints with Debugger.Break()
Using Sub-Templates
Registering Sub-Templates
Merging Properties into the Parent Template
Copying Properties from the Parent Template
Setting Properties in a Sub-Template
Rendering a Sub-Template
A Sub-Template Example
Writing to Multiple Outputs
Driving Templates With Metadata
Using .NET Types
Using SchemaExplorer
Connection Strings
Choosing Objects
The SchemaExplorer Object Model
Sorting Collections
Using Extended Properties
The XmlProperty Directive
XML Property Examples
Custom Metadata Sources
Adding Designer Support
Adding Property Set Support
Incorporating CodeSmith into Your Build Process
Using a CodeSmith Project from Command-Line
Basic Console Application Usage
Handling Input
Specifying Properties on the Command Line
Default Output Files in Templates
Compiler Options
Auto Executing Generated SQL Scripts
Merge Strategies
InsertRegion Merge Strategy
PreserveRegions Merge Strategy
Defining Regions in Non-Default Languages
Defining Your Own Merge Strategy
Active vs. Passive Generation
Using Inheritance to Enable Active Generation
Using Merge Strategies to Enable Active Generation
Using .NET 2.0 Partial Classes to Enable Active Generation
Using the CodeSmith API
Programmatically Executing Templates
Template Caching
Upgrading CodeSmith 2.x Templates
Building a Custom Schema Provider for SchemaExplorer
Using CodeSmith.CustomProperties
FileNameEditor
StringCollection
CodeSmith.BaseTemplates
OutputFileCodeTemplate
SqlCodeTemplate
StringUtil
ScriptUtility
Frequently Asked Questions
Tips and Tricks
Home Page
Support
CodeSmith Community
Template Gallery
Sales
System Requirements
CodeSmith Template Syntax Reference
CodeSmith Samples
Copyrights and Trademarks
Software Licenses
CodeSmith Editions
Batch Members
Batch Constructor
Content Property
LineCount Property
StartLineNumber Property
Properties
Batch Class
OutputFileCodeTemplate Members
OutputFileCodeTemplate Constructor
_outputFile Field
Fields
OutputFile Property
Properties
OnPostRender Method
Methods
OutputFileCodeTemplate Class
ScriptError Members
ScriptError Constructor
Class Property
LineNumber Property
Message Property
Number Property
Procedure Property
State Property
Properties
ToString Method
Methods
ScriptError Class
ScriptErrorCollection Members
ScriptErrorCollection Constructor
Count Property
Item Property
Properties
CopyTo Method
GetEnumerator Method
Methods
ScriptErrorCollection Class
ScriptResult Members
ScriptResult Constructor
Errors Property
Success Property
Properties
ToString Method
Methods
ScriptResult Class
ScriptUtility Members
ScriptUtility Constructor ()
ScriptUtility Constructor (String, String)
ScriptUtility Constructor
ConnectionString Property
Script Property
Properties
ExecuteScript Method ()
ExecuteScript Method (String, String)
ExecuteScript Method (String, String, SqlInfoMessageEventHandler)
ExecuteScript Method
Methods
ScriptInfoMessage Event
Events
ScriptUtility Class
SqlCodeTemplate Members
SqlCodeTemplate Constructor
GetCamelCaseName Method
GetCSharpVariableType Method
GetMemberVariableDeclarationStatement Method (ColumnSchema)
GetMemberVariableDeclarationStatement Method (String, ColumnSchema)
GetMemberVariableDeclarationStatement Method
GetMemberVariableDefaultValue Method
GetMemberVariableName Method
GetPropertyName Method
GetReaderMethod Method
GetSpacedName Method
GetSqlDbType Method
GetSqlParameterExtraParams Method
GetSqlParameterStatement Method (ColumnSchema)
GetSqlParameterStatement Method (ColumnSchema, Boolean)
GetSqlParameterStatement Method
GetSqlParameterStatements Method (String, ColumnSchema)
GetSqlParameterStatements Method (String, ColumnSchema, String)
GetSqlParameterStatements Method
GetSqlReaderAssignmentStatement Method
GetValidateStatements Method
IncludeEmptyCheck Method
IncludeMaxLengthCheck Method
IsUserDefinedType Method
Methods
SqlCodeTemplate Class
StringUtility Members
IsPlural Method
IsSingular Method
ToCamelCase Method
ToPascalCase Method
ToPlural Method
ToSingular Method
ToSpacedWords Method
Methods
StringUtility Class
CodeSmith.BaseTemplates
AssemblyFilePicker Members
AssemblyFilePicker Constructor
EditValue Method (ITypeDescriptorContext, IServiceProvider, Object)
EditValue Method
GetEditStyle Method (ITypeDescriptorContext)
GetEditStyle Method
Methods
AssemblyFilePicker Class
FileDialogAttribute Members
FileDialogAttribute Constructor
CheckFileExists Property
CheckPathExists Property
DefaultExtension Property
DialogType Property
Filter Property
IsCheckFileExistsSet Property
IsCheckPathExistsSet Property
IsDefaultExtensionSet Property
IsFilterSet Property
IsTitleSet Property
Title Property
Properties
FileDialogAttribute Class
FileDialogType Enumeration
FileNameEditor Members
FileNameEditor Constructor
EditValue Method (ITypeDescriptorContext, IServiceProvider, Object)
EditValue Method
GetEditStyle Method (ITypeDescriptorContext)
GetEditStyle Method
InitializeDialog Method
Methods
FileNameEditor Class
IStringCollection Members
Count Property
IsSynchronized Property
SyncRoot Property
Properties
CopyTo Method
GetEnumerator Method
Methods
IStringCollection Interface
IStringEnumerator Members
Current Property
Properties
MoveNext Method
Reset Method
Methods
IStringEnumerator Interface
IStringList Members
IsFixedSize Property
IsReadOnly Property
Item Property
Properties
Add Method
Clear Method
Contains Method
IndexOf Method
Insert Method
Remove Method
RemoveAt Method
Methods
IStringList Interface
IStringStringCollection Members
Count Property
IsSynchronized Property
SyncRoot Property
Properties
CopyTo Method
GetEnumerator Method
Methods
IStringStringCollection Interface
IStringStringDictionary Members
IsFixedSize Property
IsReadOnly Property
Item Property
Keys Property
Values Property
Properties
Add Method
Clear Method
Contains Method
Remove Method
Methods
IStringStringDictionary Interface
IStringStringEnumerator Members
Current Property
Entry Property
Key Property
Value Property
Properties
MoveNext Method
Reset Method
Methods
IStringStringEnumerator Interface
IStringStringList Members
IsFixedSize Property
IsReadOnly Property
Item Property
Properties
Add Method
Clear Method
Contains Method
IndexOf Method
Insert Method
Remove Method
RemoveAt Method
Methods
IStringStringList Interface
NameValueCollection Members
NameValueCollection Constructor ()
NameValueCollection Constructor (Int32)
NameValueCollection Constructor (NameValueCollection)
NameValueCollection Constructor (NameValueEntry[])
NameValueCollection Constructor
Capacity Property
Count Property
InnerKeys Property
InnerValues Property
IsFixedSize Property
IsReadOnly Property
IsSynchronized Property
Item Property
Keys Property
SyncRoot Property
Values Property
Properties
Add Method (NameValueEntry)
Add Method (String, String)
Add Method
AddRange Method (NameValueCollection)
AddRange Method (NameValueEntry[])
AddRange Method
Clear Method
Clone Method
Contains Method
ContainsKey Method
ContainsValue Method
CopyTo Method
Equals Method (NameValueCollection)
Equals Method
GetByIndex Method
GetByKey Method
GetEnumerator Method
GetKey Method
GetKeyList Method
GetValueList Method
IndexOf Method
IndexOfKey Method
IndexOfValue Method
Insert Method
Remove Method
RemoveAt Method
SetByIndex Method
SetByKey Method
Synchronized Method
ToArray Method
ToString Method
TrimToSize Method
Methods
NameValueCollection Class
NameValueCollectionEditor Members
NameValueCollectionEditor Constructor
EditValue Method (ITypeDescriptorContext, IServiceProvider, Object)
EditValue Method
GetEditStyle Method (ITypeDescriptorContext)
GetEditStyle Method
Methods
NameValueCollectionEditor Class
NameValueCollectionEditorUI Members
NameValueCollectionEditorUI Constructor
NameValueCollection Property
Properties
Dispose Method (Boolean)
Dispose Method
End Method
Start Method
Methods
NameValueCollectionEditorUI Class
NameValueCollectionSerializer Members
NameValueCollectionSerializer Constructor
LoadProperty Method
ParseDefaultValue Method
ReadPropertyXml Method
SaveProperty Method
WritePropertyXml Method
Methods
NameValueCollectionSerializer Class
NameValueCollectionTypeConverter Members
NameValueCollectionTypeConverter Constructor
CanConvertFrom Method (ITypeDescriptorContext, Type)
CanConvertFrom Method
CanConvertTo Method (ITypeDescriptorContext, Type)
CanConvertTo Method
ConvertFrom Method (ITypeDescriptorContext, CultureInfo, Object)
ConvertFrom Method
ConvertTo Method (ITypeDescriptorContext, CultureInfo, Object, Type)
ConvertTo Method
Methods
NameValueCollectionTypeConverter Class
NameValueEntry Members
NameValueEntry Constructor
Key Property
Value Property
Properties
Implicit NameValueEntry to DictionaryEntry Conversion
Implicit DictionaryEntry to NameValueEntry Conversion
Type Conversions
NameValueEntry Structure
StringCollection Members
StringCollection Constructor ()
StringCollection Constructor (Int32)
StringCollection Constructor (StringCollection)
StringCollection Constructor (String[])
StringCollection Constructor (Tag)
StringCollection Constructor
Capacity Property
Count Property
IsFixedSize Property
IsReadOnly Property
IsSynchronized Property
Item Property
SyncRoot Property
Properties
Add Method
AddRange Method (StringCollection)
AddRange Method (String[])
AddRange Method
Clear Method
Clone Method
Contains Method
CopyTo Method (String[])
CopyTo Method (String[], Int32)
CopyTo Method
GetEnumerator Method
IndexOf Method
Insert Method
ReadOnly Method
Remove Method
RemoveAt Method
Synchronized Method
ToArray Method
ToString Method
TrimToSize Method
Methods
StringCollection Class
StringCollection.IStringCollectionEnumerator Members
Current Property
Properties
MoveNext Method
Reset Method
Methods
StringCollection.IStringCollectionEnumerator Interface
StringCollection.Tag Enumeration
StringCollectionEditor Members
StringCollectionEditor Constructor
EditValue Method (ITypeDescriptorContext, IServiceProvider, Object)
EditValue Method
GetEditStyle Method (ITypeDescriptorContext)
GetEditStyle Method
Methods
StringCollectionEditor Class
StringCollectionEditorUI Members
StringCollectionEditorUI Constructor
StringCollection Property
Properties
Dispose Method (Boolean)
Dispose Method
End Method
Start Method
Methods
StringCollectionEditorUI Class
StringCollectionSerializer Members
StringCollectionSerializer Constructor
LoadProperty Method
ParseDefaultValue Method
ReadPropertyXml Method
SaveProperty Method
WritePropertyXml Method
Methods
StringCollectionSerializer Class
StringCollectionTypeConverter Members
StringCollectionTypeConverter Constructor
CanConvertFrom Method (ITypeDescriptorContext, Type)
CanConvertFrom Method
CanConvertTo Method (ITypeDescriptorContext, Type)
CanConvertTo Method
ConvertFrom Method (ITypeDescriptorContext, CultureInfo, Object)
ConvertFrom Method
ConvertTo Method (ITypeDescriptorContext, CultureInfo, Object, Type)
ConvertTo Method
Methods
StringCollectionTypeConverter Class
XmlSerializedFilePicker Members
XmlSerializedFilePicker Constructor
EditValue Method (ITypeDescriptorContext, IServiceProvider, Object)
EditValue Method
GetEditStyle Method (ITypeDescriptorContext)
GetEditStyle Method
Methods
XmlSerializedFilePicker Class
XmlSerializedTypeConverter Members
XmlSerializedTypeConverter Constructor
CanConvertFrom Method (ITypeDescriptorContext, Type)
CanConvertFrom Method
CanConvertTo Method (ITypeDescriptorContext, Type)
CanConvertTo Method
ConvertFrom Method (ITypeDescriptorContext, CultureInfo, Object)
ConvertFrom Method
ConvertTo Method (ITypeDescriptorContext, CultureInfo, Object, Type)
ConvertTo Method
Methods
XmlSerializedTypeConverter Class
CodeSmith.CustomProperties
ActiveSnippetConfiguration Members
ActiveSnippetConfiguration Constructor
CanWatchFile Property
ConfigurationFile Property
IsBackwardCompatible Property
SnippetMappings Property
Properties
Find Method
FindSimilar Method
LoadDefaultSettings Method
UpgradeFile Method
UpgradeSettings Method
Methods
ActiveSnippetConfiguration Class
ActiveSnippetGenerator Members
ActiveSnippetGenerator Constructor
GenerateSnippet Method
OutputUsage Method
Methods
ActiveSnippetGenerator Class
ActiveSnippetMapping Members
ActiveSnippetMapping Constructor
Alias Property
Arguments Property
DisplayName Property
PropertySet Property
SnippetUsage Property
TargetExtensions Property
TargetLanguage Property
TemplateFile Property
TemplateName Property
Properties
OnValidate Method
ToString Method
Methods
ActiveSnippetMapping Class
AssemblyResolver Members
Current Property
Properties
AddResolveCanidate Method (String})
AddResolveCanidate Method (String)
AddResolveCanidate Method
AddResolveDirectory Method (String})
AddResolveDirectory Method (String)
AddResolveDirectory Method
Dispose Method ()
Dispose Method (Boolean)
Dispose Method
Finalize Method
RemoveResolveCanidate Method
RemoveResolveDirectory Method
ResolveAssemblyPath Method (String})
ResolveAssemblyPath Method (String}, String}, Boolean)
ResolveAssemblyPath Method (String}, String}, String}, Boolean)
ResolveAssemblyPath Method (String}, String)
ResolveAssemblyPath Method (String)
ResolveAssemblyPath Method (String, String}, Boolean)
ResolveAssemblyPath Method (String, String}, String}, Boolean)
ResolveAssemblyPath Method (String, String)
ResolveAssemblyPath Method
StartAppDomainResolving Method
StopAppDomainResolving Method
Methods
AssemblyResolver Class
BusinessObjectBase Members
BusinessObjectBase Constructor
HasErrors Property
InEdit Property
IsDirty Property
Properties
BeginEdit Method
CancelEdit Method
ClearColumnError Method
ClearColumnErrors Method
EndEdit Method
FireRowResetEvent Method
GetColumnError Method
OnBeginEdit Method
OnCancelEdit Method
OnEndEdit Method
OnPropertyChanged Method
OnValidate Method
RollbackChanges Method
SaveState Method
SetColumnError Method
Validate Method
Methods
PropertyChanged Event
Events
BusinessObjectBase Class
CodeGeneratorBase Members
CodeGeneratorBase Constructor
Debug Property
KeepTempFiles Property
Properties Property
Verbose Property
Properties
CreateExceptionMessage Method
GetCodeTemplateInfo Method
GetVariables Method
OnGeneratorError Method (GeneratorErrorEventArgs)
OnGeneratorError Method (String, Boolean, Int32, String, Int32, Int32)
OnGeneratorError Method (String, Exception)
OnGeneratorError Method
OnOutputString Method (MessageEventArgs)
OnOutputString Method (String)
OnOutputString Method (String, Object[])
OnOutputString Method
OnPreOutputWritten Method
OnProgress Method (GeneratorProgressEventArgs)
OnProgress Method (Int32, Int32)
OnProgress Method
OnStatusChanged Method (MessageEventArgs)
OnStatusChanged Method (String)
OnStatusChanged Method
OutputCompilerErrors Method
ReplaceVariables Method
WriteComment Method
WriteHeader Method
Methods
GeneratorError Event
OutputString Event
PreOutputWritten Event
Progress Event
StatusChanged Event
Events
CodeGeneratorBase Class
CodeSmithDomainFactory Members
CodeSmithDomainFactory Constructor ()
CodeSmithDomainFactory Constructor (String)
CodeSmithDomainFactory Constructor
CodeSmithDomain Property
Properties
CreateInstance Method ()
CreateInstance Method (Object[])
CreateInstance Method
Dispose Method
Finalize Method
NeedCodeSmithDomain Method
Methods
CodeSmithDomainFactory Class
CodeSmithLicense Members
AllowProfessionalFeature Property
AllowSDKFeature Property
AllowServerFeature Property
AllowStandardFeature Property
ExpirationDate Property
IsBeta Property
IsFullTrial Property
IsProfessional Property
IsProfessionalTrial Property
IsSDK Property
IsServer Property
IsStandard Property
IsTrial Property
LicensedOrganization Property
LicensedUser Property
Properties
Deactivate Method
GetBitmap Method
GetInstallEdition Method
GetLicenseName Method
IsDeactivateAllowed Method
IsRegistrationAllowed Method
ShowRegistrationDialog Method
ValidatePublisher Method
Methods
CodeSmithLicense Class
CodeTemplate Members
CodeTemplate Constructor
CodeTemplateInfo Property
ContextData Property
Progress Property
RegisteredOutputs Property
RegisteredReferences Property
Response Property
State Property
ValidationErrors Property
Visible Property
Properties
CopyPropertiesTo Method (CodeTemplate)
CopyPropertiesTo Method (CodeTemplate, Boolean)
CopyPropertiesTo Method
Create Method ()
Create Method (Boolean)
Create Method
Dispose Method ()
Dispose Method (Boolean)
Dispose Method
Finalize Method
GetCodeTemplateInstance Method (String)
GetCodeTemplateInstance Method (String, Boolean)
GetCodeTemplateInstance Method (String, Boolean, Boolean)
GetCodeTemplateInstance Method
GetFileName Method
GetProperties Method ()
GetProperties Method (Boolean)
GetProperties Method
GetProperty Method
GetPropertyAttribute Method
GetPropertyDescription Method
GetPropertyInfo Method
GetRequiredProperties Method
GetTemplateAttribute Method
IsPropertyRequired Method
OnError Method
OnInit Method
OnOutputRegistered Method
OnPostRender Method
OnPreOutputWritten Method (OutputCancelEventArgs)
OnPreOutputWritten Method (String)
OnPreOutputWritten Method
OnPreRender Method
OnPropertyChanged Method
OnReferenceRegistered Method
ParseDefaultValue Method
RefreshProperties Method ()
RefreshProperties Method (Boolean)
RefreshProperties Method
RegisterOutput Method (OutputFile)
RegisterOutput Method (String)
RegisterOutput Method
RegisterReference Method
Render Method
RenderToFile Method (OutputFile, Boolean)
RenderToFile Method (OutputFile, String, IMergeStrategy)
RenderToFile Method (String, IMergeStrategy)
RenderToFile Method (String, Boolean)
RenderToFile Method (String, String, IMergeStrategy)
RenderToFile Method (String, String, Boolean)
RenderToFile Method
RenderToString Method ()
RenderToString Method (String, IMergeStrategy)
RenderToString Method
RestorePropertiesFromHashtable Method
RestorePropertiesFromPropertySet Method
RestorePropertiesFromSchema Method
RestorePropertiesFromXml Method
RestorePropertiesFromXmlFile Method
SavePropertiesToHashtable Method ()
SavePropertiesToHashtable Method (Boolean)
SavePropertiesToHashtable Method
SavePropertiesToPropertySet Method
SavePropertiesToXml Method ()
SavePropertiesToXml Method (XmlWriter)
SavePropertiesToXml Method
SavePropertiesToXmlFile Method
SetContextData Method
SetProperty Method (PropertyInfo, Object)
SetProperty Method (String, Object)
SetProperty Method (XmlNode, String)
SetProperty Method
SetPropertyAttribute Method
SetPropertyDefaults Method
SetTemplateAttribute Method
SetUnknownDirectiveAttributes Method
Validate Method
Methods
OutputRegistered Event
PreOutputWritten Event
PropertyChanged Event
ReferenceRegistered Event
Events
CodeTemplate Class
CodeTemplateCache Members
CodeTemplateCache Constructor
Instance Property
InternalTemplates Property
Templates Property
Properties
Add Method
Cleanup Method
Get Method
GetTemplateCacheDirectory Method ()
GetTemplateCacheDirectory Method (Int32)
GetTemplateCacheDirectory Method
GetWithHashCode Method
Save Method
Methods
CodeTemplateCache Class
CodeTemplateCacheItem Members
CodeTemplateCacheItem Constructor
AssemblyDependencies Property
AssemblyLocation Property
CodeBehind Property
CodeSmithVersion Property
DateCreated Property
DateModified Property
Description Property
DirectoryName Property