Skip to content

Commit

Permalink
Remove named tuples where not needed (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren authored May 29, 2024
1 parent 193d192 commit 88b652a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions PackageIndexer/DotnetPackageIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static async Task<IReadOnlyList<PackageIdentity>> GetPackagesAsync(
params string[] feedUrls
)
{
var packages = new List<(PackageIdentity packageId, bool isDeprecated)>();
var packages = new List<(PackageIdentity, bool)>();

foreach (string feedUrl in feedUrls)
{
Expand All @@ -59,7 +59,7 @@ params string[] feedUrls
return latestVersions;
}

private static async Task<IReadOnlyList<(PackageIdentity packageId, bool isDeprecated)>> GetPackagesAsync(NuGetFeed feed)
private static async Task<IReadOnlyList<(PackageIdentity, bool)>> GetPackagesAsync(NuGetFeed feed)
{
Console.WriteLine($"Getting packages from {feed.FeedUrl}...");

Expand All @@ -70,7 +70,7 @@ params string[] feedUrls
throw new ApplicationException("NuGetOrg should be the only feed.");
}

private static async Task<IReadOnlyList<(PackageIdentity version, bool isDeprecated)>> GetPackagesFromNuGetOrgAsync(NuGetFeed feed)
private static async Task<IReadOnlyList<(PackageIdentity, bool)>> GetPackagesFromNuGetOrgAsync(NuGetFeed feed)
{
Console.WriteLine("Fetching owner information...");
Dictionary<string, string[]> ownerInformation = await feed.GetOwnerMappingAsync();
Expand All @@ -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)
{
Expand All @@ -114,7 +114,8 @@ bool usePreviewVersions
{
var result = new List<PackageIdentity>();

IEnumerable<IGrouping<string, (PackageIdentity packageId, bool isDeprecated)>> groups = identities.GroupBy(i => i.Item1.Id).OrderBy(g => g.Key);
IEnumerable<IGrouping<string, (PackageIdentity, bool)>> groups =
identities.GroupBy(i => i.packageId.Id).OrderBy(g => g.Key);

foreach (IGrouping<string, (PackageIdentity packageId, bool isDeprecated)> group in groups)
{
Expand Down
2 changes: 1 addition & 1 deletion PackageIndexer/NuGet/NuGetFeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ string feed
logger,
cancellationToken);

List<(NuGetVersion, bool)> versions = new();
List<(NuGetVersion, bool)> versions = [];

foreach (IPackageSearchMetadata package in packages)
{
Expand Down

0 comments on commit 88b652a

Please sign in to comment.