public static Assembly assembly(this CSharp_FastCompiler csharpCompiler) { if (csharpCompiler != null) { if (csharpCompiler.compiledAssembly().notNull()) { return(csharpCompiler.compiledAssembly()); } if (csharpCompiler.compilerResults() != null) { if (csharpCompiler.compilerResults().Errors.HasErrors == false) { if (csharpCompiler.compilerResults().CompiledAssembly != null) { return(csharpCompiler.compilerResults().CompiledAssembly); } } else { "CompilationErrors:".line().add(csharpCompiler.compilationErrors()).error(); } } } return(null); }
public void loadH2Script(string scriptToLoad) { O2Thread.mtaThread(() => { if (scriptToLoad.fileName().starts(this.typeName())) { PublicDI.log.error("We can execute the current type of we will get a recursive load :)"); return; } currentScript = scriptToLoad; statusLabel.set_Text("loading script: {0}".format(scriptToLoad.fileName())); csharpCompiler = new CSharp_FastCompiler(); csharpCompiler.set_OnAstFail(() => { showError("Ast creation failed", csharpCompiler.astErrors()); csharpCompiler_OnAstFail.invoke(); }); csharpCompiler.set_OnAstOK(() => { showInfo("Ast creation Ok"); csharpCompiler_OnAstOk.invoke(); }); csharpCompiler.set_OnCompileFail(() => { showError("Compilation failed", csharpCompiler.compilationErrors()); csharpCompiler_OnCompileFail.invoke(); }); csharpCompiler.set_OnCompileOK(() => { showInfo("Compilation Ok: Executing 1st method"); csharpCompiler_OnCompileOk.invoke(); executeCompiledCode(); }); var sourceCode = ""; PublicDI.CurrentScript = scriptToLoad; csharpCompiler.CompilerOptions.SourceCodeFile = scriptToLoad; if (scriptToLoad.extension(".h2")) { sourceCode = H2.load(scriptToLoad).SourceCode; } if (scriptToLoad.extension(".o2") || scriptToLoad.extension(".cs")) { sourceCode = scriptToLoad.contents(); } if (sourceCode.valid()) { csharpCompiler.compileSnippet(sourceCode); } else { statusLabel.set_Text("Non supported file").textColor(this, Color.Red); } }); }
public void Main_O2_Gui_h2() { //CompileEngine.clearLocalScriptFileMappings(); var scriptName = "Main O2 Gui.h2"; // this is the script used in ascx_Execute_Scripts.NEW_GUI_SCRIPT var file = scriptName.local(); var h2Code = file.h2_SourceCode(); //compile using internal methods var csharpCode = new CSharp_FastCompiler().createCSharpCodeWith_Class_Method_WithMethodText(h2Code); assert_Not_Null(scriptName); assert_Not_Null(file); assert_Not_Null(h2Code); assert_Not_Null(csharpCode); csharpCode.assert_Contains("public class", "DynamicType", "{", "}") .assert_Contains("using System;", "System.Linq;") .assert_Contains("FluentSharp.REPL.Utils"); var compileEngine = new CompileEngine(); var assembly = compileEngine.compileSourceCode(csharpCode); assert_Is_Null(compileEngine.sbErrorMessage); assert_Not_Null(assembly); //check that we can also compile using the main wrapper methods assert_Not_Null(file.compile_H2Script()); }
public static CSharp_FastCompiler compilerResults(this CSharp_FastCompiler csharpCompiler, CompilerResults compilerResults) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerArtifacts.CompilerResults = compilerResults; } return(csharpCompiler); }
public static CSharp_FastCompiler compiledAssembly(this CSharp_FastCompiler csharpCompiler, Assembly assembly) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerArtifacts.CompiledAssembly = assembly; } return(csharpCompiler); }
public static CSharp_FastCompiler compilationUnit(this CSharp_FastCompiler csharpCompiler, CompilationUnit value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerArtifacts.CompilationUnit = value; } return(csharpCompiler); }
public static CSharp_FastCompiler debugMode(this CSharp_FastCompiler csharpCompiler, bool value) { if (csharpCompiler.notNull()) { csharpCompiler.DebugMode = value; } return(csharpCompiler); }
public static CSharp_FastCompiler compilationVersion(this CSharp_FastCompiler csharpCompiler, string value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerOptions.CompilationVersion = value; } return(csharpCompiler); }
public static CSharp_FastCompiler resolveInvocationParametersType(this CSharp_FastCompiler csharpCompiler, bool value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerOptions.ResolveInvocationParametersType = value; } return(csharpCompiler); }
public static CSharp_FastCompiler astDetails(this CSharp_FastCompiler csharpCompiler, AstDetails value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerArtifacts.AstDetails = value; } return(csharpCompiler); }
public static CSharp_FastCompiler raise_BeforeSnippetAst(this CSharp_FastCompiler csharpCompiler) { if (csharpCompiler.events().notNull()) { csharpCompiler.events().BeforeSnippetAst.invoke(); } return(csharpCompiler); }
public static CSharp_FastCompiler set_OnCompileOK(this CSharp_FastCompiler csharpCompiler, Action action) { if (csharpCompiler.events().notNull()) { csharpCompiler.events().OnCompileOK = action; } return(csharpCompiler); }
public static CSharp_FastCompiler invocationParameters(this CSharp_FastCompiler csharpCompiler, Dictionary <string, object> invocationParameters) { if (csharpCompiler.notNull()) { csharpCompiler.ExecutionOptions.InvocationParameters = invocationParameters; } return(csharpCompiler); }
public static CSharp_FastCompiler default_MethodName(this CSharp_FastCompiler csharpCompiler, string value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerOptions.default_MethodName = value; } return(csharpCompiler); }
public static CSharp_FastCompiler generateDebugSymbols(this CSharp_FastCompiler csharpCompiler, bool value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerOptions.generateDebugSymbols = value; } return(csharpCompiler); }
public static CSharp_FastCompiler createdFromSnippet(this CSharp_FastCompiler csharpCompiler, bool value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerArtifacts.CreatedFromSnippet = value; } return(csharpCompiler); }
public static CSharp_FastCompiler compilationErrors(this CSharp_FastCompiler csharpCompiler, string value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerArtifacts.CompilationErrors = value; } return(csharpCompiler); }
public static CSharp_FastCompiler useCachedAssemblyIfAvailable(this CSharp_FastCompiler csharpCompiler, bool value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerOptions.UseCachedAssemblyIfAvailable = value; } return(csharpCompiler); }
public static CSharp_FastCompiler sourceCodeFile(this CSharp_FastCompiler csharpCompiler, string value) { if (csharpCompiler.notNull()) { csharpCompiler.CompilerOptions.SourceCodeFile = value; } return(csharpCompiler); }
public static CSharp_FastCompiler raise_OnCompileOK(this CSharp_FastCompiler csharpCompiler) { if (csharpCompiler.events().notNull()) { csharpCompiler.events().OnCompileOK.invoke(); } return(csharpCompiler); }
public static CSharp_FastCompiler set_BeforeSnippetAst(this CSharp_FastCompiler csharpCompiler, Action action) { if (csharpCompiler.events().notNull()) { csharpCompiler.events().BeforeSnippetAst = action; } return(csharpCompiler); }
public static Assembly compile(this string pathToFileToCompile, bool generateDebugSymbols) { PublicDI.CurrentScript = pathToFileToCompile; var csharpCompiler = new CSharp_FastCompiler().generateDebugSymbols(generateDebugSymbols); var compileProcess = new AutoResetEvent(false); csharpCompiler.set_OnCompileFail(() => compileProcess.Set()); csharpCompiler.set_OnCompileOK(() => compileProcess.Set()); O2Thread.mtaThread(() => csharpCompiler.compileSourceCode(pathToFileToCompile.contents())); compileProcess.WaitOne(); return(csharpCompiler.assembly()); }
public static Assembly compile(this string pathToFileToCompile, bool generateDebugSymbols) { PublicDI.CurrentScript = pathToFileToCompile; var csharpCompiler = new CSharp_FastCompiler(); csharpCompiler.generateDebugSymbols = generateDebugSymbols; var compileProcess = new System.Threading.AutoResetEvent(false); csharpCompiler.compileSourceCode(pathToFileToCompile.contents()); csharpCompiler.onCompileFail = () => compileProcess.Set(); csharpCompiler.onCompileOK = () => compileProcess.Set(); compileProcess.WaitOne(); return(csharpCompiler.assembly()); }
public static Assembly compile_CodeSnippet(this string codeSnipptet, bool generateDebugSymbols) { //Note we can't use the precompiled engines here since there is an issue of the resolution of this code dependencies var csharpCompiler = new CSharp_FastCompiler().debugMode(true) .generateDebugSymbols(generateDebugSymbols); var compileProcess = new AutoResetEvent(false); csharpCompiler.set_OnAstFail(() => compileProcess.Set()); csharpCompiler.set_OnCompileFail(() => compileProcess.Set()); csharpCompiler.set_OnCompileOK(() => compileProcess.Set()); csharpCompiler.compileSnippet(codeSnipptet); compileProcess.WaitOne(); var assembly = csharpCompiler.assembly(); return(assembly); }
public static Assembly compile_CodeSnippet(this string codeSnipptet, bool generateDebugSymbols) { //Note we can't use the precompiled engines here since there is an issue of the resolution of this code dependencies var csharpCompiler = new CSharp_FastCompiler(); csharpCompiler.generateDebugSymbols = generateDebugSymbols; var compileProcess = new System.Threading.AutoResetEvent(false); //csharpCompiler.compileSourceCode(pathToFileToCompile.contents()); csharpCompiler.compileSnippet(codeSnipptet); csharpCompiler.onCompileFail = () => compileProcess.Set(); csharpCompiler.onCompileOK = () => compileProcess.Set(); compileProcess.WaitOne(); var assembly = csharpCompiler.assembly(); return(assembly); }
public static ascx_Simple_Script_Editor csharpCompiler(this ascx_Simple_Script_Editor simpleScriptEditor, CSharp_FastCompiler value) { if (simpleScriptEditor.notNull()) { simpleScriptEditor.CSharpCompiler = value; } return(simpleScriptEditor); }
public static List <string> extraSourceCodeFilesToCompile(this CSharp_FastCompiler csharpCompiler) { return(csharpCompiler.notNull() ? csharpCompiler.CompilerOptions.ExtraSourceCodeFilesToCompile : new List <string>()); }
public static CSharp_FastCompiler_Events events(this CSharp_FastCompiler csharpCompiler) { return(csharpCompiler.notNull() ? csharpCompiler.Events : null); }
public static O2CodeCompletion updateCodeComplete(this ascx_SourceCodeViewer sourceCodeViewer, CSharp_FastCompiler csharpFastCompiler) { return(sourceCodeViewer.editor().updateCodeComplete(csharpFastCompiler)); }
public static O2CodeCompletion updateCodeComplete(this ascx_SourceCodeEditor sourceCodeEditor, CSharp_FastCompiler csharpFastCompiler) { if (sourceCodeEditor.o2CodeCompletion != null) { foreach (var extraReference in csharpFastCompiler.ExtraSourceCodeFilesToCompile) { sourceCodeEditor.o2CodeCompletion.parseFile(extraReference); } //var currentCode = csharpFastCompiler.processedCode(); var currentCode = csharpFastCompiler.SourceCode; sourceCodeEditor.o2CodeCompletion.parseSourceCode(currentCode); sourceCodeEditor.o2CodeCompletion.CodeCompleteCaretLocationOffset = csharpFastCompiler.getGeneratedSourceCodeMethodLineOffset(); sourceCodeEditor.o2CodeCompletion.CodeCompleteTargetText = currentCode; // i might not need these sourceCodeEditor.textArea().CodeCompleteCaretLocationOffset = csharpFastCompiler.getGeneratedSourceCodeMethodLineOffset(); } return(sourceCodeEditor.o2CodeCompletion); }