You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: dotnet/android#9630
As #9630 required new declarations of
`DynamicallyAccessedMemberTypes.Interfaces`, we intestigated to see
*why* these were needed in Java.Interop.
There are two cases:
var listIface = typeof (IList<>);
var listType =
(from iface in type.GetInterfaces ().Concat (new[]{type})
where (listIface).IsAssignableFrom (iface.IsGenericType ? iface.GetGenericTypeDefinition () : iface)
select iface)
.FirstOrDefault ();
This first one, if `IList<>` were trimmed away. We don't actually
care, as everything in this code path would still work. We can
suppress the warning instead.
The second case:
JniValueMarshalerAttribute? ifaceAttribute = null;
foreach (var iface in type.GetInterfaces ()) {
marshalerAttr = iface.GetCustomAttribute<JniValueMarshalerAttribute> ();
if (marshalerAttr != null) {
if (ifaceAttribute != null)
throw new NotSupportedException ($"There is more than one interface with custom marshaler for type {type}.");
ifaceAttribute = marshalerAttr;
}
}
if (ifaceAttribute != null)
return (JniValueMarshaler) Activator.CreateInstance (ifaceAttribute.MarshalerType)!;
Feels like we should be able to remove this code completely.
With these changes we can remove `DynamicallyAccessedMemberTypes.Interfaces`.
I also introduced `build-tools/trim-analyzers/trim-analyzers.props`
that will setup the appropriate trimmer MSBuild properties to make
trimmer warnings an error. This should keep us from accidentally
creating warnings. I only use this setting in projects that were
already using `$(EnableAotAnalyzer)`.
0 commit comments