25 internal ModuleBuilderData m_moduleData;
29 internal InternalModuleBuilder m_internalModuleBuilder;
33 internal AssemblyBuilder ContainingAssemblyBuilder => m_assemblyBuilder;
35 internal object SyncRoot => ContainingAssemblyBuilder.SyncRoot;
37 internal InternalModuleBuilder InternalModule => m_internalModuleBuilder;
43 [SecuritySafeCritical]
46 string text = m_moduleData.m_strFileName;
51 if (ContainingAssemblyBuilder.m_assemblyData.m_strDir !=
null)
53 text =
Path.
Combine(ContainingAssemblyBuilder.m_assemblyData.m_strDir, text);
54 text =
Path.UnsafeGetFullPath(text);
56 if (ContainingAssemblyBuilder.m_assemblyData.m_strDir !=
null && text !=
null)
78 public override string ScopeName => InternalModule.ScopeName;
82 public override string Name => InternalModule.Name;
89 internal static extern IntPtr nCreateISymWriterForDynamicModule(
Module module,
string filename);
91 internal static string UnmangleTypeName(
string typeName)
93 int startIndex = typeName.Length - 1;
96 startIndex = typeName.LastIndexOf(
'+', startIndex);
102 int num = startIndex;
103 while (typeName[--num] ==
'\\')
113 return typeName.Substring(startIndex + 1);
116 internal ModuleBuilder(AssemblyBuilder assemblyBuilder, InternalModuleBuilder internalModuleBuilder)
118 m_internalModuleBuilder = internalModuleBuilder;
119 m_assemblyBuilder = assemblyBuilder;
122 internal void AddType(
string name, Type type)
124 m_TypeBuilderDict.
Add(name, type);
127 internal void CheckTypeNameConflict(
string strTypeName, Type enclosingType)
130 if (m_TypeBuilderDict.
TryGetValue(strTypeName, out value) && (object)value.DeclaringType == enclosingType)
132 throw new ArgumentException(Environment.GetResourceString(
"Argument_DuplicateTypeName"));
136 private Type GetType(
string strFormat, Type baseType)
138 if (strFormat ==
null || strFormat.Equals(
string.Empty))
142 char[] bFormat = strFormat.ToCharArray();
143 return SymbolType.FormCompoundType(bFormat, baseType, 0);
146 internal void CheckContext(params Type[][] typess)
148 ContainingAssemblyBuilder.CheckContext(typess);
151 internal void CheckContext(params Type[] types)
153 ContainingAssemblyBuilder.CheckContext(types);
158 [SuppressUnmanagedCodeSecurity]
159 private static extern int GetTypeRef(RuntimeModule module,
string strFullName, RuntimeModule refedModule,
string strRefedModuleFileName,
int tkResolution);
163 [SuppressUnmanagedCodeSecurity]
164 private static extern int GetMemberRef(RuntimeModule module, RuntimeModule refedModule,
int tr,
int defToken);
167 private int GetMemberRef(Module refedModule,
int tr,
int defToken)
169 return GetMemberRef(GetNativeHandle(), GetRuntimeModuleFromModule(refedModule).GetNativeHandle(), tr, defToken);
174 [SuppressUnmanagedCodeSecurity]
175 private static extern int GetMemberRefFromSignature(RuntimeModule module,
int tr,
string methodName,
byte[] signature,
int length);
178 private int GetMemberRefFromSignature(
int tr,
string methodName,
byte[] signature,
int length)
180 return GetMemberRefFromSignature(GetNativeHandle(), tr, methodName, signature, length);
185 [SuppressUnmanagedCodeSecurity]
186 private static extern int GetMemberRefOfMethodInfo(RuntimeModule module,
int tr, IRuntimeMethodInfo method);
189 private int GetMemberRefOfMethodInfo(
int tr, RuntimeMethodInfo method)
191 if (ContainingAssemblyBuilder.ProfileAPICheck && (method.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
193 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_APIInvalidForCurrentContext", method.FullName));
195 return GetMemberRefOfMethodInfo(GetNativeHandle(), tr, method);
199 private int GetMemberRefOfMethodInfo(
int tr, RuntimeConstructorInfo method)
201 if (ContainingAssemblyBuilder.ProfileAPICheck && (method.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
203 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_APIInvalidForCurrentContext", method.FullName));
205 return GetMemberRefOfMethodInfo(GetNativeHandle(), tr, method);
210 [SuppressUnmanagedCodeSecurity]
211 private static extern int GetMemberRefOfFieldInfo(RuntimeModule module,
int tkType, RuntimeTypeHandle declaringType,
int tkField);
214 private int GetMemberRefOfFieldInfo(
int tkType, RuntimeTypeHandle declaringType, RuntimeFieldInfo runtimeField)
216 if (ContainingAssemblyBuilder.ProfileAPICheck)
218 RtFieldInfo rtFieldInfo = runtimeField as RtFieldInfo;
219 if (rtFieldInfo !=
null && (rtFieldInfo.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
221 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_APIInvalidForCurrentContext", rtFieldInfo.FullName));
224 return GetMemberRefOfFieldInfo(GetNativeHandle(), tkType, declaringType, runtimeField.MetadataToken);
229 [SuppressUnmanagedCodeSecurity]
230 private static extern int GetTokenFromTypeSpec(RuntimeModule pModule,
byte[] signature,
int length);
233 private int GetTokenFromTypeSpec(
byte[] signature,
int length)
235 return GetTokenFromTypeSpec(GetNativeHandle(), signature, length);
240 [SuppressUnmanagedCodeSecurity]
241 private static extern int GetArrayMethodToken(RuntimeModule module,
int tkTypeSpec,
string methodName,
byte[] signature,
int sigLength);
245 [SuppressUnmanagedCodeSecurity]
246 private static extern int GetStringConstant(RuntimeModule module,
string str,
int length);
250 [SuppressUnmanagedCodeSecurity]
251 private static extern void PreSavePEFile(RuntimeModule module,
int portableExecutableKind,
int imageFileMachine);
255 [SuppressUnmanagedCodeSecurity]
256 private static extern void SavePEFile(RuntimeModule module,
string fileName,
int entryPoint,
int isExe,
bool isManifestFile);
260 [SuppressUnmanagedCodeSecurity]
261 private static extern void AddResource(RuntimeModule module,
string strName,
byte[] resBytes,
int resByteCount,
int tkFile,
int attribute,
int portableExecutableKind,
int imageFileMachine);
265 [SuppressUnmanagedCodeSecurity]
266 private static extern void SetModuleName(RuntimeModule module,
string strModuleName);
270 [SuppressUnmanagedCodeSecurity]
271 internal static extern void SetFieldRVAContent(RuntimeModule module,
int fdToken,
byte[] data,
int length);
275 [SuppressUnmanagedCodeSecurity]
276 private static extern void DefineNativeResourceFile(RuntimeModule module,
string strFilename,
int portableExecutableKind,
int ImageFileMachine);
280 [SuppressUnmanagedCodeSecurity]
281 private static extern void DefineNativeResourceBytes(RuntimeModule module,
byte[] pbResource,
int cbResource,
int portableExecutableKind,
int imageFileMachine);
286 string strResourceFileName = m_moduleData.m_strResourceFileName;
287 byte[] resourceBytes = m_moduleData.m_resourceBytes;
288 if (strResourceFileName !=
null)
290 DefineNativeResourceFile(GetNativeHandle(), strResourceFileName, (
int)portableExecutableKind, (
int)imageFileMachine);
292 else if (resourceBytes !=
null)
294 DefineNativeResourceBytes(GetNativeHandle(), resourceBytes, resourceBytes.Length, (
int)portableExecutableKind, (
int)imageFileMachine);
298 internal virtual Type FindTypeBuilderWithName(
string strTypeName,
bool ignoreCase)
303 foreach (
string key
in m_TypeBuilderDict.
Keys)
305 if (
string.Compare(key, strTypeName,
StringComparison.OrdinalIgnoreCase) == 0)
307 return m_TypeBuilderDict[key];
311 else if (m_TypeBuilderDict.
TryGetValue(strTypeName, out value))
318 internal void SetEntryPoint(MethodToken entryPoint)
320 m_EntryPoint = entryPoint;
326 if (m_moduleData.m_isSaved)
328 throw new InvalidOperationException(
string.Format(
CultureInfo.
InvariantCulture, Environment.GetResourceString(
"InvalidOperation_ModuleHasBeenSaved"), m_moduleData.m_strModuleName));
330 if (!m_moduleData.m_fGlobalBeenCreated && m_moduleData.m_fHasGlobal)
332 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_GlobalFunctionNotBaked"));
334 foreach (Type value
in m_TypeBuilderDict.
Values)
336 TypeBuilder typeBuilder;
337 if (value is TypeBuilder)
339 typeBuilder = (TypeBuilder)value;
343 EnumBuilder enumBuilder = (EnumBuilder)value;
344 typeBuilder = enumBuilder.m_typeBuilder;
346 if (!typeBuilder.IsCreated())
348 throw new NotSupportedException(
string.Format(
CultureInfo.
InvariantCulture, Environment.GetResourceString(
"NotSupported_NotAllTypesAreBaked"), typeBuilder.FullName));
351 PreSavePEFile(GetNativeHandle(), (
int)portableExecutableKind, (
int)imageFileMachine);
357 if (m_moduleData.m_embeddedRes !=
null)
359 for (ResWriterData resWriterData = m_moduleData.m_embeddedRes; resWriterData !=
null; resWriterData = resWriterData.m_nextResWriter)
361 if (resWriterData.m_resWriter !=
null)
363 resWriterData.m_resWriter.Generate();
365 byte[] array =
new byte[resWriterData.m_memoryStream.Length];
366 resWriterData.m_memoryStream.Flush();
367 resWriterData.m_memoryStream.Position = 0
L;
368 resWriterData.m_memoryStream.Read(array, 0, array.Length);
369 AddResource(GetNativeHandle(), resWriterData.m_strName, array, array.Length, m_moduleData.FileToken, (
int)resWriterData.m_attribute, (
int)portableExecutableKind, (
int)imageFileMachine);
372 DefineNativeResource(portableExecutableKind, imageFileMachine);
373 PEFileKinds isExe = (!isAssemblyFile) ?
PEFileKinds.Dll : ContainingAssemblyBuilder.m_assemblyData.m_peFileKind;
374 SavePEFile(GetNativeHandle(), fileName, m_EntryPoint.
Token, (int)isExe, isAssemblyFile);
375 m_moduleData.m_isSaved =
true;
379 private int GetTypeRefNested(Type type, Module refedModule,
string strRefedModuleFileName)
381 Type declaringType = type.DeclaringType;
382 int tkResolution = 0;
383 string text = type.FullName;
384 if (declaringType !=
null)
386 tkResolution = GetTypeRefNested(declaringType, refedModule, strRefedModuleFileName);
387 text = UnmangleTypeName(text);
389 if (ContainingAssemblyBuilder.ProfileAPICheck)
391 RuntimeType runtimeType = type as RuntimeType;
392 if (runtimeType !=
null && (runtimeType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
394 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_APIInvalidForCurrentContext", runtimeType.FullName));
397 return GetTypeRef(GetNativeHandle(), text, GetRuntimeModuleFromModule(refedModule).GetNativeHandle(), strRefedModuleFileName, tkResolution);
401 internal MethodToken InternalGetConstructorToken(ConstructorInfo con,
bool usingRef)
405 throw new ArgumentNullException(
"con");
408 ConstructorBuilder constructorBuilder =
null;
409 ConstructorOnTypeBuilderInstantiation constructorOnTypeBuilderInstantiation =
null;
410 RuntimeConstructorInfo runtimeConstructorInfo =
null;
411 if ((constructorBuilder = (con as ConstructorBuilder)) !=
null)
413 if (!usingRef && constructorBuilder.Module.Equals(
this))
415 return constructorBuilder.GetToken();
417 int token = GetTypeTokenInternal(con.ReflectedType).
Token;
418 num = GetMemberRef(con.ReflectedType.Module, token, constructorBuilder.GetToken().Token);
420 else if ((constructorOnTypeBuilderInstantiation = (con as ConstructorOnTypeBuilderInstantiation)) !=
null)
424 throw new InvalidOperationException();
426 int token = GetTypeTokenInternal(con.DeclaringType).
Token;
427 num = GetMemberRef(con.DeclaringType.Module, token, constructorOnTypeBuilderInstantiation.MetadataTokenInternal);
429 else if ((runtimeConstructorInfo = (con as RuntimeConstructorInfo)) !=
null && !con.ReflectedType.IsArray)
431 int token = GetTypeTokenInternal(con.ReflectedType).
Token;
432 num = GetMemberRefOfMethodInfo(token, runtimeConstructorInfo);
436 ParameterInfo[] parameters = con.GetParameters();
437 if (parameters ==
null)
439 throw new ArgumentException(Environment.GetResourceString(
"Argument_InvalidConstructorInfo"));
441 int num2 = parameters.Length;
445 for (
int i = 0; i < num2; i++)
447 if (parameters[i] ==
null)
449 throw new ArgumentException(Environment.GetResourceString(
"Argument_InvalidConstructorInfo"));
451 array[i] = parameters[i].ParameterType;
452 array2[i] = parameters[i].GetRequiredCustomModifiers();
453 array3[i] = parameters[i].GetOptionalCustomModifiers();
455 int token = GetTypeTokenInternal(con.ReflectedType).
Token;
456 SignatureHelper methodSigHelper = SignatureHelper.GetMethodSigHelper(
this, con.CallingConvention,
null,
null,
null, array, array2, array3);
458 byte[] signature = methodSigHelper.InternalGetSignature(out length);
459 num = GetMemberRefFromSignature(token, con.Name, signature, length);
461 return new MethodToken(num);
465 internal void Init(
string strModuleName,
string strFileName,
int tkFile)
467 m_moduleData =
new ModuleBuilderData(
this, strModuleName, strFileName, tkFile);
472 internal void ModifyModuleName(
string name)
474 m_moduleData.ModifyModuleName(name);
475 SetModuleName(GetNativeHandle(), name);
480 m_iSymWriter = writer;
488 internal RuntimeModule GetNativeHandle()
490 return InternalModule.GetNativeHandle();
493 private static RuntimeModule GetRuntimeModuleFromModule(Module m)
495 ModuleBuilder moduleBuilder = m as ModuleBuilder;
496 if (moduleBuilder !=
null)
498 return moduleBuilder.InternalModule;
500 return m as RuntimeModule;
504 private int GetMemberRefToken(MethodBase method,
IEnumerable<Type> optionalParameterTypes)
506 int cGenericParameters = 0;
507 if (method.IsGenericMethod)
509 if (!method.IsGenericMethodDefinition)
511 throw new InvalidOperationException();
513 cGenericParameters = method.GetGenericArguments().Length;
517 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_NotAVarArgCallingConvention"));
519 MethodInfo methodInfo = method as MethodInfo;
520 Type[] parameterTypes;
521 Type methodBaseReturnType;
522 if (method.DeclaringType.IsGenericType)
524 MethodBase methodBase =
null;
525 MethodOnTypeBuilderInstantiation methodOnTypeBuilderInstantiation;
526 ConstructorOnTypeBuilderInstantiation constructorOnTypeBuilderInstantiation;
527 if ((methodOnTypeBuilderInstantiation = (method as MethodOnTypeBuilderInstantiation)) !=
null)
529 methodBase = methodOnTypeBuilderInstantiation.m_method;
531 else if ((constructorOnTypeBuilderInstantiation = (method as ConstructorOnTypeBuilderInstantiation)) !=
null)
533 methodBase = constructorOnTypeBuilderInstantiation.m_ctor;
535 else if (method is MethodBuilder || method is ConstructorBuilder)
539 else if (method.IsGenericMethod)
541 methodBase = methodInfo.GetGenericMethodDefinition();
542 methodBase = methodBase.Module.ResolveMethod(method.MetadataToken, (methodBase.DeclaringType !=
null) ? methodBase.DeclaringType.GetGenericArguments() :
null, methodBase.GetGenericArguments());
546 methodBase = method.Module.ResolveMethod(method.MetadataToken, (method.DeclaringType !=
null) ? method.DeclaringType.GetGenericArguments() :
null,
null);
548 parameterTypes = methodBase.GetParameterTypes();
549 methodBaseReturnType = MethodBuilder.GetMethodBaseReturnType(methodBase);
553 parameterTypes = method.GetParameterTypes();
554 methodBaseReturnType = MethodBuilder.GetMethodBaseReturnType(method);
557 byte[] signature = GetMemberRefSignature(method.CallingConvention, methodBaseReturnType, parameterTypes, optionalParameterTypes, cGenericParameters).InternalGetSignature(out length);
559 if (!method.DeclaringType.IsGenericType)
566 byte[] signature2 = SignatureHelper.GetTypeSigToken(
this, method.DeclaringType).InternalGetSignature(out length2);
567 tr = GetTokenFromTypeSpec(signature2, length2);
569 return GetMemberRefFromSignature(tr, method.Name, signature, length);
573 internal SignatureHelper GetMemberRefSignature(
CallingConventions call, Type returnType, Type[] parameterTypes,
IEnumerable<Type> optionalParameterTypes,
int cGenericParameters)
575 int num = (parameterTypes !=
null) ? parameterTypes.Length : 0;
576 SignatureHelper methodSigHelper = SignatureHelper.GetMethodSigHelper(
this, call, returnType, cGenericParameters);
577 for (
int i = 0; i < num; i++)
579 methodSigHelper.AddArgument(parameterTypes[i]);
581 if (optionalParameterTypes !=
null)
585 foreach (Type optionalParameterType
in optionalParameterTypes)
589 methodSigHelper.AddSentinel();
591 methodSigHelper.AddArgument(optionalParameterType);
594 return methodSigHelper;
597 return methodSigHelper;
606 return InternalModule.Equals(obj);
613 return InternalModule.GetHashCode();
621 return InternalModule.GetCustomAttributes(inherit);
634 return InternalModule.GetCustomAttributes(attributeType, inherit);
648 return InternalModule.IsDefined(attributeType, inherit);
655 return InternalModule.GetCustomAttributesData();
666 return GetTypesNoLock();
670 internal Type[] GetTypesNoLock()
672 int count = m_TypeBuilderDict.
Count;
675 foreach (
Type value
in m_TypeBuilderDict.
Values)
685 array[num++] = value;
703 return GetType(className, throwOnError:
false, ignoreCase:
false);
718 return GetType(className, throwOnError:
false, ignoreCase);
735 public override Type GetType(
string className,
bool throwOnError,
bool ignoreCase)
739 return GetTypeNoLock(className, throwOnError, ignoreCase);
743 private Type GetTypeNoLock(
string className,
bool throwOnError,
bool ignoreCase)
745 Type type = InternalModule.
GetType(className, throwOnError, ignoreCase);
753 while (num <= className.Length)
755 int num2 = className.IndexOfAny(
new char[3]
769 while (num4 >= 0 && className[num4] ==
'\\')
779 text = className.Substring(0, num2);
780 text2 = className.Substring(num2);
788 text = text.Replace(
"\\\\",
"\\").Replace(
"\\[",
"[").Replace(
"\\*",
"*")
789 .Replace(
"\\&",
"&");
792 type = InternalModule.
GetType(text, throwOnError:
false, ignoreCase);
796 type = FindTypeBuilderWithName(text, ignoreCase);
797 if (type ==
null &&
Assembly is AssemblyBuilder)
799 List<ModuleBuilder> moduleBuilderList = ContainingAssemblyBuilder.m_assemblyData.m_moduleBuilderList;
800 int count = moduleBuilderList.
Count;
801 for (
int i = 0; i < count; i++)
807 ModuleBuilder moduleBuilder = moduleBuilderList[i];
808 type = moduleBuilder.FindTypeBuilderWithName(text, ignoreCase);
820 return GetType(text2, type);
832 return InternalModule.ResolveSignature(metadataToken);
847 return InternalModule.ResolveMethod(metadataToken, genericTypeArguments, genericMethodArguments);
862 return InternalModule.ResolveField(metadataToken, genericTypeArguments, genericMethodArguments);
877 return InternalModule.ResolveType(metadataToken, genericTypeArguments, genericMethodArguments);
893 return InternalModule.ResolveMember(metadataToken, genericTypeArguments, genericMethodArguments);
905 return InternalModule.ResolveString(metadataToken);
913 InternalModule.GetPEKind(out peKind, out machine);
921 return InternalModule.IsResource();
930 return InternalModule.GetFields(bindingFlags);
940 return InternalModule.GetField(name, bindingAttr);
948 return InternalModule.GetMethods(bindingFlags);
963 return InternalModule.GetMethodInternal(name, bindingAttr, binder, callConvention, types, modifiers);
970 return InternalModule.GetSignerCertificate();
979 [SecuritySafeCritical]
995 [SecuritySafeCritical]
1000 return DefineTypeNoLock(name, attr,
null,
null,
PackingSize.Unspecified, 0);
1012 [SecuritySafeCritical]
1017 CheckContext(parent);
1018 return DefineTypeNoLock(name, attr, parent,
null,
PackingSize.Unspecified, 0);
1031 [SecuritySafeCritical]
1036 return DefineTypeNoLock(name, attr, parent,
null,
PackingSize.Unspecified, typesize);
1050 [SecuritySafeCritical]
1055 return DefineTypeNoLock(name, attr, parent,
null, packingSize, typesize);
1068 [SecuritySafeCritical]
1074 return DefineTypeNoLock(name, attr, parent, interfaces,
PackingSize.Unspecified, 0);
1081 return new TypeBuilder(name, attr, parent, interfaces,
this, packingSize, typesize,
null);
1093 [SecuritySafeCritical]
1098 return DefineTypeNoLock(name, attr, parent, packsize);
1105 return new TypeBuilder(name, attr, parent,
null,
this, packsize, 0,
null);
1116 [SecuritySafeCritical]
1119 CheckContext(underlyingType);
1122 EnumBuilder enumBuilder = DefineEnumNoLock(name, visibility, underlyingType);
1123 m_TypeBuilderDict[name] = enumBuilder;
1131 return new EnumBuilder(name, underlyingType, visibility,
this);
1160 return DefineResourceNoLock(name, description, attribute);
1174 if (name.Length == 0)
1178 if (m_assemblyBuilder.IsPersistable())
1180 m_assemblyBuilder.m_assemblyData.CheckResNameConflict(name);
1183 ResWriterData resWriterData =
new ResWriterData(resourceWriter, memoryStream, name,
string.Empty,
string.Empty, attribute);
1184 resWriterData.m_nextResWriter = m_moduleData.m_embeddedRes;
1185 m_moduleData.m_embeddedRes = resWriterData;
1186 return resourceWriter;
1188 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_BadResourceContainer"));
1213 DefineManifestResourceNoLock(name, stream, attribute);
1227 if (name.Length == 0)
1231 if (m_assemblyBuilder.IsPersistable())
1233 m_assemblyBuilder.m_assemblyData.CheckResNameConflict(name);
1234 ResWriterData resWriterData =
new ResWriterData(
null, stream, name,
string.Empty,
string.Empty, attribute);
1235 resWriterData.m_nextResWriter = m_moduleData.m_embeddedRes;
1236 m_moduleData.m_embeddedRes = resWriterData;
1239 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_BadResourceContainer"));
1251 DefineUnmanagedResourceInternalNoLock(resource);
1255 internal void DefineUnmanagedResourceInternalNoLock(
byte[] resource)
1257 if (resource ==
null)
1261 if (m_moduleData.m_strResourceFileName !=
null || m_moduleData.m_resourceBytes !=
null)
1265 m_moduleData.m_resourceBytes =
new byte[resource.Length];
1266 Array.
Copy(resource, m_moduleData.m_resourceBytes, resource.Length);
1278 [SecuritySafeCritical]
1283 DefineUnmanagedResourceFileInternalNoLock(resourceFileName);
1288 internal void DefineUnmanagedResourceFileInternalNoLock(
string resourceFileName)
1290 if (resourceFileName ==
null)
1294 if (m_moduleData.m_resourceBytes !=
null || m_moduleData.m_strResourceFileName !=
null)
1298 string text =
Path.UnsafeGetFullPath(resourceFileName);
1303 if (!
File.UnsafeExists(resourceFileName))
1312 m_moduleData.m_strResourceFileName = text;
1345 return DefineGlobalMethod(name, attributes, callingConvention, returnType,
null,
null, parameterTypes,
null,
null);
1367 return DefineGlobalMethodNoLock(name, attributes, callingConvention, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
1373 if (m_moduleData.m_fGlobalBeenCreated)
1381 if (name.Length == 0)
1387 throw new ArgumentException(Environment.GetResourceString(
"Argument_GlobalFunctionHasToBeStatic"));
1389 CheckContext(returnType);
1390 CheckContext(requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes);
1391 CheckContext(requiredParameterTypeCustomModifiers);
1392 CheckContext(optionalParameterTypeCustomModifiers);
1393 m_moduleData.m_fHasGlobal =
true;
1394 return m_moduleData.m_globalTypeBuilder.DefineMethod(name, attributes, callingConvention, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
1413 return DefinePInvokeMethod(name, dllName, name, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet);
1435 return DefinePInvokeMethodNoLock(name, dllName, entryName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet);
1445 CheckContext(returnType);
1446 CheckContext(parameterTypes);
1447 m_moduleData.m_fHasGlobal =
true;
1448 return m_moduleData.m_globalTypeBuilder.DefinePInvokeMethod(name, dllName, entryName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet);
1457 CreateGlobalFunctionsNoLock();
1461 private void CreateGlobalFunctionsNoLock()
1463 if (m_moduleData.m_fGlobalBeenCreated)
1467 m_moduleData.m_globalTypeBuilder.CreateType();
1468 m_moduleData.m_fGlobalBeenCreated =
true;
1485 return DefineInitializedDataNoLock(name, data, attributes);
1491 if (m_moduleData.m_fGlobalBeenCreated)
1495 m_moduleData.m_fHasGlobal =
true;
1496 return m_moduleData.m_globalTypeBuilder.DefineInitializedData(name, data, attributes);
1514 return DefineUninitializedDataNoLock(name, size, attributes);
1520 if (m_moduleData.m_fGlobalBeenCreated)
1524 m_moduleData.m_fHasGlobal =
true;
1525 return m_moduleData.m_globalTypeBuilder.DefineUninitializedData(name, size, attributes);
1529 internal TypeToken GetTypeTokenInternal(
Type type)
1531 return GetTypeTokenInternal(type, getGenericDefinition:
false);
1535 private TypeToken GetTypeTokenInternal(Type type,
bool getGenericDefinition)
1539 return GetTypeTokenWorkerNoLock(type, getGenericDefinition);
1551 [SecuritySafeCritical]
1554 return GetTypeTokenInternal(type, getGenericDefinition:
true);
1558 private TypeToken GetTypeTokenWorkerNoLock(
Type type,
bool getGenericDefinition)
1572 byte[] signature = SignatureHelper.GetTypeSigToken(
this, type).InternalGetSignature(out length);
1573 return new TypeToken(GetTokenFromTypeSpec(signature, length));
1575 Module module = type.
Module;
1576 if (module.Equals(
this))
1578 TypeBuilder typeBuilder =
null;
1579 GenericTypeParameterBuilder genericTypeParameterBuilder =
null;
1580 EnumBuilder enumBuilder = type as EnumBuilder;
1581 typeBuilder = ((!(enumBuilder !=
null)) ? (type as TypeBuilder) : enumBuilder.m_typeBuilder);
1582 if (typeBuilder !=
null)
1584 return typeBuilder.TypeToken;
1586 if ((genericTypeParameterBuilder = (type as GenericTypeParameterBuilder)) !=
null)
1588 return new TypeToken(genericTypeParameterBuilder.MetadataTokenInternal);
1590 return new TypeToken(GetTypeRefNested(type,
this,
string.Empty));
1592 ModuleBuilder moduleBuilder = module as ModuleBuilder;
1593 bool flag = (moduleBuilder !=
null) ? moduleBuilder.IsTransient() : ((RuntimeModule)module).IsTransientInternal();
1596 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_BadTransientModuleReference"));
1598 string strRefedModuleFileName =
string.Empty;
1599 if (module.Assembly.Equals(
Assembly))
1601 if (moduleBuilder ==
null)
1603 moduleBuilder = ContainingAssemblyBuilder.GetModuleBuilder((InternalModuleBuilder)module);
1605 strRefedModuleFileName = moduleBuilder.m_moduleData.m_strFileName;
1607 return new TypeToken(GetTypeRefNested(type, module, strRefedModuleFileName));
1621 return GetTypeToken(InternalModule.GetType(name, throwOnError:
false, ignoreCase:
true));
1630 [SecuritySafeCritical]
1635 return GetMethodTokenNoLock(method, getGenericTypeDefinition:
true);
1644 return GetMethodTokenNoLock(method, getGenericTypeDefinition:
false);
1649 private MethodToken GetMethodTokenNoLock(MethodInfo method,
bool getGenericTypeDefinition)
1656 SymbolMethod symbolMethod =
null;
1657 MethodBuilder methodBuilder =
null;
1658 if ((methodBuilder = (method as MethodBuilder)) !=
null)
1660 int metadataTokenInternal = methodBuilder.MetadataTokenInternal;
1661 if (method.Module.Equals(
this))
1663 return new MethodToken(metadataTokenInternal);
1665 if (method.DeclaringType ==
null)
1667 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_CannotImportGlobalFromDifferentModule"));
1669 int tr = getGenericTypeDefinition ?
GetTypeToken(method.DeclaringType).
Token : GetTypeTokenInternal(method.DeclaringType).
Token;
1670 num = GetMemberRef(method.DeclaringType.Module, tr, metadataTokenInternal);
1674 if (method is MethodOnTypeBuilderInstantiation)
1676 return new MethodToken(GetMemberRefToken(method,
null));
1678 if ((symbolMethod = (method as SymbolMethod)) !=
null)
1680 if (symbolMethod.GetModule() ==
this)
1682 return symbolMethod.GetToken();
1684 return symbolMethod.GetToken(
this);
1686 Type declaringType = method.DeclaringType;
1687 if (declaringType ==
null)
1689 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_CannotImportGlobalFromDifferentModule"));
1691 RuntimeMethodInfo runtimeMethodInfo =
null;
1692 if (declaringType.IsArray)
1694 ParameterInfo[] parameters = method.GetParameters();
1695 Type[] array =
new Type[parameters.Length];
1696 for (
int i = 0; i < parameters.Length; i++)
1698 array[i] = parameters[i].ParameterType;
1700 return GetArrayMethodToken(declaringType, method.Name, method.CallingConvention, method.ReturnType, array);
1702 if ((runtimeMethodInfo = (method as RuntimeMethodInfo)) !=
null)
1704 int tr = getGenericTypeDefinition ?
GetTypeToken(method.DeclaringType).
Token : GetTypeTokenInternal(method.DeclaringType).
Token;
1705 num = GetMemberRefOfMethodInfo(tr, runtimeMethodInfo);
1709 ParameterInfo[] parameters2 = method.GetParameters();
1710 Type[] array2 =
new Type[parameters2.Length];
1711 Type[][] array3 =
new Type[array2.Length][];
1712 Type[][] array4 =
new Type[array2.Length][];
1713 for (
int j = 0; j < parameters2.Length; j++)
1715 array2[j] = parameters2[j].ParameterType;
1716 array3[j] = parameters2[j].GetRequiredCustomModifiers();
1717 array4[j] = parameters2[j].GetOptionalCustomModifiers();
1719 int tr = getGenericTypeDefinition ?
GetTypeToken(method.DeclaringType).
Token : GetTypeTokenInternal(method.DeclaringType).
Token;
1720 SignatureHelper methodSigHelper;
1723 methodSigHelper = SignatureHelper.GetMethodSigHelper(
this, method.CallingConvention, method.ReturnType, method.ReturnParameter.GetRequiredCustomModifiers(), method.ReturnParameter.GetOptionalCustomModifiers(), array2, array3, array4);
1725 catch (NotImplementedException)
1727 methodSigHelper = SignatureHelper.GetMethodSigHelper(
this, method.ReturnType, array2);
1730 byte[] signature = methodSigHelper.InternalGetSignature(out length);
1731 num = GetMemberRefFromSignature(tr, method.Name, signature, length);
1734 return new MethodToken(num);
1743 [SecuritySafeCritical]
1746 if (constructor ==
null)
1752 return new MethodToken(GetMethodTokenInternal(constructor, optionalParameterTypes, useMethodDef:
false));
1763 [SecuritySafeCritical]
1772 return new MethodToken(GetMethodTokenInternal(method, optionalParameterTypes, useMethodDef:
true));
1785 if (!isGenericMethodDefinition)
1790 if (isGenericMethodDefinition && useMethodDef)
1795 byte[] signature = SignatureHelper.GetMethodSpecSigHelper(
this, methodInfo.
GetGenericArguments()).InternalGetSignature(out length);
1796 return TypeBuilder.DefineMethodSpec(GetNativeHandle(), num, signature, length);
1800 if (methodInfo !=
null)
1802 return GetMethodTokenInternal(methodInfo).
Token;
1806 return GetMemberRefToken(method, optionalParameterTypes);
1820 [SecuritySafeCritical]
1825 return GetArrayMethodTokenNoLock(arrayClass, methodName, callingConvention, returnType, parameterTypes);
1832 if (arrayClass ==
null)
1836 if (methodName ==
null)
1840 if (methodName.Length == 0)
1846 throw new ArgumentException(Environment.GetResourceString(
"Argument_HasToBeArrayClass"));
1848 CheckContext(returnType, arrayClass);
1849 CheckContext(parameterTypes);
1850 SignatureHelper methodSigHelper = SignatureHelper.GetMethodSigHelper(
this, callingConvention, returnType,
null,
null, parameterTypes,
null,
null);
1852 byte[] signature = methodSigHelper.InternalGetSignature(out length);
1853 TypeToken typeTokenInternal = GetTypeTokenInternal(arrayClass);
1854 return new MethodToken(GetArrayMethodToken(GetNativeHandle(), typeTokenInternal.Token, methodName, signature, length));
1868 [SecuritySafeCritical]
1871 CheckContext(returnType, arrayClass);
1872 CheckContext(parameterTypes);
1873 MethodToken arrayMethodToken = GetArrayMethodToken(arrayClass, methodName, callingConvention, returnType, parameterTypes);
1874 return new SymbolMethod(
this, arrayMethodToken, arrayClass, methodName, callingConvention, returnType, parameterTypes);
1882 [SecuritySafeCritical]
1886 return InternalGetConstructorToken(con, usingRef:
false);
1894 [SecuritySafeCritical]
1899 return GetFieldTokenNoLock(field);
1911 FieldBuilder fieldBuilder =
null;
1912 RuntimeFieldInfo runtimeFieldInfo =
null;
1913 FieldOnTypeBuilderInstantiation fieldOnTypeBuilderInstantiation =
null;
1914 if ((fieldBuilder = (field as FieldBuilder)) !=
null)
1919 byte[] signature = SignatureHelper.GetTypeSigToken(
this, field.
DeclaringType).InternalGetSignature(out length);
1920 int tokenFromTypeSpec = GetTokenFromTypeSpec(signature, length);
1921 num = GetMemberRef(
this, tokenFromTypeSpec, fieldBuilder.GetToken().Token);
1925 if (fieldBuilder.Module.Equals(
this))
1927 return fieldBuilder.GetToken();
1931 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_CannotImportGlobalFromDifferentModule"));
1934 num = GetMemberRef(field.
ReflectedType.
Module, tokenFromTypeSpec, fieldBuilder.GetToken().Token);
1937 else if ((runtimeFieldInfo = (field as RuntimeFieldInfo)) !=
null)
1941 throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_CannotImportGlobalFromDifferentModule"));
1946 byte[] signature2 = SignatureHelper.GetTypeSigToken(
this, field.
DeclaringType).InternalGetSignature(out length2);
1947 int tokenFromTypeSpec = GetTokenFromTypeSpec(signature2, length2);
1948 num = GetMemberRefOfFieldInfo(tokenFromTypeSpec, field.
DeclaringType.GetTypeHandleInternal(), runtimeFieldInfo);
1953 num = GetMemberRefOfFieldInfo(tokenFromTypeSpec, field.
DeclaringType.GetTypeHandleInternal(), runtimeFieldInfo);
1956 else if ((fieldOnTypeBuilderInstantiation = (field as FieldOnTypeBuilderInstantiation)) !=
null)
1958 FieldInfo fieldInfo = fieldOnTypeBuilderInstantiation.FieldInfo;
1960 byte[] signature3 = SignatureHelper.GetTypeSigToken(
this, field.
DeclaringType).InternalGetSignature(out length3);
1961 int tokenFromTypeSpec = GetTokenFromTypeSpec(signature3, length3);
1962 num = GetMemberRef(fieldInfo.ReflectedType.Module, tokenFromTypeSpec, fieldOnTypeBuilderInstantiation.MetadataTokenInternal);
1967 SignatureHelper fieldSigHelper = SignatureHelper.GetFieldSigHelper(
this);
1970 byte[] signature4 = fieldSigHelper.InternalGetSignature(out length4);
1971 num = GetMemberRefFromSignature(tokenFromTypeSpec, field.
Name, signature4, length4);
1973 return new FieldToken(num, field.GetType());
1981 [SecuritySafeCritical]
1988 return new StringToken(GetStringConstant(GetNativeHandle(), str, str.Length));
1996 [SecuritySafeCritical]
1999 if (sigHelper ==
null)
2004 byte[] signature = sigHelper.InternalGetSignature(out length);
2014 [SecuritySafeCritical]
2017 if (sigBytes ==
null)
2021 byte[] array =
new byte[sigBytes.Length];
2022 Array.
Copy(sigBytes, array, sigBytes.Length);
2031 [SecuritySafeCritical]
2039 if (binaryAttribute ==
null)
2050 [SecuritySafeCritical]
2053 if (customBuilder ==
null)
2057 customBuilder.CreateCustomAttribute(
this, 1);
2064 return m_iSymWriter;
2084 return DefineDocumentNoLock(url, language, languageVendor, documentType);
2090 if (m_iSymWriter ==
null)
2094 return m_iSymWriter.
DefineDocument(url, language, languageVendor, documentType);
2103 [SecuritySafeCritical]
2108 SetUserEntryPointNoLock(entryPoint);
2113 private void SetUserEntryPointNoLock(
MethodInfo entryPoint)
2115 if (entryPoint ==
null)
2119 if (m_iSymWriter ==
null)
2132 MethodBuilder methodBuilder = entryPoint as MethodBuilder;
2133 if (methodBuilder !=
null && methodBuilder.GetModuleBuilder() !=
this)
2135 throw new InvalidOperationException(Environment.GetResourceString(
"Argument_NotInTheSameModuleBuilder"));
2152 SetSymCustomAttributeNoLock(name, data);
2156 private void SetSymCustomAttributeNoLock(
string name,
byte[] data)
2158 if (m_iSymWriter ==
null)
2169 return InternalModule.IsTransientInternal();
2212 void _ModuleBuilder.
Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid,
short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
2214 throw new NotImplementedException();
Obtains information about the attributes of a member and provides access to member metadata.
Exposes the T:System.Reflection.Emit.ModuleBuilder class to unmanaged code.
Performs reflection on a module.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
override Assembly Assembly
Gets the dynamic assembly that defined this instance of T:System.Reflection.Emit.ModuleBuilder.
MethodAttributes
Specifies flags for method attributes. These flags are defined in the corhdr.h file.
override bool IsDefined(Type attributeType, bool inherit)
Returns a value that indicates whether the specified attribute type has been applied to this module.
override object [] GetCustomAttributes(Type attributeType, bool inherit)
Returns all the custom attributes that have been applied to the current T:System.Reflection....
virtual bool IsGenericTypeDefinition
Gets a value indicating whether the current T:System.Type represents a generic type definition,...
void GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
Maps a set of names to a corresponding set of dispatch identifiers.
MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
Defines a global method with the specified name, attributes, calling convention, return type,...
The T:System.Diagnostics.SymbolStore.SymbolToken structure is an object representation of a token tha...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
void SetUserEntryPoint(MethodInfo entryPoint)
Sets the user entry point.
FileIOPermissionAccess
Specifies the type of file access requested.
override string FullyQualifiedName
Gets a String representing the fully qualified name and path to this module.
Describes and represents an enumeration type.
Provides the base functionality for writing resources to an output file or stream.
abstract Type FieldType
Gets the type of this field object.
FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes)
Defines an uninitialized data field in the .sdata section of the portable executable (PE) file.
virtual bool IsGenericParameter
Gets a value indicating whether the current T:System.Type represents a type parameter in the definiti...
abstract Type DeclaringType
Gets the class that declares this member.
int Count
Gets the number of elements contained in the T:System.Collections.Generic.List`1.
override Type GetType(string className, bool ignoreCase)
Gets the named type defined in the module, optionally ignoring the case of the type name.
virtual MethodInfo GetGenericMethodDefinition()
Returns a T:System.Reflection.MethodInfo object that represents a generic method definition from whic...
static string Combine(string path1, string path2)
Combines two strings into a path.
Discovers the attributes of a method and provides access to method metadata.
ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType)
Defines a source document.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
void SetUserEntryPoint(SymbolToken entryMethod)
Identifies the user-defined method as the entry point for the current module.
override Guid ModuleVersionId
Gets a universally unique identifier (UUID) that can be used to distinguish between two versions of a...
MethodToken GetMethodToken(MethodInfo method, IEnumerable< Type > optionalParameterTypes)
Returns the token used to identify the method that has the specified attributes and parameter types w...
override int MDStreamVersion
Gets the metadata stream version.
Discovers the attributes of a class constructor and provides access to constructor metadata.
The MethodToken struct is an object representation of a token that represents a method.
Discovers the attributes of a field and provides access to field metadata.
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize)
Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends,...
virtual Type [] GetOptionalCustomModifiers()
Gets an array of types that identify the optional custom modifiers of the field.
ImageFileMachine
Identifies the platform targeted by an executable.
TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, Type[] interfaces)
Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends,...
Represents a token that represents a string.
CallingConvention
Specifies the calling convention required to call methods implemented in unmanaged code.
override byte [] ResolveSignature(int metadataToken)
Returns the signature blob identified by a metadata token.
virtual bool IsGenericType
Gets a value indicating whether the current type is a generic type.
Defines and represents a dynamic assembly.
SignatureToken GetSignatureToken(byte[] sigBytes, int sigLength)
Defines a token for the signature that has the specified character array and signature length.
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Provides methods for building signatures.
override Type UnderlyingSystemType
Returns the underlying system type for this TypeBuilder.
EnumBuilder DefineEnum(string name, TypeAttributes visibility, Type underlyingType)
Defines an enumeration type that is a value type with a single non-static field called value__ of th...
override bool Equals(object obj)
Returns a value that indicates whether this instance is equal to the specified object.
override object [] GetCustomAttributes(bool inherit)
Returns all the custom attributes that have been applied to the current T:System.Reflection....
void DefineManifestResource(string name, Stream stream, ResourceAttributes attribute)
Defines a binary large object (BLOB) that represents a manifest resource to be embedded in the dynami...
override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the type identified by the specified metadata token, in the context defined by the specified ...
Helps build custom attributes.
SignatureToken GetSignatureToken(SignatureHelper sigHelper)
Defines a token for the signature that is defined by the specified T:System.Reflection....
Attaches a modifier to parameters so that binding can work with parameter signatures in which the typ...
MethodToken GetConstructorToken(ConstructorInfo constructor, IEnumerable< Type > optionalParameterTypes)
Returns the token used to identify the constructor that has the specified attributes and parameter ty...
Defines and represents a field. This class cannot be inherited.
void GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
Retrieves the type information for an object, which can be used to get the type information for an in...
override X509Certificate GetSignerCertificate()
Returns an T:System.Security.Cryptography.X509Certificates.X509Certificate object corresponding to th...
MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
Defines a global method with the specified name, attributes, calling convention, return type,...
MethodToken GetConstructorToken(ConstructorInfo con)
Returns the token used to identify the specified constructor within this module.
override string Name
A string that indicates that this is an in-memory module.
override int GetHashCode()
Returns the hash code for this instance.
CallingConventions
Defines the valid calling conventions for a method.
SecurityAction
Specifies the security actions that can be performed using declarative security.
ValueCollection Values
Gets a collection containing the values in the T:System.Collections.Generic.Dictionary`2.
void DefineUnmanagedResource(byte[] resource)
Defines an unmanaged embedded resource given an opaque binary large object (BLOB) of bytes.
Provides information about, and means to manipulate, the current environment and platform....
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
bool IsArray
Gets a value that indicates whether the type is an array.
bool IsPointer
Gets a value indicating whether the T:System.Type is a pointer.
IResourceWriter DefineResource(string name, string description)
Defines the named managed embedded resource to be stored in this module.
KeyCollection Keys
Gets a collection containing the keys in the T:System.Collections.Generic.Dictionary`2.
override bool Equals(object o)
Determines whether this module and the specified object are equal.
Creates a stream whose backing store is memory.To browse the .NET Framework source code for this type...
TypeBuilder DefineType(string name)
Constructs a TypeBuilder for a private type with the specified name in this module.
FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes)
Defines an initialized data field in the .sdata section of the portable executable (PE) file.
FieldToken GetFieldToken(FieldInfo field)
Returns the token used to identify the specified field within this module.
virtual bool IsGenericMethod
Gets a value indicating whether the method is generic.
MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
Defines a global method with the specified name, attributes, return type, and parameter types.
override Type GetType(string className)
Gets the named type defined in the module.
Defines and creates new instances of classes during run time.
override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the method or constructor identified by the specified metadata token, in the context defined ...
void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
Applies a custom attribute to this module by using a specified binary large object (BLOB) that repres...
TypeToken GetTypeToken(string name)
Returns the token used to identify the type with the specified name.
override Type [] GetTypes()
Returns all the classes defined within this module.
int Count
Gets the number of key/value pairs contained in the T:System.Collections.Generic.Dictionary`2.
PackingSize
Specifies one of two factors that determine the memory alignment of fields when a type is marshaled.
Defines and represents a module in a dynamic assembly.
MethodToken GetMethodToken(MethodInfo method)
Returns the token used to identify the specified method within this module.
virtual bool IsGenericMethodDefinition
Gets a value indicating whether the method is a generic method definition.
FieldAttributes
Specifies flags that describe the attributes of a field.
ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType)
Defines a document for source.
override string ResolveString(int metadataToken)
Returns the string identified by the specified metadata token.
void CreateGlobalFunctions()
Completes the global function definitions and global data definitions for this dynamic module.
override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
Gets a pair of values indicating the nature of the code in a module and the platform targeted by the ...
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
Defines the underlying structure of all code access permissions.
A platform-specific type that is used to represent a pointer or a handle.
TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, int typesize)
Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends,...
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Represents the Token returned by the metadata to represent a type.
override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the field identified by the specified metadata token, in the context defined by the specified...
Represents type declarations: class types, interface types, array types, value types,...
virtual Type [] GetRequiredCustomModifiers()
Gets an array of types that identify the required custom modifiers of the property.
Provides information about methods and constructors.
Type DeclaringType
Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo....
TypeBuilder DefineType(string name, TypeAttributes attr, Type parent)
Constructs a TypeBuilder given type name, its attributes, and the type that the defined type extends.
MethodImplOptions
Defines the details of how a method is implemented.
override Type GetType(string className, bool throwOnError, bool ignoreCase)
Gets the named type defined in the module, optionally ignoring the case of the type name....
CharSet
Dictates which character set marshaled strings should use.
abstract string Name
Gets the name of the current member.
virtual CallingConventions CallingConvention
Gets a value indicating the calling conventions for this method.
TypeBuilder DefineType(string name, TypeAttributes attr)
Constructs a TypeBuilder given the type name and the type attributes.
Selects a member from a list of candidates, and performs type conversion from actual argument type to...
TypeAttributes
Specifies type attributes.
Defines and represents a method (or constructor) on a dynamic class.
override Type [] GetGenericArguments()
Returns an array of T:System.Type objects that represent the type arguments of a generic method or th...
static void RevertAssert()
Causes any previous M:System.Security.CodeAccessPermission.Assert for the current frame to be removed...
Represents a collection of keys and values.To browse the .NET Framework source code for this type,...
override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the type or member identified by the specified metadata token, in the context defined by the ...
abstract Type ReflectedType
Gets the class object that was used to obtain this instance of MemberInfo.
override FieldInfo [] GetFields(BindingFlags bindingFlags)
Returns all fields defined in the .sdata region of the portable executable (PE) file that match the s...
IResourceWriter DefineResource(string name, string description, ResourceAttributes attribute)
Defines the named managed embedded resource with the given attributes that is to be stored in this mo...
Represents a collection of objects that can be individually accessed by index.
override MethodInfo [] GetMethods(BindingFlags bindingFlags)
Returns all the methods that have been defined at the module level for the current T:System....
The exception that is thrown when one of the arguments provided to a method is not valid.
Represents the Token returned by the metadata to represent a signature.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
The exception that is thrown when an attempt to access a file that does not exist on disk fails.
ResourceAttributes
Specifies the attributes for a manifest resource.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Writes resources in the system-default format to an output file or an output stream....
void GetTypeInfoCount(out uint pcTInfo)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
Represents a symbol writer for managed code.
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
override bool IsResource()
Gets a value indicating whether the object is a resource.
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
int Token
Returns the metadata token for this method.
ISymbolWriter GetSymWriter()
Returns the symbol writer associated with this dynamic module.
virtual Module Module
Gets the module in which the type that declares the member represented by the current T:System....
Represents a document referenced by a symbol store.
PortableExecutableKinds
Identifies the nature of the code in an executable file.
MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet)
Defines a PInvoke method with the specified name, the name of the DLL in which the method is defined,...
override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Returns the module-level method that matches the specified criteria.
MethodBuilder DefinePInvokeMethod(string name, string dllName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet)
Defines a PInvoke method with the specified name, the name of the DLL in which the method is defined,...
StringToken GetStringConstant(string str)
Returns the token of the given string in the module’s constant pool.
The exception that is thrown when a method call is invalid for the object's current state.
Provides static methods for the creation, copying, deletion, moving, and opening of a single file,...
void Add(TKey key, TValue value)
Adds the specified key and value to the dictionary.
static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Gets the T:System.Type with the specified name, specifying whether to throw an exception if the type ...
Controls access to system and user environment variables. This class cannot be inherited.
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
override string ScopeName
Gets a string that represents the name of the dynamic module.
override FieldInfo GetField(string name, BindingFlags bindingAttr)
Returns a module-level field, defined in the .sdata region of the portable executable (PE) file,...
int Token
Retrieves the metadata token for this class.
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
void SetSymCustomAttribute(string name, byte[] data)
This method does nothing.
bool IsTransient()
Returns a value that indicates whether this dynamic module is transient.
TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packsize)
Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends,...
abstract new Module Module
Gets the module (the DLL) in which the current T:System.Type is defined.
Provides information about a specific culture (called a locale for unmanaged code development)....
Controls the ability to access files and folders. This class cannot be inherited.
bool IsByRef
Gets a value indicating whether the T:System.Type is passed by reference.
ModuleHandle ModuleHandle
Gets a handle for the module.
override int MetadataToken
Gets a token that identifies the current dynamic module in metadata.
MethodToken GetArrayMethodToken(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
Returns the token for the named method on an array class.
bool TryGetValue(TKey key, out TValue value)
Gets the value associated with the specified key.
bool IsCreated()
Returns a value that indicates whether the current dynamic type has been created.
TypeToken GetTypeToken(Type type)
Returns the token used to identify the specified type within this module.
The exception that is thrown when a requested method or operation is not implemented.
void Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
Provides access to properties and methods exposed by an object.
Performs operations on T:System.String instances that contain file or directory path information....
PEFileKinds
Specifies the type of the portable executable (PE) file.
Provides methods that help you use X.509 v.3 certificates.
void SetCustomAttribute(CustomAttributeBuilder customBuilder)
Applies a custom attribute to this module by using a custom attribute builder.
MethodInfo GetArrayMethod(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
Returns the named method on an array class.
override IList< CustomAttributeData > GetCustomAttributesData()
Returns information about the attributes that have been applied to the current T:System....
void DefineUnmanagedResource(string resourceFileName)
Defines an unmanaged resource given the name of Win32 resource file.
The FieldToken struct is an object representation of a token that represents a field.
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....