Skip to content

Fix pattern bugs caught by new Roslyn diagnostic - #6012

Merged
hoyosjs merged 1 commit into
mainfrom
dev/max-charlamb/fix-redundant-patterns
Sep 8, 2026
Merged

Fix pattern bugs caught by new Roslyn diagnostic#6012
hoyosjs merged 1 commit into
mainfrom
dev/max-charlamb/fix-redundant-patterns

Conversation

@max-charlamb

@max-charlamb max-charlamb commented Sep 8, 2026

Copy link
Copy Markdown
Member

Summary

A newer Roslyn diagnostic exposed three existing negated-pattern bugs:

  • Pinned segments were incorrectly included in the segment count.
  • Generation 1 objects were incorrectly skipped when finding ephemeral references.
  • Pinned and frozen segments incorrectly contributed to fragmentation reporting.

Parenthesizing each disjunctive pattern makes not apply 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 -privatebuild

Note

This pull request description was generated with GitHub Copilot.

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
Copilot AI lite review requested due to automatic review settings September 8, 2026 19:10
@max-charlamb
max-charlamb requested a review from a team as a code owner September 8, 2026 19:10
@max-charlamb max-charlamb changed the title Fix redundant negated patterns Fix pattern bugs caught by new Roslyn diagnostic Sep 8, 2026
@hoyosjs
hoyosjs enabled auto-merge (squash) September 8, 2026 19:16
@hoyosjs
hoyosjs disabled auto-merge September 8, 2026 19:16
@hoyosjs
hoyosjs enabled auto-merge (squash) September 8, 2026 19:16

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 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 or pattern.
  • Fix ephemeral reference scanning to include Generation 1 objects by correctly negating the full or pattern.
  • Fix fragmentation reporting to exclude large/pinned/frozen segments by correctly negating the full or pattern.
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.

@hoyosjs
hoyosjs merged commit fa814a9 into main Sep 8, 2026
26 of 27 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.

3 participants