From b38abd8131e8f089fd68f95a6c6275ed8e53f187 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 3 Aug 2012 09:49:39 -0400 Subject: [PATCH] [Mono.Debugger.Soft] Implemented MethodMirror.GetCustomAttributes() --- .../Mono.Debugger.Soft/MethodMirror.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs index 85cf83d8dd5..0b2ddaf5f61 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs @@ -14,6 +14,7 @@ namespace Mono.Debugger.Soft TypeMirror declaring_type; DebugInfo debug_info; C.MethodDefinition meta; + CustomAttributeDataMirror[] cattrs; ParameterInfoMirror[] param_info; ParameterInfoMirror ret_param; LocalVariable[] locals; @@ -72,6 +73,37 @@ namespace Mono.Debugger.Soft } } + /* + * 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. + */ + public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) { + return GetCAttrs (null, inherit); + } + + 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) + cattrs = new CustomAttributeDataMirror [0]; + + // FIXME: Handle inherit + if (cattrs == null) { + CattrInfo[] info = vm.conn.Type_GetCustomAttributes (id, 0, false); + cattrs = CustomAttributeDataMirror.Create (vm, info); + } + var res = new List (); + foreach (var attr in cattrs) + if (type == null || attr.Constructor.DeclaringType == type) + res.Add (attr); + return res.ToArray (); + } + MethodInfo GetInfo () { if (info == null) info = vm.conn.Method_GetInfo (id); -- 2.25.1