internal static TypeForwardedToAttribute[] GetCustomAttribute(RuntimeAssembly assembly)
 {
     Type[] o = null;
     RuntimeAssembly.GetForwardedTypes(assembly.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack<Type[]>(ref o));
     TypeForwardedToAttribute[] attributeArray = new TypeForwardedToAttribute[o.Length];
     for (int i = 0; i < o.Length; i++)
     {
         attributeArray[i] = new TypeForwardedToAttribute(o[i]);
     }
     return attributeArray;
 }
        internal static TypeForwardedToAttribute[] GetCustomAttribute(RuntimeAssembly assembly)
        {
            Type[] types = null;
            RuntimeAssembly.GetForwardedTypes(assembly.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref types));

            TypeForwardedToAttribute[] attributes = new TypeForwardedToAttribute[types.Length];
            for (int i = 0; i < types.Length; ++i)
                attributes[i] = new TypeForwardedToAttribute(types[i]);

            return attributes;
        }
예제 #3
0
        internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
        {
            int count = 0;

            Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(assembly, caType, true, out count);
            int         token             = RuntimeAssembly.GetToken(assembly.GetNativeHandle());
            bool        isDecoratedTargetSecurityTransparent = assembly.IsAllSecurityTransparent();

            object[] customAttributes2 = CustomAttribute.GetCustomAttributes(assembly.ManifestModule as RuntimeModule, token, count, caType, isDecoratedTargetSecurityTransparent);
            if (count > 0)
            {
                Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count);
            }
            return(customAttributes2);
        }
예제 #4
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target)
        {
            Contract.Assert(target != null);

            IList<CustomAttributeData> cad = GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));

            int pcaCount = 0;
            Attribute[] a = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, false, out pcaCount);

            if (pcaCount == 0)
                return cad;

            CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount];
            cad.CopyTo(pca, pcaCount);
            for (int i = 0; i < pcaCount; i++)
            {
                pca[i] = new CustomAttributeData(a[i]);
            }

            return Array.AsReadOnly(pca);
        }
예제 #5
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 
        {
            Contract.Requires(assembly != null);
            Contract.Requires(caType != null);

            int pcaCount = 0;
            Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(assembly, caType, true, out pcaCount);
            int assemblyToken = RuntimeAssembly.GetToken(assembly.GetNativeHandle());
            bool isAssemblySecurityTransparent = assembly.IsAllSecurityTransparent();
            object[] attributes = GetCustomAttributes(assembly.ManifestModule as RuntimeModule, assemblyToken, pcaCount, caType, isAssemblySecurityTransparent);
            if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount);
            return attributes;
        }
예제 #6
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType) 
        {
            Contract.Requires(assembly != null);
            Contract.Requires(caType != null);

            if (PseudoCustomAttribute.IsDefined(assembly, caType))
                return true;

            return IsCustomAttributeDefined(assembly.ManifestModule as RuntimeModule, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType);
        }
예제 #7
0
        internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target)
        {
            IList <CustomAttributeData> customAttributes = CustomAttributeData.GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
            int num = 0;

            Attribute[] customAttributes2 = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, false, out num);
            if (num == 0)
            {
                return(customAttributes);
            }
            CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + num];
            customAttributes.CopyTo(array, num);
            for (int i = 0; i < num; i++)
            {
                array[i] = new CustomAttributeData(customAttributes2[i]);
            }
            return(Array.AsReadOnly <CustomAttributeData>(array));
        }
 internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
 {
     return (PseudoCustomAttribute.IsDefined(assembly, caType) || IsCustomAttributeDefined(assembly.ManifestModule as RuntimeModule, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType));
 }
예제 #9
0
        internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target)
        {
            IList <CustomAttributeData> customAttributes1 = CustomAttributeData.GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
            int count = 0;

            Attribute[] customAttributes2 = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, false, out count);
            if (count == 0)
            {
                return(customAttributes1);
            }
            CustomAttributeData[] array = new CustomAttributeData[customAttributes1.Count + count];
            customAttributes1.CopyTo(array, count);
            for (int index = 0; index < count; ++index)
            {
                array[index] = new CustomAttributeData(customAttributes2[index]);
            }
            return((IList <CustomAttributeData>)Array.AsReadOnly <CustomAttributeData>(array));
        }
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType) 
        {
            Contract.Requires(assembly != null);
            Contract.Requires(caType != null);

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && caType != null)
            {
                FrameworkEventSource.Log.QueryAttributeIsDefined(caType.GetFullNameForEtw());
            }
#endif

            if (PseudoCustomAttribute.IsDefined(assembly, caType))
                return true;

            return IsCustomAttributeDefined(assembly.ManifestModule as RuntimeModule, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType);
        }
예제 #11
0
 internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
 {
     if (PseudoCustomAttribute.IsDefined(assembly, caType))
     {
         return(true);
     }
     return(CustomAttribute.IsCustomAttributeDefined(assembly.ManifestModule as RuntimeModule, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType));
 }
