コード例 #1
0
        private IEnumerable <Reference> Analyze(Package package, Type type)
        {
            Console.Write(".");

            myCancellationToken.ThrowIfCancellationRequested();

            var focusedPackageTypes = myPackageToTypesMap.Count > 1
                ? null
                : myPackageToTypesMap.Single().Value;

            return(new Inspector(myAssemblyLoader, type).GetUsedTypes()
                   // if only one package is given we analyse the deps within the package - otherwise between the packages
                   .Where(edge => (AllEdges && myPackageToTypesMap.Any(e => e.Value.Contains(edge.To))) ||
                          (focusedPackageTypes != null ? focusedPackageTypes.Contains(edge.To) : IsForeignPackage(package, edge.To)))
                   .Where(edge => !IsCompilerGenerated(edge.To))
                   .Select(edge => GraphUtils.Edge(edge))
                   .Where(edge => edge.From != edge.To));
        }
コード例 #2
0
        private AnalysisDocument GenerateDocument(IReadOnlyCollection <Reference> edges)
        {
            var doc = new AnalysisDocument();

            var nodesWithEdgesIndex = new HashSet <Type>();

            if (UsedTypesOnly)
            {
                foreach (var edge in edges)
                {
                    nodesWithEdgesIndex.Add(edge.From);
                    nodesWithEdgesIndex.Add(edge.To);
                }
            }

            var relevantNotesWithCluster = myPackageToTypesMap
                                           .Select(e => new
            {
                Package = myRelevantPackages.Single(p => p.Name == e.Key),
                Types   = e.Value
            })
                                           .SelectMany((e, idx) => e.Types
                                                       .Select(t => new
            {
                Type         = t,
                Package      = e.Package,
                PackageIndex = idx
            }))
                                           .AsParallel()
                                           .Where(e => !UsedTypesOnly || nodesWithEdgesIndex.Contains(e.Type))
                                           .Select(e => new
            {
                Node         = GraphUtils.Node(e.Type),
                Cluster      = GetCluster(e.Package, e.Type),
                PackageIndex = e.PackageIndex
            });

            foreach (var entry in relevantNotesWithCluster)
            {
                doc.Add(entry.Node);

                if (entry.Cluster != null)
                {
                    doc.AddToCluster(entry.Node, entry.Cluster);
                }

                if (myPackageToTypesMap.Count > 1)
                {
                    // color coding of nodes we only need if multiple packages were analyzed
                    doc.AddNodeColor(entry.Node, Colors[entry.PackageIndex % Colors.Length]);
                }
            }

            foreach (var edge in edges)
            {
                doc.Add(edge);

                var color = GetEdgeColor(edge);
                if (color != null)
                {
                    doc.AddEdgeColor(edge, color);
                }
            }

            return(doc);
        }