Skip to content

Use Random.Shared if available. - #21149

Merged
enisn merged 7 commits into
devfrom
RandomHelper
Sep 17, 2026
Merged

enisn merged 7 commits into
devfrom
RandomHelper

Conversation

@maliming

Copy link
Copy Markdown
Member

No description provided.

@MarkCiliaVincenti

Copy link
Copy Markdown
Contributor

Ideally don't lock on the random instance. Check the logic in ThreadSafeRandomizer

@maliming maliming modified the milestones: 9.1-preview, 9.2-preview Dec 31, 2024
@maliming maliming modified the milestones: 9.2-preview, 9.3-preview Mar 10, 2025
@maliming
maliming requested a review from EngincanV March 10, 2025 01:03
@maliming
maliming marked this pull request as draft March 10, 2025 01:04
@maliming maliming modified the milestones: 9.3-preview, 10.0-preview Apr 22, 2025
@maliming maliming modified the milestones: 10.0-preview, backlog Jul 15, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A test asserts that one random shuffle must change ordering, which can fail nondeterministically.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates RandomHelper to use Random.Shared and Shuffle on modern target frameworks while retaining compatibility with .NET Standard.

Changes:

  • Uses thread-safe shared randomness on supported frameworks.
  • Replaces list randomization with Fisher–Yates or Shuffle.
  • Adds comprehensive RandomHelper tests.
File summaries
File Description
framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs Updates random number and list-shuffling implementations.
framework/test/Volo.Abp.Core.Tests/Volo/Abp/RandomHelper_Tests.cs Adds coverage for random helper behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread framework/test/Volo.Abp.Core.Tests/Volo/Abp/RandomHelper_Tests.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation preserves target compatibility and the added tests cover the changed behavior.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@maliming
maliming marked this pull request as ready for review September 17, 2026 02:08
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.47458% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.97%. Comparing base (9ca5cb9) to head (0484ce1).
⚠️ Report is 3 commits behind head on dev.

Files with missing lines Patch % Lines
...Volo.Abp.Core.Tests/Volo/Abp/RandomHelper_Tests.cs 0.00% 53 Missing ⚠️
...amework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #21149      +/-   ##
==========================================
- Coverage   49.98%   49.97%   -0.02%     
==========================================
  Files        3837     3838       +1     
  Lines      134467   134507      +40     
  Branches    10210    10211       +1     
==========================================
+ Hits        67210    67214       +4     
- Misses      65244    65279      +35     
- Partials     2013     2014       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maliming
maliming requested review from enisn and removed request for EngincanV September 17, 2026 02:50
@enisn
enisn merged commit 10e0315 into dev Sep 17, 2026
4 of 6 checks passed
@enisn
enisn deleted the RandomHelper branch September 17, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants