mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
throw if no parameterless constructor was found
This commit is contained in:
parent
c697d60609
commit
0529e2c921
1 changed files with 4 additions and 1 deletions
|
@ -74,7 +74,10 @@ namespace MLEM.Data {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static object Construct(Type t, BindingFlags flags) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue