Uh oh!
There was an error while loading. Please reload this page.
Fix inverted condition check for LinkedListItems in NatVis - #1559
Conversation
There was a problem hiding this comment.
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
IsNullOrWhiteSpaceguard soLinkedListItemsConditionis actually evaluated. - Add
ConditionalLinkedListC++ debuggee class and a corresponding<Type>definition inSimple.natvisusingLinkedListItems Condition="isActive". - Add
TestLinkedListItemsConditionintegration test and updateSimpleClassAssignmentLine/ReturnSourceLineconstants to reflect new line numbers inmain.cpp.
Show a summary per file
| File | Description |
|---|---|
| src/MIDebugEngine/Natvis.Impl/Natvis.cs | Fixes inverted IsNullOrWhiteSpace check so LinkedListItemsCondition 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
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>
24f2a96 to
ddc9fceCompareUh oh!
There was an error while loading. Please reload this page.
The condition guard was using
IsNullOrWhiteSpaceinstead of!IsNullOrWhiteSpace, which meantLinkedListItemswith aConditionattribute were never filtered, items were always shown regardless of the condition value.Added an integration test (
TestLinkedListItemsCondition) that creates twoConditionalLinkedListobjects, one withisActive=trueand one withisActive=false, and verifies that the NatVisLinkedListItemsConditionattribute is respected.