When using strings with units of measure (defined in the FSharp.UMX package), I see warnings like this:
WARNING in ./src/Client/Client.fs 72:48-79
"export 'string$00601$reflection' (imported as 'string$002400601$0024reflection') was not found in '../../.fable/FSharp.UMX.1.0.0/FSharp.UMX.fs'
@ ./src/Client/Client.fsproj
@ multi ./src/Client/Client.fsproj
Does this indicate a potential problem in FSharp.UMX or Fable compiler itself?
https://github.com/kerams/umx-repro
fake build -t run
Expecting no warnings issued since the application seems to work fine (though I do also currently see runtime errors that could be related in a different project which uses Fable.Remoting, which in turn relies on reflection).
Indeed, when I remove strings with units of measure from the Fable.Remoting contract, the runtime errors disappear.
So the warnings are justified, but at the same time, I think the necessary reflection metadata should either be generated or the unit of measure erased.
This seems to be an issue of the F# compiler. I haven't found a way to access the abbreviated type from string<[<Measure>] 'm> and the like (it's possible with the measure annotated abbreviations in FSharp.Core though). See https://github.com/dotnet/fsharp/issues/5992
The only work around I can think of at the moment is to use a custom attribute in FSharp.UMX to indicate the abbreviated type. It would be redundant but it would give Fable access to that information. The ideal solution would be to fix it in the F# compiler, of course.
Just hit the same issue, too bad...
Maybe we could hardcode the names of the annotated types is FSharp.UMX as in here... 馃 https://github.com/fable-compiler/Fable/blob/7d02d3e690a9b15cb7ca823b90c20f46f13f2a37/src/Fable.Transforms/FSharp2Fable.Util.fs#L511-L515
I guess as long as it's done for "all primitive types" it would cover it?
There's some other problem compiling the example though. Guess this used to work at some point?
Hmm, iirc it did work when we published the first version of FSharp.UMX but we may have broken it 馃槧 I should have added it to the tests.
Let's hope that https://github.com/dotnet/fsharp/pull/6805 gets merged soon and we can access the SRTP witness from Fable.
I reckon if this workaround is trivial to implement, it would be better than nothing for the time being.
This seems to work in this branch #2240
Does the fix require Fable 3.x then?
Yes, but you'll get many other benefits from the upgrade too :)
Getting a Fable compilation error when using UOM Guid:
error EXCEPTION: Cannot find dll entity System.Guid
I thought I'd reproduce the problem in the PR, but the tests compile, so now I don't know what to think. I get the error in all the files where I use the Guid UOM types, but not in the file that defines the types.
I think I found the issue, I will add a fix for next release.
@et1975 Can you please try with latest release? dotnet tool update fable --version "3.0.0-*"
Woo-hoo, you rock, as usual 馃憤
Thank you!