Skip to content

Commit c62c41f

Browse files
authored
Fix XUnitWrapperGenerator: testArguments out of scope in ConditionalTest else branch for MemberData theories (#126505)
1 parent 2ebe5d9 commit c62c41f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,11 @@ public MemberDataTest(ISymbol referencedMember,
295295
string externAlias,
296296
string argumentLoopVarIdentifier)
297297
{
298-
TestNameExpression = innerTest.TestNameExpression;
299298
Method = innerTest.Method;
300299
ContainingType = innerTest.ContainingType;
300+
// Use a static expression that doesn't reference the loop variable since it may be used
301+
// outside the foreach loop scope (e.g., in a ConditionalTest's else branch).
302+
TestNameExpression = $"\"{externAlias}::{ContainingType}.{Method}(...)\"";
301303
DisplayNameForFiltering = $"{ContainingType}.{Method}(...)";
302304

303305
_innerTest = innerTest;

0 commit comments

Comments
 (0)