Repository navigation
Description
Summary
A method data source returning an eight-element reference tuple of integers is rejected with TUnit0001 when the test accepts the corresponding tuple of longs. The analyzer prevents the test from compiling. Related runtime tuple-conversion support and coverage are in open PR #7469; this issue tracks the analyzer change separately.
Reproduction
public static Tuple<int, int, int, int, int, int, int, Tuple<int>> Row()
=> Tuple.Create(1, 2, 3, 4, 5, 6, 7, 8);
[Test]
[MethodDataSource(nameof(Row))]
public void Test(Tuple<long, long, long, long, long, long, long, Tuple<long>> value) { }Expected and actual
Expected: accept per-element implicit numeric conversions, as for value tuples.
Actual: TUnit0001 reports that the source and parameter types do not match.
Environment
Found on e452541 with SDK 10.0.403, net10.0, macOS arm64. Reproduced while adding runtime coverage in #7469. The reference-tuple spreading fix in #7457 (for #7374) is already on main; it does not cover this single tuple parameter conversion.
Please validate compatible element conversions for a single reference-tuple parameter, including nested Rest.
Acceptance criteria
- Accept a single reference-tuple parameter when each source element has a compatible implicit numeric conversion to the corresponding target element, including recursively nested
Restfor tuples longer than seven elements. - Add analyzer regressions for short reference tuples and the eight-element reproduction above.
- Keep reporting TUnit0001 for incompatible element types and mismatched tuple lengths; add negative regressions.
- Preserve existing exact-type single-tuple binding and reference-tuple spreading across multiple parameters.
Current code evidence
At main commit 1f705642be3eec0a1a55034d6210f1532ec5946c, src/TUnit.Analyzers/TestDataAnalyzer.cs preserves a tuple as one argument only when its type exactly equals the single parameter type; otherwise it spreads its elements. ReferenceTupleMethodDataSourceTests covers exact-type whole tuples and spreading, but not whole-tuple numeric widening. Merged PR #7457 addresses spreading; open PR #7469 explicitly leaves this analyzer limitation to #7480.
Activity
Fix single reference-tuple numeric widening analysis (#7480)
Address reference tuple analyzer review feedback (#7480)
Restore scoped tuple analyzer suppressions (#7480)
Keep diagnostics for unsupported nested reference tuple conversions (#…
Restrict reference tuple widening to method binding (#7480)
Cover character to decimal reference tuple binding (#7480)
Fix #7480 tuple reconstruction allowance after row spreading
Fix #7480 unsupported tuple element conversions
Fix single reference-tuple numeric widening analysis (#7480)
Address reference tuple analyzer review feedback (#7480)
Restore scoped tuple analyzer suppressions (#7480)
Keep diagnostics for unsupported nested reference tuple conversions (#…
Restrict reference tuple widening to method binding (#7480)
Cover character to decimal reference tuple binding (#7480)
Fix #7480 tuple reconstruction allowance after row spreading
Fix #7480 unsupported tuple element conversions
Fix #7480 exact nullable tuple operators and refresh regression snapshot
Reject unsupported char floating-point tuple conversions (#7480)
Reject unsupported native-integer tuple conversions (#7480)
Reject unsupported native-integer to decimal tuple binding (#7480)
Reject unsupported native-integer tuple targets (#7480)