Skip to content

Reflection discovery: DiscoverGenericTests and DiscoverGenericTestsStreamingAsync duplicate the generic-class logic #7167

Closed

Description

@thomhurst

What I saw

src/TUnit.Engine/Discovery/ReflectionTestDataCollector.cs has two copies of the generic-class discovery logic: DiscoverGenericTests (around line 657, returns a List<TestMetadata>) and DiscoverGenericTestsStreamingAsync (around line 862, returns IAsyncEnumerable<TestMetadata>). Both walk [GenerateGenericTest] attributes and class row groups, scope method rows (#7118), build test metadata and record constraint violations. Every fix in this area has to be made twice, for example #7106, #7107 and #7118 (PR #7149, which added about 40 more duplicated lines). The two copies already differ in small ways (cancellation checks, how failures are collected), which makes drift hard to spot in review.

Raised by the automated review on PR #7149 (#7149 (comment), point 2). Out of scope for that PR.

Expected

One implementation that both entry points use, for example the streaming version with the list version collecting it, or a shared helper that decides the instantiations and the method rows for a given (method, typeArguments). Discovery hot-path performance should be measured before and after, as AGENTS.md asks.

Activity

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions