Support more IAsyncEnumerable types in SignalR (#24926)

This commit is contained in:
Brennan 2020-08-14 20:42:05 -07:00 committed by GitHub
parent 1150b211cc
commit a5263d61fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -39,7 +39,10 @@ namespace Microsoft.AspNetCore.SignalR
{ {
if (type.IsGenericType) if (type.IsGenericType)
{ {
return type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>); if (type.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>))
{
return true;
}
} }
return type.GetInterfaces().Any(t => return type.GetInterfaces().Any(t =>

View File

@ -57,6 +57,12 @@ namespace Microsoft.AspNetCore.SignalR.Tests.Internal
typeof(CustomAsyncEnumerable), typeof(CustomAsyncEnumerable),
true true
}; };
yield return new object[]
{
typeof(CustomAsyncEnumerableOfT<object>),
true
};
} }
private class CustomAsyncEnumerable : IAsyncEnumerable<object> private class CustomAsyncEnumerable : IAsyncEnumerable<object>
@ -66,5 +72,13 @@ namespace Microsoft.AspNetCore.SignalR.Tests.Internal
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
private class CustomAsyncEnumerableOfT<T> : IAsyncEnumerable<object>
{
public IAsyncEnumerator<object> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
}
} }
} }