Exemple #1
0
        private void IndexConcreteMethods(ModuleDefinition module)
        {
            var implementationMethods = DecompilerService.GetConcreteMethods(module);

            foreach (var method in implementationMethods)
            {
                if (ShouldSkip(method))
                {
                    continue;
                }

                var methodNameKey = SignatureKeyService.GetFullMethodSignature(method);
                if (!ImplementationMethodsIndexedByName.ContainsKey(methodNameKey))
                {
                    ImplementationMethodsIndexedByName.Add(methodNameKey, method);
                    ImplementationMethodsList.Add(method);
                    ImplementationMethodsIndexedByTypeName.Add(method.DeclaringType.FullName, method);
                }

                var genericSignature = SignatureKeyService.GetGenericMethodSignature(method);
                if (!string.IsNullOrEmpty(genericSignature))
                {
                    if (!ImplementationMethodsIndexedByGenericSignature.ContainsKey(genericSignature))
                    {
                        ImplementationMethodsIndexedByGenericSignature.Add(genericSignature, method);
                    }
                }
            }
        }
Exemple #2
0
        private bool FindBaseClassMethod(MethodDefinition method, MethodObject methodNode)
        {
            // TODO currently only looks at direct base type
            if (ImplementationMethodsIndexedByTypeName.HasIndex(method.DeclaringType.BaseType.FullName))
            {
                var methodsOfBaseParent = ImplementationMethodsIndexedByTypeName.Get(method.DeclaringType.BaseType.FullName);
                var matchingMethod      = methodsOfBaseParent.FirstOrDefault(x => SignatureKeyService.GetMethodSignature(x).Equals(SignatureKeyService.GetMethodSignature(method)));
                if (matchingMethod != null)
                {
                    methodNode.VirtualMethod  = matchingMethod;
                    methodNode.ImplementsType = ImplementsType.Overrides;

                    return(true);
                }
            }

            return(false);
        }