Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Threading;
using BenchmarkDotNet.Attributes;
Expand All @@ -17,7 +16,7 @@ public class AppendPrependBenchmark
[Params(1, 10, 100, 1000, 10000)]
public int N;

int _store;
private int _store;

[Benchmark(Baseline = true)]
public void StartWithArray()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Threading;
Expand All @@ -17,7 +16,7 @@ public class ToObservableBenchmark
[Params(1, 10, 100, 1000, 10000, 100000, 1000000)]
public int N;

int _store;
private int _store;

[Benchmark]
public void Exact()
Expand Down
16 changes: 8 additions & 8 deletions Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ namespace Microsoft.Reactive.Testing
{
internal class MockObserver<T> : ITestableObserver<T>
{
private TestScheduler scheduler;
private List<Recorded<Notification<T>>> messages;
private TestScheduler _scheduler;
private List<Recorded<Notification<T>>> _messages;

public MockObserver(TestScheduler scheduler)
{
this.scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
messages = new List<Recorded<Notification<T>>>();
this._scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
_messages = new List<Recorded<Notification<T>>>();
}

public void OnNext(T value)
{
messages.Add(new Recorded<Notification<T>>(scheduler.Clock, Notification.CreateOnNext<T>(value)));
_messages.Add(new Recorded<Notification<T>>(_scheduler.Clock, Notification.CreateOnNext(value)));
}

public void OnError(Exception exception)
{
messages.Add(new Recorded<Notification<T>>(scheduler.Clock, Notification.CreateOnError<T>(exception)));
_messages.Add(new Recorded<Notification<T>>(_scheduler.Clock, Notification.CreateOnError<T>(exception)));
}

public void OnCompleted()
{
messages.Add(new Recorded<Notification<T>>(scheduler.Clock, Notification.CreateOnCompleted<T>()));
_messages.Add(new Recorded<Notification<T>>(_scheduler.Clock, Notification.CreateOnCompleted<T>()));
}

public IList<Recorded<Notification<T>>> Messages
{
get { return messages; }
get { return _messages; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public static void AssertEqual<T>(this IEnumerable<T> actual, IEnumerable<T> exp
throw new ArgumentNullException(nameof(expected));
}

ReactiveAssert.AreElementsEqual(expected, actual);
AreElementsEqual(expected, actual);
}

/// <summary>
Expand Down Expand Up @@ -329,7 +329,7 @@ public static void AssertEqual<T>(this IObservable<T> actual, IObservable<T> exp
throw new ArgumentNullException(nameof(expected));
}

ReactiveAssert.AreElementsEqual(expected, actual);
AreElementsEqual(expected, actual);
}
}
}
6 changes: 3 additions & 3 deletions Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ReactiveTest
/// <returns>Recorded OnNext notification.</returns>
public static Recorded<Notification<T>> OnNext<T>(long ticks, T value)
{
return new Recorded<Notification<T>>(ticks, Notification.CreateOnNext<T>(value));
return new Recorded<Notification<T>>(ticks, Notification.CreateOnNext(value));
}

/// <summary>
Expand Down Expand Up @@ -188,7 +188,7 @@ public OnNextPredicate(Func<T, bool> predicate)

