You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/code-quality/how-to-generate-code-metrics-data.md
+39-48Lines changed: 39 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ The results are generated and the **Code Metrics Results** window is displayed.
43
43
44
44
## Command-line code metrics
45
45
46
-
You can generate code metrics data from the command line for C# and Visual Basic projects for .NET Framework, .NET Core, and .NET Standard apps. To run code metrics from the command line, install the [Microsoft.CodeAnalysis.Metrics NuGet package](#microsoft-codeanalysis-metrics-nuget-package) or build the [Metrics.exe](#metrics-exe) executable yourself.
46
+
You can generate code metrics data from the command line for C# and Visual Basic projects for .NET Framework, .NET Core, and .NET Standard apps. To run code metrics from the command line, install the [Microsoft.CodeAnalysis.Metrics NuGet package](#microsoftcodeanalysismetrics-nuget-package) or build the [Metrics.exe](#metricsexe) executable yourself.
47
47
48
48
### Microsoft.CodeAnalysis.Metrics NuGet package
49
49
@@ -94,53 +94,6 @@ Build succeeded.
94
94
0 Error(s)
95
95
```
96
96
97
-
### Metrics.exe
98
-
99
-
You can use the *Metrics.exe* executable to generate code metrics data from the command line.
100
-
101
-
First, generate the *Metrics.exe* executable:
102
-
103
-
1. Clone the [dotnet/roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers) repo.
104
-
2. Open Developer Command Prompt for Visual Studio as an administrator.
105
-
3. From the root of the **roslyn-analyzers** repo, execute the following command: `Restore.cmd`
106
-
4. Change directory to *src\Tools*.
107
-
5. Execute the following command to build the **Metrics.csproj** project:
You can choose to build *Metrics.exe* in *legacy mode*. The legacy mode version of the tool generates metric values that are closer to what [older versions of the tool generated](#previous-versions). Additionally, in legacy mode, *Metrics.exe* generates code metrics for the same set of method types that previous versions of the tool generated code metrics for. For example, it doesn't generate code metrics data for field and property initializers. Legacy mode is useful for backwards compatibility or if you have code check-in gates based on code metrics numbers. The command to build *Metrics.exe* in legacy mode is:
For more information, see [Enable generating code metrics in legacy mode](https://github.com/dotnet/roslyn-analyzers/pull/1841).
143
-
144
97
### Code metrics output
145
98
146
99
The generated XML output takes the following format:
@@ -196,6 +149,44 @@ The generated XML output takes the following format:
196
149
</CodeMetricsReport>
197
150
```
198
151
152
+
### Metrics.exe
153
+
154
+
If you don't want to install the NuGet package, you can generate and use the *Metrics.exe* executable directly. To generate the *Metrics.exe* executable:
155
+
156
+
1. Clone the [dotnet/roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers) repo.
157
+
2. Open Developer Command Prompt for Visual Studio as an administrator.
158
+
3. From the root of the **roslyn-analyzers** repo, execute the following command: `Restore.cmd`
159
+
4. Change directory to *src\Tools*.
160
+
5. Execute the following command to build the **Metrics.csproj** project:
You can choose to build *Metrics.exe* in *legacy mode*. The legacy mode version of the tool generates metric values that are closer to what [older versions of the tool generated](#previous-versions). Additionally, in legacy mode, *Metrics.exe* generates code metrics for the same set of method types that previous versions of the tool generated code metrics for. For example, it doesn't generate code metrics data for field and property initializers. Legacy mode is useful for backwards compatibility or if you have code check-in gates based on code metrics numbers. The command to build *Metrics.exe* in legacy mode is:
For more information, see [Enable generating code metrics in legacy mode](https://github.com/dotnet/roslyn-analyzers/pull/1841).
189
+
199
190
### Previous versions
200
191
201
192
Previous versions of Visual Studio, including Visual Studio 2015, included a command-line code metrics tool called *Metrics.exe*. This previous version of the tool did a binary analysis, that is, an assembly-based analysis. The new tool analyzes source code instead. Because the new command-line code metrics tool is source code-based, the results are different to what's generated by previous versions of *Metrics.exe* and within the Visual Studio 2017 IDE.
0 commit comments