Permalink
Browse files

Fix MethodMirror.GetCustomAttributes ().

  • Loading branch information...
1 parent 743d05c commit bfdb8242d92017f0c1c34da9c976622c959b2da1 @vargaz vargaz committed Aug 5, 2012
@@ -395,7 +395,7 @@ public abstract class Connection
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
- internal const int MINOR_VERSION = 20;
+ internal const int MINOR_VERSION = 21;
enum WPSuspendPolicy {
NONE = 0,
@@ -517,7 +517,8 @@ enum CmdMethod {
GET_LOCALS_INFO = 5,
GET_INFO = 6,
GET_BODY = 7,
- RESOLVE_TOKEN = 8
+ RESOLVE_TOKEN = 8,
+ GET_CATTRS = 9
}
enum CmdType {
@@ -1824,6 +1825,11 @@ internal void SetSocketTimeouts (int send_timeout, int receive_timeout, int keep
}
}
+ internal CattrInfo[] Method_GetCustomAttributes (long id, long attr_type_id, bool inherit) {
+ PacketReader r = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_CATTRS, new PacketWriter ().WriteId (id).WriteId (attr_type_id));
+ return ReadCattrs (r);
+ }
+
/*
* THREAD
*/
@@ -77,24 +77,26 @@ public class MethodMirror : Mirror
* Creating the custom attributes themselves could modify the behavior of the
* debuggee, so we return objects similar to the CustomAttributeData objects
* used by the reflection-only functionality on .net.
+ * Since protocol version 2.21
*/
public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) {
return GetCAttrs (null, inherit);
}
+ /* Since protocol version 2.21 */
public CustomAttributeDataMirror[] GetCustomAttributes (TypeMirror attributeType, bool inherit) {
if (attributeType == null)
throw new ArgumentNullException ("attributeType");
return GetCAttrs (attributeType, inherit);
}
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
- if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
+ if (cattrs == null && meta != null && !Metadata.HasCustomAttributes)
cattrs = new CustomAttributeDataMirror [0];
// FIXME: Handle inherit
if (cattrs == null) {
- CattrInfo[] info = vm.conn.Type_GetCustomAttributes (id, 0, false);
+ CattrInfo[] info = vm.conn.Method_GetCustomAttributes (id, 0, false);
cattrs = CustomAttributeDataMirror.Create (vm, info);
}
var res = new List<CustomAttributeDataMirror> ();
@@ -512,6 +512,7 @@ public class NestedClass {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
+ [StateMachine (typeof (int))]
public static void locals2<T> (string[] args, int arg, T t, ref string rs) {
long i = 42;
string s = "AB";
@@ -3019,6 +3019,10 @@ public class DebuggerTests
args = gmd.GetGenericArguments ();
Assert.AreEqual (1, args.Length);
Assert.AreEqual ("T", args [0].Name);
+
+ var attrs = m.GetCustomAttributes (true);
+ Assert.AreEqual (1, attrs.Length);
+ Assert.AreEqual ("StateMachineAttribute", attrs [0].Constructor.DeclaringType.Name);
}
[Test]
View
@@ -276,7 +276,7 @@ typedef struct {
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
-#define MINOR_VERSION 20
+#define MINOR_VERSION 21
typedef enum {
CMD_SET_VM = 1,
@@ -456,6 +456,7 @@ typedef enum {
CMD_METHOD_GET_INFO = 6,
CMD_METHOD_GET_BODY = 7,
CMD_METHOD_RESOLVE_TOKEN = 8,
+ CMD_METHOD_GET_CATTRS = 9,
} CmdMethod;
typedef enum {
@@ -7565,6 +7566,7 @@ static ErrorCode
method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, guint8 *p, guint8 *end, Buffer *buf)
{
MonoMethodHeader *header;
+ int err;
switch (command) {
case CMD_METHOD_GET_NAME: {
@@ -7884,6 +7886,20 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
}
break;
}
+ case CMD_METHOD_GET_CATTRS: {
+ MonoClass *attr_klass;
+ MonoCustomAttrInfo *cinfo;
+
+ attr_klass = decode_typeid (p, &p, end, NULL, &err);
+ /* attr_klass can be NULL */
+ if (err)
+ return err;
+
+ cinfo = mono_custom_attrs_from_method (method);
+
+ buffer_add_cattrs (buf, domain, method->klass->image, attr_klass, cinfo);
+ break;
+ }
default:
return ERR_NOT_IMPLEMENTED;
}

0 comments on commit bfdb824

Please sign in to comment.