AOT compilation warnings cannot be pinpointed in code
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:
- Create simple F# project with
printfn "%i 1 - Publish with AOT
- 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
At the time of AOT compilation, F# compiler is not at all involved.
There is a compiler flag, set by <OtherFlags>--reflectionfree</OtherFlags> in the project file - it does emit a compiler diagnostic at the time of F# compilation, i.e. before AOT is involved.
The AOT analysis warning comes for the produced IL code. Maybe the AOT analysis could make use of symbols mapping back to source code, just like the debugger does - that is my only idea that would provide a solution for the general problem (problem of AOT analysis being reported on the IL code level, and not linked to original source code the user is seeing and writing)