diff --git a/package-lock.json b/package-lock.json index 8fbc551..d14686d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "electron-edge-js", - "version": "33.0.4", + "version": "33.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "electron-edge-js", - "version": "33.0.4", + "version": "33.0.5", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 93a4b6b..dd10d7b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "url": "http://tomasz.janczuk.org", "twitter": "tjanczuk" }, - "version": "33.0.4", + "version": "33.0.5", "description": "Edge.js: run .NET and Node.js in-process on Electron", "tags": [ "owin", diff --git a/src/double/Edge.js/dotnetcore/coreclrembedding.cs b/src/double/Edge.js/dotnetcore/coreclrembedding.cs index c3ac81c..bba16af 100644 --- a/src/double/Edge.js/dotnetcore/coreclrembedding.cs +++ b/src/double/Edge.js/dotnetcore/coreclrembedding.cs @@ -667,7 +667,7 @@ private static Assembly Assembly_Resolving(AssemblyLoadContext arg1, AssemblyNam } [SecurityCritical] - public static IntPtr GetFunc(string assemblyFile, string typeName, string methodName, IntPtr exception) + public static IntPtr GetFunc([MarshalAs(UnmanagedType.LPUTF8Str)]string assemblyFile, string typeName, string methodName, IntPtr exception) { try { diff --git a/test/106_node2net_symbols.js b/test/106_node2net_symbols.js new file mode 100644 index 0000000..f12a9d2 --- /dev/null +++ b/test/106_node2net_symbols.js @@ -0,0 +1,86 @@ +var edge = require('../lib/edge.js'), assert = require('assert') + , path = require('path'); + +var edgeTestDll = path.join(__dirname, '测试', 'Edge.Tests.CoreClr.dll'); +var prefix = process.env.EDGE_USE_CORECLR ? '[CoreCLR]' : process.platform === 'win32' ? '[.NET]' : '[Mono]'; + +describe('node.js to .net dll from path with asian chracters', function () { + + it(prefix + ' succeeds for hello world', function (done) { + if (!process.env.EDGE_USE_CORECLR) { + this.skip(); + } + var func = edge.func({ + assemblyFile: edgeTestDll, + typeName: 'Edge.Tests.Startup', + methodName: 'Invoke' + }); + func('Node.js', function (error, result) { + assert.ifError(error); + assert.equal(result, '.NET welcomes Node.js'); + done(); + }); + }); + + it(prefix + ' successfuly marshals data from node.js to .net', function (done) { + if (!process.env.EDGE_USE_CORECLR) { + this.skip(); + } + var func = edge.func({ + assemblyFile: edgeTestDll, + typeName: 'Edge.Tests.Startup', + methodName: 'MarshalIn' + }); + var payload = { + a: 1, + b: 3.1415, + c: 'fooåäö', + d: true, + e: false, + f: Buffer.alloc(10), + g: [ 1, 'fooåäö' ], + h: { a: 'fooåäö', b: 12 }, + i: function (payload, callback) { }, + j: new Date(Date.UTC(2013, 07, 30)) + }; + func(payload, function (error, result) { + assert.ifError(error); + assert.equal(result, 'yes'); + done(); + }); + }); + + it(prefix + ' successfuly marshals data from .net to node.js', function (done) { + if (!process.env.EDGE_USE_CORECLR) { + this.skip(); + } + var func = edge.func({ + assemblyFile: edgeTestDll, + typeName: 'Edge.Tests.Startup', + methodName: 'MarshalBack' + }); + func(null, function (error, result) { + assert.ifError(error); + assert.equal(typeof result, 'object'); + assert.ok(result.a === 1); + assert.ok(result.b === 3.1415); + assert.ok(result.c === 'fooåäö'); + assert.ok(result.d === true); + assert.ok(result.e === false); + assert.equal(typeof result.f, 'object'); + assert.ok(Buffer.isBuffer(result.f)); + assert.equal(result.f.length, 10); + assert.ok(Array.isArray(result.g)); + assert.equal(result.g.length, 2); + assert.ok(result.g[0] === 1); + assert.ok(result.g[1] === 'fooåäö'); + assert.equal(typeof result.h, 'object'); + assert.ok(result.h.a === 'fooåäö'); + assert.ok(result.h.b === 12); + assert.equal(typeof result.i, 'function'); + assert.equal(typeof result.j, 'object'); + assert.ok(result.j.valueOf() === Date.UTC(2013, 07, 30)); + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/app.js b/test/app.js index 9f91d4c..7758281 100644 --- a/test/app.js +++ b/test/app.js @@ -31,9 +31,9 @@ function addFiles(mocha){ mocha.addFile(path.join(__dirname, '103_net2node.js')); mocha.addFile(path.join(__dirname, '104_csx.js')); mocha.addFile(path.join(__dirname, '105_node2net_sync.js')); + mocha.addFile(path.join(__dirname, '106_node2net_symbols.js')); mocha.addFile(path.join(__dirname, '201_patterns.js')); mocha.addFile(path.join(__dirname, '202_serialization.js')); - } exports.runTests = function (framework, window){ diff --git a/tools/test.js b/tools/test.js index 641b1e2..3a11ab8 100644 --- a/tools/test.js +++ b/tools/test.js @@ -1,5 +1,6 @@ var spawn = require('child_process').spawn; var path = require('path'); +var fs = require('fs'); var testDir = path.resolve(__dirname, '../test'); var input = path.resolve(testDir, 'tests.cs'); var output = path.resolve(testDir, 'Edge.Tests.dll'); @@ -23,7 +24,18 @@ if (!process.env.EDGE_USE_CORECLR) { else { run(process.platform === 'win32' ? 'dotnet.exe' : 'dotnet', ['restore'], function(code, signal) { if (code === 0) { - run(process.platform === 'win32' ? 'dotnet.exe' : 'dotnet', ['build'], runOnSuccess); + run(process.platform === 'win32' ? 'dotnet.exe' : 'dotnet', ['build'], function(code, signal) { + if (code === 0) { + try{ + fs.mkdirSync('test/测试', { recursive: true }) + + } + catch (e){ + console.error(e) + } + run('cp', ['../test/bin/Debug/test.dll', '../test/测试/Edge.Tests.CoreClr.dll'], runOnSuccess); + } + }); } }); }