views:

1959

answers:

6

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?

+4  A: 

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:

BQ
>.< Beat me to it!
hypoxide
A: 
JRL
A: 

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

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

Steve Dignan
A: 

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

oops! you're on windows...

Javier
Snark! Snark! Snark!
Cyberherbalist
You could actually use cygwin for that, But I think a solution within vs2008 is required.
Adam Matan
+2  A: 

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));
}
Cyberherbalist
+4  A: 

You don't need 3rd party tools, just ctrl+shift+f then chose the "regular expression" using this: ^:b*[^:b#/]+.*$

Lei
this worked really well. thanks
Will