1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-28 19:13:38 +02:00

throw if no parameterless constructor was found

This commit is contained in:
Ellpeck 2020-07-31 20:58:25 +02:00
parent c697d60609
commit 0529e2c921

View file

@ -74,7 +74,10 @@ namespace MLEM.Data {
}
private static object Construct(Type t, BindingFlags flags) {
return t.GetConstructor(flags, null, Type.EmptyTypes, null).Invoke(null);
var constructor = t.GetConstructor(flags, null, Type.EmptyTypes, null);
if (constructor == null)
throw new NullReferenceException($"Type {t} does not have a parameterless constructor with the required visibility");
return constructor.Invoke(null);
}
}