public static void PrintStatistics(
     this PowerfulAsyncEnumerable runnable,
     List <PackageMetadata> packagesWithNetFxAsms,
     int totalCount)
 {
     Console.Out.WriteLine();
     Console.Out.WriteLine($"Packages with dotnet assemblies: {packagesWithNetFxAsms.Count} ({totalCount})");
     Console.Out.WriteLine($"Total download size(MB): {packagesWithNetFxAsms.Sum(p => p.Size) / 1000000.0}");
 }
    public static async Task <CatalogPage> ReadPage5000FromNuget(
        this PowerfulAsyncEnumerable runnable,
        HttpClient httpClient)
    {
        var url  = $"https://api.nuget.org/v3/catalog0/page5000.json";
        var page = await runnable.ReadUrl(httpClient, url).ConfigureAwait(false);

        Console.WriteLine($"Reading metadata for {url}");
        return(page);
    }
    public static async Task <CatalogPage> ReadUrl(
        this PowerfulAsyncEnumerable runnable,
        HttpClient httpClient,
        string catalogPageUrl)
    {
        var response = await httpClient.GetAsync(catalogPageUrl).ConfigureAwait(false);

        response.EnsureSuccessStatusCode();

        using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

        return(await JsonSerializer.DeserializeAsync <CatalogPage>(responseStream).ConfigureAwait(false));
    }
    public static async Task <PackageMetadata> GetMetadataForPackage(
        this PowerfulAsyncEnumerable runnable,
        HttpClient httpClient,
        string packageMetadataUrl,
        SemaphoreSlim throttler,
        CancellationToken cancellationToken)
    {
        try
        {
            await throttler.WaitAsync(cancellationToken).ConfigureAwait(false);

            return(await PackageMetadataReader.ReadUrl(httpClient, packageMetadataUrl, cancellationToken)
                   .ConfigureAwait(false));
        }
        finally
        {
            throttler.Release();
        }
    }
    public static void Explain(this PowerfulAsyncEnumerable runnable, TextWriter writer)
    {
        writer.WriteLine(@"
- Async Enumerable can be combined in powerful ways with other async and TPL constructs such as `Task.WhenAny`
");
    }