internal MetadataContext(string assemblyPath, bool readSymbols) { var resolver = new BasePathAssemblyResolver(Path.GetDirectoryName(assemblyPath)); var parameter = new ReaderParameters { AssemblyResolver = resolver, ReadSymbols = readSymbols }; var mainAssembly = AssemblyDefinition.ReadAssembly(assemblyPath, parameter); var mainAssemblyInformation = new AssemblyInformation(mainAssembly, this); resolvedCoreModule = mainAssembly.MainModule.TypeSystem.Object.Resolve().Module; resolvedCoreAssembly = resolvedCoreModule.Assembly; var resolvedCoreAssemblyInformation = new AssemblyInformation( resolvedCoreAssembly, this); var resolvedCoreModuleInformation = new ModuleInformation( resolvedCoreModule, resolvedCoreAssemblyInformation); this.MainAssembly = mainAssemblyInformation; assemblies.Add(mainAssembly, mainAssemblyInformation); assemblies.Add(resolvedCoreAssembly, resolvedCoreAssemblyInformation); modules.Add(resolvedCoreModule, resolvedCoreModuleInformation); assemblyByModule.Add(resolvedCoreModule, resolvedCoreAssembly); this.VoidType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Void); this.ObjectType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Object); this.ValueTypeType = this.GetOrAddType(resolvedCoreModule.GetType("System.ValueType")); this.EnumType = this.GetOrAddType(resolvedCoreModule.GetType("System.Enum")); this.DelegateType = this.GetOrAddType(resolvedCoreModule.GetType("System.Delegate")); this.MulticastDelegateType = this.GetOrAddType(resolvedCoreModule.GetType("System.MulticastDelegate")); this.ArrayType = this.GetOrAddType(resolvedCoreModule.GetType("System.Array")); this.ExceptionType = this.GetOrAddType(resolvedCoreModule.GetType("System.Exception")); this.ByteType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Byte); this.SByteType = this.GetOrAddType(resolvedCoreModule.TypeSystem.SByte); this.Int16Type = this.GetOrAddType(resolvedCoreModule.TypeSystem.Int16); this.UInt16Type = this.GetOrAddType(resolvedCoreModule.TypeSystem.UInt16); this.Int32Type = this.GetOrAddType(resolvedCoreModule.TypeSystem.Int32); this.UInt32Type = this.GetOrAddType(resolvedCoreModule.TypeSystem.UInt32); this.Int64Type = this.GetOrAddType(resolvedCoreModule.TypeSystem.Int64); this.UInt64Type = this.GetOrAddType(resolvedCoreModule.TypeSystem.UInt64); this.SingleType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Single); this.DoubleType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Double); this.IntPtrType = this.GetOrAddType(resolvedCoreModule.TypeSystem.IntPtr); this.UIntPtrType = this.GetOrAddType(resolvedCoreModule.TypeSystem.UIntPtr); this.CharType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Char); this.StringType = this.GetOrAddType(resolvedCoreModule.TypeSystem.String); this.BooleanType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Boolean); this.RuntimeFieldHandle = this.GetOrAddType(resolvedCoreModule.GetType("System.RuntimeFieldHandle")); }
internal AssemblyInformation GetOrAddAssembly( AssemblyDefinition assemblyDefinition) { if (assemblyDefinition == null) { return(default(AssemblyInformation)); } lock (assemblies) { if (!assemblies.TryGetValue(assemblyDefinition, out var assembly)) { assembly = new AssemblyInformation(assemblyDefinition, this); assemblies.Add(assemblyDefinition, assembly); } return(assembly); } }
public ModuleInformation(ModuleReference module, AssemblyInformation assembly) : base(module, assembly.MetadataContext) { this.DeclaringAssembly = assembly; }