Ejemplo n.º 1
0
        private void RenamePropertyNames()
        {
            Stat.Reset();
            int counter = 0;


            foreach (var t in blazorFile.module.GetTypes().Where(x => !LocalFunctions.HasDoNotMangleAttribute(x.CustomAttributes)))
            {
                //Console.WriteLine(t.Name);



                var properties = t.Properties.Where(x => !x.IsRuntimeSpecialName && !x.Name.Contains("<") && !x.Name.Contains("."))
                                 .Where(x => !LocalFunctions.HasParameterAttribute(x.CustomAttributes));



                foreach (var i in properties)
                {
                    if (!LocalData.manglePublic)
                    {
                        if (i.GetMethod != null)
                        {
                            if (i.GetMethod.IsPublic)
                            {
                                continue;
                            }
                        }

                        if (i.SetMethod != null)
                        {
                            if (i.SetMethod.IsPublic)
                            {
                                continue;
                            }
                        }
                    }


                    Console.WriteLine(i.Name);

                    if (LocalData.verboseDeep)
                    {
                        Console.WriteLine("=====property " + i.Name + ", type " + t.Name);
                    }

                    counter++;
                    i.Name = "P" + CodeHelper.GetCode(counter, MethodBase.GetCurrentMethod());

                    if (LocalData.verboseDeep)
                    {
                        Console.WriteLine("    =====new value " + i.Name);
                    }
                }

                counter = 0;
            }

            if (LocalData.verbose)
            {
                Console.WriteLine("renamed properties count = " + Stat.counter);
            }
        }