3 illinkanalyzer \- Mono's linker analyzer tool
6 \fR[\fIoptions\fR] <\fIlinker-dependency-file.xml.gz\fR>
8 Linker analyzer is a command line tool to analyze dependencies, which
9 were recorded during linker processing, and led linker to mark an item
10 to keep it in the resulting linked assembly.
12 It works on an oriented graph of dependencies, which are collected and
13 dumped during the linker run. The vertices of this graph are the items
14 of interest like assemblies, types, methods, fields, linker steps,
15 etc. The edges represent the dependencies.
16 .SH HOW TO DUMP DEPENDENCIES
17 The linker analyzer needs a linker dependencies file as an input. It
18 can be retrieved by enabling dependencies dumping during linking of a
19 Xamarin.Android or a Xamarin.iOS project.
21 That can be done on the command line by setting LinkerDumpDependencies
22 property to true and building the project. (make sure the
23 LinkAssemblies task is called, it might require cleaning the project
24 sometimes) Usually it is enough to build the project like this:
28 rm -f obj/Release/link.flag
29 msbuild /p:LinkerDumpDependencies=true /p:Configuration=Release YourAppProject.csproj
33 After a successful build, there will be a linker-dependencies.xml.gz
34 file created, containing the information for the analyzer.
38 -a, --alldeps show all dependencies
39 --csvoutput=VALUE outputs types and optionally size analysis to CSV
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
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
54 -f, --flat show all dependencies per vertex and their distance
55 -v, --verbose be more verbose. Enables stat and roots options.
59 Let say you would like to know, why a type, Android.App.Activity for
60 example, was marked by the linker. So run the analyzer like this:
64 illinkanalyzer -t Android.App.Activity linker-dependencies.xml.gz
72 Loading dependency tree from: linker-dependencies.xml.gz
74 --- Type dependencies: 'Android.App.Activity' -----------------------
76 --- TypeDef:Android.App.Activity dependencies -----------------------
78 TypeDef:Android.App.Activity
79 | TypeDef:XA.App.MainActivity [2 deps]
80 | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps]
81 | Other:Mono.Linker.Steps.ResolveFromAssemblyStep
85 The output contains dependencies string(s), starting with the type and
86 continuing with the item of interest, which depends on the type. The
87 dependency could be result of multiple reasons. For example the type
88 was referenced from a method, or the type was listed in the linker xml
91 In our example there is only one dependency string called Dependency
92 #1. It shows us that the type Android.App.Activity was marked during
93 processing of type XA.App.MainActivity by the linker. In this case
94 because the MainActivity type is based on the Activity type and thus
95 the linker marked it and kept it in the linked assembly. We can also
96 see that there are 2 dependencies for the MainActivity class. Note
97 that in the string (above) we see only 1st dependency of the 2, the
98 dependency on the assembly XA.App. And finally the assembly vertex
99 depends on the ResolveFromAssemblyStep vertex. So we see that the
100 assembly was processed in the ResolveFromAssembly linker step.
102 Now we might want to see the MainActivity dependencies. That could be done by the following analyzer run:
106 illinkanalyzer -r TypeDef:XA.App.MainActivity linker-dependencies.xml.gz
114 Loading dependency tree from: linker-dependencies.xml.gz
116 --- Raw dependencies: 'TypeDef:XA.App.MainActivity' -----------------
118 --- TypeDef:XA.App.MainActivity dependencies ------------------------
120 TypeDef:XA.App.MainActivity
121 | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps]
122 | Other:Mono.Linker.Steps.ResolveFromAssemblyStep
124 TypeDef:XA.App.MainActivity
125 | TypeDef:XA.App.MainActivity/<>c__DisplayClass1_0 [2 deps]
126 | TypeDef:XA.App.MainActivity [2 deps]
127 | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps]
128 | Other:Mono.Linker.Steps.ResolveFromAssemblyStep