Skip to content

F# using lazy keyword raises trimming warnings on publish. #17355

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

Open
abklearnhere opened this issue Jun 27, 2024 Discussed in #17323 · 1 comment
Open

F# using lazy keyword raises trimming warnings on publish. #17355

abklearnhere opened this issue Jun 27, 2024 Discussed in #17323 · 1 comment
Assignees
Labels
Area-AOT Everything related to AOT Bug Feature Improvement
Milestone

Comments

@abklearnhere
Copy link

abklearnhere commented Jun 27, 2024

Discussed in #17323

Originally posted by @abklearnhere June 18, 2024
F# using lazy keyword raises trimming warnings on publish. For example,

let f23 () = let z = lazy (12345) in z.Force()
[<EntryPoint>]
let main _ =
    f23() |> System.Console.WriteLine
    0

I am creating an F#, .NET 8 (SDK 8.0.302) console app and publish as a single file with AOT, trimming. I run dotnet publish command as below:

dotnet publish -c Release -r win-x64 --self-contained true -p:PublishAot=true -p:PublishTrimmed=true -p:ReflectionFree=false -o ./publish

This results in warning:

D:\a_work\1\s\src\FSharp.Core\prim-types.fs(7159): Trim analysis warning IL2091: Microsoft.FSharp.Control.LazyExtensions.Create(FSharpFunc`2<Unit,!!0>): 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in 'System.Lazy`1'. The generic parameter 'T' of 'Micros
oft.FSharp.Control.LazyExtensions.Create(FSharpFunc`2<Unit,!!0>)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

The warning appears regardless of -p:ReflectionFree being false or true. The fsproj file has following settings:

    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <IsAotCompatible>true</IsAotCompatible>
    <PublishAot>true</PublishAot>
    <PublishTrimmed>true</PublishTrimmed>
    <TrimmerSingleWarn>false</TrimmerSingleWarn>
@vzarytovskii
Copy link
Member

ReflectionFree doesn't affect pretty much anything outside printing.

@KevinRansom another instance of trimmning + annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AOT Everything related to AOT Bug Feature Improvement
Projects
Status: New
Development

No branches or pull requests

4 participants