From c987eacecb0f597216bb570ebf633d07caef6a42 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 28 May 2024 09:23:40 -0700 Subject: [PATCH 1/2] rename param --- PackageIndexer/DotnetPackageIndex.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PackageIndexer/DotnetPackageIndex.cs b/PackageIndexer/DotnetPackageIndex.cs index 74e95c2..b7d00c0 100644 --- a/PackageIndexer/DotnetPackageIndex.cs +++ b/PackageIndexer/DotnetPackageIndex.cs @@ -70,7 +70,7 @@ params string[] feedUrls throw new ApplicationException("NuGetOrg should be the only feed."); } - private static async Task> GetPackagesFromNuGetOrgAsync(NuGetFeed feed) + private static async Task> GetPackagesFromNuGetOrgAsync(NuGetFeed feed) { Console.WriteLine("Fetching owner information..."); Dictionary ownerInformation = await feed.GetOwnerMappingAsync(); From 68718885bf713aacbc98a3ce89ca7510d06ad528 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 28 May 2024 09:40:58 -0700 Subject: [PATCH 2/2] simplify tuples where possible --- PackageIndexer/DotnetPackageIndex.cs | 13 +++++++------ PackageIndexer/NuGet/NuGetFeed.cs | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/PackageIndexer/DotnetPackageIndex.cs b/PackageIndexer/DotnetPackageIndex.cs index b7d00c0..154636e 100644 --- a/PackageIndexer/DotnetPackageIndex.cs +++ b/PackageIndexer/DotnetPackageIndex.cs @@ -41,7 +41,7 @@ private static async Task> GetPackagesAsync( params string[] feedUrls ) { - var packages = new List<(PackageIdentity packageId, bool isDeprecated)>(); + var packages = new List<(PackageIdentity, bool)>(); foreach (string feedUrl in feedUrls) { @@ -59,7 +59,7 @@ params string[] feedUrls return latestVersions; } - private static async Task> GetPackagesAsync(NuGetFeed feed) + private static async Task> GetPackagesAsync(NuGetFeed feed) { Console.WriteLine($"Getting packages from {feed.FeedUrl}..."); @@ -70,7 +70,7 @@ params string[] feedUrls throw new ApplicationException("NuGetOrg should be the only feed."); } - private static async Task> GetPackagesFromNuGetOrgAsync(NuGetFeed feed) + private static async Task> GetPackagesFromNuGetOrgAsync(NuGetFeed feed) { Console.WriteLine("Fetching owner information..."); Dictionary ownerInformation = await feed.GetOwnerMappingAsync(); @@ -89,11 +89,11 @@ params string[] feedUrls Console.WriteLine("Getting versions..."); - ConcurrentBag<(PackageIdentity packageId, bool isDeprecated)> identities = []; + ConcurrentBag<(PackageIdentity, bool)> identities = []; await Parallel.ForEachAsync(packageIds, async (packageId, _) => { - IReadOnlyList<(NuGetVersion version, bool isDeprecated)> versions = await feed.GetAllVersionsAsync(packageId); + IReadOnlyList<(NuGetVersion, bool)> versions = await feed.GetAllVersionsAsync(packageId); foreach ((NuGetVersion version, bool isDeprecated) version in versions) { @@ -114,7 +114,8 @@ bool usePreviewVersions { var result = new List(); - IEnumerable> groups = identities.GroupBy(i => i.Item1.Id).OrderBy(g => g.Key); + IEnumerable> groups = + identities.GroupBy(i => i.packageId.Id).OrderBy(g => g.Key); foreach (IGrouping group in groups) { diff --git a/PackageIndexer/NuGet/NuGetFeed.cs b/PackageIndexer/NuGet/NuGetFeed.cs index 05c2a62..24550e1 100644 --- a/PackageIndexer/NuGet/NuGetFeed.cs +++ b/PackageIndexer/NuGet/NuGetFeed.cs @@ -153,7 +153,7 @@ string feed logger, cancellationToken); - List<(NuGetVersion, bool)> versions = new(); + List<(NuGetVersion, bool)> versions = []; foreach (IPackageSearchMetadata package in packages) {