[System.Security.SecurityCritical] // auto-generated private void Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, int iTypeSize, TypeBuilder enclosingType) { if (fullname == null) throw new ArgumentNullException("fullname"); if (fullname.Length == 0) throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "fullname"); if (fullname[0] == '\0') throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "fullname"); if (fullname.Length > 1023) throw new ArgumentException(Environment.GetResourceString("Argument_TypeNameTooLong"), "fullname"); Contract.EndContractBlock(); int i; m_module = module; m_DeclaringType = enclosingType; AssemblyBuilder containingAssem = m_module.ContainingAssemblyBuilder; // cannot have two types within the same assembly of the same name containingAssem.m_assemblyData.CheckTypeNameConflict(fullname, enclosingType); if (enclosingType != null) { // Nested Type should have nested attribute set. // If we are renumbering TypeAttributes' bit, we need to change the logic here. if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) ||((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic)) throw new ArgumentException(Environment.GetResourceString("Argument_BadNestedTypeFlags"), "attr"); } int[] interfaceTokens = null; if (interfaces != null) { for(i = 0; i < interfaces.Length; i++) { if (interfaces[i] == null) { // cannot contain null in the interface list throw new ArgumentNullException("interfaces"); } } interfaceTokens = new int[interfaces.Length + 1]; for(i = 0; i < interfaces.Length; i++) { interfaceTokens[i] = m_module.GetTypeTokenInternal(interfaces[i]).Token; } } int iLast = fullname.LastIndexOf('.'); if (iLast == -1 || iLast == 0) { // no name space m_strNameSpace = String.Empty; m_strName = fullname; } else { // split the name space m_strNameSpace = fullname.Substring(0, iLast); m_strName = fullname.Substring(iLast + 1); } VerifyTypeAttributes(attr); m_iAttr = attr; SetParent(parent); m_listMethods = new List<MethodBuilder>(); m_lastTokenizedMethod = -1; SetInterfaces(interfaces); int tkParent = 0; if (m_typeParent != null) tkParent = m_module.GetTypeTokenInternal(m_typeParent).Token; int tkEnclosingType = 0; if (enclosingType != null) { tkEnclosingType = enclosingType.m_tdType.Token; } m_tdType = new TypeToken(DefineType(m_module.GetNativeHandle(), fullname, tkParent, m_iAttr, tkEnclosingType, interfaceTokens)); m_iPackingSize = iPackingSize; m_iTypeSize = iTypeSize; if ((m_iPackingSize != 0) ||(m_iTypeSize != 0)) SetClassLayout(GetModuleBuilder().GetNativeHandle(), m_tdType.Token, m_iPackingSize, m_iTypeSize); #if !FEATURE_CORECLR // If the type is public and it is contained in a assemblyBuilder, // update the public COMType list. if (IsPublicComType(this)) { if (containingAssem.IsPersistable() && m_module.IsTransient() == false) { // This will throw InvalidOperationException if the assembly has been saved // Ideally we should reject all emit operations if the assembly has been saved, // but that would be a breaking change for some. Currently you cannot define // modules and public types, but you can still define private types and global methods. containingAssem.m_assemblyData.AddPublicComType(this); } // Now add the type to the ExportedType table if (!m_module.Equals(containingAssem.ManifestModule)) containingAssem.DefineExportedTypeInMemory(this, m_module.m_moduleData.FileToken, m_tdType.Token); } #endif m_module.AddType(FullName, this); }