Welcome to Geekdojo Sign in | Join | Help

Jose Luis Manners

.NET and other related technologies

VSS-enabled source code header

Yes, I know we all have our feelings for VSS, but I've been using this little trick (for the lack of a better word) for several years now, and I thought it's about time for me to post it here in case is beneficial to anybody else.  At the very first line on many of my programs you will find a region similar to the following:

#region Version Header
/// <remarks>
///     $Workfile: MyLogger.cs $
///   Description: This class implements a logging mechanism by wrapping the ABC Library.
///        Author: José Luis Manners     Docs: José Luis Manners
///       Created: 07/30/2004 13:23:35pm
///      $Modtime: 08/21/2004 09:35:23am $
///     $Revision: 3 $
///     Copyright: © 2004 Company Name goes here
/// </remarks>
#endregion

This is basically a header I use to document every .cs file.  There's not worst feeling in the world than having to modify somebody else's code (or perhaps and old code of yours) and not even knowing what it's suppose to do or how its purpose has changed overtime.  What's interesting about this header is that it takes advantage of the keyword expansion capabilities of VSS, so things like file name, modification date, version, etc., are automatically updated in the code by VSS every time you do a check-in.  The keywords are those enclosed in '$', btw.

To make your life easier and avoid copy and pasting each time you create a new cs file, you can create a wizard template that has this header embedded in it, and when you create a new class the header will be automatically included with the code generated by VS.NET (you can find lots of information online on how to do modify VS.NET templates).  In my case, everytime I create a new C# file I run a macro I wrote that prompts me for the description and takes care of filling in the non-VSS sections, including putting the system date in the "Created:" session, and generates the entire header.

There is a VSS keyword which I'm not showing and that is "$History: $".  With this keyword you can have VSS keep a log of all the changes directly in your code, so information like version, remarks, name of person that checked-in that version, dates, etc., are stamped in your code.  This is basically the information you can see from within VSS when you select "Show History" on a file and click on "History Details".  Althought having all this historical information directly in the source code is a little overwhelming to some people (none the last redundant), it could also be very beneficial to others - you take your pick.

HINT:  You can put the history log on a separate region in your code, that way it's "out of your way".

For more information on VSS keyword expansion features and the entire list of available keywords see the following link:

Visual SourceSafe Keyword Expansion Support

 

Published Friday, November 10, 2006 11:14 PM by jmanners
Filed Under:

Comments

No Comments

Anonymous comments are disabled
Powered by Community Server, by Telligent Systems