Implements accuracy/evasion

This commit is contained in:
2024-12-22 12:19:42 +01:00
parent 06ce7fd38d
commit 5b518df24a
7 changed files with 57 additions and 6 deletions

View File

@@ -43,9 +43,10 @@ public class ScriptRegistry
if (type == null)
throw new ArgumentNullException(nameof(type));
var constructor = type.GetConstructor(Type.EmptyTypes);
var constructor = type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
null, Type.EmptyTypes, null);
if (constructor == null)
throw new ArgumentException("The type must have a parameterless constructor.");
throw new ArgumentException($"Type {type} does not have a parameterless constructor.");
// We create a lambda that creates a new instance of the script type.
// This is more performant than using Activator.CreateInstance.