public override ValueReference GetIndexerReference(EvaluationContext ctx, object target, object[] indices) { TypeMirror targetType = GetValueType(ctx, target) as TypeMirror; Value[] values = new Value [indices.Length]; TypeMirror[] types = new TypeMirror [indices.Length]; for (int n = 0; n < indices.Length; n++) { types [n] = ToTypeMirror(ctx, GetValueType(ctx, indices [n])); values [n] = (Value)indices [n]; } List <MethodMirror> candidates = new List <MethodMirror> (); List <PropertyInfoMirror> props = new List <PropertyInfoMirror> (); TypeMirror type = targetType; while (type != null) { foreach (PropertyInfoMirror prop in type.GetProperties()) { MethodMirror met = prop.GetGetMethod(true); if (met != null && !met.IsStatic && met.GetParameters().Length > 0) { candidates.Add(met); props.Add(prop); } } type = type.BaseType; } MethodMirror idx = OverloadResolve((SoftEvaluationContext)ctx, targetType.Name, null, types, candidates, true); int i = candidates.IndexOf(idx); return(new PropertyValueReference(ctx, props[i], target, null, values)); }
public ExpandedProperty(TypeMirror typeMirror, StackFrame frame, LocalVariable localVariable) { this.frame = frame; this.localVariable = localVariable; var properties = typeMirror.GetProperties().Cast <Mirror>(); var methods = typeMirror.GetMethods().Cast <Mirror>(); var fields = typeMirror.GetFields().Cast <Mirror>(); var children = properties.Concat(methods).Concat(fields); allProperties = children.ToList(); }
private static List <KeyValuePair <string, Mirror> > GetChildren(TypeMirror type, Guid filterGuid) { var children = new List <KeyValuePair <string, Mirror> >(); do { if (filterGuid != EnumOnlyPropertiesFilter) { children.AddRange(type.GetFields().Select(x => new KeyValuePair <string, Mirror>(x.Name, x))); } if (filterGuid != EnumOnlyFieldsFilter) { children.AddRange(type.GetProperties().Select(x => new KeyValuePair <string, Mirror>(x.Name, x))); } type = type.BaseType; } while (type != null); children = children.Where(x => x.Key != null && x.Key.Length > 0 && x.Key[0] != '<').OrderBy(x => x.Key).ToList(); return(children); }
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); }
protected override IEnumerable <ValueReference> GetMembers(EvaluationContext ctx, object t, object co, BindingFlags bindingFlags) { Dictionary <string, PropertyInfoMirror> subProps = new Dictionary <string, PropertyInfoMirror> (); TypeMirror type = t as TypeMirror; TypeMirror realType = null; if (co != null && (bindingFlags & BindingFlags.Instance) != 0) { realType = GetValueType(ctx, co) as TypeMirror; } // First of all, get a list of properties overriden in sub-types while (realType != null && realType != type) { foreach (PropertyInfoMirror prop in realType.GetProperties(bindingFlags | BindingFlags.DeclaredOnly)) { MethodMirror met = prop.GetGetMethod(true); if (met == null || met.GetParameters().Length != 0 || met.IsAbstract || !met.IsVirtual || met.IsStatic) { continue; } if (met.IsPublic && ((bindingFlags & BindingFlags.Public) == 0)) { continue; } if (!met.IsPublic && ((bindingFlags & BindingFlags.NonPublic) == 0)) { continue; } subProps [prop.Name] = prop; } realType = realType.BaseType; } while (type != null) { foreach (FieldInfoMirror field in type.GetFields()) { if (field.IsStatic && ((bindingFlags & BindingFlags.Static) == 0)) { continue; } if (!field.IsStatic && ((bindingFlags & BindingFlags.Instance) == 0)) { continue; } if (field.IsPublic && ((bindingFlags & BindingFlags.Public) == 0)) { continue; } if (!field.IsPublic && ((bindingFlags & BindingFlags.NonPublic) == 0)) { continue; } yield return(new FieldValueReference(ctx, field, co, type)); } foreach (PropertyInfoMirror prop in type.GetProperties(bindingFlags)) { MethodMirror met = prop.GetGetMethod(true); if (met == null || met.GetParameters().Length != 0 || met.IsAbstract) { continue; } if (met.IsStatic && ((bindingFlags & BindingFlags.Static) == 0)) { continue; } if (!met.IsStatic && ((bindingFlags & BindingFlags.Instance) == 0)) { continue; } if (met.IsPublic && ((bindingFlags & BindingFlags.Public) == 0)) { continue; } if (!met.IsPublic && ((bindingFlags & BindingFlags.NonPublic) == 0)) { continue; } // If a property is overriden, return the override instead of the base property PropertyInfoMirror overriden; if (met.IsVirtual && subProps.TryGetValue(prop.Name, out overriden)) { yield return(new PropertyValueReference(ctx, overriden, co, overriden.DeclaringType, null)); } else { yield return(new PropertyValueReference(ctx, prop, co, type, null)); } } if ((bindingFlags & BindingFlags.DeclaredOnly) != 0) { break; } type = type.BaseType; } }