Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion external/Java.Interop
35 changes: 6 additions & 29 deletions src/Mono.Android/Java.Interop/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,47 +453,24 @@ public static void RegisterType (string java_class, Type t)
}
}

static Dictionary<string, List<Converter<string, Type?>>>? packageLookup;

[MemberNotNull (nameof (packageLookup))]
static void LazyInitPackageLookup ()
{
if (packageLookup == null)
packageLookup = new Dictionary<string, List<Converter<string, Type?>>> (StringComparer.Ordinal);
}

public static void RegisterPackage (string package, Converter<string, Type> lookup)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method should throw NotSupportedException

{
LazyInitPackageLookup ();

lock (packageLookup!) {
if (!packageLookup.TryGetValue (package, out var lookups))
packageLookup.Add (package, lookups = new List<Converter<string, Type?>> ());
lookups.Add (lookup);
}
if (package == null)
throw new ArgumentNullException ("package");
if (lookup == null)
throw new ArgumentNullException ("lookup");
throw new NotSupportedException ();
}

public static void RegisterPackages (string[] packages, Converter<string, Type?>[] lookups)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method should throw NotSupportedException

{
LazyInitPackageLookup ();

if (packages == null)
throw new ArgumentNullException ("packages");
if (lookups == null)
throw new ArgumentNullException ("lookups");
if (packages.Length != lookups.Length)
throw new ArgumentException ("`packages` and `lookups` arrays must have same number of elements.");

lock (packageLookup!) {
for (int i = 0; i < packages.Length; ++i) {
string package = packages [i];
var lookup = lookups [i];

if (!packageLookup.TryGetValue (package, out var _lookups))
packageLookup.Add (package, _lookups = new List<Converter<string, Type?>> ());
_lookups.Add (lookup);
}
}
throw new NotSupportedException ();
}

[Register ("mono/android/TypeManager", DoNotGenerateAcw = true)]
Expand Down
Loading