Skip to content

Generic classes with differently typed [Arguments] rows produce different test sets in source-gen and reflection modes #7118

Closed

Description

@thomhurst

Summary

On a generic test class whose [Arguments] rows infer different type arguments, the two modes produce different test sets.

Repro

[Arguments(1)]
[Arguments("a")]
public class MixedRows<T>(T value)
{
    [Test]
    [Arguments(1)]
    [Arguments("a")]
    public void Test<TMethod>(TMethod arg) { }
}
  • Source-gen mode: every method row runs in every class instantiation, so mistyped combinations such as Test<int>("a") are produced. That gives 4 tests, 1 of which fails on argument conversion.
  • Reflection mode: each row runs only in the instantiation its own types infer. That gives 2 tests, both passing.

Reflection mode's behaviour looks like the intended one, so source-gen should probably stop pairing rows with instantiations whose types they do not match.

Notes

Found while addressing review on #7094; the exact repro shape should be confirmed when picked up. Related: #7106, #7111.

Activity

  1. added a commit that references this issue on Oct 21, 2026
    c010c1c
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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions