Skip to content

Commit f8b22b1

Browse files
committed
fix bookmarks and move metrics.exe section down
1 parent 3de30e1 commit f8b22b1

File tree

1 file changed

+39
-48
lines changed

1 file changed

+39
-48
lines changed

docs/code-quality/how-to-generate-code-metrics-data.md

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The results are generated and the **Code Metrics Results** window is displayed.
4343

4444
## Command-line code metrics
4545

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

4848
### Microsoft.CodeAnalysis.Metrics NuGet package
4949

@@ -94,53 +94,6 @@ Build succeeded.
9494
0 Error(s)
9595
```
9696

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:
108-
109-
```shell
110-
msbuild /m /v:m /p:Configuration=Release Metrics.csproj
111-
```
112-
113-
An executable named *Metrics.exe* is generated in the *artifacts\bin* directory under the repo root.
114-
115-
> [!TIP]
116-
> To build *Metrics.exe* in [legacy mode](#legacy-mode), execute the following command:
117-
>
118-
> ```shell
119-
> msbuild /m /v:m /t:rebuild /p:LEGACY_CODE_METRICS_MODE=true Metrics.csproj
120-
> ```
121-
122-
#### Usage
123-
124-
To run *Metrics.exe*, supply a project or solution and an output XML file as arguments. For example:
125-
126-
```shell
127-
C:\>Metrics.exe /project:ConsoleApp20.csproj /out:report.xml
128-
Loading ConsoleApp20.csproj...
129-
Computing code metrics for ConsoleApp20.csproj...
130-
Writing output to 'report.xml'...
131-
Completed Successfully.
132-
```
133-
134-
#### Legacy mode
135-
136-
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:
137-
138-
```shell
139-
msbuild /m /v:m /t:rebuild /p:LEGACY_CODE_METRICS_MODE=true Metrics.csproj
140-
```
141-
142-
For more information, see [Enable generating code metrics in legacy mode](https://github.com/dotnet/roslyn-analyzers/pull/1841).
143-
14497
### Code metrics output
14598

14699
The generated XML output takes the following format:
@@ -196,6 +149,44 @@ The generated XML output takes the following format:
196149
</CodeMetricsReport>
197150
```
198151

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:
161+
162+
```shell
163+
msbuild /m /v:m /p:Configuration=Release Metrics.csproj
164+
```
165+
166+
An executable named *Metrics.exe* is generated in the *artifacts\bin* directory under the repo root.
167+
168+
#### Metrics.exe usage
169+
170+
To run *Metrics.exe*, supply a project or solution and an output XML file as arguments. For example:
171+
172+
```shell
173+
C:\>Metrics.exe /project:ConsoleApp20.csproj /out:report.xml
174+
Loading ConsoleApp20.csproj...
175+
Computing code metrics for ConsoleApp20.csproj...
176+
Writing output to 'report.xml'...
177+
Completed Successfully.
178+
```
179+
180+
#### Legacy mode
181+
182+
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:
183+
184+
```shell
185+
msbuild /m /v:m /t:rebuild /p:LEGACY_CODE_METRICS_MODE=true Metrics.csproj
186+
```
187+
188+
For more information, see [Enable generating code metrics in legacy mode](https://github.com/dotnet/roslyn-analyzers/pull/1841).
189+
199190
### Previous versions
200191

201192
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

Comments
 (0)