Skip to content

Commit

Permalink
[Java.Interop.Tools.JavaCallableWrappers] IMetadataResolver redux (#1075
Browse files Browse the repository at this point in the history
)

Context: cf80deb

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.
  • Loading branch information
jonathanpeppers authored Jan 12, 2023
1 parent e11d024 commit f03088e
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ public class JavaTypeScanner

readonly IMetadataResolver cache;

[Obsolete ("Use the TypeDefinitionCache overload for better performance.")]
public JavaTypeScanner (Action<TraceLevel, string> logger)
: this (logger, resolver: null)
{ }
[Obsolete ("Use the TypeDefinitionCache overload for better performance.", error: true)]
public JavaTypeScanner (Action<TraceLevel, string> logger) => throw new NotSupportedException ();

public JavaTypeScanner (Action<TraceLevel, string> logger, TypeDefinitionCache? cache)
: this (logger, (IMetadataResolver?) cache)
public JavaTypeScanner (Action<TraceLevel, string> logger, TypeDefinitionCache cache)
: this (logger, (IMetadataResolver) cache)
{
}

public JavaTypeScanner (Action<TraceLevel, string> logger, IMetadataResolver? resolver)
public JavaTypeScanner (Action<TraceLevel, string> logger, IMetadataResolver resolver)
{
if (logger == null)
throw new ArgumentNullException (nameof (logger));
Expand Down Expand Up @@ -96,15 +94,14 @@ public static bool ShouldSkipJavaCallableWrapperGeneration (TypeDefinition type,
return false;
}

[Obsolete ("Use the TypeDefinitionCache overload for better performance.")]
public static List<TypeDefinition> GetJavaTypes (IEnumerable<string> assemblies, IAssemblyResolver resolver, Action<string, object []> log) =>
GetJavaTypes (assemblies, resolver, log, metadataResolver: null);
[Obsolete ("Use the TypeDefinitionCache overload for better performance.", error: true)]
public static List<TypeDefinition> GetJavaTypes (IEnumerable<string> assemblies, IAssemblyResolver resolver, Action<string, object []> log) => throw new NotSupportedException ();

// Returns all types for which we need to generate Java delegate types.
public static List<TypeDefinition> GetJavaTypes (IEnumerable<string> assemblies, IAssemblyResolver resolver, Action<string, object []> log, TypeDefinitionCache? cache) =>
GetJavaTypes (assemblies, resolver, log, (IMetadataResolver?) cache);
public static List<TypeDefinition> GetJavaTypes (IEnumerable<string> assemblies, IAssemblyResolver resolver, Action<string, object []> log, TypeDefinitionCache cache) =>
GetJavaTypes (assemblies, resolver, log, (IMetadataResolver) cache);

public static List<TypeDefinition> GetJavaTypes (IEnumerable<string> assemblies, IAssemblyResolver resolver, Action<string, object []> log, IMetadataResolver? metadataResolver)
public static List<TypeDefinition> GetJavaTypes (IEnumerable<string> assemblies, IAssemblyResolver resolver, Action<string, object []> log, IMetadataResolver metadataResolver)
{
Action<TraceLevel, string> l = (level, value) => log ("{0}", new string [] { value });
return new JavaTypeScanner (l, metadataResolver).GetJavaTypes (assemblies, resolver);
Expand Down

0 comments on commit f03088e

Please sign in to comment.