Skip to content

Fix WhenEach completion for empty input - #734

Open
dajiaohuang wants to merge 1 commit into
Cysharp:masterfrom
dajiaohuang:fix/wheneach-empty-20261015
Open

dajiaohuang wants to merge 1 commit into
Cysharp:masterfrom
dajiaohuang:fix/wheneach-empty-20261015

Conversation

@dajiaohuang

Copy link
Copy Markdown

Problem

Enumerating UniTask.WhenEach(Array.Empty<UniTask<int>>()), or an empty IEnumerable<UniTask<int>>, never finishes: the first MoveNextAsync() stays pending. A batch of zero operations therefore prevents code after await foreach from running. This reproduces the empty-batch case in #664 (closed after inactivity).

Change

Complete the result channel when the materialized input has zero tasks. There is no producer to perform the normal final completion in this case. Nonempty input behavior is unchanged.

Add regression coverage for both public overloads: the first move completes successfully with false, and disposal succeeds. Both cases fail on the base revision because the move remains pending.

Validation

  • Release library build: net6.0, net7.0, netstandard2.0 and netstandard2.1, no warnings/errors.
  • Existing .NET test project plus regressions: 339 passed with explicit major runtime roll-forward to installed .NET 8; the machine does not have runtime 7.
  • The same test sources/dependencies in a local net6.0 test harness, referencing the production net6.0 library: 339 passed on runtime 6.0.11.
  • Unity acceptance was attempted in an isolated project, but the Editor exited before package import/tests because no valid license was available. Unity/IL2CPP checks are not claimed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant