Skip to content

Conversation

@asbjornvad
Copy link

This is my attempt at refactoring the RiotSharp api wrapper with a more separated approach(and up to date). The goal is that each game, be it LoL, Valorant and LoR, has their own Nuget package, and use the base functionality provided in the Core package.

The very basic stuff as API-ratelimiting is implemented and seems to work. Things like method ratelimiting and caching is not implemented yet, but should be "easy" to add, once done. This branch is NOT ready!!!

The testing is also done in each project, so the Core functionality is tested with no regards to actual implementations.

Please note that this is the work of a software engineering student during sparetime, and there might be better approaches.
I hope that others will see this as a way to get the RiotSharp wrapper back to the top, and will contribute to that goal!

asbjornvad and others added 30 commits June 23, 2024 15:21
All the Newtonsoft is now System.Text.Json.
Some tests pass, some fail because of errors in JsonSerializer.
Starting refactoring of the ratelimiting and httprequesting.
…quester.

Next task is trying to refactor some already working endpoints to work with the new requester.
…pplication ratelimiters use the IRateLimiter Interface since they fulfil the same duty. No base class for neither.
… This is simpler and the thread safety should be provided by the underlying implementation of MemoryCache.

The number of tests are unsatisfactory as of now.
…ot of uncommented code to avoid build errors.
…hanged exception and Lease.

Still needs some more stuff. A util method should be used to create and send requests to reduce code duplication.
Refactored `IRequester` to `IRiotRequester` across the codebase for improved clarity and alignment with Riot API domain-specific terminology. Updated static data endpoints, constructors, and method calls to reflect this change. Removed `summonerId`-based methods in favor of `puuid`, modernizing API usage.

Deprecated the `ChampionMastery` class and related methods, introducing nullable return types and new methods in `IChampionMasteryEndpoint`. Added unit tests for Champion Mastery functionality using `Moq` and `NUnit`.

Enhanced error handling, modularity, and code readability. Introduced `RateLimitedEndpointBase` for centralized rate-limiting and request handling. Updated project dependencies and improved test coverage for reliability.

Appsettings file needs to be added in the test project root with an apikey.
Refactored `IRequester` to `IRiotRequester` across the codebase for improved clarity and alignment with Riot API domain-specific terminology. Updated static data endpoints, constructors, and method calls to reflect this change. Removed `summonerId`-based methods in favor of `puuid`, modernizing API usage.

Deprecated the `ChampionMastery` class and related methods, introducing nullable return types and new methods in `IChampionMasteryEndpoint`. Added unit tests for Champion Mastery functionality using `Moq` and `NUnit`.

Enhanced error handling, modularity, and code readability. Introduced `RateLimitedEndpointBase` for centralized rate-limiting and request handling. Updated project dependencies and improved test coverage for reliability.

Appsettings file needs to be added in the test project root with an apikey.
For every TestFixture that shouldnt be run in CI, add the     [Category("OnlyLocal")]
At [TestFixture].
Updated .gitignore to exclude appsettings.json files in test directories. Removed hardcoded `ApiKey` from appsettings.json to enhance security and prevent sensitive information from being stored in version control.
Introduced Champion Mastery API with new endpoint, interface, and models
to retrieve mastery data, scores, and top champions. Refactored namespaces
to improve organization and updated exception handling for better error
messages. Enhanced test coverage with a new test project targeting .NET 8.0
and added unit tests for Champion Mastery functionality. Adjusted visibility
of JSON converters for external use and updated solution/project files to
support new features.
asbjornvad added 19 commits July 5, 2025 22:01
Champion rotation endpoint is basically a copy paste of the old.
It has the implemented Match endpoint but it has no tests as of yet...
A lot of nullable and required fields that might be wrong, the docs are pretty bad at specifying what is and is not in the json. Removed 2 txt files. Updated the Core project to nuget capability. So the Lol and account project references nuget instead of project.
@asbjornvad
Copy link
Author

Notes:

  • Account project should be complete.
  • Core has a working requester and ApplicationRateLimiter. Still needs support for caching, MethodRateLimiter and possibly return of HttpResponse instead of desirialized content. Also needs support for RSO (Riot Sign On?).
  • Most of the LoL endpoints are implemented. However the official documentation is lacking when it comes to which fields are always returned and which are only sometimes. Therefore the "required" and "nullable" properties should be reconsidered. Tests pass, but other calls might fail.
  • I have dabbled with github actions and have two workflows. One that runs on pushes(build and test) and one that runs on created releases(push nuget). Push nuget tests the build to verify, and then pushes the 3 nuget packages to nuget.org(see AV.RiotSharp.Account, Core and LeagueOfLegends).

The overall architecture is differs slightly from the monolithic RiotAPI approach the current RiotSharp project uses.

@BenFradet
Copy link
Owner

thanks 👍 , do you consider the pr ready for review now?

@asbjornvad
Copy link
Author

If the notes above are taken into account then yes.

@asbjornvad asbjornvad marked this pull request as ready for review January 22, 2026 09:30
Copy link
Owner

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great effort! 💪
A couple of notes:

  • try to refrain from swearing in the code 😅
  • try to minimize code duplication (e.g. around the converters and the ToApiString() functions)
  • try to remove commented out code

"II" => Division.II,
"III" => Division.III,
"IV" => Division.IV,
_ => throw new JsonException("Invalid division value")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like some converters have a default value, some throw
maybe we should align them on an approach

{
serializer.Serialize(writer, ((Tier)value).ToString().ToUpper());
}
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove

Comment on lines +45 to +59
string stringValue = value switch
{
Queue.RankedSolo5x5 => "RANKED_SOLO_5x5",
Queue.RankedTeam3x3 => "RANKED_TEAM_3x3",
Queue.RankedTeam5x5 => "RANKED_TEAM_5x5",
Queue.TeamBuilderDraftRanked5x5 => "TEAM_BUILDER_DRAFT_RANKED_5x5",
Queue.TeamBuilderDraftUnranked5x5 => "TEAM_BUILDER_DRAFT_UNRANKED_5x5",
Queue.RankedFlexSR => "RANKED_FLEX_SR",
Queue.RankedFlexTT => "RANKED_FLEX_TT",
Queue.TeamBuilderRankedSolo => "TEAM_BUILDER_RANKED_SOLO",
Queue.RankedPremade3x3 => "RANKED_PREMADE_3x3",
Queue.RankedPremade5x5 => "RANKED_PREMADE_5x5",
Queue.Darkstar => "DARKSTAR_3x3",
_ => "RANKED_SOLO_5x5"
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't we leverage Queue.ToApiString()?

{
/// <summary>
/// Timeline event data.
/// The documentation is fucking pisspoor!!! LIKE WTF Riot???
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The documentation is fucking pisspoor!!! LIKE WTF Riot???
/// The documentation is bad!!! LIKE WTF Riot???

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this is empty

… Next i would want to do the same for the RateLimiter, but that is a different beast...
…lection stuff found in the .net source repo.
@asbjornvad
Copy link
Author

Thanks for the review. I have started fixing and will comment or resolve along the way.
I really appreciate that you take the time, this is a great learning experience for me(:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants