Conversation
|
@JeremyTCD |
|
It would also be nice if the For example, now the following code leads to errors: using System;
using System.Threading.Tasks;
using Jering.Javascript.NodeJS;
namespace TestNodeJs
{
class Program
{
static void Main(string[] args)
{
Task<double> task = StaticNodeJSService.InvokeFromStringAsync<double>(
@"module.exports = { pi: 3.14 };",
"math.js",
"pi"
);
task.Wait();
double result = task.Result;
Console.WriteLine("result = {0}", result);
}
}
} |
3466bed to
27161f9
Compare
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
=========================================
+ Coverage 96.81% 97.51% +0.7%
=========================================
Files 18 18
Lines 533 564 +31
=========================================
+ Hits 516 550 +34
+ Misses 17 14 -3
Continue to review full report at Codecov.
|
|
@DaniilSokolyuk Thanks for taking a look! Should be released by tomorrow. @Taritsyn I'll keep that suggestion in mind, it's somewhat out of scope for now. Wrt #56, I realized we don't need new overloads, we just need |
|
@JeremyTCD OK. |
src/NodeJS/NodeJSServiceImplementations/OutOfProcess/OutOfProcessNodeJSService.cs
Outdated
Show resolved
Hide resolved
|
System.Text.Json is extendable |
|
Yeap it supports custom converters, but it doesn't support serializing to dynamic result = nodeJSService.InvokeFromStringAsync<object>(moduleString); |
3730bdc to
d01c6b2
Compare
- Added module factory overloads that atomically attempt to invoke from cache/cache if unable to invoke from cache. - Added overloads that don't return any values.
- Made implemented methods virtual. Previously all they did was call TryInvokeCoreAsync, now they have logic, so they should be exposed for overriding.
- Added shortcut for requests with return type Void to HttpNodeJSService. - Updated integration tests.
…it should have been throwing ArgumentNullExceptions.
d01c6b2 to
aa5b806
Compare
|
🚀 Released v5.2.0. |
Add members with "params object[] args" for convenience.E.g so instead of this:we can do this:E.g:
E.g:
Edit:
No longer adding members with "params object[] args" because if we expose the following methods:
Users might expect:
to invoke
InvokeFromStringAsync<string>(string moduleSource, params object[] args), but it actually invokesInvokeFromStringAsync<string>(string moduleSource, string newCacheIdentifier, params object[] args);.Similarly,
Invokes
InvokeFromStringAsync<string>(string moduleSource, string newCacheIdentifier, string exportName, params object[] args);.Some framework methods like
Activator.CreateInstancehave the same issue. However,with this library, I think there is higher probability of accidents because users might try
INodeServices.InvokeAsyncsyntax likeInvokeFromFileAsync<string>(javascriptModule, arg1);and it's likely that users will be sending strings to Node.js.