public ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options)
        {
            EvaluationContext  cctx      = ctx.WithOptions(options);
            object             tdataType = null;
            TypeDisplayData    tdata     = null;
            List <ObjectValue> list      = new List <ObjectValue> ();

            foreach (ValueReference val in cctx.Adapter.GetMembersSorted(cctx, objectSource, type, obj, bindingFlags))
            {
                object decType = val.DeclaringType;
                if (decType != null && decType != tdataType)
                {
                    tdataType = decType;
                    tdata     = cctx.Adapter.GetTypeDisplayData(cctx, decType);
                }
                DebuggerBrowsableState state = tdata.GetMemberBrowsableState(val.Name);
                if (state == DebuggerBrowsableState.Never)
                {
                    continue;
                }
                ObjectValue oval = val.CreateObjectValue(options);
                list.Add(oval);
            }
            if ((bindingFlags & BindingFlags.NonPublic) == 0)
            {
                BindingFlags newFlags = bindingFlags | BindingFlags.NonPublic;
                newFlags &= ~BindingFlags.Public;
                list.Add(CreateNonPublicsNode(cctx, objectSource, type, obj, newFlags));
            }
            return(list.ToArray());
        }
        public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
        {
            if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
                throw new ArgumentOutOfRangeException("state");

            this.state = state;
        }
Example #3
0
 public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
 {
     if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
     {
         throw new ArgumentOutOfRangeException("state");
     }
     this.state = state;
 }
        public void AddDebuggerBrowsableAttribute(IMutableMember member, DebuggerBrowsableState debuggerBrowsableState)
        {
            ArgumentUtility.CheckNotNull("member", member);

            var attribute = new CustomAttributeDeclaration(s_debuggerBrowsableAttributeConstructor, new object[] { debuggerBrowsableState });

            member.AddCustomAttribute(attribute);
        }
Example #5
0
        public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
        {
            if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
            {
                throw new ArgumentOutOfRangeException(nameof(state));
            }
            Contract.EndContractBlock();

            this.state = state;
        }
Example #6
0
		public CorFieldInfo(CorType ownerType, uint token, string name, TypeSig fieldType, FieldAttributes attrs, object constant, CorElementType constantType, DebuggerBrowsableState? debuggerBrowsableState, bool compilerGeneratedAttribute) {
			this.OwnerType = ownerType;
			this.Token = token;
			this.Name = name;
			this.FieldType = fieldType;
			this.Attributes = attrs;
			this.Constant = constant;
			this.ConstantType = constantType;
			this.DebuggerBrowsableState = debuggerBrowsableState;
			this.CompilerGeneratedAttribute = compilerGeneratedAttribute;
		}
Example #7
0
		public CorPropertyInfo(CorType ownerType, uint token, uint getToken, uint setToken, string name, MethodSig getSig, MethodSig setSig, MethodAttributes getMethodAttributes, DebuggerBrowsableState? debuggerBrowsableState) {
			this.OwnerType = ownerType;
			this.Token = token;
			this.GetToken = getToken;
			this.SetToken = setToken;
			this.Name = name;
			this.GetSig = getSig;
			this.SetSig = setSig;
			this.GetMethodAttributes = getMethodAttributes;
			this.DebuggerBrowsableState = debuggerBrowsableState;
		}
Example #8
0
        private static DkmClrDebuggerBrowsableAttributeState ConvertBrowsableState(DebuggerBrowsableState state)
        {
            switch (state)
            {
            case DebuggerBrowsableState.Never:
                return(DkmClrDebuggerBrowsableAttributeState.Never);

            case DebuggerBrowsableState.Collapsed:
                return(DkmClrDebuggerBrowsableAttributeState.Collapsed);

            case DebuggerBrowsableState.RootHidden:
                return(DkmClrDebuggerBrowsableAttributeState.RootHidden);

            default:
                throw ExceptionUtilities.UnexpectedValue(state);
            }
        }
 public DebuggerBrowsableAttribute(DebuggerBrowsableState state);
