-
-
Notifications
You must be signed in to change notification settings - Fork 90
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 testing for vanilla and ocamlcompatible serializers #4252
Conversation
The annotation didn't actually do this - it only runs when reflection functions are called on the type, so we couldn't guarantee that all the serialized types were made note of, preventing us from doing regression testing on them.
(users don't have characters anyway)
…alizer This makes it much easier to debug why initializers are called
This allows the serializers initialization to run
e47d47c
to
b1a01e6
Compare
let newValue = (name, f v) :: currentValue | ||
data[key] <- newValue | ||
|
||
let v<'t when 't : equality> (dataName : string) (data : 't) = |
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 think it's a marginal cost to rename these fns to vanilla
and ocamlcompat
for sake of legibility
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.
or better yet, genVanilla
and genOcaml
. Even genV
and genO
would be better
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 looks good. I've noted various minor change requests, but barring those this makes me feel more secure in our serializers. (though naturally there's still work to be done for additional serializers)
@@ -307,6 +66,9 @@ type EvalWorker = | |||
/// | |||
/// Once evaluated, an async call to `self.postMessage` will be made | |||
static member OnMessage(input : string) = | |||
// We'd like to only call this once on initialization, but I can't figure out how |
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.
Here's my idea:
- define
static member OnInit() = ...
fn - create a binding to that exposed member, and call it right before the 2+3 warmup call, here:
const messageHandler = Module.mono_bind_static_method( |
Or have you tried that and it doesn't work?
Adding the initializer to BlazorWorker/EvalWorker worked great, thanks! |
After many wrong paths, this adds testing to the Vanilla and OCamlCompatible serializers. This adds significant clarity about what kind of changes can be safely made to the serializers. It also adds some (indirect sorta) documentation to where the serializers are used.
The tests have three parts:
Json.Vanilla.allow<type> "reason"
(orJson.OCamlCompatible
) in new initialization functionsbackend/serialization
, and are checked against them. Any changes cause these files to change (they are checked into git)Most of the excitement here is in Serialization.Tests.fs
We now have a really good understanding of where the vanilla and ocamlcompatible serializers are used, which should make it much easier to eradicate the ocamlcompatible one (in some future PRs)
Some things I did to make this work:
./scripts/build/dotnet-fsi