Skip to content

Commit 9f999e1

Browse files
committed
Suppress warnings in non-trimmable-typemap codepaths
1 parent 01e4fb9 commit 9f999e1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Mono.Android/Java.Interop/JavaConvert.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,21 @@ public ArrayElementConverter (Array array)
289289
if (elementType != null && typeof (IJavaPeerable).IsAssignableFrom (elementType)) {
290290
if (RuntimeFeature.TrimmableTypeMap)
291291
return FromJniHandleWithTrimmableTypeMapping (handle, transfer, elementType);
292-
return Java.Lang.Object.GetObject (handle, transfer, elementType);
292+
return GetObjectWithSuppression (handle, transfer, elementType);
293293
}
294294

295295
var value = FromJniHandleWithRuntimeTypeMapping (handle, transfer);
296296
if (value == null || elementType == null || elementType.IsAssignableFrom (value.GetType ()))
297297
return value;
298298
return Convert.ChangeType (value, elementType, CultureInfo.InvariantCulture);
299299
}
300+
301+
[UnconditionalSuppressMessage ("ReflectionAnalysis", "IL2067:RequiresUnreferencedCode",
302+
Justification = "Custom trimmer steps marks the activation constructors on IJavaPeerable types.")]
303+
static object? GetObjectWithSuppression (IntPtr handle, JniHandleOwnership transfer, Type? elementType)
304+
{
305+
return Java.Lang.Object.GetObject (handle, transfer, elementType);
306+
}
300307
}
301308

302309
static object? FromJniHandleWithRuntimeTypeMapping (IntPtr handle, JniHandleOwnership transfer)

0 commit comments

Comments
 (0)