Skip to content

Conversation

logiclrd
Copy link

@logiclrd logiclrd commented Oct 1, 2025

This PR updates places that use Interlocked.Exchange and/or Interlocked.CompareExchange with int values that are really booleans because, historically, the type bool wasn't supported to use the new overloads in .NET 9.0+ that do support bool. As the code has targets older than .NET 9.0, these are all used conditionally, with fallback to int on older platforms. Constants named TRUE and FALSE are used, tracking the actual type of the backing field, so that the actual code doesn't need separate implementations.

Closes: #3686

cursor[bot]

This comment was marked as outdated.

@logiclrd logiclrd force-pushed the interlocked-booleans branch from e79b72c to 34bec13 Compare October 1, 2025 23:39
@logiclrd
Copy link
Author

logiclrd commented Oct 1, 2025

If you accept this, please consider adding the hacktoberfest-accepted label to the PR (or the hacktoberfest topic to the repository as a whole). 😸

Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.48%. Comparing base (c4fe48f) to head (34bec13).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/Sentry.Profiling/SampleProfilerSession.cs 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4585      +/-   ##
==========================================
- Coverage   73.48%   73.48%   -0.01%     
==========================================
  Files         482      482              
  Lines       17679    17680       +1     
  Branches     3495     3493       -2     
==========================================
  Hits        12992    12992              
- Misses       3797     3799       +2     
+ Partials      890      889       -1     

☔ View full report in Codecov by Sentry.
📢 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.

…d of `bool` because of the lack of support in Interlocked.Exchange/CompareExchange to use the now-supported type, but with backwards-compatible support for .NET pre-9.0.
@logiclrd logiclrd force-pushed the interlocked-booleans branch from e409bbc to f0d95a3 Compare October 2, 2025 18:23
@logiclrd
Copy link
Author

logiclrd commented Oct 2, 2025

Rebased to resolve merge conflict in CHANGELOG.md.

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.

Use bools and enums with Interlocked.CompareExchange
1 participant