Skip to content

Complete method-source generic class discovery parity and fix tuple normalization #7597

Open

Description

@thomhurst

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

  1. 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.
  2. 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

Parent: #7224. This is the discovery part of the review-budget split of #7571.

Activity

  1. added
    bugSomething isn't working
    P2Medium: edge case, mode divergence, flaky test, or workaround exists
    on Nov 4, 2026
  2. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: edge case, mode divergence, flaky test, or workaround existsbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions