fsprojects / FSharp.Compiler.PortaCode

The PortaCode F# code format and corresponding interpreter. Used by Fabulous and others.
Other
42 stars 11 forks source link

Fabulous LiveUpdate + erased type providers (FSharp.Data.JsonProvider) #14

Open bra1nDump opened 5 years ago

bra1nDump commented 5 years ago

Right now our team is placing most of the time into developing the UI for our Fabulous app, and the build/deploy time is around 2 minutes, so we are trying to use LiveUpdate. At the same time we are using FSharp.Data JsonProvider across the application, for instance ABCTypeProvider.Root often times ends up in the Model.

The compilation on the build machine goes fine, but when porta code is run by the interpreter on the application host (android emulator) this is the error that happens ERROR SENDING TO WEBHOOK: "System.Exception: error converting rhs of init System.InvalidOperationException: the type 'Root' does not have a qualified name

I assume the problem is that type gets erased and since it is referenced in the Model it does not work. But it really sucks and I am trying to get it to work

Tried:

Contemplating:

  1. Try to use --livechecksonly
  2. Somehow prevent the type to be erased
    • Is this even possible? From my limited type provider understanding the designer of the provider makes the decision weather to erase the type or not
    • Maybe there are some interresting [] that will prevent erasure
    • Supply options to the type provider 'constructor'
  3. Choose a different type provider implementation that does not erase the type
  4. Relax the type constraints to obj and have helpers to access the fields of the type (all in the separate util project)

New idea:

If the code is first compiled by FSharp.Compiler.Service maybe figure out why it does not erase the types (assumption) as well as regular VS build process does

I think I will do more research on number 1 and if I fail proceed with 3.

Any suggestions on a good way to troubleshoot this?

AndreasBroager commented 3 years ago

I have this exact same problem. I have created a library, where I pull a backend for data. I use JsonProvider to "parse" the data, and I try to put it in the model.

It works fine while building the app, but liveupdate throws same error as it does for you.

Did you come up with a solution? if so, would you mind sharing it?