Esempio n. 1
0
        void FindInitializeComponentMethod(MTypeDef type, MMethodDef possibleInitMethod)
        {
            foreach (var methodDef in type.AllMethods)
            {
                if (methodDef.MethodDef.Name != ".ctor")
                {
                    continue;
                }
                if (methodDef.MethodDef.Body == null)
                {
                    continue;
                }
                foreach (var instr in methodDef.MethodDef.Body.Instructions)
                {
                    if (instr.OpCode.Code != Code.Call && instr.OpCode.Code != Code.Callvirt)
                    {
                        continue;
                    }
                    if (!MethodEqualityComparer.CompareDeclaringTypes.Equals(possibleInitMethod.MethodDef, instr.Operand as IMethod))
                    {
                        continue;
                    }

                    memberInfos.Method(possibleInitMethod).suggestedName = "InitializeComponent";
                    return;
                }
            }
        }
        public bool Check(MTypeDef type)
        {
            if (results.ContainsKey(type))
            {
                return(results[type]);
            }

            bool val;

            if (classNames.ContainsKey(type.TypeDef.FullName))
            {
                val = true;
            }
            else if (type.baseType == null)
            {
                if (type.TypeDef.BaseType != null)
                {
                    val = classNames.ContainsKey(type.TypeDef.BaseType.FullName);
                }
                else
                {
                    val = false;
                }
            }
            else
            {
                val = Check(type.baseType.typeDef);
            }

            results[type] = val;
            return(val);
        }
Esempio n. 3
0
 public TypeInfo(MTypeDef typeDef, MemberInfos memberInfos)
     : base(typeDef)
 {
     type             = typeDef;
     this.memberInfos = memberInfos;
     oldNamespace     = typeDef.TypeDef.Namespace.String;
 }
Esempio n. 4
0
 public void AddBaseType(MTypeDef baseDef, ITypeDefOrRef baseRef)
 {
     if (baseDef == null || baseRef == null)
     {
         return;
     }
     baseType = new TypeInfo(baseRef, baseDef);
 }
Esempio n. 5
0
 public void AddInterface(MTypeDef ifaceDef, ITypeDefOrRef iface)
 {
     if (ifaceDef == null || iface == null)
     {
         return;
     }
     interfaces.Add(new TypeInfo(iface, ifaceDef));
 }
Esempio n. 6
0
 public TypeInfo(MTypeDef typeDef, MemberInfos memberInfos)
     : base(typeDef)
 {
     this.type        = typeDef;
     this.memberInfos = memberInfos;
     oldNamespace     = typeDef.TypeDef.Namespace.String;
     if (base.oldFullName.Contains("[Public]"))
     {
         oldNamespace += "[Public]";
     }
 }
Esempio n. 7
0
 void MergeState(MTypeDef other)
 {
     if (other == null)
     {
         return;
     }
     if (!memberInfos.TryGetType(other, out var otherInfo))
     {
         return;
     }
     variableNameState.Merge(otherInfo.variableNameState);
 }
Esempio n. 8
0
        void MergeState(MTypeDef other)
        {
            if (other == null)
            {
                return;
            }
            TypeInfo otherInfo;

            if (!_memberInfos.TryGetType(other, out otherInfo))
            {
                return;
            }
            VariableNameState.Merge(otherInfo.VariableNameState);
        }
Esempio n. 9
0
        void mergeState(MTypeDef other)
        {
            if (other == null)
            {
                return;
            }
            TypeInfo otherInfo;

            if (!memberInfos.tryGetType(other, out otherInfo))
            {
                return;
            }
            variableNameState.merge(otherInfo.variableNameState);
        }
Esempio n. 10
0
        string FindWindowsFormsClassName(MTypeDef type)
        {
            foreach (var methodDef in type.AllMethods)
            {
                if (methodDef.MethodDef.Body == null)
                {
                    continue;
                }
                if (methodDef.MethodDef.IsStatic || methodDef.MethodDef.IsVirtual)
                {
                    continue;
                }
                var instructions = methodDef.MethodDef.Body.Instructions;
                for (int i = 2; i < instructions.Count; i++)
                {
                    var call = instructions[i];
                    if (call.OpCode.Code != Code.Call && call.OpCode.Code != Code.Callvirt)
                    {
                        continue;
                    }
                    if (!IsWindowsFormsSetNameMethod(call.Operand as IMethod))
                    {
                        continue;
                    }

                    var ldstr = instructions[i - 1];
                    if (ldstr.OpCode.Code != Code.Ldstr)
                    {
                        continue;
                    }
                    var className = ldstr.Operand as string;
                    if (className == null)
                    {
                        continue;
                    }

                    if (instructions[i - 2].GetParameterIndex() != 0)
                    {
                        continue;
                    }

                    FindInitializeComponentMethod(type, methodDef);
                    return(className);
                }
            }
            return(null);
        }
Esempio n. 11
0
 public bool IsWinFormsClass(MTypeDef type)
 {
     return(checkWinFormsClass.Check(type));
 }
Esempio n. 12
0
 public bool TryGetType(MTypeDef t, out TypeInfo info) => allTypeInfos.TryGetValue(t, out info);
Esempio n. 13
0
 public bool Check(MTypeDef type) => Check(type, 0);
Esempio n. 14
0
 public bool Check(MTypeDef type)
 {
     return(Check(type, 0));
 }
Esempio n. 15
0
 public bool TryGetType(MTypeDef t, out TypeInfo info)
 {
     return(allTypeInfos.TryGetValue(t, out info));
 }
Esempio n. 16
0
 public TypeInfo Type(MTypeDef t)
 {
     return(allTypeInfos[t]);
 }
Esempio n. 17
0
 public TypeInfo Type(MTypeDef t) => allTypeInfos[t];
Esempio n. 18
0
 public void Add(MTypeDef t) => types.Add(t);
Esempio n. 19
0
 public bool IsWinFormsClass(MTypeDef type) => checkWinFormsClass.Check(type);