in src/Google.Cloud.Functions.Hosting/HostingInternals.cs [279:286]
private static Type? GetGenericInterfaceImplementationTypeArgument(Type target, Type genericInterface)
{
var matches = target.GetInterfaces()
.Where(iface => iface.IsGenericType && iface.GetGenericTypeDefinition() == genericInterface);
// We only want to return an unambiguous match. Note that this will evaluate the list twice in the "got one" case,
// but that's okay.
return matches.Count() == 1 ? matches.Single().GetGenericArguments()[0] : null;
}