Match MSTest overloads against the test data - #1862
Merged
Merged
Conversation
FindMethod returned the first method whose name matched, so with overloaded test methods every case resolved to the same MethodInfo. Two ways that goes wrong: * The parameter count guard in BuildVerifier compares the data length against that MethodInfo, so it mismatches for the other overload and SetParameters is silently skipped, dropping the parameters from the file name. * The parameter names handed to InnerVerifier come from that MethodInfo, so a same arity overload is labeled with the other overload's parameter names. The data the test was invoked with is all there is to tell overloads apart, so candidates are now narrowed by parameter count and then by the types of that data. It still falls back to the first match when that does not narrow to one.
This was referenced Aug 26, 2026
This was referenced Aug 27, 2026
Open
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.
TestExecutionContext.FindMethodreturned the first method whose name matchedTestContext.TestName, ignoring parameters. With overloaded test methods every case resolved to the sameMethodInfo, which goes wrong two ways — both reproduced:BuildVerifieronly callsSetParameterswhen the test data length matches thatMethodInfo's parameter count, so for the other overload it silently does not.Overload(int, int)with[DataRow(1, 2)]named its snapshotOverloadTests.Overload.verified.txt— no parameters at all, so every case of that overload collides on one file.InnerVerifiercome from that sameMethodInfo, so a same-arity overload is labeled with the other overload's parameter names.SameArityOverload(int number)with[DataRow(1)]named its snapshot..._text=1, borrowingtextfrom thestringoverload.The data the test was invoked with is all there is to tell overloads apart, so candidates are now narrowed by parameter count (allowing for a params array, whose
DataRowexposes raw pre-binding data) and then by the runtime types of that data. When neither narrows to a single candidate it falls back to the first match, so nothing that resolves today changes.The non-overloaded path is unchanged: a single name match returns immediately, without allocating the candidate list.
OverloadTestscovers both shapes — different arity, and same arity distinguishable only by type. Both produce wrong names onmain.Verify.MSTest.Testspasses for net11.0 and net48 (163), andVerify.MSTestbuilds for all seven target frameworks.