private DependencyGraph GetDependencyGraph(ILoggerFactory loggerFactory) { var analyzer = new DependencyAnalyzer(loggerFactory); DependencyGraph graph; if (!string.IsNullOrEmpty(Package)) { graph = analyzer.Analyze(Package, Version, Framework); } else if (Path.GetExtension(Project).Equals(".sln", StringComparison.OrdinalIgnoreCase)) { graph = analyzer.AnalyzeSolution(Project, Framework); } else { graph = analyzer.Analyze(Project, Framework); } return(graph); }
// ReSharper disable once UnusedMember.Local private void OnExecute() { var loggerFactory = LoggerFactory.Create(builder => builder .SetMinimumLevel(Verbosity) .AddConsole()); var analyzer = new DependencyAnalyzer(loggerFactory); DependencyGraph graph; if (!string.IsNullOrEmpty(Package)) { graph = analyzer.Analyze(Package, Version, Framework); } else if (Path.GetExtension(Project).Equals(".sln", StringComparison.OrdinalIgnoreCase)) { graph = analyzer.AnalyzeSolution(Project, Framework); } else { graph = analyzer.Analyze(Project, Framework); } Application.Init(); var top = new CustomWindow(); var left = new FrameView("Dependencies") { Width = Dim.Percent(50), Height = Dim.Fill(1) }; var right = new View() { X = Pos.Right(left), Width = Dim.Fill(), Height = Dim.Fill(1) }; var helpText = new Label("Use arrow keys and Tab to move around. Ctrl+D to toggle assembly visibility. Esc to quit.") { Y = Pos.AnchorEnd(1) }; var runtimeDepends = new FrameView("Runtime depends") { Width = Dim.Fill(), Height = Dim.Percent(33f) }; var packageDepends = new FrameView("Package depends") { Y = Pos.Bottom(runtimeDepends), Width = Dim.Fill(), Height = Dim.Percent(50f) }; var reverseDepends = new FrameView("Reverse depends") { Y = Pos.Bottom(packageDepends), Width = Dim.Fill(), Height = Dim.Fill() }; var orderedDependencyList = graph.Nodes.OrderBy(x => x.Id).ToImmutableList(); var dependenciesView = new ListView(orderedDependencyList) { CanFocus = true, AllowsMarking = false }; left.Add(dependenciesView); var runtimeDependsView = new ListView(Array.Empty <Node>()) { CanFocus = true, AllowsMarking = false }; runtimeDepends.Add(runtimeDependsView); var packageDependsView = new ListView(Array.Empty <Node>()) { CanFocus = true, AllowsMarking = false }; packageDepends.Add(packageDependsView); var reverseDependsView = new ListView(Array.Empty <Node>()) { CanFocus = true, AllowsMarking = false }; reverseDepends.Add(reverseDependsView); right.Add(runtimeDepends, packageDepends, reverseDepends); top.Add(left, right, helpText); Application.Top.Add(top); top.Dependencies = orderedDependencyList; top.VisibleDependencies = orderedDependencyList; top.DependenciesView = dependenciesView; dependenciesView.SelectedItem = 0; UpdateLists(); dependenciesView.SelectedChanged += UpdateLists; Application.Run(); void UpdateLists() { var selectedNode = top.VisibleDependencies[dependenciesView.SelectedItem]; runtimeDependsView.SetSource(graph.Edges.Where(x => x.Start.Equals(selectedNode) && x.End is AssemblyReferenceNode) .Select(x => x.End).ToImmutableList()); packageDependsView.SetSource(graph.Edges.Where(x => x.Start.Equals(selectedNode) && x.End is PackageReferenceNode) .Select(x => $"{x.End}{(string.IsNullOrEmpty(x.Label) ? string.Empty : " (Wanted: " + x.Label + ")")}").ToImmutableList()); reverseDependsView.SetSource(graph.Edges.Where(x => x.End.Equals(selectedNode)) .Select(x => $"{x.Start}{(string.IsNullOrEmpty(x.Label) ? string.Empty : " (Wanted: " + x.Label + ")")}").ToImmutableList()); } }