Esempio n. 1
0
        private bool IsInnerAssemblyCall(MethodNode rootMethod, MethodObject calledMethod, MethodDefinition calledMethodDefinition)
        {
            if (calledMethod.GetMethodType() == MethodType.ImplAndInterface) // method has concrete implementation and interface
            {
                // if the concrete method called is not of the same assembly as the root method then return false
                if (!calledMethod.ConcreteMethod.DeclaringType.Module.Assembly.Name.Name.Equals(rootMethod.ConcreteType.AssemblyName))
                {
                    return(false);
                }
            }
            else if (calledMethod.GetMethodType() == MethodType.InterfaceOnly) // method has only an interface (concrete impl module may not be loaded)
            {
                // if the interface method called is not of the same assembly as the root method then return false
                if (!calledMethod.InterfaceMethod.DeclaringType.Module.Name.Equals(rootMethod.ConcreteType.AssemblyName))
                {
                    return(false);
                }
            }
            else // just a concrete impl with no interface
            {
                // if the concrete method called is not of the same assembly as the root method then return false
                if (!calledMethod.ConcreteMethod.DeclaringType.Module.Assembly.Name.Name.Equals(rootMethod.ConcreteType.AssemblyName))
                {
                    return(false);
                }
            }

            // if the called method is not of the company's namespace then return flase
            if (!Regex.IsMatch(calledMethodDefinition.DeclaringType.Namespace, _companyAssembliesPattern))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        private bool IsCrossAssemblyCall(MethodNode rootMethod, MethodObject calledMethod, int depth)
        {
            if (depth == 1)
            {
                return(false);
            }

            var calledMethodDefinition = calledMethod.GetMethodDefinition();

            if (!calledMethodDefinition.IsPublic && !calledMethodDefinition.DeclaringType.IsPublic)
            {
                return(false);
            }

            if (calledMethod.GetMethodType() == MethodType.ImplAndInterface)
            {
                if (calledMethod.ConcreteMethod.DeclaringType.Module.Assembly.Name.Name.Equals(rootMethod.ConcreteType.AssemblyName))
                {
                    return(false);
                }
            }
            else if (calledMethod.GetMethodType() == MethodType.InterfaceOnly)
            {
                if (calledMethod.InterfaceMethod.DeclaringType.Module.Name.Equals(rootMethod.ConcreteType.AssemblyName))
                {
                    return(false);
                }
            }
            else
            {
                if (calledMethod.ConcreteMethod.DeclaringType.Module.Assembly.Name.Name.Equals(rootMethod.ConcreteType.AssemblyName))
                {
                    return(false);
                }
            }

            if (!Regex.IsMatch(calledMethodDefinition.DeclaringType.Namespace, _companyAssembliesPattern))
            {
                return(false);
            }

            return(true);
        }