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

Replace a sprintf in the Tetris example with a string interpolation #429

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

Numpsy
Copy link
Collaborator

@Numpsy Numpsy commented Jul 3, 2024

I tried doing a NativeAOT build of the Tetris example on top of #413 to see if it worked and got

GenericMethod() is not compatible with AOT compilation. Inspect and fix AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.GetUncachedMethodInvoker(RuntimeTypeInfo[], MemberInfo) + 0x2f
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.MakeGenericMethod(Type[]) + 0x189
   at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.buildCaptureFunc[a](PrintfImpl.FormatSpecifier, a, Type[], Type, Tuple`5) + 0x245
   at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.parseAndCreateFuncFactoryAux(FSharpList`1, String, Type, Int32&) + 0x22c
   at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.parseAndCreateFunctionFactory() + 0x78
   at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.GetCurriedPrinterFactory() + 0x1f
   at Microsoft.FSharp.Core.PrintfImpl.FormatParser`4.GetCurriedStringPrinter() + 0x20
   at Example.Tetris.View.menuView[a](Game.State, a) + 0x191
   at Example.Tetris.View.view$cont@142(Game.State, FSharpFunc`2, Unit) + 0xa0
   at Avalonia.FuncUI.Elmish.Program.withHost@14.Invoke(model, FSharpFunc`2) + 0x78
   at Elmish.ProgramModule.runWithDispatch[msg,arg,model,view](FSharpFunc`2, arg, Program`4) + 0x200
   at Example.Tetris.MainWindow..ctor() + 0x21e
   at Example.Tetris.App.OnFrameworkInitializationCompleted() + 0x26
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder, String[], Action`1) + 0x2f
   at Examples.Elmish.Tetris!<BaseAddress>+0x99a8d3

and changing the sprintf to an interpolation seems to fix it (after that change, the AOT build seems to be fully functional on Windows, haven't tried any other platforms)

@JaggerJo JaggerJo merged commit 11bf204 into fsprojects:master Jul 4, 2024
1 check passed
@Numpsy Numpsy deleted the interp branch July 4, 2024 09:47
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

Successfully merging this pull request may close these issues.

None yet

2 participants