Example #1
0
        internal static void CheckCustomAttributes(Cecil.ICustomAttributeProvider type,
							    out DebuggerBrowsableState? browsable_state,
							    out DebuggerDisplayAttribute debugger_display,
							    out DebuggerTypeProxyAttribute type_proxy,
							    out bool is_compiler_generated)
        {
            browsable_state = null;
            debugger_display = null;
            type_proxy = null;
            is_compiler_generated = false;

            foreach (Cecil.CustomAttribute cattr in type.CustomAttributes) {
                string cname = cattr.Constructor.DeclaringType.FullName;
                if (cname == cgen_attr) {
                    is_compiler_generated = true;
                } else if (cname == debugger_display_attr) {
                    string text = (string) cattr.ConstructorArguments [0].Value;
                    debugger_display = new DebuggerDisplayAttribute (text);
                    foreach (var named_arg in cattr.Properties) {
                        string key = named_arg.Name;
                        if (key == "Name")
                            debugger_display.Name = (string) named_arg.Argument.Value;
                        else if (key == "Type")
                            debugger_display.Type = (string) named_arg.Argument.Value;
                        else {
                            debugger_display = null;
                            break;
                        }
                    }
                } else if (cname == browsable_attr) {
                    browsable_state = (DebuggerBrowsableState) cattr.GetBlob () [2];
                } else if (cname == type_proxy_attr) {
                    string text = (string) cattr.ConstructorArguments [0].Value;
                    type_proxy = new DebuggerTypeProxyAttribute (text);
                }
            }
        }
		public void Constructor_Type ()
		{
			var dtp = new DebuggerTypeProxyAttribute (typeof (string));
			Assert.IsNull (dtp.Target, "#1");
			Assert.AreEqual (typeof (string).AssemblyQualifiedName, dtp.ProxyTypeName, "#2");
		}
        bool InsertProxyChildren(DebuggingService dbgr, DebuggerTypeProxyAttribute pattr, TreeIter parent, ITargetStructObject sobj)
        {
            Mono.Debugger.StackFrame frame = dbgr.MainThread.CurrentFrame;
             		ITargetStructType proxy_type = frame.Language.LookupType (frame, pattr.ProxyTypeName) as ITargetStructType;
            if (proxy_type == null)
                proxy_type = frame.Language.LookupType (frame,
                                    sobj.Type.Name + "+" + pattr.ProxyTypeName) as ITargetStructType;
            if (proxy_type != null) {
                string name = String.Format (".ctor({0})", sobj.Type.Name);
                ITargetMethodInfo method = null;

                foreach (ITargetMethodInfo m in proxy_type.Constructors) {
                    if (m.FullName == name)
                        method = m;
                }

                if (method != null) {
                    ITargetFunctionObject ctor = proxy_type.GetConstructor (frame, method.Index);
                    ITargetObject[] args = new ITargetObject[1];
                    args[0] = sobj;

                    ITargetStructObject proxy_obj = ctor.Type.InvokeStatic (frame, args, false) as ITargetStructObject;

                    if (proxy_obj != null) {
                        foreach (ITargetPropertyInfo prop in proxy_obj.Type.Properties) {
                            InsertStructMember (parent, proxy_obj, prop, false);
                        }

                        TreeIter iter = store.Append (parent);
                        store.SetValue (iter, NAME_COL, "Raw View");
                        store.SetValue (iter, RAW_VIEW_COL, true);

                        Gdk.Pixbuf icon = Runtime.Gui.Resources.GetIcon (Stock.Class, Gtk.IconSize.Menu);
                        if (icon != null)
                            store.SetValue (iter, PIXBUF_COL, icon);

                        iters.Remove (iter);
                        AddPlaceholder (sobj, iter);

                        return true;
                    }
                }
            }

            return false;
        }