Skip to content

Simplify data source attribute hierarchy and return types #4784

Description

@thomhurst

Problem

The data source attribute system has grown to 26+ types with a deeply nested core return type:

IAsyncEnumerable<Func<Task<object?[]?>>>

This is three levels of wrapping. Every data source must pack results into object?[] even for single values, and every consumer must unpack them.

The many variants exist to provide simpler semantics for sync vs async use cases, which is good — but the naming and hierarchy could be cleaned up.

Specific issues

  1. Naming inconsistencies — InstanceMethodDataSourceSourceAttribute and AsyncDependencyInjectionDataSourceSourceAttribute have a double "Source" typo
  2. Inconsistent naming patterns — mix of DataSource, Source, SourceGenerator in attribute names
  3. Return type complexity — IAsyncEnumerable<Func<Task<object?[]?>>> is hard to reason about. The Func<Task<...>> wrapping (deferred lazy evaluation) could be opt-in rather than required by default
  4. Arity explosion — DataSourceGeneratorAttribute<T> through <T1,T2,T3,T4,T5> plus async variants (10 classes for the same concept)

Proposed Direction

  • Fix the double-"Source" typos
  • Establish a consistent naming convention across all data source attributes
  • Consider simplifying the core return type (e.g. a TestDataRow struct to replace raw object?[])
  • Evaluate whether the arity variants can be reduced

Notes

  • The sync/async split is intentional and provides good ergonomics — keep that
  • This is a source-breaking change for anyone implementing custom data sources
  • Deferred to v2

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions