From 60be9f3a1832d84c5ade7c6bb91d973c59283603 Mon Sep 17 00:00:00 2001 From: Mersad Katana Date: Sun, 29 Mar 2020 12:42:06 +0200 Subject: [PATCH] Remove duplicated tables when printing references (#19) Co-authored-by: Thomas Chavakis --- src/Methods.cs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Methods.cs b/src/Methods.cs index 529692b7..df5f5fb9 100644 --- a/src/Methods.cs +++ b/src/Methods.cs @@ -160,15 +160,12 @@ public async Task PrintReferencesAsync(string projectPath, bool uniqueList foreach (var item in projects) { IEnumerable references = this.GetProjectReferences(item); + var currentProjectLicenses = await this.GetNugetInformationAsync(item, references); + licenses.Add(currentProjectLicenses); - if (uniqueList) + if (!uniqueList) { - licenses.Add(await this.GetNugetInformationAsync(item, references)); - } - else - { - licenses.Add(await this.GetNugetInformationAsync(item, references)); - PrintLicenses(licenses); + PrintLicenses(currentProjectLicenses); } result = true; @@ -182,18 +179,14 @@ public async Task PrintReferencesAsync(string projectPath, bool uniqueList return result; } - public void PrintLicenses(List> licenses) + public void PrintLicenses(Dictionary licenses) { if (licenses.Any()) { Console.WriteLine(Environment.NewLine + "References:"); - - foreach (var license in licenses) - { - Console.WriteLine(license.ToStringTable(new[] { "Reference", "Licence", "Version", "LicenceType" }, - a => a.Value.Metadata.Id ?? "---", a => a.Value.Metadata.LicenseUrl ?? "---", - a => a.Value.Metadata.Version ?? "---", a => (a.Value.Metadata.License != null ? a.Value.Metadata.License.Text : "---"))); - } + Console.WriteLine(licenses.ToStringTable(new[] { "Reference", "Licence", "Version", "LicenceType" }, + a => a.Value.Metadata.Id ?? "---", a => a.Value.Metadata.LicenseUrl ?? "---", + a => a.Value.Metadata.Version ?? "---", a => (a.Value.Metadata.License != null ? a.Value.Metadata.License.Text : "---"))); } }