Fix pattern bugs caught by new Roslyn diagnostic - #6012
Merged
Conversation
Add parentheses around negated disjunctive patterns so newer compilers do not report CS9336. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7b2ca30d-742d-402c-8ba5-afec8b6d69a1
hoyosjs
approved these changes
Sep 8, 2026
hoyosjs
enabled auto-merge (squash)
September 8, 2026 19:16
hoyosjs
disabled auto-merge
September 8, 2026 19:16
hoyosjs
enabled auto-merge (squash)
September 8, 2026 19:16
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The code changes are small, targeted, and correct; only a minor PR-description count mismatch was noted.
Pull request overview
This PR fixes incorrect C# negated-pattern logic exposed by a newer Roslyn diagnostic by adding parentheses so not applies to the full disjunctive pattern set, restoring the intended GC segment/generation filtering behavior in SOS extension commands.
Changes:
- Fix segment counting to exclude frozen/pinned segments by correctly negating the full
orpattern. - Fix ephemeral reference scanning to include Generation 1 objects by correctly negating the full
orpattern. - Fix fragmentation reporting to exclude large/pinned/frozen segments by correctly negating the full
orpattern.
File summaries
| File | Description |
|---|---|
| src/Microsoft.Diagnostics.ExtensionCommands/FindEphemeralReferencesToLOHCommand.cs | Corrects negated or patterns affecting segment counting and Gen0/Gen1 filtering. |
| src/Microsoft.Diagnostics.ExtensionCommands/DumpHeapService.cs | Corrects negated or pattern so pinned/frozen/large segments don’t contribute to fragmentation reporting. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A newer Roslyn diagnostic exposed three existing negated-pattern bugs:
Parenthesizing each disjunctive pattern makes
notapply to the complete set of excluded values. This fixes the behavior and resolves the four CS9336 diagnostics.Testing
eng\build.ps1 -restore -build -ci -configuration Release -architecture x64 -privatebuildNote
This pull request description was generated with GitHub Copilot.