Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

[.Net Native] F# Support #5780

@charlesroddie

Description

@charlesroddie

[2018-12-06 update] F# UWP apps are releasable via the Windows Store. #6055 (comment)

[2018-06-17 update] UWP apps are compiling and running. More progress by the community in the last 4 days than Microsoft made in 3 years. The main issue is sprintf and we are looking into workarounds.

Problem

F# libraries cannot be used to create native UWP store apps. This results from the lack of F# support in the .NET Native UWP AOT compiler, which is required for publishing UWP store apps. In this post UWP will mean native UWP, i.e. compiled to IL or machine code.

Why support is needed

  1. Windows application programming.
    a) UWP is actively developed (the platform itself and 3rd party components), unlike WPF.
    b) UWP also allows AR/VR and XBox apps, and Windows 10 IoT.
  2. F# becomes toxic for cross-platform applications or controls that must support UWP.
    a) Xamarin.Forms F# developers end up without Windows app support.
    b) Creating Xamarin.Forms controls in F# for general consumption is effectively ruled out since UWP support is expected.
    c) Xamarin.Forms developers must avoid using .Net libraries if they are written in F#.

There has been huge user demand for this, with 1500+ votes for Add F# support for .NET Native and 2000+ votes for F# support in .Net native for UWP when those were active. This thread is a continuation of F# Support in .NET Native and UWP.

Status of work

Unfortunately users outside Microsoft cannot work on .Net Native. Microsoft has promised support:

2015-10 @crutkas: We are committed to bringing F# support to .NET Native... we’ve been working on .NET Native support for more advanced .NET IL code, like tail call instructions and complex generic types

2016-07 @cartermp: We get recent internal builds of the toolchain that we run tests on, we add tests to try and see what else we can break, and we report issues. These issues get logged into the .NET Native engineering backlog as soon as they come up.

2017-08 @cartermp: We'll remain subject matter experts for the UWP team to work with on .NET Native support, push for F# on their priority list after their .NET Standard support is completed, and we'll also contribute in identifying problems that need to be solved for proper .NET Native support.

Unfortunately the issue appears to have slipped between Microsoft teams with no-one currently working on it.

Technical issues

Two hard issues have been mentioned from the beginning, but the first seems to have been a red herring, and the second may have been fixed.

Tailcall support
2016-16-07 @dsyme: Yes, it's feasible for tailcalls just to be ignored in first-cut support. UWP Native would just have to ignore the tailcall prefix.

Generics
2017-09-04 @KevinRansom: I'm pretty sure the nested generics got fixed.

There is no public information about other issues and therefore it is not publicly known what is blocking F# usage.

What the community can do

Test .Net Native and CoreRT

CoreRT testing is in progress. It is now possible to test .Net Native. See @DjArt 's post here.

You can use the scaffolding here to test .Net Native and CoreRT. The F# cheatsheet works and we are starting to test the F# test suite. You can also try your UWP/Xamarin Forms apps. Generally avoid printf etc. and ToString() on F# record types and discriminated unions.

Please report issues in this (CoreRT) repo. If issues in .Net Native can be fixed in CoreRT, the fixes can probably be moved over into .Net Native.

Workarounds

  • F# can be used to create non-Store UWP apps that are sideloaded onto Windows PCs that are in "developer mode".
  • F# can be used to create Store apps using non-UWP technology (using desktop bridge with e.g. WPF or javascript transpliation with e.g. Fable/React Native).
  • Xamarin Forms has a preview of WPF support. Whether this becomes a viable platform depends on support by 3rd party controls.
  • (Speculative) In the .Net Core 3.0 timeframe, UWP controls can be used in WPF apps. Presumably .Net Native is not required. We may be able to create a store app using WPF (desktop bridge) hosting a UWP app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions