void RemoveMultipleUsings() { string usingString = "using UnityEngine.Advertisements;using UnityEngine.UI;using UnityEngine;"; _engine.RemoveUsings(usingString); Assert.IsTrue(_engine.AllUsings.Count == 0 && _engine.AllReferencedAssemblies.Count == 1); }
//------------------------------------------------------------------------------------------------- //Removes usings from system, so it's namespace resources become inaccessible for dynamic code void RemoveUsings() { CSScriptEngine engine = new CSScriptEngine(); engine.AddOnCompilationFailedHandler(OnCompilationFailedAction); engine.AddUsings("using SomeCustomNamespace;"); engine.CompileCode("HeyPrinter hp = new HeyPrinter(); hp.PrintHey();").Execute(); engine.RemoveUsings("using SomeCustomNamespace;"); //Now this will result in error engine.CompileCode("HeyPrinter hp = new HeyPrinter(); hp.PrintHey();"); engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction); }