Skip to content

Generic class row that infers no type argument: core rule for method [Arguments] rows and constructor binding, both modes #7389

Closed

Description

@thomhurst

Split from #7337, which went over the issue-pr-loop rework budget (20 automated review rounds, with a blocking finding still open). This part delivers the core behaviour of #7209 for class [Arguments] rows beside method [Arguments] rows only.

Scope

A class-level [Arguments] row whose values bind only to constructor parameters that don't use a class type parameter (for example [Arguments(42)] on C<T>(int number)) supplies no class type argument. In both modes:

  • Method [Arguments] rows infer T as they do without a class row: C<int> for [Arguments(1)], C<object> for [Arguments(null)] (Untyped [Arguments(null)] method row on a generic class silently produces no test #7141).
  • Each instance is built from the class row (number = 42).
  • The class row binds to the same constructor in both modes: the [TestConstructor] constructor when there is one, otherwise the first public instance constructor (this includes C# primary constructors).

Files

  • TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs: ClassRowSuppliesNoTypeArguments and GetClassRowConstructor, plus replacing the NoClassRowForMethodRowMessage throw with the type-free rows used as class rows.
  • TUnit.Engine/Discovery/ReflectionTestDataCollector.cs: SplitTypeFreeClassRows/ClassRowSuppliesNoTypeArguments/GetClassRowConstructor, limited to the class-row and method-row path.
  • ReflectionGenericConstraintViolations.cs: only if the method-row constraint check needs the shared type mapping.
  • Tests: TestProject Bugs/_7209 (the row that infers no type, the control row that does infer T, the primary-constructor and [TestConstructor] classes), Issue7209Tests in both modes, and the Tests7209 generator snapshot.

Reusable commits

Branch issue-7209-generic-class-row-no-type-arg (PR #7337). Start from fdc2edb570, 9d27913945, and the [TestConstructor] half of bc7255a35a. Leave out the commits for other data sources; they belong to the sibling issue.

Acceptance criteria

Activity

  1. added
    bugSomething isn't working
    P2Medium: edge case, mode divergence, flaky test, or workaround exists
    on Nov 2, 2026
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 workingin-progressWork is in progress

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions