예제 #1
0
        public void SetupFixture_SetUp()
        {
            CompileEngine.clearCompilationCache();              // ensure the compilatation cache is clean

            var o2PlatformScripts = new O2_Platform_Scripts();
            var scriptsFolder     = o2PlatformScripts.ScriptsFolder();

            if ("".offline())                    // we can't do the sync when offline
            {
                return;
            }

            Assert.IsTrue(o2PlatformScripts.SetUp());  // call SetUp which will trigger the git clone (if needed)

            scriptsFolder.assert_Folder_Exists()
            .assert_Is_True(path => path.isGitRepository());

            //check that expected O2.Platform.Scripts files are in there:
            var nGit      = o2PlatformScripts.nGit;
            var fullPath1 = nGit.file_FullPath("README.md");
            var fullPath2 = nGit.file_FullPath(@"_DataFiles\_Images\O2_Logo.gif");

            Assert.IsTrue(nGit.pull());
            Assert.IsTrue(fullPath1.fileExists());
            Assert.IsTrue(fullPath2.fileExists());
        }
예제 #2
0
 //O2 Script Library
 [Test] public void CompileAllScripts()
 {
     PublicDI.log.writeToDebug(true);
     CompileEngine.clearCompilationCache();
     foreach (var method in typeof(O2_Script_Library).methods())
     {
         var code     = method.invoke().str();
         var assembly = code.compileCodeSnippet();
         Assert.IsNotNull(assembly, "Failed for compile {0} with code: \n\n {1}".format(method.Name, code));
         "Compiled OK: {0}".info(method.Name);
     }
 }
