Skip to content

Commit

Permalink
merging changes from edge-js
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Dec 15, 2024
1 parent 5780f26 commit 9571bc4
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/double/Edge.js/dotnetcore/coreclrembedding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
86 changes: 86 additions & 0 deletions test/106_node2net_symbols.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
2 changes: 1 addition & 1 deletion test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
14 changes: 13 additions & 1 deletion tools/test.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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);
}
});
}
});
}
Expand Down

0 comments on commit 9571bc4

Please sign in to comment.