Add Join/LeftJoin/RightJoin tuple overloads to LINQ APIs#121998
Add Join/LeftJoin/RightJoin tuple overloads to LINQ APIs#121998eiriktsarpalis merged 7 commits intomainfrom
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-linq |
|
@copilot please invoke the code-review skill and post your analysis/results as comment on this PR |
🤖 Copilot Code Review — PR #121998Holistic AssessmentMotivation: The PR adds tuple-returning overloads for Approach: The implementation duplicates the iterator logic rather than delegating to the Summary: Detailed Findings✅ API surface matches approved designThe ref assemblies match the approved API from the API review. All overloads use a single method with ✅ Implementation correctness — EnumerableThe new ✅ Implementation correctness — AsyncEnumerableBoth sync and async key selector variants are provided. The ✅ Queryable expression tree constructionThe
|
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
… AsyncEnumerable Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
…omparer parameter Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
c5d0ac1 to
95b9985
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds tuple-returning overloads for LINQ Join, LeftJoin, and RightJoin across Enumerable, Queryable, and AsyncEnumerable, allowing callers to omit a resultSelector when they just want paired results.
Changes:
- Added tuple-returning overloads for
Enumerable.Join/LeftJoin/RightJoinand correspondingQueryableandAsyncEnumerableAPIs. - Implemented new iterators that yield named tuples (with default/null for unmatched outer-join side).
- Added/updated reference assemblies and expanded test coverage for the new overloads.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Linq/src/System/Linq/Join.cs | Adds Enumerable.Join overload returning (TOuter Outer, TInner Inner). |
| src/libraries/System.Linq/src/System/Linq/LeftJoin.cs | Adds Enumerable.LeftJoin overload returning (TOuter Outer, TInner? Inner). |
| src/libraries/System.Linq/src/System/Linq/RightJoin.cs | Adds Enumerable.RightJoin overload returning (TOuter? Outer, TInner Inner). |
| src/libraries/System.Linq/ref/System.Linq.cs | Exposes new Enumerable tuple overloads in the public ref surface. |
| src/libraries/System.Linq/tests/JoinTests.cs | Adds tests for tuple Enumerable.Join. |
| src/libraries/System.Linq/tests/LeftJoinTests.cs | Adds tests for tuple Enumerable.LeftJoin. |
| src/libraries/System.Linq/tests/RightJoinTests.cs | Adds tests for tuple Enumerable.RightJoin. |
| src/libraries/System.Linq.Queryable/src/System/Linq/Queryable.cs | Adds tuple overloads for Queryable.Join/LeftJoin/RightJoin building corresponding expression trees. |
| src/libraries/System.Linq.Queryable/ref/System.Linq.Queryable.cs | Exposes new Queryable tuple overloads in the public ref surface. |
| src/libraries/System.Linq.Queryable/tests/JoinTests.cs | Adds tests for tuple Queryable.Join. |
| src/libraries/System.Linq.Queryable/tests/LeftJoinTests.cs | Adds tests for tuple Queryable.LeftJoin. |
| src/libraries/System.Linq.Queryable/tests/RightJoinTests.cs | Adds tests for tuple Queryable.RightJoin. |
| src/libraries/System.Linq.AsyncEnumerable/src/System/Linq/Join.cs | Adds tuple overloads for AsyncEnumerable.Join (sync + async key selector variants). |
| src/libraries/System.Linq.AsyncEnumerable/src/System/Linq/LeftJoin.cs | Adds tuple overloads for AsyncEnumerable.LeftJoin (sync + async key selector variants). |
| src/libraries/System.Linq.AsyncEnumerable/src/System/Linq/RightJoin.cs | Adds tuple overloads for AsyncEnumerable.RightJoin (sync + async key selector variants). |
| src/libraries/System.Linq.AsyncEnumerable/ref/System.Linq.AsyncEnumerable.cs | Exposes new AsyncEnumerable tuple overloads in the public ref surface. |
| src/libraries/System.Linq.AsyncEnumerable/tests/JoinTests.cs | Adds tests for tuple AsyncEnumerable.Join. |
| src/libraries/System.Linq.AsyncEnumerable/tests/LeftJoinTests.cs | Adds tests for tuple AsyncEnumerable.LeftJoin. |
| src/libraries/System.Linq.AsyncEnumerable/tests/RightJoinTests.cs | Adds tests for tuple AsyncEnumerable.RightJoin. |
src/libraries/System.Linq.Queryable/src/System/Linq/Queryable.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Queryable/src/System/Linq/Queryable.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Queryable/src/System/Linq/Queryable.cs
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
…gthen tuple tests - Update XML doc summaries and comparer param docs on all tuple-returning Join/LeftJoin/RightJoin overloads (Enumerable and Queryable) to clarify that null/omitted comparer falls back to EqualityComparer<TKey>.Default. - Replace Count/Contains assertions in TupleJoin_Basic, TupleLeftJoin_Basic, and TupleRightJoin_Basic with exact sequence equality checks to verify ordering and multiplicity semantics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
🤖 Copilot Code Review — PR #121998Note This review was generated by Copilot and should be verified by a human reviewer. Holistic AssessmentMotivation: Well-justified quality-of-life improvement. The Approach: The implementation is clean and follows established codebase patterns faithfully. Each tuple overload mirrors its existing Summary: Detailed Findings
|
|
/ba-g all tests passing. |
Implements tuple-returning overloads for
Join,LeftJoin, andRightJointhat eliminate the need for aresultSelectorlambda when you just want the joined elements as a tuple.Changes
Join<TOuter, TInner, TKey>,LeftJoin<TOuter, TInner, TKey>,RightJoin<TOuter, TInner, TKey>returning(TOuter Outer, TInner Inner)tuples (with nullable element for outer joins)Expression<Func<>>key selectorsIEqualityComparer<TKey>? comparer = nullparameterExample
Before:
After:
Fixes #120596
Original prompt
This section details on the original issue you should resolve
<issue_title>[API Proposal]: Linq Join return tuple similar to Zip</issue_title>
<issue_description>### Background and motivation
For simplicity of
Joinit should just return(TOuter,TInner)instead of the need forresultSelectorAPI Proposal
API Usage
Alternative Designs
Without this it need to make another lambda just for return tuple