You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Jint 3.0.0-beta-2054 now. And issue/discussion #1643 works as expected now. Thank you @viruscamp
But I think I have found another issue with clr objects. Calling an existing function on a proxy object leads to System.Reflection.TargetException: 'Object does not match target type.'
classTestClass{publicstringName=>"My Name is Test";publicvoidSayHello(){
Console.WriteLine("Hello");}publicintAdd(inta,intb){returna+b;}}
new Engine().SetValue("T",new TestClass()).Execute("""
const handler = {
get(target, property, receiver) {
if (!target[property]) {
return (...args) => "Not available";
}
// return Reflect.get(target, property, receiver);
return Reflect.get(...arguments);
}
};
const p = new Proxy(T, handler);
const name = p.Name; // works
const s = p.GetX(); // works because method does NOT exist on clr object
p.SayHello(); // throws System.Reflection.TargetException: 'Object does not match target type.'
const t = p.Add(5,3); // throws System.Reflection.TargetException: 'Object does not match target type.'
""");
The same code is working fine in pure javascript
classTestClass{getName(){return'My name is test';}SayHello(){console.log('Hello',this.Name);}Add(a,b){returna+b;}}consthandler={get(target,property,receiver){if(!target[property]){return(...args)=>"Not available";}// return Reflect.get(target, property, receiver);returnReflect.get(...arguments);}};constT=newTestClass();constp=newProxy(T,handler);constname=p.Name;consts=p.GetX();console.log(s);p.SayHello();constt=p.Add(5,3);console.log(t);/* Output> "Not available"> "Hello" "My name is test"> 8*/
The text was updated successfully, but these errors were encountered:
Hi,
I am using Jint 3.0.0-beta-2054 now. And issue/discussion #1643 works as expected now. Thank you @viruscamp
But I think I have found another issue with clr objects. Calling an existing function on a proxy object leads to
System.Reflection.TargetException: 'Object does not match target type.'
The same code is working fine in pure javascript
The text was updated successfully, but these errors were encountered: