浏览代码

AsyncEnumerable.ElementAtOrDefault*Async: Fix signature for nullable.

Daniel Weber 5 年之前
父节点
当前提交
91a2b87398

+ 3 - 3
Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs

@@ -1102,14 +1102,14 @@ namespace System.Linq
         
         private static MethodInfo? ElementAtOrDefaultAsync__TSource__3__0(Type TSource) =>
             (s_ElementAtOrDefaultAsync__TSource__3__0 ??
-            (s_ElementAtOrDefaultAsync__TSource__3__0 = new Func<IAsyncQueryable<object>, int, CancellationToken, ValueTask<object>>(ElementAtOrDefaultAsync<object>).GetMethodInfo()!.GetGenericMethodDefinition())).MakeGenericMethod(TSource);
+            (s_ElementAtOrDefaultAsync__TSource__3__0 = new Func<IAsyncQueryable<object>, int, CancellationToken, ValueTask<object?>>(ElementAtOrDefaultAsync<object>).GetMethodInfo()!.GetGenericMethodDefinition())).MakeGenericMethod(TSource);
 
-        public static ValueTask<TSource> ElementAtOrDefaultAsync<TSource>(this IAsyncQueryable<TSource> source, int index, CancellationToken cancellationToken = default)
+        public static ValueTask<TSource?> ElementAtOrDefaultAsync<TSource>(this IAsyncQueryable<TSource> source, int index, CancellationToken cancellationToken = default)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.Provider.ExecuteAsync<TSource>(Expression.Call(ElementAtOrDefaultAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
+            return source.Provider.ExecuteAsync<TSource?>(Expression.Call(ElementAtOrDefaultAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
         }
 
         private static MethodInfo? s_Except__TSource__2__0;

+ 3 - 3
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs

@@ -20,14 +20,14 @@ namespace System.Linq
         /// <returns>An async-enumerable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.</returns>
         /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
         /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than zero.</exception>
-        public static ValueTask<TSource> ElementAtOrDefaultAsync<TSource>(this IAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken = default)
+        public static ValueTask<TSource?> ElementAtOrDefaultAsync<TSource>(this IAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken = default)
         {
             if (source == null)
                 throw Error.ArgumentNull(nameof(source));
 
             return Core(source, index, cancellationToken);
 
-            static async ValueTask<TSource> Core(IAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken)
+            static async ValueTask<TSource?> Core(IAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken)
             {
                 if (source is IAsyncPartition<TSource> p)
                 {
@@ -62,7 +62,7 @@ namespace System.Linq
                     }
                 }
 
-                return default!;
+                return default;
             }
         }
     }