New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to override interop members #758
Conversation
Thiking also that an overload that return a JsValue instead of a property descriptor, or an object, might be better suited since it's called in CLR land, for CLR instances. |
Jint/Engine.cs
Outdated
@@ -239,6 +239,12 @@ public Engine(Action<Engine, Options> options) | |||
ClrTypeConverter = new DefaultTypeConverter(this); | |||
} | |||
|
|||
public void SetMemberAccessor(Type type, string name, Func<Engine, object, PropertyDescriptor> accessor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to change behavior runtime or would it make sense to do these via options when initializing engine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what requirements there are behind, but looks good. Just a question about whether this should be added to main engine api or via options and some sort of callback.
If you look at how object wrapping is configured: https://github.com/sebastienros/jint/blob/dev/Jint/Options.cs#L78-L87 And then used: https://github.com/sebastienros/jint/blob/dev/Jint/Native/JsValue.cs#L349-L351 I think allowing to call such callback and if it returns non-null the result should be used instead the one created in normal logic? It would make the API similar. |
Will try to implement a callback instead. |
Updated |
Looks good! |
Open to discussion. It might be better to refactor the internal type and dictionary to expose them directly.