Sunday, January 08, 2006

Visual SourceSafe RSS Generator Bug Fix

I've downloaded Greg Reinacker's c# source to generate RSS feeds from Visual SourceSafe and improved it by reducing the working set. Following is the unified diff. (Be careful of wrapped lines when you select it into a text file.) If you need a tool to apply this diff, I recommend Tortise Merge which is a part of TortiseSVN which is a Windows shell extension for Subversion.



Index: GenRss.cs
===================================================================
--- GenRss.cs (revision 12)
+++ GenRss.cs (working copy)
@@ -91,29 +91,37 @@
foreach (SourceSafeTypeLib.IVSSVersion ver in versions)
{
i++;
- if (i > maxItems)
- continue;

- string action = ver.Action;
- string file = ver.VSSItem.Name;
- string user = ver.Username;
- string vernum = ver.VersionNumber.ToString();
- string comment = ver.Comment;
+ // Kevin Greiner (2/22/2005) The following loop is
+ // specifically written to allow the foreach to completely finish. Testing has
+ // shown that aborting the foreach prematurely increases the working set
+ // 10-fold.
+ if (i <= maxItems)
+ {
+
+ string action = ver.Action;
+ string file = ver.VSSItem.Name;
+ string user = ver.Username;
+ string vernum = ver.VersionNumber.ToString();
+ string comment = ver.Comment;

- DateTime dt = ver.Date;
+ DateTime dt = ver.Date;

- w.WriteStartElement("item");
- w.WriteElementString("title", String.Format("{0}/{1}", action, file));
- w.WriteStartElement("guid");
- w.WriteAttributeString("isPermaLink","false");
- w.WriteString(String.Format("{0}:{1}:{2}", file, vernum, action));
- w.WriteEndElement();
- w.WriteElementString("description", String.Format("{0}",comment));
- w.WriteElementString("pubDate", dt.ToUniversalTime().ToString("r"));
- w.WriteElementString("creator", "http://purl.org/dc/elements/1.1/", user);
- w.WriteEndElement(); // item
+ w.WriteStartElement("item");
+ w.WriteElementString("title", String.Format("{0}/{1}", action, file));
+ w.WriteStartElement("guid");
+ w.WriteAttributeString("isPermaLink","false");
+ w.WriteString(String.Format("{0}:{1}:{2}", file, vernum, action));
+ w.WriteEndElement();
+ w.WriteElementString("description", String.Format("{0}",comment));
+ w.WriteElementString("pubDate", dt.ToUniversalTime().ToString("r"));
+ w.WriteElementString("creator", "http://purl.org/dc/elements/1.1/", user);
+ w.WriteEndElement(); // item
+
+ }
+
+ Marshal.ReleaseComObject(ver);

- Marshal.ReleaseComObject(ver);
}