visual studio – I need to count the lines of code in the function’s call tree


Visual Studio 2019 version 16.4 and higher has built-in Code Metrics, including the Lines of Source code.

Analyze → Calculate Code Metrics

1.Right-click on your project or solution in the Solution Explorer.

2.Select Analyze and Code Cleanup.

3.Click on Calculate Code Metrics.

This will generate a report that includes various metrics, including the number of lines of code for each function.However, this won’t directly show the lines of code for the functions called within a function.

As a workaround, you can check all the functions called in a function one by one and retrieve each function’s corresponding column Lines of Source Code in metrics report, then sum them manually.

Docs Referred:

https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-values?view=vs-2022#software-measurements

Leave a Reply

Your email address will not be published. Required fields are marked *