diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs b/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs index ea863881293..49abcb50c33 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,11 @@ bool ShouldScan (ITaskItem assembly) public void AddJavaType (TypeDefinition type, List 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. types.Add (type);