diff --git a/src/Microsoft.Android.Templates/android-bindinglib/AndroidBinding1.csproj b/src/Microsoft.Android.Templates/android-bindinglib/AndroidBinding1.csproj
index 5f78e42ab48..56c74d9fc01 100644
--- a/src/Microsoft.Android.Templates/android-bindinglib/AndroidBinding1.csproj
+++ b/src/Microsoft.Android.Templates/android-bindinglib/AndroidBinding1.csproj
@@ -5,6 +5,11 @@
AndroidBinding1
enable
enable
+
+ true
+
+ full
+
diff --git a/src/Microsoft.Android.Templates/android/AndroidApp1.csproj b/src/Microsoft.Android.Templates/android/AndroidApp1.csproj
index 5a71d2ab599..c539a1f4c45 100644
--- a/src/Microsoft.Android.Templates/android/AndroidApp1.csproj
+++ b/src/Microsoft.Android.Templates/android/AndroidApp1.csproj
@@ -10,4 +10,11 @@
1
1.0
+
+
+ full
+
\ No newline at end of file
diff --git a/src/Microsoft.Android.Templates/androidlib/AndroidLib1.csproj b/src/Microsoft.Android.Templates/androidlib/AndroidLib1.csproj
index 3c076d5fd9d..d50d9b99196 100644
--- a/src/Microsoft.Android.Templates/androidlib/AndroidLib1.csproj
+++ b/src/Microsoft.Android.Templates/androidlib/AndroidLib1.csproj
@@ -5,5 +5,10 @@
AndroidLib1
enable
enable
+
+ true
\ No newline at end of file
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
index 8504ad98ec8..5d4506284cd 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
@@ -74,8 +74,9 @@
SdkOnly
None
- link
+ full
partial
+ false
true
android-arm;android-arm64;android-x86;android-x64
diff --git a/src/Xamarin.Android.Build.Tasks/Resources/LayoutBinding.cs b/src/Xamarin.Android.Build.Tasks/Resources/LayoutBinding.cs
index 86a260258f2..457c91add45 100644
--- a/src/Xamarin.Android.Build.Tasks/Resources/LayoutBinding.cs
+++ b/src/Xamarin.Android.Build.Tasks/Resources/LayoutBinding.cs
@@ -1,5 +1,5 @@
using System;
-
+using System.Diagnostics.CodeAnalysis;
using Android.App;
using Android.Views;
@@ -9,6 +9,8 @@ namespace Xamarin.Android.Design
abstract class LayoutBinding
{
+ const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors;
+
Activity boundActivity;
View boundView;
OnLayoutItemNotFoundHandler onLayoutItemNotFound;
@@ -25,7 +27,13 @@ protected LayoutBinding (View view, OnLayoutItemNotFoundHandler onLayoutItemNotF
this.onLayoutItemNotFound = onLayoutItemNotFound;
}
- protected T FindView (int resourceId, ref T cachedField) where T: View
+ protected T FindView <
+ [DynamicallyAccessedMembers (Constructors)]
+ T
+ > (
+ int resourceId,
+ ref T cachedField)
+ where T: View
{
if (cachedField != null)
return cachedField;
@@ -58,7 +66,14 @@ Activity EnsureActivity ()
throw new InvalidOperationException ("Finding fragments is supported only for Activity instances");
}
- T __FindFragment (int resourceId, Func finder, ref T cachedField) where T: Java.Lang.Object
+ T __FindFragment<
+ [DynamicallyAccessedMembers (Constructors)]
+ T
+ > (
+ int resourceId,
+ Func finder,
+ ref T cachedField)
+ where T: Java.Lang.Object
{
if (cachedField != null)
return cachedField;
@@ -74,7 +89,15 @@ T __FindFragment (int resourceId, Func finder, ref T cachedField
return ret;
}
#if __ANDROID_11__
- protected T FindFragment (int resourceId, global::Android.App.Fragment __ignoreMe, ref T cachedField) where T: global::Android.App.Fragment
+ protected T FindFragment<
+ [DynamicallyAccessedMembers (Constructors)]
+ T
+ > (
+ int resourceId,
+ global::Android.App.Fragment __ignoreMe,
+ ref T cachedField
+ )
+ where T: global::Android.App.Fragment
{
return __FindFragment (resourceId, (activity) => activity.FragmentManager.FindFragmentById (resourceId), ref cachedField);
}
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs
index 507fb5c8aef..8e625dc3ab7 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs
@@ -240,6 +240,10 @@ public void BuildHasNoWarnings (bool isRelease, bool xamarinForms, bool multidex
new XamarinFormsAndroidApplicationProject () :
new XamarinAndroidApplicationProject ();
proj.IsRelease = isRelease;
+ // Enable full trimming
+ if (!xamarinForms && isRelease) {
+ proj.TrimModeRelease = TrimMode.Full;
+ }
if (multidex) {
proj.SetProperty ("AndroidEnableMultiDex", "True");
}
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidLinkMode.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidLinkMode.cs
index eb3204389df..40dcd0946da 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidLinkMode.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidLinkMode.cs
@@ -9,4 +9,10 @@ public enum AndroidLinkMode
SdkOnly,
Full,
}
+
+ public enum TrimMode
+ {
+ Partial,
+ Full,
+ }
}
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownProperties.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownProperties.cs
index 9473811e49e..fa20a560acd 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownProperties.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownProperties.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Xamarin.ProjectTools
{
@@ -18,6 +18,7 @@ public static class KnownProperties
public const string RuntimeIdentifiers = "RuntimeIdentifiers";
public const string RunAOTCompilation = "RunAOTCompilation";
public const string PublishTrimmed = "PublishTrimmed";
+ public const string TrimMode = "TrimMode";
public const string SupportedOSPlatformVersion = "SupportedOSPlatformVersion";
public const string Deterministic = "Deterministic";
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs
index 67b77daceee..5b54d4b2201 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs
@@ -155,6 +155,11 @@ public AndroidLinkMode AndroidLinkModeRelease {
set { SetProperty (ReleaseProperties, KnownProperties.AndroidLinkMode, value.ToString ()); }
}
+ public TrimMode TrimModeRelease {
+ get => Enum.TryParse (GetProperty (ReleaseProperties, KnownProperties.TrimMode), out TrimMode trimMode) ? trimMode : TrimMode.Partial;
+ set => SetProperty (ReleaseProperties, KnownProperties.TrimMode, value.ToString ().ToLowerInvariant ());
+ }
+
public bool EnableMarshalMethods {
get { return string.Equals (GetProperty (KnownProperties.AndroidEnableMarshalMethods), "True", StringComparison.OrdinalIgnoreCase); }
set { SetProperty (KnownProperties.AndroidEnableMarshalMethods, value.ToString ()); }
diff --git a/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/BindingTests.cs b/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/BindingTests.cs
index 76ff290748d..33132c9479e 100644
--- a/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/BindingTests.cs
+++ b/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/BindingTests.cs
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using NUnit.Framework;
@@ -180,6 +181,7 @@ public void VirtualMethodBinding ()
}
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void JavaAbstractMethodTest ()
{
// Library is referencing APIv1, ICursor is from APIv2
@@ -198,7 +200,7 @@ public void JavaAbstractMethodTest ()
throw e;
}
- var mi = ic.GetType ().GetMethod ("global::Test.Bindings.ICursor.MethodWithCursor", BindingFlags.Instance | BindingFlags.NonPublic);
+ var mi = typeof (Library.MyClrCursor).GetMethod ("global::Test.Bindings.ICursor.MethodWithCursor", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.IsNotNull (mi, "ICursor.MethodWithCursor not found");
if (mi.GetMethodBody ()?.LocalVariables?.Count is not int x || x == 0)
throw new Exception ("FixAbstractMethodStep broken, MethodWithRT added, while it should not be");
diff --git a/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj b/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj
index da9c1c1f6e1..9b78edfbbbe 100644
--- a/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj
+++ b/tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj
@@ -18,6 +18,10 @@
..\..\..\bin\Test$(Configuration)
+
+ full
+
+
diff --git a/tests/Mono.Android-Tests/Android.Graphics/NinePatchTests.cs b/tests/Mono.Android-Tests/Android.Graphics/NinePatchTests.cs
index ecaf082aaca..5b342c2108c 100644
--- a/tests/Mono.Android-Tests/Android.Graphics/NinePatchTests.cs
+++ b/tests/Mono.Android-Tests/Android.Graphics/NinePatchTests.cs
@@ -1,5 +1,5 @@
using System;
-
+using System.Diagnostics.CodeAnalysis;
using Android.App;
using Android.Content.Res;
using Android.Graphics;
@@ -25,6 +25,7 @@ public class NinePatchTests
};
[Test, TestCaseSource (nameof (NinePatchDrawables))]
+ [DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (NinePatchDrawable))]
public void DrawableFromRes_ShouldBeTypeNinePatchDrawable (int resId, string name)
{
var d = Application.Context.Resources.GetDrawable (resId);
@@ -33,6 +34,7 @@ public void DrawableFromRes_ShouldBeTypeNinePatchDrawable (int resId, string nam
}
[Test, TestCaseSource (nameof (NinePatchDrawables))]
+ [DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (NinePatchDrawable))]
public void DrawableFromResStream_ShouldBeTypeNinePatchDrawable (int resId, string name)
{
var value = new Android.Util.TypedValue ();
diff --git a/tests/Mono.Android-Tests/Android.Widget/CustomWidgetTests.cs b/tests/Mono.Android-Tests/Android.Widget/CustomWidgetTests.cs
index 9ffd36a7328..ec2ab5bdc1d 100644
--- a/tests/Mono.Android-Tests/Android.Widget/CustomWidgetTests.cs
+++ b/tests/Mono.Android-Tests/Android.Widget/CustomWidgetTests.cs
@@ -1,9 +1,11 @@
-using Android.App;
+using System.Diagnostics.CodeAnalysis;
+using Android.App;
using Android.Content;
using Android.Util;
using Android.Views;
using Android.Widget;
using NUnit.Framework;
+using Mono.Android_Test.Library;
namespace Xamarin.Android.RuntimeTests
{
@@ -12,6 +14,7 @@ public class CustomWidgetTests
{
// https://bugzilla.xamarin.com/show_bug.cgi?id=23880
[Test]
+ [DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (CustomTextView))]
public void UpperCaseCustomWidget_ShouldNotThrowInflateException ()
{
Assert.DoesNotThrow (() => {
@@ -21,6 +24,7 @@ public void UpperCaseCustomWidget_ShouldNotThrowInflateException ()
}
[Test]
+ [DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (CustomTextView))]
public void LowerCaseCustomWidget_ShouldNotThrowInflateException ()
{
Assert.DoesNotThrow (() => {
@@ -30,6 +34,7 @@ public void LowerCaseCustomWidget_ShouldNotThrowInflateException ()
}
[Test]
+ [DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (CustomTextView))]
public void UpperAndLowerCaseCustomWidget_FromLibrary_ShouldNotThrowInflateException ()
{
Assert.DoesNotThrow (() => {
diff --git a/tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs b/tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs
index 302ef9b2ac5..629f4dfdce3 100644
--- a/tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs
+++ b/tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Linq;
@@ -47,12 +48,19 @@ public void JavaConvert_FromJavaObject_ShouldNotBreakExistingReferences ()
static Func GetIJavaObjectToInt32 ()
{
- var JavaConvert = typeof (Java.Lang.Object).Assembly.GetType ("Java.Interop.JavaConvert");
+ [UnconditionalSuppressMessage ("Trimming", "IL2060", Justification = "")]
+ static MethodInfo MakeGenericMethod (MethodInfo method, Type type) =>
+ // FIXME: https://github.com/xamarin/xamarin-android/issues/8724
+ #pragma warning disable IL3050
+ method.MakeGenericMethod (type);
+ #pragma warning restore IL3050
+
+ var JavaConvert = Type.GetType ("Java.Interop.JavaConvert, Mono.Android");
var FromJavaObject_T = JavaConvert.GetMethods (BindingFlags.Public | BindingFlags.Static)
.First (m => m.Name == "FromJavaObject" && m.IsGenericMethod);
return (Func) Delegate.CreateDelegate (
typeof(Func),
- FromJavaObject_T.MakeGenericMethod (typeof (int)));
+ MakeGenericMethod (FromJavaObject_T, typeof (int)));
}
[Test]
diff --git a/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj b/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
index f21c94de80f..604d33d234a 100644
--- a/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
+++ b/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
@@ -36,9 +36,13 @@
r8
+ full
+
+ true
+
<_AndroidRemapMembers Include="Remaps.xml" />
diff --git a/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/System/AppContextTests.cs b/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/System/AppContextTests.cs
index da3228cffe5..9ac37a97742 100644
--- a/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/System/AppContextTests.cs
+++ b/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/System/AppContextTests.cs
@@ -1,5 +1,6 @@
using NUnit.Framework;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Reflection;
namespace SystemTests
@@ -44,7 +45,11 @@ public void GetData (string name, string expected)
[Test]
[TestCaseSource (nameof (TestPrivateSwitchesSource))]
- public void TestPrivateSwitches (string className, string propertyName, object expected)
+ public void TestPrivateSwitches (
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)]
+ string className,
+ string propertyName,
+ object expected)
{
var type = Type.GetType (className, throwOnError: true);
var members = type.GetMember (propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
diff --git a/tests/Mono.Android-Tests/System.Drawing/TypeConverterTest.cs b/tests/Mono.Android-Tests/System.Drawing/TypeConverterTest.cs
index 18c164a3d6d..dbfb5d4ab65 100644
--- a/tests/Mono.Android-Tests/System.Drawing/TypeConverterTest.cs
+++ b/tests/Mono.Android-Tests/System.Drawing/TypeConverterTest.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using NUnit.Framework;
@@ -10,6 +11,7 @@ namespace System.Drawing {
public class TypeConverterTest {
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void ColorConverter ()
{
var typeConverter = TypeDescriptor.GetConverter (typeof (Color));
@@ -22,6 +24,7 @@ public void ColorConverter ()
}
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void RectangleConverter ()
{
var typeConverter = TypeDescriptor.GetConverter (typeof (Rectangle));
@@ -34,6 +37,7 @@ public void RectangleConverter ()
}
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void PointConverter ()
{
var typeConverter = TypeDescriptor.GetConverter (typeof (Point));
@@ -44,6 +48,7 @@ public void PointConverter ()
}
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void SizeConverter ()
{
var typeConverter = TypeDescriptor.GetConverter (typeof (Size));
@@ -54,6 +59,7 @@ public void SizeConverter ()
}
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void SizeFConverter ()
{
var typeConverter = TypeDescriptor.GetConverter (typeof (SizeF));
diff --git a/tests/Mono.Android-Tests/System.Text.Json/JsonSerializerTest.cs b/tests/Mono.Android-Tests/System.Text.Json/JsonSerializerTest.cs
index 18714d9c99c..ce179773315 100644
--- a/tests/Mono.Android-Tests/System.Text.Json/JsonSerializerTest.cs
+++ b/tests/Mono.Android-Tests/System.Text.Json/JsonSerializerTest.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using NUnit.Framework;
@@ -9,16 +10,24 @@ namespace System.Text.JsonTests {
public class JsonSerializerTest {
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void Serialize ()
{
+ // FIXME: https://github.com/xamarin/xamarin-android/issues/8724
+ #pragma warning disable IL3050
string text = JsonSerializer.Serialize(42);
+ #pragma warning restore IL3050
Assert.AreEqual("42", text);
}
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void Deserialize ()
{
+ // FIXME: https://github.com/xamarin/xamarin-android/issues/8724
+ #pragma warning disable IL3050
object value = JsonSerializer.Deserialize("42", typeof(int));
+ #pragma warning restore IL3050
Assert.AreEqual(42, value);
}
}
diff --git a/tests/Mono.Android-Tests/System/AppDomainTest.cs b/tests/Mono.Android-Tests/System/AppDomainTest.cs
index 362804634d1..f2fd832dadf 100644
--- a/tests/Mono.Android-Tests/System/AppDomainTest.cs
+++ b/tests/Mono.Android-Tests/System/AppDomainTest.cs
@@ -1,10 +1,5 @@
using System;
using System.Globalization;
-
-using Android.App;
-using Android.Content;
-using Android.Runtime;
-
using NUnit.Framework;
namespace SystemTests {
@@ -13,34 +8,9 @@ namespace SystemTests {
public class AppDomainTest {
[Test]
- [Category ("HybridAotNotWorking")] // See https://github.com/xamarin/xamarin-android/issues/1536
- [Category ("DotNetIgnore")] // System.PlatformNotSupportedException : Secondary AppDomains are not supported on this platform.
- public void DateTime_Now_Works ()
- {
- new Boom().Bang();
-
-
- var otherDomain = AppDomain.CreateDomain ("other domain");
-
- var otherType = typeof (Boom);
- var obj = (Boom) otherDomain.CreateInstanceAndUnwrap (
- otherType.Assembly.FullName,
- otherType.FullName);
- obj.Bang ();
- }
- }
-
- class Boom : MarshalByRefObject
- {
- public void Bang()
- {
- var x = DateTime.Now;
- Console.WriteLine ("Within AppDomain {0}, DateTime.Now={1}.", AppDomain.CurrentDomain.FriendlyName, x);
- }
-
- public override object InitializeLifetimeService ()
+ public void AppDomain_CreateDomain_Throws ()
{
- return null;
+ Assert.Throws (() => AppDomain.CreateDomain ("other domain"));
}
}
}
diff --git a/tests/Mono.Android-Tests/System/ExceptionTest.cs b/tests/Mono.Android-Tests/System/ExceptionTest.cs
index 19b1098d89c..a1511e393d2 100644
--- a/tests/Mono.Android-Tests/System/ExceptionTest.cs
+++ b/tests/Mono.Android-Tests/System/ExceptionTest.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
@@ -16,9 +17,7 @@ public class ExceptionTest {
static Java.Lang.Throwable CreateJavaProxyThrowable (Exception e)
{
- var JavaProxyThrowable_type = typeof (Java.Lang.Object)
- .Assembly
- .GetType ("Android.Runtime.JavaProxyThrowable");
+ var JavaProxyThrowable_type = Type.GetType ("Android.Runtime.JavaProxyThrowable, Mono.Android");
MethodInfo? create = JavaProxyThrowable_type.GetMethod (
"Create",
BindingFlags.Static | BindingFlags.Public,
@@ -30,6 +29,7 @@ static Java.Lang.Throwable CreateJavaProxyThrowable (Exception e)
}
[Test]
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
public void InnerExceptionIsSet ()
{
Exception ex;
@@ -48,6 +48,7 @@ public void InnerExceptionIsSet ()
Assert.AreSame (ex, alias.InnerException);
}
+ [RequiresUnreferencedCode ("Tests trimming unsafe features")]
void CompareStackTraces (Exception ex, Java.Lang.Throwable throwable)
{
var managedTrace = new StackTrace (ex);
diff --git a/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs b/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs
index 9046c528909..061319d86d4 100644
--- a/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs
+++ b/tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs
@@ -30,6 +30,7 @@
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -160,6 +161,7 @@ static bool IsSecureChannelFailure (Exception e)
return Exceptions (e).Any (v => (v as WebException)?.Status == WebExceptionStatus.SecureChannelFailure);
}
+ [UnconditionalSuppressMessage ("Trimming", "IL2075", Justification = "Tests private fields are preserved by other means")]
static Type GetInnerHandlerType (HttpClient httpClient)
{
BindingFlags bflasgs = BindingFlags.Instance | BindingFlags.NonPublic;