Example #10
0
        public virtual ObjectValue[] GetObjectValueChildren(EvaluationContext ctx, IObjectSource objectSource, object type, object obj, int firstItemIndex, int count, bool dereferenceProxy)
        {
            if (IsArray(ctx, obj))
            {
                ArrayElementGroup agroup = new ArrayElementGroup(ctx, CreateArrayAdaptor(ctx, obj));
                return(agroup.GetChildren(ctx.Options));
            }

            if (IsPrimitive(ctx, obj))
            {
                return(new ObjectValue[0]);
            }

            bool showRawView = false;

            // If there is a proxy, it has to show the members of the proxy
            object proxy = obj;

            if (dereferenceProxy)
            {
                proxy = GetProxyObject(ctx, obj);
                if (proxy != obj)
                {
                    type        = GetValueType(ctx, proxy);
                    showRawView = true;
                }
            }

            TypeDisplayData tdata = GetTypeDisplayData(ctx, type);
            bool            groupPrivateMembers = ctx.Options.GroupPrivateMembers && (ctx.Options.GroupUserPrivateMembers || IsExternalType(ctx, type));

            List <ObjectValue> values           = new List <ObjectValue> ();
            BindingFlags       flattenFlag      = ctx.Options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
            BindingFlags       nonNonPublicFlag = groupPrivateMembers || showRawView ? (BindingFlags)0 : BindingFlags.NonPublic;
            BindingFlags       staticFlag       = ctx.Options.GroupStaticMembers ? (BindingFlags)0 : BindingFlags.Static;
            BindingFlags       access           = BindingFlags.Public | BindingFlags.Instance | flattenFlag | nonNonPublicFlag | staticFlag;

            // Load all members to a list before creating the object values,
            // to avoid problems with objects being invalidated due to evaluations in the target,
            List <ValueReference> list = new List <ValueReference> ();

            list.AddRange(GetMembersSorted(ctx, objectSource, type, proxy, access));

            object tdataType = type;

            foreach (ValueReference val in list)
            {
                try {
                    object decType = val.DeclaringType;
                    if (decType != null && decType != tdataType)
                    {
                        tdataType = decType;
                        tdata     = GetTypeDisplayData(ctx, decType);
                    }
                    DebuggerBrowsableState state = tdata.GetMemberBrowsableState(val.Name);
                    if (state == DebuggerBrowsableState.Never)
                    {
                        continue;
                    }

                    if (state == DebuggerBrowsableState.RootHidden && dereferenceProxy)
                    {
                        object ob = val.Value;
                        if (ob != null)
                        {
                            values.Clear();
                            values.AddRange(GetObjectValueChildren(ctx, val, ob, -1, -1));
                            showRawView = true;
                            break;
                        }
                    }
                    else
                    {
                        ObjectValue oval = val.CreateObjectValue(true);
                        values.Add(oval);
                    }
                }
                catch (Exception ex) {
                    ctx.WriteDebuggerError(ex);
                    values.Add(ObjectValue.CreateError(null, new ObjectPath(val.Name), GetDisplayTypeName(GetTypeName(ctx, val.Type)), ex.Message, val.Flags));
                }
            }

            if (showRawView)
            {
                values.Add(RawViewSource.CreateRawView(ctx, objectSource, obj));
            }
            else
            {
                if (IsArray(ctx, proxy))
                {
                    ICollectionAdaptor col    = CreateArrayAdaptor(ctx, proxy);
                    ArrayElementGroup  agroup = new ArrayElementGroup(ctx, col);
                    ObjectValue        val    = ObjectValue.CreateObject(null, new ObjectPath("Raw View"), "", "", ObjectValueFlags.ReadOnly, values.ToArray());
                    values = new List <ObjectValue> ();
                    values.Add(val);
                    values.AddRange(agroup.GetChildren(ctx.Options));
                }
                else
                {
                    if (ctx.Options.GroupStaticMembers && HasMembers(ctx, type, proxy, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | flattenFlag))
                    {
                        access = BindingFlags.Static | BindingFlags.Public | flattenFlag | nonNonPublicFlag;
                        values.Add(FilteredMembersSource.CreateStaticsNode(ctx, objectSource, type, proxy, access));
                    }
                    if (groupPrivateMembers && HasMembers(ctx, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag))
                    {
                        values.Add(FilteredMembersSource.CreateNonPublicsNode(ctx, objectSource, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag));
                    }

                    if (!ctx.Options.FlattenHierarchy)
                    {
                        object baseType = GetBaseType(ctx, type, false);
                        if (baseType != null)
                        {
                            values.Insert(0, BaseTypeViewSource.CreateBaseTypeView(ctx, objectSource, baseType, proxy));
                        }
                    }
                }
            }
            return(values.ToArray());
        }
