Remove use of GetRuntimeInterfaceMap in IsTypeAwaitable (#10572)
`GetRuntimeInterfaceMap` is a rather expensive API and it doesn't look like the use here is warranted. The replacement should have equivalent behavior.
This commit is contained in:
parent
d1138f2cde
commit
9cd2ad15ff
|
|
@ -74,10 +74,7 @@ namespace Microsoft.Extensions.Internal
|
||||||
}
|
}
|
||||||
|
|
||||||
// INotifyCompletion supplies a method matching "void OnCompleted(Action action)"
|
// INotifyCompletion supplies a method matching "void OnCompleted(Action action)"
|
||||||
var iNotifyCompletionMap = awaiterType
|
var onCompletedMethod = typeof(INotifyCompletion).GetRuntimeMethods().Single(m =>
|
||||||
.GetTypeInfo()
|
|
||||||
.GetRuntimeInterfaceMap(typeof(INotifyCompletion));
|
|
||||||
var onCompletedMethod = iNotifyCompletionMap.InterfaceMethods.Single(m =>
|
|
||||||
m.Name.Equals("OnCompleted", StringComparison.OrdinalIgnoreCase)
|
m.Name.Equals("OnCompleted", StringComparison.OrdinalIgnoreCase)
|
||||||
&& m.ReturnType == typeof(void)
|
&& m.ReturnType == typeof(void)
|
||||||
&& m.GetParameters().Length == 1
|
&& m.GetParameters().Length == 1
|
||||||
|
|
@ -89,10 +86,7 @@ namespace Microsoft.Extensions.Internal
|
||||||
if (implementsICriticalNotifyCompletion)
|
if (implementsICriticalNotifyCompletion)
|
||||||
{
|
{
|
||||||
// ICriticalNotifyCompletion supplies a method matching "void UnsafeOnCompleted(Action action)"
|
// ICriticalNotifyCompletion supplies a method matching "void UnsafeOnCompleted(Action action)"
|
||||||
var iCriticalNotifyCompletionMap = awaiterType
|
unsafeOnCompletedMethod = typeof(ICriticalNotifyCompletion).GetRuntimeMethods().Single(m =>
|
||||||
.GetTypeInfo()
|
|
||||||
.GetRuntimeInterfaceMap(typeof(ICriticalNotifyCompletion));
|
|
||||||
unsafeOnCompletedMethod = iCriticalNotifyCompletionMap.InterfaceMethods.Single(m =>
|
|
||||||
m.Name.Equals("UnsafeOnCompleted", StringComparison.OrdinalIgnoreCase)
|
m.Name.Equals("UnsafeOnCompleted", StringComparison.OrdinalIgnoreCase)
|
||||||
&& m.ReturnType == typeof(void)
|
&& m.ReturnType == typeof(void)
|
||||||
&& m.GetParameters().Length == 1
|
&& m.GetParameters().Length == 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue