2 using System.Reflection;
5 using System.Collections.Generic;
7 namespace Mono.Debugger.Soft
9 public class AssemblyMirror : Mirror
12 MethodMirror entry_point;
14 ModuleMirror main_module;
16 AssemblyDefinition meta;
17 AppDomainMirror domain;
18 Dictionary<string, long> typeCacheIgnoreCase = new Dictionary<string, long> (StringComparer.InvariantCultureIgnoreCase);
19 Dictionary<string, long> typeCache = new Dictionary<string, long> ();
21 internal AssemblyMirror (VirtualMachine vm, long id) : base (vm, id) {
24 public string Location {
27 location = vm.conn.Assembly_GetLocation (id);
32 public MethodMirror EntryPoint {
34 if (!entry_point_set) {
35 long mid = vm.conn.Assembly_GetEntryPoint (id);
38 entry_point = vm.GetMethod (mid);
39 entry_point_set = true;
45 public ModuleMirror ManifestModule {
47 if (main_module == null) {
48 main_module = vm.GetModule (vm.conn.Assembly_GetManifestModule (id));
54 // Since Protocol version 2.45
55 public AppDomainMirror Domain {
58 vm.CheckProtocolVersion (2, 45);
59 domain = vm.GetDomain (vm.conn.Assembly_GetIdDomain (id));
65 public virtual AssemblyName GetName () {
67 string name = vm.conn.Assembly_GetName (id);
68 aname = new AssemblyName (name);
73 public ObjectMirror GetAssemblyObject () {
74 return vm.GetObject (vm.conn.Assembly_GetObject (id));
77 public TypeMirror GetType (string name, bool throwOnError, bool ignoreCase)
80 throw new ArgumentNullException ("name");
82 throw new ArgumentException ("name", "Name cannot be empty");
85 throw new NotImplementedException ();
88 if (!typeCacheIgnoreCase.TryGetValue (name, out typeId)) {
89 typeId = vm.conn.Assembly_GetType (id, name, ignoreCase);
90 typeCacheIgnoreCase.Add (name, typeId);
91 var type = vm.GetType (typeId);
93 typeCache.Add (type.FullName, typeId);
98 if (!typeCache.TryGetValue (name, out typeId)) {
99 typeId = vm.conn.Assembly_GetType (id, name, ignoreCase);
100 typeCache.Add (name, typeId);
103 return vm.GetType (typeId);
106 public TypeMirror GetType (String name, Boolean throwOnError)
108 return GetType (name, throwOnError, false);
111 public TypeMirror GetType (String name) {
112 return GetType (name, false, false);
116 * An optional Cecil assembly which could be used to access metadata instead
117 * of reading it from the debuggee.
119 public AssemblyDefinition Metadata {
124 if (value.MainModule.Name != ManifestModule.Name)
125 throw new ArgumentException ("The supplied assembly is named '" + value.MainModule.Name + "', while the assembly in the debuggee is named '" + ManifestModule.Name + "'.");
126 if (value.MainModule.Mvid != ManifestModule.ModuleVersionId)
127 throw new ArgumentException ("The supplied assembly's main module has guid '" + value.MainModule.Mvid + ", while the assembly in the debuggee has guid '" + ManifestModule.ModuleVersionId + "'.", "value");