Skip to content

Instantly share code, notes, and snippets.

@lemmit
Last active February 19, 2016 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lemmit/1af0289a30021e31da92 to your computer and use it in GitHub Desktop.
Save lemmit/1af0289a30021e31da92 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.SignalR;
namespace SignalRHubConvetionTest
{
class GoodHub : Hub
{
}
class BadHub : Hub
{
public string Method(string heh)
{
return "A";
}
public string Method(int heh)
{
return "A";
}
public string Method(int heh, string hehe)
{
return "A";
}
}
class Program
{
static void Main(string[] args)
{
var failedHubs = Test();
foreach (var hub in failedHubs)
{
Console.WriteLine(hub.Name);
}
Console.WriteLine(!failedHubs.Any() ? "Test OK" : "Test Failed");
}
static IEnumerable<Type> Test()
{
var hubs = AppDomain
.CurrentDomain
.GetAssemblies()
.SelectMany(domainAssembly =>
domainAssembly
.GetTypes()
.Where(assemblyType =>
typeof(Microsoft.AspNet.SignalR.Hub).IsAssignableFrom(assemblyType))
);
return hubs.Where(hub =>
hub.GetMethods()
.GroupBy(method => method.GetParameters().Count() + method.Name)
.Any(grouping => grouping.Count() > 1)
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment