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

@ -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 =>

View File

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