Skip to content

Preserve generic class source row semantics and distinguish null collections from null rows #7445

Closed

Description

@thomhurst

Generic class data sources need consistent constructor-row semantics in generated and reflection discovery. Extract the runtime support from #7422 as a separately mergeable change, preserving existing discovery until the generator inference is enabled in the sibling issue.

Scope and owned files

  • src/TUnit.Core/Attributes/TestData/{GenericClassRowPartition,MethodDataSourceAttribute,StaticDataSourceAttribute}.cs, src/TUnit.Core/GenericConstraintViolationEntry.cs, and src/TUnit.Engine/Discovery/ReflectionTestDataCollector.cs.
  • src/TUnit.Core/Helpers/DataSourceFactories.cs for the null-collection correction.
  • Runtime-focused new regression fixtures and integration tests in separate files; relevant PublicAPI snapshots. Include the independent PublicAPI path-scrubber correction from the branch if still needed.
  • Reuse commits from preserved branch issue-7333-class-method-source, head df168fa58f32f0ef591b731330cf2407b4922fc9; extract changes rather than cherry-picking the whole feature.

Acceptance criteria

  • Preserve fresh factory objects, constructor selection, explicit versus inferred row filtering, empty-source fallback and constraint-violation row reporting in both modes.
  • Resolve Codex finding fix(generator): infer generic class types from class MethodDataSource rows #7422 (comment): an own-class IEnumerable<string>? Rows() => null on a seeded C<T>(T value) supplies no extra null constructor row. Preserve a legitimate null element inside a non-null collection. Verify synchronous and async collection factory variants affected by the same conversion.
  • Keep generated-code configuration APIs hidden with EditorBrowsable(Never), document intentional public surface, preserve trimming and Native AOT.
  • This part must merge with the current generator, without depending on the sibling generator feature. Add meaningful direct runtime/factory tests and both-mode regressions for behavior available on main; run relevant PublicAPI tests and native publishing. Do not run Engine.Tests locally.

Split because #7422 reached 21 automated review rounds with a new blocking parity finding. The feature remains tracked by parent #7333.

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