예제 #1
0
        public static bool CompileProgram(string program, List <string> errors, ref Assembly assembly)
        {
#if !XB1
            if (!string.IsNullOrEmpty(program))
            {
                if (MyFakes.ENABLE_ROSLYN_SCRIPTS)
                {
                    var messageList = new List <MyScriptCompiler.Message>();
                    assembly = MyScriptCompiler.Static.Compile(
                        MyApiTarget.Ingame,
                        Path.Combine(MyFileSystem.UserDataPath, "EditorCode.dll"),
                        MyScriptCompiler.Static.GetIngameScript(program, "Program", typeof(MyGridProgram).Name),
                        messageList).Result;
                    errors.Clear();
                    errors.AddRange(messageList.OrderByDescending(m => m.Severity).Select(m => m.Text));

                    return(assembly != null);
                }

                string finalCode = CODE_WRAPPER_BEFORE + program + CODE_WRAPPER_AFTER;
                if (true == IlCompiler.CompileStringIngame(Path.Combine(MyFileSystem.UserDataPath, "IngameScript.dll"), new string[] { finalCode }, out assembly, errors))
                {
                    return(true);
                }
            }
#else // XB1
            System.Diagnostics.Debug.Assert(false, "No scripts on XB1");
#endif // XB1
            return(false);
        }
예제 #2
0
 public static bool CompileProgram(string program, List <string> errors, ref Assembly assembly)
 {
     if (program != null && program.Length > 0)
     {
         string finalCode = CODE_WRAPPER_BEFORE + program + CODE_WRAPPER_AFTER;
         if (true == IlCompiler.CompileStringIngame("IngameScript.dll", new string[] { finalCode }, out assembly, errors))
         {
             return(true);
         }
     }
     return(false);
 }