Originally posted by **@abklearnhere** June 18, 2024
F# using lazy keyword raises trimming warnings on publish. For example,
```fsharp
let f23 () = let z = lazy (12345) in z.Force()
[]
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:
```powershell
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): '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)' 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:
```xml
Exenet8.0truetruetruefalse
```
Discussed in https://github.com/dotnet/fsharp/discussions/17323
ReflectionFree
doesn't affect pretty much anything outside printing.@KevinRansom another instance of trimmning + annotations.