Skip to content
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

[Trimming][AOT] Investigate trimming and AOT warnings in dotnet new maui-blazor sample app #22368

Open
simonrozsival opened this issue May 13, 2024 · 1 comment
Assignees
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming)

Comments

@simonrozsival
Copy link
Member

This is a follow-up to #22282 and it is related to #18658

When publishing the dotnet new maui-blazor app with NativeAOT using the current net9.0 build of MAUI (a45f7021b7773b18f93800bd2d804fe56a6360ef), the ILC reports the following 26 warnings:

> dotnet new maui-blazor
> ../maui/dotnet-local.sh publish -f net9.0-maccatalyst -r maccatalyst-arm64 -p:PublishAot=true -p:PublishAotUsingRuntimePack=true -p:TrimmerSingleWarn=false
...
ILC : warning IL3000: Microsoft.AspNetCore.Components.WebView.WebViewManager.StaticWebAssetsLoader.ResolveRelativeToAssembly(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
ILC : warning IL3000: Microsoft.AspNetCore.Components.WebView.WebViewManager.StaticWebAssetsLoader.ResolveRelativeToAssembly(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
ILC : warning IL3000: Microsoft.AspNetCore.Components.WebView.WebViewManager.StaticWebAssetsLoader.ResolveRelativeToAssembly(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
ILC : Trim analysis warning IL2067: Microsoft.AspNetCore.Components.WebView.Services.WebViewRenderer.AddRootComponent(Type,String): '' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'Microsoft.AspNetCore.Components.RenderTree.WebRenderer.AddRootComponent(Type,String)'. The parameter '#0' of method 'Microsoft.AspNetCore.Components.WebView.Services.WebViewRenderer.AddRootComponent(Type,String)' 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.
ILC : AOT analysis warning IL3050: Microsoft.AspNetCore.Components.RenderTree.WebRenderer.AttachWebRendererInterop(IJSRuntime,JsonSerializerOptions,JSComponentInterop): Using member 'System.Text.Json.JsonSerializer.Serialize<Object[]>(Object[],JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.AspNetCore.Components.Web.Infrastructure.JSComponentInterop.SetRootComponentParameters(Int32,Int32,JsonElement,JsonSerializerOptions): Using member 'System.Text.Json.JsonSerializer.Deserialize(JsonElement,Type,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.AspNetCore.Components.Web.Infrastructure.JSComponentInterop.SetRootComponentParameters(Int32,Int32,JsonElement,JsonSerializerOptions): Using member 'System.Text.Json.JsonSerializer.Deserialize<IJSObjectReference>(JsonElement,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.AspNetCore.Components.Web.Infrastructure.JSComponentInterop.SetRootComponentParameters(Int32,Int32,JsonElement,JsonSerializerOptions): Using member 'System.Text.Json.JsonSerializer.Deserialize<IJSObjectReference>(JsonElement,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.Infrastructure.DotNetObjectReferenceJsonConverterFactory.CreateConverter(Type,JsonSerializerOptions): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
ILC : AOT analysis warning IL3050: Microsoft.AspNetCore.Components.Web.WebEventData.ParseEventArgsJson(Renderer,JsonSerializerOptions,UInt64,String,JsonElement): Using member 'System.Text.Json.JsonSerializer.Deserialize(String,Type,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : Trim analysis warning IL2072: Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider,IComponent): '' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'Microsoft.AspNetCore.Components.ComponentFactory.GetComponentTypeInfo(Type)'. The return value of method 'System.Object.GetType()' 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.
ILC : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.WebView.IpcCommon.Serialize(String,Object[]): Using member 'System.Text.Json.JsonSerializer.Serialize<IEnumerable`1<Object>>(IEnumerable`1<Object>,JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
ILC : AOT analysis warning IL3050: Microsoft.AspNetCore.Components.WebView.IpcCommon.Serialize(String,Object[]): Using member 'System.Text.Json.JsonSerializer.Serialize<IEnumerable`1<Object>>(IEnumerable`1<Object>,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : Trim analysis warning IL2072: Microsoft.AspNetCore.Components.CascadingParameterState.FindCascadingParameters(ComponentState,Boolean&): '' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'Microsoft.AspNetCore.Components.CascadingParameterState.GetCascadingParameterInfos(Type)'. The return value of method 'System.Object.GetType()' 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.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime,DotNetInvocationInfo,String): Using member 'System.Text.Json.JsonSerializer.Serialize<Object>(Object,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.WebView.IpcCommon.TryDeserialize<T>(String,T&,ArraySegment`1<JsonElement>&): Using member 'System.Text.Json.JsonSerializer.Deserialize(ReadOnlySpan`1<Char>,Type,JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
ILC : AOT analysis warning IL3050: Microsoft.AspNetCore.Components.WebView.IpcCommon.TryDeserialize<T>(String,T&,ArraySegment`1<JsonElement>&): Using member 'System.Text.Json.JsonSerializer.Deserialize(ReadOnlySpan`1<Char>,Type,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.JSRuntime.EndInvokeJS(Int64,Boolean,Utf8JsonReader&): Using member 'System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader&,Type,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.JSRuntime.InvokeAsync<TValue>(Int64,String,CancellationToken,Object[]): Using member 'System.Text.Json.JsonSerializer.Serialize<Object[]>(Object[],JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.Infrastructure.DotNetDispatcher.EndInvokeDotNetAfterTask(Task,JSRuntime,DotNetInvocationInfo&): Using member 'System.Text.Json.JsonSerializer.Serialize<Object>(Object,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.Infrastructure.DotNetDispatcher.<>c.<GetTaskByType>b__14_0(Type,MethodInfo): Using member 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.Infrastructure.DotNetDispatcher.ParseArguments(JSRuntime,String,String,Type[]): Using member 'System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader&,Type,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
ILC : Trim analysis warning IL2111: Microsoft.JSInterop.Infrastructure.DotNetDispatcher.GetCachedMethodInfo(IDotNetObjectReference,String): Method 'Microsoft.JSInterop.Infrastructure.DotNetDispatcher.<GetCachedMethodInfo>g__ScanTypeForCallableMethods|16_0(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
ILC : Trim analysis warning IL2065: Microsoft.JSInterop.Infrastructure.DotNetDispatcher.ScanAssemblyForCallableMethods(DotNetDispatcher.AssemblyKey): Value passed to implicit 'this' parameter of method 'System.Type.GetMethods(BindingFlags)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.Infrastructure.TaskGenericsUtil.<>c.<GetTaskResult>b__5_0(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
ILC : AOT analysis warning IL3050: Microsoft.JSInterop.Infrastructure.TaskGenericsUtil.<>c.<CreateResultSetter>b__12_0(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
...
@simonrozsival simonrozsival added the area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) label May 13, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming)
Projects
None yet
Development

No branches or pull requests

2 participants