Skip to content

NativeAOT FSharp issue #70999

@kant2002

Description

@kant2002

Not sure if I again on the unsupported territory or not, but let's pretend not.

Get code from this PR JamesRandall/fsharp-wolfenstein#7 and add

diff --git a/desktop/FSharpWolfenstein.Desktop.fsproj b/desktop/FSharpWolfenstein.Desktop.fsproj
index 74c5450..a7114eb 100644
--- a/desktop/FSharpWolfenstein.Desktop.fsproj
+++ b/desktop/FSharpWolfenstein.Desktop.fsproj
@@ -2,9 +2,11 @@

     <PropertyGroup>
         <OutputType>Exe</OutputType>
-        <TargetFramework>net6.0</TargetFramework>
+        <TargetFramework>net7.0</TargetFramework>
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
         <PublishAot Condition="'$(TargetFramework)' == 'net7.0'">true</PublishAot>
+        <IlcTrimMetadata>true</IlcTrimMetadata>
+        <TrimmerDefaultAction>link</TrimmerDefaultAction>
     </PropertyGroup>

     <ItemGroup>

Publish with dotnet publish -c Release --self-contained.
Mostly application works, but some diagnostic information triggers

Unhandled Exception: System.Collections.Generic.KeyNotFoundException: An index satisfying the predicate was not found in the collection.
   at Microsoft.FSharp.Collections.ArrayModule.loop@596-36[T, TResult](FSharpFunc`2, T[], Int32) + 0x9e
   at Microsoft.FSharp.Reflection.Impl.getUnionCaseTyp(Type, Int32, BindingFlags) + 0x3e
   at Microsoft.FSharp.Reflection.Impl.fieldsPropsOfUnionCase(Type, Int32, BindingFlags) + 0x143
   at Microsoft.FSharp.Reflection.FSharpValue.GetUnionFields(Object, Type, FSharpOption`1) + 0x6f
   at Microsoft.FSharp.Text.StructuredPrintfImpl.ReflectUtils.Value.GetValueInfoOfObject$cont@525(BindingFlags, Object, Type, Unit) + 0x57
   at Microsoft.FSharp.Text.StructuredPrintfImpl.Display.ObjectGraphFormatter.objL(Display.ShowMode, Int32, Display.Precedence, Object, Type) + 0x3f
   at Microsoft.FSharp.Text.StructuredPrintfImpl.Display.Format@1515.Invoke(Int32, Display.Precedence, Tuple`2) + 0x3a
   at Microsoft.FSharp.Text.StructuredPrintfImpl.Display.ObjectGraphFormatter.Format[a](Display.ShowMode, a, Type) + 0x83
   at Microsoft.FSharp.Text.StructuredPrintfImpl.Display.anyToStringForPrintf[T](FormatOptions, BindingFlags, T, Type) + 0x5c
   at Microsoft.FSharp.Core.PrintfImpl.ObjectPrinter.GenericToStringCore[T](T, FormatOptions, BindingFlags) + 0x47
   at Microsoft.FSharp.Core.PrintfImpl.OneStepWithArg@508-1.Invoke(A) + 0x37
   at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider, String, ParamsArray) + 0x644
   at System.String.FormatHelper(IFormatProvider, String, ParamsArray) + 0xae
   at Microsoft.FSharp.Core.PrintfImpl.InterpolandToString@924.Invoke(Object) + 0x75
   at Microsoft.FSharp.Core.PrintfImpl.PrintfEnv`3.RunSteps(Object[], Type[], PrintfImpl.Step[]) + 0xb4
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThen[T](PrintfFormat`4) + 0x6a
   at App.AI.preProcess(Model.Game, Model.Enemy) + 0x110
   at App.AI.applyAi(Double, Model.Game, Model.GameObject) + 0x5b
   at App.Update.updatedGameObjects@254.Invoke(Int32, Model.GameObject) + 0x95
   at Microsoft.FSharp.Primitives.Basics.List.mapiToFreshConsTail[a, b](FSharpList`1, OptimizedClosures.FSharpFunc`3, FSharpList`1, Int32) + 0x5c
   at Microsoft.FSharp.Primitives.Basics.List.mapi[T, TResult](FSharpFunc`2, FSharpList`1) + 0xb1
   at App.Update.updateEnemies@251(Double, Model.WallRenderingResult, Model.Game, Boolean) + 0x67
   at App.Update.updateFrame(Model.Game, Double, Model.WallRenderingResult) + 0x295
   at Program.render(Double) + 0x4a
   at Program.main@198-1.Invoke(Double) + 0x9
   at Silk.NET.Windowing.Internals.ViewImplementationBase.DoRender() + 0x16e
   at Silk.NET.Windowing.Internals.ViewImplementationBase.Run(Action) + 0x15
   at Silk.NET.Windowing.WindowExtensions.Run(IView) + 0x61
   at Program.main(String[]) + 0x149
   at FSharpWolfenstein.Desktop!<BaseAddress>+0x462583

Which seems to be from this line

https://github.com/JamesRandall/fsharp-wolfenstein/blob/4032d6e3157dd3ca99a26ab617be2f983700a3e9/browser/src/CrossPlatform/AI.fs#L278

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions