private static AssemblyDefinition[] LoadAssemblies(string packageDirectory) { var assemblyDirectory = PathConstruction.Combine(packageDirectory, "tools"); var assemblyResolver = new DefaultAssemblyResolver(); assemblyResolver.AddSearchDirectory(assemblyDirectory); return(PathConstruction.GlobFiles(assemblyDirectory, "docfx.exe") .Select(x => AssemblyDefinition.ReadAssembly(x, new ReaderParameters { AssemblyResolver = assemblyResolver })) .ToArray()); }
public IEnumerable <IndexBase.Module> ExtractModules(string filePath) { var readerParameters = new ReaderParameters(); var resolver = new DefaultAssemblyResolver(); var assLocation = typeof(CecilProcessor).GetTypeInfo().Assembly.Location; var assDir = Path.GetDirectoryName(assLocation); var targetDirFolder = Path.GetDirectoryName(filePath); resolver.AddSearchDirectory(targetDirFolder); resolver.AddSearchDirectory(assDir); foreach (var resolvePath in Environment.GetCommandLineArgs().Where(w => w.ToLower().StartsWith("-cecilrefpath:"))) { resolver.AddSearchDirectory(resolvePath.Substring("-cecilRefPath:".Length)); } readerParameters.AssemblyResolver = resolver; if (new FileInfo(filePath).Exists == false) { if (new FileInfo(Path.Combine(assDir, filePath)).Exists) { filePath = Path.Combine(assDir, filePath); } } var assDef = AssemblyDefinition.ReadAssembly(filePath, readerParameters); foreach (var mb in moduleBuilders) { foreach (var module in mb.CreateModules(assDef)) { yield return(module); } } }
private static AssemblyDefinition LoadAssembly(string path) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(path)); var reader = new ReaderParameters() { AssemblyResolver = resolver }; return(AssemblyDefinition.ReadAssembly(path, reader)); }
private void LoadModules() { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(_file.DirectoryName); var parameters = new ReaderParameters { AssemblyResolver = resolver, }; _module = ModuleDefinition.ReadModule(_file.FullName, parameters); }
public ModuleDefinition ReadModuleDefinition(string path) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(ManagedFolder); ModuleDefinition module = ModuleDefinition.ReadModule(path, new ReaderParameters() { AssemblyResolver = resolver, }); return(module); }
private static ReaderParameters GetReadParameters(string assemblyPath, string[] probingPaths) { using (var resolver = new DefaultAssemblyResolver()) { if (!string.IsNullOrEmpty(assemblyPath) && File.Exists(assemblyPath)) { resolver.AddSearchDirectory(Path.GetDirectoryName(assemblyPath)); } if (probingPaths != null) { foreach (var searchDir in probingPaths) { if (Directory.Exists(searchDir)) { resolver.AddSearchDirectory(searchDir); } } } ReaderParameters readParams; try { readParams = new ReaderParameters() { AssemblyResolver = resolver, ReadSymbols = File.Exists(Path.ChangeExtension(assemblyPath, ".pdb")) }; } catch (InvalidOperationException) { readParams = new ReaderParameters() { AssemblyResolver = resolver }; } return(readParams); } }
IAssemblyResolver GetAssemblyResolver() { if (test_case.AssemblyResolver != null) { return(test_case.AssemblyResolver); } test_resolver = new DefaultAssemblyResolver(); var directory = Path.GetDirectoryName(test_case.ModuleLocation); test_resolver.AddSearchDirectory(directory); return(test_resolver); }
public CecilSymbolHelperTests() { var location = GetType().Assembly.Location; var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(location)); var parameters = new ReaderParameters { ReadSymbols = true, AssemblyResolver = resolver }; _module = ModuleDefinition.ReadModule(location, parameters); _cecilSymbolHelper = new CecilSymbolHelper(); }
protected ModuleDefinition read_module(string path, bool readOnly) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(path)); var rp = new ReaderParameters { ReadWrite = !readOnly, AssemblyResolver = resolver }; return(ModuleDefinition.ReadModule(path, rp)); }
private static AssemblyDefinition GetAssembly(string location) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(typeof(IPropertyContainer).Assembly.Location)); return(AssemblyDefinition.ReadAssembly( location, new ReaderParameters() { AssemblyResolver = resolver })); }
private static ReaderParameters GetReaderParameters(string folder) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(folder); var parameters = new ReaderParameters { AssemblyResolver = resolver, }; return(parameters); }
public DllMerger(MergeOptions options) { var assemblyResolver = new DefaultAssemblyResolver(); assemblyResolver.AddSearchDirectory(Path.GetDirectoryName(options.Executable)); var assembly = AssemblyDefinition.ReadAssembly(options.Executable, new ReaderParameters() { AssemblyResolver = assemblyResolver }); _assembly = assembly; _options = options; }
public static RuntimeInitializeOnLoadMethodsData ExtractPlayerRuntimeInitializeOnLoadMethods(BuildTarget targetPlatform, string[] assemblyPaths, string[] searchDirs) { var classInfoList = new List <RuntimeInitializeClassInfo>(); int methodCount = 0; foreach (var assemblyPath in assemblyPaths) { try { var assemblyResolverData = new GetAssemblyResolverData { SearchDirs = searchDirs, }; var resolver = new DefaultAssemblyResolver(); foreach (var searchDir in searchDirs) { resolver.AddSearchDirectory(searchDir); } assemblyResolverData.Resolver = resolver; var assembly = AssemblyDefinition.ReadAssembly(assemblyPath, new ReaderParameters { AssemblyResolver = assemblyResolverData.Resolver }); var assemblyName = assembly.Name.Name; foreach (var module in assembly.Modules) { foreach (var type in module.Types) { FindRuntimeInitializeOnLoadMethodAttributes(type, assemblyName, ref classInfoList, ref methodCount); } } } catch (Exception ex) { throw new Exception("ExtractPlayerRuntimeInitializeOnLoadMethods: Failed to process " + assemblyPath + ", " + ex); } } var data = new RuntimeInitializeOnLoadMethodsData(); data.classInfos = classInfoList.ToArray(); data.methodsCount = methodCount; return(data); }
static void Main() { string managedPath = PathDiscovery.FindManagedDirectory(); var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(managedPath); Version version = GetUnityVersion(); // as of Unity 2017.2, the UnityEngine assembly has been split into multiple assemblies // the assembly containing the GameObject class is UnityEngine.CoreModule string coreName = version.Major < 2017 || (version.Major == 2017 && version.Minor == 1) ? "UnityEngine" : "UnityEngine.CoreModule"; string corePath = PathDiscovery.GetAssemblyPath(resolver, coreName); byte[] coreData = File.ReadAllBytes(corePath); Console.WriteLine("Unity {0} detected.", version); ModuleDefinition unityCore = ModuleDefinition.ReadModule( new MemoryStream(coreData), new ReaderParameters { AssemblyResolver = resolver }); TypeDefinition gameObject = unityCore.GetType("UnityEngine", "GameObject"); // UPM works by adding a static constructor to the GameObject class, // which calls an initialization function in PluginManager.Core SetStaticCtor(gameObject, GenStaticCtor(unityCore, il => { ModuleDefinition upm = ModuleDefinition.ReadModule(CoreLibrary); TypeDefinition upmMain = upm.GetType("PluginManager.Core", "PluginManager"); MethodDefinition upmInit = upmMain.Methods.Single(m => m.Name == "Initialize"); il.Emit(OpCodes.Call, unityCore.ImportReference(upmInit)); il.Emit(OpCodes.Ret); upm.Dispose(); })); unityCore.Write(corePath); // We need to copy PluginManager.Core.dll into the Managed directory File.Copy(CoreLibrary, Path.Combine(managedPath, CoreLibrary), true); Console.WriteLine("UPM installed."); }
void patch_dll() { try { var temp_path = temp_base + "patch.dll"; File.Copy(dll_path, temp_path, true); var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(dlls_path); var reader = new ReaderParameters() { AssemblyResolver = resolver }; var game_dll = AssemblyDefinition.ReadAssembly(temp_path, reader).MainModule; var welcome = game_dll.Types.Single(t => t.Name == "WelcomeScript"); var labels = welcome.Resolve().Fields.Single(f => f.Name == "FlashingLabels"); labels.IsPrivate = false; labels.IsPublic = true; labels.Attributes = Mono.Cecil.FieldAttributes.Public; var csharp_dll = AssemblyDefinition.ReadAssembly(dlls_path + "Assembly-CSharp-firstpass.dll", reader); var ui_label = csharp_dll.MainModule.Types.Single(t => t.Name == "UILabel"); var set_text = ui_label.Methods.Single(m => m.Name == "set_text"); var setref = game_dll.ImportReference(set_text); var start = welcome.Methods.Single(m => m.Name == "Start"); var il2 = start.Body.GetILProcessor(); il2.InsertBefore(start.Body.Instructions[0], il2.Create(OpCodes.Callvirt, setref)); il2.InsertBefore(start.Body.Instructions[0], il2.Create(OpCodes.Ldstr, "Warning ! Do not submit bug reports, Yandere Loader is loaded !")); il2.InsertBefore(start.Body.Instructions[0], il2.Create(OpCodes.Ldelem_Ref)); il2.InsertBefore(start.Body.Instructions[0], il2.Create(OpCodes.Ldc_I4_2)); il2.InsertBefore(start.Body.Instructions[0], il2.Create(OpCodes.Ldfld, labels)); il2.InsertBefore(start.Body.Instructions[0], il2.Create(OpCodes.Ldarg_0)); game_dll.Write(dll_path); } catch (Exception e) { write_line("[CRITICAL]: Failed to patch dll: " + e.ToString()); Application.Exit(); } }
public static void addProfiler(string assemblyPath, string fileName, string typeName, string methodName) { if (Application.isPlaying || EditorApplication.isCompiling) { Debug.Log("You need stop play mode or wait compiling finished"); return; } if (!System.IO.File.Exists(assemblyPath + fileName)) { Debug.Log("This Project didn't contains this dll"); return; } var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(assemblyPath); var readerParameters = new ReaderParameters { ReadSymbols = false, AssemblyResolver = resolver }; var assembly = AssemblyDefinition.ReadAssembly(assemblyPath + fileName, readerParameters); if (assembly == null) { Debug.LogError("InjectTool Inject Load assembly failed: " + assemblyPath); return; } try { ProcessAssembly(assembly, typeName, methodName); assembly.Write(assemblyPath + fileName, new WriterParameters { WriteSymbols = false }); Debug.Log("Listening function " + methodName + " successfully!"); } catch (Exception ex) { Debug.LogError("InjectTool addProfiler failed: " + ex); throw; } finally { if (assembly.MainModule.SymbolReader != null) { Debug.Log("InjectTool addProfiler Succeed"); assembly.MainModule.SymbolReader.Dispose(); } } // Debug.Log("InjectTool Inject" + fileName + " End"); }
private static ModuleDefinition LoadModule(string assemblyPath, ICollection <string> assemblySearchPaths) { DefaultAssemblyResolver assemblyResolver = new DefaultAssemblyResolver(); if (assemblySearchPaths == null) { assemblyResolver.AddSearchDirectory(Path.GetDirectoryName(assemblyPath)); } else { foreach (string assemblySearchPath in assemblySearchPaths) { assemblyResolver.AddSearchDirectory(assemblySearchPath); } } string pdbPath = Path.ChangeExtension(assemblyPath, "pdb"); if (!File.Exists(pdbPath)) { return(ModuleDefinition.ReadModule(assemblyPath, new ReaderParameters { AssemblyResolver = assemblyResolver })); } using (FileStream symbolStream = File.OpenRead(pdbPath)) { ReaderParameters readerParametersWithSymbolStream = new ReaderParameters { ReadSymbols = true, SymbolReaderProvider = new PdbReaderProvider(), SymbolStream = symbolStream, AssemblyResolver = assemblyResolver }; return(ModuleDefinition.ReadModule(assemblyPath, readerParametersWithSymbolStream)); } }
public AssemblySet(string name, IEnumerable <string> paths, IEnumerable <string> resolverSearchPaths, IEnumerable <string> imports) { Name = name; foreach (var path in paths) { assemblyPaths.Add(path); } // add default search paths var assemblyDirectories = paths .Where(p => p.Contains(Path.DirectorySeparatorChar)) .Select(p => Path.GetDirectoryName(p)); foreach (var searchPath in resolverSearchPaths.Union(assemblyDirectories)) { assemblySearchPaths.Add(searchPath); } char oppositeSeparator = Path.DirectorySeparatorChar == '/' ? '\\' : '/'; Func <string, string> sanitize = p => p.Replace(oppositeSeparator, Path.DirectorySeparatorChar); foreach (var searchPath in assemblySearchPaths.Select(sanitize)) { resolver.AddSearchDirectory(searchPath); } this.importPaths = imports; if (this.importPaths != null) { this.Importers = this.importPaths.Select(p => MDocUpdater.Instance.GetImporter(p, supportsEcmaDoc: false)); } else { this.Importers = new DocumentationImporter[0]; } }
// helper function to invoke Weaver with an AssemblyDefinition from a // file path, with dependencies added. static bool WeaveFromFile(string assemblyPath, string[] dependencies) { // resolve assembly from stream using (DefaultAssemblyResolver asmResolver = new DefaultAssemblyResolver()) using (AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(assemblyPath, new ReaderParameters { ReadWrite = true, ReadSymbols = true, AssemblyResolver = asmResolver })) { // add this assembly's path and unity's assembly path asmResolver.AddSearchDirectory(Path.GetDirectoryName(assemblyPath)); asmResolver.AddSearchDirectory(Helpers.UnityEngineDllDirectoryName()); // add dependencies if (dependencies != null) { foreach (string path in dependencies) { asmResolver.AddSearchDirectory(path); } } // create weaver with logger weaver = new Weaver(new CompilationFinishedLogger()); if (weaver.Weave(assembly, asmResolver, out bool modified)) { // write changes to file if modified if (modified) { assembly.Write(new WriterParameters { WriteSymbols = true }); } return(true); } return(false); } }
void LoadDLL(string path, GameObject obj) { var defaultResolver = new DefaultAssemblyResolver(); defaultResolver.AddSearchDirectory(ScriptDirectory); defaultResolver.AddSearchDirectory(Paths.ManagedPath); defaultResolver.AddSearchDirectory(Paths.BepInExAssemblyDirectory); using (var dll = AssemblyDefinition.ReadAssembly(path, new ReaderParameters { AssemblyResolver = defaultResolver })) { dll.Name.Name = $"{dll.Name.Name}-{DateTime.Now.Ticks}"; using (var ms = new MemoryStream()) { dll.Write(ms); var ass = Assembly.Load(ms.ToArray()); foreach (Type type in ass.GetTypes()) { if (typeof(BaseUnityPlugin).IsAssignableFrom(type)) { var metadata = MetadataHelper.GetMetadata(type); if (metadata != null) { var typeDefinition = dll.MainModule.Types.First(x => x.FullName == type.FullName); var typeInfo = Chainloader.ToPluginInfo(typeDefinition); Chainloader.PluginInfos[metadata.GUID] = typeInfo; Logger.Log(LogLevel.Info, $"Reloading {metadata.GUID}"); StartCoroutine(DelayAction(() => obj.AddComponent(type))); } } } } } }
/// <summary> /// Writes the module <paramref name="module"/> to the file specified by the path <paramref name="moduleFilePath"/> /// </summary> /// <param name="module"></param> /// <param name="moduleFilePath"></param> public static void WriteModule(ModuleDefinition module, String moduleFilePath) { // Quick fix for AssemblyResolutionException // occurring in RequestReduce and Newtonsoft.Json projects // detailed info documented in challenges.txt // TODO: Check if there is more elegant solution if (module.AssemblyResolver is DefaultAssemblyResolver) { DefaultAssemblyResolver resolver = module.AssemblyResolver as DefaultAssemblyResolver; resolver.AddSearchDirectory(System.IO.Path.GetDirectoryName(module.FullyQualifiedName)); } module.Write(moduleFilePath); UpdateModuleDictionary(module, moduleFilePath); }
internal void Compile(string assembly) { resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(assembly)); var basm = AssemblyDefinition.ReadAssembly(assembly, new ReaderParameters { AssemblyResolver = resolver }); var allasm = FindRefs(basm); foreach (var asm in allasm) { WriteLine(asm.FullName); } }
public static IEnumerable <ExtensionReference> GenerateExtensionReferences(string fileName, ConsoleLogger logger) { BaseAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(fileName)); ReaderParameters readerParams = new ReaderParameters { AssemblyResolver = resolver }; AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(fileName, readerParams); var startupAttributes = assembly.Modules.SelectMany(p => p.GetCustomAttributes()) .Where(a => IsWebJobsStartupAttributeType(a.AttributeType, logger)); List <ExtensionReference> extensionReferences = new List <ExtensionReference>(); foreach (var attribute in startupAttributes) { var typeProperty = attribute.ConstructorArguments.ElementAtOrDefault(0); var nameProperty = attribute.ConstructorArguments.ElementAtOrDefault(1); TypeDefinition typeDef = (TypeDefinition)typeProperty.Value; string assemblyQualifiedName = Assembly.CreateQualifiedName(typeDef.Module.Assembly.FullName, GetReflectionFullName(typeDef)); string name; // Because we're now using static analysis we can't rely on the constructor running so have to get the name ourselves. if (string.Equals(attribute.AttributeType.FullName, FunctionsStartupAttributeType, StringComparison.OrdinalIgnoreCase)) { // FunctionsStartup always uses the type name as the name. name = typeDef.Name; } else { // WebJobsStartup does some trimming. name = GetName((string)nameProperty.Value, typeDef); } var extensionReference = new ExtensionReference { Name = name, TypeName = assemblyQualifiedName }; extensionReferences.Add(extensionReference); } return(extensionReferences); }
public void LoadAsm(string f) { source = f; var ar = new DefaultAssemblyResolver(); ar.AddSearchDirectory(Path.GetDirectoryName(f)); string[] searchDirs = new string[] { @"C:\Program Files\Reference Assemblies", @"C:\Program Files (x86)\Reference Assemblies" }; foreach (string sd in searchDirs) { if (Directory.Exists(sd)) { ar.AddSearchDirectory(sd); } } ar.ResolveFailure += new AssemblyResolveEventHandler(ResolveFailure); ReaderParameters rp = new ReaderParameters() { AssemblyResolver = ar }; assembly = AssemblyDefinition.ReadAssembly(source, rp); LoadAssemblyTree(); }
public void Variant() { var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "ScriptBuilder.Tests.dll"); var assemblyResolver = new DefaultAssemblyResolver(); assemblyResolver.AddSearchDirectory(TestContext.CurrentContext.TestDirectory); var readerParameters = new ReaderParameters(ReadingMode.Deferred) { AssemblyResolver = assemblyResolver }; var module = ModuleDefinition.ReadModule(path, readerParameters); ObjectApprover.VerifyWithJson(SqlVariantReader.Read(module).ToList()); }
// It's important that this logic remains in a separate function, // otherwise the Mono.Cecil and GamePluginKit.API assemblies // will be resolved before the custom resolver is registered. static void LoadPluginAssemblies(Transform root, string directory, SearchOption searchOption) { using (var resolver = new DefaultAssemblyResolver()) { foreach (string searchPath in SearchPaths) { resolver.AddSearchDirectory(searchPath); } var readParams = new ReaderParameters { AssemblyResolver = resolver }; foreach (string filePath in Directory.GetFiles(directory, "*.dll", searchOption)) { // Mono.Cecil is used to inspect the attributes for a very important reason. // If a plugin assembly contains attributes that are not present in the game's // assemblies (for example, TargetFrameworkAttribute when using the old Mono runtime) // the game will throw an exception when calling Assembly.GetCustomAttributes. using (var asmDef = AssemblyDefinition.ReadAssembly(filePath, readParams)) { var assembly = Assembly.LoadFrom(filePath); foreach (var attribute in asmDef.CustomAttributes) { try { if (attribute.AttributeType.FullName != "GamePluginKit.StartupBehaviourAttribute") { continue; } // Retrieve the behaviour type var typeRef = attribute.ConstructorArguments[0].Value as TypeReference; var typeName = Assembly.CreateQualifiedName(typeRef.Module.Assembly.FullName, typeRef.FullName); var behaviour = Type.GetType(typeName); new GameObject(behaviour.Name, behaviour).transform.SetParent(root); } catch (Exception ex) { Debug.LogException(ex); } } } } } }
public void RunInject(string assemblyPath, string assemblyName) { OnProgressChanged(assemblyName, 0f); string fullName = Utility.Path.GetCombinePath(assemblyPath, assemblyName); if (!File.Exists(fullName)) { Debug.LogWarning(string.Format("Assembly '{0}' does not exist.", fullName)); return; } DefaultAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(fullName)); ModuleDefinition moduleDefinition = ModuleDefinition.ReadModule(fullName, new ReaderParameters { AssemblyResolver = resolver }); Collection <TypeDefinition> typeDefinitions = moduleDefinition.Types; int typeCount = typeDefinitions.Count; if (typeCount <= 0) { return; } int index = 0; foreach (TypeDefinition typeDefinition in typeDefinitions) { if (NeedInject(typeDefinition)) { Collection <MethodDefinition> methodDefinitions = typeDefinition.Methods; foreach (MethodDefinition methodDefinition in methodDefinitions) { if (NeedInject(methodDefinition)) { InjectMethod(typeDefinition, methodDefinition); } } } OnProgressChanged(assemblyName, ++index / (float)typeCount); } moduleDefinition.Write(fullName, new WriterParameters { WriteSymbols = true }); }
public static AssemblyDef LoadFrom(string path) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(path)); var assemblyDef = AssemblyDefinition.ReadAssembly( path, new ReaderParameters { AssemblyResolver = resolver }); return(new AssemblyDef(assemblyDef.MainModule)); }
/// <summary> /// 获取程序集反射器 /// </summary> /// <param name="path"></param> /// <returns></returns> public MonoAssemblyReflector LoadAssembly(string path) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(path)); var reader = new ReaderParameters() { AssemblyResolver = resolver }; var assembly = AssemblyDefinition.ReadAssembly(path, reader); return(new MonoAssemblyReflector(assembly)); }
/// <summary> /// Helper to create the correct reader parameter construct based on the parameters. /// </summary> /// <returns></returns> public static ReaderParameters GetReaderParameters(string inputAssembly, IEnumerable <string> searchDirectories, ISymbolReaderProvider symbolReader) { var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(new FileInfo(inputAssembly).DirectoryName); if (searchDirectories != null) { foreach (var dir in searchDirectories) { resolver.AddSearchDirectory(dir); } } var rp = new ReaderParameters { AssemblyResolver = resolver, ReadSymbols = symbolReader != null, SymbolReaderProvider = symbolReader }; return(rp); }
ModuleDefinition GetModule() { var location = test_case.ModuleLocation; var directory = Path.GetDirectoryName (location); var resolver = new DefaultAssemblyResolver (); resolver.AddSearchDirectory (directory); var parameters = new ReaderParameters { SymbolReaderProvider = GetSymbolReaderProvider (), AssemblyResolver = resolver, }; switch (type) { case TestCaseType.ReadImmediate: parameters.ReadingMode = ReadingMode.Immediate; return ModuleDefinition.ReadModule (location, parameters); case TestCaseType.ReadDeferred: parameters.ReadingMode = ReadingMode.Deferred; return ModuleDefinition.ReadModule (location, parameters); case TestCaseType.WriteFromImmediate: parameters.ReadingMode = ReadingMode.Immediate; return RoundTrip (location, parameters, "cecil-irt"); case TestCaseType.WriteFromDeferred: parameters.ReadingMode = ReadingMode.Deferred; return RoundTrip (location, parameters, "cecil-drt"); default: return null; } }
IAssemblyResolver GetAssemblyResolver () { if (test_case.AssemblyResolver != null) return test_case.AssemblyResolver; var resolver = new DefaultAssemblyResolver (); var directory = Path.GetDirectoryName (test_case.ModuleLocation); resolver.AddSearchDirectory (directory); return resolver; }