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 1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// 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.
4
4
5
5
using System ;
6
6
using System . Linq ;
@@ -40,5 +40,17 @@ public async Task OfType_String()
40
40
await HasNextAsync ( e , "foo" ) ;
41
41
await NoNextAsync ( e ) ;
42
42
}
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
+ }
43
55
}
44
56
}
Original file line number Diff line number Diff line change 1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// 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.
4
4
5
5
using System . Collections . Generic ;
6
6
using System . Threading ;
@@ -25,14 +25,14 @@ public static partial class AsyncEnumerable
25
25
/// <param name="source">The async-enumerable sequence that contains the elements to be filtered.</param>
26
26
/// <returns>An async-enumerable sequence that contains elements from the input sequence of type TResult.</returns>
27
27
/// <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 )
29
29
{
30
30
if ( source == null )
31
31
throw Error . ArgumentNull ( nameof ( source ) ) ;
32
32
33
33
return Core ( source ) ;
34
34
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 )
36
36
{
37
37
await foreach ( var obj in source . WithCancellation ( cancellationToken ) . ConfigureAwait ( false ) )
38
38
{
You can’t perform that action at this time.
0 commit comments