Ignore static constructors when creating types

This commit is contained in:
Finite Reality
2016-07-27 21:40:45 +01:00
parent dd0d94645e
commit 2f0881460c

View File

@@ -8,7 +8,7 @@ namespace Discord.Commands
{ {
internal static object CreateObject(TypeInfo typeInfo, CommandService service, IDependencyMap map = null) internal static object CreateObject(TypeInfo typeInfo, CommandService service, IDependencyMap map = null)
{ {
var constructors = typeInfo.DeclaredConstructors.ToArray(); var constructors = typeInfo.DeclaredConstructors.Where(x => !x.IsStatic).ToArray();
if (constructors.Length == 0) if (constructors.Length == 0)
throw new InvalidOperationException($"No constructor found for \"{typeInfo.FullName}\""); throw new InvalidOperationException($"No constructor found for \"{typeInfo.FullName}\"");
else if (constructors.Length > 1) else if (constructors.Length > 1)