예제 #12
0
        internal static Attribute[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType, bool includeSecCa, out int count)
        {
            count = 0;
            bool flag = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);

            if (!flag && PseudoCustomAttribute.s_pca.GetValueOrDefault(caType) == null && !PseudoCustomAttribute.IsSecurityAttribute(caType))
            {
                return(new Attribute[0]);
            }
            List <Attribute> list = new List <Attribute>();

            if (includeSecCa && (flag || PseudoCustomAttribute.IsSecurityAttribute(caType)))
            {
                object[] array;
                PseudoCustomAttribute.GetSecurityAttributes(assembly.ManifestModule.ModuleHandle.GetRuntimeModule(), RuntimeAssembly.GetToken(assembly.GetNativeHandle()), true, out array);
                if (array != null)
                {
                    foreach (object obj in array)
                    {
                        if (caType == obj.GetType() || obj.GetType().IsSubclassOf(caType))
                        {
                            list.Add((Attribute)obj);
                        }
                    }
                }
            }
            count = list.Count;
            return(list.ToArray());
        }
 internal static Attribute[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType, bool includeSecCa, out int count)
 {
     count = 0;
     bool flag = (caType == ((RuntimeType) typeof(object))) || (caType == ((RuntimeType) typeof(Attribute)));
     if ((!flag && (s_pca.GetValueOrDefault(caType) == null)) && !IsSecurityAttribute(caType))
     {
         return new Attribute[0];
     }
     List<Attribute> list = new List<Attribute>();
     if (includeSecCa && (flag || IsSecurityAttribute(caType)))
     {
         object[] objArray;
         GetSecurityAttributes(assembly.ManifestModule.ModuleHandle.GetRuntimeModule(), RuntimeAssembly.GetToken(assembly.GetNativeHandle()), true, out objArray);
         if (objArray != null)
         {
             foreach (object obj2 in objArray)
             {
                 if ((caType == obj2.GetType()) || obj2.GetType().IsSubclassOf(caType))
                 {
                     list.Add((Attribute) obj2);
                 }
             }
         }
     }
     count = list.Count;
     return list.ToArray();
 }
예제 #14
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static Attribute[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType, bool includeSecCa, out int count)
        {
            count = 0;

            bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);

            if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
                return new Attribute[0];

            List<Attribute> pcas = new List<Attribute>();
            if (includeSecCa && (all || IsSecurityAttribute(caType)))
            {
                object[] securityAttributes;

                GetSecurityAttributes(assembly.ManifestModule.ModuleHandle.GetRuntimeModule(), RuntimeAssembly.GetToken(assembly.GetNativeHandle()), true, out securityAttributes);
                if (securityAttributes != null)
                    foreach (object a in securityAttributes)
                        if (caType == a.GetType() || a.GetType().IsSubclassOf(caType))
                            pcas.Add((Attribute)a);
            }

            //TypeForwardedToAttribute.GetCustomAttribute(assembly) throws FileNotFoundException if the forwarded-to
            //assemblies are not present. This breaks many V4 scenarios because some framework types are forwarded 
            //to assemblies not included in the client SKU. Let's omit TypeForwardedTo for now until we have a better solution.

            //if (all || caType == (RuntimeType)typeof(TypeForwardedToAttribute))
            //{
            //    TypeForwardedToAttribute[] attrs = TypeForwardedToAttribute.GetCustomAttribute(assembly);
            //    pcas.AddRange(attrs);
            //}

            count = pcas.Count;
            return pcas.ToArray();
        }
예제 #15
0
        [System.Security.SecurityCritical]  // auto-generated
        private static Module DefineDynamicModule(RuntimeAssembly containingAssembly, 
                                           bool emitSymbolInfo,
                                           String name,
                                           String filename,
                                           ref StackCrawlMark stackMark,
                                           ref IntPtr pInternalSymWriter,
                                           bool fIsTransient,
                                           out int tkFile)
        {
            RuntimeModule retModule = null;

            DefineDynamicModule(containingAssembly.GetNativeHandle(),
                                emitSymbolInfo,
                                name,
                                filename,
                                JitHelpers.GetStackCrawlMarkHandle(ref stackMark),
                                ref pInternalSymWriter,
                                JitHelpers.GetObjectHandleOnStack(ref retModule),
                                fIsTransient,
                                out tkFile);

            return retModule;
        }
 internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target)
 {
     IList<CustomAttributeData> customAttributes = GetCustomAttributes((RuntimeModule) target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
     int count = 0;
     Attribute[] attributeArray = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, false, out count);
     if (count == 0)
     {
         return customAttributes;
     }
     CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + count];
     customAttributes.CopyTo(array, count);
     for (int i = 0; i < count; i++)
     {
         array[i] = new CustomAttributeData(attributeArray[i]);
     }
     return Array.AsReadOnly<CustomAttributeData>(array);
 }
 internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
 {
     int count = 0;
     Attribute[] sourceArray = PseudoCustomAttribute.GetCustomAttributes(assembly, caType, true, out count);
     int token = RuntimeAssembly.GetToken(assembly.GetNativeHandle());
     bool isDecoratedTargetSecurityTransparent = assembly.IsAllSecurityTransparent();
     object[] destinationArray = GetCustomAttributes(assembly.ManifestModule as RuntimeModule, token, count, caType, isDecoratedTargetSecurityTransparent);
     if (count > 0)
     {
         Array.Copy(sourceArray, 0, destinationArray, destinationArray.Length - count, count);
     }
     return destinationArray;
 }