Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeLibrary example is missing mention of F# #5647

Open
1 of 3 tasks
lukemerrick opened this issue Jan 31, 2023 · 0 comments
Open
1 of 3 tasks

NativeLibrary example is missing mention of F# #5647

lukemerrick opened this issue Jan 31, 2023 · 0 comments

Comments

@lukemerrick
Copy link

Issue description

The AOT Native Library example does not include any F# code or documentation. Attempting to adapt the example to F# as in the below example causes a compiler error This attribute is currently unsupported by the F# compiler. Applying it will not achieve its intended effect. but I cannot find any mention of this limitation, workarounds, future support date, etc.

This is particularly confusing/frustrating because there is this lovely 2+ year old example of doing an F# native library in .NET SDK version 3, but there seems to be little else on the web discussing F# native libraries in more modern .NET.

It would be superb if someone would be willing to add some or all of the following information to either to this example repo or the official docs or both!

Information which would be super helpful to me and others like me

  • Whether there is an official mainline way to compile a Native Library from F# in the same way as C# in .NET 7
  • The backstory to the compiler error and the current outlook for adding UnmanagedCallersOnly support to the F# compiler
  • Best practices for working around the limitations in the current release of .NET 7 (is it best to use CoreRT despite it being superseded by mainline .NET?)

Thank you for reading!

// My attempt to expose a simple function in a Native Library build.
namespace HelloLib

open System.Runtime.InteropServices

module Say =
    [<UnmanagedCallersOnly(EntryPoint= "hello")>]
    let hello name =
        printfn "Hello %s" name

Target framework

Check the .NET target framework(s) being used, and include the version number(s).

  • .NET Core
  • .NET Framework
  • .NET Standard 7.0.102

If using the .NET Core SDK, include dotnet --info output. If using .NET Framework without the .NET Core SDK, include info from Visual Studio's Help > About Microsoft Visual Studio dialog.

dotnet --info output or About VS info
dotnet --info
.NET SDK:
 Version:   7.0.102
 Commit:    4bbdd14480

Runtime Environment:
 OS Name:     manjaro
 OS Version:  
 OS Platform: Linux
 RID:         manjaro-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.102/

Host:
  Version:      7.0.2
  Architecture: x64
  Commit:       d037e070eb

.NET SDKs installed:
  7.0.102 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant