Visual Studio 2017 - measuring "Lines of code"

Vivek Jaiswal picture Vivek Jaiswal · Jul 23, 2017 · Viewed 10.9k times · Source

I'm unable to find a good option for my Visual Studio 2017.

I tried right clicking the projects, but there wasn't an option for "Analyze".

Just a few hours ago, I installed "Roslyn Code Analysis" using Nuget package manager. It's installed as "Archimetrics.Analysis".

How do I get "Lines of code" using this package. I have tried all the tried all the common ways of right clicking and trying to fins something but to no avail. That's why I installed this package "Roslyn" for code analysis, which is installed as "Archimetrics.Analysis".

Answer

sam picture sam · Jan 18, 2018

A little hacky way that works quite well is to use a RegEx with Find in Files

  1. Ctrl-Shift-F or Edit -> Find and Replace -> Find in Files
  2. Use ^(?([^\r\n])\s)*[^\s+?/]+[^\n]*$ in the 'Find what:' field
  3. Check 'Use Regular Expressions'
  4. Set 'Look in:' and 'Look at these file types:' to your desired search scope
  5. Hit enter and scroll to the bottom after the find is complete and you'll see Matching lines: 25843. That's the line count