-
-
Notifications
You must be signed in to change notification settings - Fork 581
Closed
Description
Version used
Version 3.0.0-beta-2053.
Describe the bug
When destructuring a method out of an object provided from C# code, and then trying to invoke the method from Javascript, a TargetException
is raised, stating Non-static method requires a target
.
To Reproduce
void Main()
{
var engine = new Engine();
engine.SetValue("test", new Test());
engine.Execute("const { log } = test; log()");
}
class Test
{
public void log() { Console.WriteLine("logging"); }
}
Expected behavior
I expect to be able to destructure an object from within Javascript and invoke its methods.
Additional context
- If you mark the
Test.log
method asstatic
, the problem disappears, but also theTest
class won't have access to its instance fields/properties/methods, so it is not really a solution. - If you do not invoke the
log
method, there is no exception. - The problem with destructuring also occurs in other contexts, e.g. when using destructuring in a lambda:
({ log }) => log()
.
Metadata
Metadata
Assignees
Labels
No labels