예제 #1
0
        private bool IsMemberWhiteListed(MemberReference member)
        {
            if (WhiteListCache != null)
            {
                if (WhiteListCache.Any(regex => regex.IsMatch(member.FullName)))
                {
                    return(true);
                }
            }

            MetadataCollection customAttributes = null;

            if (member is TypeReference)
            {
                var type = TypeInfoProvider.GetTypeInformation((TypeReference)member);
                if (type != null)
                {
                    customAttributes = type.Metadata;
                }
            }
            else if (member is MethodReference)
            {
                var method = TypeInfoProvider.GetMemberInformation <MethodInfo>(member);
                if (method != null)
                {
                    customAttributes = method.Metadata;
                }
            }
            else if (member is FieldReference)
            {
                var field = TypeInfoProvider.GetMemberInformation <FieldInfo>(member);
                if (field != null)
                {
                    customAttributes = field.Metadata;
                }
            }

            if (customAttributes != null && customAttributes.HasAttribute("JSIL.Meta.JSDeadCodeEleminationEntryPoint"))
            {
                return(true);
            }

            if (member.DeclaringType != null)
            {
                var declaringType = TypeInfoProvider.GetTypeInformation(member.DeclaringType);
                if (declaringType.Metadata.HasAttribute("JSIL.Meta.JSDeadCodeEleminationClassEntryPoint"))
                {
                    return(true);
                }

                while (declaringType != null)
                {
                    if (declaringType.Metadata.HasAttribute("JSIL.Meta.JSDeadCodeEleminationHierarchyEntryPoint"))
                    {
                        return(true);
                    }

                    declaringType = declaringType.BaseClass;
                }
            }

            return(false);
        }