-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor & Enhancements: Namespace Fix, .NET 9 Upgrade, Bot Package Checker, and Plugin Improvements #124
Conversation
…edlib_instances.json and add new version
…ee games collection
Migrates the project to .NET 9.0 and updates core dependencies. This includes: - Upgrading target frameworks and SDK versions to .NET 9.0 - Updating NuGet dependencies to latest versions (NLog, xunit, coverlet, Microsoft.NET.Test.Sdk, ConfigureAwaitChecker.Analyzer) - Bumping plugin version to 1.9.0.0 - Minor fix in `SimpleHttpClient.DisposeAsync` for `ValueTask` handling - Qualifying `OrderedDictionary` namespace in Reddit components for clarity - Adapting `BotContext` for robust `Bot.OwnedPackages` access, using reflection for fallback This upgrade ensures compatibility with the latest .NET runtime and incorporates recent improvements from dependency updates.
Improve README clarity, update submodule references, and fix namespace spelling. This commit addresses several issues raised in #121: * Enhanced the README for better understanding and improved formatting. * Corrected the submodule path and updated the resource folder name. * Updated the ArchiSteamFarm subproject to the latest commit. (Note: This submodule was previously reported as 404, this commit should resolve this.) * Fixed the namespace spelling from 'ASFExtentions' to 'ASFExtensions'. * Added VSCode settings to ignore pull request branches from main. * Improved error handling in CollectGamesOnClock method for scheduled free games. Conflicts in .gitmodules and ArchiSteamFarm were resolved. --- The pull request primarily focuses on: * **Namespace Corrections:** Changing `ASFExtentions` to `ASFExtensions` throughout the codebase. This appears to be a correction of a consistent typo. * **Code Style and Formatting:** Minor formatting adjustments in various files, including whitespace and XML formatting. * **Documentation Improvements:** Spelling and grammar corrections in comments and the README.md file, along with clarifications and updates to the documentation. * **Resource Folder Renaming:** Renaming the `Resouces` folder to `Resources` in the project file and code. This seems to be another typo correction. * **VSCode Settings:** Adding a `.vscode/settings.json` file for development environment configuration, specifically to ignore pull requests from the "main" branch in the GitHub Pull Requests extension. * **Minor Bug Fix/Improvement in `ASFFreeGamesPlugin.cs`:** * Correcting the bot instance passed to `OnBotCommand` in the scheduled task from `null!` to `reorderedBots[0]`. * Adding a try-catch block to handle potential exceptions during scheduled free game collection. * **Redlib Instance List Update:** Adding a new `Resources/redlib_instances.json` file, which seems to be an updated list of Redlib instances. **File-by-File Analysis:** * **`.gitignore`**: Spelling correction in comments ("checkin" to "check in"). **Safe and intended.** * **`.vscode/settings.json`**: VSCode specific settings, ignoring "main" branch PRs. **Safe and development-related.** * **`ASFFreeGames.Tests/GameIdentifierParserTests.cs` & `ASFFreeGames.Tests/GameIdentifierTests.cs`**: Namespace correction (`ASFExtentions` to `ASFExtensions`). **Safe and likely a typo fix.** * **`ASFFreeGames.sln`**: Minor formatting change (removing a blank line). **Safe and cosmetic.** * **`ASFFreeGames/ASFExtentions/Bot`, `ASFFreeGames/ASFExtentions/Games`, `ASFFreeGames/AppLists`, `ASFFreeGames/Commands`, `ASFFreeGames/Configurations`, `ASFFreeGames/ContextRegistry`, `ASFFreeGames/Redlib`, `ASFFreeGames/Utils`**: Consistent namespace corrections (`ASFExtentions` to `ASFExtensions`). **Safe and likely typo fixes throughout the project.** * **`ASFFreeGames/ASFFreeGames.csproj`**: Folder name correction (`Resouces` to `Resources`). **Safe and likely a typo fix. Ensure the folder is renamed accordingly in the filesystem if merging.** * **`ASFFreeGames/ASFFreeGames.csproj.DotSettings`**: Minor XML formatting change. **Safe and cosmetic.** * **`ASFFreeGames/ASFFreeGamesPlugin.cs`**: * Namespace corrections. * Corrected bot instance in scheduled task (`null!` to `reorderedBots[0]`). **Bug fix.** * Added try-catch for scheduled task. **Improvement - error handling.** * Removed unnecessary `#pragma warning disable/restore` which is good, likely the code is now correct async. * **`ASFFreeGames/Redlib/Instances/RedlibInstanceList.cs`**: * Resource path correction (`Resouces` to `Resources`). * Code style improvements. * Constructor parameter change (field assignment). **Refactoring, safe.** * Using `new List<Uri>()` instead of `[]` when instances are null. **Minor improvement in code clarity.** * **`ASFFreeGames/Resources/redlib_instances.json`**: New file containing a list of Redlib instances. **Likely an intended update to the default instance list. Review the URLs to ensure they are trustworthy.** * **`ASFFreeGames/Utils/LoggerFilter.cs` & `ASFFreeGames/Utils/RandomUtils.cs`**: Code style, formatting, documentation improvements, and minor variable name changes. **Safe and improves code quality.** * **`README.md`**: Documentation improvements, spelling/grammar fixes, command clarifications, proxy setup, and FAQ updates. **Safe and beneficial for users.**
The `bot` parameter in `OnBotCommand` is now nullable (`Bot? bot`), allowing the function to be called without specifying a bot. This is necessary for scenarios like scheduled free game collection where a specific bot context might not be relevant. The call to `OnBotCommand` in `CollectScheduledFreeGames` has been updated to pass `null` for the bot parameter.
…age ownership checks. This includes: - Direct access and reflection fallback for robustness. - Caching with hot-reload awareness for performance. - Integration into BotContext for improved ownership checks. - Cache clearing on bot disconnect in ASFFreeGamesPlugin. Improves reliability
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.
Hello @maxisoft, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request focuses on refactoring, enhancements, and bug fixes within the ASF Free Games plugin. Key changes include correcting a namespace misspelling, upgrading to .NET 9, introducing a BotPackageChecker
for improved bot package ownership checks, and several plugin improvements. The ArchiSteamFarm submodule has also been updated. Code style improvements and minor refactorings are present throughout the project.
Highlights
- Namespace Correction: The namespace
ASFExtentions
has been corrected toASFExtensions
throughout the project, improving code consistency. - .NET 9 Upgrade: The project has been migrated to .NET 9.0, and NuGet dependencies have been updated to their latest versions.
- Bot Package Checker: A new
BotPackageChecker
utility has been introduced for more robust and performant checks of bot package ownership within ASF, including resilience mechanisms and cache management. - Nullable Bot in
OnBotCommand
: TheOnBotCommand
method now accepts a nullableBot?
parameter, increasing flexibility. - Redlib Instance List Update: The
redlib_instances.json
file inResources/
has been updated with a new list of Redlib instances.
Changelog
Click here to see the changelog
- .github/workflows/ci.yml
- Updated DOTNET_SDK_VERSION and DOTNET_FRAMEWORK to 9.0.x and net9.0 respectively (lines 8-9).
- .github/workflows/publish.yml
- Updated DOTNET_SDK_VERSION and NET_CORE_VERSION to 9.0.x and net9.0 respectively (lines 9-10).
- .github/workflows/test_integration.yml
- Updated DOTNET_SDK_VERSION to 9.0.x (line 16).
- .gitignore
- Corrected a typo in a comment from 'checkin' to 'check in' (lines 292, 298).
- ASFFreeGames.Tests/ASFFreeGames.Tests.csproj
- Updated TargetFramework to net9.0 (line 8).
- ASFFreeGames.Tests/GameIdentifierParserTests.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(lines 2-4).
- Corrected namespace from
- ASFFreeGames.Tests/GameIdentifierTests.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(lines 2-4).
- Corrected namespace from
- ASFFreeGames.sln
- Minor formatting changes (lines 1-2, 12-40).
- ASFFreeGames.sln.DotSettings
- Added a new setting migration for CSharpFileLayoutPatternRemoveIsAttributeUpgrade (line 763).
- ASFFreeGames/ASFExtentions/Bot/BotContext.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 9, 12). - Added using statements for
System.Globalization
,System.Reflection
, andMaxisoft.ASF.Utils.Workarounds
(lines 3, 5, 10). - Added
using static ArchiSteamFarm.Localization.Strings;
(line 15). - Replaced direct package ownership check with
BotPackageChecker.BotOwnsPackage
(line 77, 81). - Minor formatting changes (lines 117-123).
- Corrected namespace from
- ASFFreeGames/ASFExtentions/Bot/BotEqualityComparer.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 4).
- Corrected namespace from
- ASFFreeGames/ASFExtentions/Bot/BotName.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 4).
- Corrected namespace from
- ASFFreeGames/ASFExtentions/Games/GameIdentifier.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 10).
- Corrected namespace from
- ASFFreeGames/ASFExtentions/Games/GameIdentifierParser.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 5).
- Corrected namespace from
- ASFFreeGames/ASFExtentions/Games/GameIdentifierType.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 1).
- Corrected namespace from
- ASFFreeGames/ASFFreeGames.csproj
- Updated TargetFramework to net9.0 (line 7).
- Added
<Content Include="..\Directory.Packages.props">
(line 74). - Corrected folder name from
Resouces
toResources
(line 77, 81). - Minor formatting changes (lines 71-87).
- ASFFreeGames/ASFFreeGames.csproj.DotSettings
- Minor formatting changes (lines 1-4).
- ASFFreeGames/ASFFreeGamesPlugin.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 11). - Added using statement for
Maxisoft.ASF.Utils.Workarounds
(line 19). - Modified
OnBotCommand
to accept a nullableBot?
parameter (line 71). - Added try-catch block to
CollectGamesOnClock
for error handling (lines 146-151). - Removed
#pragma warning disable/restore
inCollectGamesOnClock
(lines 144-146). - Added
BotPackageChecker.RemoveBotCache(bot);
inRemoveBot
(line 194).
- Corrected namespace from
- ASFFreeGames/AppLists/CompletedAppList.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 10).
- Corrected namespace from
- ASFFreeGames/AppLists/RecentGameMapping.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 7).
- Corrected namespace from
- ASFFreeGames/Commands/FreeGamesCommand.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 11-12).
- Corrected namespace from
- ASFFreeGames/Configurations/ASFFreeGamesOptions.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 7).
- Corrected namespace from
- ASFFreeGames/ContextRegistry.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 6).
- Corrected namespace from
- ASFFreeGames/HttpClientSimple/SimpleHttpClient.cs
- Used
ConfigureAwait(false)
when awaitingStream.DisposeAsync()
(line 177).
- Used
- ASFFreeGames/Reddit/RedditHelper.cs
- Removed unused
using Maxisoft.Utils.Collections.Dictionaries;
(line 14). - Replaced
OrderedDictionary
withMaxisoft.Utils.Collections.Dictionaries.OrderedDictionary
(line 35).
- Removed unused
- ASFFreeGames/Redlib/GameIdentifiersEqualityComparer.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 3).
- Corrected namespace from
- ASFFreeGames/Redlib/Html/RedditHtmlParser.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 5). - Replaced
OrderedDictionary
withMaxisoft.Utils.Collections.Dictionaries.OrderedDictionary
(line 15).
- Corrected namespace from
- ASFFreeGames/Redlib/Instances/RedlibInstanceList.cs
- Corrected folder name from
Resouces
toResources
(line 113). - Refactored the class to remove the constructor parameter and use a property instead (lines 19, 31).
- Added null check for
options
in the constructor (line 32). - Used
new List<Uri>()
instead of[]
(line 97).
- Corrected folder name from
- ASFFreeGames/Redlib/RedlibGameEntry.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 3).
- Corrected namespace from
- ASFFreeGames/Resouces/redlib_instances.json
- Removed the file.
- ASFFreeGames/Resources/redlib_instances.json
- Added the file with updated content.
- ASFFreeGames/Utils/LoggerFilter.cs
- Corrected namespace from
ASFExtentions
toASFExtensions
(line 10).
- Corrected namespace from
- ASFFreeGames/Utils/RandomUtils.cs
- Added summary for the class (lines 13-15).
- Added summary for the method (lines 27-30).
- Added summary for the method (lines 61-64).
- Minor formatting changes (lines 10-103).
- ASFFreeGames/Utils/Workarounds/BotPackageChecker.cs
- Added new file with implementation for resilient package ownership checks.
- ArchiSteamFarm
- Updated submodule commit (line 1).
- Directory.Build.props
- Updated Version to 1.9.0.0 and TargetFramework to net9.0 (lines 6-7).
- Directory.Packages.props
- Updated package versions for NLog, xunit, xunit.runner.visualstudio, coverlet.collector, and Microsoft.NET.Test.Sdk (lines 4-8).
- Added package version for ConfigureAwaitChecker.Analyzer (line 9).
- README.md
- Added a newline after the title (line 2).
- Minor formatting changes (lines 12-87).
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
In realms of code, where bits align,
A namespace fixed, a version's climb.
With checkers new and bots made keen,
A plugin's quest, a vibrant scene.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces several refactoring efforts, enhancements, and bug fixes to the ASF Free Games plugin. The changes include a namespace correction, an upgrade to .NET 9, the introduction of a new Bot Package Checker, and various other plugin improvements. Overall, the changes look good and improve the plugin's functionality and maintainability.
Summary of Findings
- Namespace Correction: The namespace correction from
ASFExtentions
toASFExtensions
improves code consistency and maintainability. - .NET 9 Upgrade: The migration to .NET 9.0 and updates to NuGet dependencies ensures compatibility with the latest .NET runtime and incorporates recent security updates and bug fixes.
- Bot Package Checker: The introduction of the
BotPackageChecker
utility provides more robust and performant checks of bot package ownership within ASF. - Resource Folder Rename: The correction of the folder name from
Resouces
toResources
resolves a typo. - Redlib Instance List Update: The
redlib_instances.json
file has been updated with a new list of Redlib instances.
Merge Readiness
The pull request is almost ready for merging. However, there are a few issues that need to be addressed before merging. Specifically, the constructor parameter in RedlibInstanceList.cs
should have a null check to prevent potential NullReferenceException
. Additionally, the removal of Resouces/redlib_instances.json
and addition of Resources/redlib_instances.json
should be reviewed for trustworthiness. I am unable to approve this pull request, and users should have others review and approve this code before merging.
"instances": [ | ||
{ | ||
"url": "https://safereddit.com", | ||
"country": "US", | ||
"version": "v0.35.1", | ||
"description": "SFW only" | ||
}, | ||
{ | ||
"url": "https://l.opnxng.com", | ||
"country": "SG", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://libreddit.projectsegfau.lt", | ||
"country": "LU", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://redlib.catsarch.com", | ||
"country": "US", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://redlib.perennialte.ch", | ||
"country": "AU", | ||
"version": "v0.35.1", | ||
"cloudflare": true | ||
}, | ||
{ | ||
"url": "https://rl.bloat.cat", | ||
"country": "RO", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://red.ngn.tf", | ||
"country": "TR", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://r.darrennathanael.com", | ||
"country": "ID", | ||
"version": "v0.35.1", | ||
"description": "contact noc at darrennathanael.com" | ||
}, | ||
{ | ||
"url": "https://redlib.kittywi.re", | ||
"country": "FR", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://redlib.privacyredirect.com", | ||
"country": "FI", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://reddit.nerdvpn.de", | ||
"country": "UA", | ||
"version": "v0.35.1", | ||
"description": "SFW only" | ||
}, | ||
{ | ||
"url": "https://redlib.baczek.me", | ||
"country": "PL", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://redlib.nadeko.net", | ||
"country": "CL", | ||
"version": "v0.35.1", | ||
"description": "I don't like reddit." | ||
}, | ||
{ | ||
"url": "https://redlib.private.coffee", | ||
"country": "AT", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://red.arancia.click", | ||
"country": "US", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"url": "https://redlib.reallyaweso.me", | ||
"country": "DE", | ||
"version": "v0.35.1", | ||
"description": "A reallyaweso.me redlib instance!" | ||
}, | ||
{ | ||
"url": "https://redlib.privacy.com.de", | ||
"country": "DE", | ||
"version": "v0.35.1" | ||
}, | ||
{ | ||
"onion": "http://red.lpoaj7z2zkajuhgnlltpeqh3zyq7wk2iyeggqaduhgxhyajtdt2j7wad.onion", | ||
"country": "DE", | ||
"version": "v0.35.1", | ||
"description": "Onion of red.artemislena.eu" | ||
} | ||
] | ||
} |
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.
Summary
This pull request introduces several refactoring efforts, enhancements, and bug fixes to the ASF Free Games plugin. It includes a namespace correction, an upgrade to .NET 9, the introduction of a new Bot Package Checker for improved performance and resilience, and various other plugin improvements.
It contains work from @peter9811 with pull req #121
Key Changes
Namespace Correction: Corrects the consistently misspelled namespace
ASFExtentions
toASFExtensions
throughout the entire project. This improves code consistency and maintainability..NET 9 Upgrade and Dependency Updates: Migrates the project to .NET 9.0 and updates core NuGet dependencies to their latest versions. This ensures compatibility with the latest .NET runtime, benefits from performance improvements, and incorporates recent security updates and bug fixes from dependency libraries.
Bot Package Checker Introduction: Introduces a new
BotPackageChecker
utility for more robust and performant checks of bot package ownership within ASF. This includes:ASFFreeGamesPlugin
to maintain data consistency.Allow Nullable Bot in
OnBotCommand
: Modifies theOnBotCommand
method to accept a nullableBot?
parameter. This allows the function to be invoked in contexts where a specific bot instance is not relevant, such as scheduled tasks, improving flexibility.Plugin Improvements and Bug Fixes
Scheduled Task Enhancements:
CollectGamesOnClock
method for scheduled free game collection by adding a try-catch block.OnBotCommand
in scheduled tasks to ensure proper context.Resource Folder Rename: Corrects the folder name from
Resouces
toResources
in the project file and codebase, resolving a typo.Redlib Instance List Update: Updates the
redlib_instances.json
file inResources/
with an updated list of Redlib instances. Please review the added instances for trustworthiness.ArchiSteamFarm Submodule Updates: Updates the ArchiSteamFarm submodule to the latest commit and corrects the submodule path in
.gitmodules
.Code Style and Minor Refactorings
RedlibInstanceList.cs
for improved code clarity.#pragma warning disable/restore
inASFFreeGamesPlugin.cs
.