Example #11
0
 public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
 {
     this.state = state;
 }
 public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
 {
 }
        public override ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options)
        {
            EvaluationContext ctx = GetContext(options);

            try
            {
                List <ObjectValue> list        = new List <ObjectValue> ();
                BindingFlags       flattenFlag = options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
                BindingFlags       flags       = BindingFlags.Static | BindingFlags.Public | flattenFlag;
                bool groupPrivateMembers       = options.GroupPrivateMembers && (options.GroupUserPrivateMembers || ctx.Adapter.IsExternalType(ctx, type));
                if (!groupPrivateMembers)
                {
                    flags |= BindingFlags.NonPublic;
                }

                TypeDisplayData tdata     = ctx.Adapter.GetTypeDisplayData(ctx, type);
                object          tdataType = type;

                foreach (ValueReference val in ctx.Adapter.GetMembersSorted(ctx, this, type, null, flags))
                {
                    object decType = val.DeclaringType;
                    if (decType != null && decType != tdataType)
                    {
                        tdataType = decType;
                        tdata     = ctx.Adapter.GetTypeDisplayData(ctx, decType);
                    }
                    DebuggerBrowsableState state = tdata.GetMemberBrowsableState(val.Name);
                    if (state == DebuggerBrowsableState.Never)
                    {
                        continue;
                    }

                    ObjectValue oval = val.CreateObjectValue(options);
                    list.Add(oval);
                }

                List <ObjectValue> nestedTypes = new List <ObjectValue> ();
                foreach (object t in ctx.Adapter.GetNestedTypes(ctx, type))
                {
                    nestedTypes.Add(new TypeValueReference(ctx, t).CreateObjectValue(options));
                }

                nestedTypes.Sort(delegate(ObjectValue v1, ObjectValue v2)
                {
                    return(v1.Name.CompareTo(v2.Name));
                });

                list.AddRange(nestedTypes);

                if (groupPrivateMembers)
                {
                    list.Add(FilteredMembersSource.CreateNonPublicsNode(ctx, this, type, null, BindingFlags.NonPublic | BindingFlags.Static | flattenFlag));
                }

                if (!options.FlattenHierarchy)
                {
                    object baseType = ctx.Adapter.GetBaseType(ctx, type, false);
                    if (baseType != null)
                    {
                        TypeValueReference baseRef = new TypeValueReference(ctx, baseType);
                        ObjectValue        baseVal = baseRef.CreateObjectValue(false);
                        baseVal.Name = "base";
                        list.Insert(0, baseVal);
                    }
                }

                return(list.ToArray());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                ctx.WriteDebuggerOutput(ex.Message);
                return(new ObjectValue [0]);
            }
        }
Example #14
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 Ctor_InvalidState_ThrowsArgumentOutOfRangeException(DebuggerBrowsableState state)
 {
     AssertExtensions.Throws <ArgumentOutOfRangeException>("state", () => new DebuggerBrowsableAttribute(state));
 }
 { public HiddenMember(DebuggerBrowsableState dummy)
   {
   }
Example #17
0
        public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
        {
            if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
                throw new ArgumentOutOfRangeException(nameof(state));
            Contract.EndContractBlock();

            _state = state;
        }
Example #18
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Diagnostics.DebuggerBrowsableAttribute" /> class. </summary><param name="state">One of the <see cref="T:System.Diagnostics.DebuggerBrowsableState" /> values that specifies how to display the member.</param><exception cref="T:System.ArgumentOutOfRangeException"><paramref name="state" /> is not one of the <see cref="T:System.Diagnostics.DebuggerBrowsableState" /> values.</exception>
 public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
 {
     throw new NotImplementedException();
 }
		public DebuggerBrowsableAttribute(DebuggerBrowsableState state) {
			this.state = state;
		}
 public void AddDebuggerBrowsableAttribute(DebuggerBrowsableState state) => this.Add(this.builder.GetType("System.Diagnostics.DebuggerBrowsableAttribute"), state);
Example #21
0
 private static DkmClrDebuggerBrowsableAttributeState ConvertBrowsableState(DebuggerBrowsableState state)
 {
     switch (state)
     {
         case DebuggerBrowsableState.Never:
             return DkmClrDebuggerBrowsableAttributeState.Never;
         case DebuggerBrowsableState.Collapsed:
             return DkmClrDebuggerBrowsableAttributeState.Collapsed;
         case DebuggerBrowsableState.RootHidden:
             return DkmClrDebuggerBrowsableAttributeState.RootHidden;
         default:
             throw ExceptionUtilities.UnexpectedValue(state);
     }
 }
Example #22
0
 public void AddDebuggerBrowsableAttribute(DebuggerBrowsableState state) => this.Add(typeof(DebuggerBrowsableAttribute), state);
        public void Ctor_State(DebuggerBrowsableState state)
        {
            var attribute = new DebuggerBrowsableAttribute(state);

            Assert.Equal(state, attribute.State);
        }