Description
While using TUnitMigrator I encountered an issue when using TheoryData<T1, T2> with multiple types it translates into an IEnumerable<T1, T2> and leads to code that cannot compile.
Given you have a xUnit Theory with TheoryData like so:
[Theory][MemberData(nameof(MyData))]publicvoidMyTest(stringa,intb){}and the data defined as:
publicstaticTheoryData<string,int>MyData{get{vardata=newTheoryData<string,int>{{"a",1},{"b",2}};returndata;}}Then when the TheoryData gets transformed into a MethodDataSource it seems to create an IEnumerable<string, int>, but the data variable is transformed into an array with only the first type like:
publicstaticIEnumerable<string,int>MyData{get{vardata=string[]{{"a",1},{"b",2}}}}This doesn't compile at all.
Expected Behavior
I would have expected the analyzer to generate something like follows or similar that would compile and work with data driven test cases:
publicstaticIEnumerable<Func<(string,int)>>MyData{get{yieldreturn()=>("a",1);yieldreturn()=>("b",2);}}Actual Behavior
Code not compiling
Steps to Reproduce
- Clone: https://github.com/Cheesebaron/tunitmigrator-xunittheorydata-repro
dotnet tool install --global TUnitMigratortunit-migrate /path/to/tunitmigrator-xunittheorydata-repro
TUnit Version
1.16.4
.NET Version
.NET 10
Operating System
macOS
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
Description
While using TUnitMigrator I encountered an issue when using
TheoryData<T1, T2>with multiple types it translates into anIEnumerable<T1, T2>and leads to code that cannot compile.Given you have a xUnit Theory with TheoryData like so:
and the data defined as:
Then when the
TheoryDatagets transformed into aMethodDataSourceit seems to create anIEnumerable<string, int>, but the data variable is transformed into an array with only the first type like:This doesn't compile at all.
Expected Behavior
I would have expected the analyzer to generate something like follows or similar that would compile and work with data driven test cases:
Actual Behavior
Code not compiling
Steps to Reproduce
dotnet tool install --global TUnitMigratortunit-migrate /path/to/tunitmigrator-xunittheorydata-reproTUnit Version
1.16.4
.NET Version
.NET 10
Operating System
macOS
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
dotnet testordotnet run, not just in my IDE