public override bool Equals(Notification<T> other)
{
if (Object.ReferenceEquals(this, other))
if (ReferenceEquals(this, other))
{
return true;
}
Expand Down Expand Up @@ -218,7 +218,7 @@ public OnErrorPredicate(Func<Exception, bool> predicate)

public override bool Equals(Notification<T> other)
{
if (Object.ReferenceEquals(this, other))
if (ReferenceEquals(this, other))
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override IDisposable ScheduleAbsolute<TState>(TState state, long dueTime,
dueTime = Clock + 1;
}

return base.ScheduleAbsolute<TState>(state, dueTime, action);
return base.ScheduleAbsolute(state, dueTime, action);
}

/// <summary>
Expand Down
9 changes: 4 additions & 5 deletions Rx.NET/Source/src/System.Reactive/Linq/Observable/Repeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal sealed class _ : IdentitySink<TResult>
{
private readonly TResult _value;

IDisposable _task;
private IDisposable _task;

public _(TResult value, IObserver<TResult> observer)
: base(observer)
Expand Down Expand Up @@ -127,9 +127,9 @@ internal sealed class _ : IdentitySink<TResult>
{
private readonly TResult _value;

int _remaining;
private int _remaining;

IDisposable _task;
private IDisposable _task;

public _(TResult value, int repeatCount, IObserver<TResult> observer)
: base(observer)
Expand Down Expand Up @@ -197,8 +197,7 @@ internal sealed class _ : IdentitySink<TResult>
{
private readonly TResult _value;

int _remaining;

private readonly int _remaining;
public _(TResult value, int remaining, IObserver<TResult> observer)
: base(observer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public ToObservableRecursive(IEnumerable<TSource> source, IScheduler scheduler)

internal sealed class _ : IdentitySink<TSource>
{
IEnumerator<TSource> _enumerator;
private IEnumerator<TSource> _enumerator;

volatile bool _disposed;
private volatile bool _disposed;

public _(IObserver<TSource> observer)
: base(observer)
Expand Down
6 changes: 3 additions & 3 deletions Rx.NET/Source/tests/Tests.System.Reactive/MockDisposable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ namespace ReactiveTests
{
public class MockDisposable : List<long>, IDisposable
{
private TestScheduler scheduler;
private TestScheduler _scheduler;

public MockDisposable(TestScheduler scheduler)
{
this.scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
this._scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
Add(scheduler.Clock);
}

public void Dispose()
{
Add(scheduler.Clock);
Add(_scheduler.Clock);
}
}
}
44 changes: 22 additions & 22 deletions Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public class MockEnumerable<T> : IEnumerable<T>
{
public readonly TestScheduler Scheduler;
public readonly List<Subscription> Subscriptions = new List<Subscription>();
private IEnumerable<T> underlyingEnumerable;
private IEnumerable<T> _underlyingEnumerable;

public MockEnumerable(TestScheduler scheduler, IEnumerable<T> underlyingEnumerable)
{
Scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
this.underlyingEnumerable = underlyingEnumerable ?? throw new ArgumentNullException(nameof(underlyingEnumerable));
this._underlyingEnumerable = underlyingEnumerable ?? throw new ArgumentNullException(nameof(underlyingEnumerable));
}

public IEnumerator<T> GetEnumerator()
{
return new MockEnumerator(Scheduler, Subscriptions, underlyingEnumerable.GetEnumerator());
return new MockEnumerator(Scheduler, Subscriptions, _underlyingEnumerable.GetEnumerator());
}

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
Expand All @@ -32,42 +32,42 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()

private class MockEnumerator : IEnumerator<T>
{
private readonly List<Subscription> subscriptions;
private IEnumerator<T> enumerator;
private TestScheduler scheduler;
private readonly int index;
private bool disposed = false;
private readonly List<Subscription> _subscriptions;
private IEnumerator<T> _enumerator;
private TestScheduler _scheduler;
private readonly int _index;
private bool _disposed;

public MockEnumerator(TestScheduler scheduler, List<Subscription> subscriptions, IEnumerator<T> enumerator)
{
this.subscriptions = subscriptions;
this.enumerator = enumerator;
this.scheduler = scheduler;
this._subscriptions = subscriptions;
this._enumerator = enumerator;
this._scheduler = scheduler;

index = subscriptions.Count;
_index = subscriptions.Count;
subscriptions.Add(new Subscription(scheduler.Clock));
}

public T Current
{
get
{
if (disposed)
if (_disposed)
{
throw new ObjectDisposedException("this");
}

return enumerator.Current;
return _enumerator.Current;
}
}

public void Dispose()
{
if (!disposed)
if (!_disposed)
{
disposed = true;
enumerator.Dispose();
subscriptions[index] = new Subscription(subscriptions[index].Subscribe, scheduler.Clock);
_disposed = true;
_enumerator.Dispose();
_subscriptions[_index] = new Subscription(_subscriptions[_index].Subscribe, _scheduler.Clock);
}
}

Expand All @@ -78,22 +78,22 @@ object System.Collections.IEnumerator.Current

public bool MoveNext()
{
if (disposed)
if (_disposed)
{
throw new ObjectDisposedException("this");
}

return enumerator.MoveNext();
return _enumerator.MoveNext();
}

public void Reset()
{
if (disposed)
if (_disposed)
{
throw new ObjectDisposedException("this");
}

enumerator.Reset();
_enumerator.Reset();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class DefaultSchedulerTest
[Fact]
public void Schedule_ArgumentChecking()
{
ReactiveAssert.Throws<ArgumentNullException>(() => DefaultScheduler.Instance.Schedule<int>(42, default));
ReactiveAssert.Throws<ArgumentNullException>(() => DefaultScheduler.Instance.Schedule<int>(42, DateTimeOffset.Now, default));
ReactiveAssert.Throws<ArgumentNullException>(() => DefaultScheduler.Instance.Schedule<int>(42, TimeSpan.Zero, default));
ReactiveAssert.Throws<ArgumentNullException>(() => DefaultScheduler.Instance.Schedule(42, default));
ReactiveAssert.Throws<ArgumentNullException>(() => DefaultScheduler.Instance.Schedule(42, DateTimeOffset.Now, default));
ReactiveAssert.Throws<ArgumentNullException>(() => DefaultScheduler.Instance.Schedule(42, TimeSpan.Zero, default));
ReactiveAssert.Throws<ArgumentNullException>(() => DefaultScheduler.Instance.SchedulePeriodic(42, TimeSpan.FromSeconds(1), default));
ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => DefaultScheduler.Instance.SchedulePeriodic(42, TimeSpan.FromSeconds(-1), _ => _));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public void EventLoop_ArgumentChecking()
#if !NO_THREAD
ReactiveAssert.Throws<ArgumentNullException>(() => new EventLoopScheduler(null));
#endif
ReactiveAssert.Throws<ArgumentNullException>(() => el.Schedule<int>(42, default));
ReactiveAssert.Throws<ArgumentNullException>(() => el.Schedule<int>(42, DateTimeOffset.Now, default));
ReactiveAssert.Throws<ArgumentNullException>(() => el.Schedule<int>(42, TimeSpan.Zero, default));
ReactiveAssert.Throws<ArgumentNullException>(() => el.Schedule(42, default));
ReactiveAssert.Throws<ArgumentNullException>(() => el.Schedule(42, DateTimeOffset.Now, default));
ReactiveAssert.Throws<ArgumentNullException>(() => el.Schedule(42, TimeSpan.Zero, default));
ReactiveAssert.Throws<ArgumentNullException>(() => el.SchedulePeriodic(42, TimeSpan.FromSeconds(1), default));
ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => el.SchedulePeriodic(42, TimeSpan.FromSeconds(-1), _ => _));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,32 @@ public void Immediate_ScheduleActionError()
[Fact]
public void Immediate_ArgumentChecking()
{
ReactiveAssert.Throws<ArgumentNullException>(() => Scheduler.Immediate.Schedule<int>(42, default));
ReactiveAssert.Throws<ArgumentNullException>(() => Scheduler.Immediate.Schedule<int>(42, DateTimeOffset.Now, default));
ReactiveAssert.Throws<ArgumentNullException>(() => Scheduler.Immediate.Schedule<int>(42, TimeSpan.Zero, default));
ReactiveAssert.Throws<ArgumentNullException>(() => Scheduler.Immediate.Schedule(42, default));
ReactiveAssert.Throws<ArgumentNullException>(() => Scheduler.Immediate.Schedule(42, DateTimeOffset.Now, default));
ReactiveAssert.Throws<ArgumentNullException>(() => Scheduler.Immediate.Schedule(42, TimeSpan.Zero, default));
}

[Fact]
public void Immediate_Simple1()
{
var _x = 0;
Scheduler.Immediate.Schedule<int>(42, (self, x) => { _x = x; return Disposable.Empty; });
Scheduler.Immediate.Schedule(42, (self, x) => { _x = x; return Disposable.Empty; });
Assert.Equal(42, _x);
}

[Fact]
public void Immediate_Simple2()
{
var _x = 0;
Scheduler.Immediate.Schedule<int>(42, DateTimeOffset.Now, (self, x) => { _x = x; return Disposable.Empty; });
Scheduler.Immediate.Schedule(42, DateTimeOffset.Now, (self, x) => { _x = x; return Disposable.Empty; });
Assert.Equal(42, _x);
}

[Fact]
public void Immediate_Simple3()
{
var _x = 0;
Scheduler.Immediate.Schedule<int>(42, TimeSpan.Zero, (self, x) => { _x = x; return Disposable.Empty; });
Scheduler.Immediate.Schedule(42, TimeSpan.Zero, (self, x) => { _x = x; return Disposable.Empty; });
Assert.Equal(42, _x);
}

Expand All @@ -85,7 +85,7 @@ public void Immediate_Recursive1()
{
var _x = 0;
var _y = 0;
Scheduler.Immediate.Schedule<int>(42, (self, x) => { _x = x; return self.Schedule<int>(43, (self2, y) => { _y = y; return Disposable.Empty; }); });
Scheduler.Immediate.Schedule(42, (self, x) => { _x = x; return self.Schedule(43, (self2, y) => { _y = y; return Disposable.Empty; }); });
Assert.Equal(42, _x);
Assert.Equal(43, _y);
}
Expand All @@ -95,7 +95,7 @@ public void Immediate_Recursive2()
{
var _x = 0;
var _y = 0;
Scheduler.Immediate.Schedule<int>(42, (self, x) => { _x = x; return self.Schedule<int>(43, DateTimeOffset.Now, (self2, y) => { _y = y; return Disposable.Empty; }); });
Scheduler.Immediate.Schedule(42, (self, x) => { _x = x; return self.Schedule(43, DateTimeOffset.Now, (self2, y) => { _y = y; return Disposable.Empty; }); });
Assert.Equal(42, _x);
Assert.Equal(43, _y);
}
Expand All @@ -105,7 +105,7 @@ public void Immediate_Recursive3()
{
var _x = 0;
var _y = 0;
Scheduler.Immediate.Schedule<int>(42, (self, x) => { _x = x; return self.Schedule<int>(43, TimeSpan.FromMilliseconds(100), (self2, y) => { _y = y; return Disposable.Empty; }); });
Scheduler.Immediate.Schedule(42, (self, x) => { _x = x; return self.Schedule(43, TimeSpan.FromMilliseconds(100), (self2, y) => { _y = y; return Disposable.Empty; }); });
Assert.Equal(42, _x);
Assert.Equal(43, _y);
}
Expand Down
Loading