Example #1
0
        private void Apply(ModuleDefMD module, TypeDef type)
        {
            var baseNames = Helper.GetBaseNames(type);
            var ispub     = RType.IsPublic(type);

            foreach (var m in type.Methods)
            {
                if (!IsSpecialName(m, baseNames))
                {
                    var nn = GetMethodyName(m);
                    Helper.WriteLine(type.Name + "." + m.Name + " -> " + nn);
                    m.Name = nn;
                    int pc = 1;
                    foreach (var p in m.ParamDefs)
                    {
                        p.Name = "p" + pc;
                        pc++;
                    }
                }
                if (m.IsConstructor && ((!ispub) || m.IsPrivate || (m.IsAssembly && (!m.IsFamily))))
                {
                    int pc = 1;
                    foreach (var p in m.ParamDefs)
                    {
                        p.Name = "p" + pc;
                        pc++;
                    }
                }
            }
        }
Example #2
0
        private static bool IsSpecialName(MethodDef m, HashSet <string> pubNames)
        {
            var  pn   = m.Name;
            bool isPN = m.IsRuntimeSpecialName ||  //m.IsSpecialName ||
                        pn.Contains(".") ||
                        pn.Contains("_Item") || pn.Contains("Invoke") ||
                        pubNames.Contains(pn);

            if (isPN)
            {
                return(true);
            }

            var typePub = RType.IsPublic(m.DeclaringType);

            if (typePub)
            {
                if (m.IsFamily)
                {
                    return(true);
                }                               // protected
                if (m.IsPublic)
                {
                    return(true);
                }                               // Public
            }

            return(false);
        }
Example #3
0
        private void Apply(ModuleDefMD module, TypeDef type)
        {
            var baseNames = Helper.GetBaseNames(type);

            if (!RType.IsPublic(type))
            {
                foreach (var p in type.Properties)
                {
                    if (!IsSpecialName(p, baseNames))
                    {
                        var nn = GetPropertyName(p);
                        Helper.WriteLine(type.Name + "." + p.Name + " -> " + nn);
                        p.Name = nn;
                    }
                }
            }
        }
Example #4
0
        public static HashSet <String> GetBaseNames(TypeDef tdef)
        {
            var list = GetBaseTypes(tdef);
            //var hs = list.ToHashSet(tdef.DefinitionAssembly);

            HashSet <String> r = new HashSet <string>();

            foreach (var d in list)
            {
                if (d.DefinitionAssembly != tdef.DefinitionAssembly)
                {
                    foreach (var n1 in d.Properties)
                    {
                        r.Add(n1.Name);
                    }
                    foreach (var n2 in d.Methods)
                    {
                        r.Add(n2.Name);
                    }
                }
                else
                {
                    if (RType.IsPublic(d))
                    {
                        foreach (var n1 in d.Properties)
                        {
                            r.Add(n1.Name);
                        }
                        foreach (var n2 in d.Methods)
                        {
                            if (n2.IsFamily || n2.IsPublic)
                            {
                                r.Add(n2.Name);
                            }
                        }
                    }
                }
            }

            return(r);
        }
Example #5
0
        private void Apply(ModuleDefMD module, TypeDef type)
        {
            var ispub = RType.IsPublic(type);

            foreach (var m in type.Fields)
            {
                if (m.Name.Contains("__"))
                {
                    continue;
                }
                if (m.IsRuntimeSpecialName)
                {
                    continue;
                }
                if (m.IsPrivate || (m.IsAssembly && (!m.IsFamily)) || (!ispub))
                {
                    fcount++;
                    m.Name = "f" + fcount;
                }
            }
        }