Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Fix 3+ arg Zip not working with immediate sources #828

Merged
merged 2 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,10 @@ public override void OnError(Exception error)

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small comment why the base (and not the own) method is called could be helpful for future readers.


lock (_gate)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4462,13 +4462,17 @@ public void Zip2WithImmediateReturn()
[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]
Expand Down