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(); 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 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; }
public static O2CodeCompletion updateCodeComplete(this ascx_SourceCodeViewer sourceCodeViewer, CSharp_FastCompiler csharpFastCompiler) { return sourceCodeViewer.editor().updateCodeComplete(csharpFastCompiler); }
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.onAstFail = ()=>{ showError("Ast creation failed", csharpCompiler.AstErrors); csharpCompiler_onAstFail.invoke(); }; csharpCompiler.onAstOK = ()=>{ showInfo("Ast creation Ok"); csharpCompiler_onAstOK.invoke(); }; csharpCompiler.onCompileFail = ()=>{ showError("Compilation failed", csharpCompiler.CompilationErrors); csharpCompiler_onCompileFail.invoke(); }; csharpCompiler.onCompileOK = () => { showInfo("Compilation Ok: Executing 1st method"); csharpCompiler_onCompileOK.invoke(); executeCompiledCode(); }; var sourceCode = ""; PublicDI.CurrentScript = scriptToLoad; csharpCompiler.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); }); }