Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic F# to C# translation

I was wondering if there's any automatic conversion of F# code to C# code that works well in practice. The reason for this is that we have a fair bit of logic in F# which we would like to use with Mono for Android, MonocMac, MonoTouch... to create an app for each platform. As those don't support F# directly it woould be nice if we could continue programming the logic in F# and do the GUI part with C# and those tools.

Anyone knows of something? Thanks.

like image 707
Jacobo Polavieja Avatar asked Feb 15 '12 11:02

Jacobo Polavieja


People also ask

What is ATF Type F?

3.0. 2 Reviews. Valvoline Type F ATF is an automatic transmission fluid that has been uniquely engineered to meet and exceed the requirements of older Ford and select import vehicles with automatic transmissions and is officially licensed and approved by Ford.

Do all Ford vehicles use Type F automatic transmission fluid?

This fluid was used in all Ford transmissions until 1977 and most Ford transmissions until 1980.

Can you use Type F transmission fluid for power steering?

The special frictional properties of Motorcraft ATF Type-F ensure proper shifting in Ford transmissions that require a fluid meeting ESW-M2C33-F. It is also recommended for power steering systems in a wide variety of Ford Vehicles calling for a Type-F fluid, built prior to Model Years 1996-1998.

What is compatible with Type F transmission fluid?

Ford Type F—an old ATF first introduced in 1967 and used in all Ford products prior to 1977, and in some until 1980; also used in various import vehicles of the period, including Mercury Capri, Jaguar, Mazda, Saab, Toyota, and Volvo. Type F is not compatible with any other ATF.


5 Answers

Why do you need to translate the code? A compiled managed binary should work well with Mono. Just add it to the project.

You can use a tool like ILSpy to decompile your code into another language, but that doesn't really change much - that's the whole point of compiling different languages into .NET CIL.

like image 188
skolima Avatar answered Nov 15 '22 18:11

skolima


Any .NET decompiler which supports both F# and C# can do it.

For example: Cecil.Decompiler and ILSpy.

Steve Gilham has some good articles about decompiling F# to C# using Cecil.Decompiler and ILSpy and some other blog posts about interoperability between F# and C# code. Those articles may be helpful for you.

Normally, I only use ILSpy when I wonder what's going on under F# code, which will be more explicit when decompiled to C#. Compiling F# code into a separate dll and consuming it in your C# code is the best way to go.

like image 39
pad Avatar answered Nov 15 '22 17:11

pad


In theory, you should be able to run your F# code on MonoTouch and Mono for Android. In practice...things are more complicated. :-)

MonoTouch and Mono for Android provide their own base class libraries which are incompatible with desktop .NET (they're largely a superset of Silverlight). In order to get your F# code running under MonoTouch and Mono for Android, you must first compile your F# code against the appropriate assemblies.

Furthermore, you'll need to either remove all dependencies on FSharp.Core.dll (is that even possible?) or port FSharp.Core.dll so that it can execute against the equivalent MonoTouch and Mono for Android assemblies. I'm sure this is possible, but I have no idea if it's been done or how easy this would be.

Once you have either removed or fulfilled the FSharp.Core.dll and related dependencies, you should be able to just add all the required assemblies (your F# assembly plus dependencies) to the project and run.

like image 23
jonp Avatar answered Nov 15 '22 18:11

jonp


Just found these blog posts by an F# and all things Mono guy: MonoTouch & F# P I and MonoTouch & F# P II

like image 34
Jwosty Avatar answered Nov 15 '22 19:11

Jwosty


Just compile your F# library with --standalone (Properties | Build | Other flags | --standalone) and it will incorporate FSharp.Core.dll into your library.

like image 24
Maximilian Wilson Avatar answered Nov 15 '22 18:11

Maximilian Wilson