Boo.Lang.Compiler.Steps.CheckAttributesUsage.OnAttribute C# (CSharp) Метод

OnAttribute() публичный Метод

public OnAttribute ( Boo node ) : void
node Boo
Результат void
        public override void OnAttribute(Boo.Lang.Compiler.Ast.Attribute node)
        {
            Type attrType = AttributeType(node);
            if (attrType == null) return;

            // check allowed attribute usage(s)
            System.Attribute[] usages = System.Attribute.GetCustomAttributes(attrType, typeof(AttributeUsageAttribute));
            if (usages.Length == 0) return;

            //only one AttributeUsage is allowed anyway
            AttributeUsageAttribute usage = (AttributeUsageAttribute)usages[0];
            if (AttributeTargets.All != usage.ValidOn)
            {
                AttributeTargets? target = TargetFor(node);
                if (target.HasValue && !IsValid(usage, target.Value))
                {
                    Errors.Add(
                        CompilerErrorFactory.InvalidAttributeTarget(node, attrType, usage.ValidOn));
                }
            }
            if (!usage.AllowMultiple)
            {
                INodeWithAttributes m = node.ParentNode as INodeWithAttributes;
                foreach (Boo.Lang.Compiler.Ast.Attribute mAttr in m.Attributes)
                {
                    if (mAttr == node) continue;
                    IExternalEntity mAttrEnt = TypeSystemServices.GetOptionalEntity(mAttr) as IExternalEntity;
                    if (null != mAttrEnt && mAttrEnt.MemberInfo.DeclaringType == attrType)
                        Errors.Add(
                            CompilerErrorFactory.MultipleAttributeUsage(node, attrType));
                }
            }

            // handle special compiler-supported attributes
            //TODO: ObsoleteAttribute
        }