diff --git a/Directory.Build.props b/Directory.Build.props
index 8aa75e7b4..5da999fb1 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,7 +9,7 @@
true
true
- 8.0
+ 9.0
net$(DotNetTargetFrameworkVersion)
diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml
index 8fe06a4a7..d23031a36 100644
--- a/build-tools/automation/azure-pipelines.yaml
+++ b/build-tools/automation/azure-pipelines.yaml
@@ -19,8 +19,8 @@ pr:
variables:
RunningOnCI: true
Build.Configuration: Release
- DotNetCoreVersion: 8.0.303
- DotNetTargetFramework: net8.0
+ DotNetCoreVersion: 9.0.200
+ DotNetTargetFramework: net9.0
NetCoreTargetFrameworkPathSuffix: -$(DotNetTargetFramework)
HostedPoolName: Azure Pipelines
HostedWinImage: windows-2022
diff --git a/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs b/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs
index 6b3e4458b..159db9fed 100644
--- a/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs
+++ b/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
@@ -11,8 +12,12 @@
namespace Java.Interop {
+ [RequiresDynamicCode (ExpressionRequiresUnreferencedCode)]
+ [RequiresUnreferencedCode (ExpressionRequiresUnreferencedCode)]
public class MarshalMemberBuilder : JniRuntime.JniMarshalMemberBuilder
{
+ internal const string ExpressionRequiresUnreferencedCode = "System.Linq.Expression usage may trim away required code.";
+
public MarshalMemberBuilder ()
{
}
diff --git a/src/Java.Interop/Java.Interop/JniRuntime.JniMarshalMemberBuilder.cs b/src/Java.Interop/Java.Interop/JniRuntime.JniMarshalMemberBuilder.cs
index b74d6ec87..2670e09f6 100644
--- a/src/Java.Interop/Java.Interop/JniRuntime.JniMarshalMemberBuilder.cs
+++ b/src/Java.Interop/Java.Interop/JniRuntime.JniMarshalMemberBuilder.cs
@@ -29,8 +29,13 @@ public JniMarshalMemberBuilder MarshalMemberBuilder {
internal bool UseMarshalMemberBuilder => marshalMemberBuilder != null;
+ const string NotUsedInAndroid = "This code path is not used in Android projects.";
+
+ // FIXME: https://github.com/dotnet/java-interop/issues/1192
[DynamicDependency (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, "Java.Interop.MarshalMemberBuilder", "Java.Interop.Export")]
+ [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = NotUsedInAndroid)]
[UnconditionalSuppressMessage ("Trimming", "IL2035", Justification = "Java.Interop.Export.dll is not always present.")]
+ [UnconditionalSuppressMessage ("Trimming", "IL3050", Justification = NotUsedInAndroid)]
partial void SetMarshalMemberBuilder (CreationOptions options)
{
if (!options.UseMarshalMemberBuilder) {
diff --git a/src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs b/src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs
index a6acbe77a..9a8e5be9d 100644
--- a/src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs
+++ b/src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs
@@ -266,18 +266,16 @@ protected virtual IEnumerable GetSimpleReferences (Type type)
static readonly Type[] EmptyTypeArray = Array.Empty ();
const string NotUsedInAndroid = "This code path is not used in Android projects.";
+ // FIXME: https://github.com/dotnet/java-interop/issues/1192
+ [UnconditionalSuppressMessage ("Trimming", "IL3050", Justification = NotUsedInAndroid)]
static Type MakeArrayType (Type type) =>
- // FIXME: https://github.com/dotnet/java-interop/issues/1192
- #pragma warning disable IL3050
type.MakeArrayType ();
- #pragma warning restore IL3050
+ // FIXME: https://github.com/dotnet/java-interop/issues/1192
[UnconditionalSuppressMessage ("Trimming", "IL2055", Justification = NotUsedInAndroid)]
+ [UnconditionalSuppressMessage ("Trimming", "IL3050", Justification = NotUsedInAndroid)]
static Type MakeGenericType (Type type, Type arrayType) =>
- // FIXME: https://github.com/dotnet/java-interop/issues/1192
- #pragma warning disable IL3050
type.MakeGenericType (arrayType);
- #pragma warning restore IL3050
[UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "Types returned here should be preserved via other means.")]
[return: DynamicallyAccessedMembers (MethodsConstructors)]
@@ -400,16 +398,15 @@ IEnumerable CreateGetTypesForSimpleReferenceEnumerator (string jniSimpleRe
// https://github.com/xamarin/xamarin-android/blob/5472eec991cc075e4b0c09cd98a2331fb93aa0f3/src/Microsoft.Android.Sdk.ILLink/MarkJavaObjects.cs#L176-L186
const string makeGenericTypeMessage = "Generic 'Invoker' types are preserved by the MarkJavaObjects trimmer step.";
+ // FIXME: https://github.com/dotnet/java-interop/issues/1192
[UnconditionalSuppressMessage ("Trimming", "IL2055", Justification = makeGenericTypeMessage)]
+ [UnconditionalSuppressMessage ("Trimming", "IL3050", Justification = makeGenericTypeMessage)]
[return: DynamicallyAccessedMembers (Constructors)]
static Type MakeGenericType (
[DynamicallyAccessedMembers (Constructors)]
Type type,
Type [] arguments) =>
- // FIXME: https://github.com/dotnet/java-interop/issues/1192
- #pragma warning disable IL3050
type.MakeGenericType (arguments);
- #pragma warning restore IL3050
var signature = type.GetCustomAttribute ();
if (signature == null || signature.InvokerType == null) {
diff --git a/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs b/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs
index eb9e23790..36a4745c5 100644
--- a/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs
+++ b/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs
@@ -675,12 +675,11 @@ static JniValueMarshaler GetObjectArrayMarshaler (Type elementType)
{
const string makeGenericMethodMessage = "This code path is not used in Android projects.";
+ // FIXME: https://github.com/dotnet/java-interop/issues/1192
[UnconditionalSuppressMessage ("Trimming", "IL2060", Justification = makeGenericMethodMessage)]
+ [UnconditionalSuppressMessage ("Trimming", "IL3050", Justification = makeGenericMethodMessage)]
static MethodInfo MakeGenericMethod (MethodInfo method, Type type) =>
- // FIXME: https://github.com/dotnet/java-interop/issues/1192
- #pragma warning disable IL3050
method.MakeGenericMethod (type);
- #pragma warning restore IL3050
Func indirect = GetObjectArrayMarshalerHelper