From c27eca80f486559f8a9045f23f5a40d6e32f4bf5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 15:40:55 +0000 Subject: [PATCH 1/3] Initial plan From 7dda6b00aaab31dccd79c648d64743c4e2ac510a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 16:01:11 +0000 Subject: [PATCH 2/3] Enable nullable reference types in XAJavaTypeScanner.cs Agent-Logs-Url: https://github.com/dotnet/android/sessions/eefa7fb2-7f0f-4339-8339-2c48677c5f07 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com> --- .../Utilities/XAJavaTypeScanner.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs b/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs index ea863881293..82cf47a83c6 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs @@ -1,3 +1,4 @@ +#nullable enable using System; using System.Collections.Generic; using System.IO; @@ -90,7 +91,7 @@ bool ShouldScan (ITaskItem assembly) } string? hasMonoAndroidReferenceMetadata = assembly.GetMetadata ("HasMonoAndroidReference"); - if (String.IsNullOrEmpty (hasMonoAndroidReferenceMetadata)) { + if (hasMonoAndroidReferenceMetadata.IsNullOrEmpty ()) { return true; // Just in case - the metadata missing might be a false negative } @@ -104,6 +105,9 @@ bool ShouldScan (ITaskItem assembly) public void AddJavaType (TypeDefinition type, List types) { + ArgumentNullException.ThrowIfNull (type); + ArgumentNullException.ThrowIfNull (types); + if (type.HasJavaPeer (cache)) { // For subclasses of e.g. Android.App.Activity. types.Add (type); From 194a08723fdeb041025ea7849b52ebd23a03ac01 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 22 May 2026 11:31:34 -0500 Subject: [PATCH 3/3] Use explicit null checks for netstandard2.0 compatibility ArgumentNullException.ThrowIfNull is not available in netstandard2.0, which Xamarin.Android.Build.Tasks targets. Replace with explicit null checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Utilities/XAJavaTypeScanner.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs b/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs index 82cf47a83c6..49abcb50c33 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs @@ -105,8 +105,10 @@ bool ShouldScan (ITaskItem assembly) public void AddJavaType (TypeDefinition type, List types) { - ArgumentNullException.ThrowIfNull (type); - ArgumentNullException.ThrowIfNull (types); + if (type == null) + throw new ArgumentNullException (nameof (type)); + if (types == null) + throw new ArgumentNullException (nameof (types)); if (type.HasJavaPeer (cache)) { // For subclasses of e.g. Android.App.Activity.