Commit 2af4d6b
committed
chore: Fix trimmer warnings
Context: dotnet/runtime#121629
Context: dea3b57 / 56a003b [may not exist]
Context: c3c4c78
Enable `$(IsAotCompatible)`=true for the following projects:
* `src/Uno.Extensions.Core/Uno.Extensions.Core.csproj`
* `src/Uno.Extensions.Navigation/Uno.Extensions.Navigation.csproj`
* `src/Uno.Extensions.Reactive/Uno.Extensions.Reactive.csproj`
Fix the following warnings-as-errors:
src/Uno.Extensions.Core/DependencyInjection/ServiceCollectionExtensions.cs(24,3): error IL2091:
'TService' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in 'Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAddTransient<TService>(IServiceCollection)'.
The generic parameter 'TImplementation' of 'Uno.Extensions.ServiceCollectionExtensions.AddNamedSingleton<TService, TImplementation>(IServiceCollection, 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.
src/Uno.Extensions.Navigation/MappedViewMap.cs(14,6): error IL2067:
'ViewModel' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.Extensions.Navigation.ViewMap.ViewMap(Type, Func<Type>, Type, DataMap, Type, Object)'.
The parameter 'ViewModel' of method 'Uno.Extensions.Navigation.MappedViewMap.MappedViewMap(Type, Func<Type>, Type, DataMap, Type, 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.
src/Uno.Extensions.Navigation/ViewMap.cs(66,5): error IL2087:
'ViewModel' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.Extensions.Navigation.ViewMap<TView>.ViewMap(Type, DataMap, Type, Object)'.
The generic parameter 'TViewModel' of 'Uno.Extensions.Navigation.ViewMap<TView, TViewModel>' 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.
src/Uno.Extensions.Reactive/Collections/Facades/Map/LockedMemoizedConverter.cs(20,75): error IL2091:
'TValue' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in 'System.Runtime.CompilerServices.ConditionalWeakTable<TKey, TValue>'.
The generic parameter 'TFrom' of 'Uno.Extensions.Conversion.LockedMemoizedConverter<TFrom, TTo>' 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.
…
src/Uno.Extensions.Reactive/Collections/Facades/Map/OneWayMemoizedConverter.cs(19,75): error IL2091:
'TValue' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in 'System.Runtime.CompilerServices.ConditionalWeakTable<TKey, TValue>'.
The generic parameter 'TFrom' of 'Uno.Extensions.Conversion.OneWayMemoizedConverter<TFrom, TTo>' 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.
…
src/Uno.Extensions.Navigation/ViewMap.cs(86,15): error IL2091:
'TViewModel' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in 'Uno.Extensions.Navigation.ViewMap<TView, TViewModel>'.
The generic parameter 'TViewModel' of 'Uno.Extensions.Navigation.ResultDataViewMap<TView, TViewModel, TResultData>' 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.
Add the missing `[DynamicallyAccessedMembers]`.
Address the following warnings-as-errors:
src/Uno.Extensions.Navigation/ViewMap.cs(44,5): error IL2067:
'ViewModel' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.Extensions.Navigation.ViewMap.ViewMap(Type, Func<Type>, Type, DataMap, Type, Object)'.
The parameter 'Data' of method 'Uno.Extensions.Navigation.ViewMap<TView>.ViewMap(Type, DataMap, Type, Object)' 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.
This is dotnet/runtime#121629. Work around it by providing the
`ViewSelector: null` parameter.
Suppress the following warning-as-errors:
src/Uno.Extensions.Reactive/Presentation/Bindings/BindableViewModelBase.HotReload.cs(102,15): error IL2067:
'updatedModelType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'Uno.Extensions.Reactive.Bindings.BindableViewModelBase.__Reactive_CreateModelInstance(Type)'.
The parameter 'updatedModelType' of method 'Uno.Extensions.Reactive.Bindings.BindableViewModelBase.HotPatch(Type, 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.
src/Uno.Extensions.Reactive/Presentation/Bindings/BindableViewModelBase.HotReload.cs(319,26): error IL2026:
Using member 'Uno.Extensions.Reactive.Bindings.BindableViewModelBase.CreateSilentFeed(Type)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
HotReload does not support trimmed environments.
src/Uno.Extensions.Reactive/Presentation/Bindings/BindableViewModelBase.HotReload.cs(390,30): error IL2072:
'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'Uno.Extensions.Reactive.Bindings.BindableViewModelBase.IsFeed(Type, out Type)'.
The return value of method 'System.Reflection.PropertyInfo.PropertyType.get' 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.
Suppress the following warning-as-error:
src/Uno.Extensions.Reactive/Core/HotReload/HotReloadService.cs(11,12): error IL2026:
Using member 'Uno.Extensions.Reactive.Core.HotReload.HotReloadService.UpdateApplication(Type[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
`MetadataUpdateOriginalTypeAttribute` may be a per-assembly type, so it cannot be statically known.
This is on an `[assembly:]`-level attribute. I can think of only
using `#pragma warning disable` to remove the error.
Suppress the following warning-as-error:
src/Uno.Extensions.Navigation/RouteInfo.cs(27,29): error IL2073:
'Uno.Extensions.Navigation.RouteInfo.RenderView.get' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' requirements.
The return value of method 'System.Func<TResult>.Invoke()' 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.
Remember 56a003b (which has the comment, merged into dea3b57)?
> Add `[DynamicallyAccessedMembers]` to `RouteInfo.RenderView`. This
> is a bit of a lie, as `RenderView` invokes `View`…:
> …
> and there is no way to update the `View` parameter to assert that the
> returned `Type` fulfills the requirements. Oddly, this doesn't require
> suppressing anything…
*Now* it needs suppressing. We can't change the parameter type without
incurring an ABI break.
TODO: use constructor overloading?
Look into `System.Runtime.CompilerServices.OverloadResolutionPriority`.
For the following warning-as-errors:
src/Uno.Extensions.Navigation/NavigationRequestExtensions.cs(115,30): error IL2060:
Call to 'System.Reflection.MethodInfo.MakeGenericMethod(params Type[])' can not be statically analyzed.
It's not possible to guarantee the availability of requirements of the generic method.
src/Uno.Extensions.Navigation/NavigationRequestExtensions.cs(115,30): error IL3050:
Using member 'System.Reflection.MethodInfo.MakeGenericMethod(params Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
The native code for this instantiation might not be available at runtime.
This was apparently added in c3c4c78.
For now, suppress the warning.
Address the following warning-as-error:
src/Uno.Extensions.Http/ServiceCollectionExtensions.cs(117,15): error IL3050:
Using member 'Microsoft.Extensions.Configuration.ConfigurationBinder.Get<T>(IConfiguration)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.
TODO: understand why generics were added to this codepath, and
possibly *remove* them? At a glance, the generics don't appear to be
publicly visible…
For now, Add `[RequiresUnreferencedCode]` to `AddClientWithEndpoint()`.
Address the following warnings-as-errors:
src/Uno.Extensions.Reactive/Core/HotReload/HotReloadService.cs(69,8): error IL2075:
'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'.
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.
The reflection use is required, and this is part of the
HotReload codepath, so annotate with `[RequiresUnreferencedCode]`.
Address the following warnings-as-errors:
src/Uno.Extensions.Serialization/SystemTextJsonSerializer.cs(86,85): error IL3050:
Using member 'System.Text.Json.JsonSerializer.Serialize(Object, 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.
src/Uno.Extensions.Serialization/SystemTextJsonSerializer.cs(104,89): error IL3050:
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.
src/Uno.Extensions.Reactive/Presentation/Bindings/BindableViewModelBase.HotReload.cs(403,41): error IL2070:
'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'.
The parameter 'type' of method 'Uno.Extensions.Reactive.Bindings.BindableViewModelBase.IsFeed(Type, out 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.
Add `[RequiresDynamicCodeAttribute]` or `[RequiresUnreferencedCode]`,
depending on the warning message.1 parent dea3b57 commit 2af4d6b
15 files changed
Lines changed: 152 additions & 27 deletions
File tree
- src
- Uno.Extensions.Core
- DependencyInjection
- Uno.Extensions.Http
- Uno.Extensions.Reactive
- Collections/Facades/Map
- Core/HotReload
- Presentation/Bindings
- Utils
- Uno.Extensions.Serialization
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
47 | 55 | | |
48 | 56 | | |
49 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| |||
102 | 111 | | |
103 | 112 | | |
104 | 113 | | |
105 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
106 | 121 | | |
107 | 122 | | |
108 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
Lines changed: 36 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 112 | + | |
119 | 113 | | |
120 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
121 | 147 | | |
122 | 148 | | |
123 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
54 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
55 | 67 | | |
56 | 68 | | |
57 | 69 | | |
| |||
60 | 72 | | |
61 | 73 | | |
62 | 74 | | |
63 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
64 | 81 | | |
65 | 82 | | |
66 | 83 | | |
| |||
71 | 88 | | |
72 | 89 | | |
73 | 90 | | |
74 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
75 | 97 | | |
76 | 98 | | |
77 | 99 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
17 | 23 | | |
| |||
0 commit comments