Beispiel #1
0
        private void AnalyzeAttributeIntroductions(TargetClassDefinition classDefinition)
        {
            var builder = new AttributeIntroductionDefinitionBuilder(classDefinition);

            var attributesOnMixins = from m in classDefinition.Mixins
                                     from a in m.CustomAttributes
                                     select a;
            var potentialSuppressors = classDefinition.CustomAttributes.Concat(attributesOnMixins);

            builder.AddPotentialSuppressors(potentialSuppressors);

            foreach (MixinDefinition mixin in classDefinition.Mixins)
            {
                builder.Apply(mixin);
            }
        }
Beispiel #2
0
        private void AnalyzeMemberAttributeIntroductions(TargetClassDefinition classDefinition)
        {
            // Check that SuppressAttributesAttribute cannot be applied to methods, properties, and fields.
            // As long as this holds, we don't need to deal with potential suppressors here.
            const AttributeTargets memberTargets = AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field;

            Assertion.IsTrue((AttributeUtility.GetAttributeUsage(typeof(SuppressAttributesAttribute)).ValidOn & memberTargets) == 0,
                             "TargetClassDefinitionBuilder must be updated with AddPotentialSuppressors once SuppressAttributesAttribute supports members");

            foreach (MemberDefinitionBase member in classDefinition.GetAllMembers())
            {
                if (member.Overrides.Count != 0)
                {
                    var introductionBuilder = new AttributeIntroductionDefinitionBuilder(member);
                    foreach (MemberDefinitionBase overrider in member.Overrides)
                    {
                        introductionBuilder.Apply(overrider);
                    }
                }
            }
        }