using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Reflection.Emit { /// Provides methods for building signatures. // Token: 0x02000216 RID: 534 [ClassInterface(ClassInterfaceType.None)] [ComDefaultInterface(typeof(_SignatureHelper))] [ComVisible(true)] public sealed class SignatureHelper : _SignatureHelper { // Token: 0x06001C27 RID: 7207 RVA: 0x0006A2B4 File Offset: 0x000684B4 internal SignatureHelper(ModuleBuilder module, SignatureHelper.SignatureHelperType type) { this.type = type; this.module = module; } /// Maps a set of names to a corresponding set of dispatch identifiers. /// Reserved for future use. Must be IID_NULL. /// Passed-in array of names to be mapped. /// Count of the names to be mapped. /// The locale context in which to interpret the names. /// Caller-allocated array which receives the IDs corresponding to the names. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001C28 RID: 7208 RVA: 0x0006A2CC File Offset: 0x000684CC void _SignatureHelper.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId) { throw new NotImplementedException(); } /// Retrieves the type information for an object, which can then be used to get the type information for an interface. /// The type information to return. /// The locale identifier for the type information. /// Receives a pointer to the requested type information object. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001C29 RID: 7209 RVA: 0x0006A2D4 File Offset: 0x000684D4 void _SignatureHelper.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo) { throw new NotImplementedException(); } /// Retrieves the number of type information interfaces that an object provides (either 0 or 1). /// Points to a location that receives the number of type information interfaces provided by the object. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001C2A RID: 7210 RVA: 0x0006A2DC File Offset: 0x000684DC void _SignatureHelper.GetTypeInfoCount(out uint pcTInfo) { throw new NotImplementedException(); } /// Provides access to properties and methods exposed by an object. /// Identifies the member. /// Reserved for future use. Must be IID_NULL. /// The locale context in which to interpret arguments. /// Flags describing the context of the call. /// Pointer to a structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays. /// Pointer to the location where the result is to be stored. /// Pointer to a structure that contains exception information. /// The index of the first argument that has an error. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001C2B RID: 7211 RVA: 0x0006A2E4 File Offset: 0x000684E4 void _SignatureHelper.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr) { throw new NotImplementedException(); } /// Returns a signature helper for a field. /// The SignatureHelper object for a field. /// The dynamic module that contains the field for which the SignatureHelper is requested. // Token: 0x06001C2C RID: 7212 RVA: 0x0006A2EC File Offset: 0x000684EC public static SignatureHelper GetFieldSigHelper(Module mod) { if (mod != null && !(mod is ModuleBuilder)) { throw new ArgumentException("ModuleBuilder is expected"); } return new SignatureHelper((ModuleBuilder)mod, SignatureHelper.SignatureHelperType.HELPER_FIELD); } /// Returns a signature helper for a local variable. /// The SignatureHelper object for a local variable. /// The dynamic module that contains the local variable for which the SignatureHelper is requested. // Token: 0x06001C2D RID: 7213 RVA: 0x0006A324 File Offset: 0x00068524 public static SignatureHelper GetLocalVarSigHelper(Module mod) { if (mod != null && !(mod is ModuleBuilder)) { throw new ArgumentException("ModuleBuilder is expected"); } return new SignatureHelper((ModuleBuilder)mod, SignatureHelper.SignatureHelperType.HELPER_LOCAL); } /// Returns a signature helper for a local variable. /// A for a local variable. // Token: 0x06001C2E RID: 7214 RVA: 0x0006A35C File Offset: 0x0006855C public static SignatureHelper GetLocalVarSigHelper() { return new SignatureHelper(null, SignatureHelper.SignatureHelperType.HELPER_LOCAL); } /// Returns a signature helper for a method given the method's calling convention and return type. /// The SignatureHelper object for a method. /// The calling convention of the method. /// The return type of the method, or null for a void return type (Sub procedure in Visual Basic). // Token: 0x06001C2F RID: 7215 RVA: 0x0006A368 File Offset: 0x00068568 public static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type returnType) { return SignatureHelper.GetMethodSigHelper(null, callingConvention, (CallingConvention)0, returnType, null); } /// Returns a signature helper for a method given the method's unmanaged calling convention and return type. /// The SignatureHelper object for a method. /// The unmanaged calling convention of the method. /// The return type of the method, or null for a void return type (Sub procedure in Visual Basic). /// /// is an unknown unmanaged calling convention. // Token: 0x06001C30 RID: 7216 RVA: 0x0006A374 File Offset: 0x00068574 public static SignatureHelper GetMethodSigHelper(CallingConvention unmanagedCallingConvention, Type returnType) { return SignatureHelper.GetMethodSigHelper(null, CallingConventions.Standard, unmanagedCallingConvention, returnType, null); } /// Returns a signature helper for a method given the method's module, calling convention, and return type. /// The SignatureHelper object for a method. /// The that contains the method for which the SignatureHelper is requested. /// The calling convention of the method. /// The return type of the method, or null for a void return type (Sub procedure in Visual Basic). /// /// is null. /// /// is not a . // Token: 0x06001C31 RID: 7217 RVA: 0x0006A380 File Offset: 0x00068580 public static SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, Type returnType) { return SignatureHelper.GetMethodSigHelper(mod, callingConvention, (CallingConvention)0, returnType, null); } /// Returns a signature helper for a method given the method's module, unmanaged calling convention, and return type. /// The SignatureHelper object for a method. /// The that contains the method for which the SignatureHelper is requested. /// The unmanaged calling convention of the method. /// The return type of the method, or null for a void return type (Sub procedure in Visual Basic). /// /// is null. /// /// is not a .-or- is an unknown unmanaged calling convention. // Token: 0x06001C32 RID: 7218 RVA: 0x0006A38C File Offset: 0x0006858C public static SignatureHelper GetMethodSigHelper(Module mod, CallingConvention unmanagedCallConv, Type returnType) { return SignatureHelper.GetMethodSigHelper(mod, CallingConventions.Standard, unmanagedCallConv, returnType, null); } /// Returns a signature helper for a method with a standard calling convention, given the method's module, return type, and argument types. /// The SignatureHelper object for a method. /// The that contains the method for which the SignatureHelper is requested. /// The return type of the method, or null for a void return type (Sub procedure in Visual Basic). /// The types of the arguments of the method, or null if the method has no arguments. /// /// is null.-or-An element of is null. /// /// is not a . // Token: 0x06001C33 RID: 7219 RVA: 0x0006A398 File Offset: 0x00068598 public static SignatureHelper GetMethodSigHelper(Module mod, Type returnType, Type[] parameterTypes) { return SignatureHelper.GetMethodSigHelper(mod, CallingConventions.Standard, (CallingConvention)0, returnType, parameterTypes); } /// Returns a signature helper for a property, given the dynamic module that contains the property, the property type, and the property arguments. /// A object for a property. /// The that contains the property for which the is requested. /// The property type. /// The argument types, or null if the property has no arguments. /// /// is null.-or-An element of is null. /// /// is not a . // Token: 0x06001C34 RID: 7220 RVA: 0x0006A3A4 File Offset: 0x000685A4 [MonoTODO("Not implemented")] public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes) { throw new NotImplementedException(); } // Token: 0x06001C35 RID: 7221 RVA: 0x0006A3AC File Offset: 0x000685AC private static int AppendArray(ref Type[] array, Type t) { if (array != null) { Type[] array2 = new Type[array.Length + 1]; Array.Copy(array, array2, array.Length); array2[array.Length] = t; array = array2; return array.Length - 1; } array = new Type[1]; array[0] = t; return 0; } // Token: 0x06001C36 RID: 7222 RVA: 0x0006A3F8 File Offset: 0x000685F8 private static void AppendArrayAt(ref Type[][] array, Type[] t, int pos) { int num = Math.Max(pos, (array != null) ? array.Length : 0); Type[][] array2 = new Type[num + 1][]; if (array != null) { Array.Copy(array, array2, num); } array2[pos] = t; array = array2; } // Token: 0x06001C37 RID: 7223 RVA: 0x0006A440 File Offset: 0x00068640 private static void ValidateParameterModifiers(string name, Type[] parameter_modifiers) { foreach (Type type in parameter_modifiers) { if (type == null) { throw new ArgumentNullException(name); } if (type.IsArray) { throw new ArgumentException(Locale.GetText("Array type not permitted"), name); } if (type.ContainsGenericParameters) { throw new ArgumentException(Locale.GetText("Open Generic Type not permitted"), name); } } } // Token: 0x06001C38 RID: 7224 RVA: 0x0006A4AC File Offset: 0x000686AC private static void ValidateCustomModifier(int n, Type[][] custom_modifiers, string name) { if (custom_modifiers == null) { return; } if (custom_modifiers.Length != n) { throw new ArgumentException(Locale.GetText(string.Format("Custom modifiers length `{0}' does not match the size of the arguments", new object[0]))); } foreach (Type[] array in custom_modifiers) { if (array != null) { SignatureHelper.ValidateParameterModifiers(name, array); } } } // Token: 0x06001C39 RID: 7225 RVA: 0x0006A510 File Offset: 0x00068710 private static Exception MissingFeature() { throw new NotImplementedException("Mono does not currently support setting modOpt/modReq through SignatureHelper"); } /// Adds a set of arguments to the signature, with the specified custom modifiers. /// The types of the arguments to be added. /// An array of arrays of types. Each array of types represents the required custom modifiers for the corresponding argument, such as or . If a particular argument has no required custom modifiers, specify null instead of an array of types. If none of the arguments have required custom modifiers, specify null instead of an array of arrays. /// An array of arrays of types. Each array of types represents the optional custom modifiers for the corresponding argument, such as or . If a particular argument has no optional custom modifiers, specify null instead of an array of types. If none of the arguments have optional custom modifiers, specify null instead of an array of arrays. /// An element of is null. -or-One of the specified custom modifiers is null. (However, null can be specified for the array of custom modifiers for any argument.) /// The signature has already been finished. -or-One of the specified custom modifiers is an array type.-or-One of the specified custom modifiers is an open generic type. That is, the property is true for the custom modifier. -or-The size of or does not equal the size of . // Token: 0x06001C3A RID: 7226 RVA: 0x0006A51C File Offset: 0x0006871C [MonoTODO("Currently we ignore requiredCustomModifiers and optionalCustomModifiers")] public void AddArguments(Type[] arguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) { if (arguments == null) { throw new ArgumentNullException("arguments"); } if (requiredCustomModifiers != null || optionalCustomModifiers != null) { throw SignatureHelper.MissingFeature(); } SignatureHelper.ValidateCustomModifier(arguments.Length, requiredCustomModifiers, "requiredCustomModifiers"); SignatureHelper.ValidateCustomModifier(arguments.Length, optionalCustomModifiers, "optionalCustomModifiers"); for (int i = 0; i < arguments.Length; i++) { this.AddArgument(arguments[i], (requiredCustomModifiers == null) ? null : requiredCustomModifiers[i], (optionalCustomModifiers == null) ? null : optionalCustomModifiers[i]); } } /// Adds an argument of the specified type to the signature, specifying whether the argument is pinned. /// The argument type. /// true if the argument is pinned; otherwise, false. /// /// is null. // Token: 0x06001C3B RID: 7227 RVA: 0x0006A5A4 File Offset: 0x000687A4 [MonoTODO("pinned is ignored")] public void AddArgument(Type argument, bool pinned) { this.AddArgument(argument); } /// Adds an argument to the signature, with the specified custom modifiers. /// The argument type. /// An array of types representing the required custom modifiers for the argument, such as or . If the argument has no required custom modifiers, specify null. /// An array of types representing the optional custom modifiers for the argument, such as or . If the argument has no optional custom modifiers, specify null. /// /// is null. -or-An element of or is null. /// The signature has already been finished. -or-One of the specified custom modifiers is an array type.-or-One of the specified custom modifiers is an open generic type. That is, the property is true for the custom modifier. // Token: 0x06001C3C RID: 7228 RVA: 0x0006A5B0 File Offset: 0x000687B0 public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) { if (argument == null) { throw new ArgumentNullException("argument"); } if (requiredCustomModifiers != null) { SignatureHelper.ValidateParameterModifiers("requiredCustomModifiers", requiredCustomModifiers); } if (optionalCustomModifiers != null) { SignatureHelper.ValidateParameterModifiers("optionalCustomModifiers", optionalCustomModifiers); } int num = SignatureHelper.AppendArray(ref this.arguments, argument); if (requiredCustomModifiers != null) { SignatureHelper.AppendArrayAt(ref this.modreqs, requiredCustomModifiers, num); } if (optionalCustomModifiers != null) { SignatureHelper.AppendArrayAt(ref this.modopts, optionalCustomModifiers, num); } } /// Returns a signature helper for a property, given the dynamic module that contains the property, the property type, the property arguments, and custom modifiers for the return type and arguments. /// A object for a property. /// The that contains the property for which the is requested. /// The property type. /// An array of types representing the required custom modifiers for the return type, such as or . If the return type has no required custom modifiers, specify null. /// An array of types representing the optional custom modifiers for the return type, such as or . If the return type has no optional custom modifiers, specify null. /// The types of the property's arguments, or null if the property has no arguments. /// An array of arrays of types. Each array of types represents the required custom modifiers for the corresponding argument of the property. If a particular argument has no required custom modifiers, specify null instead of an array of types. If the property has no arguments, or if none of the arguments have required custom modifiers, specify null instead of an array of arrays. /// An array of arrays of types. Each array of types represents the optional custom modifiers for the corresponding argument of the property. If a particular argument has no optional custom modifiers, specify null instead of an array of types. If the property has no arguments, or if none of the arguments have optional custom modifiers, specify null instead of an array of arrays. /// /// is null.-or-An element of is null. -or-One of the specified custom modifiers is null. (However, null can be specified for the array of custom modifiers for any argument.) /// The signature has already been finished. -or- is not a .-or-One of the specified custom modifiers is an array type.-or-One of the specified custom modifiers is an open generic type. That is, the property is true for the custom modifier.-or-The size of or does not equal the size of . // Token: 0x06001C3D RID: 7229 RVA: 0x0006A624 File Offset: 0x00068824 [MonoTODO("Not implemented")] public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { throw new NotImplementedException(); } /// Adds an argument to the signature. /// The type of the argument. /// The signature has already been finished. /// /// is null. // Token: 0x06001C3E RID: 7230 RVA: 0x0006A62C File Offset: 0x0006882C public void AddArgument(Type clsArgument) { if (clsArgument == null) { throw new ArgumentNullException("clsArgument"); } SignatureHelper.AppendArray(ref this.arguments, clsArgument); } /// Marks the end of a vararg fixed part. This is only used if the caller is creating a vararg signature call site. // Token: 0x06001C3F RID: 7231 RVA: 0x0006A64C File Offset: 0x0006884C [MonoTODO("Not implemented")] public void AddSentinel() { throw new NotImplementedException(); } // Token: 0x06001C40 RID: 7232 RVA: 0x0006A654 File Offset: 0x00068854 private static bool CompareOK(Type[][] one, Type[][] two) { if (one == null) { return two == null; } if (two == null) { return false; } if (one.Length != two.Length) { return false; } int i = 0; while (i < one.Length) { Type[] array = one[i]; Type[] array2 = two[i]; if (array == null) { if (array2 != null) { goto IL_52; } } else { if (array2 == null) { return false; } goto IL_52; } IL_AB: i++; continue; IL_52: if (array.Length != array2.Length) { return false; } for (int j = 0; j < array.Length; j++) { Type type = array[j]; Type type2 = array2[j]; if (type == null) { if (type2 != null) { return false; } } else { if (type2 == null) { return false; } if (!type.Equals(type2)) { return false; } } } goto IL_AB; } return true; } /// Checks if this instance is equal to the given object. /// true if the given object is a SignatureHelper and represents the same signature; otherwise, false. /// The object with which this instance should be compared. // Token: 0x06001C41 RID: 7233 RVA: 0x0006A71C File Offset: 0x0006891C public override bool Equals(object obj) { SignatureHelper signatureHelper = obj as SignatureHelper; if (signatureHelper == null) { return false; } if (signatureHelper.module != this.module || signatureHelper.returnType != this.returnType || signatureHelper.callConv != this.callConv || signatureHelper.unmanagedCallConv != this.unmanagedCallConv) { return false; } if (this.arguments != null) { if (signatureHelper.arguments == null) { return false; } if (this.arguments.Length != signatureHelper.arguments.Length) { return false; } for (int i = 0; i < this.arguments.Length; i++) { if (!signatureHelper.arguments[i].Equals(this.arguments[i])) { return false; } } } else if (signatureHelper.arguments != null) { return false; } return SignatureHelper.CompareOK(signatureHelper.modreqs, this.modreqs) && SignatureHelper.CompareOK(signatureHelper.modopts, this.modopts); } /// Creates and returns a hash code for this instance. /// Returns the hash code based on the name. // Token: 0x06001C42 RID: 7234 RVA: 0x0006A820 File Offset: 0x00068A20 public override int GetHashCode() { return 0; } // Token: 0x06001C43 RID: 7235 [MethodImpl(MethodImplOptions.InternalCall)] internal extern byte[] get_signature_local(); // Token: 0x06001C44 RID: 7236 [MethodImpl(MethodImplOptions.InternalCall)] internal extern byte[] get_signature_field(); /// Adds the end token to the signature and marks the signature as finished, so no further tokens can be added. /// Returns a byte array made up of the full signature. // Token: 0x06001C45 RID: 7237 RVA: 0x0006A824 File Offset: 0x00068A24 public byte[] GetSignature() { SignatureHelper.SignatureHelperType signatureHelperType = this.type; if (signatureHelperType == SignatureHelper.SignatureHelperType.HELPER_FIELD) { return this.get_signature_field(); } if (signatureHelperType != SignatureHelper.SignatureHelperType.HELPER_LOCAL) { throw new NotImplementedException(); } return this.get_signature_local(); } /// Returns a string representing the signature arguments. /// Returns a string representing the arguments of this signature. // Token: 0x06001C46 RID: 7238 RVA: 0x0006A860 File Offset: 0x00068A60 public override string ToString() { return "SignatureHelper"; } // Token: 0x06001C47 RID: 7239 RVA: 0x0006A868 File Offset: 0x00068A68 internal static SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, CallingConvention unmanagedCallingConvention, Type returnType, Type[] parameters) { if (mod != null && !(mod is ModuleBuilder)) { throw new ArgumentException("ModuleBuilder is expected"); } if (returnType == null) { returnType = typeof(void); } if (returnType.IsUserType) { throw new NotSupportedException("User defined subclasses of System.Type are not yet supported."); } if (parameters != null) { for (int i = 0; i < parameters.Length; i++) { if (parameters[i].IsUserType) { throw new NotSupportedException("User defined subclasses of System.Type are not yet supported."); } } } SignatureHelper signatureHelper = new SignatureHelper((ModuleBuilder)mod, SignatureHelper.SignatureHelperType.HELPER_METHOD); signatureHelper.returnType = returnType; signatureHelper.callConv = callingConvention; signatureHelper.unmanagedCallConv = unmanagedCallingConvention; if (parameters != null) { signatureHelper.arguments = new Type[parameters.Length]; for (int j = 0; j < parameters.Length; j++) { signatureHelper.arguments[j] = parameters[j]; } } return signatureHelper; } // Token: 0x0400097E RID: 2430 private ModuleBuilder module; // Token: 0x0400097F RID: 2431 private Type[] arguments; // Token: 0x04000980 RID: 2432 private SignatureHelper.SignatureHelperType type; // Token: 0x04000981 RID: 2433 private Type returnType; // Token: 0x04000982 RID: 2434 private CallingConventions callConv; // Token: 0x04000983 RID: 2435 private CallingConvention unmanagedCallConv; // Token: 0x04000984 RID: 2436 private Type[][] modreqs; // Token: 0x04000985 RID: 2437 private Type[][] modopts; // Token: 0x02000217 RID: 535 internal enum SignatureHelperType { // Token: 0x04000987 RID: 2439 HELPER_FIELD, // Token: 0x04000988 RID: 2440 HELPER_LOCAL, // Token: 0x04000989 RID: 2441 HELPER_METHOD, // Token: 0x0400098A RID: 2442 HELPER_PROPERTY } } }