You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by @abklearnhere June 18, 2024
I asked this question on StackOverflow and was suggested that it should be discussed on GitHub in relation to #15980 . Here is the original issue:
I am creating an F#, .NET 8 (SDK 8.0.302) console app and publish as a single file with AOT, trimming. I defined a discriminated union and used it in few trivial functions. But this raises AOT and trimming warnings when I run dotnet publish command. Is this expected or am I missing something obvious? I am running:
typeAnyDU= X | Y
letf1()=letunrelated= System.DateTime.Now in()letf2()=letworks= X in()letf3()=letworks= X inmatch works with| X ->0|_->1letf4()=letunrelated= System.DateTime.Now inletfails= X in()letf5()=letfails= X inif fails = X then1else0[<EntryPoint>]letmain _ =
f1 ()|> ignore // no warnings. unrelated.
f2 ()|> ignore // no warnings.
f3 ()|> ignore // no warnings.
f4 ()|> ignore // IL3053 and IL2104 warnings.
f5 ()|> ignore // IL3053 and IL2104 warnings.0
When I added <TrimmerSingleWarn>false</TrimmerSingleWarn> to fsproj, I got around 50 warnings mostly related to reflection and print formatting with warning codes: IL2055, IL2060, IL2067, IL2070, IL2072, IL2075, IL2080, IL3050.
Also, adding [<Struct>] attribute to the DU didn't help.
The example code is simplified. My real DU structure and usage is fairly complex. So enums instead of DUs is not an option.
So, am I missing something obvious or this is expected? Should I report this as an issue?
The text was updated successfully, but these errors were encountered:
Currently you have to use the --reflectionfree switch to make F# trim-safe. This removes generated .ToString() methods. To get useful ToString() methods you then need to override these and manually write out code. This is what we do.
The reason for this is that the generated .ToString() methods are not properly compiled at present. A proposal to do so is in fsharp/fslang-suggestions#919 .
Thanks @vzarytovskii, @charlesroddie for creating #17324 and suggesting --reflectionfree. It did remove warnings and enabled me to try some more tests. I've shared some interesting findings and follow up queries in the original discussion #17323. Will be great to get a feedback!
Discussed in #17323
Originally posted by @abklearnhere June 18, 2024
I asked this question on StackOverflow and was suggested that it should be discussed on GitHub in relation to #15980 . Here is the original issue:
I am creating an F#, .NET 8 (SDK 8.0.302) console app and publish as a single file with AOT, trimming. I defined a discriminated union and used it in few trivial functions. But this raises AOT and trimming warnings when I run
dotnet publish
command. Is this expected or am I missing something obvious? I am running:And the code is:
The
fsproj
file has following settings:When I added
<TrimmerSingleWarn>false</TrimmerSingleWarn>
tofsproj
, I got around 50 warnings mostly related to reflection and print formatting with warning codes: IL2055, IL2060, IL2067, IL2070, IL2072, IL2075, IL2080, IL3050.Also, adding
[<Struct>]
attribute to the DU didn't help.The example code is simplified. My real DU structure and usage is fairly complex. So
enums
instead of DUs is not an option.So, am I missing something obvious or this is expected? Should I report this as an issue?
The text was updated successfully, but these errors were encountered: