From 27a7d04b2f062327053a4154e7b0ae34eb703a43 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 3 Jul 2016 18:35:15 +0900 Subject: [PATCH] Add AssemblyDefinition paramater to IsGacAssembly --- ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs | 6 +++--- ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs b/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs index f7c180c0a..e58aa7857 100644 --- a/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/WholeProjectDecompiler.cs @@ -193,8 +193,8 @@ namespace ICSharpCode.Decompiler.CSharp if (r.Name != "mscorlib") { w.WriteStartElement("Reference"); w.WriteAttributeString("Include", r.Name); - if (!IsGacAssembly(r)) { - var asm = module.AssemblyResolver.Resolve(r); + var asm = module.AssemblyResolver.Resolve(r); + if (!IsGacAssembly(r, asm)) { if (asm != null) { w.WriteElementString("HintPath", asm.MainModule.FullyQualifiedName); } @@ -222,7 +222,7 @@ namespace ICSharpCode.Decompiler.CSharp } } - protected virtual bool IsGacAssembly(AssemblyNameReference r) + protected virtual bool IsGacAssembly(AssemblyNameReference r, AssemblyDefinition asm) { return false; } diff --git a/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs b/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs index 670012393..1f9df5d13 100644 --- a/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs +++ b/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs @@ -226,12 +226,14 @@ namespace ICSharpCode.Decompiler.Tests public TestProjectDecompiler(string baseDir) { - localAssemblies = new DirectoryInfo(baseDir).EnumerateFiles("*.dll").Select(f => f.Name).ToArray(); + localAssemblies = new DirectoryInfo(baseDir).EnumerateFiles("*.dll").Select(f => f.FullName).ToArray(); } - protected override bool IsGacAssembly(AssemblyNameReference r) + protected override bool IsGacAssembly(AssemblyNameReference r, AssemblyDefinition asm) { - return !localAssemblies.Contains(r.Name + ".dll"); + if (asm == null) + return false; + return !localAssemblies.Contains(asm.MainModule.FullyQualifiedName); } }