Beispiel #1
0
        protected virtual MemberSetting MarkMember(MemberSetting parent, IMemberDefinition mem, Marking mark)
        {
            MemberSetting ret = new MemberSetting(mem);

            ApplyRules(mem, mark);
            return(ret);
        }
Beispiel #2
0
        private void MarkMember(MemberSetting parent, IMemberDefinition mem, Marking mark, List <MemberSetting> settings)
        {
            MemberSetting ret = MarkMember(parent, mem, mark);

            ret.Parameters = mark.CurrentConfusions;
            settings.Add(ret);
        }
Beispiel #3
0
        protected virtual MemberSetting MarkType(ModuleDefinition mod, TypeDefinition type, Marking mark)
        {
            MemberSetting ret = new MemberSetting(type);

            ApplyRules(type, mark);
            return(ret);
        }
Beispiel #4
0
        private void MarkType(ModuleDefinition mod, TypeDefinition type, Marking mark, List <MemberSetting> settings)
        {
            MemberSetting ret = MarkType(mod, type, mark);

            ret.Parameters = mark.CurrentConfusions;

            using (mark.Level())
            {
                List <MemberSetting>     memSettings = new List <MemberSetting>();
                TypeDefinition           typeDef     = ret.Object as TypeDefinition;
                List <IMemberDefinition> mems        = new List <IMemberDefinition>(typeDef.Methods.OfType <IMemberDefinition>().Concat(
                                                                                        typeDef.Fields.OfType <IMemberDefinition>()).Concat(
                                                                                        typeDef.Properties.OfType <IMemberDefinition>()).Concat(
                                                                                        typeDef.Events.OfType <IMemberDefinition>()));
                foreach (var i in mems)
                {
                    using (mark.Level())
                        MarkMember(ret, i, mark, memSettings);
                }

                foreach (var i in typeDef.NestedTypes)
                {
                    using (mark.Level())
                        MarkType(mod, i, mark, memSettings);
                }

                ret.Members = memSettings.ToArray();
            }
            settings.Add(ret);
        }
Beispiel #5
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();
        }
Beispiel #6
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();
        }