fix(sourcegen): fully-qualify Linq calls in params array binding (#6140) by thomhurst · Pull Request #6141 · thomhurst/TUnit (original) (raw)

@thomhurst

The dynamic-count params/array binding emitted Enumerable.Range(...).Select(...).ToArray() using the extension-method chain. Generated .g.cs files only import System.Linq when the project has ImplicitUsings enabled, so projects without it failed to compile with CS1061 ("IEnumerable does not contain a definition for Select").

Rewrite as fully-qualified static calls Enumerable.ToArray(Enumerable.Select(Enumerable.Range(...), ...)) so the generated code compiles regardless of the consuming project's usings.

Regressed in #6122. Snapshots regenerated.

[claude[bot]](/apps/claude)

@thomhurst

…6140)

Compiles the generated output WITHOUT using System.Linq in scope and asserts the resulting C# compilation has no errors. Fails with CS1061 against the pre-fix extension-method chain; passes with the fully-qualified static calls.

The existing snapshot harness can't catch this class of bug: TestsBase injects global using global::System.Linq; and only inspects generator diagnostics, never the resulting compilation's C# errors.

[claude[bot]](/apps/claude)

@thomhurst

…6140)

Addresses PR review feedback: document in TestsBase that the injected global using System.Linq; hides CS1061-style bugs from snapshot tests, so generated code must use fully-qualified static calls.

[claude[bot]](/apps/claude)

[claude[bot]](/apps/claude)

@thomhurst thomhurst deleted the fix/6140-params-array-linq-qualification branch

June 1, 2026 09:39

This was referenced

Jun 1, 2026

@claude claude Bot mentioned this pull request

Jun 1, 2026

1 task

This was referenced

Jun 1, 2026

This was referenced

Jun 15, 2026

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})