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!
-
Expand
Microsoft.Win32
-
Expand
Microsoft.Win32.SafeHandles
-
Expand
System
-
Expand
System.Runtime.Hosting
-
Expand
System.Runtime.InteropServices
-
Expand
System.Runtime.CompilerServices
-
Expand
System.Collections
-
Expand
System.Collections.Generic
-
Expand
System.Collections.ObjectModel
-
Expand
System.Configuration.Assemblies
-
Expand
System.Diagnostics
-
Expand
System.Diagnostics.CodeAnalysis
-
Expand
System.Diagnostics.SymbolStore
-
Expand
System.Globalization
-
Expand
System.IO
-
Expand
System.IO.IsolatedStorage
-
Expand
System.Reflection
-
Expand
System.Reflection.Cache
-
Expand
System.Reflection.Emit
-
Expand
__ExceptionInfo
-
Expand
__ExceptionInstance
-
Expand
__FixupData
-
Expand
AssemblyBuilder
-
Expand
AssemblyBuilderAccess
-
Expand
AssemblyBuilderData
-
Expand
ConstructorBuilder
-
Expand
ConstructorOnTypeBuilderInstantiation
-
Expand
CustAttr
-
Expand
CustomAttributeBuilder
-
Expand
DestroyScout
-
Expand
DynamicILGenerator
-
Expand
DynamicILInfo
-
Expand
DynamicMethod
-
Expand
DynamicResolver
-
Expand
DynamicScope
-
Expand
EmptyCAHolder
-
Expand
Entry
-
Expand
EnumBuilder
-
Expand
EventBuilder
-
Expand
EventToken
-
Expand
FieldBuilder
-
Expand
FieldOnTypeBuilderInstantiation
-
Expand
FieldToken
-
Expand
FlowControl
-
Expand
Format
-
Expand
GenericMethodInfo
-
Expand
GenericTypeParameterBuilder
-
Expand
ILGenerator
-
Expand
Label
-
Expand
LineNumberInfo
-
Expand
LocalBuilder
-
Expand
LocalSymInfo
-
Expand
MethodBuilder
-
Expand
MethodBuilderInstantiation
-
Expand
MethodOnTypeBuilderInstantiation
-
Expand
MethodRental
-
Expand
MethodToken
-
Expand
ModuleBuilder
-
Expand
ModuleBuilderData
-
Expand
OpCode
-
Expand
OpCodes
-
Expand
OpCodeType
-
Expand
OperandType
-
Expand
PackingSize
-
Expand
ParameterBuilder
-
Expand
ParameterToken
-
Expand
PEFileKinds
-
Expand
PropertyBuilder
-
Expand
PropertyToken
-
Expand
REDocument
-
Expand
ResWriterData
-
Expand
RTDynamicMethod
-
Expand
ScopeAction
-
Expand
ScopeTree
-
Expand
SecurityControlFlags
-
Expand
SignatureHelper
-
AddData(int)
-
AddData(uint)
-
AddData(ulong)
-
AddElementType(int)
-
AddOneArgTypeHelper(Type)
-
AddOneArgTypeHelper(Type, bool)
-
AddOneArgTypeHelper(Type, Type, Type)
-
AddOneArgTypeHelperWorker(Type, bool)
-
AddToken(int)
-
GetFieldSigHelper(Module)
-
GetLocalVarSigHelper()
-
GetLocalVarSigHelper(Module)
-
GetMethodSigHelper(CallingConvention, Type)
-
GetMethodSigHelper(CallingConventions, Type)
-
GetMethodSigHelper(Module, CallingConvention, Type)
-
GetMethodSigHelper(Module, CallingConventions, int, Type, Type, Type, Type, Type, Type)
-
GetMethodSigHelper(Module, CallingConventions, Type)
-
GetMethodSigHelper(Module, CallingConventions, Type, int)
-
GetMethodSigHelper(Module, CallingConventions, Type, Type, Type, Type, Type, Type)
-
GetMethodSigHelper(Module, Type, Type)
-
GetMethodSpecSigHelper(Module, Type)
-
GetPropertySigHelper(Module, Type, Type)
-
GetPropertySigHelper(Module, Type, Type, Type, Type, Type, Type)
-
GetTypeSigToken(Module, Type)
-
Init(Module)
-
Init(Module, int)
-
Init(Module, int, int)
-
InternalAddRuntimeType(Type)
-
InternalAddTypeToken(TypeToken, int)
-
SignatureHelper(Module, int)
-
SignatureHelper(Module, int, int, Type, Type, Type)
-
SignatureHelper(Module, int, Type, Type, Type)
-
SignatureHelper(Module, Type)
-
Expand
SignatureToken
-
Expand
StackBehaviour
-
Expand
StringToken
-
Expand
SymbolMethod
-
Expand
SymbolType
-
Expand
SymCustomAttr
-
Expand
TypeBuilder
-
Expand
TypeBuilderInstantiation
-
Expand
TypeKind
-
Expand
TypeNameBuilder
-
Expand
TypeToken
-
Expand
UnmanagedMarshal
-
Expand
VarArgMethod
-
Expand
System.Resources
-
Expand
System.Runtime
-
Expand
System.Runtime.InteropServices.Expando
-
Expand
System.Runtime.ConstrainedExecution
-
Expand
System.Runtime.Remoting.Activation
-
Expand
System.Runtime.Remoting.Messaging
-
Expand
System.Runtime.Remoting.Channels
-
Expand
System.Runtime.Remoting.Lifetime
-
Expand
System.Runtime.Remoting
-
Expand
System.Runtime.Remoting.Contexts
-
Expand
System.Runtime.Remoting.Proxies
-
Expand
System.Runtime.Remoting.Metadata
-
Expand
System.Runtime.Remoting.Metadata.W3cXsd2001
-
Expand
System.Runtime.Remoting.Services
-
Expand
System.Runtime.Serialization
-
Expand
System.Runtime.Serialization.Formatters
-
Expand
System.Runtime.Serialization.Formatters.Binary
-
Expand
System.Runtime.Versioning
-
Expand
System.Security
-
Expand
System.Security.Cryptography
-
Expand
System.Security.Cryptography.X509Certificates
-
Expand
System.Security.Permissions
-
Expand
System.Security.Policy
-
Expand
System.Security.Principal
-
Expand
System.Security.Util
-
Expand
System.Text
-
Expand
System.Threading
-
Expand
System.Runtime.Remoting.Channels.Http
-
Expand
System.Runtime.Remoting.Channels.Tcp
-
Expand
System.Runtime.Remoting.MetadataServices
-
Expand
System.Runtime.Serialization.Formatters.Soap.Xml
-
Expand
System.Runtime.Serialization.Formatters.Soap
-
Expand
Microsoft.Tools.Caspol
-
Expand
Microsoft.Tools.Build
-
Expand
Microsoft.CSharp
-
Expand
System.CodeDom
-
Expand
System.CodeDom.Compiler
-
Expand
System.Collections.Specialized
-
Expand
System.ComponentModel
-
Expand
System.ComponentModel.Design
-
Expand
System.ComponentModel.Design.Serialization
-
Expand
System.Configuration
-
Expand
System.Web
-
Expand
System.Configuration.Provider
-
Expand
System.Configuration.Internal
-
Expand
System.Internal
-
Expand
System.Windows.Forms
-
Expand
System.Net
-
Expand
System.Net.Sockets
-
Expand
System.Net.NetworkInformation
-
Expand
System.Net.ComImports
-
Expand
System.Net.Security
-
Expand
System.Net.Cache
-
Expand
System.Net.Configuration
-
Expand
System.Text.RegularExpressions
-
Expand
System.Tools
-
Expand
System.IO.Compression
-
Expand
System.IO.Ports
-
Expand
System.Security.AccessControl
-
Expand
System.Xml
-
Expand
System.Xml.XPath.DataBinding
-
Expand
System.Xml.Schema
-
Expand
System.Xml.Serialization
-
Expand
System.Xml.Serialization.Advanced
-
Expand
System.Xml.Serialization.Configuration
-
Expand
System.Xml.XPath
-
Expand
System.Xml.Xsl
-
Expand
System.Xml.Xsl.IlGen
-
Expand
System.Xml.Xsl.Qil
-
Expand
System.Xml.Xsl.Runtime
-
Expand
System.Xml.Xsl.XPath
-
Expand
System.Xml.Xsl.Xslt
-
Expand
System.Xml.Xsl.XsltOld
-
Expand
System.Xml.Xsl.XsltOld.Debugger
-
Expand
Microsoft.JScript
-
Expand
Microsoft.Vsa
-
Expand
Microsoft.JScript.Vsa
- namespace System.Reflection.Emit
- {
- using System.Text;
- using System;
- using System.Reflection;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Security.Permissions;
-
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_SignatureHelper))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class SignatureHelper : _SignatureHelper
- {
- #region Consts Fields
- internal const int mdtTypeRef = 16777216;
- internal const int mdtTypeDef = 33554432;
- internal const int mdtTypeSpec = 553648128;
-
- #region ElementType
-
- internal const byte ELEMENT_TYPE_END = 0;
- internal const byte ELEMENT_TYPE_VOID = 1;
- internal const byte ELEMENT_TYPE_BOOLEAN = 2;
- internal const byte ELEMENT_TYPE_CHAR = 3;
- internal const byte ELEMENT_TYPE_I1 = 4;
- internal const byte ELEMENT_TYPE_U1 = 5;
- internal const byte ELEMENT_TYPE_I2 = 6;
- internal const byte ELEMENT_TYPE_U2 = 7;
- internal const byte ELEMENT_TYPE_I4 = 8;
- internal const byte ELEMENT_TYPE_U4 = 9;
- internal const byte ELEMENT_TYPE_I8 = 10;
- internal const byte ELEMENT_TYPE_U8 = 11;
- internal const byte ELEMENT_TYPE_R4 = 12;
- internal const byte ELEMENT_TYPE_R8 = 13;
- internal const byte ELEMENT_TYPE_STRING = 14;
-
- internal const byte ELEMENT_TYPE_PTR = 15;
-
- internal const byte ELEMENT_TYPE_BYREF = 16;
-
- internal const byte ELEMENT_TYPE_VALUETYPE = 17;
-
- internal const byte ELEMENT_TYPE_CLASS = 18;
-
- internal const byte ELEMENT_TYPE_VAR = 19;
-
- internal const byte ELEMENT_TYPE_ARRAY = 20;
-
- internal const byte ELEMENT_TYPE_GENERICINST = 21;
-
- internal const byte ELEMENT_TYPE_TYPEDBYREF = 22;
-
- internal const byte ELEMENT_TYPE_I = 24;
-
- internal const byte ELEMENT_TYPE_U = 25;
-
- internal const byte ELEMENT_TYPE_FNPTR = 27;
-
- internal const byte ELEMENT_TYPE_OBJECT = 28;
-
- internal const byte ELEMENT_TYPE_SZARRAY = 29;
-
- internal const byte ELEMENT_TYPE_MVAR = 30;
-
- internal const byte ELEMENT_TYPE_CMOD_REQD = 31;
-
- internal const byte ELEMENT_TYPE_CMOD_OPT = 32;
-
- internal const byte ELEMENT_TYPE_INTERNAL = 33;
-
- internal const byte ELEMENT_TYPE_MAX = 34;
-
- internal const byte ELEMENT_TYPE_SENTINEL = 65;
-
- internal const byte ELEMENT_TYPE_PINNED = 69;
- #endregion
-
- #region Unmanged Calling Convetions
- internal const int IMAGE_CEE_UNMANAGED_CALLCONV_C = 1;
- internal const int IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL = 2;
- internal const int IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL = 3;
- internal const int IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL = 4;
- #endregion
-
- #region Managed Calling Conventions
- internal const int IMAGE_CEE_CS_CALLCONV_DEFAULT = 0;
- internal const int IMAGE_CEE_CS_CALLCONV_VARARG = 5;
- internal const int IMAGE_CEE_CS_CALLCONV_FIELD = 6;
- internal const int IMAGE_CEE_CS_CALLCONV_LOCAL_SIG = 7;
- internal const int IMAGE_CEE_CS_CALLCONV_PROPERTY = 8;
- internal const int IMAGE_CEE_CS_CALLCONV_UNMGD = 9;
- internal const int IMAGE_CEE_CS_CALLCONV_GENERICINST = 10;
- internal const int IMAGE_CEE_CS_CALLCONV_MAX = 11;
-
- #endregion
- #region Misc
-
- internal const int IMAGE_CEE_CS_CALLCONV_MASK = 15;
-
- internal const int IMAGE_CEE_CS_CALLCONV_GENERIC = 16;
-
- internal const int IMAGE_CEE_CS_CALLCONV_HASTHIS = 32;
-
- internal const int IMAGE_CEE_CS_CALLCONV_RETPARAM = 64;
-
- internal const int NO_SIZE_IN_SIG = -1;
- #endregion
-
- #endregion
-
- #region Static Members
- public static SignatureHelper GetMethodSigHelper(Module mod, Type returnType, Type[] parameterTypes)
- {
- return GetMethodSigHelper(mod, CallingConventions.Standard, returnType, null, null, parameterTypes, null, null);
- }
-
- /// <include file='doc\SignatureHelper.uex' path='docs/doc[@for="SignatureHelper.GetMethodSigHelper"]/*' />
- static internal SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, Type returnType, int cGenericParam)
- {
- return GetMethodSigHelper(mod, callingConvention, cGenericParam, returnType, null, null, null, null, null);
- }
-
- public static SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, Type returnType)
- {
- return GetMethodSigHelper(mod, callingConvention, returnType, null, null, null, null, null);
- }
-
- static internal SignatureHelper GetMethodSpecSigHelper(Module scope, Type[] inst)
- {
- SignatureHelper sigHelp = new SignatureHelper(scope, IMAGE_CEE_CS_CALLCONV_GENERICINST);
- sigHelp.AddData(inst.Length);
- foreach (Type t in inst)
- sigHelp.AddArgument(t);
- return sigHelp;
- }
-
- static internal SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
- {
- return GetMethodSigHelper(scope, callingConvention, 0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
- }
-
- static internal SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
- {
- SignatureHelper sigHelp;
- int intCall;
-
- if (returnType == null) {
- returnType = typeof(void);
- }
-
- intCall = IMAGE_CEE_CS_CALLCONV_DEFAULT;
-
- if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
- intCall = IMAGE_CEE_CS_CALLCONV_VARARG;
-
- if (cGenericParam > 0) {
- intCall |= IMAGE_CEE_CS_CALLCONV_GENERIC;
- }
-
- if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis)
- intCall |= IMAGE_CEE_CS_CALLCONV_HASTHIS;
-
- sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
- sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
-
- return sigHelp;
- }
-
- public static SignatureHelper GetMethodSigHelper(Module mod, CallingConvention unmanagedCallConv, Type returnType)
- {
- SignatureHelper sigHelp;
- int intCall;
-
- if (returnType == null)
- returnType = typeof(void);
-
- if (unmanagedCallConv == CallingConvention.Cdecl) {
- intCall = IMAGE_CEE_UNMANAGED_CALLCONV_C;
- }
- else if (unmanagedCallConv == CallingConvention.StdCall || unmanagedCallConv == CallingConvention.Winapi) {
- intCall = IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL;
- }
- else if (unmanagedCallConv == CallingConvention.ThisCall) {
- intCall = IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL;
- }
- else if (unmanagedCallConv == CallingConvention.FastCall) {
- intCall = IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL;
- }
- else {
- throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), "unmanagedCallConv");
- }
-
- sigHelp = new SignatureHelper(mod, intCall, returnType, null, null);
-
- return sigHelp;
- }
-
- public static SignatureHelper GetLocalVarSigHelper()
- {
- return GetLocalVarSigHelper(null);
- }
-
- public static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type returnType)
- {
- return GetMethodSigHelper(null, callingConvention, returnType);
- }
-
- public static SignatureHelper GetMethodSigHelper(CallingConvention unmanagedCallingConvention, Type returnType)
- {
- return GetMethodSigHelper(null, unmanagedCallingConvention, returnType);
- }
-
- public static SignatureHelper GetLocalVarSigHelper(Module mod)
- {
- return new SignatureHelper(mod, IMAGE_CEE_CS_CALLCONV_LOCAL_SIG);
- }
-
- public static SignatureHelper GetFieldSigHelper(Module mod)
- {
- return new SignatureHelper(mod, IMAGE_CEE_CS_CALLCONV_FIELD);
- }
-
- public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes)
- {
- return GetPropertySigHelper(mod, returnType, null, null, parameterTypes, null, null);
- }
-
- public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
- {
- SignatureHelper sigHelp;
-
- if (returnType == null) {
- returnType = typeof(void);
- }
-
- sigHelp = new SignatureHelper(mod, IMAGE_CEE_CS_CALLCONV_PROPERTY, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
- sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
-
- return sigHelp;
- }
-
- static internal SignatureHelper GetTypeSigToken(Module mod, Type type)
- {
- if (mod == null)
- throw new ArgumentNullException("module");
-
- if (type == null)
- throw new ArgumentNullException("type");
-
- return new SignatureHelper(mod, type);
- }
- #endregion
-
- #region Private Data Members
- private byte[] m_signature;
- private int m_currSig;
-
- private int m_sizeLoc;
-
- private ModuleBuilder m_module;
- private bool m_sigDone;
- private int m_argCount;
-
- #endregion
- #region Constructor
- private SignatureHelper(Module mod, int callingConvention)
- {
-
- Init(mod, callingConvention);
- }
-
- private SignatureHelper(Module mod, int callingConvention, int cGenericParameters, Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
- {
-
- Init(mod, callingConvention, cGenericParameters);
-
- if (callingConvention == IMAGE_CEE_CS_CALLCONV_FIELD)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldSig"));
-
- AddOneArgTypeHelper(returnType, requiredCustomModifiers, optionalCustomModifiers);
- }
-
- private SignatureHelper(Module mod, int callingConvention, Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) : this(mod, callingConvention, 0, returnType, requiredCustomModifiers, optionalCustomModifiers)
- {
- }
-
- private SignatureHelper(Module mod, Type type)
- {
- Init(mod);
-
- AddOneArgTypeHelper(type);
- }
-
- private void Init(Module mod)
- {
- m_signature = new byte[32];
- m_currSig = 0;
- m_module = mod as ModuleBuilder;
- m_argCount = 0;
- m_sigDone = false;
- m_sizeLoc = NO_SIZE_IN_SIG;
-
- if (m_module == null && mod != null)
- throw new ArgumentException(Environment.GetResourceString("NotSupported_MustBeModuleBuilder"));
- }
-
- private void Init(Module mod, int callingConvention)
- {
- Init(mod, callingConvention, 0);
- }
-
- private void Init(Module mod, int callingConvention, int cGenericParam)
- {
- Init(mod);
-
- AddData(callingConvention);
-
- if (callingConvention == IMAGE_CEE_CS_CALLCONV_FIELD || callingConvention == IMAGE_CEE_CS_CALLCONV_GENERICINST) {
- m_sizeLoc = NO_SIZE_IN_SIG;
- }
- else {
- if (cGenericParam > 0)
- AddData(cGenericParam);
-
- m_sizeLoc = m_currSig++;
- }
- }
-
- #endregion
-
- #region Private Members
- private void AddOneArgTypeHelper(Type argument, bool pinned)
- {
- if (pinned)
- AddElementType(ELEMENT_TYPE_PINNED);
-
- AddOneArgTypeHelper(argument);
- }
-
- private void AddOneArgTypeHelper(Type clsArgument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
- {
-
-
-
- ASSERT.PRECONDITION(clsArgument != null);
- ASSERT.PRECONDITION((optionalCustomModifiers == null && requiredCustomModifiers == null) || !clsArgument.ContainsGenericParameters);
- ASSERT.PRECONDITION(requiredCustomModifiers == null || Array.IndexOf(requiredCustomModifiers, null) == -1);
- ASSERT.PRECONDITION(optionalCustomModifiers == null || Array.IndexOf(optionalCustomModifiers, null) == -1);
-
- if (optionalCustomModifiers != null) {
- for (int i = 0; i < optionalCustomModifiers.Length; i++) {
- AddElementType(ELEMENT_TYPE_CMOD_OPT);
- ASSERT.CONSISTENCY_CHECK(!MetadataToken.IsNullToken(optionalCustomModifiers[i].MetadataTokenInternal));
- AddToken(m_module.GetTypeToken(optionalCustomModifiers[i]).Token);
- }
- }
-
- if (requiredCustomModifiers != null) {
- for (int i = 0; i < requiredCustomModifiers.Length; i++) {
- AddElementType(ELEMENT_TYPE_CMOD_REQD);
- ASSERT.CONSISTENCY_CHECK(!MetadataToken.IsNullToken(requiredCustomModifiers[i].MetadataTokenInternal));
- AddToken(m_module.GetTypeToken(requiredCustomModifiers[i]).Token);
- }
- }
-
- AddOneArgTypeHelper(clsArgument);
- }
-
- private void AddOneArgTypeHelper(Type clsArgument)
- {
- AddOneArgTypeHelperWorker(clsArgument, false);
- }
- private void AddOneArgTypeHelperWorker(Type clsArgument, bool lastWasGenericInst)
- {
- if (clsArgument.IsGenericParameter) {
- if (clsArgument.DeclaringMethod != null)
- AddData(ELEMENT_TYPE_MVAR);
- else
- AddData(ELEMENT_TYPE_VAR);
-
- AddData(clsArgument.GenericParameterPosition);
- }
- else if (clsArgument.IsGenericType && (!clsArgument.IsGenericTypeDefinition || !lastWasGenericInst)) {
- AddElementType(ELEMENT_TYPE_GENERICINST);
-
- AddOneArgTypeHelperWorker(clsArgument.GetGenericTypeDefinition(), true);
-
- Type[] args = clsArgument.GetGenericArguments();
-
- AddData(args.Length);
-
- foreach (Type t in args)
- AddOneArgTypeHelper(t);
- }
- else if (clsArgument is TypeBuilder) {
- TypeBuilder clsBuilder = (TypeBuilder)clsArgument;
- TypeToken tkType;
-
- if (clsBuilder.Module == m_module) {
- tkType = clsBuilder.TypeToken;
- }
- else {
- tkType = m_module.GetTypeToken(clsArgument);
- }
-
- if (clsArgument.IsValueType) {
- InternalAddTypeToken(tkType, ELEMENT_TYPE_VALUETYPE);
- }
- else {
- InternalAddTypeToken(tkType, ELEMENT_TYPE_CLASS);
- }
- }
- else if (clsArgument is EnumBuilder) {
- TypeBuilder clsBuilder = ((EnumBuilder)clsArgument).m_typeBuilder;
- TypeToken tkType;
-
- if (clsBuilder.Module == m_module) {
- tkType = clsBuilder.TypeToken;
- }
- else {
- tkType = m_module.GetTypeToken(clsArgument);
- }
-
- if (clsArgument.IsValueType) {
- InternalAddTypeToken(tkType, ELEMENT_TYPE_VALUETYPE);
- }
- else {
- InternalAddTypeToken(tkType, ELEMENT_TYPE_CLASS);
- }
- }
- else if (clsArgument.IsByRef) {
- AddElementType(ELEMENT_TYPE_BYREF);
- clsArgument = clsArgument.GetElementType();
- AddOneArgTypeHelper(clsArgument);
- }
- else if (clsArgument.IsPointer) {
- AddElementType(ELEMENT_TYPE_PTR);
- AddOneArgTypeHelper(clsArgument.GetElementType());
- }
- else if (clsArgument.IsArray) {
- if (clsArgument.IsSzArray) {
- AddElementType(ELEMENT_TYPE_SZARRAY);
-
- AddOneArgTypeHelper(clsArgument.GetElementType());
- }
- else {
- AddElementType(ELEMENT_TYPE_ARRAY);
-
- AddOneArgTypeHelper(clsArgument.GetElementType());
-
-
- AddData(clsArgument.GetArrayRank());
-
- AddData(0);
- AddData(0);
- }
- }
- else {
- RuntimeType rType = clsArgument as RuntimeType;
- int type = rType != null ? GetCorElementTypeFromClass(rType) : ELEMENT_TYPE_MAX;
-
- if (IsSimpleType(type)) {
- AddElementType(type);
- }
- else {
- if (clsArgument == typeof(object)) {
- AddElementType(ELEMENT_TYPE_OBJECT);
- }
- else if (clsArgument == typeof(string)) {
- AddElementType(ELEMENT_TYPE_STRING);
- }
- else {
- if (m_module == null) {
- InternalAddRuntimeType(rType);
- }
- else {
- if (clsArgument.IsValueType) {
- InternalAddTypeToken(m_module.GetTypeToken(clsArgument), ELEMENT_TYPE_VALUETYPE);
- }
- else {
- InternalAddTypeToken(m_module.GetTypeToken(clsArgument), ELEMENT_TYPE_CLASS);
- }
- }
- }
- }
- }
- }
-
- private void AddData(int data)
- {
-
-
- if (m_currSig + 4 >= m_signature.Length) {
- m_signature = ExpandArray(m_signature);
- }
-
- if (data <= 127) {
- m_signature[m_currSig++] = (byte)(data & 255);
- }
- else if (data <= 16383) {
- m_signature[m_currSig++] = (byte)((data >> 8) | 128);
- m_signature[m_currSig++] = (byte)(data & 255);
- }
- else if (data <= 536870911) {
- m_signature[m_currSig++] = (byte)((data >> 24) | 192);
- m_signature[m_currSig++] = (byte)((data >> 16) & 255);
- m_signature[m_currSig++] = (byte)((data >> 8) & 255);
- m_signature[m_currSig++] = (byte)((data)&255);
- }
- else {
- throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger"));
- }
-
- }
-
- private void AddData(uint data)
- {
- if (m_currSig + 4 >= m_signature.Length) {
- m_signature = ExpandArray(m_signature);
- }
-
- m_signature[m_currSig++] = (byte)((data)&255);
- m_signature[m_currSig++] = (byte)((data >> 8) & 255);
- m_signature[m_currSig++] = (byte)((data >> 16) & 255);
- m_signature[m_currSig++] = (byte)((data >> 24) & 255);
- }
-
- private void AddData(ulong data)
- {
- if (m_currSig + 8 >= m_signature.Length) {
- m_signature = ExpandArray(m_signature);
- }
-
- m_signature[m_currSig++] = (byte)((data)&255);
- m_signature[m_currSig++] = (byte)((data >> 8) & 255);
- m_signature[m_currSig++] = (byte)((data >> 16) & 255);
- m_signature[m_currSig++] = (byte)((data >> 24) & 255);
- m_signature[m_currSig++] = (byte)((data >> 32) & 255);
- m_signature[m_currSig++] = (byte)((data >> 40) & 255);
- m_signature[m_currSig++] = (byte)((data >> 48) & 255);
- m_signature[m_currSig++] = (byte)((data >> 56) & 255);
- }
-
- private void AddElementType(int cvt)
- {
-
- if (m_currSig + 1 >= m_signature.Length)
- m_signature = ExpandArray(m_signature);
-
- m_signature[m_currSig++] = (byte)cvt;
- }
-
- private void AddToken(int token)
- {
-
-
-
-
- int rid = (token & 16777215);
-
- int type = (token & unchecked((int)4278190080u));
-
- if (rid > 67108863) {
-
- throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger"));
- }
-
- rid = (rid << 2);
-
-
-
-
- if (type == mdtTypeRef) {
-
- rid |= 1;
- }
- else if (type == mdtTypeSpec) {
-
- rid |= 2;
- }
-
- AddData(rid);
- }
-
- private void InternalAddTypeToken(TypeToken clsToken, int CorType)
- {
-
- AddElementType(CorType);
- AddToken(clsToken.Token);
- }
-
- unsafe private void InternalAddRuntimeType(Type type)
- {
-
-
- AddElementType(ELEMENT_TYPE_INTERNAL);
- }
-
- void* handle = (void*)type.GetTypeHandleInternal().Value;
- }
- }