fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Publishing a trimmed ASP.NET project does not print trim warnings

Open kerams opened this issue 3 years ago • 7 comments

Repro steps

  1. Create an empty C# ASP.NET application
  2. Create an empty F# ASP.NET application
  3. Put <PublishTrimmed>true</PublishTrimmed> into both project files
  4. dotnet publish -c Release --self-contained each project

Expected behavior

Publishing the F# project prints a list of warnings similar to the C# counterpart. Such as:

ILLink : Trim analysis warning IL2026: System.Security.Cryptography.Xml.CryptoHelpers.CreateFromName<T>(String): Using
member 'System.Security.Cryptography.CryptoConfig.CreateFromName(String)' which has 'RequiresUnreferencedCodeAttribute'
 can break functionality when trimming application code. The default algorithm implementations might be removed, use st
rong type references like 'RSA.Create()' instead. [snip\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj]
snip\.nuget\packages\microsoft.aspnetcore.app.runtime.win-x64\7.0.0-rc.2.22476.2\runtimes\win-x64\lib\net7.0\M
icrosoft.AspNetCore.Components.dll : warning IL2104: Assembly 'Microsoft.AspNetCore.Components' produced trim warnings.
 For more information see https://aka.ms/dotnet-illink/libraries [snip\ConsoleApp1\ConsoleApp1\Cons
oleApp1.csproj]

Actual behavior

Publishing the F# project prints no warnings at all.

Known workarounds

None.

Related information

  • 7.0.100-rc.2.22477.23
  • Win 10

kerams avatar Oct 29 '22 08:10 kerams

I'm not entirely sure it's F# issue, we don't so anything special regarding this flag.

@baronfel do you happen to know who we can talk to about it?

vzarytovskii avatar Oct 29 '22 18:10 vzarytovskii

Fair. I suspected the issue might be transferred, but this repo seemed like a good first port of call.

kerams avatar Oct 29 '22 18:10 kerams

Not 100% sure, I'd want to see a binlog of each case and try to identify what's different.

Though I fear that if the analysis is Roalyn-analyzer-based, F# simply won't be able to participate in it at all.

@agocke do you know off the top of your head how this works?

baronfel avatar Oct 29 '22 18:10 baronfel

Yup, we have two experiences: roslyn analyzers for build time analysis and IL analysis during publishing. I'd definitely expect F# to get the IL analysis during publish. If it's not, my first guess is that warnings are disabled somehow via <SuppressTrimAnalysisWarnings>true</>. That's not supposed to be enabled for ASP, but I can't rule it out,

agocke avatar Oct 29 '22 21:10 agocke

Building an Android project with trimming and AOT enabled does not print any warnings at all either.

kerams avatar May 28 '24 07:05 kerams

@kerams My recollection is that warnings are suppressed by default for Android. Could you try setting SuppressTrimAnalysisWarnings to false?

agocke avatar May 28 '24 22:05 agocke

Nothing. I'm guessing F# tooling swallows or does not opt into these.

kerams avatar May 29 '24 06:05 kerams