瀏覽代碼

Merge pull request #1334 from dotnet/dev/bartde/selectmany_checked_onerror

Propagate OverflowException in SelectMany via OnError.
Bart J.F. De Smet 5 年之前
父節點
當前提交
c4b8a8b511
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs

+ 6 - 3
Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs

@@ -209,11 +209,12 @@ namespace System.Reactive.Linq.ObservableImpl
 
                 public override void OnNext(TSource value)
                 {
-                    var index = checked(_index++);
+                    int index;
                     IObservable<TCollection> collection;
 
                     try
                     {
+                        index = checked(_index++);
                         collection = _collectionSelector(value, index);
                     }
                     catch (Exception ex)
@@ -457,11 +458,12 @@ namespace System.Reactive.Linq.ObservableImpl
 
                 public override void OnNext(TSource value)
                 {
-                    var index = checked(_index++);
+                    int index;
 
                     IEnumerable<TCollection> xs;
                     try
                     {
+                        index = checked(_index++);
                         xs = _collectionSelector(value, index);
                     }
                     catch (Exception exception)
@@ -721,11 +723,12 @@ namespace System.Reactive.Linq.ObservableImpl
 
                 public override void OnNext(TSource value)
                 {
-                    var index = checked(_index++);
+                    int index;
 
                     Task<TCollection> task;
                     try
                     {
+                        index = checked(_index++);
                         Interlocked.Increment(ref _count);
                         task = _collectionSelector(value, index, _cancel.Token);
                     }