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
It'd be great to improve reflection support for Fable 3. We can do it by bringing the reflection changes in #1839, but if possible I'd like to have these changes:
Have a separate PR for reflection and quotation support.
Keep the current style in Reflection.ts. That is, use module functions instead of class methods so it works better with tree shaking.
Instead of adding attribute and member information to all types. We could have the following functions in the Fable.Core.Reflection module:
The Replacements module would replace calls to these methods with the necessary info inline, so we only generate the code where is needed.
What do you think @krauthaufen? Do the changes look good? Would you like to help with this? (If you want to sart working, please note we'll be using the next branch for Fable 3 development).
No unfortunately it didn't. I realized that my original idea of having something like generateMethods<'T>() wouldn't work for many use cases, like quotations, so I'm still unsure how to balance improving reflection support while keeping JS bundle sizes small.
As suggested by @fable-compiler on twitter, I was able to find work arounds using a mix of dynamic code and inline functions. While the dynamic code is more brittle, it's quite contained and can be made somewhat safe with tests.
I find the inline workaround more problematic as it renders the generated JS unreadable, which is a shame as the JS generated by Fable seems otherwise surprisingly readable.
Closing as this didn't make it into Fable 3 at the end. There are a few other issues still open about increasing reflection support in specific situations. We can try to deal with them in a case-by-case basis.
Activity
lfr commentedon Dec 16, 2020
Did this make it to Fable 3 in the end?
alfonsogarciacaro commentedon Dec 18, 2020
No unfortunately it didn't. I realized that my original idea of having something like
generateMethods<'T>()wouldn't work for many use cases, like quotations, so I'm still unsure how to balance improving reflection support while keeping JS bundle sizes small.lfr commentedon Dec 18, 2020
As suggested by @fable-compiler on twitter, I was able to find work arounds using a mix of dynamic code and inline functions. While the dynamic code is more brittle, it's quite contained and can be made somewhat safe with tests.
I find the
inlineworkaround more problematic as it renders the generated JS unreadable, which is a shame as the JS generated by Fable seems otherwise surprisingly readable.alfonsogarciacaro commentedon Jul 12, 2021
Closing as this didn't make it into Fable 3 at the end. There are a few other issues still open about increasing reflection support in specific situations. We can try to deal with them in a case-by-case basis.