File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
System.Linq.Async.Tests/System/Linq/Operators
System.Linq.Async/System/Linq/Operators Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT License.
3- // See the LICENSE file in the project root for more information.
3+ // See the LICENSE file in the project root for more information.
44
55using System ;
66using System . Linq ;
@@ -40,5 +40,17 @@ public async Task OfType_String()
4040 await HasNextAsync ( e , "foo" ) ;
4141 await NoNextAsync ( e ) ;
4242 }
43+
44+ [ Fact ]
45+ public async Task OfType_NotNullObject ( )
46+ {
47+ var xs = new object ? [ ] { 42 , null , "foo" , null } . ToAsyncEnumerable ( ) ;
48+ var ys = xs . OfType < object > ( ) ;
49+
50+ var e = ys . GetAsyncEnumerator ( ) ;
51+ await HasNextAsync ( e , 42 ) ;
52+ await HasNextAsync ( e , "foo" ) ;
53+ await NoNextAsync ( e ) ;
54+ }
4355 }
4456}
Original file line number Diff line number Diff line change 11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT License.
3- // See the LICENSE file in the project root for more information.
3+ // See the LICENSE file in the project root for more information.
44
55using System . Collections . Generic ;
66using System . Threading ;
@@ -25,14 +25,14 @@ public static partial class AsyncEnumerable
2525 /// <param name="source">The async-enumerable sequence that contains the elements to be filtered.</param>
2626 /// <returns>An async-enumerable sequence that contains elements from the input sequence of type TResult.</returns>
2727 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
28- public static IAsyncEnumerable < TResult > OfType < TResult > ( this IAsyncEnumerable < object > source )
28+ public static IAsyncEnumerable < TResult > OfType < TResult > ( this IAsyncEnumerable < object ? > source )
2929 {
3030 if ( source == null )
3131 throw Error . ArgumentNull ( nameof ( source ) ) ;
3232
3333 return Core ( source ) ;
3434
35- static async IAsyncEnumerable < TResult > Core ( IAsyncEnumerable < object > source , [ System . Runtime . CompilerServices . EnumeratorCancellation ] CancellationToken cancellationToken = default )
35+ static async IAsyncEnumerable < TResult > Core ( IAsyncEnumerable < object ? > source , [ System . Runtime . CompilerServices . EnumeratorCancellation ] CancellationToken cancellationToken = default )
3636 {
3737 await foreach ( var obj in source . WithCancellation ( cancellationToken ) . ConfigureAwait ( false ) )
3838 {
You can’t perform that action at this time.
0 commit comments