From c41057a6345ad62acb3cf6fb72276192bbef5a82 Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Tue, 13 Mar 2018 10:05:43 -0700 Subject: [PATCH] Run the correct entrypoint --- Ooui.Wasm.Build.Tasks/BuildDistTask.cs | 21 ++++++++++++++------- Ooui/Client.js | 11 ++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Ooui.Wasm.Build.Tasks/BuildDistTask.cs b/Ooui.Wasm.Build.Tasks/BuildDistTask.cs index 2164d26..27e1a16 100644 --- a/Ooui.Wasm.Build.Tasks/BuildDistTask.cs +++ b/Ooui.Wasm.Build.Tasks/BuildDistTask.cs @@ -29,6 +29,7 @@ namespace Ooui.Wasm.Build.Tasks CopyRuntime (); LinkAssemblies (); ExtractClientJs (); + DiscoverEntryPoint (); GenerateHtml (); GenerateServer (); return true; @@ -151,6 +152,17 @@ namespace Ooui.Wasm.Build.Tasks Log.LogMessage ($"Client JS {dest}"); } + MethodDefinition entryPoint; + + void DiscoverEntryPoint () + { + var asm = AssemblyDefinition.ReadAssembly (Assembly); + entryPoint = asm.EntryPoint; + if (entryPoint == null) { + throw new Exception ($"{Path.GetFileName (Assembly)} is missing an entry point"); + } + } + void GenerateHtml () { var htmlPath = Path.Combine (distPath, "index.html"); @@ -158,7 +170,6 @@ namespace Ooui.Wasm.Build.Tasks w.Write (@" - Ooui Wasm @@ -167,12 +178,8 @@ namespace Ooui.Wasm.Build.Tasks

Loading...

- diff --git a/Ooui/Client.js b/Ooui/Client.js index 1dc9dfe..27ca77d 100644 --- a/Ooui/Client.js +++ b/Ooui/Client.js @@ -108,8 +108,9 @@ function ooui (rootElementPath) { monitorSizeChanges (1000/10); } -function oouiWasm (mainAsmName, mainNamspace, mainClassName, mainMethodNmae, assemblies) +function oouiWasm (mainAsmName, mainNamespace, mainClassName, mainMethodName, assemblies) { + Module.entryPoint = { "a": mainAsmName, "n": mainNamespace, "t": mainClassName, "m": mainMethodName }; Module.assemblies = assemblies; monitorSizeChanges (1000/30); @@ -453,15 +454,15 @@ var WebAssemblyApp = { if (!this.ooui_ReceiveWebAssemblySessionMessageJson_method) throw "Could not find ReceiveWebAssemblySessionMessageJson method"; - this.main_module = MonoRuntime.assembly_load (mainAsmName); + this.main_module = MonoRuntime.assembly_load (Module.entryPoint.a); if (!this.main_module) - throw "Could not find Main Module " + mainAsmName + ".dll"; + throw "Could not find Main Module " + Module.entryPoint.a + ".dll"; - this.main_class = MonoRuntime.find_class (this.main_module, "", "Program") + this.main_class = MonoRuntime.find_class (this.main_module, Module.entryPoint.n, Module.entryPoint.t) if (!this.main_class) throw "Could not find Program class in main module"; - this.main_method = MonoRuntime.find_method (this.main_class, "Main", -1) + this.main_method = MonoRuntime.find_method (this.main_class, Module.entryPoint.m, -1) if (!this.main_method) throw "Could not find Main method"; },