예제 #3
0
        [Test] public void CompileEngine_Ctor()
        {
            CompileEngine.clearCompilationCache();
            // call the static Ctor to reset the values
            typeof(CompileEngine).invoke_Ctor_Static();

            var compileEngine = new CompileEngine();

            assert_Is_True(compileEngine.useCachedAssemblyIfAvailable);
            assert_Are_Equal(compileEngine.compilationVersion, "v4.0");
            assert_Not_Empty(CompileEngine.LocalReferenceFolders);


            assert_Not_Empty(CompileEngine.DefaultReferencedAssemblies);
            assert_Not_Empty(CompileEngine.DefaultUsingStatements);
            assert_Not_Empty(CompileEngine.CachedCompiledAssembliesMappingsFile);
            assert_Not_Empty(CompileEngine._specialO2Tag_ExtraReferences);

            assert_Is_Empty(CompileEngine.CachedCompiledAssemblies);
            assert_Is_Empty(CompileEngine.CompilationPathMappings);
            assert_Is_Empty(CompileEngine.LocalScriptFileMappings);
            assert_Is_Empty(CompileEngine.LocalFoldersToSearchForCodeFiles);
            assert_Is_Empty(CompileEngine.LocalFoldersToAddToFileMappings);
        }
        public void configureGui()
        {
            result_Panel.visible(false);
            executeButton.enabled(false);

            commandsToExecute.textEditor().showInvalidLines(false);

            swapGeneratedCodeViewMode();                // make it not visible by default

            executeButton.onClick(execute);
            commandsToExecute.onTextChanged(onTextChanged);

            commandsToExecute.editor().vScroolBar_Enabled(false);
            commandsToExecute.editor().hScroolBar_Enabled(false);
            commandsToExecute.set_ColorsForCSharp();

            commandsToExecute.allowCompile(false);
            sourceCodeViewer.allowCompile(false);

            sourceCodeViewer.astDetails(false);
            commandsToExecute.astDetails(false);

            //remove original ContextMenu and add new one
            sourceCodeViewer.textEditorControl().remove_ContextMenu();
            var contextMenu = commandsToExecute.textEditorControl().add_ContextMenu();

            commandsToExecute.textArea().KeyUp           += (sender, e) => handlePressedKeys(e);
            commandsToExecute.textArea().KeyEventHandler += handleKeyEventHandler;

            contextMenu.add_MenuItem("current source code")
            .add_MenuItem("compile", (menuitem) => compile())
            .add_MenuItem("copy to clipboard", (menuitem) => currentCode().toClipboard())
            .add_MenuItem("save", (menuitem) => saveScript())
            .add_MenuItem("save As", (menuitem) => saveAsScript())
            .add_MenuItem("what is the current loaded filename", (menuitem) => "The path of the currently loaded file is: {0}".info(currentSourceCodeFilePath()))
            .add_MenuItem("force compilation", (menuitem) => forceCompilation())
            .add_MenuItem("replace with generated source code", (menuitem) => replaceMainCodeWithGeneratedSource())
            .add_MenuItem("show/hide generated source code", (menuitem) => swapGeneratedCodeViewMode())
            .add_MenuItem("-------------------------------")
            .add_MenuItem("clear AssembliesCheckedIfExists list", (menuitem) => O2GitHub.clear_AssembliesCheckedIfExists())
            .add_MenuItem("clear CachedCompiledAssemblies list", (menuitem) => CompileEngine.clearCompilationCache())
            .add_MenuItem("clear LocalScriptFileMappings list", (menuitem) => CompileEngine.clearLocalScriptFileMappings())
            .add_MenuItem("clear CompilationPathMappings list", (menuitem) => CompileEngine.clearCompilationPathMappings());

            contextMenu.add_MenuItem("selected text")
            .add_MenuItem("cut", () => commandsToExecute.editor().clipboard_Cut())
            .add_MenuItem("copy", () => commandsToExecute.editor().clipboard_Copy())
            .add_MenuItem("paste", () => commandsToExecute.editor().clipboard_Paste())
            .add_MenuItem("(if a local file) open selected text in code Editor", () => openSelectedTextInCodeEditor());
            contextMenu.add_MenuItem("execution options")
            .add_MenuItem("execute", (menuitem) => execute())
            .add_MenuItem("enable /disable Execute on compile", (menuitem) => ExecuteOnCompile = !ExecuteOnCompile)
            .add_MenuItem("enable /disable Execute on enter", (menuitem) => ExecuteOnEnter     = !ExecuteOnEnter)
            .add_MenuItem("disable / enabled Auto compile on code change", (menuitem) => AutoCompileOnCodeChange = !AutoCompileOnCodeChange);
            contextMenu.add_MenuItem("auto saved scripts")
            .add_MenuItem("show auto saved scripts", (menuitem) => showAutoSavedScripts())
            .add_MenuItem("enable / disable Auto Save on compile success", (menuitem) => AutoSaveOnCompileSuccess = !AutoSaveOnCompileSuccess);
            contextMenu.add_MenuItem("code complete")
            .add_MenuItem("enable Code Complete", (menuitem) => commandsToExecute.enableCodeComplete())
            .add_MenuItem("enable /disabled 'Only Show Code Complete Results From O2 Namespace'", (menuitem) => enableDisableFullCodeComplete());
            contextMenu.add_MenuItem("code snippets (helper)")
            .add_MenuItem("when compiling: Dont use Cached Assembly if available", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("when compiling: remove all auto references to O2 scripts and dlls (same as next two options)", (menuitem) => insertCodeSnipptet(menuitem.Text))
            //.add_MenuItem("when compiling: don't include extra cs file (with extension methods)", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("when compiling, only add referenced assemblies", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("when compiling, set InvocationParameters to dynamic", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("generate debug symbols (and create temp assembly)", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("add using statement", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("add additional source code (when compile)", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("add external reference (dll or exe or GAC assembly)", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("run in STA thread (when invoke)", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("run in MTA thread (when invoke)", (menuitem) => insertCodeSnipptet(menuitem.Text))
            .add_MenuItem("clear 'AssembliesCheckedIfExists' cache", (menuitem) => insertCodeSnipptet(menuitem.Text));
            contextMenu.add_MenuItem("This Script Editor")
            .add_MenuItem("REPL script this Script", scriptTheCurrentScript)
            .add_MenuItem("REPL script this Script's codeComplete object", scriptTheCurrentScript_CodeComplete);
            contextMenu.add_MenuItem("O2 Scripts")
            //.add_MenuItem("Download/Update O2 Scripts (via http)", O2Scripts.downloadO2Scripts)
            .add_MenuItem("O2 Script: find WinForms Control and REPL it ", () => "Util - Find WinForms Control and REPL it.h2".local().executeH2Script())
            .add_MenuItem("O2 Script: new C# Script Editor", () => open.scriptEditor())
            .add_MenuItem("O2 Script: Find Script to execute", () => "Util - O2 Available scripts.h2".local().executeH2Script())
            .add_MenuItem("O2 Script: open Main O2 GUI", () => "Main O2 Gui.h2".local().executeH2Script())
            .add_MenuItem("O2 Script: open ConsoleOut", () => "Util - ConsoleOut.h2".local().executeH2Script());

            contextMenu.add_MenuItem("package current Script as StandAlone Exe", () => packageCurrentScriptAsStandAloneExe());
            contextMenu.add_MenuItem("show O2 Object Model", () => open.o2ObjectModel());
            contextMenu.add_MenuItem("report a bug to O2 developers", () => ReportBug.showGui(commandsToExecute));
            contextMenu.add_MenuItem("show Log Viewer", (menuitem) => showLogViewer());
        }