public void Init() { mdbRepo = MdbFactory.createRepo(); }
public void LoadFrom(FilePath assemblyPath) { FileName = assemblyPath; string tid = Runtime.SystemAssemblyService.GetTargetFrameworkForAssembly(Runtime.SystemAssemblyService.DefaultRuntime, assemblyPath); if (tid != null) { targetFramework = Runtime.SystemAssemblyService.GetTargetFramework(tid); } AssemblyDefinition adef = AssemblyFactory.GetAssembly(assemblyPath); MdbFactory mdbFactory = new MdbFactory(); try { ISymbolReader reader = mdbFactory.CreateReader(adef.MainModule, assemblyPath); adef.MainModule.LoadSymbols(reader); } catch { // Ignore } var files = new HashSet <FilePath> (); foreach (TypeDefinition type in adef.MainModule.Types) { foreach (MethodDefinition met in type.Methods) { if (met.HasBody && met.Body.Instructions != null && met.Body.Instructions.Count > 0) { SequencePoint sp = met.Body.Instructions[0].SequencePoint; if (sp != null) { files.Add(sp.Document.Url); } } } } FilePath rootPath = FilePath.Empty; foreach (FilePath file in files) { AddFile(file, BuildAction.Compile); if (rootPath.IsNullOrEmpty) { rootPath = file.ParentDirectory; } else if (!file.IsChildPathOf(rootPath)) { rootPath = FindCommonRoot(rootPath, file); } } if (!rootPath.IsNullOrEmpty) { BaseDirectory = rootPath; } /* * foreach (AssemblyNameReference aref in adef.MainModule.AssemblyReferences) { * if (aref.Name == "mscorlib") * continue; * string asm = assemblyPath.ParentDirectory.Combine (aref.Name); * if (File.Exists (asm + ".dll")) * References.Add (new ProjectReference (ReferenceType.Assembly, asm + ".dll")); * else if (File.Exists (asm + ".exe")) * References.Add (new ProjectReference (ReferenceType.Assembly, asm + ".exe")); * else * References.Add (new ProjectReference (ReferenceType.Gac, aref.FullName)); * }*/ }