Rodion Degtyar
Rodion Degtyar

Reputation: 330

I need to count the lines of code in the function's call tree

I have a function in my code. I need to count the lines of code in its call tree. That is, I need to count the number of lines in this function, plus all the lines of code in the functions it calls, and so on recursively.

Is there a simple method/plugin to do this?

Upvotes: 0

Views: 39

Answers (1)

Dou Xu-MSFT
Dou Xu-MSFT

Reputation: 3321

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

Upvotes: 0

Related Questions