Skip to content

Fix inverted condition check for LinkedListItems in NatVis - #1559

Merged
Andrew Wang (WardenGnaw) merged 1 commit into
mainfrom
fix/natvis-linkedlist-condition-check
May 19, 2026
Merged

Fix inverted condition check for LinkedListItems in NatVis#1559
Andrew Wang (WardenGnaw) merged 1 commit into
mainfrom
fix/natvis-linkedlist-condition-check

Conversation

@WardenGnaw

Copy link
Copy Markdown
Member

The condition guard was using IsNullOrWhiteSpace instead of !IsNullOrWhiteSpace, which meant LinkedListItems with a Condition attribute were never filtered, items were always shown regardless of the condition value.

Added an integration test (TestLinkedListItemsCondition) that creates two ConditionalLinkedList objects, one with isActive=true and one with isActive=false, and verifies that the NatVis LinkedListItemsCondition attribute is respected.

CopilotAI left a comment

Copy link
Copy Markdown

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 fixes an inverted condition check in the NatVis LinkedListItems handler in Natvis.cs. Previously, String.IsNullOrWhiteSpace(item.Condition) caused the condition evaluation to be skipped whenever a Condition attribute was present, so LinkedListItems were always shown regardless of the condition. The fix inverts the check so the condition is evaluated only when it is non-empty, matching the typical pattern used elsewhere. A new integration test and supporting debuggee artifacts (C++ class + Natvis type) are added to validate both true/false Condition cases.

Changes:

  • Invert the IsNullOrWhiteSpace guard so LinkedListItemsCondition is actually evaluated.
  • Add ConditionalLinkedList C++ debuggee class and a corresponding <Type> definition in Simple.natvis using LinkedListItems Condition="isActive".
  • Add TestLinkedListItemsCondition integration test and update SimpleClassAssignmentLine/ReturnSourceLine constants to reflect new line numbers in main.cpp.
Show a summary per file
FileDescription
src/MIDebugEngine/Natvis.Impl/Natvis.csFixes inverted IsNullOrWhiteSpace check so LinkedListItemsCondition is evaluated when present.
test/CppTests/Tests/NatvisTests.csUpdates line-number constants and adds TestLinkedListItemsCondition integration test.
test/CppTests/debuggees/natvis/src/visualizer_files/Simple.natvisAdds ConditionalLinkedList visualizer with LinkedListItems Condition="isActive".
test/CppTests/debuggees/natvis/src/main.cppInstantiates active/inactive ConditionalLinkedList instances before the return for inspection.
test/CppTests/debuggees/natvis/src/ConditionalLinkedList.hNew C++ singly-linked list class used by the new test.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 0

The condition guard was using IsNullOrWhiteSpace instead of
!IsNullOrWhiteSpace, which meant LinkedListItems with a Condition
attribute were never filtered — items were always shown regardless
of the condition value.
Added an integration test (TestLinkedListItemsCondition) that
creates two ConditionalLinkedList objects — one with isActive=true
and one with isActive=false — and verifies that the natvis
LinkedListItems Condition attribute is respected.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@WardenGnaw
Andrew Wang (WardenGnaw)force-pushed the fix/natvis-linkedlist-condition-check branch from 24f2a96 to ddc9fceCompareMay 19, 2026 17:04
@WardenGnaw
Andrew Wang (WardenGnaw) merged commit ef103a0 into mainMay 19, 2026
6 checks passed
@WardenGnaw
Andrew Wang (WardenGnaw) deleted the fix/natvis-linkedlist-condition-check branch May 19, 2026 23:48
Sign up for freeto 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

@WardenGnaw@gregg-miskelly