diff --git a/src/SignalR/common/Shared/ReflectionHelper.cs b/src/SignalR/common/Shared/ReflectionHelper.cs index 93b613f840..61372141b0 100644 --- a/src/SignalR/common/Shared/ReflectionHelper.cs +++ b/src/SignalR/common/Shared/ReflectionHelper.cs @@ -1,5 +1,5 @@ // Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. #nullable disable @@ -39,7 +39,10 @@ namespace Microsoft.AspNetCore.SignalR { if (type.IsGenericType) { - return type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>); + if (type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>)) + { + return true; + } } return type.GetInterfaces().Any(t => diff --git a/src/SignalR/server/SignalR/test/Internal/ReflectionHelperTests.cs b/src/SignalR/server/SignalR/test/Internal/ReflectionHelperTests.cs index 3602555539..45e4953dfd 100644 --- a/src/SignalR/server/SignalR/test/Internal/ReflectionHelperTests.cs +++ b/src/SignalR/server/SignalR/test/Internal/ReflectionHelperTests.cs @@ -57,6 +57,12 @@ namespace Microsoft.AspNetCore.SignalR.Tests.Internal typeof(CustomAsyncEnumerable), true }; + + yield return new object[] + { + typeof(CustomAsyncEnumerableOfT), + true + }; } private class CustomAsyncEnumerable : IAsyncEnumerable @@ -66,5 +72,13 @@ namespace Microsoft.AspNetCore.SignalR.Tests.Internal throw new NotImplementedException(); } } + + private class CustomAsyncEnumerableOfT : IAsyncEnumerable + { + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + { + throw new NotImplementedException(); + } + } } }