Slow version of C# interpreter because modern JITs are too fast.
Web Playground
- 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.Run("" Console.WriteLine(""hello from inception""); "");");Can replace methods after parsing. This also affects already instantiated objects.
varr=CScript.CreateRunner(@"class Foo { public int GiveMeNumber() => 10; }");varfoo=r.Instantiate("Foo");// should be 10foo.Invoke("GiveMeNumber");ss.UpdateMethodsOnly(@"class Foo { public int GiveMeNumber() => 20; }");// should be 20foo.Invoke("GiveMeNumber");Supports virtual inheritance, this is useful with Unity.
classMyBehaviour:MonoBehaviour{publicvoidSayHello(){/* ... */}}// Error, MonoBehaviour cannot be instantiated by Unity's lawss.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 one derivered object.
// You can invoke methods from `MyBehaviour` which are defined in script-side.ss.Invoke("SayHello");// You can also invoke methods from `MonoBehaviour`ss.Invoke("StopAllCoroutines");Prevents malicious function call such as Threading and File.
varac=newAccessControl();ac.AddBlockedType("System.Threading.Thread");ac.AddBlockedNamespace("System.IO");newRunConfig(){accessControl=ac};Prevents long-running tasks with a timeout option.
newRunConfig(){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");vara=1234;Console.WriteLine(a);vara=4556;// redefination