[Test] public void register_GitHub_As_ExternalAssemblerResolver() { var targetAssembly = "BasicCacher.dll"; var currentLocation = AssemblyResolver.NameResolver(targetAssembly); // check if it has been downloaded before and delete it if it had if (currentLocation.fileExists()) { currentLocation.file_Delete(); } currentLocation.assert_File_Not_Exists(); assert_Not_Null(AssemblyResolver.ExternalAssemblerResolver); AssemblyResolver.ExternalAssemblerResolver.clear(); assert_Is_Empty(AssemblyResolver.ExternalAssemblerResolver); O2GitHub.register_GitHub_As_ExternalAssemblerResolver(); assert_Is_Not_Empty(AssemblyResolver.ExternalAssemblerResolver); assert_Null("System.dll".resolve_Assembly_Using_ExternalAssemblerResolver()); assert_Not_Null(targetAssembly.resolve_Assembly_Using_ExternalAssemblerResolver()); assert_Size_Is(AssemblyResolver.ExternalAssemblerResolver, 1); //calling it again, should not add a duplicate resolver O2GitHub.register_GitHub_As_ExternalAssemblerResolver(); assert_Size_Is(AssemblyResolver.ExternalAssemblerResolver, 1); }
/// <summary> /// Thread used to download a file from GitHub (will try a couple locations) /// </summary> [Test] public void downloadThread() { // ********************************************* // first try to do a direct download of the 3 possible locations // with url mapped in PublicDI.config.O2GitHub_ExternalDlls Action <string, string> test_DirectDownload = (targetAssembly, downloadLocation) => { PublicDI.config.O2GitHub_ExternalDlls.info(); assert_Are_Equal(PublicDI.config.O2GitHub_ExternalDlls.HEAD_StatusCode(), HttpStatusCode.BadRequest); var localFilePath = tempDownloadDir.pathCombine(targetAssembly); var webLocation = "{0}{1}".format(downloadLocation, targetAssembly).trim(); localFilePath.assert_File_Not_Exists(); // file shouln't be there before download assert_True(webLocation.httpFileExists()); // check that we can ping it new O2Kernel_Web().downloadBinaryFile(webLocation, localFilePath); // download file localFilePath.assert_File_Exists(); // file should be there now localFilePath.file_Delete(); // delete in order to not affect test_downloadThread tests localFilePath.assert_File_Not_Exists(); }; Action <string, bool> test_downloadThread = (file, shouldExist) => { var localFilePath = ""; var result = O2GitHub.downloadThread(file, ref localFilePath, useCacheInfo: false); assert_Not_Null(localFilePath); // this is always set assert_Are_Equal(shouldExist, result); assert_Are_Equal(shouldExist, localFilePath.fileExists()); }; test_DirectDownload("GithubSharp.Plugins.LogProviders.SimpleLogProvider.dll", PublicDI.config.O2GitHub_ExternalDlls); // 6k - Moq.dll can also be used but it is bigger (400k) test_DirectDownload("O2_Kernel_WCF.dll", PublicDI.config.O2GitHub_Binaries); // 20k test_DirectDownload("ActiveUp.Net.Dns.dll", PublicDI.config.O2GitHub_FilesWithNoCode); // 40k test_downloadThread("O2_Kernel_WCF.dll", true); test_downloadThread("O2_Kernel_AAA.dll", false); test_downloadThread("ActiveUp.Net.Dns.dll", true); test_downloadThread("ActiveUp.AAA.BBB.dll", false); test_downloadThread("GithubSharp.Plugins.LogProviders.SimpleLogProvider.dll", true); test_downloadThread("GithubSharp.Plugins.LogProviders.AAAAAAAAAAAAAAAAA.dll", false); // ********************************************* // Then use the download Thread to confirm that we get the same files }
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()); }
public static void register_GitHub_As_ExternalAssemblerResolver() { O2GitHub.register_GitHub_As_ExternalAssemblerResolver(); }