-
Notifications
You must be signed in to change notification settings - Fork 17
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
Upgrade to Nagareyama #54
Conversation
elif isBigInt (get key jsThis) then | ||
let bigInt : bigint = get key jsThis | ||
elif isBigInt v then | ||
let bigInt : bigint = !!v |
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.
this
fails here if the function is compiled as an arrow function. But using the value directly works in either case.
let unexpectedJson = JS.JSON.stringify otherwise | ||
let expectedType = JS.JSON.stringify cases | ||
let unexpectedJson = string otherwise | ||
let expectedType = string cases |
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.
We're removing inheritance of union types because of performance reasons so we're giving up some utility methods like toJSON
to avoid repetition in every class definition. We can consider to add them again, but using the string operators works here anyways.
Hi @alfonsogarciacaro, thanks a lot for giving this a go. I am running the tests locally and oh boy many stuff broke 😅
This seems to be root problem of many of failing tests especially for the following types:
I understand that you don't want to repeat Can you please rebase on master? I have added some functionality to handle the Fable 3 awkwardness without the I am not able to run the application in the browser with webpack, is that not possible yet with Fable 3? Final question, can you help me figure out why the specialized |
I just pushed a new release of SimpleJson that handles the serialization via Reflection in order to control the generated JSON structure with serializing objects into JSON and avoiding the runtime implementation details of the objects (even though the deserializer will be able to handle those anyways) I believe I made the library Nagareyama-proof by now 😄 just need to run the tests against it 🚀 |
Wow, I was trying to bring back the missing stuff from Fable 2 to Nagareyama but seems you are faster 🏎️ |
Having |
@alfonsogarciacaro I made some more changes to allow running nagareyama alongside Fable 2.x and it now on master: # Run Fable 2.x tests
npm test
# Run Nagareyama tests
npm run test-nagareyama There are some issues when creating let output = System.Collections.Generic.Dictionary<IStructuralComparable, _>() Where I tried using let output = Activator.CreateInstance(concreteDictionaryType) |> unbox<Dictionary<IStructuralComparable, _>> But creating the instance of the dictionary fails saying:
At least something like that where the issue remains of not being able to create the dictionary via reflection, any ideas? 🤔 |
Sorry, forgot to reply to this. Nagareyama is compatible with Webpack, but you need to do a few changes, see MangelMaxime/fulma-demo#43 Also, I've released nagareyama-alpha-008, can you please try with that? Hopefully it solves some of the problems including the dictionary. As unions/records are inheriting Equals/CompareTo again a generic comparer should work, this is what Thoth.Json does although it deals with string keys separately (mainly for performance to make sure a native js Map is generated): https://github.com/thoth-org/Thoth.Json/blob/c52e7ea7ff9918ea0ae82e098cbe2053b3f82e49/src/Decode.fs#L1171 Anyways, you're right that Fable 2 & 3 generate a different hash function for |
Thoth seems to only handle dictionaries where the key is a I was able to solve this problem by cheating a little bit and tricking Fable into generating the right comparer function using dummy types: let output =
match keyType with
| TypeInfo.Union _ -> Dictionary<Result<_, _>, _>()
| TypeInfo.Record _ -> Dictionary<{| dummy: int |}, _>() |> unbox
| _ -> Dictionary<IStructuralComparable, _>() |> unbox Now all the tests are running both for Fable 2.x and Fable 3 as of SimpleJson 3.13
As for the changes in webpack, I would really really appreciate if you could reconsider the removal of the use of |
@alfonsogarciacaro I've implemented Fable 3 support in this repo with backward-compatibility with Fable 2.x this is pretty much resolved. Thanks a lot for giving me the head start 😄 I will close this PR and will keep updating the Fable 3 version as more releases become available |
This uses Nagareyama instead of fable-splitter to run the tests. In order to run ES2015 modules directly, I'm passing the
-r esm
option to Mocha.I made a few minor code changes but some tests are still failing. I know we don't want to make breaking code changes in Fable 3 but some things in SimpleJson depend on Fable or even F# implementation specifics and can easily break so it'd be nice to fix those. For example the FSharpMap and FSharpSet internal representation are changing in FSharp.Core and we're porting the change to Fable: dotnet/fsharp#10188
It's true that testing the type of a dynamic object is tricky in Fable. Nagareyama is removing the restriction of testing generic types (although the type parameters are still ignored) maybe that could help. We could also includes some methods in Fable.Core.Reflection like
isMap
,isSet
, isDictionary`, etc.