Skip to content

Commit f7d668d

Browse files
authored
Merge pull request #828 from akarnokd/Zip3Fix
4.x: Fix 3+ arg Zip not working with immediate sources
2 parents 418a037 + 8dd6b3d commit f7d668d

File tree

2 files changed

+14
-7
lines changed
  • Rx.NET/Source
    • src/System.Reactive/Linq/Observable
    • tests/Tests.System.Reactive/Tests/Linq/Observable

2 files changed

+14
-7
lines changed

Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,10 @@ public override void OnError(Exception error)
524524

525525
public override void OnCompleted()
526526
{
527-
Dispose();
527+
// Calling Dispose() here would clear the queue prematurely.
528+
// We only need to dispose the IDisposable of the upstream,
529+
// which is done by SafeObserver.Dispose(bool).
530+
base.Dispose(true);
528531

529532
lock (_gate)
530533
{

Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ZipTest.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,13 +4462,17 @@ public void Zip2WithImmediateReturn()
44624462
[Fact]
44634463
public void Zip3WithImmediateReturn()
44644464
{
4465-
Observable.Zip<Unit, Unit, Unit, Unit>(
4466-
Observable.Return(Unit.Default),
4467-
Observable.Return(Unit.Default),
4468-
Observable.Return(Unit.Default),
4469-
(_, __, ___) => Unit.Default
4465+
int result = 0;
4466+
4467+
Observable.Zip<int, int, int, int>(
4468+
Observable.Return(1),
4469+
Observable.Return(2),
4470+
Observable.Return(4),
4471+
(a, b, c) => a + b + c
44704472
)
4471-
.Subscribe(_ => { });
4473+
.Subscribe(v => result = v);
4474+
4475+
Assert.Equal(7, result);
44724476
}
44734477

44744478
[Fact]

0 commit comments

Comments
 (0)