소스 검색

4.x: Fix 3+ arg Zip not working with immediate sources
(cherry picked from commit bf2a31415a0c8a03c37879522a99703cbd28aa61)

Add comment to changes
(cherry picked from commit 8dd6b3d7b7fd6d7a757162068921824a918a8208)

Dávid Karnok 7 년 전
부모
커밋
4aabda1be9

+ 4 - 1
Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs

@@ -524,7 +524,10 @@ namespace System.Reactive.Linq.ObservableImpl
 
         public override void OnCompleted()
         {
-            Dispose();
+            // Calling Dispose() here would clear the queue prematurely.
+            // We only need to dispose the IDisposable of the upstream,
+            // which is done by SafeObserver.Dispose(bool).
+            base.Dispose(true);
 
             lock (_gate)
             {

+ 10 - 6
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ZipTest.cs

@@ -4462,13 +4462,17 @@ namespace ReactiveTests.Tests
         [Fact]
         public void Zip3WithImmediateReturn()
         {
-            Observable.Zip<Unit, Unit, Unit, Unit>(
-                Observable.Return(Unit.Default),
-                Observable.Return(Unit.Default),
-                Observable.Return(Unit.Default),
-                (_, __, ___) => Unit.Default
+            int result = 0;
+
+            Observable.Zip<int, int, int, int>(
+                Observable.Return(1),
+                Observable.Return(2),
+                Observable.Return(4),
+                (a, b, c) => a + b + c
             )
-            .Subscribe(_ => { });
+            .Subscribe(v => result = v);
+
+            Assert.Equal(7, result);
         }
 
         [Fact]