mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.47k stars 538 forks source link

[BUG] .NET 9 Android: "Assembly 'SkiaSharp' produced trim warnings" #3042

Open tipa opened 1 week ago

tipa commented 1 week ago

Description

I am seeing build warnings when compiling my app with .NET 9 RC 2 for Android. Example project: test.zip

Code

In a .NET 9 Android project, add this:

[Register("test.ChartView")]
sealed partial class ChartView : SKCanvasView
{
    public ChartView(Context context, IAttributeSet attributes) : base(context) { }
}

You can also share some XAML:

<ItemGroup>
  <PackageReference Include="SkiaSharp.Views" Version="3.0.0-preview.4.1" />
</ItemGroup>

Expected Behavior

No warnings

Actual Behavior

C:\Users\me\.nuget\packages\skiasharp.views\3.0.0-preview.4.1\lib\net7.0-android33.0\SkiaSharp.Views.Android.dll : warning IL2104: Assembly 'SkiaSharp.Views.Android' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries
C:\Users\me\.nuget\packages\skiasharp\3.0.0-preview.4.1\lib\net7.0-android33.0\SkiaSharp.dll : warning IL2104: Assembly 'SkiaSharp' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries

Version of SkiaSharp

3.x-preview.4.1 (Current Preview)

Platform / Operating System

Android

Code of Conduct

charlesroddie commented 3 days ago

You need to put <TrimmerSingleWarn>false</TrimmerSingleWarn> in your project file to see the detailed warnings.

tipa commented 3 days ago

These are the detailed warnings:

ILLink : Trim analysis warning IL2122: SkiaSharp: Type 'SkiaSharp.Resource' is not assembly qualified. Type name strings used for dynamically accessing a type should be assembly qualified.
ILLink : Trim analysis warning IL2122: SkiaSharp.Views.Android: Type 'SkiaSharp.Views.Android.Resource' is not assembly qualified. Type name strings used for dynamically accessing a type should be assembly qualified.

Just to be clear, my app works well, I'd just like to have a warning-free build :)