Skip to content

Generic class without class rows: method [Arguments] row beside an IEnumerable<object> [MethodDataSource] runs on different instantiations per mode #7362

Done

Description

@thomhurst

What happens

Take a generic test class with no class data source and a non-generic test method that has both an [Arguments] row inferring T and a [MethodDataSource] member of the test class declared as IEnumerable<object>:

public class ProbeNoClassRowMixed<T>
{
    public static IEnumerable<object> Rows() => [2];

    [Test]
    [Arguments(1)]
    [MethodDataSource(nameof(Rows))]
    public void Run(T value) => Console.WriteLine($"{typeof(T).Name} {value}");
}

Observed on net10.0 at #7337's head:

Mode Tests
Source-generated C<int>.Run(1), C<object>.Run(2), C<object>.Run(1)
Reflection C<int>.Run(1) only

The generator runs the [Arguments(1)] row on C<object> as well, although #7118 says a method row runs only on the instantiation it infers. Reflection drops the [MethodDataSource] rows entirely.

Expected

Both modes give the same result, with no row running on an instantiation it doesn't infer and no source silently disappearing. With a class [Arguments] row that infers no type (the core #7209 rule shipped in #7392), the intended comparison is C<int>.Run(1) and C<int>.Run(2), which is a reasonable target here as well.

Found while verifying a Codex finding on #7337.

Acceptance criteria

  • Reproduce this no-class-data-source case on current main; keep it distinct from Generic class row that infers no type argument: reflection parity beside other data sources #7390, which has type-free class rows.
  • Apply the same method-source instantiation rule in both modes, retaining both source values without duplicating the [Arguments] row on an unrelated instantiation.
  • Add a targeted TestProject fixture and a both-mode engine regression that asserts the exact test count, values, and closed class types.

Activity

  1. added
    bug
    P2
    on Nov 2, 2026
  2. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    Triage: added a native blocked_by #7209. The expected behavior follows #7209's rule, and PR #7337 changes the reflection [MethodDataSource] handling this issue touches. Fixing this first would conflict with that PR.

  3. thomhurst commented on Nov 3, 2026

    @thomhurst
    OwnerAuthor

    Removed the closed #7209 dependency after #7392 (ca4437c). This issue has no class data source; #7390 instead covers combinations beside a type-free class row. The no-class-row regression still needs its own reproduction and parity fix on current main.

  4. thomhurst commented on Nov 29, 2026

    @thomhurst
    OwnerAuthor

    Partly fixed on #7883: both modes now agree, and nothing is dropped or duplicated. Run(2) still runs on C<object> rather than C<int>. Fixture: https://github.com/thomhurst/TUnit/tree/followup/class-row-repro-fixtures/tests/TUnit.TestProject/Bugs/_7362. Left for a follow-up PR.

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

    P2bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions