private void InitializeAnalyzer() { foundMethods = new ConcurrentDictionary <MethodDef, int>(); var baseMethods = TypesHierarchyHelpers.FindBaseMethods(analyzedMethod).ToArray(); if (baseMethods.Length > 0) { baseMethod = baseMethods[baseMethods.Length - 1]; } else { baseMethod = analyzedMethod; } possibleTypes = new List <ITypeDefOrRef>(); ITypeDefOrRef type = analyzedMethod.DeclaringType.BaseType; while (type != null) { possibleTypes.Add(type); var resolvedType = type.ResolveTypeDef(); type = resolvedType == null ? null : resolvedType.BaseType; } }
private void InitializeAnalyzer() { foundMethods = new ConcurrentDictionary <MethodDefinition, int>(); var BaseMethods = TypesHierarchyHelpers.FindBaseMethods(analyzedMethod).ToArray(); if (BaseMethods.Length > 0) { baseMethod = BaseMethods[BaseMethods.Length - 1]; } else { baseMethod = analyzedMethod; } possibleTypes = new List <TypeReference>(); TypeReference type = analyzedMethod.DeclaringType.BaseType; while (type != null) { possibleTypes.Add(type); type = type.Resolve().BaseType; } }
void InitializeAnalyzer() { foundMethods = new ConcurrentDictionary <MethodDef, int>(); var baseMethods = TypesHierarchyHelpers.FindBaseMethods(analyzedMethod).ToArray(); if (baseMethods.Length > 0) { baseMethod = baseMethods[baseMethods.Length - 1]; } else { baseMethod = analyzedMethod; } }
protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct) { AddTypeEquivalentTypes(Context.DocumentService, analyzedTypes[0], analyzedTypes); var overrides = analyzedMethod.Overrides; foreach (var declType in analyzedTypes) { if (overrides.Count > 0) { bool matched = false; foreach (var o in overrides) { if (o.MethodDeclaration.ResolveMethodDef() is MethodDef method && (method.IsVirtual || method.IsAbstract)) { matched = true; yield return(new MethodNode(method) { Context = Context }); } } if (matched) { yield break; } } foreach (var method in TypesHierarchyHelpers.FindBaseMethods(analyzedMethod, declType)) { if (!(method.IsVirtual || method.IsAbstract)) { continue; } yield return(new MethodNode(method) { Context = Context }); yield break; } } }
public static IEnumerable <VirtualMethod> VirtualAnalysis(IEnumerable <TypeDefinition> types) { var virtuals = new Dictionary <MethodDefinition, VirtualMethod>(); foreach (var t in types) { foreach (var m in t.Methods) { //types var overrides = TypesHierarchyHelpers.FindBaseMethods(m).Where(b => b.IsVirtual); foreach (var basem in overrides) { AddMethod(virtuals, m, basem); } foreach (var i in t.Interfaces) { foreach (var interfaceMethod in i.InterfaceType.Resolve().Methods) { // don't create virtual for the instance checker metod if (interfaceMethod.Name.Contains("IsInstance")) { continue; } //if (MatchInterfaceMethod(interfaceMethod, m)) if (TypesHierarchyHelpers.MatchInterfaceMethod(interfaceMethod, m, i.InterfaceType)) { AddMethod(virtuals, m, interfaceMethod); } } } } } return(virtuals.Values.ToArray()); }