Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build/config.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/emgarten/nuget.catalogreader</RepositoryUrl>
<PackageTags>nuget nugetcatalog nugetfeed nugetv3</PackageTags>
<PackageIconUrl>
https://emgartenstatic.blob.core.windows.net/nupkgs/icons/nuget.catalogreader.png</PackageIconUrl>
<PackageIconUrl>https://emgartenstatic.blob.core.windows.net/nupkgs/icons/nuget.catalogreader.png</PackageIconUrl>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/NuGet.CatalogReader/CatalogPageEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public int CompareTo(CatalogPageEntry? other)
{
if (other == null)
{
return -1;
return 1;
}

return CommitTimeStamp.CompareTo(other.CommitTimeStamp);
Expand Down
2 changes: 1 addition & 1 deletion src/NuGet.CatalogReader/FeedReader/PackageEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public int CompareTo(PackageEntry? other)
{
if (other == null)
{
return -1;
return 1;
}

var result = StringComparer.OrdinalIgnoreCase.Compare(Id, other.Id);
Expand Down
47 changes: 43 additions & 4 deletions src/NuGet.CatalogReader/ProcessEntriesUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ public static Task<IReadOnlyList<FileInfo>> DownloadNuspecsAsync(string outputDi
throw new InvalidOperationException("Duplicate entries detected. Entries must be unique by id/version.");
}

return RunAsync<FileInfo>(
return RunAsyncCore<FileInfo>(
apply: e => e.DownloadNuspecAsync(outputDirectory, mode, token),
maxThreads: maxConcurrentDownloads,
entries: entriesArray,
token: token);
}

[Obsolete("Use the overload with CancellationToken as the last parameter.")]
#pragma warning disable CA1068 // CancellationToken parameters must come last
public static Task<IReadOnlyList<FileInfo>> DownloadNuspecsAsync(string outputDirectory, DownloadMode mode, int maxConcurrentDownloads, CancellationToken token, IEnumerable<CatalogEntry> entries)
#pragma warning restore CA1068
{
return DownloadNuspecsAsync(outputDirectory, mode, maxConcurrentDownloads, entries, token);
}

public static Task<IReadOnlyList<FileInfo>> DownloadNupkgsAsync(string outputDirectory, DownloadMode mode, int maxConcurrentDownloads, IEnumerable<CatalogEntry> entries, CancellationToken token)
{
var entriesArray = entries.ToArray();
Expand All @@ -34,13 +42,21 @@ public static Task<IReadOnlyList<FileInfo>> DownloadNupkgsAsync(string outputDir
throw new InvalidOperationException("Duplicate entries detected. Entries must be unique by id/version.");
}

return RunAsync<FileInfo>(
return RunAsyncCore<FileInfo>(
apply: e => e.DownloadNupkgAsync(outputDirectory, mode, token),
maxThreads: maxConcurrentDownloads,
entries: entriesArray,
token: token);
}

[Obsolete("Use the overload with CancellationToken as the last parameter.")]
#pragma warning disable CA1068 // CancellationToken parameters must come last
public static Task<IReadOnlyList<FileInfo>> DownloadNupkgsAsync(string outputDirectory, DownloadMode mode, int maxConcurrentDownloads, CancellationToken token, IEnumerable<CatalogEntry> entries)
#pragma warning restore CA1068
{
return DownloadNupkgsAsync(outputDirectory, mode, maxConcurrentDownloads, entries, token);
}

/// <summary>
/// Filter entry list to only the latest version of a package.
/// </summary>
Expand All @@ -57,10 +73,33 @@ public static CatalogEntry[] FilterToLatestPerId(bool includePrerelease, IEnumer
/// <summary>
/// Apply an async transform to each entry with throttled concurrency.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">Result type of the transform.</typeparam>
/// <param name="apply">Transform or action to apply to each catalog entry.</param>
/// <param name="maxThreads">Max threads</param>
public static async Task<IReadOnlyList<T>> RunAsync<T>(Func<CatalogEntry, Task<T>> apply, int maxThreads, IEnumerable<CatalogEntry> entries, CancellationToken token)
/// <param name="entries">Catalog entries to process.</param>
/// <param name="token">Cancellation token.</param>
public static Task<IReadOnlyList<T>> RunAsync<T>(Func<CatalogEntry, Task<T>> apply, int maxThreads, IEnumerable<CatalogEntry> entries, CancellationToken token)
{
return RunAsyncCore(apply, maxThreads, entries, token);
}

/// <summary>
/// Apply an async transform to each entry with throttled concurrency.
/// </summary>
/// <typeparam name="T">Result type of the transform.</typeparam>
/// <param name="apply">Transform or action to apply to each catalog entry.</param>
/// <param name="maxThreads">Max threads</param>
/// <param name="token">Cancellation token.</param>
/// <param name="entries">Catalog entries to process.</param>
[Obsolete("Use the overload with CancellationToken as the last parameter.")]
#pragma warning disable CA1068 // CancellationToken parameters must come last
public static Task<IReadOnlyList<T>> RunAsync<T>(Func<CatalogEntry, Task<T>> apply, int maxThreads, CancellationToken token, IEnumerable<CatalogEntry> entries)
#pragma warning restore CA1068
{
return RunAsyncCore(apply, maxThreads, entries, token);
}

private static async Task<IReadOnlyList<T>> RunAsyncCore<T>(Func<CatalogEntry, Task<T>> apply, int maxThreads, IEnumerable<CatalogEntry> entries, CancellationToken token)
{
var entriesArray = entries.ToArray();

Expand Down