Skip to content
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

Comprehensive Update and Fixes for ASFFreeGames Plugin v1.5.1 #65

Merged
merged 16 commits into from
May 5, 2024
Merged

Conversation

maxisoft
Copy link
Owner

@maxisoft maxisoft commented May 5, 2024

This pull request introduces a series of enhancements and fixes that bring the ASFFreeGames plugin up to speed with the latest ASF version, improving stability and compatibility.

Changes:

  • Upgrade: Updated the plugin to be compatible with the latest ASF version, addressing previous incompatibility issues.
  • Configuration Saving: Fixed an issue with ASFFreeGamesOptions to ensure the correct file size when saving configurations.
  • Version Bump: Bumped the plugin version to 1.5.1.
  • Dependency Management: Added the missing Microsoft.NET.Test.Sdk version to package versions to resolve build errors.
  • Compilation: Refactored code to ensure successful compilation in publish mode.
  • CI/CD: Updated GitHub Actions workflows to use .NET 8.0 SDK, enhancing the CI build process.
  • Logging: Removed debug logging from RedditHelper to clean up the output.
  • Error Handling: Refined error handling and retry logic in RedditHelper for more robust operation.
  • Optimization: Refactored RandomUtils for better performance using Math and MemoryMarshal.Cast.
  • Thread-Safety: Enhanced GaussianRandom class to ensure thread safety and compliance with ASF's GetNon... method.
  • Alignment: Modified GaussianRandom class to align with the Wikipedia C++ implementation.
  • Edge Case Handling: Improved GaussianRandom class to handle edge cases more effectively.

Fixes:

This update addresses several critical issues reported by users:

This update ensures that users will have a smoother and more reliable experience with the ASFFreeGames plugin.

This commit modifies the GaussianRandom class to use Math instead of MathF and MemoryMarshal.Cast instead of BitConverter. This allows the plugin to be compatible with trimmed ASF binaries that do not include those methods. This also improves the performance by reducing the number of calls to Fill(bytes) from 2 to 1. This fixes the issue #46 (#46) that was reported.
…ZeroBytes specification

This commit modifies the GaussianRandom class to use Interlocked.CompareExchange instead of a bool field to ensure thread-safety when accessing the stored value for the next Gaussian number. This commit also changes the GetNonZeroBytes method to use a Span<byte> parameter and a stack-allocated buffer to ensure that no zero bytes are generated, as required by the RandomNumberGenerator base class. Thus, the compliance and performance of the GaussianRandom class are improved.
…Box-Muller formula

This commit modifies the GaussianRandom class to use the same logic as the C++ implementation of the Box-Muller formula that is shown on Wikipedia. This involves using a do-while loop to generate a non-zero uniform random number u1, and checking if it is greater than the smallest positive double value (double.Epsilon). This ensures that the logarithm and square root operations do not produce NaN or infinity values. This improves the robustness and accuracy of the GaussianRandom class.
This commit improves the GaussianRandom class to handle some edge cases. It does the following changes:

- It uses 2 * sizeof(long) instead of 16 as the size of the byte span to avoid hard-coding the value and make it more readable.
- It uses -2.0 instead of -2.0f as the coefficient of the logarithm in the Box-Muller formula to use double precision instead of float precision.
- It adds a do-while loop to check if the generated random number is finite and not NaN or infinity, and repeats the generation if it is not. This prevents the NextGaussian method from returning invalid values.
- Upgraded target framework to .NET 8.0 to match ASF requirements.
- Updated ASF submodule to the latest stable release.
- Transitioned from Newtonsoft.Json to System.Text.Json for improved compatibility with ASF.
- Refined GaussianRandom implementation to function with the latest trimmed ASF binary.
- Enhanced RedditHelper to utilize System.Text.Json, improving JSON handling.
- Modified GaussianRandom to utilize a more reliable RNG method compatible with ASF's trimmed version.
- Various improvements and code cleanups in line with ASF's updated codebase.
…uration

- Updated `Save` method to address potential issue with file size after writing JSON data.
- Implemented option to set file size explicitly after writing using `fs.SetLength(fs.Position)`.

This change prevents potential corruption in the saved configuration file by ensuring the correct size reflects the actual JSON content.
- Included the version number for Microsoft.NET.Test.Sdk in Directory.Packages.props to align with project dependencies and resolve NU1010 build error.
- Changed the type of CollectIntervalManager from an interface to a concrete class in ASFFreeGamesPlugin.
- Suppressed specific warnings in GetIPCommand to prevent compilation issues related to asynchronous calls and code analysis rules.
- Aligned DOTNET_SDK_VERSION with the upgraded project framework across CI, publish, and test integration workflows.
- Ensured consistency in .NET versioning to facilitate correct environment setup for build and test processes.
- Deleted unnecessary debug log statements from the GetGames method.
- Simplified exception handling by removing redundant try-catch blocks.
- Implemented retry logic with exponential backoff for fetching payload.
- Streamlined JsonNode parsing and error handling for more robust operation.
@maxisoft maxisoft self-assigned this May 5, 2024
@maxisoft maxisoft changed the title Comprehensive Update and Fixes for ASFFreeGames Plugin v1.5.x Comprehensive Update and Fixes for ASFFreeGames Plugin v1.5.1 May 5, 2024
@maxisoft maxisoft merged commit 928784c into main May 5, 2024
20 checks passed
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.

1 participant