Exemple #1
0
        private static void DumpAssemblyVersionInfoFor(
            IEnumerable <string> assemblyPaths,
            bool noColor,
            bool showPaths,
            IEnumerable <string> otherArgs)
        {
            foreach (var asmFile in assemblyPaths)
            {
                var lister = new AssemblyDependencyTrawler(Debug);
                var asm    = lister.TryLoadPath(asmFile);
                if (asm == null)
                {
                    LogErrorIfExplicitlySelected(asmFile, otherArgs);
                    continue;
                }

                var rebinds = ListRebindsFor(asmFile);

                var deps   = new List <AssemblyDependencyInfo>();
                var root   = Path.GetDirectoryName(asmFile);
                var errors = lister.ListFileDeps(asm, deps, root);
                DisplayAssemblyAndDeps(asmFile, asm, deps, rebinds, noColor, showPaths);
                if (!errors.Any())
                {
                    continue;
                }

                Console.WriteLine("Errors follow:");
                foreach (var error in errors)
                {
                    Console.WriteLine(error);
                }
            }
        }
Exemple #2
0
        private static void DumpReverseLookupFor(IEnumerable <string> asmPaths,
                                                 IEnumerable <string> reverseLookup,
                                                 bool noColor,
                                                 bool showPaths)
        {
            var final = new Dictionary <string, List <List <AssemblyDependencyInfo> > >();

            foreach (var asmFile in asmPaths)
            {
                var trawler = new AssemblyDependencyTrawler(Debug);
                var asm     = trawler.TryLoadPath(asmFile);
                if (asm == null)
                {
                    continue;
                }

                var root = Path.GetDirectoryName(asmFile);
                var deps = new List <AssemblyDependencyInfo>();
                trawler.ListFileDeps(asm, deps, root);
                foreach (var seek in reverseLookup)
                {
                    if (deps.Any(d => d.Name.Equals(seek, StringComparison.OrdinalIgnoreCase)))
                    {
                        if (!final.ContainsKey(seek))
                        {
                            final[seek] = new List <List <AssemblyDependencyInfo> >();
                        }

                        foreach (var dep in deps)
                        {
                            dep.Level++;
                        }

                        deps.Insert(0, new AssemblyDependencyInfo(
                                        asm.GetName(),
                                        true,
                                        0));
                        deps[0].SetPathOnDisk(asmFile);
                        final[seek].Add(deps);
                    }
                }
            }

            var dumped = 0;

            foreach (var kvp in final)
            {
                if (dumped++ > 0)
                {
                    Console.WriteLine("\n");
                }

                foreach (var tree in kvp.Value)
                {
                    Console.WriteLine(noColor
                        ? $"Depends on {kvp.Key}:"
                        : $"Depends on {kvp.Key.BrightRed()}:");

                    var trimmed = TrimTree(tree, kvp.Key);
                    // TODO: factor in rebinds for reverse lookup?
                    DisplayDeps(trimmed, new AssemblyRebind[0], noColor, showPaths, s => s.Contains(kvp.Key));
                }
            }
        }