Skip to content

Commit c6aa720

Browse files
dellis1972jonpryor
authored andcommitted
[Java.Interop.Tools.Cecil] Change DirectoryAssemblyResolver to allow 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`.
1 parent 15cf8c1 commit c6aa720

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,22 @@ public Dictionary<string, AssemblyDefinition> ToResolverCache ()
110110
return new Dictionary<string, AssemblyDefinition>(cache);
111111
}
112112

113-
public virtual AssemblyDefinition Load (string fileName)
113+
public virtual AssemblyDefinition Load (string fileName, bool forceLoad = false)
114114
{
115115
if (!File.Exists (fileName))
116116
return null;
117117

118-
AssemblyDefinition assembly;
118+
AssemblyDefinition assembly = null;
119119
var name = Path.GetFileNameWithoutExtension (fileName);
120-
if (cache.TryGetValue (name, out assembly))
120+
if (!forceLoad && cache.TryGetValue (name, out assembly))
121121
return assembly;
122122

123123
try {
124124
assembly = ReadAssembly (fileName);
125125
} catch (Exception e) {
126126
Diagnostic.Error (9, e, "Error while loading assembly: {0}", fileName);
127127
}
128-
cache.Add (name, assembly);
128+
cache [name] = assembly;
129129
return assembly;
130130
}
131131

0 commit comments

Comments
 (0)