Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 - measuring "Lines of code"

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".

like image 531
Vivek Jaiswal Avatar asked Jul 23 '17 15:07

Vivek Jaiswal


2 Answers

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
like image 200
sam Avatar answered Jan 04 '23 00:01

sam


I use the famous "Supercharger" extension and among the many functions,it has just that:

Supercharger

Result:


Code structure statistics for project 'SysMonitor_1'

C# classes        :        14
C# interfaces     :         1
C# structs        :         1
C# enums          :         0

C# functions      :        49
C# properties     :        11

Code line count statistics for project 'SysMonitor_1'

C# comment lines  :       128
C# empty lines    :       105
C# pure code lines:       722
-----------------------------
Total C# lines    :       955

Non-C# lines      :       607

=============================
All lines         :     1.562
like image 33
Brummell Avatar answered Jan 03 '23 23:01

Brummell