Skip to content

Fix inverted condition check for LinkedListItems in NatVis#1559

Open
WardenGnaw wants to merge 1 commit into
mainfrom
fix/natvis-linkedlist-condition-check
Open

Fix inverted condition check for LinkedListItems in NatVis#1559
WardenGnaw wants to merge 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 LinkedListItems Condition attribute is respected.

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>
Copy link
Copy Markdown

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 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 LinkedListItems Condition 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
File Description
src/MIDebugEngine/Natvis.Impl/Natvis.cs Fixes inverted IsNullOrWhiteSpace check so LinkedListItems Condition is evaluated when present.
test/CppTests/Tests/NatvisTests.cs Updates line-number constants and adds TestLinkedListItemsCondition integration test.
test/CppTests/debuggees/natvis/src/visualizer_files/Simple.natvis Adds ConditionalLinkedList visualizer with LinkedListItems Condition="isActive".
test/CppTests/debuggees/natvis/src/main.cpp Instantiates active/inactive ConditionalLinkedList instances before the return for inspection.
test/CppTests/debuggees/natvis/src/ConditionalLinkedList.h New 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

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.

2 participants