Esempio n. 1
0
 internal static void SetMarshalAsAttribute(ModuleBuilder module, int token, CustomAttributeBuilder attribute)
 {
     attribute = attribute.DecodeBlob(module.Assembly);
     FieldMarshalTable.Record rec = new FieldMarshalTable.Record();
     rec.Parent     = token;
     rec.NativeType = WriteMarshallingDescriptor(module, attribute);
     module.FieldMarshal.AddRecord(rec);
 }
Esempio n. 2
0
        internal void SetAttribute(AssemblyBuilder asm, CustomAttributeBuilder cab)
        {
            Universe u    = cab.Constructor.Module.universe;
            Type     type = cab.Constructor.DeclaringType;

            if (copyright == null && type == u.System_Reflection_AssemblyCopyrightAttribute)
            {
                copyright = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
            else if (trademark == null && type == u.System_Reflection_AssemblyTrademarkAttribute)
            {
                trademark = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
            else if (product == null && type == u.System_Reflection_AssemblyProductAttribute)
            {
                product = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
            else if (company == null && type == u.System_Reflection_AssemblyCompanyAttribute)
            {
                company = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
            else if (description == null && type == u.System_Reflection_AssemblyDescriptionAttribute)
            {
                description = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
            else if (title == null && type == u.System_Reflection_AssemblyTitleAttribute)
            {
                title = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
            else if (informationalVersion == null && type == u.System_Reflection_AssemblyInformationalVersionAttribute)
            {
                informationalVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
            else if (fileVersion == null && type == u.System_Reflection_AssemblyFileVersionAttribute)
            {
                fileVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
            }
        }
Esempio n. 3
0
		internal void SetAttribute(AssemblyBuilder asm, CustomAttributeBuilder cab)
		{
			Universe u = cab.Constructor.Module.universe;
			Type type = cab.Constructor.DeclaringType;
			if (copyright == null && type == u.System_Reflection_AssemblyCopyrightAttribute)
			{
				copyright = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
			else if (trademark == null && type == u.System_Reflection_AssemblyTrademarkAttribute)
			{
				trademark = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
			else if (product == null && type == u.System_Reflection_AssemblyProductAttribute)
			{
				product = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
			else if (company == null && type == u.System_Reflection_AssemblyCompanyAttribute)
			{
				company = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
			else if (description == null && type == u.System_Reflection_AssemblyDescriptionAttribute)
			{
				description = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
			else if (title == null && type == u.System_Reflection_AssemblyTitleAttribute)
			{
				title = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
			else if (informationalVersion == null && type == u.System_Reflection_AssemblyInformationalVersionAttribute)
			{
				informationalVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
			else if (fileVersion == null && type == u.System_Reflection_AssemblyFileVersionAttribute)
			{
				fileVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
			}
		}
Esempio n. 4
0
		public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
		{
			Universe u = this.ModuleBuilder.universe;
			Type type = customBuilder.Constructor.DeclaringType;
			if (type == u.System_Runtime_InteropServices_StructLayoutAttribute)
			{
				SetStructLayoutPseudoCustomAttribute(customBuilder.DecodeBlob(this.Assembly));
			}
			else if (type == u.System_SerializableAttribute)
			{
				attribs |= TypeAttributes.Serializable;
			}
			else if (type == u.System_Runtime_InteropServices_ComImportAttribute)
			{
				attribs |= TypeAttributes.Import;
			}
			else if (type == u.System_Runtime_CompilerServices_SpecialNameAttribute)
			{
				attribs |= TypeAttributes.SpecialName;
			}
			else
			{
				if (type == u.System_Security_SuppressUnmanagedCodeSecurityAttribute)
				{
					attribs |= TypeAttributes.HasSecurity;
				}
				this.ModuleBuilder.SetCustomAttribute(token, customBuilder);
			}
		}
		internal static void SetMarshalAsAttribute(ModuleBuilder module, int token, CustomAttributeBuilder attribute)
		{
			attribute = attribute.DecodeBlob(module.Assembly);
			FieldMarshalTable.Record rec = new FieldMarshalTable.Record();
			rec.Parent = token;
			rec.NativeType = WriteMarshallingDescriptor(module, attribute);
			module.FieldMarshal.AddRecord(rec);
		}
Esempio n. 6
0
		public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
		{
			Universe u = this.ModuleBuilder.universe;
			Type type = customBuilder.Constructor.DeclaringType;
			if (type == u.System_Runtime_InteropServices_DllImportAttribute)
			{
				attributes |= MethodAttributes.PinvokeImpl;
				SetDllImportPseudoCustomAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
			}
			else if (type == u.System_Runtime_CompilerServices_MethodImplAttribute)
			{
				SetMethodImplAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
			}
			else if (type == u.System_Runtime_InteropServices_PreserveSigAttribute)
			{
				implFlags |= MethodImplAttributes.PreserveSig;
			}
			else if (type == u.System_Runtime_CompilerServices_SpecialNameAttribute)
			{
				attributes |= MethodAttributes.SpecialName;
			}
			else
			{
				if (type == u.System_Security_SuppressUnmanagedCodeSecurityAttribute)
				{
					attributes |= MethodAttributes.HasSecurity;
				}
				this.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
			}
		}
		public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
		{
			Universe u = this.Module.universe;
			if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_FieldOffsetAttribute)
			{
				customBuilder = customBuilder.DecodeBlob(this.Module.Assembly);
				SetOffset((int)customBuilder.GetConstructorArgument(0));
			}
			else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute)
			{
				MarshalSpec.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder);
				attribs |= FieldAttributes.HasFieldMarshal;
			}
			else if (customBuilder.Constructor.DeclaringType == u.System_NonSerializedAttribute)
			{
				attribs |= FieldAttributes.NotSerialized;
			}
			else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
			{
				attribs |= FieldAttributes.SpecialName;
			}
			else
			{
				typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
			}
		}
		public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
		{
			switch (customBuilder.KnownCA)
			{
				case KnownCA.FieldOffsetAttribute:
					SetOffset((int)customBuilder.DecodeBlob(this.Module.Assembly).GetConstructorArgument(0));
					break;
				case KnownCA.MarshalAsAttribute:
					FieldMarshal.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder);
					attribs |= FieldAttributes.HasFieldMarshal;
					break;
				case KnownCA.NonSerializedAttribute:
					attribs |= FieldAttributes.NotSerialized;
					break;
				case KnownCA.SpecialNameAttribute:
					attribs |= FieldAttributes.SpecialName;
					break;
				default:
					typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
					break;
			}
		}
		public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
		{
			switch (customBuilder.KnownCA)
			{
				case KnownCA.DllImportAttribute:
					SetDllImportPseudoCustomAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
					attributes |= MethodAttributes.PinvokeImpl;
					break;
				case KnownCA.MethodImplAttribute:
					SetMethodImplAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
					break;
				case KnownCA.PreserveSigAttribute:
					implFlags |= MethodImplAttributes.PreserveSig;
					break;
				case KnownCA.SpecialNameAttribute:
					attributes |= MethodAttributes.SpecialName;
					break;
				case KnownCA.SuppressUnmanagedCodeSecurityAttribute:
					attributes |= MethodAttributes.HasSecurity;
					goto default;
				default:
					this.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
					break;
			}
		}
		public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
		{
			switch (customBuilder.KnownCA)
			{
				case KnownCA.StructLayoutAttribute:
					SetStructLayoutPseudoCustomAttribute(customBuilder.DecodeBlob(this.Assembly));
					break;
				case KnownCA.SerializableAttribute:
					attribs |= TypeAttributes.Serializable;
					break;
				case KnownCA.ComImportAttribute:
					attribs |= TypeAttributes.Import;
					break;
				case KnownCA.SpecialNameAttribute:
					attribs |= TypeAttributes.SpecialName;
					break;
				case KnownCA.SuppressUnmanagedCodeSecurityAttribute:
					attribs |= TypeAttributes.HasSecurity;
					goto default;
				default:
					this.ModuleBuilder.SetCustomAttribute(token, customBuilder);
					break;
			}
		}