private IEnumerable <(string pathPostfix, string contents)> GetDotNotations( FileInfo projectFile, ImmutableDictionary <string, string> globalProperties, string[] targets, string[] endNodes) { Console.WriteLine("Loading graph..."); var sw = Stopwatch.StartNew(); var graph = new ProjectGraph(new ProjectGraphEntryPoint(projectFile.FullName, globalProperties), ProjectCollection.GlobalProjectCollection); sw.Stop(); Console.WriteLine($@"{projectFile} loaded {graph.ProjectNodes.Count} node(s) in {sw.ElapsedMilliseconds}ms."); var entryTargetsPerNode = graph.GetTargetLists(targets); if (endNodes != null) { var endGraphNodes = graph.ProjectNodes.Where(n => endNodes.Any(en => n.ProjectInstance.FullPath.Contains(en))); var paths = GraphPaths.FindAllPathsBetween(graph.GraphRoots, endGraphNodes); var deduplicatedNodes = paths.SelectMany(p => p).ToHashSet(); yield return($"_PathsEndingIn_{string.Join(",", endNodes)}", GraphVis.Create(deduplicatedNodes, entryTargetsPerNode)); } yield return("", GraphVis.Create(graph, entryTargetsPerNode)); }
private string LoadGraph(FileInfo projectFile) { var files = new List <string>(); if (projectFile.Extension == ".sln") { files.AddRange(SolutionParser.GetProjectFiles(projectFile.FullName)); } else { files.Add(projectFile.FullName); } Console.WriteLine("Loading graph..."); var sw = Stopwatch.StartNew(); var graph = new ProjectGraph(files, ProjectCollection.GlobalProjectCollection); Console.WriteLine($@"{projectFile} loaded {graph.ProjectNodes.Count} node(s) in {sw.ElapsedMilliseconds}ms."); return(GraphVis.Create(graph)); }