How to count lines of code in a .NET solution?

7

What are all (free or not) solutions for counting lines of code in a .NET solution?

Use two Visual Studios: 2012 and 2013.

    
asked by anonymous 13.03.2014 / 20:04

2 answers

12

Right-click the solution, and then click Calculate Code Metrics .

Thiswindowwillappear:

with the following regex: ^(?([^\r\n])\s)*[^\s+?/]+[^\n]*$

do not forget to check the regex box

    
13.03.2014 / 20:12
1

Just go to the Analyze menu - > Calculate Code Metrics

An alternative would be to use PowerShell, where you can count all non-blank lines of a solution . To do this, simply specify the directory and the extension of the files in which the count will be performed (.cs, .xaml, etc):

PS> Set-Location CaminhoDaSolution
PS CaminhoDaSolution> (dir -include *.extensao1, *.extensao2, *.extensao3 -recurse | select-string .).Count
    
13.03.2014 / 20:13