Пример #1
0
        public static string Create(ProjectGraph graph, GraphVisOptions options)
        {
            // I don't really remember why I did the hash thing. I think I was concerned with duplicate nodes?
            var projects = new ConcurrentDictionary <string, ProjectGraphNode>();

            var selectedProjects = graph.ProjectNodes.Where(p => !p.ProjectInstance.FullPath.Contains("dirs.proj"));

            return(Create(selectedProjects, options));
        }
Пример #2
0
        public static string Create(
            ProjectGraph graph,
            GraphVisOptions options,
            IReadOnlyDictionary <ProjectGraphNode, ImmutableList <string> > entryTargetsPerNode = null)
        {
            var selectedProjects = graph.ProjectNodes.Where(p => !p.ProjectInstance.FullPath.Contains("dirs.proj"));

            return(Create(selectedProjects, options, entryTargetsPerNode));
        }
Пример #3
0
        public static string Create(IEnumerable <ProjectGraphNode> graphNodes, GraphVisOptions options)
        {
            var graphNodesSet = graphNodes.ToHashSet();
            var seen          = new HashSet <ProjectGraphNode>();

            var sb    = new StringBuilder();
            var edges = new StringBuilder();
            //var nodes = new StringBuilder();
            var clusters = new StringBuilder();

            foreach (var group in graphNodesSet
                     .GroupBy(n => n.ProjectInstance.FullPath, (p, plist) => new { ProjectGroupName = p, Projects = plist }))
            {
                GraphVisCluster cluster = new GraphVisCluster(group.ProjectGroupName);

                foreach (var node in group.Projects)
                {
                    var graphNode = new GraphVisNode(node);
                    cluster.AddNode(graphNode);

                    if (seen.Contains(node))
                    {
                        continue;
                    }
                    seen.Add(node);

                    // skip references not in the set of input nodes, in case a subgraph was given
                    foreach (var subNode in node.ProjectReferences.Where(r => graphNodesSet.Contains(r)))
                    {
                        var subGraphVisNode = new GraphVisNode(subNode);
                        var edgeString      = new GraphVisEdge(graphNode, subGraphVisNode);

                        edges.AppendLine(edgeString.Create());

                        //if (!seen.Contains(node))
                        //    nodes.AppendLine(subGraphVisNode.Create());
                    }
                }

                clusters.AppendLine(cluster.Create());
            }

            sb.AppendLine("digraph prof {");
            sb.AppendLine("  ratio = fill;");
            sb.AppendLine($"  nodesep = {options.NodeSep};");
            sb.AppendLine($"  ranksep = {options.RankSep};");
            sb.AppendLine("  node [style=filled];");
            sb.Append(clusters);
            sb.Append(edges);
            sb.AppendLine("}");
            GraphVisNode._count = 1;
            return(sb.ToString());
        }
        public static string Create(ProjectGraph graphNodes, GraphVisOptions options)
        {
            // I don't really remember why I did the hash thing. I think I was concerned with duplicate nodes?
            var projects = new ConcurrentDictionary <string, ProjectGraphNode>();

            foreach (var node in graphNodes.ProjectNodes)
            {
                var propsHash = GraphVis.HashGlobalProps(node.ProjectInstance.GlobalProperties);
                projects.TryAdd(node.ProjectInstance.FullPath + propsHash, node);
            }

            return(Create(projects, options));
        }
        public static string Create(ConcurrentDictionary <string, ProjectGraphNode> projects, GraphVisOptions options)
        {
            HashSet <ProjectGraphNode> seen = new HashSet <ProjectGraphNode>();

            var sb    = new StringBuilder();
            var edges = new StringBuilder();
            //var nodes = new StringBuilder();
            var clusters = new StringBuilder();

            foreach (var group in projects
                     .Where(n => !n.Value.ProjectInstance.FullPath.Contains("dirs.proj"))
                     .GroupBy(kvp => kvp.Value.ProjectInstance.FullPath, (p, plist) => new { ProjectGroupName = p, Projects = projects.Where(p2 => p2.Value.ProjectInstance.FullPath == p).ToList() }))
            {
                GraphVisCluster cluster = new GraphVisCluster(@group.ProjectGroupName);

                foreach (var node in @group.Projects)
                {
                    var graphNode = new GraphVisNode(node.Value);
                    cluster.AddNode(graphNode);

                    if (seen.Contains(node.Value))
                    {
                        continue;
                    }
                    seen.Add(node.Value);

                    //nodes.AppendLine(graphNode.Create());

                    foreach (var subNode in node.Value.ProjectReferences)
                    {
                        var subGraphVisNode = new GraphVisNode(subNode);
                        var edgeString      = new GraphVisEdge(graphNode, subGraphVisNode);

                        edges.AppendLine(edgeString.Create());

                        //if (!seen.Contains(node.Value))
                        //    nodes.AppendLine(subGraphVisNode.Create());
                    }
                }

                clusters.AppendLine(cluster.Create());
            }

            sb.AppendLine("digraph prof {");
            sb.AppendLine("  ratio = fill;");
            sb.AppendLine($"  nodesep = {options.NodeSep};");
            sb.AppendLine($"  ranksep = {options.RankSep};");
            sb.AppendLine("  node [style=filled];");
            sb.Append(clusters);
            sb.Append(edges);
            sb.AppendLine("}");
            GraphVisNode._count = 1;
            return(sb.ToString());
        }