Question

Possible Duplicate:
How do you count the lines of code in a Visual Studio solution?

How can I show the code metrics window in Visual Studio 2008 Professional SP1? I'm looking to see how many total lines of code my project is for school and I can't find it.

The help file said to go to View->Other Windows->Code Metrics, but this option is not available to me. I also tried right-clicking the project in the Solution Explorer to see if there was an option but there wasn't.

Where is this mythical unicorn of a feature? If the Pro version doesn't have this feature has anyone found a simple external method to count the lines in all .cs files in an automated way?

Was it helpful?

Solution

Code Metrics is only available in the Team System versions of Visual Studio 2008. If you have an Express Edition, Standard, or Professional you're out of luck.

See comments and screenshots here:

OTHER TIPS

You don't need 3rd party tools, just press CTRL+SHIFT+F, and in the window that pops up choose "use regular expression". Use this Regular Expression:

^:b*[^:b#/]+.*$

For Visual Studio 2012 and above the regular expression is:

^(?([^\r\n])\s)*[^\s+?/]+[^\n]*$

DPack does this. After installing, just go to Tools -> DPack -> Solution Statistics...

http://www.usysware.com/dpack/

I don't have that feature in my VS2008, so a few months ago I implemented a quick and dirty windows app that counts the number of CRLFs in my C# files. Granted, this counts empty lines, and lines in files generated by VS, but with a bit of tweaking, I am sure you could make it generate a good count. Here is the operative code in the Windows Form; the dlgFolder control is the FolderBrowserDialog control:

if (dlgFolder.ShowDialog() == DialogResult.OK)
{
   int totalLines = 0;
   string[] fileList = Directory.GetFiles(dlgFolder.SelectedPath, "*.cs",    SearchOption.AllDirectories);

   for (int x = 0; x < fileList.Length; x++)
   {
      string[] sourceCodeLines = File.ReadAllLines(fileList[x]);
      totalLines += sourceCodeLines.Length;    
   }

   MessageBox.Show(String.Format("There are {0} lines of C# code in the folder{1}",
totalLines.ToString(), dlgFolder.SelectedPath));
}

find . -type f -print0 | wc --files0-from=-

oops! you're on windows...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top