Ouch - Legacy and NRE
December 04, 2019 - Wednesday afternoon
Two things broke that make me sad - both of which originally surprised me with how smooth they were to implement.
1. BinaryFormatter + F#
I ran into a serialization problem that I still can't figure out how to reliably reproduce, maybe related to how F# maps are created. A 9! year old message here from Don Syme seems to suggest BinaryFormatter was considered legacy track already way back then.
Would've been nice to reflect that in the MSDN docs! I could probably work around this specific issue, but I don't know what else lurks around the corner. Looks like I need to pick up Json.NET for F# serialization, which I expect will come with it's own issues.
2. Unity + F#
I tried to put the app on Play Store to do an internal test release and discovered they require 64 bit builds. Unity's Mono script backend doesn't support 64 bit, so I had to change to il2cpp.
The il2cpp backend must build with assembly stripping (which I know as tree shaking from the javascript world), which causes a NullReferenceException in Unity's mono linker while traversing a generic collection in my project. There is no option to disable assembly stripping, only to change the aggressiveness of code removal.
Someone else had the same issue with an F# .dll, but theirs only occured with script debugging enabled whereas I'm not able to build with il2cpp at all. It hurts so good finding a year old duplicate issue with no solution, and as always there's a relevant xkcd.
So - I've filed a bug with Unity and am waiting to hear back. WTB 64bit Mono support in Unity. Or maybe I should try out Godot..
P.S. In case you do follow along in that NRE thread - I did try to find those tweets, and of course that user no longer exists.