Skip to content

Await chained key computation in AsyncEnumerable ordering - #135356

Open
eiriktsarpalis with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-nullreferenceexception-thenby
Open

eiriktsarpalis with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-nullreferenceexception-thenby

Conversation

Copilot AI commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ThenBy and ThenByDescending discard chained key-computation tasks, allowing sorting to read uninitialized keys when selectors suspend and silently ignoring selector exceptions.

  • Fix: Await each subsequent sorter’s key computation before sorting.
  • Regression coverage: Add deterministic suspended-selector cases for secondary and third-level ordering in both directions, plus exception propagation when primary keys differ.
if (_next is not null)
{
    await _next.ComputeKeysAsync(elements, count, cancellationToken);
}

@azure-pipelines

azure-pipelines Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix NullReferenceException in async ThenBy key selector Await chained key computation in AsyncEnumerable ordering Oct 7, 2026
Copilot AI requested a review from eiriktsarpalis October 7, 2026 18:22
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-linq
See info in area-owners.md if you want to be subscribed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncEnumerable.ThenBy with async key selector throws NullReferenceException: secondary keys not awaited

2 participants