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
Add protected function instance constructor #759
Add protected function instance constructor #759
Conversation
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.
Awesome! This is just the coverage we need more to make sure CLR interop story works for people extending Jint.
|
||
public UuidTests() | ||
{ | ||
_engine = new Engine(o => o.AddObjectConverter(new UuidConverter())) |
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.
What do you think about adding an extension method on Options named AddUuid()
which would register the converter and also call CreateUuidConstructor ?
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.
Sounds good. Would need some API refactoring.
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.
Can we get away with AddObjectConverter<T>
? not sure if we can bind the constructor with that though.
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.
@viceice I think we would need a way to add Action to a list that would be executed by the engine when it has initialized the options object.
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.
What about to add Engine.ObjectConverters
as public List<IObjectConverter> ObjectConverters => Options._ObjectConverters
? so we can add IObjectConverter
after Engine
contructor finished?
Then the AddUuid()
extension would be very easy.
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 prefer not to since we are looking at ways to reuse engines. Having all the configuration kept in options would allow us to reuse it on any engine instance once cleared of any state. We could even add a list of scripts. Or use these options in a factory object for pooling.
Instead of calling these methods from Engine, we can also have a method Apply(engine) such that the engine code would not change every time we add options. And a Options.Configure (Action) to register custom logic. I can add this to your PR if you prefer.
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.
Ok, feel free to change the PR. 🙃
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.
Maybe I need to give you write access to my fork, because it's in an org.
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.
If you haven't unallowed me, then by default I can write on the branch you used to submit a PR
Had not realized that all these UUid classes were only in Tests, until I start adding what I suggested. |
I've started here. |
FunctionInstance
closes: #753