Fix inverted condition check for LinkedListItems in NatVis#1559
Open
WardenGnaw wants to merge 1 commit into
Open
Fix inverted condition check for LinkedListItems in NatVis#1559WardenGnaw wants to merge 1 commit into
WardenGnaw wants to merge 1 commit into
Conversation
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>
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 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.