private static void AnalyseFieldsInType(SymbolTypeDefinition symbolType)
        {
            var overloads = new List <SymbolOverload>();

            foreach (var field in symbolType.Type.Fields)
            {
                if (field.IsSpecialName || field.IsRuntimeSpecialName)
                {
                    continue;
                }

                var fieldOverload = overloads.FirstOrDefault(
                    overload => overload.Symbols.All(
                        x => ((FieldDefinition)x.Member).FieldType != field.FieldType));

                if (fieldOverload == null)
                {
                    fieldOverload = new SymbolOverload();
                    overloads.Add(fieldOverload);
                    symbolType.MemberOverloads.Add(fieldOverload);
                }

                fieldOverload.Symbols.Add(new SymbolDefinition(field));
            }
        }
        private static void AnalyseMethodsInType(SymbolTypeDefinition symbolType)
        {
            var overloads = new List <SymbolOverload>();

            foreach (var method in symbolType.Type.Methods)
            {
                if (method.IsSpecialName || method.IsRuntimeSpecialName || method.IsVirtual)
                {
                    continue;
                }

                var methodOverload = overloads.FirstOrDefault(
                    overload => overload.Symbols.All(
                        x =>
                {
                    var method2 = (MethodDefinition)x.Member;
                    return(method2.ReturnType != method.ReturnType ||
                           !method2.Parameters.SequenceEqual(method.Parameters, ParameterComparer.Instance));
                }));

                if (methodOverload == null)
                {
                    methodOverload = new SymbolOverload();
                    overloads.Add(methodOverload);
                    symbolType.MemberOverloads.Add(methodOverload);
                }

                methodOverload.Symbols.Add(new SymbolDefinition(method));
            }
        }
        private void AnalysePropertiesInType(SymbolTypeDefinition symbolType)
        {
            var overloads = new List <SymbolOverload>();

            foreach (var property in symbolType.Type.Properties)
            {
                if (property.IsSpecialName || property.IsRuntimeSpecialName)
                {
                    continue;
                }

                var propertyOverload = overloads.FirstOrDefault(
                    overload => overload.Symbols.All(
                        x => ((PropertyDefinition)x.Member).PropertyType != property.PropertyType));

                if (propertyOverload == null)
                {
                    propertyOverload = new SymbolOverload();
                    overloads.Add(propertyOverload);
                    symbolType.MemberOverloads.Add(propertyOverload);
                }

                propertyOverload.Symbols.Add(new SymbolDefinition(property));
            }
        }
Exemplo n.º 4
0
        private static void AnalyseFieldsInType(SymbolTypeDefinition symbolType)
        {
            var overloads = new List <SymbolOverload>();

            foreach (var field in symbolType.Type.Fields)
            {
                if (field.IsSpecialName || field.IsRuntimeSpecialName || (Obfuscator.current.SkipPublicFields && field.IsPublic))
                {
#if DEBUG
                    Console.Write("Field in Symboltype skipped.");
                    Logger.logger("Field Skipped: " + field.Name);
#endif

                    continue;
                }

                var fieldOverload = overloads.FirstOrDefault(
                    overload => overload.Symbols.All(
                        x => ((FieldDefinition)x.Member).FieldType != field.FieldType));

                if (fieldOverload == null)
                {
                    fieldOverload = new SymbolOverload();
                    overloads.Add(fieldOverload);
                    symbolType.MemberOverloads.Add(fieldOverload);
                }

                fieldOverload.Symbols.Add(new SymbolDefinition(field));
            }
        }
Exemplo n.º 5
0
        private void AnalyseType(TypeDefinition type)
        {
            var symbolType = new SymbolTypeDefinition(type);

            Report.TypesToRename.Add(symbolType);

            foreach (var nestedType in type.NestedTypes)
            {
            #if DEBUG
                Logger.logger("NestedType: " + nestedType.FullName);
                #endif

                AnalyseType(nestedType);
            }

            if (type.IsEnum || type.IsValueType)
            {
            #if DEBUG
                Logger.logger("Type Returned void : ");
                #endif

                return;
            }

            //
            //if (!symbolType.Type.IsNested)
            AnalyseFieldsInType(symbolType);

            AnalyseMethodsInType(symbolType);
            AnalysePropertiesInType(symbolType);
        }
Exemplo n.º 6
0
        private static void AnalyseMethodsInType(SymbolTypeDefinition symbolType)
        {
            var overloads = new List <SymbolOverload>();

            foreach (var method in symbolType.Type.Methods)
            {
                if (method.IsSpecialName || method.IsRuntimeSpecialName || method.IsVirtual || (Obfuscator.current.SkipPublicMethods && method.IsPublic) || (Obfuscator.current.SkipPrivateMethods && method.IsPrivate))
                {
                #if DEBUG
                    Console.Write("Method Skipped.");
                    Logger.logger("Method Skipped: " + method.Name);
                #endif
                    continue;
                }

                var methodOverload = overloads.FirstOrDefault(
                    overload => overload.Symbols.All(
                        x =>
                {
                    var method2 = (MethodDefinition)x.Member;
                    return(method2.ReturnType != method.ReturnType ||
                           !method2.Parameters.SequenceEqual(method.Parameters, ParameterComparer.Instance));
                }));

                if (methodOverload == null)
                {
                    methodOverload = new SymbolOverload();
                    overloads.Add(methodOverload);
                    symbolType.MemberOverloads.Add(methodOverload);
                }

                methodOverload.Symbols.Add(new SymbolDefinition(method));
            }
        }
        private void AnalyseType(TypeDefinition type)
        {
            var symbolType = new SymbolTypeDefinition(type);

            Report.TypesToRename.Add(symbolType);

            foreach (var nestedType in type.NestedTypes)
            {
                AnalyseType(nestedType);
            }

            //if (type.IsEnum || type.IsValueType)
            //    return;
            //
            //if (!symbolType.Type.IsNested)
            AnalyseFieldsInType(symbolType);

            AnalyseMethodsInType(symbolType);
            AnalysePropertiesInType(symbolType);
        }