[System.Security.SecurityCritical] // auto-generated public void Bake(ModuleBuilder module, int token) { if (m_customBuilder == null) { TypeBuilder.DefineCustomAttribute(module, token, module.GetConstructorToken(m_con).Token, m_binaryAttribute, false, false); } else { m_customBuilder.CreateCustomAttribute(module, token); } }
private void SetCustomAttributeNoLock(ConstructorInfo con, byte[] binaryAttribute) { TypeBuilder.DefineCustomAttribute( m_manifestModuleBuilder, // pass in the in-memory assembly module AssemblyBuilderData.m_tkAssembly, // This is the AssemblyDef token m_manifestModuleBuilder.GetConstructorToken(con).Token, binaryAttribute, false, typeof(System.Diagnostics.DebuggableAttribute) == con.DeclaringType); // Track the CA for persistence if (m_assemblyData.m_access != AssemblyBuilderAccess.Run) { // tracking the CAs for persistence m_assemblyData.AddCustomAttribute(con, binaryAttribute); } }
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { if (con == null) { throw new ArgumentNullException(nameof(con)); } if (binaryAttribute == null) { throw new ArgumentNullException(nameof(binaryAttribute)); } ModuleBuilder module = m_typeBuilder.Module as ModuleBuilder; m_typeBuilder.ThrowIfCreated(); TypeBuilder.DefineCustomAttribute(module, m_tkField.Token, module.GetConstructorToken(con).Token, binaryAttribute, false, false); }
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { ModuleBuilder module = m_typeBuilder.Module as ModuleBuilder; m_typeBuilder.ThrowIfCreated(); if (con == null) { throw new ArgumentNullException("con"); } if (binaryAttribute == null) { throw new ArgumentNullException("binaryAttribute"); } TypeBuilder.InternalCreateCustomAttribute( m_tkField.Token, module.GetConstructorToken(con).Token, binaryAttribute, module, false); }
/// <summary> /// Use this function if client decides to form the custom attribute blob themselves. /// </summary> public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { if (con == null) { throw new ArgumentNullException(nameof(con)); } if (binaryAttribute == null) { throw new ArgumentNullException(nameof(binaryAttribute)); } lock (SyncRoot) { TypeBuilder.DefineCustomAttribute( _manifestModuleBuilder, // pass in the in-memory assembly module AssemblyBuilderData.AssemblyDefToken, _manifestModuleBuilder.GetConstructorToken(con), binaryAttribute); } }
private int GetMethodToken(MethodBase method, Type[] optionalParameterTypes, bool UseMethodDef) { int tkParent = 0; ModuleBuilder module = (ModuleBuilder)this.m_methodBuilder.Module; MethodInfo info = method as MethodInfo; if (method.IsGenericMethod) { int num2; MethodInfo genericMethodDefinition = info; bool isGenericMethodDefinition = info.IsGenericMethodDefinition; if (!isGenericMethodDefinition) { genericMethodDefinition = info.GetGenericMethodDefinition(); } if (!this.m_methodBuilder.Module.Equals(genericMethodDefinition.Module) || ((genericMethodDefinition.DeclaringType != null) && genericMethodDefinition.DeclaringType.IsGenericType)) { tkParent = this.GetMemberRefToken(genericMethodDefinition, null); } else { tkParent = module.GetMethodTokenInternal(genericMethodDefinition).Token; } if (isGenericMethodDefinition && UseMethodDef) { return(tkParent); } byte[] signature = SignatureHelper.GetMethodSpecSigHelper(module, info.GetGenericArguments()).InternalGetSignature(out num2); return(TypeBuilder.DefineMethodSpec(module.GetNativeHandle(), tkParent, signature, num2)); } if (((method.CallingConvention & CallingConventions.VarArgs) == 0) && ((method.DeclaringType == null) || !method.DeclaringType.IsGenericType)) { if (info != null) { return(module.GetMethodTokenInternal(info).Token); } return(module.GetConstructorToken(method as ConstructorInfo).Token); } return(this.GetMemberRefToken(method, optionalParameterTypes)); }
// return the byte interpretation of the custom attribute internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner) { CreateCustomAttribute(mod, tkOwner, mod.GetConstructorToken(m_con).Token, false); }
// return the byte interpretation of the custom attribute internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner) { CreateCustomAttribute(mod, tkOwner, mod.GetConstructorToken(m_con).Token, false); }
// return the byte interpretation of the custom attribute internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner) { TypeBuilder.DefineCustomAttribute(mod, tkOwner, mod.GetConstructorToken(m_con), m_blob); }