Beispiel #1
0
        IEnumerable <FieldDefinition> getPossibleFields(TypeDefinition type)
        {
            var typeToFields = new TypeDefinitionDict <List <FieldDefinition> >();

            foreach (var field in type.Fields)
            {
                if (field.Attributes != FieldAttributes.Private)
                {
                    continue;
                }
                var fieldType = DotNetUtils.getType(module, field.FieldType);
                if (fieldType == null)
                {
                    continue;
                }
                if (!checkBaseType(fieldType))
                {
                    continue;
                }
                var list = typeToFields.find(fieldType);
                if (list == null)
                {
                    typeToFields.add(fieldType, list = new List <FieldDefinition>());
                }
                list.Add(field);
            }

            foreach (var list in typeToFields.getValues())
            {
                if (list.Count == 1)
                {
                    yield return(list[0]);
                }
            }
        }
        public TypeDefinitionDict <bool> getInlinedTypes(IEnumerable <MethodDefinition> unusedMethods)
        {
            var unused = new MethodDefinitionAndDeclaringTypeDict <bool>();

            foreach (var method in unusedMethods)
            {
                unused.add(method, true);
            }

            var types = new TypeDefinitionDict <bool>();

            foreach (var type in methodsTypes.getKeys())
            {
                if (checkAllMethodsUnused(unused, type))
                {
                    types.add(type, true);
                }
            }
            return(types);
        }
        public TypeDefinitionDict<bool> getInlinedTypes(IEnumerable<MethodDefinition> unusedMethods)
        {
            var unused = new MethodDefinitionAndDeclaringTypeDict<bool>();
            foreach (var method in unusedMethods)
                unused.add(method, true);

            var types = new TypeDefinitionDict<bool>();
            foreach (var type in methodsTypes.getKeys()) {
                if (checkAllMethodsUnused(unused, type))
                    types.add(type, true);
            }
            return types;
        }
Beispiel #4
0
        IEnumerable<FieldDefinition> getPossibleFields(TypeDefinition type)
        {
            var typeToFields = new TypeDefinitionDict<List<FieldDefinition>>();
            foreach (var field in type.Fields) {
                if (field.Attributes != FieldAttributes.Private)
                    continue;
                var fieldType = DotNetUtils.getType(module, field.FieldType);
                if (fieldType == null || !fieldType.IsValueType)
                    continue;
                var list = typeToFields.find(fieldType);
                if (list == null)
                    typeToFields.add(fieldType, list = new List<FieldDefinition>());
                list.Add(field);
            }

            foreach (var list in typeToFields.getValues()) {
                if (list.Count == 1)
                    yield return list[0];
            }
        }