Skip to content

Support typed rows for C# 13 params ReadOnlySpan<T> parameters #7462

Closed

Description

@thomhurst

Summary

Typed test-data rows do not support packing individual elements into C# 13 params ReadOnlySpan<T> parameters. Packing currently supports arrays and five array-assignable collection interfaces. Support for span params would let users pass typed rows to methods using the newer C# syntax.

Reproduction

On .NET 10, declare a TypedDataSourceAttribute<(int[], string)> source and apply it to [Test] void Run<T>(T[] values, params ReadOnlySpan<string> rest). The row contains an array and one string; the desired invocation packs the string into rest.

Proposal

Support span params consistently in source-generated discovery, reflection execution and analyzer validation, or provide a specific unsupported-parameter diagnostic. Reflection invocation cannot box a span, so accepting the analyzer conversion alone is insufficient.

At main commit d9e9e66, TupleArgumentHelper.GetTrailingElementType and ReflectionTestDataCollector.GetTrailingElementType only accept arrays and IEnumerable<T>, ICollection<T>, IList<T>, IReadOnlyCollection<T>, and IReadOnlyList<T>. Both return null for ReadOnlySpan<T>.

Discovered while reviewing #7460; broader params support is outside its array-inference scope. Please handle the span parameter consistently in both execution modes.

Activity

  1. added
    enhancementNew feature or request
    P3Low: cleanup, minor enhancement, or rare edge case
    on Nov 3, 2026
  2. thomhurst commented on Nov 3, 2026

    @thomhurst
    OwnerAuthor

    Triage checked against origin/main at d9e9e66: both TupleArgumentHelper.GetTrailingElementType and ReflectionTestDataCollector.GetTrailingElementType still exclude ReadOnlySpan. Open PR #7460 addresses array inference, not span invocation, and does not supersede this issue. No duplicate, stale claim, or prerequisite was found; the issue remains current and available for implementation.

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

    P3Low: cleanup, minor enhancement, or rare edge caseenhancementNew feature or requestin-progressWork is in progress

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions