Пример #1
0
        // Token: 0x06006150 RID: 24912 RVA: 0x0014C9AC File Offset: 0x0014ABAC
        private static void UpdateComTypesInAssembly(AssemblyBuilder asmBldr, ModuleBuilder modBldr)
        {
            AssemblyBuilderData assemblyData = asmBldr.m_assemblyData;

            Type[] types = modBldr.GetTypes();
            int    num   = types.Length;

            for (int i = 0; i < num; i++)
            {
                assemblyData.AddPublicComType(types[i]);
            }
        }
Пример #2
0
        private static void UpdateComTypesInAssembly(AssemblyBuilder asmBldr, ModuleBuilder modBldr)
        {
            AssemblyBuilderData assemblyBuilderData = asmBldr.m_assemblyData;

            Type[] types  = modBldr.GetTypes();
            int    length = types.Length;

            for (int index = 0; index < length; ++index)
            {
                assemblyBuilderData.AddPublicComType(types[index]);
            }
        }
Пример #3
0
        private static void UpdateComTypesInAssembly(AssemblyBuilder asmBldr, ModuleBuilder modBldr)
        {
            // Retrieve the AssemblyBuilderData associated with the assembly builder.
            AssemblyBuilderData AsmBldrData = asmBldr.m_assemblyData;

            // Go through the types in the module and add them as public COM types.
            Type[] aTypes   = modBldr.GetTypes();
            int    NumTypes = aTypes.Length;

            for (int cTypes = 0; cTypes < NumTypes; cTypes++)
            {
                AsmBldrData.AddPublicComType(aTypes[cTypes]);
            }
        }
Пример #4
0
        internal AssemblyBuilder(AppDomain domain,
                                 AssemblyName name,
                                 AssemblyBuilderAccess access,
                                 ref StackCrawlMark stackMark,
                                 IEnumerable <CustomAttributeBuilder> unsafeAssemblyAttributes)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (access != AssemblyBuilderAccess.Run && access != AssemblyBuilderAccess.RunAndCollect)
            {
                throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)access), nameof(access));
            }

            // Clone the name in case the caller modifies it underneath us.
            name = (AssemblyName)name.Clone();

            // Scan the assembly level attributes for any attributes which modify how we create the
            // assembly. Currently, we look for any attribute which modifies the security transparency
            // of the assembly.
            List <CustomAttributeBuilder> assemblyAttributes = null;

            if (unsafeAssemblyAttributes != null)
            {
                // Create a copy to ensure that it cannot be modified from another thread
                // as it is used further below.
                assemblyAttributes = new List <CustomAttributeBuilder>(unsafeAssemblyAttributes);
            }

            _internalAssemblyBuilder = (InternalAssemblyBuilder)nCreateDynamicAssembly(domain,
                                                                                       name,
                                                                                       ref stackMark,
                                                                                       access);

            _assemblyData = new AssemblyBuilderData(_internalAssemblyBuilder, access);

            // Make sure that ManifestModule is properly initialized
            // We need to do this before setting any CustomAttribute
            InitManifestModule();

            if (assemblyAttributes != null)
            {
                foreach (CustomAttributeBuilder assemblyAttribute in assemblyAttributes)
                {
                    SetCustomAttribute(assemblyAttribute);
                }
            }
        }
Пример #5
0
        internal virtual uint GetOneTimeFlags()
        {
            RuntimeMethodHandle methodHandle = this.MethodHandle;
            uint num           = 0;
            Type declaringType = this.DeclaringType;

            if ((this.ContainsGenericParameters || ((declaringType != null) && declaringType.ContainsGenericParameters)) || (((this.CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) || ((this.Attributes & MethodAttributes.RequireSecObject) == MethodAttributes.RequireSecObject)))
            {
                num |= 2;
            }
            else
            {
                AssemblyBuilderData assemblyData = this.Module.Assembly.m_assemblyData;
                if ((assemblyData != null) && ((assemblyData.m_access & AssemblyBuilderAccess.Run) == 0))
                {
                    num |= 2;
                }
            }
            if (num == 0)
            {
                num |= GetSpecialSecurityFlags(methodHandle);
                if ((num & 4) == 0)
                {
                    if (((this.Attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) || ((declaringType != null) && !declaringType.IsVisible))
                    {
                        num |= 4;
                    }
                    else if (this.IsGenericMethod)
                    {
                        Type[] genericArguments = this.GetGenericArguments();
                        for (int i = 0; i < genericArguments.Length; i++)
                        {
                            if (!genericArguments[i].IsVisible)
                            {
                                num |= 4;
                                break;
                            }
                        }
                    }
                }
            }
            num |= this.GetOneTimeSpecificFlags();
            return(num | 1);
        }
Пример #6
0
        private void GetOneTimeFlags()
        {
            Type declaringType = this.DeclaringType;
            uint num           = 0;

            if ((((declaringType != null) && declaringType.ContainsGenericParameters) || ((declaringType == null) && this.Module.Assembly.ReflectionOnly)) || (declaringType is ReflectionOnlyType))
            {
                num |= 2;
            }
            else
            {
                AssemblyBuilderData assemblyData = this.Module.Assembly.m_assemblyData;
                if ((assemblyData != null) && ((assemblyData.m_access & AssemblyBuilderAccess.Run) == 0))
                {
                    num |= 2;
                }
            }
            if (num == 0)
            {
                if ((this.m_fieldAttributes & FieldAttributes.InitOnly) != FieldAttributes.PrivateScope)
                {
                    num |= 0x10;
                }
                if ((this.m_fieldAttributes & FieldAttributes.HasFieldRVA) != FieldAttributes.PrivateScope)
                {
                    num |= 0x10;
                }
                if (((this.m_fieldAttributes & FieldAttributes.FieldAccessMask) != FieldAttributes.Public) || ((declaringType != null) && !declaringType.IsVisible))
                {
                    num |= 4;
                }
                Type fieldType = this.FieldType;
                if ((fieldType.IsPointer || fieldType.IsEnum) || fieldType.IsPrimitive)
                {
                    num |= 0x20;
                }
            }
            num |= 1;
            this.m_invocationFlags = num;
        }