SignalR Hub convention test

While implementing SignalR controller you have to keep in your mind that method overloading inside the Hub works... suddenly not as we expect.
Let's consider example of Hub a implementation:

public class TestHub : Hub  
  public void Send(MessageA message){ ... }
  public void Send(MessageB message){ ... }

We can try to call our server-side methods from the browser using:

    $.connection.testHub.send({"Field" : "test"});

Unfortunetely, neither of two previously declared method will be called (which is also weird, I supposed that last declared will be called actually).

To implement methods with same names we need to declare methods with a different number of parameters

So briefly speaking, method overloading does not work at all, and fails very silently. I came up with an idea to create a convention test that will find that kind of situation. So how can we find it? We need to scan assemblies for classes that derive from Hub, iterate through metods checking for duplicates.

static IEnumerable<Type> Test(){  
//find classes derived from Hub
  var hubs = AppDomain.CurrentDomain
                      .SelectMany(domainAssembly => 
                              .Where(assemblyType =>  typeof(Microsoft.AspNet.SignalR.Hub).IsAssignableFrom(assemblyType))

//return those types which have methods with same name and same number of params
 return hubs.Where(hub => 
                      .GroupBy(method => method.GetParameters().Count() + method.Name)
                      .Any(grouping => grouping.Count() > 1)

Full code with the sample usage can be found here.

Hope you have enjoyed!