MonoMethod.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. //
  2. // MonoMethod.cs: The class used to represent methods from the mono runtime.
  3. //
  4. // Authors:
  5. // Paolo Molaro ([email protected])
  6. // Marek Safar ([email protected])
  7. //
  8. // (C) 2001 Ximian, Inc. http://www.ximian.com
  9. // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
  10. // Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System.Collections.Generic;
  32. using System.Globalization;
  33. using System.Runtime.CompilerServices;
  34. using System.Runtime.InteropServices;
  35. using System.Runtime.Serialization;
  36. #if !FULL_AOT_RUNTIME
  37. using System.Reflection.Emit;
  38. #endif
  39. using System.Security;
  40. using System.Threading;
  41. using System.Text;
  42. using System.Diagnostics;
  43. namespace System.Reflection {
  44. internal struct MonoMethodInfo
  45. {
  46. #pragma warning disable 649
  47. private Type parent;
  48. private Type ret;
  49. internal MethodAttributes attrs;
  50. internal MethodImplAttributes iattrs;
  51. private CallingConventions callconv;
  52. #pragma warning restore 649
  53. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  54. static extern void get_method_info (IntPtr handle, out MonoMethodInfo info);
  55. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  56. static extern int get_method_attributes (IntPtr handle);
  57. internal static MonoMethodInfo GetMethodInfo (IntPtr handle)
  58. {
  59. MonoMethodInfo info;
  60. MonoMethodInfo.get_method_info (handle, out info);
  61. return info;
  62. }
  63. internal static Type GetDeclaringType (IntPtr handle)
  64. {
  65. return GetMethodInfo (handle).parent;
  66. }
  67. internal static Type GetReturnType (IntPtr handle)
  68. {
  69. return GetMethodInfo (handle).ret;
  70. }
  71. internal static MethodAttributes GetAttributes (IntPtr handle)
  72. {
  73. return (MethodAttributes)get_method_attributes (handle);
  74. }
  75. internal static CallingConventions GetCallingConvention (IntPtr handle)
  76. {
  77. return GetMethodInfo (handle).callconv;
  78. }
  79. internal static MethodImplAttributes GetMethodImplementationFlags (IntPtr handle)
  80. {
  81. return GetMethodInfo (handle).iattrs;
  82. }
  83. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  84. static extern ParameterInfo[] get_parameter_info (IntPtr handle, MemberInfo member);
  85. static internal ParameterInfo[] GetParametersInfo (IntPtr handle, MemberInfo member)
  86. {
  87. return get_parameter_info (handle, member);
  88. }
  89. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  90. static extern MarshalAsAttribute get_retval_marshal (IntPtr handle);
  91. static internal ParameterInfo GetReturnParameterInfo (MonoMethod method)
  92. {
  93. return ParameterInfo.New (GetReturnType (method.mhandle), method, get_retval_marshal (method.mhandle));
  94. }
  95. };
  96. abstract class RuntimeMethodInfo : MethodInfo
  97. {
  98. internal BindingFlags BindingFlags {
  99. get {
  100. return 0;
  101. }
  102. }
  103. }
  104. /*
  105. * Note: most of this class needs to be duplicated for the contructor, since
  106. * the .NET reflection class hierarchy is so broken.
  107. */
  108. [Serializable()]
  109. [StructLayout (LayoutKind.Sequential)]
  110. internal class MonoMethod : RuntimeMethodInfo, ISerializable
  111. {
  112. #pragma warning disable 649
  113. internal IntPtr mhandle;
  114. string name;
  115. Type reftype;
  116. #pragma warning restore 649
  117. internal MonoMethod () {
  118. }
  119. internal MonoMethod (RuntimeMethodHandle mhandle) {
  120. this.mhandle = mhandle.Value;
  121. }
  122. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  123. internal static extern string get_name (MethodBase method);
  124. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  125. internal static extern MonoMethod get_base_method (MonoMethod method, bool definition);
  126. public override MethodInfo GetBaseDefinition ()
  127. {
  128. return get_base_method (this, true);
  129. }
  130. internal override MethodInfo GetBaseMethod ()
  131. {
  132. return get_base_method (this, false);
  133. }
  134. public override ParameterInfo ReturnParameter {
  135. get {
  136. return MonoMethodInfo.GetReturnParameterInfo (this);
  137. }
  138. }
  139. public override Type ReturnType {
  140. get {
  141. return MonoMethodInfo.GetReturnType (mhandle);
  142. }
  143. }
  144. public override ICustomAttributeProvider ReturnTypeCustomAttributes {
  145. get {
  146. return MonoMethodInfo.GetReturnParameterInfo (this);
  147. }
  148. }
  149. public override MethodImplAttributes GetMethodImplementationFlags ()
  150. {
  151. return MonoMethodInfo.GetMethodImplementationFlags (mhandle);
  152. }
  153. public override ParameterInfo[] GetParameters ()
  154. {
  155. var src = MonoMethodInfo.GetParametersInfo (mhandle, this);
  156. if (src.Length == 0)
  157. return src;
  158. // Have to clone because GetParametersInfo icall returns cached value
  159. var dest = new ParameterInfo [src.Length];
  160. Array.FastCopy (src, 0, dest, 0, src.Length);
  161. return dest;
  162. }
  163. internal override ParameterInfo[] GetParametersInternal ()
  164. {
  165. return MonoMethodInfo.GetParametersInfo (mhandle, this);
  166. }
  167. internal override int GetParametersCount ()
  168. {
  169. return MonoMethodInfo.GetParametersInfo (mhandle, this).Length;
  170. }
  171. /*
  172. * InternalInvoke() receives the parameters correctly converted by the
  173. * binder to match the types of the method signature.
  174. */
  175. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  176. internal extern Object InternalInvoke (Object obj, Object[] parameters, out Exception exc);
  177. [DebuggerHidden]
  178. [DebuggerStepThrough]
  179. public override Object Invoke (Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  180. {
  181. if (binder == null)
  182. binder = Type.DefaultBinder;
  183. /*Avoid allocating an array every time*/
  184. ParameterInfo[] pinfo = GetParametersInternal ();
  185. ConvertValues (binder, parameters, pinfo, culture, invokeAttr);
  186. #if !NET_2_1
  187. if (SecurityManager.SecurityEnabled) {
  188. // sadly Attributes doesn't tell us which kind of security action this is so
  189. // we must do it the hard way - and it also means that we can skip calling
  190. // Attribute (which is another an icall)
  191. SecurityManager.ReflectedLinkDemandInvoke (this);
  192. }
  193. #endif
  194. if (ContainsGenericParameters)
  195. throw new InvalidOperationException ("Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.");
  196. Exception exc;
  197. object o = null;
  198. try {
  199. // The ex argument is used to distinguish exceptions thrown by the icall
  200. // from the exceptions thrown by the called method (which need to be
  201. // wrapped in TargetInvocationException).
  202. o = InternalInvoke (obj, parameters, out exc);
  203. } catch (ThreadAbortException) {
  204. throw;
  205. #if NET_2_1
  206. } catch (MethodAccessException) {
  207. throw;
  208. #endif
  209. } catch (Exception e) {
  210. throw new TargetInvocationException (e);
  211. }
  212. if (exc != null)
  213. throw exc;
  214. return o;
  215. }
  216. internal static void ConvertValues (Binder binder, object[] args, ParameterInfo[] pinfo, CultureInfo culture, BindingFlags invokeAttr)
  217. {
  218. if (args == null) {
  219. if (pinfo.Length == 0)
  220. return;
  221. throw new TargetParameterCountException ();
  222. }
  223. if (pinfo.Length != args.Length)
  224. throw new TargetParameterCountException ();
  225. for (int i = 0; i < args.Length; ++i) {
  226. var arg = args [i];
  227. var pi = pinfo [i];
  228. if (arg == Type.Missing) {
  229. if (pi.DefaultValue == System.DBNull.Value)
  230. throw new ArgumentException(Environment.GetResourceString("Arg_VarMissNull"),"parameters");
  231. args [i] = pi.DefaultValue;
  232. continue;
  233. }
  234. var rt = (RuntimeType) pi.ParameterType;
  235. args [i] = rt.CheckValue (arg, binder, culture, invokeAttr);
  236. }
  237. }
  238. public override RuntimeMethodHandle MethodHandle {
  239. get {
  240. return new RuntimeMethodHandle (mhandle);
  241. }
  242. }
  243. public override MethodAttributes Attributes {
  244. get {
  245. return MonoMethodInfo.GetAttributes (mhandle);
  246. }
  247. }
  248. public override CallingConventions CallingConvention {
  249. get {
  250. return MonoMethodInfo.GetCallingConvention (mhandle);
  251. }
  252. }
  253. public override Type ReflectedType {
  254. get {
  255. return reftype;
  256. }
  257. }
  258. public override Type DeclaringType {
  259. get {
  260. return MonoMethodInfo.GetDeclaringType (mhandle);
  261. }
  262. }
  263. public override string Name {
  264. get {
  265. if (name != null)
  266. return name;
  267. return get_name (this);
  268. }
  269. }
  270. public override bool IsDefined (Type attributeType, bool inherit) {
  271. return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
  272. }
  273. public override object[] GetCustomAttributes( bool inherit) {
  274. return MonoCustomAttrs.GetCustomAttributes (this, inherit);
  275. }
  276. public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
  277. return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
  278. }
  279. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  280. internal static extern DllImportAttribute GetDllImportAttribute (IntPtr mhandle);
  281. internal object[] GetPseudoCustomAttributes ()
  282. {
  283. int count = 0;
  284. /* MS.NET doesn't report MethodImplAttribute */
  285. MonoMethodInfo info = MonoMethodInfo.GetMethodInfo (mhandle);
  286. if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
  287. count ++;
  288. if ((info.attrs & MethodAttributes.PinvokeImpl) != 0)
  289. count ++;
  290. if (count == 0)
  291. return null;
  292. object[] attrs = new object [count];
  293. count = 0;
  294. if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
  295. attrs [count ++] = new PreserveSigAttribute ();
  296. if ((info.attrs & MethodAttributes.PinvokeImpl) != 0) {
  297. DllImportAttribute attr = GetDllImportAttribute (mhandle);
  298. if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
  299. attr.PreserveSig = true;
  300. attrs [count ++] = attr;
  301. }
  302. return attrs;
  303. }
  304. public override string ToString () {
  305. StringBuilder sb = new StringBuilder ();
  306. Type retType = ReturnType;
  307. if (Type.ShouldPrintFullName (retType))
  308. sb.Append (retType.ToString ());
  309. else
  310. sb.Append (retType.Name);
  311. sb.Append (" ");
  312. sb.Append (Name);
  313. if (IsGenericMethod) {
  314. Type[] gen_params = GetGenericArguments ();
  315. sb.Append ("[");
  316. for (int j = 0; j < gen_params.Length; j++) {
  317. if (j > 0)
  318. sb.Append (",");
  319. sb.Append (gen_params [j].Name);
  320. }
  321. sb.Append ("]");
  322. }
  323. sb.Append ("(");
  324. var p = GetParametersInternal ();
  325. ParameterInfo.FormatParameters (sb, p);
  326. if ((CallingConvention & CallingConventions.VarArgs) != 0) {
  327. if (p.Length > 0)
  328. sb.Append (", ");
  329. sb.Append ("...");
  330. }
  331. sb.Append (")");
  332. return sb.ToString ();
  333. }
  334. // ISerializable
  335. public void GetObjectData(SerializationInfo info, StreamingContext context)
  336. {
  337. Type[] genericArguments = IsGenericMethod && !IsGenericMethodDefinition
  338. ? GetGenericArguments () : null;
  339. MemberInfoSerializationHolder.Serialize ( info, Name, ReflectedType, ToString(), MemberTypes.Method, genericArguments);
  340. }
  341. public override MethodInfo MakeGenericMethod (Type [] methodInstantiation)
  342. {
  343. if (methodInstantiation == null)
  344. throw new ArgumentNullException ("methodInstantiation");
  345. if (!IsGenericMethodDefinition)
  346. throw new InvalidOperationException ("not a generic method definition");
  347. /*FIXME add GetGenericArgumentsLength() internal vcall to speed this up*/
  348. if (GetGenericArguments ().Length != methodInstantiation.Length)
  349. throw new ArgumentException ("Incorrect length");
  350. bool hasUserType = false;
  351. foreach (Type type in methodInstantiation) {
  352. if (type == null)
  353. throw new ArgumentNullException ();
  354. if (!(type is MonoType))
  355. hasUserType = true;
  356. }
  357. if (hasUserType)
  358. #if FULL_AOT_RUNTIME
  359. throw new NotSupportedException ("User types are not supported under full aot");
  360. #else
  361. return new MethodOnTypeBuilderInst (this, methodInstantiation);
  362. #endif
  363. MethodInfo ret = MakeGenericMethod_impl (methodInstantiation);
  364. if (ret == null)
  365. throw new ArgumentException (String.Format ("The method has {0} generic parameter(s) but {1} generic argument(s) were provided.", GetGenericArguments ().Length, methodInstantiation.Length));
  366. return ret;
  367. }
  368. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  369. extern MethodInfo MakeGenericMethod_impl (Type [] types);
  370. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  371. public override extern Type [] GetGenericArguments ();
  372. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  373. extern MethodInfo GetGenericMethodDefinition_impl ();
  374. public override MethodInfo GetGenericMethodDefinition ()
  375. {
  376. MethodInfo res = GetGenericMethodDefinition_impl ();
  377. if (res == null)
  378. throw new InvalidOperationException ();
  379. return res;
  380. }
  381. public override extern bool IsGenericMethodDefinition {
  382. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  383. get;
  384. }
  385. public override extern bool IsGenericMethod {
  386. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  387. get;
  388. }
  389. public override bool ContainsGenericParameters {
  390. get {
  391. if (IsGenericMethod) {
  392. foreach (Type arg in GetGenericArguments ())
  393. if (arg.ContainsGenericParameters)
  394. return true;
  395. }
  396. return DeclaringType.ContainsGenericParameters;
  397. }
  398. }
  399. public override MethodBody GetMethodBody () {
  400. return GetMethodBody (mhandle);
  401. }
  402. public override IList<CustomAttributeData> GetCustomAttributesData () {
  403. return CustomAttributeData.GetCustomAttributes (this);
  404. }
  405. }
  406. abstract class RuntimeConstructorInfo : ConstructorInfo
  407. {
  408. internal BindingFlags BindingFlags {
  409. get {
  410. return 0;
  411. }
  412. }
  413. internal void SerializationInvoke (Object target, SerializationInfo info, StreamingContext context)
  414. {
  415. Invoke (target, new object[] { info, context });
  416. }
  417. }
  418. [Serializable()]
  419. [StructLayout (LayoutKind.Sequential)]
  420. internal class MonoCMethod : RuntimeConstructorInfo, ISerializable
  421. {
  422. #pragma warning disable 649
  423. internal IntPtr mhandle;
  424. string name;
  425. Type reftype;
  426. #pragma warning restore 649
  427. public override MethodImplAttributes GetMethodImplementationFlags ()
  428. {
  429. return MonoMethodInfo.GetMethodImplementationFlags (mhandle);
  430. }
  431. public override ParameterInfo[] GetParameters ()
  432. {
  433. return MonoMethodInfo.GetParametersInfo (mhandle, this);
  434. }
  435. internal override ParameterInfo[] GetParametersInternal ()
  436. {
  437. return MonoMethodInfo.GetParametersInfo (mhandle, this);
  438. }
  439. internal override int GetParametersCount ()
  440. {
  441. var pi = MonoMethodInfo.GetParametersInfo (mhandle, this);
  442. return pi == null ? 0 : pi.Length;
  443. }
  444. /*
  445. * InternalInvoke() receives the parameters correctly converted by the binder
  446. * to match the types of the method signature.
  447. */
  448. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  449. internal extern Object InternalInvoke (Object obj, Object[] parameters, out Exception exc);
  450. [DebuggerHidden]
  451. [DebuggerStepThrough]
  452. public override object Invoke (object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
  453. {
  454. if (obj == null) {
  455. if (!IsStatic)
  456. throw new TargetException ("Instance constructor requires a target");
  457. } else if (!DeclaringType.IsInstanceOfType (obj)) {
  458. throw new TargetException ("Constructor does not match target type");
  459. }
  460. return DoInvoke (obj, invokeAttr, binder, parameters, culture);
  461. }
  462. object DoInvoke (object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
  463. {
  464. if (binder == null)
  465. binder = Type.DefaultBinder;
  466. ParameterInfo[] pinfo = MonoMethodInfo.GetParametersInfo (mhandle, this);
  467. MonoMethod.ConvertValues (binder, parameters, pinfo, culture, invokeAttr);
  468. #if !NET_2_1
  469. if (SecurityManager.SecurityEnabled) {
  470. // sadly Attributes doesn't tell us which kind of security action this is so
  471. // we must do it the hard way - and it also means that we can skip calling
  472. // Attribute (which is another an icall)
  473. SecurityManager.ReflectedLinkDemandInvoke (this);
  474. }
  475. #endif
  476. if (obj == null && DeclaringType.ContainsGenericParameters)
  477. throw new MemberAccessException ("Cannot create an instance of " + DeclaringType + " because Type.ContainsGenericParameters is true.");
  478. if ((invokeAttr & BindingFlags.CreateInstance) != 0 && DeclaringType.IsAbstract) {
  479. throw new MemberAccessException (String.Format ("Cannot create an instance of {0} because it is an abstract class", DeclaringType));
  480. }
  481. return InternalInvoke (obj, parameters);
  482. }
  483. public object InternalInvoke (object obj, object[] parameters)
  484. {
  485. Exception exc;
  486. object o = null;
  487. try {
  488. o = InternalInvoke (obj, parameters, out exc);
  489. #if NET_2_1
  490. } catch (MethodAccessException) {
  491. throw;
  492. #endif
  493. } catch (Exception e) {
  494. throw new TargetInvocationException (e);
  495. }
  496. if (exc != null)
  497. throw exc;
  498. return obj == null ? o : null;
  499. }
  500. [DebuggerHidden]
  501. [DebuggerStepThrough]
  502. public override Object Invoke (BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  503. {
  504. return DoInvoke (null, invokeAttr, binder, parameters, culture);
  505. }
  506. public override RuntimeMethodHandle MethodHandle {
  507. get {
  508. return new RuntimeMethodHandle (mhandle);
  509. }
  510. }
  511. public override MethodAttributes Attributes {
  512. get {
  513. return MonoMethodInfo.GetAttributes (mhandle);
  514. }
  515. }
  516. public override CallingConventions CallingConvention {
  517. get {
  518. return MonoMethodInfo.GetCallingConvention (mhandle);
  519. }
  520. }
  521. public override bool ContainsGenericParameters {
  522. get {
  523. return DeclaringType.ContainsGenericParameters;
  524. }
  525. }
  526. public override Type ReflectedType {
  527. get {
  528. return reftype;
  529. }
  530. }
  531. public override Type DeclaringType {
  532. get {
  533. return MonoMethodInfo.GetDeclaringType (mhandle);
  534. }
  535. }
  536. public override string Name {
  537. get {
  538. if (name != null)
  539. return name;
  540. return MonoMethod.get_name (this);
  541. }
  542. }
  543. public override bool IsDefined (Type attributeType, bool inherit) {
  544. return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
  545. }
  546. public override object[] GetCustomAttributes( bool inherit) {
  547. return MonoCustomAttrs.GetCustomAttributes (this, inherit);
  548. }
  549. public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
  550. return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
  551. }
  552. public override MethodBody GetMethodBody () {
  553. return GetMethodBody (mhandle);
  554. }
  555. public override string ToString () {
  556. StringBuilder sb = new StringBuilder ();
  557. sb.Append ("Void ");
  558. sb.Append (Name);
  559. sb.Append ("(");
  560. ParameterInfo[] p = GetParameters ();
  561. for (int i = 0; i < p.Length; ++i) {
  562. if (i > 0)
  563. sb.Append (", ");
  564. sb.Append (p[i].ParameterType.Name);
  565. }
  566. if (CallingConvention == CallingConventions.Any)
  567. sb.Append (", ...");
  568. sb.Append (")");
  569. return sb.ToString ();
  570. }
  571. // ISerializable
  572. public void GetObjectData(SerializationInfo info, StreamingContext context)
  573. {
  574. MemberInfoSerializationHolder.Serialize ( info, Name, ReflectedType, ToString(), MemberTypes.Constructor);
  575. }
  576. public override IList<CustomAttributeData> GetCustomAttributesData () {
  577. return CustomAttributeData.GetCustomAttributes (this);
  578. }
  579. }
  580. }