Skip to content

Commit ab88958

Browse files
Merge pull request #1617 from amis92/fix/1525-oftype-nullability
2 parents 4f841af + 3ad0032 commit ab88958

File tree

2 files changed

+16
-4
lines changed
  • Ix.NET/Source
    • System.Linq.Async.Tests/System/Linq/Operators
    • System.Linq.Async/System/Linq/Operators

2 files changed

+16
-4
lines changed

Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

55
using System;
66
using 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
}

Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

55
using System.Collections.Generic;
66
using 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
{

0 commit comments

Comments
 (0)