From 0e07d78b92fc8ea3b160e2bdd3c365e3b61f62c5 Mon Sep 17 00:00:00 2001 From: agracio Date: Thu, 21 Mar 2024 13:26:25 +0000 Subject: [PATCH] code cleanup --- lib/bootstrap/bootstrap.csproj | 3 --- lib/edge.js | 2 +- src/common/edge.cpp | 3 +-- src/double/Edge.js/dotnet/EdgeJs.cs | 12 +++++++++++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/bootstrap/bootstrap.csproj b/lib/bootstrap/bootstrap.csproj index 9c855958..47a05275 100644 --- a/lib/bootstrap/bootstrap.csproj +++ b/lib/bootstrap/bootstrap.csproj @@ -11,8 +11,5 @@ - - - diff --git a/lib/edge.js b/lib/edge.js index 3a6e60a8..ba6d8447 100644 --- a/lib/edge.js +++ b/lib/edge.js @@ -41,7 +41,7 @@ if (process.env.EDGE_DEBUG) { } if (edgeNative.match(/edge_coreclr\.node$/i)) { // Propagate the choice between desktop and coreclr to edge-cs; this is used in deciding - // how to compile literal C# at https://github.com/tjanczuk/edge-cs/blob/master/lib/edge-cs.js + // how to compile literal C# at https://github.com/agracio/edge-js-cs/blob/master/lib/edge-cs.js process.env.EDGE_USE_CORECLR = 1; } if (process.env.EDGE_USE_CORECLR && !process.env.EDGE_BOOTSTRAP_DIR && fs.existsSync(path.join(__dirname, 'bootstrap', 'bin', 'Release', 'netcoreapp3.1', 'bootstrap.dll'))) { diff --git a/src/common/edge.cpp b/src/common/edge.cpp index 9f339e4e..0f522059 100644 --- a/src/common/edge.cpp +++ b/src/common/edge.cpp @@ -81,7 +81,7 @@ bool HasEnvironmentVariable(const char* variableName) #pragma unmanaged #endif #ifdef HAVE_CORECLR - #if NODE_MAJOR_VERSION >= 10 + #if NODE_MAJOR_VERSION >= 10 NAN_MODULE_WORKER_ENABLED(edge_coreclr, init) #else NODE_MODULE(edge_coreclr, init) @@ -93,5 +93,4 @@ bool HasEnvironmentVariable(const char* variableName) NODE_MODULE(edge_nativeclr, init) #endif #endif - // vim: ts=4 sw=4 et: diff --git a/src/double/Edge.js/dotnet/EdgeJs.cs b/src/double/Edge.js/dotnet/EdgeJs.cs index 302e9b9b..66303120 100644 --- a/src/double/Edge.js/dotnet/EdgeJs.cs +++ b/src/double/Edge.js/dotnet/EdgeJs.cs @@ -76,6 +76,9 @@ public Task InitializeInternal(object input) [DllImport("node.dll", EntryPoint = "?Start@node@@YAHHQEAPEAD@Z", CallingConvention = CallingConvention.Cdecl)] static extern int NodeStartx64(int argc, string[] argv); + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + private static extern int GetShortPathName(string LongPath, StringBuilder ShortPath, int BufferSize); + [DllImport("kernel32.dll", EntryPoint = "LoadLibrary")] static extern int LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpLibFileName); @@ -116,7 +119,14 @@ public static Func> Func(string code) argv.Add(p); } } - argv.Add(Path.Combine(AssemblyDirectory, "edge", "double_edge.js")); + + // Workaround for unicode characters in path + string path = AssemblyDirectory + "\\edge\\double_edge.js"; + StringBuilder shortPath = new StringBuilder(255); + int result = GetShortPathName(path, shortPath, shortPath.Capacity); + argv.Add(shortPath.ToString()); + // End workaround for unicode characters in path + argv.Add(string.Format("-EdgeJs:{0}", Path.Combine(edgeDirectory, "EdgeJs.dll"))); nodeStart(argv.Count, argv.ToArray()); waitHandle.Set();