Skip to content

Commit

Permalink
Merge pull request #1040 from dotnet/dev/bartde/rx_less_default_of_T
Browse files Browse the repository at this point in the history
Remove some uses of default(T)
  • Loading branch information
bartdesmet committed Sep 24, 2019
2 parents 6bcb54f + 3f0be4b commit d0c8d33
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 63 deletions.
32 changes: 16 additions & 16 deletions Rx.NET/Source/src/System.Reactive/Joins/Plan.cs
Expand Up @@ -58,7 +58,7 @@ internal Plan(Pattern<T1> expression, Func<T1, TResult> selector)
activePlan = new ActivePlan<T1>(firstJoinObserver,
first =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first);
Expand Down Expand Up @@ -104,7 +104,7 @@ internal Plan(Pattern<T1, T2> expression, Func<T1, T2, TResult> selector)
activePlan = new ActivePlan<T1, T2>(firstJoinObserver, secondJoinObserver,
(first, second) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second);
Expand Down Expand Up @@ -154,7 +154,7 @@ internal Plan(Pattern<T1, T2, T3> expression, Func<T1, T2, T3, TResult> selector
activePlan = new ActivePlan<T1, T2, T3>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
(first, second, third) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third);
Expand Down Expand Up @@ -207,7 +207,7 @@ internal class Plan<T1, T2, T3, T4, TResult> : Plan<TResult>
activePlan = new ActivePlan<T1, T2, T3, T4>(firstJoinObserver, secondJoinObserver, thirdJoinObserver, fourthJoinObserver,
(first, second, third, fourth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth);
Expand Down Expand Up @@ -263,7 +263,7 @@ internal class Plan<T1, T2, T3, T4, T5, TResult> : Plan<TResult>
activePlan = new ActivePlan<T1, T2, T3, T4, T5>(firstJoinObserver, secondJoinObserver, thirdJoinObserver, fourthJoinObserver, fifthJoinObserver,
(first, second, third, fourth, fifth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth);
Expand Down Expand Up @@ -323,7 +323,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, TResult> : Plan<TResult>
fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
(first, second, third, fourth, fifth, sixth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth);
Expand Down Expand Up @@ -386,7 +386,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, TResult> : Plan<TResult>
fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh);
Expand Down Expand Up @@ -452,7 +452,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, TResult> : Plan<TResult>
fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth);
Expand Down Expand Up @@ -521,7 +521,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> : Plan<TResult>
fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth);
Expand Down Expand Up @@ -593,7 +593,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> : Plan<TRe
fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
Expand Down Expand Up @@ -669,7 +669,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> : Pla
fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh);
Expand Down Expand Up @@ -749,7 +749,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>
twelfthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth);
Expand Down Expand Up @@ -833,7 +833,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TRes
twelfthJoinObserver, thirteenthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth);
Expand Down Expand Up @@ -924,7 +924,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
fourteenthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth);
Expand Down Expand Up @@ -1017,7 +1017,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
fourteenthJoinObserver, fifteenthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth);
Expand Down Expand Up @@ -1113,7 +1113,7 @@ internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
sixteenthJoinObserver,
(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth) =>
{
var result = default(TResult);
TResult result;
try
{
result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth);
Expand Down
Expand Up @@ -187,7 +187,7 @@ public override void OnError(Exception error)

public override void OnCompleted()
{
var result = default(TResult);
TResult result;
try
{
result = _resultSelector(_accumulation);
Expand Down
2 changes: 1 addition & 1 deletion Rx.NET/Source/src/System.Reactive/Linq/Observable/Cast.cs
Expand Up @@ -26,7 +26,7 @@ public _(IObserver<TResult> observer)

public override void OnNext(TSource value)
{
var result = default(TResult);
TResult result;
try
{
result = (TResult)(object)value;
Expand Down
Expand Up @@ -92,7 +92,7 @@ public void OnNext(TFirst value)

if (_other.HasValue)
{
var res = default(TResult);
TResult res;
try
{
res = _parent._resultSelector(value, _other.Value);
Expand Down Expand Up @@ -163,7 +163,7 @@ public void OnNext(TSecond value)

if (_other.HasValue)
{
var res = default(TResult);
TResult res;
try
{
res = _parent._resultSelector(_other.Value, value);
Expand Down Expand Up @@ -262,7 +262,7 @@ public void Next(int index)

if (_hasValueAll)
{
var res = default(TResult);
TResult res;
try
{
res = GetResult();
Expand Down Expand Up @@ -450,7 +450,7 @@ private void OnNext(int index, TSource value)

if (_hasValueAll || (_hasValueAll = _hasValue.All()))
{
var res = default(TResult);
TResult res;
try
{
res = _resultSelector(new ReadOnlyCollection<TSource>(_values));
Expand Down
Expand Up @@ -37,7 +37,7 @@ public _(Distinct<TSource, TKey> parent, IObserver<TSource> observer)

public override void OnNext(TSource value)
{
var key = default(TKey);
TKey key;
var hasAdded = false;
try
{
Expand Down
Expand Up @@ -40,7 +40,7 @@ public _(DistinctUntilChanged<TSource, TKey> parent, IObserver<TSource> observer

public override void OnNext(TSource value)
{
var key = default(TKey);
TKey key;
try
{
key = _keySelector(value);
Expand Down
Expand Up @@ -175,7 +175,7 @@ public FromEvent(Func<Action<TEventArgs>, TDelegate> conversion, Action<TDelegat

protected override TDelegate GetHandler(Action<TEventArgs> onNext)
{
var handler = default(TDelegate);
TDelegate handler;

if (_conversion == null)
{
Expand Down
Expand Up @@ -32,7 +32,7 @@ public Impl(Func<EventHandler<TEventArgs>, TDelegate> conversion, Action<TDelega

protected override TDelegate GetHandler(Action<EventPattern<TEventArgs>> onNext)
{
var handler = default(TDelegate);
TDelegate handler;

if (_conversion == null)
{
Expand Down
4 changes: 2 additions & 2 deletions Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupBy.cs
Expand Up @@ -65,7 +65,7 @@ public override void Run(IObservable<TSource> source)

public override void OnNext(TSource value)
{
var key = default(TKey);
TKey key;
try
{
key = _keySelector(value);
Expand Down Expand Up @@ -130,7 +130,7 @@ public override void OnNext(TSource value)
ForwardOnNext(group);
}

var element = default(TElement);
TElement element;
try
{
element = _elementSelector(value);
Expand Down
Expand Up @@ -74,7 +74,7 @@ private ISubject<TElement> NewSubject()

public override void OnNext(TSource value)
{
var key = default(TKey);
TKey key;
try
{
key = _keySelector(value);
Expand Down Expand Up @@ -148,7 +148,7 @@ public override void OnNext(TSource value)
durationObserver.SetResource(duration.SubscribeSafe(durationObserver));
}

var element = default(TElement);
TElement element;
try
{
element = _elementSelector(value);
Expand Down
Expand Up @@ -124,7 +124,7 @@ public override void OnNext(TLeft value)
// BREAKING CHANGE v2 > v1.x - The duration sequence is subscribed to before the result sequence is evaluated.
durationObserver.SetResource(duration.SubscribeSafe(durationObserver));

var result = default(TResult);
TResult result;
try
{
result = _parent._resultSelector(value, window);
Expand Down
4 changes: 2 additions & 2 deletions Rx.NET/Source/src/System.Reactive/Linq/Observable/Join.cs
Expand Up @@ -123,7 +123,7 @@ public override void OnNext(TLeft value)
{
if (rightValue.Key < rightID)
{
var result = default(TResult);
TResult result;
try
{
result = _parent._resultSelector(value, rightValue.Value);
Expand Down Expand Up @@ -246,7 +246,7 @@ public override void OnNext(TRight value)
{
if (leftValue.Key < leftID)
{
var result = default(TResult);
TResult result;
try
{
result = _parent._resultSelector(leftValue.Value, value);
Expand Down
2 changes: 1 addition & 1 deletion Rx.NET/Source/src/System.Reactive/Linq/Observable/MaxBy.cs
Expand Up @@ -42,7 +42,7 @@ public _(MaxBy<TSource, TKey> parent, IObserver<IList<TSource>> observer)

public override void OnNext(TSource value)
{
var key = default(TKey);
TKey key;
try
{
key = _keySelector(value);
Expand Down
2 changes: 1 addition & 1 deletion Rx.NET/Source/src/System.Reactive/Linq/Observable/MinBy.cs
Expand Up @@ -42,7 +42,7 @@ public _(MinBy<TSource, TKey> parent, IObserver<IList<TSource>> observer)

public override void OnNext(TSource value)
{
var key = default(TKey);
TKey key;
try
{
key = _keySelector(value);
Expand Down
4 changes: 2 additions & 2 deletions Rx.NET/Source/src/System.Reactive/Linq/Observable/Select.cs
Expand Up @@ -33,7 +33,7 @@ public _(Func<TSource, TResult> selector, IObserver<TResult> observer)

public override void OnNext(TSource value)
{
var result = default(TResult);
TResult result;
try
{
result = _selector(value);
Expand Down Expand Up @@ -77,7 +77,7 @@ public _(Func<TSource, int, TResult> selector, IObserver<TResult> observer)

public override void OnNext(TSource value)
{
var result = default(TResult);
TResult result;
try
{
result = _selector(value, checked(_index++));
Expand Down
Expand Up @@ -121,7 +121,7 @@ public InnerObserver(_ parent, TSource value)

public override void OnNext(TCollection value)
{
var res = default(TResult);
TResult res;

try
{
Expand Down Expand Up @@ -288,7 +288,7 @@ public InnerObserver(_ parent, TSource value, int index)

public override void OnNext(TCollection value)
{
var res = default(TResult);
TResult res;

try
{
Expand Down Expand Up @@ -598,7 +598,7 @@ private void OnCompletedTask(TSource value, Task<TCollection> task)
{
case TaskStatus.RanToCompletion:
{
var res = default(TResult);
TResult res;
try
{
res = _resultSelector(value, task.Result);
Expand Down Expand Up @@ -755,7 +755,7 @@ private void OnCompletedTask(TSource value, int index, Task<TCollection> task)
{
case TaskStatus.RanToCompletion:
{
var res = default(TResult);
TResult res;
try
{
res = _resultSelector(value, index, task.Result);
Expand Down
Expand Up @@ -99,7 +99,7 @@ public void OnNext(TFirst value)
latest = _parent._latest;
}

var res = default(TResult);
TResult res;

try
{
Expand Down

0 comments on commit d0c8d33

Please sign in to comment.