Skip to content

Commit

Permalink
[Java.Interop.Tools.Cecil] Change DirectoryAssemblyResolver to allow …
Browse files Browse the repository at this point in the history
…forced loading. (#270)

Context: dotnet/android#1154
Context: dotnet/android#1356

One of the problems we currently face is that our build system
resolves `ref` netstandard libraries. With the current cache
system, onces an assembly has been loaded into the Cecil cache
it only ever uses that assembly. We might need to replace the
current cached version with a new one if we detect a `ref` and
need to reload the `lib`.
  • Loading branch information
dellis1972 authored and jonpryor committed Mar 22, 2018
1 parent 15cf8c1 commit 4e1965d
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,22 @@ public Dictionary<string, AssemblyDefinition> ToResolverCache ()
return new Dictionary<string, AssemblyDefinition>(cache);
}

public virtual AssemblyDefinition Load (string fileName)
public virtual AssemblyDefinition Load (string fileName, bool forceLoad = false)
{
if (!File.Exists (fileName))
return null;

AssemblyDefinition assembly;
AssemblyDefinition assembly = null;
var name = Path.GetFileNameWithoutExtension (fileName);
if (cache.TryGetValue (name, out assembly))
if (!forceLoad && cache.TryGetValue (name, out assembly))
return assembly;

try {
assembly = ReadAssembly (fileName);
} catch (Exception e) {
Diagnostic.Error (9, e, "Error while loading assembly: {0}", fileName);
}
cache.Add (name, assembly);
cache [name] = assembly;
return assembly;
}

Expand Down

0 comments on commit 4e1965d

Please sign in to comment.