That's "Yet Another Little Tool"... In an endless series of diversions to keep myself somewhat challenged, last night I wrote a little tool that applies a header to C# source files.
See the screen shot below.
The header text box is directly editable and recognizes tokens opened by "[" and closed by "]". When detected, a row is added (or removed if an existing field is removed from the header) to the Replaceable Fields grid view. The grid view displays an image in the first column coupled the the feedback column (which in turn indicates whether the field is supported, properly constructed and a value provided for if not an auto field or a Subversion field--we will talk about this in a minute). The second column is the name of the replaceable field, the third column is the value to replace the field name with in the header text (if the field is auto field or a Subversion field, the value is not supplied manually).
So, what does this mean? I can create (and save and load, incidentally) header templates which will automatically be appended to any C# source file. Furthermore, if a Subversion URL is provided that matches the source directory, the tool will query Subversion and automatically populate the SVN:AUTHOR field and the SVN:CREATED_DATE field and optionally append Subversion log messages to the end of the source file as comments.
Also, the tool supports a limited vocabulary of AUTO:* fields, such as the FILE (file name) auto field. Auto fields are, as you might expect, automatically filled in for you.
The rest of the fields such as COMPANY NAME, PRODUCT NAME, and COPYRIGHT use name/value pairs supplied by the user. See the screen shot below. Any number of fields may be added to the header.
Probably the most interesting thing about this little tool is the use of SharpSVN to query Subversion for information about the source files. Either I am missing something, or the documentation is really quite lacking for SharpSVN. I was able to figure out how to do the following:
- Connect to an Subversion repository
- Get the revision list for a particular file
- Get additional information about a file for the first revision (in order to retrieve the AUTHOR and CREATED_DATE fields)
- Get the list of log messages supplied during check in (as I mentioned, these are optionally appended to the end of the source file as comments).
Here is the code snippet: