-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
In some cases, ilc keeps some code in the final executable, but the only code path accessing it has been trimmed.
Reproduction Steps
Clone https://github.com/MrJul/repro-ilc-not-trimming
Run dotnet publish -r win-x64
This is a very stripped down version of code from Avalonia reproducing the problem.
(Note that in this example, only one type is kept, but in Avalonia there are more.)
Expected behavior
Everything in LinuxLib is trimmed, only WindowsLib is referenced.
Actual behavior
X11RenderingMode from LinuxLib isn't trimmed, but all methods using it have been removed.
In the following screenshots, we can notice that X11RenderingMode is referenced from X11PlatformOptions's constructor, which has been trimmed away:


Regression?
No.
Known Workarounds
No response
Configuration
Latest Microsoft.DotNet.ILCompiler from daily build, 9.0.0-rc.1.24381.5
Other information
For comparison, ILLink works fine in this scenario: no LinuxLib assembly is visible in the trimmed folder.
Note that with .NET 8.0.7, the whole call path (X11PlatformOptions, AvaloniaX11PlatformExtensions, etc.) is incorrectly kept by ilc.
With .NET 9.0.0-rc.1.24381.5, only X11RenderingMode is kept. I couldn't find the PR that fixed the above, but it's probably related to this issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status