-
Notifications
You must be signed in to change notification settings - Fork 142
Refactor #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Refactor #729
Conversation
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].
Needs cleanup
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.
… them. Use the Builder class to build.
Champion rotation endpoint is basically a copy paste of the old.
…ave Models folder.
…hange to the Champion mastery endpoint.
…nough to justify more work.
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.
… then makes a new batch of nuget packages.
|
Notes:
The overall architecture is differs slightly from the monolithic RiotAPI approach the current RiotSharp project uses. |
|
thanks 👍 , do you consider the pr ready for review now? |
|
If the notes above are taken into account then yes. |
…rated TestObject just to test other than string.
BenFradet
left a comment
There was a problem hiding this 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") |
There was a problem hiding this comment.
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()); | ||
| } | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove
| 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" | ||
| }; |
There was a problem hiding this comment.
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??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// The documentation is fucking pisspoor!!! LIKE WTF Riot??? | |
| /// The documentation is bad!!! LIKE WTF Riot??? |
There was a problem hiding this comment.
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.
|
Thanks for the review. I have started fixing and will comment or resolve along the way. |
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!