Ejemplo n.º 1
0
        protected override TypeDisplayData OnGetTypeDisplayData(EvaluationContext ctx, object gtype)
        {
            CorType         type = (CorType)gtype;
            TypeDisplayData td   = null;

            CorEvaluationContext wctx = (CorEvaluationContext)ctx;
            Type t = type.GetTypeInfo(wctx.Session);

            if (t == null)
            {
                return(null);
            }

            foreach (object att in t.GetCustomAttributes(false))
            {
                DebuggerTypeProxyAttribute patt = att as DebuggerTypeProxyAttribute;
                if (patt != null)
                {
                    if (td == null)
                    {
                        td = new TypeDisplayData();
                    }
                    td.ProxyType = patt.ProxyTypeName;
                    continue;
                }
                DebuggerDisplayAttribute datt = att as DebuggerDisplayAttribute;
                if (datt != null)
                {
                    if (td == null)
                    {
                        td = new TypeDisplayData();
                    }
                    td.NameDisplayString  = datt.Name;
                    td.TypeDisplayString  = datt.Type;
                    td.ValueDisplayString = datt.Value;
                    continue;
                }
            }

            ArrayList mems = new ArrayList();

            mems.AddRange(t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance));
            mems.AddRange(t.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance));

            foreach (MemberInfo m in mems)
            {
                object[] atts = m.GetCustomAttributes(typeof(DebuggerBrowsableAttribute), false);
                if (atts.Length == 0)
                {
                    atts = m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), false);
                    if (atts.Length > 0)
                    {
                        atts[0] = new DebuggerBrowsableAttribute(DebuggerBrowsableState.Never);
                    }
                }
                if (atts.Length > 0)
                {
                    if (td == null)
                    {
                        td = new TypeDisplayData();
                    }
                    if (td.MemberData == null)
                    {
                        td.MemberData = new Dictionary <string, DebuggerBrowsableState> ();
                    }
                    td.MemberData[m.Name] = ((DebuggerBrowsableAttribute)atts[0]).State;
                }
            }
            return(td);
        }
        protected override TypeDisplayData OnGetTypeDisplayData(EvaluationContext gctx, object type)
        {
            SoftEvaluationContext ctx = (SoftEvaluationContext)gctx;
            TypeDisplayData       td  = new TypeDisplayData();

            try {
                TypeMirror t = (TypeMirror)type;
                foreach (CustomAttributeDataMirror attr in t.GetCustomAttributes(true))
                {
                    string attName = attr.Constructor.DeclaringType.FullName;
                    if (attName == "System.Diagnostics.DebuggerDisplayAttribute")
                    {
                        DebuggerDisplayAttribute at = BuildAttribute <DebuggerDisplayAttribute> (attr);
                        td.NameDisplayString  = at.Name;
                        td.TypeDisplayString  = at.Type;
                        td.ValueDisplayString = at.Value;
                    }
                    else if (attName == "System.Diagnostics.DebuggerTypeProxyAttribute")
                    {
                        DebuggerTypeProxyAttribute at = BuildAttribute <DebuggerTypeProxyAttribute> (attr);
                        td.ProxyType = at.ProxyTypeName;
                        if (!string.IsNullOrEmpty(td.ProxyType))
                        {
                            ForceLoadType(ctx, td.ProxyType);
                        }
                    }
                }
                foreach (FieldInfoMirror fi in t.GetFields())
                {
                    CustomAttributeDataMirror[] attrs = fi.GetCustomAttributes(true);
                    DebuggerBrowsableAttribute  att   = GetAttribute <DebuggerBrowsableAttribute> (attrs);
                    if (att == null)
                    {
                        var cga = GetAttribute <System.Runtime.CompilerServices.CompilerGeneratedAttribute> (attrs);
                        if (cga != null)
                        {
                            att = new DebuggerBrowsableAttribute(DebuggerBrowsableState.Never);
                        }
                    }
                    if (att != null)
                    {
                        if (td.MemberData == null)
                        {
                            td.MemberData = new Dictionary <string, DebuggerBrowsableState> ();
                        }
                        td.MemberData [fi.Name] = att.State;
                    }
                }
                foreach (PropertyInfoMirror pi in t.GetProperties())
                {
                    DebuggerBrowsableAttribute att = GetAttribute <DebuggerBrowsableAttribute> (pi.GetCustomAttributes(true));
                    if (att != null)
                    {
                        if (td.MemberData == null)
                        {
                            td.MemberData = new Dictionary <string, DebuggerBrowsableState> ();
                        }
                        td.MemberData [pi.Name] = att.State;
                    }
                }
            } catch (Exception ex) {
                ctx.Session.WriteDebuggerOutput(true, ex.ToString());
            }
            return(td);
        }