Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Customizing C# Wizard Templates in Visual Studio .NET 2003

2.33/5 (5 votes)
5 Aug 20053 min read 1  
How to customize VS.NET 2003 C# templates to accommodate default comments and Visual SourceSafe keywords.

Introduction

This is a really short article on an interesting subject. It is intended to show how easy it is to change the default C# templates used when new items are created within Visual Studio .NET 2003. This can really come in handy, for example if you want to include a fixed comment in all your classes or use Visual Source Safe keywords to generate a log history within each class file.

Setup

Most programmers have to follow some company centric programming procedures and I am no exception. Where I work we have to include fixed comment headers in all classes we create and we use Visual SourceSafe keywords to keep track of the class history within the class file (VSS keywords are a way to allow VSS to place certain information directly into your file to create a file header for you).

Leave it to Murphy - Of course, it was very common to find classes all over the place that did not adhere to the procedure. People forgot to add the comments, the keywords or both. So, we thought of changing the Visual Studio template files for class creation. The result of that effort is the main topic of this article.

Context

I want to make it absolutely clear that this article does not focus on VSS keywords or a technical explanation of Visual Studio .NET wizard templates. Other articles or sources have covered these issues already and so adding my take would probably be a bit redundant. If you want to familiarize yourself with either wizard templates or VSS keywords then please visit the links found in the "Further Information" section.

The juice

The wizard template files for C# can be located in the following directory: [Visual Studio .NET 2003 Install Directory]\VC#\VC#Wizards. In my case that would translate to: C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards. Each [...Wiz] directory contains the "Templates\1033" directories. Each "1033" directory contains the template file for the corresponding wizard. If I wanted to change the template for normal classes on my local computer, I would edit the following file: C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpClassWiz\Templates\1033\NewCSharpFile.cs. Relatively easy stuff. Therefore, the edited version of my class template includes a default comment and a couple of VSS keywords. It looks like this:

C#
/* 
* $Header: $
* $Log: $ 
*/
using System;
namespace [!output SAFE_NAMESPACE_NAME]
{
    /// <summary>
    /// Summary description for [!output SAFE_CLASS_NAME].
    /// <para>Copyright (C) 2005 Jónas Antonsson - My Company ltd.</para>
    /// </summary>
    public class [!output SAFE_CLASS_NAME]
    {
        /// <summary>
        /// Default constructor.
        /// </summary>
        public [!output SAFE_CLASS_NAME]()
        {
        }
    }
}

Extended use

Of course, this cute little article is fixed on C#. Wizard templates for other VS.NET 2003 supported languages are also easily customizable. For example, my wizard templates for Visual Basic or J# can be located here:

  • C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards
  • C:\Program Files\Microsoft Visual Studio .NET 2003\VJ#\vjsharpwizards

Please note that these are absolute paths derived from the setup of my system.

Further information

For further information on the template files visit:

For further information on VSS keywords (and more VSS goodies) visit:

My blog:

Revision history

  • 7th August, 2005:
    • Added a couple of chapters to set up a context for the article.
    • Added "Revision history".

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here