-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #20: Show a dependency tree of all transient packages.
- Loading branch information
1 parent
16ee808
commit e9be321
Showing
17 changed files
with
353 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
using Microsoft.Build.Evaluation; | ||
using NuGet.Frameworks; | ||
using NuGet.Frameworks; | ||
|
||
namespace NuGetMonitor.Models; | ||
|
||
internal sealed record TransitiveDependencies(Project Project, NuGetFramework TargetFramework, IReadOnlyDictionary<PackageInfo, HashSet<PackageInfo>> ParentsByChild); | ||
internal sealed record TransitiveDependencies(string ProjectName, NuGetFramework TargetFramework, IReadOnlyDictionary<PackageInfo, HashSet<PackageInfo>> ParentsByChild); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.ComponentModel.Design; | ||
using Microsoft.VisualStudio.Shell; | ||
using NuGetMonitor.View.Monitor; | ||
|
||
namespace NuGetMonitor; | ||
|
||
internal sealed class NuGetMonitorCommands | ||
{ | ||
private const int _monitorCommandId = 0x0100; | ||
private const int _dependencyTreeCommandId = 0x0101; | ||
|
||
private static readonly Guid _commandSet = new("df4cd5dd-21c1-4666-8b25-bffe33b47ac1"); | ||
|
||
private readonly AsyncPackage _package; | ||
|
||
private NuGetMonitorCommands(AsyncPackage package, OleMenuCommandService commandService) | ||
{ | ||
_package = package ?? throw new ArgumentNullException(nameof(package)); | ||
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); | ||
|
||
commandService.AddCommand(new MenuCommand(ExecuteMonitorCommand, new CommandID(_commandSet, _monitorCommandId))); | ||
commandService.AddCommand(new MenuCommand(ExecuteDependencyTreeCommand, new CommandID(_commandSet, _dependencyTreeCommandId))); | ||
} | ||
|
||
public static NuGetMonitorCommands? Instance | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
public static async Task InitializeAsync(AsyncPackage package) | ||
{ | ||
await JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); | ||
|
||
var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(true) as OleMenuCommandService ?? throw new InvalidOperationException("Failed to get menu command service"); | ||
|
||
Instance = new NuGetMonitorCommands(package, commandService); | ||
} | ||
|
||
public void ShowMonitorToolWindow() | ||
{ | ||
_package.JoinableTaskFactory.RunAsync(async delegate | ||
{ | ||
var window = await _package.ShowToolWindowAsync(typeof(NuGetMonitorToolWindow), 0, true, _package.DisposalToken); | ||
if (window?.Frame == null) | ||
throw new NotSupportedException("Cannot create tool window"); | ||
}).FireAndForget(); | ||
} | ||
|
||
private void ExecuteMonitorCommand(object sender, EventArgs e) | ||
{ | ||
ShowMonitorToolWindow(); | ||
} | ||
public void ShowDependencyTreeToolWindow() | ||
{ | ||
_package.JoinableTaskFactory.RunAsync(async delegate | ||
{ | ||
var window = await _package.ShowToolWindowAsync(typeof(DependencyTreeToolWindow), 0, true, _package.DisposalToken); | ||
if (window?.Frame == null) | ||
throw new NotSupportedException("Cannot create tool window"); | ||
}).FireAndForget(); | ||
} | ||
|
||
private void ExecuteDependencyTreeCommand(object sender, EventArgs e) | ||
{ | ||
ShowDependencyTreeToolWindow(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<UserControl x:Class="NuGetMonitor.View.DependencyTree.DependencyTreeControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:NuGetMonitor.View.DependencyTree" | ||
xmlns:toms="urn:TomsToolbox" | ||
xmlns:styles="urn:TomsToolbox.Wpf.Styles" | ||
xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging" | ||
xmlns:imageCatalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<UserControl.DataContext> | ||
<local:DependencyTreeViewModel /> | ||
</UserControl.DataContext> | ||
<UserControl.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="/NuGetMonitor;component/Resources/VSColorScheme.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
<Thickness x:Key="NodeMargin">4</Thickness> | ||
<HierarchicalDataTemplate x:Key="NodeTemplate" | ||
DataType="{x:Type local:ChildNode}" | ||
ItemsSource="{Binding Children}"> | ||
<HierarchicalDataTemplate.ItemContainerStyle> | ||
<Style TargetType="TreeViewItem"> | ||
<Setter Property="IsExpanded" Value="True" /> | ||
</Style> | ||
</HierarchicalDataTemplate.ItemContainerStyle> | ||
<TextBlock x:Name="TextBlock" Margin="{StaticResource NodeMargin}"> | ||
<Run Text="{Binding PackageIdentity, Mode=OneWay}" /> | ||
<Run Text="{Binding Issues, Mode=OneWay}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" /> | ||
</TextBlock> | ||
<HierarchicalDataTemplate.Triggers> | ||
<DataTrigger Binding="{Binding HasChildren}" Value="False"> | ||
<Setter TargetName="TextBlock" Property="FontWeight" Value="Bold" /> | ||
</DataTrigger> | ||
</HierarchicalDataTemplate.Triggers> | ||
</HierarchicalDataTemplate> | ||
</ResourceDictionary> | ||
</UserControl.Resources> | ||
<Grid FocusManager.FocusedElement="{Binding ElementName=TreeView}"> | ||
<DockPanel> | ||
<ToolBar DockPanel.Dock="Top" | ||
Style="{DynamicResource {x:Static styles:ResourceKeys.ToolBarStyle}}"> | ||
<Button Command="{Binding RefreshCommand}" ToolTip="Refresh"> | ||
<imaging:CrispImage Width="16" Height="16" Moniker="{x:Static imageCatalog:KnownMonikers.Refresh}" /> | ||
</Button> | ||
</ToolBar> | ||
<TreeView x:Name="TreeView" | ||
BorderThickness="0 1 0 0" | ||
ItemsSource="{Binding TransitivePackages}"> | ||
<TreeView.ItemContainerStyle> | ||
<Style TargetType="TreeViewItem"> | ||
<Setter Property="IsExpanded" Value="True" /> | ||
</Style> | ||
</TreeView.ItemContainerStyle> | ||
<TreeView.ItemTemplate> | ||
<HierarchicalDataTemplate DataType="{x:Type local:RootNode}" | ||
ItemsSource="{Binding Children}" | ||
ItemTemplate="{StaticResource NodeTemplate}"> | ||
<HierarchicalDataTemplate.ItemContainerStyle> | ||
<Style TargetType="TreeViewItem"> | ||
<Setter Property="IsExpanded" Value="False" /> | ||
</Style> | ||
</HierarchicalDataTemplate.ItemContainerStyle> | ||
<TextBlock Margin="{StaticResource NodeMargin}" FontSize="14"> | ||
<TextBlock.Text> | ||
<MultiBinding StringFormat="{}{0} [{1}]"> | ||
<MultiBinding.Bindings> | ||
<Binding Path="ProjectName" /> | ||
<Binding Path="TargetFramework" /> | ||
</MultiBinding.Bindings> | ||
</MultiBinding> | ||
</TextBlock.Text> | ||
<!--<Run Text="{Binding ProjectName, Mode=OneWay}" /><Run Text=" [" /><Run Text="{Binding TargetFramework, Mode=OneWay}" /><Run Text="]" />--> | ||
</TextBlock> | ||
</HierarchicalDataTemplate> | ||
</TreeView.ItemTemplate> | ||
</TreeView> | ||
</DockPanel> | ||
<toms:LoadingIndicator IsActive="{Binding IsLoading}" Header="Loading..." d:IsHidden="True" /> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace NuGetMonitor.View.DependencyTree | ||
{ | ||
/// <summary> | ||
/// Interaction logic for DependencyTreeControl.xaml | ||
/// </summary> | ||
public partial class DependencyTreeControl | ||
{ | ||
public DependencyTreeControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Runtime.InteropServices; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace NuGetMonitor.View.DependencyTree; | ||
|
||
[Guid("C82FB9BC-D58C-48CA-95EC-40905527089F")] | ||
public sealed class DependencyTreeToolWindow : ToolWindowPane | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DependencyTreeToolWindow"/> class. | ||
/// </summary> | ||
public DependencyTreeToolWindow() : base(null) | ||
{ | ||
Caption = "Package Dependency Tree"; | ||
Content = new DependencyTreeControl(); | ||
} | ||
} |
Oops, something went wrong.