Slow version of C# interpreter because modern JITs are too fast.
- More Compatability: Brings C# scripting into WSA, iOS and WebAssembly.
- And nothing
- No manual assembly references
- No type or method binding
Even this can be possible:
CScript.Run(@"
CScript.RunSimple("" Console.WriteLine(""hello from inception""); "");
");
Can replace methods after parsing. This also affects already instantiated objects.
var r = CScript.CreateRunner(@"
class Foo { public int GiveMeNumber() => 10; }
");
var foo = r.Instantiate("Foo");
// should be 10
foo.Invoke("GiveMeNumber");
ss.UpdateMethodsOnly(@"
class Foo { public int GiveMeNumber() => 20; }
");
// should be 20
foo.Invoke("GiveMeNumber");
Supports virtual inheritance, this is useful with Unity.
class MyBehaviour : MonoBehaviour { /* ... */ }
// Error, MonoBehaviour cannot be instantiated by Unity's law
ss.Instantiate("MyBehaviour");
// Use this when you're not able to create an object yourself.
ss.Override("MyBehaviour", gameObject);
Finally, there will be two instances, but act as derivered one object.
var ac = new AccessControl();
ac.AddBlockedType("System.Threading.Thread");
ac.AddBlockedNamespace("System.IO");
new RunConfig() {
accessControl = ac
};
new RunConfig() {
timeout = 1000 /* ms */
};
Since SlowSharp is an interpreter, there're some differences and limitations.
Lazy semantic validation
SlowSharp does not validate whole syntaxs during the parse time. It only checks the overall form is valid or not.
As a result, some mistakes won't be detected until it's fully reached and executed.
Console.WriteLine("Hello");
// There's not method `WriteLn` in `Conosle` class.
// However, this will not throw an exception util SlowSharp actually
// evaluates the below line.
Console.WriteLn("World");
var a = 1234;
Console.WriteLine(a);
var a = 4556; // redefination