Repository navigation
Description
Summary
Generic test classes using method-level MethodDataSource rows must discover the same closed class types in generated and reflection modes. Finish the discovery adapters from #7571 on top of the separate runtime prerequisite, correcting the two remaining generator inference findings before opening a replacement PR.
Proposal
Reuse branch issue-7224-class-inference at 3dd509bc6e81ef411d439f455f15ce399c2b89c9. Own src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs, Helpers/GenericClassInferencePolicy.cs, CodeGenerators/Helpers/InstanceFactoryGenerator.cs and TupleArgumentHelper.cs; src/TUnit.Engine/Discovery/ReflectionTestDataCollector.cs and ReflectionGenericConstraintViolations.cs; generator Tests7224 and intentional Tests7210 snapshots, ReflectionDeclaredMemberTests, _7224 fixtures and tests/TUnit.Engine.Tests/Issue7224Tests.cs.
Blocking findings to resolve
- Infer generic test class types from method data sources in both modes #7571 (comment) : GetMethodDataSourceRowType unwraps singleton value tuples containing TestDataRow but misses reference tuples. For C.Run(T) with IEnumerable<Tuple<TestDataRow>>, infer int in both modes, matching execution rather than inferring TestDataRow.
- Infer generic test class types from method data sources in both modes #7571 (comment) : reject nullable tuple declarations from scalar class inference, matching reflection IsNullableTuple. For explicit C.Run(T,string) and IEnumerable<(int,string)?>, retain the valid explicit instantiation without adding an invalid C<(int,string)?> test.
Acceptance criteria
- Deliver Reflection mode: generic test class does not infer its type arguments from a method-level [MethodDataSource]; source-gen does #7224 discovery parity with the supported scalar, tuple, wrapped-array, async, external, inherited, overloaded and explicit-type rows covered by the original fixtures.
- Add shared fixtures and generator snapshots for both findings; test generated and reflection discovery and execution.
- Keep uninferable-source diagnostics and existing optional-constructor behavior; preserve Reflection mode: generic test with a repeated type parameter is named Repeated<int> but runs with a different type argument #7121 method inference behavior.
- Run affected generator snapshots, relevant runtime tests, targeted _7224 fixtures in both modes and Native AOT validation. Engine integration tests remain CI-only; inspect their results before merge. Run public API tests for shipped API changes.
- Reuse reviewed changes selectively on current main plus the runtime prerequisite, keeping runtime file ownership in that prerequisite. Preserve runtime data-row binding and constructor partitions for generic class inference #7596 also owns any minimal generator/type-description support and focused snapshots required to make its constructor-array filter safe; reuse that support here rather than postponing it or creating a dependency cycle. Existing nonblocking follow-ups (Generic class row that infers no type argument: reflection parity beside other data sources #7390, Typed tuple rows with multiple trailing values skip argument type validation #7463, Uninferable method data sources share a discovery-failure test ID #7595, TUnit0001 rejects data rows that omit a plain trailing array #7587, Simplify declared row shape and generic inference policy inputs #7588, Share class-row type inference between the source generator, analyzer and reflection #7377) remain separate.
Parent: #7224. This is the discovery part of the review-budget split of #7571.
Activity
thomhurst commentedon Nov 4, 2026
Triage: retained native blocked_by #7596 and clarified that the prerequisite owns minimal constructor-array safety emission and its tests. The discovery adapters remain here, avoiding a reverse dependency; removed the redundant blocked label.