Remove Debug/Release line number branching from tests#8
Open
Conversation
6e2b787 to
ecbd72f
Compare
Add SourceAssert helper that reads actual source files to validate PDB-reported line numbers, replacing hardcoded Debug/Release conditional checks. The helper finds method declarations (including attributes) and body ranges in source files, making line number assertions work identically in both configurations. Changes: - New SourceAssert.cs with LineIsWithinMethod, GetMethodRange, GetAllMethodRanges, and FindSourceFile methods - DiaSessionTests: removed ValidateMinLineNumber/ValidateLineNumbers helpers, using SourceAssert instead - DifferentTestFrameworkSimpleTests: removed Debug/Release branching for NUnit and xUnit adapter line assertions - DiscoverTests: removed dead Debug/Release branching Fixes microsoft#15458 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ecbd72f to
b520286
Compare
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.
Summary
Add a \SourceAssert\ helper that reads actual source files to validate PDB-reported line numbers, replacing hardcoded Debug/Release conditional checks. This makes tests behave identically in both configurations, fixing the issue where CI (Release) and local (Debug) runs had different behavior.
Changes
How it works
Instead of hardcoding expected line numbers per build configuration, the tests now read the actual source file, find the method by its signature (looking for \methodName(\ patterns), and verify the PDB-reported line falls within that method's declaration range (from attributes through closing brace).
Fixes microsoft#15458