-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support for Attributes? #48
Comments
@thautwarm I'm not sure about this so we need to ask the experts @alfonsogarciacaro and @Zaid-Ajaj. I don't know about custom attribute support, but know that there's some support for custom plugins that might handle custom attributes i.e https://github.com/Zaid-Ajaj/Feliz/tree/master/Feliz.CompilerPlugins but I have never used it myself |
Right now, attributes should be visible to plugins but are erased in generated code. This is because in JS we're always careful not to output too many things so the bundle size doesn't grow too much. Take note that F# already adds many attributes on its own. Maybe in the case of Python the bundle size doesn't matter too much and it's ok to output the attributes (probably filtering out the compiler generated ones). I think this should be possible to do in the Fable2Python step when generating the reflection info as the attribute info is kept in the Fable AST. In the particular case of Json serialization, the community usually tends to customize things using custom coders instead of attributes in the type declaration though: https://thoth-org.github.io/Thoth.Json/documentation/auto/json-representation.html#extra-coders |
Thanks! @dbrattli @alfonsogarciacaro |
@alfonsogarciacaro Yes, bundle size does not matter at all for Python (disk space is free), but loading times still matters. So we still need to be careful to not eagerly import everything for stuff that is rarely used. Lazy loading of modules is possible in Python so that is something we might have to consider down the line, e.g: https://github.com/ReactiveX/RxPY/blob/master/rx/operators/__init__.py#L60 |
At the beginning I was considering to put all the reflection info in a separate file but discarded it because it messed up with Webpack integration (Fable 2 relied on the Webpack watcher), not sure if it would make sense to consider it again. |
I'm now happy with Fable's reflection, which allows me to do what pydantic does in the python world.
However I want to step further. I want to allow syntax sugars in the configuration, but get the same syntax tree.
By using attributes, I want to control JSON deserialization, to parse into the same results for
and
Is the use of attributes possible in Fable?
The text was updated successfully, but these errors were encountered: