Skip to content

Commit 2af4d6b

Browse files
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/ServiceCollectionExtensions.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Uno.Extensions;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace Uno.Extensions;
24

35
public static class ServiceCollectionExtensions
46
{
@@ -15,7 +17,10 @@ public static IServiceCollection AddNamedSingleton<TService, TImplementation>(th
1517

1618
}
1719

18-
public static IServiceCollection AddNamedSingleton<TService, TImplementation>(this IServiceCollection services, string Name)
20+
public static IServiceCollection AddNamedSingleton<
21+
TService,
22+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation
23+
>(this IServiceCollection services, string Name)
1924
where TService : class where TImplementation : class, TService
2025
{
2126
// Register the concrete type (the NamedInstance will use this
@@ -43,7 +48,10 @@ private static IServiceCollection AddNamedSingletonReference<TService>(this ISer
4348
.AddSingleton<INamedInstance<TService>>(sp => new NamedInstanceReference<TService>(sp, OriginalName, Name));
4449
}
4550

46-
public static IServiceCollection SetDefaultInstance<TService, TImplementation>(this IServiceCollection services)
51+
public static IServiceCollection SetDefaultInstance<
52+
TService,
53+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation
54+
>(this IServiceCollection services)
4755
where TService : class where TImplementation : class, TService
4856
{
4957
return services.AddNamedSingleton<TService, TImplementation>(DefaultInstanceKey);

src/Uno.Extensions.Core/Uno.Extensions.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS1591</WarningsNotAsErrors>
99
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
1010
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
11+
<IsAotCompatible>true</IsAotCompatible>
1112
</PropertyGroup>
1213
<ItemGroup>
1314
<PackageReference Include="Microsoft.Extensions.Logging" />

src/Uno.Extensions.Http/ServiceCollectionExtensions.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Uno.Extensions;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace Uno.Extensions;
24

35
/// <summary>
46
/// Extensions for <see cref="IServiceCollection"/>
@@ -49,7 +51,14 @@ public static IServiceCollection AddClient<TClient, TImplementation>(
4951
/// <param name="name">[optional] Name of the endpoint (used to load from appsettings)</param>
5052
/// <param name="configure">[optional] Callback to configure the endpoint</param>
5153
/// <returns>Updated service collection</returns>
52-
public static IServiceCollection AddClientWithEndpoint<TClient, TImplementation, TEndpoint>(
54+
public static IServiceCollection AddClientWithEndpoint<
55+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
56+
TClient,
57+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
58+
TImplementation,
59+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
60+
TEndpoint
61+
>(
5362
this IServiceCollection services,
5463
HostBuilderContext context,
5564
TEndpoint? options = null,
@@ -102,7 +111,13 @@ public static IServiceCollection AddClient<TInterface>(
102111
/// <param name="httpClientFactory">[optional] Callback to configure the HttpClient</param>
103112
/// <param name="configure">[optional] Callback to configure the endpoint</param>
104113
/// <returns>Updated service collection</returns>
105-
public static IServiceCollection AddClientWithEndpoint<TInterface, TEndpoint>(
114+
[RequiresUnreferencedCode("From `ConfigurationBinder.Get<T>(IConfiguration)`.")]
115+
public static IServiceCollection AddClientWithEndpoint<
116+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
117+
TInterface,
118+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
119+
TEndpoint
120+
>(
106121
this IServiceCollection services,
107122
HostBuilderContext context,
108123
TEndpoint? options = null,

src/Uno.Extensions.Navigation/MappedViewMap.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace Uno.Extensions.Navigation;
55
internal record MappedViewMap(
66
Type? View = null,
77
Func<Type?>? ViewSelector = null,
8+
[param: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicConstructors)]
89
Type? ViewModel = null,
910
DataMap? Data = null,
1011
Type? ResultData = null,

src/Uno.Extensions.Navigation/NavigationRequestExtensions.cs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Uno.Extensions.Navigation;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace Uno.Extensions.Navigation;
24

35
public static class NavigationRequestExtensions
46
{
@@ -107,17 +109,41 @@ internal static NavigationRequest ToRequest(
107109
var request = new NavigationRequest(sender, hint.ToRoute(navigator, resolver, data), cancellation);
108110
return request;
109111
}
110-
var navMethods = typeof(NavigationRequestExtensions)
111-
.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
112-
.Where(m => m.Name == nameof(ToRequest) &&
113-
m.IsGenericMethodDefinition).ToArray();
114-
var navMethod = navMethods.First();
115-
var constructedNavMethod = navMethod.MakeGenericMethod(hint.Result);
116-
var nav = (NavigationRequest)constructedNavMethod.Invoke(null, new object?[] { hint, navigator, resolver, sender, data, cancellation })!;
117-
return nav;
118-
112+
return InvokeToRequest(hint, hint.Result, navigator, resolver, sender, data, cancellation);
119113
}
120114

115+
[UnconditionalSuppressMessage("Trimming", "IL2060", Justification = "hide until proper solution can be determined")]
116+
[UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "hide until proper solution can be determined")]
117+
private static NavigationRequest InvokeToRequest(
118+
RouteHint hint,
119+
Type resultType,
120+
INavigator navigator,
121+
IRouteResolver resolver,
122+
object sender,
123+
object? data,
124+
CancellationToken cancellation)
125+
{
126+
try
127+
{
128+
var navMethods = typeof(NavigationRequestExtensions)
129+
.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
130+
.Where(m => m.Name == nameof(ToRequest) &&
131+
m.IsGenericMethodDefinition).ToArray();
132+
var navMethod = navMethods.First();
133+
var constructedNavMethod = navMethod.MakeGenericMethod(resultType);
134+
var nav = (NavigationRequest)constructedNavMethod.Invoke(null, new object?[] { hint, navigator, resolver, sender, data, cancellation })!;
135+
return nav;
136+
}
137+
catch (Exception e)
138+
{
139+
// TODO: how to get an ILogger?
140+
Console.Error.WriteLine($"Could not invoke ToRequest<{resultType.FullName}>(…): {e.Message}");
141+
Console.Error.WriteLine(e);
142+
throw;
143+
}
144+
}
145+
146+
121147
internal static NavigationRequest<TResult> ToRequest<TResult>(
122148
this RouteHint hint,
123149
INavigator navigator,

src/Uno.Extensions.Navigation/RouteInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public record RouteInfo(
2424
public RouteInfo? DependsOnRoute { get; set; }
2525

2626
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
27+
[UnconditionalSuppressMessage("Trimming", "IL2073", Justification = "Cannot 'forward' `[DynamicallyAccessedMembers]` to Func<T>; would need to use a new type, which would be an ABI break.")]
2728
public Type? RenderView => View?.Invoke();
2829
public bool IsDependent = !string.IsNullOrWhiteSpace(DependsOn);
2930
}

src/Uno.Extensions.Navigation/Uno.Extensions.Navigation.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
<!-- As we are InternalsVisibleTo, we disable some compatibility types that are not used by package itself. -->
1111
<UnoExtensionsGeneration_DisableModuleInitializerAttribute>True</UnoExtensionsGeneration_DisableModuleInitializerAttribute>
12+
13+
<IsAotCompatible>true</IsAotCompatible>
1214
</PropertyGroup>
1315

1416
<ItemGroup>

src/Uno.Extensions.Navigation/ViewMap.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,19 @@ internal virtual void RegisterResultDataType(IServiceCollection services)
3737
}
3838

3939
public record ViewMap<TView>(
40+
[param: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicConstructors)]
4041
Type? ViewModel = null,
4142
DataMap? Data = null,
4243
Type? ResultData = null,
4344
object? ViewAttributes = null
44-
) : ViewMap(View: typeof(TView), ViewModel: ViewModel, Data: Data, ResultData: ResultData, ViewAttributes: ViewAttributes)
45+
) : ViewMap(
46+
View: typeof(TView),
47+
ViewSelector: null,
48+
ViewModel: ViewModel,
49+
Data: Data,
50+
ResultData: ResultData,
51+
ViewAttributes: ViewAttributes
52+
)
4553
where TView: class, new()
4654
{
4755
public override void RegisterTypes(IServiceCollection services)
@@ -51,7 +59,11 @@ public override void RegisterTypes(IServiceCollection services)
5159
}
5260
}
5361

54-
public record ViewMap<TView, TViewModel>(
62+
public record ViewMap<
63+
TView,
64+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
65+
TViewModel
66+
>(
5567
DataMap? Data = null,
5668
Type? ResultData = null,
5769
object? ViewAttributes = null
@@ -60,7 +72,12 @@ public record ViewMap<TView, TViewModel>(
6072
{
6173
}
6274

63-
public record DataViewMap<TView, TViewModel, TData>(
75+
public record DataViewMap<
76+
TView,
77+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
78+
TViewModel,
79+
TData
80+
>(
6481
Func<TData, IDictionary<string, string>>? ToQuery = null,
6582
Func<IServiceProvider, IDictionary<string, object>, Task<TData?>>? FromQuery = null,
6683
Type? ResultData = null,
@@ -71,7 +88,12 @@ public record DataViewMap<TView, TViewModel, TData>(
7188
{
7289
}
7390

74-
public record ResultDataViewMap<TView, TViewModel, TResultData>(
91+
public record ResultDataViewMap<
92+
TView,
93+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
94+
TViewModel,
95+
TResultData
96+
>(
7597
DataMap? Data = null,
7698
object? ViewAttributes = null
7799
) : ViewMap<TView,TViewModel>(Data: Data, ResultData: typeof(TResultData), ViewAttributes: ViewAttributes)

src/Uno.Extensions.Reactive/Collections/Facades/Map/LockedMemoizedConverter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ namespace Uno.Extensions.Conversion;
1111
/// </summary>
1212
/// <typeparam name="TFrom">The source value type</typeparam>
1313
/// <typeparam name="TTo">The target value type</typeparam>
14-
internal class LockedMemoizedConverter<TFrom, TTo> : ICachedConverter<TFrom, TTo>, IConverter<TFrom, TTo>
14+
internal class LockedMemoizedConverter<
15+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
16+
TFrom,
17+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
18+
TTo
19+
> : ICachedConverter<TFrom, TTo>, IConverter<TFrom, TTo>
1520
where TFrom : class
1621
where TTo : class
1722
{

src/Uno.Extensions.Reactive/Collections/Facades/Map/OneWayMemoizedConverter.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Collections.Immutable;
4+
using System.Diagnostics.CodeAnalysis;
45
using System.Linq;
56
using System.Runtime.CompilerServices;
67

@@ -11,7 +12,12 @@ namespace Uno.Extensions.Conversion;
1112
/// </summary>
1213
/// <typeparam name="TFrom">The source value type</typeparam>
1314
/// <typeparam name="TTo">The target value type</typeparam>
14-
internal class OneWayMemoizedConverter<TFrom, TTo> : ICachedConverter<TFrom, TTo>, IConverter<TFrom, TTo>
15+
internal class OneWayMemoizedConverter<
16+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
17+
TFrom,
18+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
19+
TTo
20+
> : ICachedConverter<TFrom, TTo>, IConverter<TFrom, TTo>
1521
where TFrom : class
1622
where TTo : class
1723
{

0 commit comments

Comments
 (0)