Skip to content

Fix CS8762 suppression in ConcurrentBag#121122

Merged
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:fixsuppression
Oct 27, 2025
Merged

Fix CS8762 suppression in ConcurrentBag#121122
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:fixsuppression

Conversation

@stephentoub
Copy link
Member

Closes #36132

Copilot AI review requested due to automatic review settings October 27, 2025 16:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes an unnecessary compiler warning suppression (CS8762) in the ConcurrentBag<T> class by restructuring the conditional logic. The refactoring changes from a separate boolean assignment followed by an if-check to a combined if-statement with the same condition, allowing the compiler to properly track nullability constraints without needing a pragma suppression.

Key Changes:

  • Refactored the TrySteal method to eliminate the intermediate gotItem boolean variable
  • Combined the conditional expression directly into the if-statement to satisfy nullability analysis

@stephentoub
Copy link
Member Author

/ba-g build timeout

@stephentoub stephentoub merged commit 2ed2e46 into dotnet:main Oct 27, 2025
84 of 87 checks passed
@stephentoub stephentoub deleted the fixsuppression branch October 27, 2025 21:31
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Placeholder for nullability annotation workarounds

2 participants