We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace System.Reflection.Emit
- {
-
- using System;
- using System.Runtime.Remoting.Activation;
- using System.Reflection;
- using System.Security;
- using System.Security.Permissions;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Runtime.CompilerServices;
- using ArrayList = System.Collections.ArrayList;
- using CultureInfo = System.Globalization.CultureInfo;
- using System.Threading;
-
-
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum PackingSize
- {
- Unspecified = 0,
- Size1 = 1,
- Size2 = 2,
- Size4 = 4,
- Size8 = 8,
- Size16 = 16,
- Size32 = 32,
- Size64 = 64,
- Size128 = 128
- }
-
-
- [HostProtection(MayLeakOnAbort = true)]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_TypeBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class TypeBuilder : Type, _TypeBuilder
- {
- #region Declarations
- internal class CustAttr
- {
- private ConstructorInfo m_con;
- private byte[] m_binaryAttribute;
- private CustomAttributeBuilder m_customBuilder;
-
- public CustAttr(ConstructorInfo con, byte[] binaryAttribute)
- {
- if (con == null)
- throw new ArgumentNullException("con");
-
- if (binaryAttribute == null)
- throw new ArgumentNullException("binaryAttribute");
-
- m_con = con;
- m_binaryAttribute = binaryAttribute;
- }
-
- public CustAttr(CustomAttributeBuilder customBuilder)
- {
- if (customBuilder == null)
- throw new ArgumentNullException("customBuilder");
-
- m_customBuilder = customBuilder;
- }
-
- public void Bake(ModuleBuilder module, int token)
- {
- if (m_customBuilder == null) {
- TypeBuilder.InternalCreateCustomAttribute(token, module.GetConstructorToken(m_con).Token, m_binaryAttribute, module, false);
- }
- else {
- m_customBuilder.CreateCustomAttribute(module, token);
- }
- }
- }
- #endregion
-
- #region Public Static Methods
- public static MethodInfo GetMethod(Type type, MethodInfo method)
- {
- if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
-
-
-
-
-
-
-
-
- if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedGenericMethodDefinition"), "method");
-
- if (method.DeclaringType == null || !method.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_MethodNeedGenericDeclaringType"), "method");
-
- if (type.GetGenericTypeDefinition() != method.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidMethodDeclaringType"), "type");
-
-
-
-
- if (type.IsGenericTypeDefinition)
- type = type.MakeGenericType(type.GetGenericArguments());
-
- if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), "type");
-
- return MethodOnTypeBuilderInstantiation.GetMethod(method, type as TypeBuilderInstantiation);
- }
- public static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor)
- {
- if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
-
- if (!constructor.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstructorNeedGenericDeclaringType"), "constructor");
-
- if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), "type");
-
-
- if (type is TypeBuilder && type.IsGenericTypeDefinition)
- type = type.MakeGenericType(type.GetGenericArguments());
-
- if (type.GetGenericTypeDefinition() != constructor.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorDeclaringType"), "type");
-
- return ConstructorOnTypeBuilderInstantiation.GetConstructor(constructor, type as TypeBuilderInstantiation);
- }
- public static FieldInfo GetField(Type type, FieldInfo field)
- {
- if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
-
- if (!field.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_FieldNeedGenericDeclaringType"), "field");
-
- if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), "type");
-
-
- if (type is TypeBuilder && type.IsGenericTypeDefinition)
- type = type.MakeGenericType(type.GetGenericArguments());
-
- if (type.GetGenericTypeDefinition() != field.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldDeclaringType"), "type");
-
- return FieldOnTypeBuilderInstantiation.GetField(field, type as TypeBuilderInstantiation);
- }
- #endregion
-
- #region Public Const
- public const int UnspecifiedTypeSize = 0;
- #endregion
-
- #region Private Static FCalls
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void InternalSetParentType(int tdTypeDef, int tkParent, Module module);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void InternalAddInterfaceImpl(int tdTypeDef, int tkInterface, Module module);
- #endregion
-
- #region Internal Static FCalls
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern int InternalDefineMethod(int handle, string name, byte[] signature, int sigLength, MethodAttributes attributes, Module module);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern int InternalDefineMethodSpec(int handle, byte[] signature, int sigLength, Module module);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern int InternalDefineField(int handle, string name, byte[] signature, int sigLength, FieldAttributes attributes, Module module);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalSetMethodIL(int methodHandle, bool isInitLocals, byte[] body, byte[] LocalSig, int sigLength, int maxStackSize, int numExceptions, __ExceptionInstance[] exceptions, int[] tokenFixups, int[] rvaFixups,
- Module module);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalCreateCustomAttribute(int tkAssociate, int tkConstructor, byte[] attr, Module module, bool toDisk, bool updateCompilerFlags);
-
- static internal void InternalCreateCustomAttribute(int tkAssociate, int tkConstructor, byte[] attr, Module module, bool toDisk)
- {
- byte[] localAttr = null;
-
- if (attr != null) {
- localAttr = new byte[attr.Length];
- Array.Copy(attr, localAttr, attr.Length);
- }
- TypeBuilder.InternalCreateCustomAttribute(tkAssociate, tkConstructor, localAttr, module, toDisk, false);
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalSetPInvokeData(Module module, string DllName, string name, int token, int linkType, int linkFlags);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern int InternalDefineProperty(Module module, int handle, string name, int attributes, byte[] signature, int sigLength, int notifyChanging, int notifyChanged);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern int InternalDefineEvent(Module module, int handle, string name, int attributes, int tkEventType);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalDefineMethodSemantics(Module module, int tkAssociation, MethodSemanticsAttributes semantics, int tkMethod);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalDefineMethodImpl(ModuleBuilder module, int tkType, int tkBody, int tkDecl);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalSetMethodImpl(Module module, int tkMethod, MethodImplAttributes MethodImplAttributes);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern int InternalSetParamInfo(Module module, int tkMethod, int iSequence, ParameterAttributes iParamAttributes, string strParamName);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern int InternalGetTokenFromSig(Module module, byte[] signature, int sigLength);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalSetFieldOffset(Module module, int fdToken, int iOffset);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalSetClassLayout(Module module, int tdToken, PackingSize iPackingSize, int iTypeSize);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalSetMarshalInfo(Module module, int tk, byte[] ubMarshal, int ubSize);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalSetConstantValue(Module module, int tk, ref Variant var);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern void InternalAddDeclarativeSecurity(Module module, int parent, SecurityAction action, byte[] blob);
- #endregion
-
- #region Internal\Private Static Members
- private static bool IsPublicComType(Type type)
- {
-
-
-
-
-
- Type enclosingType = type.DeclaringType;
- if (enclosingType != null) {
- if (IsPublicComType(enclosingType)) {
- if ((type.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic) {
- return true;
- }
- }
- }
- else {
- if ((type.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) {
- return true;
- }
- }
-
- return false;
- }
-
- static internal bool IsTypeEqual(Type t1, Type t2)
- {
-
- if (t1 == t2)
- return true;
- TypeBuilder tb1 = null;
- TypeBuilder tb2 = null;
- Type runtimeType1 = null;
- Type runtimeType2 = null;
-
-
- if (t1 is TypeBuilder) {
- tb1 = (TypeBuilder)t1;
-
- runtimeType1 = tb1.m_runtimeType;
- }
- else {
- runtimeType1 = t1;
- }
-
- if (t2 is TypeBuilder) {
- tb2 = (TypeBuilder)t2;
-
- runtimeType2 = tb2.m_runtimeType;
- }
- else {
- runtimeType2 = t2;
- }
-
-
- if (tb1 != null && tb2 != null && tb1 == tb2)
- return true;
-
-
- if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2)
- return true;
-
- return false;
- }
-
- static internal void SetConstantValue(Module module, int tk, Type destType, object value)
- {
-
-
-
- if (value == null) {
- if (destType.IsValueType)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNull"));
- }
- else {
-
- Type type = value.GetType();
-
-
- if (destType.IsEnum == false) {
- if (destType != type)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
-
- switch (Type.GetTypeCode(type)) {
- case TypeCode.Boolean:
- case TypeCode.Char:
- case TypeCode.SByte:
- case TypeCode.Byte:
- case TypeCode.Int16:
- case TypeCode.UInt16:
- case TypeCode.Int32:
- case TypeCode.UInt32:
- case TypeCode.Int64:
- case TypeCode.UInt64:
- case TypeCode.Single:
- case TypeCode.Double:
- case TypeCode.Decimal:
- case TypeCode.String:
- break;
- default:
-
- {
- if (type != typeof(System.DateTime))
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNotSupported"));
- break;
- }
- break;
-
- }
- }
- else {
-
- if (destType.UnderlyingSystemType != type)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
- }
- }
-
-
- Variant var = new Variant(value);
-
- InternalSetConstantValue(module, tk, ref var);
- }
-
- #endregion
-
- #region Private Data Members
- internal ArrayList m_ca;
- internal MethodBuilder m_currentMethod;
- private TypeToken m_tdType;
- private ModuleBuilder m_module;
- internal string m_strName;
- private string m_strNameSpace;
- private string m_strFullQualName;
- private Type m_typeParent;
- private Type[] m_typeInterfaces;
- internal TypeAttributes m_iAttr;
- internal GenericParameterAttributes m_genParamAttributes;
- internal ArrayList m_listMethods;
- private int m_constructorCount;
- private int m_iTypeSize;
- private PackingSize m_iPackingSize;
- private TypeBuilder m_DeclaringType;
- private Type m_underlyingSystemType;
-
- internal bool m_isHiddenGlobalType;
- internal bool m_isHiddenType;
- internal bool m_hasBeenCreated;
- internal RuntimeType m_runtimeType;
-
- private int m_genParamPos;
- private GenericTypeParameterBuilder[] m_inst;
- private bool m_bIsGenParam;
- private bool m_bIsGenTypeDef;
- private MethodBuilder m_declMeth;
- private TypeBuilder m_genTypeDef;
- #endregion
-
- #region Constructor
- private TypeBuilder(TypeBuilder genTypeDef, GenericTypeParameterBuilder[] inst)
- {
- m_genTypeDef = genTypeDef;
- m_DeclaringType = genTypeDef.m_DeclaringType;
- m_typeParent = genTypeDef.m_typeParent;
- m_runtimeType = genTypeDef.m_runtimeType;
- m_tdType = genTypeDef.m_tdType;
- m_strName = genTypeDef.m_strName;
- m_bIsGenParam = false;
- m_bIsGenTypeDef = false;
- m_module = genTypeDef.m_module;
- m_inst = inst;
- m_hasBeenCreated = true;
- }
-
- internal TypeBuilder(string szName, int genParamPos, MethodBuilder declMeth)
- {
- m_declMeth = declMeth;
- m_DeclaringType = (TypeBuilder)m_declMeth.DeclaringType;
- m_module = (ModuleBuilder)declMeth.Module;
- InitAsGenericParam(szName, genParamPos);
- }
-
- private TypeBuilder(string szName, int genParamPos, TypeBuilder declType)
- {
- m_DeclaringType = declType;
- m_module = (ModuleBuilder)declType.Module;
- InitAsGenericParam(szName, genParamPos);
- }
-
- private void InitAsGenericParam(string szName, int genParamPos)
- {
- m_strName = szName;
- m_genParamPos = genParamPos;
- m_bIsGenParam = true;
- m_bIsGenTypeDef = false;
- m_typeInterfaces = new Type[0];
- }
-
- internal TypeBuilder(string name, TypeAttributes attr, Type parent, Module module, PackingSize iPackingSize, int iTypeSize, TypeBuilder enclosingType)
- {
- Init(name, attr, parent, null, module, iPackingSize, iTypeSize, enclosingType);
- }
-
- internal TypeBuilder(string name, TypeAttributes attr, Type parent, Type[] interfaces, Module module, PackingSize iPackingSize, TypeBuilder enclosingType)
- {
- Init(name, attr, parent, interfaces, module, iPackingSize, UnspecifiedTypeSize, enclosingType);
- }
-
- internal TypeBuilder(ModuleBuilder module)
- {
- m_tdType = new TypeToken(SignatureHelper.mdtTypeDef);
- m_isHiddenGlobalType = true;
- m_module = (ModuleBuilder)module;
- m_listMethods = new ArrayList();
- }
-
- private void Init(string fullname, TypeAttributes attr, Type parent, Type[] interfaces, Module module, PackingSize iPackingSize, int iTypeSize, TypeBuilder enclosingType)
- {
- int i;
- int[] interfaceTokens;
- m_bIsGenTypeDef = false;
- interfaceTokens = null;
- m_bIsGenParam = false;
- m_hasBeenCreated = false;
- m_runtimeType = null;
- m_isHiddenGlobalType = false;
- m_isHiddenType = false;
- m_module = (ModuleBuilder)module;
- m_DeclaringType = enclosingType;
- Assembly containingAssem = m_module.Assembly;
- m_underlyingSystemType = null;
-
- 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");
-
-
- containingAssem.m_assemblyData.CheckTypeNameConflict(fullname, enclosingType);
-
- if (enclosingType != null) {
-
-
- if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) || ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadNestedTypeFlags"), "attr");
- }
-
- if (interfaces != null) {
- for (i = 0; i < interfaces.Length; i++) {
- if (interfaces[i] == null) {
-
- throw new ArgumentNullException("interfaces");
- }
- }
- interfaceTokens = new int[interfaces.Length];
- for (i = 0; i < interfaces.Length; i++) {
- interfaceTokens[i] = m_module.GetTypeToken(interfaces[i]).Token;
- }
- }
-
- int iLast = fullname.LastIndexOf('.');
- if (iLast == -1 || iLast == 0) {
-
- m_strNameSpace = String.Empty;
- m_strName = fullname;
- }
- else {
-
- m_strNameSpace = fullname.Substring(0, iLast);
- m_strName = fullname.Substring(iLast + 1);
- }
-
- VerifyTypeAttributes(attr);
-
- m_iAttr = attr;
-
- SetParent(parent);
-
- m_listMethods = new ArrayList();
-
- SetInterfaces(interfaces);
-
- m_constructorCount = 0;
-
- int tkParent = 0;
- if (m_typeParent != null)
- tkParent = m_module.GetTypeToken(m_typeParent).Token;
-
- int tkEnclosingType = 0;
- if (enclosingType != null) {
- tkEnclosingType = enclosingType.m_tdType.Token;
- }
-
- m_tdType = new TypeToken(InternalDefineClass(fullname, tkParent, interfaceTokens, m_iAttr, m_module, Guid.Empty, tkEnclosingType, 0));
-
- m_iPackingSize = iPackingSize;
- m_iTypeSize = iTypeSize;
- if ((m_iPackingSize != 0) || (m_iTypeSize != 0))
- InternalSetClassLayout(Module, m_tdType.Token, m_iPackingSize, m_iTypeSize);
-
-
-
- if (IsPublicComType(this)) {
- if (containingAssem is AssemblyBuilder) {
- AssemblyBuilder assemBuilder = (AssemblyBuilder)containingAssem;
- if (assemBuilder.IsPersistable() && m_module.IsTransient() == false) {
- assemBuilder.m_assemblyData.AddPublicComType(this);
- }
- }
- }
- }
-
- #endregion
-
- #region Private Members
- private MethodBuilder DefinePInvokeMethodHelper(string name, string dllName, string importName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers,
- Type[][] parameterTypeOptionalCustomModifiers, CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
- CheckContext(returnType);
- CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
- CheckContext(parameterTypeRequiredCustomModifiers);
- CheckContext(parameterTypeOptionalCustomModifiers);
-
- if (Module.Assembly.m_assemblyData.m_isSynchronized) {
- lock (Module.Assembly.m_assemblyData) {
- return DefinePInvokeMethodHelperNoLock(name, dllName, importName, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers,
- parameterTypeOptionalCustomModifiers, nativeCallConv, nativeCharSet);
- }
- }
- else {
- return DefinePInvokeMethodHelperNoLock(name, dllName, importName, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers,
- parameterTypeOptionalCustomModifiers, nativeCallConv, nativeCharSet);
- }
- }
-
- private MethodBuilder DefinePInvokeMethodHelperNoLock(string name, string dllName, string importName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers,
- Type[][] parameterTypeOptionalCustomModifiers, CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
-
- ThrowIfCreated();
-
- if (name == null)
- throw new ArgumentNullException("name");
-
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
-
- if (dllName == null)
- throw new ArgumentNullException("dllName");
-
- if (dllName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "dllName");
-
- if (importName == null)
- throw new ArgumentNullException("importName");
-
- if (importName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "importName");
-
- if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeOnInterface"));
-
- if ((attributes & MethodAttributes.Abstract) != 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeMethod"));
-
-
-
-
-
- attributes = attributes | MethodAttributes.PinvokeImpl;
- MethodBuilder method = new MethodBuilder(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, m_module,
- this, false);
-
- int sigLength;
- byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength);
-
- if (m_listMethods.Contains(method)) {
- throw new ArgumentException(Environment.GetResourceString("Argument_MethodRedefined"));
- }
- m_listMethods.Add(method);
-
- MethodToken token = method.GetToken();
-
- int linkFlags = 0;
- switch (nativeCallConv) {
- case CallingConvention.Winapi:
- linkFlags = (int)PInvokeMap.CallConvWinapi;
- break;
- case CallingConvention.Cdecl:
- linkFlags = (int)PInvokeMap.CallConvCdecl;
- break;
- case CallingConvention.StdCall:
- linkFlags = (int)PInvokeMap.CallConvStdcall;
- break;
- case CallingConvention.ThisCall:
- linkFlags = (int)PInvokeMap.CallConvThiscall;
- break;
- case CallingConvention.FastCall:
- linkFlags = (int)PInvokeMap.CallConvFastcall;
- break;
- }
- switch (nativeCharSet) {
- case CharSet.None:
- linkFlags |= (int)PInvokeMap.CharSetNotSpec;
- break;
- case CharSet.Ansi:
- linkFlags |= (int)PInvokeMap.CharSetAnsi;
- break;
- case CharSet.Unicode:
- linkFlags |= (int)PInvokeMap.CharSetUnicode;
- break;
- case CharSet.Auto:
- linkFlags |= (int)PInvokeMap.CharSetAuto;
- break;
- }
-
- InternalSetPInvokeData(m_module, dllName, importName, token.Token, 0, linkFlags);
- method.SetToken(token);
-
- return method;
- }
-
- private FieldBuilder DefineDataHelper(string name, byte[] data, int size, FieldAttributes attributes)
- {
- string strValueClassName;
- TypeBuilder valueClassType;
- FieldBuilder fdBuilder;
- TypeAttributes typeAttributes;
-
- if (name == nu