Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show how many lines of code my project contains in Visual Studio? [duplicate]

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?

like image 347
KingNestor Avatar asked May 05 '09 22:05

KingNestor


People also ask

How do I count lines of code in Visual Studio project?

In VS2010 there is a in-built tool that counts all lines of code and other values too: Go to View -> Other Windows -> Code metrics results.

How do you find the number of lines of code in a project?

We can check all of the lines of code in a file or directory by the command cloc --by-file. Our folder contains two Vue files, so we're getting the count of both of them as well as the sum. Now, the most useful cloc command is to get the lines of code of the whole project.

How do I use code metrics in Visual Studio?

By enabling . NET code-quality analyzers and enabling the four code metrics (maintainability) rules it contains. By choosing the Analyze > Calculate Code Metrics menu command within Visual Studio. From the command line for C# and Visual Basic projects.


2 Answers

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]*$ 
like image 99
Lei Avatar answered Oct 11 '22 08:10

Lei


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:

  • http://blogs.msdn.com/fxcop/archive/2007/10/03/new-for-visual-studio-2008-code-metrics.aspx
  • http://blogs.msdn.com/somasegar/archive/2007/10/04/code-analysis-features-in-vs-2008.aspx
like image 28
BQ. Avatar answered Oct 11 '22 08:10

BQ.