private static string GetScriptContent(ScriptFileManifest script) { var sb = new StringBuilder(); sb.AppendLine($"#line 1 \"{script.Path}\""); sb.AppendLine(script.ScriptContent); var scriptContent = sb.ToString(); return(scriptContent); }
public static TReturnType Execute <TReturnType, TGlobalsType>(ScriptFileManifest script, TGlobalsType globals) { var scriptContent = GetScriptContent(script); var compilation = CreateCompilation <TGlobalsType>(scriptContent); var rawAssemblyResult = RawAssembly(compilation); var assembly = Assembly.Load(rawAssemblyResult.RawAssembly, rawAssemblyResult.RawSymbol); var entryPoint = GetEntryPointFromAssembly(assembly); var result = ExecuteEntryPoint(globals, entryPoint); if (result is TReturnType castedResult) { return(castedResult); } return(default(TReturnType)); }