public override IList <IAttributeInstance> GetAttributeInstances(IClrTypeName clrName)
        {
            if (AttributeClassNames.IsEmpty())
            {
                return(EmptyList <IAttributeInstance> .Instance);
            }

            if (!(GetDeclaration()?.GetFSharpSymbol() is FSharpEntity entity))
            {
                return(EmptyList <IAttributeInstance> .Instance);
            }

            var psiModule   = GetPsiModule();
            var entityAttrs = entity.Attributes;

            if (entityAttrs.Count == 0)
            {
                return(EmptyList <IAttributeInstance> .Instance);
            }

            var result = new FrugalLocalList <IAttributeInstance>();

            foreach (var fcsAttribute in entityAttrs)
            {
                if (new ClrTypeName(fcsAttribute.AttributeType.QualifiedBaseName).Equals(clrName))
                {
                    result.Add(new FSharpAttributeInstance(fcsAttribute, psiModule));
                }
            }

            return(result.ResultingList());
        }
Exemple #2
0
        public override IList <IAttributeInstance> GetAttributeInstances(IClrTypeName clrName)
        {
            if (AttributeClassNames.IsEmpty())
            {
                return(EmptyList <IAttributeInstance> .Instance);
            }

            if (!((GetDeclaration() as IFSharpTypeDeclaration)?.GetFSharpSymbol() is FSharpEntity entity))
            {
                return(EmptyList <IAttributeInstance> .Instance);
            }

            var psiModule   = GetPsiModule();
            var entityAttrs = entity.Attributes;
            var attrs       = new IAttributeInstance[entityAttrs.Count];

            for (var i = 0; i < attrs.Length; i++)
            {
                attrs[i] = new FSharpAttributeInstance(entityAttrs[i], psiModule);
            }

            return(attrs);
        }