Skip to content

Whole reference-tuple rows are spread before an omitted plain trailing array #7623

Closed

Description

@thomhurst

Summary

A reference-tuple row passed whole to the first test parameter is spread when a plain trailing array follows it. The binder can otherwise supply an empty trailing array; this shape instead fails with InvalidCastException.

Reproduction

public class Tests
{
    public static IEnumerable<Tuple<int, string>> Rows() => [Tuple.Create(1, "tuple")];
    [Test, MethodDataSource(nameof(Rows))]
    public void Run<T>(Tuple<T, string> row, int[] extra) { }
}

Suppress TUnit0001 for this fixture (the analyzer limitation is tracked by #7622/#7587). With whole-row inference enabled, source-generated execution reports Unable to cast object of type System.Int32 to System.Tuple<int,string> instead of passing the tuple and an empty array.

Expected and actual

Expected: whole tuple binding followed by an empty collecting array, consistent with trailing-array collection elsewhere. Actual: tuple columns are passed as separate arguments. Optional and params parameters use whole-tuple binding, while plain trailing arrays are excluded by DataUnwrapper.RemainingDataParametersAreOmittable and the generator's tuple reconstruction condition.

Environment

.NET SDK 10.0.403, macOS arm64; reproduced during #7620 validation at f0e5567 with the optional-parameter inference correction. Both exclusion conditions remain on origin/main at 149ac45. Existing #7340 covers optional/params shapes and is closed; #7587 covers analyzer validation rather than runtime tuple retention.

Please support whole-tuple binding before an omitted plain trailing array in both execution modes, with runtime and analyzer regression coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low: cleanup, minor enhancement, or rare edge casebugSomething isn't workingin-progressWork is in progress

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions