Giter VIP home page Giter VIP logo

.net-apiclient's People

Contributors

itssimple avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

.net-apiclient's Issues

Problem with multithreading

in readme.md

Please make note that the ApiClient inheirits of IDisposable, so that you dispose of it when you're done with it.

consider this code:

await Parallel.ForEachAsync(Enumerable.Range(1, 100), async (i, token) =>
{
    try
    {
        using var apiClient = new ApiClient("MY_API_KEY", "MY_EMAIL");
        var file = await apiClient.GetModAsync(238222);
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
    }
});

it pops out some exceptions like this:

System.Threading.Tasks.TaskCanceledException: OperationCanceled
 ---> System.IO.IOException: net_io_read
 ---> System.ObjectDisposedException: ObjectDisposed_Generic
ObjectDisposed_ObjectName_Name, System.Net.Sockets.NetworkStream
   at System.Net.Sockets.NetworkStream.<ThrowIfDisposed>g__ThrowObjectDisposedException|63_0()
.......
   at CurseForge.APIClient.ApiClient.GET[T](String endpoint, ValueTuple`2[] queryParameters) in D:\Git\CurseForge.APIClient\ApiClient.cs:line 79
   at CurseForge.APIClient.ApiClient.GetModAsync(UInt32 modId) in D:\Git\CurseForge.APIClient\Mods.cs:line 22
   at Program.<>c.<<<Main>$>b__0_0>d.MoveNext() in C:\Users\cyl18\source\repos\TestDotNet6\TestDotNet6\Program.cs:line 15

in ApiClient.cs, the _httpClient is static, which means a single instance disposes would affect all existing instances

private static HttpClient _httpClient;

and a static HttpClient would cause extra problems like all ApiClient will use the same ApiKey

i have made a simple pull request to fix this problem :) (#2)

Improvement of error handling

Hello! First of all, I'd like to say thank you for such a great implementation of CurseForge API. I have just a few improvements ideas I'd like to see.

Recently, I started looking for Mod Files using ProjectId and FileId from Minecraft modpacks manifest.json file. Most of them was successfuly found, but some have missing files. I mean, mods being deleted from CurseForge. So ApiClient class have to throw not a very informative Exception about it, as CurseForge API response was 404 NotFound StatusCode. This messes up with many another http exceptions, where rate-limit gets applied or API key have been rejected.

I'd like to ask you just add some information about "bad" response being received. Split all types of CurseForge API exception to different classes, or at least, add a Message property to Exception, so we can identify Mods that cannot be found, or Rate Limit exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.