Skip to content

Commit c12149e

Browse files
authored
Backport fix on IAsyncEnumerable from 5.0 to 3.1 (https://github.com/dotnet/aspnetcore/pull/24926/files) (#25177)
1 parent 080565b commit c12149e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/SignalR/common/Shared/ReflectionHelper.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ public static bool IsIAsyncEnumerable(Type type)
3737
{
3838
if (type.IsGenericType)
3939
{
40-
return type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>);
40+
if (type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>))
41+
{
42+
return true;
43+
}
4144
}
4245

4346
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)