Skip to content

Instantly share code, notes, and snippets.

@MikeCodesDotNET
Last active May 11, 2020 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeCodesDotNET/da64a67a7795ded857d8782b448bdbe4 to your computer and use it in GitHub Desktop.
Save MikeCodesDotNET/da64a67a7795ded857d8782b448bdbe4 to your computer and use it in GitHub Desktop.
private Script userScript;
private void CompileScript()
{
UpdateSource(); //Handles creating a copy of the script which includes variables the user never sees.
string text = csSource.Text; //csSource is an object from the UI provider
userScript = CSharpScript.Create(text, options: userScriptOptions);
userScript.Compile();
//Validation class
ScriptValidator scriptValidator = new ScriptValidator(userScript);
if(!scriptValidator.IsValid)
{
MessageBox.Show($"Found {scriptValidator.Errors.Count()} illegal APIs in script.", "Build Error");
userScript = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment