private static ReflectionMethod GetMatchedReflectionMethod(MonoCecilMethod monoCecilMethod, IEnumerable <ReflectionMethod> reflectionMethods) { return(reflectionMethods.FirstOrDefault(reflectionMethod => reflectionMethod.Name == monoCecilMethod.Name && reflectionMethod.Parameters .Select(reflectionParameter => reflectionParameter.ParameterType.FullName) .SequenceEqual(monoCecilMethod.Parameters.Select(parameter => parameter.ParameterType.FullName)))); }
private static MonoCecilMethod GetSetMethodFromViewModelBase(MonoCecilType viewModelBaseType) { return(setMethodInViewModelBase ?? (setMethodInViewModelBase = viewModelBaseType.Methods.Single(method => method.Name == "Set" && method.Parameters.Count() == 4 && method.GetParameterByIndex(0).ParameterType.FullName == typeof(string).FullName && method.GetParameterByIndex(1).ParameterType.FullName == "T&" && method.GetParameterByIndex(2).ParameterType.FullName == "T" && method.GetParameterByIndex(3).ParameterType.FullName == typeof(bool).FullName))); }
private static CommonMethod CreateCommonMethod(MonoCecilMethod monoCecilMethod, IEnumerable <ReflectionMethod> reflectionMethods) { var matchedReflectionMethod = GetMatchedReflectionMethod(monoCecilMethod, reflectionMethods); if (matchedReflectionMethod == null) { return(null); } var methodAttributes = JoinAttributes(matchedReflectionMethod.Attributes, monoCecilMethod.Attributes); return(new CommonMethod(methodAttributes, monoCecilMethod, matchedReflectionMethod)); }
private IEnumerable <AsmTreeNode> WalkTypeChildren(AsmTreeNode node) { var type = (TypeDefinition)node.IlDefinition; foreach (var method in type.Methods) { var wrappedMethod = new MonoCecilMethod(method); yield return(new AsmTreeNode(this, wrappedMethod) { FullName = wrappedMethod.ToString(), NodeType = AssemblyTreeNodeType.Method }); } }
public IEnumerable <IList <AsmTreeNode> > FindPathToMethod(string methodNameContains) { if (this.assemblies == null) { this.assemblies = this.assemblyLoader.LoadDomainAssemblies(options); } foreach (var asm in this.assemblies) { foreach (var type in asm.MainModule.Types) { foreach (var method in type.Methods) { if (method.FullName.ToLower().Contains(methodNameContains.ToLower())) { var wrapped = new MonoCecilMethod(method); yield return(new List <AsmTreeNode> { new AsmTreeNode(this, asm) { FullName = asm.MainModule.Name, NodeType = AssemblyTreeNodeType.Assembly }, new AsmTreeNode(this, asm) { FullName = type.Namespace, NodeType = AssemblyTreeNodeType.Namespace }, new AsmTreeNode(this, type) { FullName = type.FullName, NodeType = AssemblyTreeNodeType.Type }, new AsmTreeNode(this, wrapped) { FullName = wrapped.ToString(), NodeType = AssemblyTreeNodeType.Method } }); } } } } }
public virtual MonoCecilGenericInstanceMethod CreateGenericInstanceMethod(MonoCecilMethod monoCecilMethod) { return(new MonoCecilGenericInstanceMethod(new GenericInstanceMethod(monoCecilMethod.Instance))); }
internal CommonMethod(CommonAttribute[] attributes, MonoCecilMethod monoCecilMethod, ReflectionMethod reflectionMethod) { Attributes = attributes; MonoCecilMethod = monoCecilMethod; ReflectionMethod = reflectionMethod; }