Skip to content

test: parity test for typed-row type inference across source-gen and reflection #7386

Open

Description

@thomhurst

Summary

Merged PR #7343 (#7214) added two implementations of the typed-row binding rules for generic test methods, and they must stay in sync:

  • InferMethodTypeArgumentsFromRowType in src/TUnit.Core.SourceGenerator/Extensions/TypedDataSourceInference.cs works on Roslyn symbols.
  • InferTypesFromTypedRow in src/TUnit.Engine/Discovery/ReflectionTestDataCollector.cs works on System.Reflection.

Each is about 150 lines and mirrors the other branch for branch. The review rounds on #7343 found several parity gaps (nullable tuples, ITuple, reference-array spreads, and the netstandard2.0 ITuple gap fixed in e0738cb). Every new rule needs two edits.

Proposed work

  1. Add a parity test that runs one table of (row type, method signature, expected type arguments or "infers nothing") cases through both implementations. Today Issue7214Tests checks parity only indirectly, through the test names.
  2. Optionally, factor the shape classification (spread elements, whole row, unknown) into one place, so that each mode keeps only a thin mapping layer.

Acceptance criteria

  • One case table covers both modes and fails when they diverge.
  • Behaviour does not change. Compare inference results, including cases that infer nothing; runtime fallback behavior can intentionally differ between modes.
  • Cover the reviewed nullable-tuple, ITuple, reference-array spread, and netstandard2.0 tuple-shape cases.

The prerequisite #7343 is now on origin/main; this issue is available for implementation. This focused parity table is related to the broader rules consolidation in #7371 and should be reused there.

Raised by the Claude review on #7343.

Activity

  1. added
    enhancementNew feature or request
    P3Low: cleanup, minor enhancement, or rare edge case
    on Nov 2, 2026
  2. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    Triage update: #7343 has merged and #7214 is closed. Both inference implementations are now on origin/main; removed the completed prerequisite link. Issue7214Tests still checks integration outcomes rather than one direct inference case table. The body now makes that distinction explicit, including intentional runtime fallback differences.

  3. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    PR #7620's latest Claude review asks that this parity table also cover sole-tuple reconstruction versus invariant whole-row matching. Please include nullable lifting, repeated generic bindings, generic interfaces/base classes, numeric and user-defined conversions, and string parsing for static value-tuple and instance reference-tuple sources. Its SingleTupleElementConversionTests, RepeatedTupleBindingTests and ClosedClassTupleInferenceTests provide shared execution fixtures in both modes; the follow-up here should compare inference directly, including rejected shapes.

  4. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    PR #7620 is closed under its rework budget; tuple implementation and parity coverage continue in #7629. Preserve Claude review 6650151530's nonblocking follow-ups when designing this parity work: compare generic-base traversal and candidate-binding isolation in ReflectionTestDataCollector/TestGenericTypeResolver, consider a shared runtime helper and named matcher predicates, and document TupleHelper's cache key space (measure before changing the hot path). The repeated method-source attribute predicate and guarded failure lookup are cleanup suggestions, not acceptance blockers for #7628/#7629. The existing shared conversion matrix should remain the behavioral baseline.

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

    P3Low: cleanup, minor enhancement, or rare edge caseenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions