From 71023dca00c9b6a2f54de08543c02fe16efc86ed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 22:02:51 +0000 Subject: [PATCH 1/2] Initial plan From f23eb7f49f4f8e951ed527e6d1869a980f52e8b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 22:42:15 +0000 Subject: [PATCH 2/2] Remove unused ILLink analyzer and all repository references Co-authored-by: sbomer <787361+sbomer@users.noreply.github.com> --- eng/Subsets.props | 1 - src/tools/illink/README.md | 4 - src/tools/illink/illink.slnx | 1 - .../src/analyzer/ConsoleDependencyGraph.cs | 230 ------------------ .../LinkerAnalyzerCore/DependencyGraph.cs | 156 ------------ .../LinkerAnalyzerCore/SpaceAnalyzer.cs | 165 ------------- src/tools/illink/src/analyzer/Main.cs | 96 -------- src/tools/illink/src/analyzer/README.md | 133 ---------- src/tools/illink/src/analyzer/analyzer.csproj | 17 -- src/tools/illink/trimming.slnx | 3 - 10 files changed, 806 deletions(-) delete mode 100644 src/tools/illink/src/analyzer/ConsoleDependencyGraph.cs delete mode 100644 src/tools/illink/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs delete mode 100644 src/tools/illink/src/analyzer/LinkerAnalyzerCore/SpaceAnalyzer.cs delete mode 100644 src/tools/illink/src/analyzer/Main.cs delete mode 100644 src/tools/illink/src/analyzer/README.md delete mode 100644 src/tools/illink/src/analyzer/analyzer.csproj diff --git a/eng/Subsets.props b/eng/Subsets.props index 66150fa2e02851..61b5f0c818d518 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -533,7 +533,6 @@ - diff --git a/src/tools/illink/README.md b/src/tools/illink/README.md index af33c811debbb2..a4af5301c77a10 100644 --- a/src/tools/illink/README.md +++ b/src/tools/illink/README.md @@ -9,10 +9,6 @@ The [IL Trimmer](src/linker/README.md) is the developer's tool that can be used The trimmer is always enabled for all size sensitive .NET workloads like Blazor WebAssembly, Xamarin or .NET mobile and can be manually enabled for other project types. The default apps trimming setting can be further customized by using a number of [msbuild properties](https://learn.microsoft.com/dotnet/core/deploying/trimming-options). -## Dependencies Analyzer - -The [analyzer](src/analyzer/README.md) is a tool to analyze dependencies which were recorded during trimmer processing. It tracks details about reasons and connection between elements to keep it in the resulting linked assembly. It can be used to better understand the dependencies between different types and members to help further reduce the linked output. - ## Trimming Lens The [tlens](src/tlens/README.md) is another tool for developers which can be used to explore ways to reduce the size of trimmed apps or exploring libraries readiness for trimming. The tool produces a recommendation where the compiled source could be improved to produce even smaller outputs when trimmed using the trimmer. diff --git a/src/tools/illink/illink.slnx b/src/tools/illink/illink.slnx index 51cdf087c58838..51f777b68357b7 100644 --- a/src/tools/illink/illink.slnx +++ b/src/tools/illink/illink.slnx @@ -5,7 +5,6 @@ - diff --git a/src/tools/illink/src/analyzer/ConsoleDependencyGraph.cs b/src/tools/illink/src/analyzer/ConsoleDependencyGraph.cs deleted file mode 100644 index 2f4b98e38adc06..00000000000000 --- a/src/tools/illink/src/analyzer/ConsoleDependencyGraph.cs +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// -// ConsoleDependencyGraph.cs: text output related code for dependency graph -// -// Author: -// Radek Doulik (rodo@xamarin.com) -// -// Copyright 2015 Xamarin Inc (http://www.xamarin.com). -// - -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using LinkerAnalyzer.Core; - -namespace LinkerAnalyzer -{ - public class ConsoleDependencyGraph : DependencyGraph - { - public bool Tree; - public bool FlatDeps; - - public void ShowDependencies(string raw, List verticesList, string searchString) - { - VertexData vertex = Vertex(raw); - if (vertex == null) - { - Regex regex = new Regex(searchString); - int count = 0; - - foreach (var v in verticesList) - { - if (regex.Match(v.value) != Match.Empty) - { - ShowDependencies(v); - count++; - } - } - - if (count == 0) - Console.WriteLine("\nUnable to find vertex: {0}", raw); - else - Console.WriteLine("\nFound {0} matches", count); - } - else - ShowDependencies(vertex); - } - - void ShowFlatDependencies(VertexData vertex) - { - bool first = true; - var flatDeps = GetAllDependencies(vertex); - - Console.WriteLine(); - - foreach (var d in flatDeps) - { - var dSize = SpaceAnalyzer == null ? 0 : SpaceAnalyzer.GetSize(d.Item1); - if (first) - { - var sizeStr = dSize > 0 ? $" [size: {dSize}]" : ""; - Console.WriteLine($"Distance | {d.Item1.value} [total deps: {flatDeps.Count}]{sizeStr}"); - Line(); - first = false; - continue; - } - var sizeStr2 = dSize > 0 ? $" [size: {dSize}]" : ""; - Console.WriteLine($"{string.Format("{0,8}", d.Item2)} | {d.Item1.value}{d.Item1.DepsCount}{sizeStr2}"); - } - } - - string SizeString(VertexData vertex) - { - return SpaceAnalyzer == null ? - "" : string.Format(" size: {0}", SpaceAnalyzer.GetSize(vertex)); - } - - public void ShowDependencies(VertexData vertex) - { - if (FlatDeps) - { - ShowFlatDependencies(vertex); - - return; - } - - Header("{0} dependencies", vertex.value); - if (vertex.parentIndexes == null) - { - Console.WriteLine("Root dependency"); - } - else - { - int i = 0; - var visited = new HashSet(); - - foreach (int index in vertex.parentIndexes) - { - Console.WriteLine("Dependency #{0}", ++i); - Console.WriteLine($"\t{vertex.value}{SizeString(vertex)}"); - - var childVertex = Vertex(index); - Console.WriteLine("\t| {0}{1}", childVertex.value, childVertex.DepsCount); - - visited.Clear(); - visited.Add(index); - - while (childVertex.parentIndexes != null) - { - int pi = 0, childIdx; - - do - { - childIdx = childVertex.parentIndexes[pi]; - pi++; - } while (visited.Contains(childIdx) && pi < childVertex.parentIndexes.Count); - - childVertex = Vertex(childIdx); - - if (visited.Contains(childIdx)) - { - Console.WriteLine($"\twarning: loop to {childVertex.value}"); - break; - } - - visited.Add(childIdx); - Console.WriteLine("\t| {0}{1}", childVertex.value, childVertex.DepsCount); - } - - if (Tree) - break; - } - } - } - - public void ShowAllDependencies() - { - Header("All dependencies"); - Console.WriteLine("Types count: {0}", vertices.Count); - foreach (var vertex in vertices) - ShowDependencies(vertex); - } - - public void ShowTypesDependencies() - { - Header("All types dependencies"); - Console.WriteLine("Deps count: {0}", Types.Count); - foreach (var type in Types) - ShowDependencies(type); - } - - static string Tabs(string key) - { - int count = Math.Max(1, 2 - key.Length / 8); - - if (count == 1) - return "\t"; - else - return "\t\t"; - } - - public void ShowStat(bool verbose = false) - { - Header("Statistics"); - if (verbose) - { - foreach (var key in counts.Keys) - Console.WriteLine("Vertex type:\t{0}{1}count:{2}", key, Tabs(key), counts[key]); - } - else - { - Console.WriteLine("Assemblies:\t{0}", counts["Assembly"]); - Console.WriteLine("Modules:\t{0}", counts["Module"]); - Console.WriteLine("Types:\t\t{0}", counts["TypeDef"]); - Console.WriteLine("Fields:\t\t{0}", counts["Field"]); - Console.WriteLine("Methods:\t{0}", counts["Method"]); - } - - Console.WriteLine(); - Console.WriteLine("Total vertices: {0}", vertices.Count); - } - - public void ShowRoots() - { - Header("Root vertices"); - - int count = 0; - foreach (var vertex in vertices) - { - if (vertex.parentIndexes == null) - { - Console.WriteLine("{0}", vertex.value); - count++; - } - } - - Console.WriteLine(); - Console.WriteLine("Total root vertices: {0}", count); - } - - public void ShowRawDependencies(string raw) - { - Header("Raw dependencies: '{0}'", raw); - ShowDependencies(raw, vertices, raw); - } - - public void ShowTypeDependencies(string raw) - { - Header("Type dependencies: '{0}'", raw); - ShowDependencies("TypeDef:" + raw, Types, raw); - } - - static readonly string line = new string('-', 72); - - static void Line() - { - Console.Write(line); - Console.WriteLine(); - } - - public static void Header(string header, params object[] values) - { - string formatted = string.Format(header, values); - Console.WriteLine(); - Console.WriteLine($"--- {formatted} {new string('-', Math.Max(3, 67 - formatted.Length))}"); - } - } -} diff --git a/src/tools/illink/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs b/src/tools/illink/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs deleted file mode 100644 index 4bb024d5d909d1..00000000000000 --- a/src/tools/illink/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// -// DependencyGraph.cs: ILLink dependencies graph -// -// Author: -// Radek Doulik (rodo@xamarin.com) -// -// Copyright 2015 Xamarin Inc (http://www.xamarin.com). -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml; - -namespace LinkerAnalyzer.Core -{ - public class VertexData - { - public string value; - public List parentIndexes; - public int index; - - public string DepsCount - { - get - { - if (parentIndexes == null || parentIndexes.Count < 1) - return ""; - return string.Format(" [{0} deps]", parentIndexes.Count); - } - } - } - - public class DependencyGraph - { - protected List vertices = new List(); - public List Types = new List(); - readonly Dictionary indexes = new Dictionary(); - protected Dictionary counts = new Dictionary(); - internal SpaceAnalyzer SpaceAnalyzer { get; set; } - - public void Load(string filename) - { - Console.WriteLine("Loading dependency tree from: {0}", filename); - - try - { - using (var fileStream = File.OpenRead(filename)) - { - Load(fileStream); - } - } - catch (Exception) - { - Console.WriteLine("Unable to open and read the dependencies."); - Environment.Exit(1); - } - } - - void Load(FileStream fileStream) - { - using (XmlReader reader = XmlReader.Create(fileStream)) - { - while (reader.Read()) - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - // Console.WriteLine(reader.Name); - if (reader.Name == "edge" && reader.IsStartElement()) - { - string b = reader.GetAttribute("b"); - string e = reader.GetAttribute("e"); - //Console.WriteLine("edge value " + b + " --> " + e); - - if (e != b) - { - VertexData begin = Vertex(b, true); - VertexData end = Vertex(e, true); - - end.parentIndexes ??= new List(); - if (!end.parentIndexes.Contains(begin.index)) - { - end.parentIndexes.Add(begin.index); - //Console.WriteLine(" end parent index: {0}", end.parentIndexes); - } - } - } - break; - default: - //Console.WriteLine("node: " + reader.NodeType); - break; - } - } - } - } - - public VertexData Vertex(string vertexName, bool create = false) - { - if (indexes.TryGetValue(vertexName, out int index)) - return vertices[index]; - - if (!create) - return null; - - index = vertices.Count; - var vertex = new VertexData() { value = vertexName, index = index }; - vertices.Add(vertex); - indexes.Add(vertexName, index); - string prefix = vertexName.Substring(0, vertexName.IndexOf(':')); - if (counts.TryGetValue(prefix, out var count)) - counts[prefix] = count + 1; - else - counts[prefix] = 1; - //Console.WriteLine("prefix " + prefix + " count " + counts[prefix]); - if (prefix == "TypeDef") - { - Types.Add(vertex); - } - - return vertex; - } - - public VertexData Vertex(int index) - { - return vertices[index]; - } - - IEnumerable> AddDependencies(VertexData vertex, HashSet reachedVertices, int depth) - { - reachedVertices.Add(vertex.index); - yield return new Tuple(vertex, depth); - - if (vertex.parentIndexes == null) - yield break; - - foreach (var pi in vertex.parentIndexes) - { - var parent = Vertex(pi); - if (reachedVertices.Contains(parent.index)) - continue; - - foreach (var d in AddDependencies(parent, reachedVertices, depth + 1)) - yield return d; - } - } - - public List> GetAllDependencies(VertexData vertex) - { - return new List>(AddDependencies(vertex, new HashSet(), 0)); - } - } -} diff --git a/src/tools/illink/src/analyzer/LinkerAnalyzerCore/SpaceAnalyzer.cs b/src/tools/illink/src/analyzer/LinkerAnalyzerCore/SpaceAnalyzer.cs deleted file mode 100644 index 21a11684a707b1..00000000000000 --- a/src/tools/illink/src/analyzer/LinkerAnalyzerCore/SpaceAnalyzer.cs +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// SpaceAnalyzer.cs -// -// Author: -// Radek Doulik -// -// Copyright (C) 2018 Microsoft Corporation (http://www.microsoft.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections.Generic; -using Mono.Cecil; - -namespace LinkerAnalyzer.Core -{ - public class SpaceAnalyzer - { - readonly string assembliesDirectory; - readonly List assemblies = new List(); - readonly Dictionary sizes = new Dictionary(); - - public SpaceAnalyzer(string assembliesDirectory) - { - this.assembliesDirectory = assembliesDirectory; - } - - static bool IsAssemblyBound(TypeDefinition td) - { - do - { - if (td.IsNestedPrivate || td.IsNestedAssembly || td.IsNestedFamilyAndAssembly) - return true; - - td = td.DeclaringType; - } while (td != null); - - return false; - } - - static string GetTypeKey(TypeDefinition td) - { - if (td == null) - return ""; - - var addAssembly = td.IsNotPublic || IsAssemblyBound(td); - - var addition = addAssembly ? $":{td.Module}" : ""; - return $"{td.MetadataToken.TokenType}:{td}{addition}"; - } - - static string GetKey(MethodDefinition method) - { - return $"{method.MetadataToken.TokenType}:{method}"; - } - - int GetMethodSize(MethodDefinition method) - { - var key = GetKey(method); - int msize; - - if (sizes.TryGetValue(key, out msize)) - return msize; - - msize = method.Body.CodeSize; - msize += method.Name.Length; - - sizes.Add(key, msize); - - return msize; - } - - int ProcessType(TypeDefinition type) - { - int size = type.Name.Length; - - foreach (var field in type.Fields) - size += field.Name.Length; - - foreach (var method in type.Methods) - { - method.Resolve(); - if (method.Body != null) - size += GetMethodSize(method); - } - - type.Resolve(); - try - { - sizes.Add(GetTypeKey(type), size); - } - catch (ArgumentException e) - { - Console.WriteLine($"\nWarning: duplicated type '{type}' scope '{type.Scope}'\n{e}"); - } - return size; - } - - public void LoadAssemblies(bool verbose = true) - { - if (verbose) - { - ConsoleDependencyGraph.Header("Space analyzer"); - Console.WriteLine("Load assemblies from {0}", assembliesDirectory); - } - else - Console.Write("Analyzing assemblies ."); - - var resolver = new DefaultAssemblyResolver(); - resolver.AddSearchDirectory(assembliesDirectory); - - int totalSize = 0; - foreach (var file in System.IO.Directory.GetFiles(assembliesDirectory, "*.dll")) - { - if (verbose) - Console.WriteLine($"Analyzing {file}"); - else - Console.Write("."); - - ReaderParameters parameters = new ReaderParameters() { ReadingMode = ReadingMode.Immediate, AssemblyResolver = resolver }; - var assembly = AssemblyDefinition.ReadAssembly(file, parameters); - assemblies.Add(assembly); - foreach (var module in assembly.Modules) - { - foreach (var type in module.Types) - { - totalSize += ProcessType(type); - foreach (var child in type.NestedTypes) - totalSize += ProcessType(child); - } - } - } - - if (verbose) - Console.WriteLine("Total known size: {0}", totalSize); - else - System.Console.WriteLine(); - } - - public int GetSize(VertexData vertex) - { - return sizes.TryGetValue(vertex.value, out var size) ? size : 0; - } - } -} diff --git a/src/tools/illink/src/analyzer/Main.cs b/src/tools/illink/src/analyzer/Main.cs deleted file mode 100644 index f12d759633f86b..00000000000000 --- a/src/tools/illink/src/analyzer/Main.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// -// Main.cs: Main program file of command line utility. -// -// Author: -// Radek Doulik (rodo@xamarin.com) -// -// Copyright 2015 Xamarin Inc (http://www.xamarin.com). -// - -using System; -using LinkerAnalyzer.Core; -using Mono.Options; - -namespace LinkerAnalyzer -{ - static class MainClass - { - static void Main(string[] args) - { - bool showUsage = true; - bool showAllDeps = false; - bool showTypeDeps = false; - string typeName = null; - bool showRawDeps = false; - string rawName = null; - bool showRoots = false; - bool showStat = false; - bool showTypes = false; - bool reduceToTree = false; - bool verbose = false; - bool flatDeps = false; - string linkedPath = null; - - var optionsParser = new OptionSet() { - { "a|alldeps", "show all dependencies", v => { showAllDeps = v != null; } }, - { "h|help", "show this message and exit.", v => showUsage = v != null }, - { "l|linkedpath=", "sets the linked assemblies directory path. Enables displaying size estimates.", v => { linkedPath = v; } }, - { "r|rawdeps=", "show raw vertex dependencies. Raw vertex VALUE is in the raw format written by illink to the dependency XML file. VALUE can be regular expression", v => { showRawDeps = v != null; rawName = v; } }, - { "roots", "show root dependencies.", v => showRoots = v != null }, - { "stat", "show statistic of loaded dependencies.", v => showStat = v != null }, - { "tree", "reduce the dependency graph to the tree.", v => reduceToTree = v != null }, - { "types", "show all types dependencies.", v => showTypes = v != null }, - { "t|typedeps=", "show type dependencies. The VALUE can be regular expression", v => { showTypeDeps = v != null; typeName = v; } }, - { "f|flat", "show all dependencies per vertex and their distance", v => flatDeps = v != null }, - { "v|verbose", "be more verbose. Enables stat and roots options.", v => verbose = v != null }, - }; - - if (args.Length > 0) - { - showUsage = false; - optionsParser.Parse(args); - } - - if (showUsage) - { - Console.WriteLine("Usage:\n\n\tillinkanalyzer [Options] \n\nOptions:\n"); - optionsParser.WriteOptionDescriptions(Console.Out); - Console.WriteLine(); - return; - } - - string dependencyFile = args[args.Length - 1]; - - ConsoleDependencyGraph deps = new ConsoleDependencyGraph() { Tree = reduceToTree, FlatDeps = flatDeps }; - deps.Load(dependencyFile); - - if (linkedPath != null) - { - deps.SpaceAnalyzer = new SpaceAnalyzer(linkedPath); - deps.SpaceAnalyzer.LoadAssemblies(verbose); - } - - if (verbose) - { - showStat = true; - showRoots = true; - } - - if (showStat) - deps.ShowStat(verbose); - if (showRoots) - deps.ShowRoots(); - if (showRawDeps) - deps.ShowRawDependencies(rawName); - if (showTypeDeps) - deps.ShowTypeDependencies(typeName); - if (showAllDeps) - deps.ShowAllDependencies(); - else if (showTypes) - deps.ShowTypesDependencies(); - } - } -} diff --git a/src/tools/illink/src/analyzer/README.md b/src/tools/illink/src/analyzer/README.md deleted file mode 100644 index 89371f2f375a62..00000000000000 --- a/src/tools/illink/src/analyzer/README.md +++ /dev/null @@ -1,133 +0,0 @@ -# ILLink Analyzer - -The ILLink analyzer is a command line tool to analyze dependencies, which -were recorded during ILLink processing, and led ILLink to mark an item -to keep it in the resulting linked assembly. - -It works on an oriented graph of dependencies, which are collected and -dumped during the ILLink run. The vertices of this graph are the items -of interest like assemblies, types, methods, fields, linker steps, -etc. The edges represent the dependencies. - -## How to dump dependencies - -The ILLink analyzer needs a ILLink dependencies file as an input. It -can be retrieved by enabling dependencies dumping during trimming of a -project. - -For console .NET projects you need to publish the application -with trimming enabled and use the `_TrimmerDumpDependencies` property: - -```dotnet publish /p:PublishTrimmed=true /p:_TrimmerDumpDependencies=true``` - -In this case the dependencies file will be in -`obj////linked/linker-dependencies.xml`. - -For Xamarin.Android and Xamarin.iOS, that can be done on the command line by setting -`LinkerDumpDependencies` property to `true` and building the -project. (make sure the LinkAssemblies task is called, it might -require cleaning the project sometimes) Usually it is enough to build -the project like this: - -```msbuild /p:LinkerDumpDependencies=true /p:Configuration=Release YourAppProject.csproj``` - -For .NET SDK style projects, you will want to use `_TrimmerDumpDependencies` instead: - -```msbuild /p:_TrimmerDumpDependencies=true /p:Configuration=Release YourAppProject.csproj``` - -After a successful build, there will be a linker-dependencies.xml -file created, containing the information for the analyzer. - -## How to use the analyzer - -Let say you would like to know, why a type, Android.App.Activity for -example, was marked by ILLink. So run the analyzer like this: - -```illinkanalyzer -t Android.App.Activity linker-dependencies.xml``` - -Output: - -``` -Loading dependency tree from: linker-dependencies.xml - ---- Type dependencies: 'Android.App.Activity' ----------------------- - ---- TypeDef:Android.App.Activity dependencies ----------------------- -Dependency #1 - TypeDef:Android.App.Activity - | TypeDef:XA.App.MainActivity [2 deps] - | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps] - | Other:Mono.Linker.Steps.ResolveFromAssemblyStep -``` - -The output contains dependencies string(s), starting with the type and continuing with the item of interest, which depends on the type. The dependency could be a result of multiple reasons. For example, the type was referenced from a method, or the type was listed in the ILLink XML descriptor file. - -In our example there is only one dependency string called `Dependency -#1`. It shows us that the type `Android.App.Activity` was marked -during processing of type `XA.App.MainActivity` by ILLink. In this -case because the `MainActivity` type is based on the `Activity` type -and thus ILLink marked it and kept it in the linked assembly. We -can also see that there are 2 dependencies for the `MainActivity` -class. Note that in the string (above) we see only 1st dependency of -the 2, the dependency on the assembly `XA.App`. And finally the -assembly vertex depends on the `ResolveFromAssemblyStep` vertex. So we -see that the assembly was processed in the `ResolveFromAssembly` -ILLink step. - -Now we might want to see the `MainActivity` dependencies. That could -be done by the following analyzer run: - -```illinkanalyzer -r TypeDef:XA.App.MainActivity linker-dependencies.xml``` - -Output: - -``` -Loading dependency tree from: linker-dependencies.xml - ---- Raw dependencies: 'TypeDef:XA.App.MainActivity' ----------------- - ---- TypeDef:XA.App.MainActivity dependencies ------------------------ -Dependency #1 - TypeDef:XA.App.MainActivity - | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps] - | Other:Mono.Linker.Steps.ResolveFromAssemblyStep -Dependency #2 - TypeDef:XA.App.MainActivity - | TypeDef:XA.App.MainActivity/<>c__DisplayClass1_0 [2 deps] - | TypeDef:XA.App.MainActivity [2 deps] - | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [3 deps] - | Other:Mono.Linker.Steps.ResolveFromAssemblyStep -``` - -### Known issues - -Sometimes ILLink processing is not straight forward and the -marking is postponed, like processing of some of the methods. They are -queued to be processed later. In such case the dependencies are -"interrupted" and the dependecy string for the method usually shows -just dependency on the Mark step. - -# Command line help - -``` -Usage: - - illinkanalyzer [Options] - -Options: - - -a, --alldeps show all dependencies - -h, --help show this message and exit. - -r, --rawdeps=VALUE show raw vertex dependencies. Raw vertex VALUE is - in the raw format written by ILLink to the - dependency XML file. VALUE can be regular - expression - --roots show root dependencies. - --stat show statistic of loaded dependencies. - --tree reduce the dependency graph to the tree. - --types show all types dependencies. - -t, --typedeps=VALUE show type dependencies. The VALUE can be regular - expression - -f, --flat show all dependencies per vertex and their distance - -v, --verbose be more verbose. Enables stat and roots options. -``` diff --git a/src/tools/illink/src/analyzer/analyzer.csproj b/src/tools/illink/src/analyzer/analyzer.csproj deleted file mode 100644 index cafa08a4480916..00000000000000 --- a/src/tools/illink/src/analyzer/analyzer.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - Exe - illinkanalyzer - disable - - - - - - - - - - - \ No newline at end of file diff --git a/src/tools/illink/trimming.slnx b/src/tools/illink/trimming.slnx index 39c9f96a633694..e59e5205973796 100644 --- a/src/tools/illink/trimming.slnx +++ b/src/tools/illink/trimming.slnx @@ -8,9 +8,6 @@ - - -