Replies: 2 comments 1 reply
-
This is quite exotic use case due to the generic and probably hasn't been tested/implemented. As JS doesn't have generics the type system isn't prepared for such.. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hmm, do you mean the generic T in the Example class, or that Func is based on generics. var engine = new Jint.Engine();
engine.SetValue("Example", new Example());
engine.Execute("""
const obj = {
value: 42
};
const res = Example.ExchangeObject(obj); // works
const res2 = Example.ExchangeObjectViaFunc(() => 3); // works, only to ensure that not Func is the issue
const res3 = Example.ExchangeObjectViaFunc(() => obj); // does not work, throws 'Object must implement IConvertible'
""");
class Example()
{
public object ExchangeObject(object obj)
{
return obj;
}
public object ExchangeObjectViaFunc(Func<object> objViaFunc)
{
return objViaFunc();
}
} What I do not understand is why it makes a difference if an object is passed directly or is returned by a Func. I both cases the object is passed from js to c#. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
From a technical point of view, I do not understand why exchanging an object directly works but not via a Func. Is this an error in Jint or are there are some technical reasons for that?
Beta Was this translation helpful? Give feedback.
All reactions