From f03088e7b4ce4467b520106be92f9d4d47cba346 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 12 Jan 2023 11:00:31 -0600 Subject: [PATCH] [Java.Interop.Tools.JavaCallableWrappers] IMetadataResolver redux (#1075) Context: cf80deb7d2ad3c79abfd0140e4adee4376b41af5 I found a couple places we didn't add `[Obsolete (error: true)]`, but luckily this requires no code changes in xamarin/xamarin-android. Update `JavaTypeScanner` so that `IMetadataResolver` is required. I did a quick search, and I'm not finding anymore of these. --- .../JavaTypeScanner.cs | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaTypeScanner.cs b/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaTypeScanner.cs index 97f2222ea..8a00814fe 100644 --- a/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaTypeScanner.cs +++ b/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaTypeScanner.cs @@ -18,17 +18,15 @@ public class JavaTypeScanner readonly IMetadataResolver cache; - [Obsolete ("Use the TypeDefinitionCache overload for better performance.")] - public JavaTypeScanner (Action logger) - : this (logger, resolver: null) - { } + [Obsolete ("Use the TypeDefinitionCache overload for better performance.", error: true)] + public JavaTypeScanner (Action logger) => throw new NotSupportedException (); - public JavaTypeScanner (Action logger, TypeDefinitionCache? cache) - : this (logger, (IMetadataResolver?) cache) + public JavaTypeScanner (Action logger, TypeDefinitionCache cache) + : this (logger, (IMetadataResolver) cache) { } - public JavaTypeScanner (Action logger, IMetadataResolver? resolver) + public JavaTypeScanner (Action logger, IMetadataResolver resolver) { if (logger == null) throw new ArgumentNullException (nameof (logger)); @@ -96,15 +94,14 @@ public static bool ShouldSkipJavaCallableWrapperGeneration (TypeDefinition type, return false; } - [Obsolete ("Use the TypeDefinitionCache overload for better performance.")] - public static List GetJavaTypes (IEnumerable assemblies, IAssemblyResolver resolver, Action log) => - GetJavaTypes (assemblies, resolver, log, metadataResolver: null); + [Obsolete ("Use the TypeDefinitionCache overload for better performance.", error: true)] + public static List GetJavaTypes (IEnumerable assemblies, IAssemblyResolver resolver, Action log) => throw new NotSupportedException (); // Returns all types for which we need to generate Java delegate types. - public static List GetJavaTypes (IEnumerable assemblies, IAssemblyResolver resolver, Action log, TypeDefinitionCache? cache) => - GetJavaTypes (assemblies, resolver, log, (IMetadataResolver?) cache); + public static List GetJavaTypes (IEnumerable assemblies, IAssemblyResolver resolver, Action log, TypeDefinitionCache cache) => + GetJavaTypes (assemblies, resolver, log, (IMetadataResolver) cache); - public static List GetJavaTypes (IEnumerable assemblies, IAssemblyResolver resolver, Action log, IMetadataResolver? metadataResolver) + public static List GetJavaTypes (IEnumerable assemblies, IAssemblyResolver resolver, Action log, IMetadataResolver metadataResolver) { Action l = (level, value) => log ("{0}", new string [] { value }); return new JavaTypeScanner (l, metadataResolver).GetJavaTypes (assemblies, resolver);