You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Arguments] row that breaks a constraint is reported in source-gen mode but silently dropped in reflection mode when the method has [GenerateGenericTest] #7153
When a generic test method has a method-level [GenerateGenericTest], an [Arguments] row whose inferred type argument breaks the method's constraints behaves differently in the two modes:
Source-gen mode: the row is reported as a failed test (Type 'String' does not satisfy the 'struct' constraint for generic parameter 'T').
Reflection mode: the row is silently dropped. ReflectionTestDataCollector.InferMethodInstantiationsFromDataSources skips sources whose inferred types break the constraints, and the row does not appear as a test at all.
TUnit.TestProject, net10.0, with a treenode filter on this class:
Source-gen: 2 tests. Run<int>(5) passes, Run fails with the struct constraint message.
--reflection: 1 test. Run<int>(5) passes, and the "x" row is gone.
(TUnit0001 flags "x" at compile time, so the repro needs #pragma warning disable TUnit0001.)
Expected
The same tests in both modes. After #7097 / #7107 the convention is that an invalid row is reported, not dropped, so reflection mode should probably report it as source-gen mode does.
Context
Found while fixing #7116. That PR aligns the [MethodDataSource] / typed-data-source case with [GenerateGenericTest] (source-gen no longer reports a data source whose declared type breaks the constraint, because the rows run on the [GenerateGenericTest] type, as in reflection mode). It leaves [Arguments] rows alone, because a literal argument cannot be converted to the listed type the way a broad declared type can.
Activity
fix(engine): report [Arguments] rows that break constraints with [Gen…