From: Marcos Henrich Date: Thu, 28 May 2015 14:59:21 +0000 (+0100) Subject: [SRE] Fixes GetMethodToken GetConstructorToken. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=bb139b85cdf3dce1b14ad95dd598a07f7e36b048;p=mono.git [SRE] Fixes GetMethodToken GetConstructorToken. ModuleBuilder.GetMethodToken and ModuleBuilder.GetConstructorToken. no longer crash when called with a null optionalParameterTypes. --- diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs index d798089dcb5..f9caf2cbf3f 100644 --- a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs @@ -592,8 +592,7 @@ namespace System.Reflection.Emit { if (method == null) throw new ArgumentNullException ("method"); - var optParamTypes = new List (optionalParameterTypes); - return new MethodToken (GetToken (method, optParamTypes.ToArray ())); + return new MethodToken (GetToken (method, optionalParameterTypes)); } public MethodToken GetArrayMethodToken (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) @@ -618,8 +617,7 @@ namespace System.Reflection.Emit { if (con.DeclaringType.Module != this) throw new InvalidOperationException ("The constructor is not in this module"); - var optParamTypes = new List (optionalParameterTypes); - return new MethodToken (GetToken (constructor, optParamTypes.ToArray ())); + return new MethodToken (GetToken (constructor, optionalParameterTypes)); } public FieldToken GetFieldToken (FieldInfo field) @@ -696,6 +694,14 @@ namespace System.Reflection.Emit { return getToken (this, member, create_open_instance); } + internal int GetToken (MethodBase method, IEnumerable opt_param_types) { + if (opt_param_types == null) + return getToken (this, method, true); + + var optParamTypes = new List (opt_param_types); + return getMethodToken (this, method, optParamTypes.ToArray ()); + } + internal int GetToken (MethodBase method, Type[] opt_param_types) { return getMethodToken (this, method, opt_param_types); }