Skip to content

Commit

Permalink
Fixed resolver to resolve the issue that PCL mscorlib overwrites .NET…
Browse files Browse the repository at this point in the history
… 4 mscorlib.
  • Loading branch information
lextm committed Oct 11, 2014
1 parent 4616193 commit 5f7fb5e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Obfuscar/AssemblyCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace Obfuscar
class AssemblyCache : DefaultAssemblyResolver
{
readonly Project project;
private List<string> paths = new List<string> ();

public AssemblyCache (Project project)
{
Expand Down Expand Up @@ -68,11 +69,27 @@ public TypeDefinition GetTypeDefinition (TypeReference type)
public new void RegisterAssembly (AssemblyDefinition assembly)
{
var path = assembly.GetPortableProfileDirectory ();
if (path != null && Directory.Exists (path)) {
AddSearchDirectory (path);
}
if (path != null && Directory.Exists (path))
paths.Add (path);

base.RegisterAssembly (assembly);
}

public override AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters)
{
AssemblyDefinition result;
if (name.IsRetargetable) {
foreach (var path in paths)
AddSearchDirectory (path);

result = base.Resolve (name, parameters);
foreach (var path in paths)
RemoveSearchDirectory (path);
} else {
result = base.Resolve (name, parameters);
}

return result;
}
}
}

0 comments on commit 5f7fb5e

Please sign in to comment.