Click here to Skip to main content
Click here to Skip to main content

Customizing C# Wizard Templates in Visual Studio .NET 2003

, 5 Aug 2005
Rate this:
Please Sign up or sign in to vote.
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:

/* 
* $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

Share

About the Author

Jónas Antonsson
Web Developer
Iceland Iceland
Jónas B. Antonsson is a professional software developer. He's been in the business for eight years and has enjoyed some success.

Comments and Discussions

 
GeneralBetter articles PinmemberJónas Antonsson5-Aug-05 8:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 5 Aug 2005
Article Copyright 2005 by Jónas Antonsson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid