There are a zillion source code line counters on the web, but at work downloading binaries is blocked at the firewall level. So when Mike asked for an estimate of the number of lines in the project, I put this simple C# 2.0 application together.
Counting lines in code isn't much fun, nor is it very precise. There are lots of ways to skin this cat including: grouping by either file type, language or module/project, then you need to decide what files to include? Only the hand coded ones, or perhaps machine generated too. It's not always easy to work out which is which. Then it occur to you: what exactly is a line of code? A simple count of carriage-returns? Non empty lines? Do I attempt exclude comments?
For the purpose of this exercise all this project does is count carriage returns and then group the result by file type. Before running it i manually extracted from Sourcesafe a subset of files. To do so requires in depth knowledge or the project files and judgement on whether it should be counted. Because different languages are used in different modules it was easy to summarise the output in a report.
The biggest problem with this approach is that it's unrepeatable. The figure will be different if I were to do this again tomorrow and it would be hard to track progress in terms of lines of code in a month's time.
I think the way forward is to make the tool rule drive. The user should be able to define a profile then run the count directly against Sourcesafe. Look out for version 0.02
