Exemple #1
0
        private void MarkModule(ModuleDefinition mod, Marking mark, List <ModuleSetting> settings)
        {
            bool          exclude;
            ModuleSetting ret = MarkModule(mod, mark, out exclude);

            ret.Parameters = mark.CurrentConfusions;

            if (!exclude)
            {
                List <MemberSetting> typeSettings = new List <MemberSetting>();
                foreach (TypeDefinition type in mod.Types)
                {
                    mark.StartLevel();
                    MarkType(type, mark, typeSettings);
                    mark.LeaveLevel();
                }
                ret.Members = typeSettings.ToArray();
            }

            settings.Add(ret);

            mark.LeaveLevel();
        }
Exemple #2
0
        private void MarkType(TypeDefinition type, Marking mark, List <MemberSetting> settings)
        {
            bool          exclude;
            MemberSetting ret = MarkType(type, mark, out exclude);

            ret.Parameters = mark.CurrentConfusions;

            if (!exclude)
            {
                List <MemberSetting> memSettings = new List <MemberSetting>();

                foreach (TypeDefinition nType in type.NestedTypes)
                {
                    mark.StartLevel();
                    MarkType(nType, mark, memSettings);
                    mark.LeaveLevel();
                }

                foreach (MethodDefinition mtd in type.Methods)
                {
                    mark.StartLevel();
                    MarkMember(mtd, mark, Target.Methods, memSettings);
                    mark.LeaveLevel();
                }

                foreach (FieldDefinition fld in type.Fields)
                {
                    mark.StartLevel();
                    MarkMember(fld, mark, Target.Fields, memSettings);
                    mark.LeaveLevel();
                }

                foreach (PropertyDefinition prop in type.Properties)
                {
                    mark.StartLevel();
                    MarkMember(prop, mark, Target.Properties, memSettings);
                    mark.LeaveLevel();
                }

                foreach (EventDefinition evt in type.Events)
                {
                    mark.StartLevel();
                    MarkMember(evt, mark, Target.Events, memSettings);
                    mark.LeaveLevel();
                }

                ret.Members = memSettings.ToArray();
            }

            if (!ret.Parameters.IsEmpty() || ret.Members.Length != 0)
            {
                settings.Add(ret);
            }

            mark.LeaveLevel();
        }
Exemple #3
0
        private AssemblySetting MarkAssembly(AssemblyDefinition asm, Marking mark)
        {
            bool            exclude;
            AssemblySetting ret = MarkAssembly(asm, mark, out exclude);

            ret.GlobalParameters = mark.CurrentConfusions;

            if (!exclude)
            {
                List <ModuleSetting> modSettings = new List <ModuleSetting>();
                foreach (ModuleDefinition mod in asm.Modules)
                {
                    MarkModule(mod, mark, modSettings);
                }
                ret.Modules = modSettings.ToArray();
            }

            mark.LeaveLevel();
            return(ret);
        }
Exemple #4
0
        private void MarkMember(IMemberDefinition mem, Marking mark, Target target, List <MemberSetting> settings)
        {
            if (target == Target.Methods && (mem as MethodDefinition).SemanticsAttributes != MethodSemanticsAttributes.None)
            {
                return;
            }

            bool          exclude;
            MemberSetting ret = MarkMember(mem, mark, out exclude);

            ret.Parameters = mark.CurrentConfusions;

            if (!exclude)
            {
                List <MemberSetting> semSettings = new List <MemberSetting>();
                if (target == Target.Properties)
                {
                    PropertyDefinition      prop = mem as PropertyDefinition;
                    List <MethodDefinition> sems = new List <MethodDefinition>();
                    if (prop.GetMethod != null)
                    {
                        sems.Add(prop.GetMethod);
                    }
                    if (prop.SetMethod != null)
                    {
                        sems.Add(prop.SetMethod);
                    }
                    if (prop.HasOtherMethods)
                    {
                        sems.AddRange(prop.OtherMethods);
                    }
                    foreach (MethodDefinition mtd in sems)
                    {
                        mark.StartLevel();
                        ProcessAttribute(mtd, mark);
                        semSettings.Add(new MemberSetting(mtd)
                        {
                            Parameters = mark.CurrentConfusions, Members = new MemberSetting[0]
                        });
                        mark.LeaveLevel();
                        mark.LeaveLevel();
                    }
                }
                else if (target == Target.Events)
                {
                    EventDefinition         evt  = mem as EventDefinition;
                    List <MethodDefinition> sems = new List <MethodDefinition>();
                    if (evt.AddMethod != null)
                    {
                        sems.Add(evt.AddMethod);
                    }
                    if (evt.RemoveMethod != null)
                    {
                        sems.Add(evt.RemoveMethod);
                    }
                    if (evt.InvokeMethod != null)
                    {
                        sems.Add(evt.InvokeMethod);
                    }
                    if (evt.HasOtherMethods)
                    {
                        sems.AddRange(evt.OtherMethods);
                    }
                    foreach (MethodDefinition mtd in sems)
                    {
                        mark.StartLevel();
                        ProcessAttribute(mtd, mark);
                        semSettings.Add(new MemberSetting(mtd)
                        {
                            Parameters = mark.CurrentConfusions, Members = new MemberSetting[0]
                        });
                        mark.LeaveLevel();
                        mark.LeaveLevel();
                    }
                }
                ret.Members = semSettings.ToArray();
            }

            if (!ret.Parameters.IsEmpty() || ret.Members.Length != 0)
            {
                settings.Add(ret);
            }

            mark.LeaveLevel();
        }