Skip to content

Commit 2ce4867

Browse files
authored
Add how-to-debug document (#691)
* Add how-to-debug document * update * update * update
1 parent 8701a06 commit 2ce4867

9 files changed

+86
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## Introduction
2+
3+
### Input
4+
5+
The input of mdoc is `dll`,`winmd` or `exe` which are organized in below folder structure.
6+
7+
```
8+
|_dependencies
9+
| |_version1
10+
| |-A.dependent.dll
11+
| |-B.dependent.dll
12+
|_version1
13+
|-A.dll
14+
|_B.dll
15+
```
16+
In current production pipeline, not all the source repos have binaries in it. Some are the NuGet packages registered in csv file.
17+
18+
Example sources:
19+
1. [binaries](https://apidrop.visualstudio.com/_git/binaries)
20+
2. [mrefconfig](https://apidrop.visualstudio.com/binaries/_git/mrefconfig?path=/bundlepackages)
21+
3. [content repo](https://github.com/Azure/azure-docs-sdk-dotnet/tree/main/bundlepackages)
22+
23+
We may not always be able to use the source repo as the input so the best way is to download the pipeline artifact to local to debug.
24+
![Pipeline](./images/pipeline.png)
25+
![Artifact](./images/artifact.png)
26+
27+
### Commands
28+
29+
There are 2 commands used in current production pipelines.
30+
31+
1. fx-bootstrap: generate `frameworks.xml` to the output folder
32+
```dotnetcli
33+
fx-bootstrap -fx {frameworks output folder} -importContent {true/false}
34+
```
35+
2. update: generate ECMAXMLs to the output folder
36+
```dotnetcli
37+
update -o {mdoc output folder} -fx {frameworks path} --debug -index false -lang docid -lang vb.net -lang fsharp -L "C:\Program Files (x86)\Windows Kits\10\References" -L "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\msdatasrc.dll" -L "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\PublicAssemblies" -L "C:\Program Files\dotnet" --delete
38+
```
39+
40+
### Debug steps
41+
1. Clone https://github.com/mono/api-doc-tools repo to local.
42+
2. Open it in Visual Studio and make sure it is built successfully.
43+
3. Set `mdoc` as the startup project.
44+
4. Prepare the input folder in local disk.
45+
![Input foldler](./images/input-folder.png)
46+
5. Create two launch profiles, one for `fx-bootstrap` and one for `update`.
47+
![Lanuch profile1](./images/lanuch-profile1.png)
48+
![Lanuch profile2](./images/lanuch-profile2.png)
49+
6. Locate the problematic piece of code.
50+
7. Set a breakpoint and start to debug.
51+
52+
## Example
53+
1. Partner reported a bug: https://ceapex.visualstudio.com/Engineering/_workitems/edit/896871
54+
2. Analysis the bug and identify this is a mdoc issue.
55+
3. Located the impacted .NET content repo: [dotnet-api-docs](https://github.com/dotnet/dotnet-api-docs).
56+
4. Find the corresponding pipeline in the commit log. https://apidrop.visualstudio.com/Content%20CI/_build/results?buildId=422059&view=results
57+
![Commit Log](./images/commit-log.png)
58+
5. Since the source is not NuGet source, we can pull the source repo as our input.
59+
6. Go to `Run .NET CI Script` step and find the source repo in the `paramsJson`
60+
```
61+
"https://apidrop.visualstudio.com/_git/binaries","branch":"master","folder":"dotnet"
62+
```
63+
7. Clone the source repo to local.
64+
8. Select `fx-bootstrap` launch profile and run.
65+
```dotnetcli
66+
fx-bootstrap -fx "{local path}\binaries\dotnet"
67+
```
68+
9. The entry class of mdoc is [mdoc.cs](https://github.com/mono/api-doc-tools/blob/main/mdoc/Mono.Documentation/mdoc.cs) and the update command is in [MDocUpdater.cs](https://github.com/mono/api-doc-tools/blob/main/mdoc/Mono.Documentation/MDocUpdater.cs).
69+
10. After analyzing the bug, you may want to set a breakpoint at:
70+
![breakpoint](./images/breakpoint.png)
71+
11. Select `update` launch profile and start to debug.
72+
73+
## Tips
74+
1. If you want to debug against a specific .dll, you can modify this line of [MDocUpdater.cs](https://github.com/mono/api-doc-tools/blob/f0bee064c5e018b82a39ec36a4c59d474fb154f9/mdoc/Mono.Documentation/MDocUpdater.cs#L367)
75+
76+
From
77+
```
78+
var assemblyFiles = filters.Split('|').SelectMany(v => Directory.GetFiles(path, v));
79+
```
80+
To
81+
```
82+
var assemblyFiles = filters.Split('|').SelectMany(v => Directory.GetFiles(path, v)).Where(x => x.Contains("name-of-dll"));
83+
```
83.7 KB
Loading
Loading
45.5 KB
Loading
Loading
Loading
Loading
102 KB
Loading

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,6 @@ make prepare all check
8282
```
8383

8484
Please review [mono's installation guide](http://www.mono-project.com/download/#download-lin) if you are using a different flavor of linux.
85+
86+
## How to debug
87+
[How to debug mdoc](./Documentation/how-to-debug/how-to-debug-mdoc.md)

0 commit comments

Comments
 (0)