Trim warnings from components assemblies
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
When a .NET web app is published with trimming there are components trim warnings.
For example:
```
ILLink : Trim analysis warning IL2080: Microsoft.AspNetCore.Components.Reflection.MemberAssignment.d__0.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The field 'Microsoft.AspNetCore.Components.Reflection.MemberAssignment.d__0.5__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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2072: Microsoft.AspNetCore.Components.CascadingParameterState.FindCascadingParameters(ComponentState): 'componentType' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'Microsoft.AspNetCore.Components.CascadingParameterState.GetReflectedCascadingParameterInfos(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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2077: Microsoft.AspNetCore.Components.ComponentFactory.CreateInitializer(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'Microsoft.AspNetCore.Components.Reflection.MemberAssignment.GetPropertiesIncludingInherited(Type, BindingFlags)'. The field 'Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass7_0.type' 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2072: Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider, IComponent): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'Microsoft.AspNetCore.Components.ComponentFactory.CreateInitializer(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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Builder.CircuitJavaScriptInitializationMiddleware.d__2.MoveNext(): Using member 'Microsoft.AspNetCore.Http.HttpResponseJsonExtensions.WriteAsJsonAsync(HttpResponse, TValue, CancellationToken)' 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.Server.Circuits.CircuitOptionsJavaScriptInitializersConfiguration.Configure(CircuitOptions): Using member 'System.Text.Json.JsonSerializer.Deserialize(Stream, 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder, String, Action): Using member 'Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.Map(IEndpointRouteBuilder, String, RequestDelegate)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This API may perform reflection on the supplied delegate and its parameters. These types may be trimmed if not directly referenced. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder, String, Action): Using member 'Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.Map(IEndpointRouteBuilder, String, RequestDelegate)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This API may perform reflection on the supplied delegate and its parameters. These types may be trimmed if not directly referenced. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.Server.ComponentParameterDeserializer.TryDeserializeParameters(IList, IList, ParameterView&): Using member 'System.Text.Json.JsonSerializer.Deserialize(String, 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.Protect(String, Object): Using member 'System.Text.Json.JsonSerializer.Serialize(TValue, 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.Unprotect(String, String): Using member 'System.Text.Json.JsonSerializer.Deserialize(String, 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2067: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer.AddComponentAsync(Type, ParameterView, String): 'componentType' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'Microsoft.AspNetCore.Components.RenderTree.WebRenderer.AddRootComponent(Type, String)'. The parameter 'componentType' of method 'Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer.AddComponentAsync(Type, ParameterView, 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.Server.ServerComponentDeserializer.DeserializeServerComponent(ServerComponentMarker): Using member 'System.Text.Json.JsonSerializer.Deserialize(String, 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
ILLink : Trim analysis warning IL2026: Microsoft.AspNetCore.Components.Server.ServerComponentDeserializer.TryDeserializeComponentDescriptorCollection(String, List`1&): Using member 'System.Text.Json.JsonSerializer.Deserialize(String, 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. [C:\Development\Source\aspnetcore\src\Grpc\Linking\test\testassets\BasicWebsite\BasicWebsite.csproj]
```
I think these are all related to `Microsoft.AspNetCore.Components.Server` which hasn't been marked as trimmed. Need to do that and fix any trim warnings.
Contributor guide
Assessment
This issue has not been assessed yet.