|
7 | 7 | using System.Collections.Generic; |
8 | 8 | using System.IO; |
9 | 9 | using System.Linq; |
| 10 | +using System.Runtime.CompilerServices; |
10 | 11 | using System.Text; |
11 | 12 | using Mono.Cecil; |
12 | 13 |
|
@@ -213,30 +214,28 @@ public static AssemblyDefinition GetTestNFAppAssemblyDefinition() |
213 | 214 | { |
214 | 215 | AssemblyDefinition ret = null; |
215 | 216 |
|
216 | | - ret = AssemblyDefinition.ReadAssembly(TestNFAppFullPath); |
| 217 | + ret = AssemblyDefinition.ReadAssembly( |
| 218 | + TestNFAppFullPath, |
| 219 | + new ReaderParameters { AssemblyResolver = ProvideLoadHints() }); |
217 | 220 |
|
218 | 221 | return ret; |
219 | 222 | } |
220 | 223 |
|
221 | 224 | public static AssemblyDefinition GetTestNFAppAssemblyDefinitionWithLoadHints() |
222 | 225 | { |
223 | | - IDictionary<string, string> loadHints = new Dictionary<string, string>(StringComparer.Ordinal) |
224 | | - { |
225 | | - ["mscorlib"] = GetmscorlibAssemblyDefinition().MainModule.FileName, |
226 | | - ["TestNFClassLibrary"] = GetTestNFClassLibraryDefinition().MainModule.FileName |
227 | | - }; |
228 | | - |
229 | 226 | return AssemblyDefinition.ReadAssembly( |
230 | 227 | TestNFAppFullPath, |
231 | | - new ReaderParameters { AssemblyResolver = new LoadHintsAssemblyResolver(loadHints) }); |
| 228 | + new ReaderParameters { AssemblyResolver = ProvideLoadHints() }); |
232 | 229 | } |
233 | 230 |
|
234 | 231 |
|
235 | 232 | public static AssemblyDefinition GetTestNFClassLibraryDefinition() |
236 | 233 | { |
237 | 234 | AssemblyDefinition ret = null; |
238 | 235 |
|
239 | | - ret = AssemblyDefinition.ReadAssembly(TestNFClassLibFullPath); |
| 236 | + ret = AssemblyDefinition.ReadAssembly( |
| 237 | + TestNFClassLibFullPath, |
| 238 | + new ReaderParameters { AssemblyResolver = ProvideLoadHints() }); |
240 | 239 |
|
241 | 240 | return ret; |
242 | 241 | } |
@@ -485,5 +484,13 @@ internal static MethodDefinition GetMethodDefinition( |
485 | 484 | public static string NanoClrLocalInstance => Environment.GetEnvironmentVariable( |
486 | 485 | _varNameForLocalNanoCLRInstancePath, |
487 | 486 | EnvironmentVariableTarget.Process); |
| 487 | + |
| 488 | + private static DefaultAssemblyResolver ProvideLoadHints() |
| 489 | + { |
| 490 | + var resolver = new DefaultAssemblyResolver(); |
| 491 | + resolver.AddSearchDirectory(TestExecutionLocation); |
| 492 | + |
| 493 | + return resolver; |
| 494 | + } |
488 | 495 | } |
489 | 496 | } |
0 commit comments