Is there an API for Sourcesafe to retrieve the total code lines in source control?

I am looking for a way to access the projects stored in Sourcesafe along with their total lines of code and possibly the overall number of classes, among other metrics. Is there a Software Development Kit (SDK) available for Sourcesafe, specifically for the 2005 version, that would enable me to achieve this?

Additionally, is there a file within Sourcesafe that catalogs all of the projects? If so, I could utilize that information to calculate the total line count.

Thank you!

To retrieve the total lines of code in Visual SourceSafe (VSS) 2005, you don't have a direct API for this purpose, but you can utilize the VSS Interop library that allows you to automate some of the interactions with the SourceSafe database.

Here's a basic approach to achieve this:

  1. Use the SourceSafe Interop Library: You can use the SourceSafe automation library (Microsoft.VisualStudio.SourceSafe.Interop.dll) to interact with the SourceSafe database programmatically.
  2. Script the Line Counting: Write a script in a language like C# or VB.NET that utilizes the Interop library to checkout files and count lines. This involves scripts pulling all projects and iterating through each file to calculate lines of code.
  3. Locate Project Listing: The VSS database structure does not provide a single file listing all projects somewhat aligned like modern code repositories. Instead, interact with the projects through the VSS interface or scripts.

Here's a snippet in C# to get you started:

using System; using Microsoft.VisualStudio.SourceSafe.Interop;

class LineCounter
{
static void Main()
{
VSSDatabase db = new VSSDatabase();
db.Open(@“C:\Path\To\srcsafe.ini”, “username”, “password”);
// Add logic to iterate projects and count lines here
}
}

Remember, access to VSS might be limited depending on your network and authorization settings. Script execution requires careful permission handling. For accurate line counts and additional metrics, consider integrating an external static analysis tool after files are retrieved. This will ensure precise measurement of classes, lines, and more complex metrics.

To get the total lines of code from Visual SourceSafe 2005, there's no direct API, but you can leverage the SourceSafe Interop library.

  • SourceSafe Interop Library: Use Microsoft.VisualStudio.SourceSafe.Interop.dll to automate interactions with the VSS database.
  • Scripting: Write a script in C# using the Interop library to list files and count lines.

Here's a basic C# snippet:

using Microsoft.VisualStudio.SourceSafe.Interop;

class LineCounter {
static void Main() {
VSSDatabase db = new VSSDatabase();
db.Open(@“C:\Path\To\srcsafe.ini”, “username”, “password”);
// Implement file iteration and line counting logic here
}
}

Note: For project listing, interact through VSS interface or scripts, as it lacks a comprehensive mapping file. Consider permissions for accessing VSS.