Skip to content

Commit a5263d6

Browse files
Support more IAsyncEnumerable types in SignalR (#24926)
1 parent 1150b21 commit a5263d6

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/SignalR/common/Shared/ReflectionHelper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
#nullable disable
55

@@ -39,7 +39,10 @@ public static bool IsIAsyncEnumerable(Type type)
3939
{
4040
if (type.IsGenericType)
4141
{
42-
return type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>);
42+
if (type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>))
43+
{
44+
return true;
45+
}
4346
}
4447

4548
return type.GetInterfaces().Any(t =>

src/SignalR/server/SignalR/test/Internal/ReflectionHelperTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ async IAsyncEnumerable<int> Stream()
5757
typeof(CustomAsyncEnumerable),
5858
true
5959
};
60+
61+
yield return new object[]
62+
{
63+
typeof(CustomAsyncEnumerableOfT<object>),
64+
true
65+
};
6066
}
6167

6268
private class CustomAsyncEnumerable : IAsyncEnumerable<object>
@@ -66,5 +72,13 @@ public IAsyncEnumerator<object> GetAsyncEnumerator(CancellationToken cancellatio
6672
throw new NotImplementedException();
6773
}
6874
}
75+
76+
private class CustomAsyncEnumerableOfT<T> : IAsyncEnumerable<object>
77+
{
78+
public IAsyncEnumerator<object> GetAsyncEnumerator(CancellationToken cancellationToken = default)
79+
{
80+
throw new NotImplementedException();
81+
}
82+
}
6983
}
7084
}

0 commit comments

Comments
 (0)