How to count the number of lines of code in a C # solution, without comments and without lines, and other redundant things, etc.?


By redundant stuff, I mean the namespaces, as I know they are necessary but if there are 10k of them, it doesn't add valuable info to the table.

Could this be done using Linq?

No need to reinvent the wheel. Take a look at the Visual Studio Code Metrics PowerTool 11.0


The Code Metrics PowerTool is a command line utility that calculates code metrics for your managed code and saves them to an XML file. This tool enables teams to collect and report code metrics as part of their build process. The code metrics calculated are:

• Maintainability Index

• Cyclomatic Complexity

• Depth of Inheritance

• Class Coupling

• Lines Of Code (LOC)

I know you said you don't have Ultimate, so I just wanted to show you what you're missing.

For everyone else, there's SourceMonitor