* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
- internal const int MINOR_VERSION = 8;
+ internal const int MINOR_VERSION = 9;
enum WPSuspendPolicy {
NONE = 0,
SET_PROTOCOL_VERSION = 8,
ABORT_INVOKE = 9,
SET_KEEPALIVE = 10,
- GET_TYPES_FOR_SOURCE_FILE = 11
+ GET_TYPES_FOR_SOURCE_FILE = 11,
+ GET_TYPES = 12
}
enum CmdEvent {
return types;
}
+ internal long[] VM_GetTypes (string name, bool ignoreCase) {
+ var res = SendReceive (CommandSet.VM, (int)CmdVM.GET_TYPES, new PacketWriter ().WriteString (name).WriteBool (ignoreCase));
+ int count = res.ReadInt ();
+ long[] types = new long [count];
+ for (int i = 0; i < count; ++i)
+ types [i] = res.ReadId ();
+ return types;
+ }
+
/*
* DOMAIN
*/
res [i] = GetType (ids [i]);
return res;
}
+
+ //
+ // Return a list of TypeMirror objects for all loaded types named 'NAME'.
+ // NAME should be in the the same for as with Assembly.GetType ().
+ // Since protocol version 2.9.
+ //
+ public IList<TypeMirror> GetTypes (string name, bool ignoreCase) {
+ long[] ids = conn.VM_GetTypes (name, ignoreCase);
+ var res = new TypeMirror [ids.Length];
+ for (int i = 0; i < ids.Length; ++i)
+ res [i] = GetType (ids [i]);
+ return res;
+ }
internal void queue_event_set (EventSet es) {
lock (queue_monitor) {
Assert.IsTrue (types.Any (t => t.FullName == "Tests"));
Assert.IsFalse (types.Any (t => t.FullName == "System.Int32"));
}
+
+ [Test]
+ public void GetTypesNamed () {
+ run_until ("user");
+
+ var types = vm.GetTypes ("Tests", false);
+ Assert.AreEqual (1, types.Count);
+ Assert.AreEqual ("Tests", types [0].FullName);
+
+ types = vm.GetTypes ("System.Exception", false);
+ Assert.AreEqual (1, types.Count);
+ Assert.AreEqual ("System.Exception", types [0].FullName);
+ }
}
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
-#define MINOR_VERSION 8
+#define MINOR_VERSION 9
typedef enum {
CMD_SET_VM = 1,
CMD_VM_SET_PROTOCOL_VERSION = 8,
CMD_VM_ABORT_INVOKE = 9,
CMD_VM_SET_KEEPALIVE = 10,
- CMD_VM_GET_TYPES_FOR_SOURCE_FILE = 11
+ CMD_VM_GET_TYPES_FOR_SOURCE_FILE = 11,
+ CMD_VM_GET_TYPES = 12
} CmdVM;
typedef enum {
g_ptr_array_free (res_domains, TRUE);
break;
}
+ case CMD_VM_GET_TYPES: {
+ GHashTableIter iter;
+ MonoDomain *domain;
+ int i;
+ char *name;
+ gboolean ignore_case;
+ GPtrArray *res_classes, *res_domains;
+ MonoTypeNameParse info;
+
+ name = decode_string (p, &p, end);
+ ignore_case = decode_byte (p, &p, end);
+
+ if (!mono_reflection_parse_type (name, &info)) {
+ g_free (name);
+ mono_reflection_free_type_info (&info);
+ return ERR_INVALID_ARGUMENT;
+ }
+
+ res_classes = g_ptr_array_new ();
+ res_domains = g_ptr_array_new ();
+
+ mono_loader_lock ();
+ g_hash_table_iter_init (&iter, domains);
+ while (g_hash_table_iter_next (&iter, NULL, (void**)&domain)) {
+ MonoAssembly *ass;
+ gboolean type_resolve;
+ MonoType *t;
+ GSList *tmp;
+
+ mono_domain_assemblies_lock (domain);
+ for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
+ ass = tmp->data;
+
+ if (ass->image) {
+ type_resolve = TRUE;
+ t = mono_reflection_get_type (ass->image, &info, ignore_case, &type_resolve);
+ if (t) {
+ g_ptr_array_add (res_classes, mono_type_get_class (t));
+ g_ptr_array_add (res_domains, domain);
+ }
+ }
+ }
+ mono_domain_assemblies_unlock (domain);
+ }
+ mono_loader_unlock ();
+
+ g_free (name);
+ mono_reflection_free_type_info (&info);
+
+ buffer_add_int (buf, res_classes->len);
+ for (i = 0; i < res_classes->len; ++i)
+ buffer_add_typeid (buf, g_ptr_array_index (res_domains, i), g_ptr_array_index (res_classes, i));
+ g_ptr_array_free (res_classes, TRUE);
+ g_ptr_array_free (res_domains, TRUE);
+ break;
+ }
default:
return ERR_NOT_IMPLEMENTED;