Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portable Class Library using F# without FSharp.Core.dll reference

I tried to create portable class library using F# which could be used for example from C# code. But looks like using standard F# constructs, like raise makes FSharp.Core.dll necessary to use created Portable Class Library.

raise(ArgumentNullException("parameter")) is transformed into

Operators.Raise<Unit>(new ArgumentNullException("source"));

(where Operators.Raise lives in Microsoft.FSharp.Core namespace) instead of just

throw new Exception

I assume that's not the only F# construct which is compiled to some static method from FSharp.Core.dll library.

Is there any way to create F# code (especially Portable Class Library) which after compilation does not require a reference to FSharp.Core.dll or any other FSharp-specific library?

like image 671
MarcinJuraszek Avatar asked Jan 24 '14 06:01

MarcinJuraszek


2 Answers

If you compile the code with

--standalone

the compiler will do an equivalent of static linking. As a result, the references won't be needed at run time.

This is probably the best you can do.

like image 141
John Palmer Avatar answered Oct 16 '22 07:10

John Palmer


Ideally you would be referencing a portable version of FSharp.Core that have been built against a certain profile, rather than statically linking everything.

I think there are portable versions of profile 47, 88, and 158.

like image 32
7sharp9 Avatar answered Oct 16 '22 07:10

7sharp9