1illinkanalyzer(1) General Commands Manual illinkanalyzer(1)
2
3
4
6 illinkanalyzer - Mono's linker analyzer tool
7
9 illinkanalyzer [options] <linker-dependency-file.xml.gz>
10
12 Linker analyzer is a command line tool to analyze dependencies, which
13 were recorded during linker processing, and led linker to mark an item
14 to keep it in the resulting linked assembly.
15
16 It works on an oriented graph of dependencies, which are collected and
17 dumped during the linker run. The vertices of this graph are the items
18 of interest like assemblies, types, methods, fields, linker steps, etc.
19 The edges represent the dependencies.
20
22 The linker analyzer needs a linker dependencies file as an input. It
23 can be retrieved by enabling dependencies dumping during linking of a
24 Xamarin.Android or a Xamarin.iOS project.
25
26 That can be done on the command line by setting LinkerDumpDependencies
27 property to true and building the project. (make sure the LinkAssem‐
28 blies task is called, it might require cleaning the project sometimes)
29 Usually it is enough to build the project like this:
30
31 rm -f obj/Release/link.flag
32 msbuild /p:LinkerDumpDependencies=true /p:Configuration=Release YourAppProject.csproj
33
34 After a successful build, there will be a linker-dependencies.xml.gz
35 file created, containing the information for the analyzer.
36
38 -a, --alldeps show all dependencies
39 --csvoutput=VALUE outputs types and optionally size analysis to CSV
40 file
41 -h, --help show this message and exit.
42 -l, --linkedpath=VALUE sets the linked assemblies directory path. Enables
43 displaying size estimates.
44 -r, --rawdeps=VALUE show raw vertex dependencies. Raw vertex VALUE is
45 in the raw format written by linker to the
46 dependency XML file. VALUE can be regular
47 expression
48 --roots show root dependencies.
49 --stat show statistic of loaded dependencies.
50 --tree reduce the dependency graph to the tree.
51 --types show all types dependencies.
52 -t, --typedeps=VALUE show type dependencies. The VALUE can be regular
53 expression
54 -f, --flat show all dependencies per vertex and their distance
55 -v, --verbose be more verbose. Enables stat and roots options.
56
58 Let say you would like to know, why a type, Android.App.Activity for
59 example, was marked by the linker. So run the analyzer like this:
60
61 illinkanalyzer -t Android.App.Activity linker-dependencies.xml.gz
62
63 Output:
64
65 Loading dependency tree from: linker-dependencies.xml.gz
66
67 --- Type dependencies: 'Android.App.Activity' -----------------------
68
69 --- TypeDef:Android.App.Activity dependencies -----------------------
70 Dependency #1
71 TypeDef:Android.App.Activity
72 | TypeDef:XA.App.MainActivity [2 deps]
73 | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps]
74 | Other:Mono.Linker.Steps.ResolveFromAssemblyStep
75
76 The output contains dependencies string(s), starting with the type and
77 continuing with the item of interest, which depends on the type. The
78 dependency could be result of multiple reasons. For example the type
79 was referenced from a method, or the type was listed in the linker xml
80 file to be protected.
81
82 In our example there is only one dependency string called Dependency
83 #1. It shows us that the type Android.App.Activity was marked during
84 processing of type XA.App.MainActivity by the linker. In this case
85 because the MainActivity type is based on the Activity type and thus
86 the linker marked it and kept it in the linked assembly. We can also
87 see that there are 2 dependencies for the MainActivity class. Note that
88 in the string (above) we see only 1st dependency of the 2, the depen‐
89 dency on the assembly XA.App. And finally the assembly vertex depends
90 on the ResolveFromAssemblyStep vertex. So we see that the assembly was
91 processed in the ResolveFromAssembly linker step.
92
93 Now we might want to see the MainActivity dependencies. That could be
94 done by the following analyzer run:
95
96 illinkanalyzer -r TypeDef:XA.App.MainActivity linker-dependencies.xml.gz
97
98 Output:
99
100 Loading dependency tree from: linker-dependencies.xml.gz
101
102 --- Raw dependencies: 'TypeDef:XA.App.MainActivity' -----------------
103
104 --- TypeDef:XA.App.MainActivity dependencies ------------------------
105 Dependency #1
106 TypeDef:XA.App.MainActivity
107 | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps]
108 | Other:Mono.Linker.Steps.ResolveFromAssemblyStep
109 Dependency #2
110 TypeDef:XA.App.MainActivity
111 | TypeDef:XA.App.MainActivity/<>c__DisplayClass1_0 [2 deps]
112 | TypeDef:XA.App.MainActivity [2 deps]
113 | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps]
114 | Other:Mono.Linker.Steps.ResolveFromAssemblyStep
115
117 msbuild(1)
118
119
120
121 illinkanalyzer(1)