write an Add-In (or buy one) like our wondeful .NET Refactor.">
KnowDotNet Visual Organizer

Editing your Class Templates in Visual Studio .NET

by William Ryan
Print this Article Discuss in Forums

There are many things that I do over and over each day that would make great candidates for automation. One of the first things that comes to mind is creating "regions" in my code. My company (and probably most that use regions) has some standards for our regions, for example Public Properties, Public Methods, Constants, Private Variables etc. One way of automating this task is to write an Add-In (or buy one) like our wondeful .NET Refactor. While this approach does the job very well, it's done after the fact and well, you may want to get creative in a way that we didn't provide. One of the easiest ways to accomplish this is to edit the Template for Add Class for instance:
Navigate to \Program Files\Visual Studio .NET 2003\VC#\VC#Wizards\CSharpAddClassWiz\Templates\1033\NewCSharpFile.cs. Open this up and edit away:
using System;
using System.Data;
namespace [!output SAFE_NAMESPACE_NAME]
{
/// <summary>
/// Summary description for [!output SAFE_CLASS_NAME].
///
public class [!output SAFE_CLASS_NAME]
{
public [!output SAFE_CLASS_NAME]()
{
//
// TODO: Add constructor logic here
//
}
          #region Public Properties
          #endregion

          #region Public Methods
          #endregion

          #region Private/Protected Variables
          #endregion

          #region Constants
          #endregion

}
}

Viola' . Your done. Obviously there's a whole h3ll of a lot more you can do with this stuff - but I've just started digging into it - will post other more compelling things as I come across them. BTW, I'm guessing (but not sure) the same works for VB.NET. Didn't mean to leave you guys out but like I said, I'm pretty new to playing with these. When I get through some more complex stuff I'll update everything for VB.NET

Writing Add-Ins for Visual Studio .NET
Writing Add-ins for Visual Studio .NET
by Les Smith
Apress Publishing