posted on Saturday, January 08, 2005 8:36 PM by johnwood

Source Code Metrics Pt 1: Line Counter

Recently I've been working on having our nightly build automatically generate some statistics for all our C# projects. Just some stats that show me the size and complexity of the source, so I can get an idea of how projects are progressing.

I'm starting with something that can count the total number of lines of source code. It's a simple utility that takes a path, looks for .csproj files in all folders (in and below the path), and counts the lines in all the source files in that project. It then reports the total number of lines, .cs files and projects that were found.

It deliberately misses out some auto-generated files. It determines this by the filename: if there's an equivalent .xsd or .rpt file then it ignores that file.

You run the utility with the path to start in as the argument (eg. countlines c:\mysource ).

Anyway in case anyone else ever wants this, you can find it at http://www.serviceframework.com/services/countlines.zip .

The source code for this utility can be downloaded here.

Let me know if you find any problems!

Comments