Skip to content

AOT compilation warnings cannot be pinpointed in code #18959

@webe42

Description

@webe42

Please provide a succinct description of the issue:

Attempting to use AOT with F# is problematic when trying to identify where your code may be calling offending functions. The C# compiler seems to do better with this by providing the exact call site, F# compiler does not.

It seems F# isn't fully AOT compatible yet and will take some time to get there. But a resolution to this item could ease the pain in the meantime.

Provide the steps required to reproduce the problem:

  1. Create simple F# project with printfn "%i 1
  2. Publish with AOT
  3. Observe AOT trim warnings

Expected behavior

As with the C# compiler, the call site is pin-pointed to your code. In this example it is pin-pointed to Program.Main():

AOT analysis warning IL3050: Program.<Main>$(String[]): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.

Actual behavior

Call site is obscured with the F# compiler:

AOT analysis warning IL3050: Microsoft.FSharp.Reflection.Impl.getUnionCaseTyp(Type,Int32,BindingFlags): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.

Known workarounds

None

Related information

I've had some limited success using tricks learned here. But it isn't easy or timely.

  • Operating system=Windows&Linux
  • .NET Runtime = .NET Core 10 rc1
  • Editing Tools = VSCode

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions