浏览代码

Fixes from code review - use CA(false) and use Array.Empty where available

Oren Novotny 9 年之前
父节点
当前提交
2e013c4d49

+ 10 - 7
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.Multiple.cs

@@ -442,7 +442,7 @@ namespace System.Linq
                 {
                     List<TInner> group;
 
-                    if (!await _outer.MoveNext(cancellationToken))
+                    if (!await _outer.MoveNext(cancellationToken).ConfigureAwait(false))
                     {
                         return false;
                     }
@@ -451,7 +451,7 @@ namespace System.Linq
                     {
                         _innerGroups = new Dictionary<TKey, List<TInner>>();
 
-                        while (await _inner.MoveNext(cancellationToken))
+                        while (await _inner.MoveNext(cancellationToken).ConfigureAwait(false))
                         {
                             var inner = _inner.Current;
                             var innerKey = _innerKeySelector(inner);
@@ -478,7 +478,13 @@ namespace System.Linq
                                 outerKey != null
                                 && _innerGroups.TryGetValue(outerKey, out group)
                                     ? (IEnumerable<TInner>)group
-                                    : EmptyEnumerable<TInner>.Instance));
+                                    :
+#if NO_ARRAY_EMPTY
+                                    EmptyArray<TInner>.Value
+#else
+                                    Array.Empty<TInner>()
+#endif
+                                    ));
 
                     return true;
                 }
@@ -491,10 +497,7 @@ namespace System.Linq
                     _outer.Dispose();
                 }
 
-                private sealed class EmptyEnumerable<TElement>
-                {
-                    public static readonly TElement[] Instance = new TElement[0];
-                }
+      
             }
         }
 

+ 15 - 0
Ix.NET/Source/System.Interactive.Async/EmptyArray.cs

@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+#if NO_ARRAY_EMPTY
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace System.Linq
+{
+    internal sealed class EmptyArray<TElement>
+    {
+        public static readonly TElement[] Value = new TElement[0];
+    }
+}
+#endif

+ 21 - 0
Ix.NET/Source/System.Interactive.Async/project.json

@@ -33,12 +33,33 @@
         "define": [
           "HAS_AWAIT",
           "HAS_APTCA",
+          "NO_ARRAY_EMPTY",
           "DESKTOPCLR",
           "DESKTOPCLR45"
         ]
       }
     },
+    "net46": {
+      "buildOptions": {
+        "define": [
+          "HAS_AWAIT",
+          "HAS_APTCA",
+          "DESKTOPCLR",
+          "DESKTOPCLR46"
+        ]
+      }
+    },
     "netstandard1.0": {
+      "buildOptions": {
+        "define": [
+          "HAS_AWAIT",
+          "NO_ARRAY_EMPTY",
+          "CRIPPLED_REFLECTION",
+          "PLIB"
+        ]
+      }
+    },
+    "netstandard1.3": {
       "buildOptions": {
         "define": [
           "HAS_AWAIT",