Skip to content

Untyped [Arguments(null)] method row on a generic class silently produces no test #7141

Closed

Description

@thomhurst

Summary

An untyped [Arguments(null)] method row on a generic test class, with nothing else to infer the class's type argument, produces zero tests in both source-gen and reflection modes. There is no diagnostic or failed test, so the test silently disappears.

public class NullRowOnGenericClass<T>
{
    [Test]
    [Arguments(null)]
    public void Run(T value) { }
}

Where

  • Source gen: InferClassTypesFromMethodArguments in src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs returns null for a null params array.
  • Reflection: InferClassTypeArgumentsFromMethodRow in src/TUnit.Engine/Discovery/ReflectionTestDataCollector.cs returns null for ArgumentsAttribute.IsNullValuesArray.

#7106 (PR #7111) chose this deliberately so that [Arguments(null)] does not break a where T : struct constraint (fixture NullArrayMethodRowOnConstrainedClass). The problem is that when no other row or [GenerateGenericTest] provides an instantiation, the row is dropped without any signal.

Reproduce

Add the class above to TUnit.TestProject, then run --treenode-filter "/*/<ns>/NullRowOnGenericClass/*" in either mode. Discovery finds 0 tests.

Expected

Either infer object, matching how a generic method treats [Arguments(null)] (#7120), when that satisfies the constraints, or report a clear diagnostic or failed test saying T cannot be inferred. Do the same in both modes.

Found while fixing #7120.

Activity

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