protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct) { //note: only goes up 1 level AnalyzerTreeNodeData newNode = null; try { //get base type (if any) if (analyzedMethod.DeclaringType.BaseType == null) { yield break; } ITypeDefOrRef baseType = analyzedMethod.DeclaringType.BaseType; while (baseType != null) { //only typedef has a Methods property if (baseType is TypeDef) { TypeDef def = (TypeDef)baseType; foreach (var method in def.Methods) { if (TypesHierarchyHelpers.IsBaseMethod(method, analyzedMethod)) { newNode = new MethodNode(method) { Context = Context }; break; //there can be only one } } //escape from the while loop if we have a match (cannot yield return in try/catch) if (newNode != null) { break; } baseType = def.BaseType; } else { //try to resolve the TypeRef //will be null if resolving failed baseType = baseType.Resolve(); } } } catch (ResolveException) { //ignored } if (newNode != null) { yield return(newNode); } }
public static bool RequiresSpecialAccess(this ITypeDefOrRef type) { var typeDef = (TypeDefinition)type.Resolve(); while (typeDef != null) { if (typeDef.IsNestedPrivate || typeDef.IsNestedFamily || typeDef.IsNestedFamilyAndAssembly || typeDef.IsNestedFamilyOrAssembly) { return(true); } typeDef = typeDef.DeclaringType; } return(false); }
protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct) { //get base type (if any) if (analyzedEvent.DeclaringType.BaseType == null) { yield break; } ITypeDefOrRef baseType = analyzedEvent.DeclaringType.BaseType; while (baseType != null) { //only typedef has a Events property if (baseType is TypeDef) { TypeDef def = (TypeDef)baseType; foreach (EventDef eventDef in def.Events) { if (TypesHierarchyHelpers.IsBaseEvent(eventDef, analyzedEvent)) { MethodDef anyAccessor = eventDef.AddMethod ?? eventDef.RemoveMethod; if (anyAccessor == null) { continue; } yield return(new EventNode(eventDef) { Context = Context }); yield break; } } baseType = def.BaseType; } else { //try to resolve the TypeRef //will be null if resolving failed baseType = baseType.Resolve(); } } }
protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct) { //get base type (if any) if (analyzedProperty.DeclaringType.BaseType == null) { yield break; } ITypeDefOrRef baseType = analyzedProperty.DeclaringType.BaseType; while (baseType != null) { //only typedef has a Properties property if (baseType is TypeDef) { TypeDef def = (TypeDef)baseType; foreach (PropertyDef property in def.Properties) { if (TypesHierarchyHelpers.IsBaseProperty(property, analyzedProperty)) { MethodDef anyAccessor = property.GetMethod ?? property.SetMethod; if (anyAccessor == null) { continue; } yield return(new PropertyNode(property) { Context = Context }); yield break; } } baseType = def.BaseType; } else { //try to resolve the TypeRef //will be null if resolving failed baseType = baseType.Resolve(); } } }