Skip to content

Commit 2d65f31

Browse files
committed
Render include/exclude attributes in dependencies
This is useful information for package authors, render similar to how we render content extra attributes.
1 parent d291337 commit 2d65f31

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/dotnet-nugetize/Program.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Diagnostics.CodeAnalysis;
5-
using System.Globalization;
65
using System.IO;
76
using System.Linq;
87
using System.Reflection;
9-
using System.Runtime.InteropServices;
108
using System.Text;
119
using System.Threading;
1210
using System.Threading.Tasks;
@@ -15,7 +13,6 @@
1513
using Mono.Options;
1614
using Spectre.Console;
1715
using Spectre.Console.Rendering;
18-
using static Devlooped.SponsorLink;
1916
using static ThisAssembly.Strings;
2017

2118
namespace NuGetize;
@@ -396,7 +393,7 @@ void AddContents(TreeNode node, List<XElement> contents)
396393
}
397394

398395
if (attributes.Count > 0)
399-
parent.AddNode($"[white]{Path.GetFileName(file)}[/] [grey]({string.Join(',', attributes)})[/]");
396+
parent.AddNode($"[white]{Path.GetFileName(file)}[/] [grey]({string.Join(", ", attributes)})[/]");
400397
else
401398
parent.AddNode($"[white]{Path.GetFileName(file)}[/]");
402399
}
@@ -413,7 +410,16 @@ void AddDependencies(Tree root, List<XElement> dependencies)
413410
var tf = deps.AddNode($"[green]{group.Key}[/]");
414411
foreach (var dependency in group)
415412
{
416-
tf.AddNode(Markup.FromInterpolated($"[white]{dependency.Attribute("Include").Value}[/], [grey]{dependency.Element("Version").Value}[/]"));
413+
var attributes = new List<string>();
414+
if (dependency.Element("PackInclude")?.Value is string include && !string.IsNullOrEmpty(include))
415+
attributes.Add("include=" + include);
416+
if (dependency.Element("PackExclude")?.Value is string exclude && !string.IsNullOrEmpty(exclude))
417+
attributes.Add("exclude=" + exclude);
418+
419+
if (attributes.Count > 0)
420+
tf.AddNode(Markup.FromInterpolated($"[white]{dependency.Attribute("Include").Value}[/], [grey]{dependency.Element("Version").Value}[/] [grey]({string.Join(", ", attributes)})[/]"));
421+
else
422+
tf.AddNode(Markup.FromInterpolated($"[white]{dependency.Attribute("Include").Value}[/], [grey]{dependency.Element("Version").Value}[/]"));
417423
}
418424
}
419425
}

0 commit comments

Comments
 (0)