From 21c0a1da209602538215e0872ebf3ad85f5ad4e2 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Mon, 26 Sep 2016 13:18:26 -0400 Subject: [PATCH] [Java.Interop.Tools.JavaCallableWrappers] TypeNameMapGenerator directories The `TypeNameMapGenerator(IEnumerable, Action)` constructor attempted to use `DirectoryAssemblyResolver` to load each assembly provided by the `IEnumerable` parameter, in-order, *without* updating `DirectoryAssemblyResolver.SearchDirectories`. The result is that things would only work if the assemblies were sorted in "dependency order", e.g. `mscorlib.dll` first, and any other assembly dependency before it's used. Should the order be otherwise, e.g. `{System.dll, mscorlib.dll}`, then things would horrifically break: System.IO.FileNotFoundException: Could not load assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Perhaps it doesn't exist in the Mono for Android profile? File name: 'mscorlib.dll' at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0015d] in <216e7ad0b70c419890a52554f287cdcd>:0 at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00001] in <216e7ad0b70c419890a52554f287cdcd>:0 at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x0004e] in <4f9b8c8361824d0ca9025449919e12be>:0 at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00007] in <4f9b8c8361824d0ca9025449919e12be>:0 at Mono.Cecil.TypeReference.Resolve () [0x00014] in <4f9b8c8361824d0ca9025449919e12be>:0 Improver the `TypeNameMapGenerator` constructor so that `DirectoryAssemblyResolver.SearchDirectories` is set to contain all directories for all assemblies provied, *before* attempting to load any assemblies. This allows assemblies to be provided in an arbitrary order, while still allowing assemblies to be found. --- .../TypeNameMapGenerator.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/TypeNameMapGenerator.cs b/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/TypeNameMapGenerator.cs index a39775135..ff60f69cd 100644 --- a/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/TypeNameMapGenerator.cs +++ b/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/TypeNameMapGenerator.cs @@ -71,6 +71,13 @@ public TypeNameMapGenerator (IEnumerable assemblies, Action