From 9532bca0140d1fd1cf4f4bc8ed0bc3032508874b Mon Sep 17 00:00:00 2001 From: Max Charlamb Date: Tue, 8 Sep 2026 15:06:26 -0400 Subject: [PATCH] Fix redundant pattern warnings 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 --- .../DumpHeapService.cs | 2 +- .../FindEphemeralReferencesToLOHCommand.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/DumpHeapService.cs b/src/Microsoft.Diagnostics.ExtensionCommands/DumpHeapService.cs index c7250e8845..305719d092 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/DumpHeapService.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/DumpHeapService.cs @@ -111,7 +111,7 @@ public bool PrintHeap(IEnumerable objects, DisplayKind displayKind, b // Also, don't report fragmentation for Large/Pinned/Frozen segments. This check // is a little slow, so we do this last. ClrSegment seg = obj.Type.Heap.GetSegmentByAddress(obj); - if (seg is not null && seg.Kind is not GCSegmentKind.Large or GCSegmentKind.Pinned or GCSegmentKind.Frozen) + if (seg is not null && seg.Kind is not (GCSegmentKind.Large or GCSegmentKind.Pinned or GCSegmentKind.Frozen)) { fragmentation ??= new(); fragmentation.Add((lastFreeObject, obj)); diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/FindEphemeralReferencesToLOHCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/FindEphemeralReferencesToLOHCommand.cs index 221c06f502..0dd4ca6bbb 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/FindEphemeralReferencesToLOHCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/FindEphemeralReferencesToLOHCommand.cs @@ -19,7 +19,7 @@ public class FindEphemeralReferencesToLOHCommand : ClrRuntimeCommandBase public override void Invoke() { - int segments = Runtime.Heap.Segments.Count(seg => seg.Kind is not GCSegmentKind.Frozen or GCSegmentKind.Pinned); + int segments = Runtime.Heap.Segments.Count(seg => seg.Kind is not (GCSegmentKind.Frozen or GCSegmentKind.Pinned)); if (segments > 50) { string gcSegKind = Runtime.Heap.SubHeaps[0].HasRegions ? "regions" : "segments"; @@ -121,7 +121,7 @@ public override void Invoke() // This handles both regions and segments Generation gen = seg.GetGeneration(obj); - if (gen is not Generation.Generation0 or Generation.Generation1) + if (gen is not (Generation.Generation0 or Generation.Generation1)) { continue; }