[System] Process.WaitForExit now triggers event Exited.
[mono.git] / mcs / class / corlib / System.Reflection / MonoMethod.cs
1 //
2 // MonoMethod.cs: The class used to represent methods from the mono runtime.
3 //
4 // Authors:
5 //   Paolo Molaro (lupus@ximian.com)
6 //   Marek Safar (marek.safar@gmail.com)
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
32 using System.Collections.Generic;
33 using System.Globalization;
34 using System.Runtime.CompilerServices;
35 using System.Runtime.InteropServices;
36 using System.Runtime.Serialization;
37 #if !FULL_AOT_RUNTIME
38 using System.Reflection.Emit;
39 #endif
40 using System.Security;
41 using System.Threading;
42 using System.Text;
43 using System.Diagnostics;
44 using System.Diagnostics.Contracts;
45
46 namespace System.Reflection {
47         
48         internal struct MonoMethodInfo 
49         {
50 #pragma warning disable 649     
51                 private Type parent;
52                 private Type ret;
53                 internal MethodAttributes attrs;
54                 internal MethodImplAttributes iattrs;
55                 private CallingConventions callconv;
56 #pragma warning restore 649             
57
58                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
59                 static extern void get_method_info (IntPtr handle, out MonoMethodInfo info);
60                 
61                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
62                 static extern int get_method_attributes (IntPtr handle);
63                 
64                 internal static MonoMethodInfo GetMethodInfo (IntPtr handle)
65                 {
66                         MonoMethodInfo info;
67                         MonoMethodInfo.get_method_info (handle, out info);
68                         return info;
69                 }
70
71                 internal static Type GetDeclaringType (IntPtr handle)
72                 {
73                         return GetMethodInfo (handle).parent;
74                 }
75
76                 internal static Type GetReturnType (IntPtr handle)
77                 {
78                         return GetMethodInfo (handle).ret;
79                 }
80
81                 internal static MethodAttributes GetAttributes (IntPtr handle)
82                 {
83                         return (MethodAttributes)get_method_attributes (handle);
84                 }
85
86                 internal static CallingConventions GetCallingConvention (IntPtr handle)
87                 {
88                         return GetMethodInfo (handle).callconv;
89                 }
90
91                 internal static MethodImplAttributes GetMethodImplementationFlags (IntPtr handle)
92                 {
93                         return GetMethodInfo (handle).iattrs;
94                 }
95
96                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
97                 static extern ParameterInfo[] get_parameter_info (IntPtr handle, MemberInfo member);
98
99                 static internal ParameterInfo[] GetParametersInfo (IntPtr handle, MemberInfo member)
100                 {
101                         return get_parameter_info (handle, member);
102                 }
103
104                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
105                 static extern MarshalAsAttribute get_retval_marshal (IntPtr handle);
106
107                 static internal ParameterInfo GetReturnParameterInfo (MonoMethod method)
108                 {
109                         return ParameterInfo.New (GetReturnType (method.mhandle), method, get_retval_marshal (method.mhandle));
110                 }
111         };
112         
113         abstract class RuntimeMethodInfo : MethodInfo, ISerializable
114         {
115                 internal BindingFlags BindingFlags {
116                         get {
117                                 return 0;
118                         }
119                 }
120
121                 RuntimeType ReflectedTypeInternal {
122                         get {
123                                 return (RuntimeType) ReflectedType;
124                         }
125                 }
126
127         internal override string FormatNameAndSig (bool serialization)
128         {
129             // Serialization uses ToString to resolve MethodInfo overloads.
130             StringBuilder sbName = new StringBuilder(Name);
131
132             // serialization == true: use unambiguous (except for assembly name) type names to distinguish between overloads.
133             // serialization == false: use basic format to maintain backward compatibility of MethodInfo.ToString().
134             TypeNameFormatFlags format = serialization ? TypeNameFormatFlags.FormatSerialization : TypeNameFormatFlags.FormatBasic;
135
136             if (IsGenericMethod)
137                 sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this, format));
138
139             sbName.Append("(");
140             ParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention, serialization);
141             sbName.Append(")");
142
143             return sbName.ToString();
144         }
145
146         public override String ToString() 
147         {
148             return ReturnType.FormatTypeName() + " " + FormatNameAndSig(false);
149         }
150
151         #region ISerializable Implementation
152         public void GetObjectData(SerializationInfo info, StreamingContext context)
153         {
154             if (info == null)
155                 throw new ArgumentNullException("info");
156             Contract.EndContractBlock();
157
158             MemberInfoSerializationHolder.GetSerializationInfo(
159                 info,
160                 Name,
161                 ReflectedTypeInternal,
162                 ToString(),
163                 SerializationToString(),
164                 MemberTypes.Method,
165                 IsGenericMethod & !IsGenericMethodDefinition ? GetGenericArguments() : null);
166         }
167
168         internal string SerializationToString()
169         {
170             return ReturnType.FormatTypeName(true) + " " + FormatNameAndSig(true);
171         }
172         #endregion
173         }
174
175         /*
176          * Note: most of this class needs to be duplicated for the contructor, since
177          * the .NET reflection class hierarchy is so broken.
178          */
179         [Serializable()]
180         [StructLayout (LayoutKind.Sequential)]
181         internal class MonoMethod : RuntimeMethodInfo
182         {
183 #pragma warning disable 649
184                 internal IntPtr mhandle;
185                 string name;
186                 Type reftype;
187 #pragma warning restore 649
188
189                 internal MonoMethod () {
190                 }
191
192                 internal MonoMethod (RuntimeMethodHandle mhandle) {
193                         this.mhandle = mhandle.Value;
194                 }
195                 
196                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
197                 internal static extern string get_name (MethodBase method);
198
199                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
200                 internal static extern MonoMethod get_base_method (MonoMethod method, bool definition);
201
202                 public override MethodInfo GetBaseDefinition ()
203                 {
204                         return get_base_method (this, true);
205                 }
206
207                 internal override MethodInfo GetBaseMethod ()
208                 {
209                         return get_base_method (this, false);
210                 }
211
212                 public override ParameterInfo ReturnParameter {
213                         get {
214                                 return MonoMethodInfo.GetReturnParameterInfo (this);
215                         }
216                 }
217
218                 public override Type ReturnType {
219                         get {
220                                 return MonoMethodInfo.GetReturnType (mhandle);
221                         }
222                 }
223                 public override ICustomAttributeProvider ReturnTypeCustomAttributes { 
224                         get {
225                                 return MonoMethodInfo.GetReturnParameterInfo (this);
226                         }
227                 }
228                 
229                 public override MethodImplAttributes GetMethodImplementationFlags ()
230                 {
231                         return MonoMethodInfo.GetMethodImplementationFlags (mhandle);
232                 }
233
234                 public override ParameterInfo[] GetParameters ()
235                 {
236                         var src = MonoMethodInfo.GetParametersInfo (mhandle, this);
237                         if (src.Length == 0)
238                                 return src;
239
240                         // Have to clone because GetParametersInfo icall returns cached value
241                         var dest = new ParameterInfo [src.Length];
242                         Array.FastCopy (src, 0, dest, 0, src.Length);
243                         return dest;
244                 }
245
246                 internal override ParameterInfo[] GetParametersInternal ()
247                 {
248                         return MonoMethodInfo.GetParametersInfo (mhandle, this);
249                 }
250                 
251                 internal override int GetParametersCount ()
252                 {
253                         return MonoMethodInfo.GetParametersInfo (mhandle, this).Length;
254                 }
255
256                 /*
257                  * InternalInvoke() receives the parameters correctly converted by the 
258                  * binder to match the types of the method signature.
259                  */
260                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
261                 internal extern Object InternalInvoke (Object obj, Object[] parameters, out Exception exc);
262
263                 [DebuggerHidden]
264                 [DebuggerStepThrough]
265                 public override Object Invoke (Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
266                 {
267                         if (binder == null)
268                                 binder = Type.DefaultBinder;
269
270                         /*Avoid allocating an array every time*/
271                         ParameterInfo[] pinfo = GetParametersInternal ();
272                         ConvertValues (binder, parameters, pinfo, culture, invokeAttr);
273
274 #if !NET_2_1
275                         if (SecurityManager.SecurityEnabled) {
276                                 // sadly Attributes doesn't tell us which kind of security action this is so
277                                 // we must do it the hard way - and it also means that we can skip calling
278                                 // Attribute (which is another an icall)
279                                 SecurityManager.ReflectedLinkDemandInvoke (this);
280                         }
281 #endif
282
283                         if (ContainsGenericParameters)
284                                 throw new InvalidOperationException ("Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.");
285
286                         Exception exc;
287                         object o = null;
288
289                         try {
290                                 // The ex argument is used to distinguish exceptions thrown by the icall
291                                 // from the exceptions thrown by the called method (which need to be
292                                 // wrapped in TargetInvocationException).
293                                 o = InternalInvoke (obj, parameters, out exc);
294                         } catch (ThreadAbortException) {
295                                 throw;
296 #if NET_2_1
297                         } catch (MethodAccessException) {
298                                 throw;
299 #endif
300                         } catch (Exception e) {
301                                 throw new TargetInvocationException (e);
302                         }
303
304                         if (exc != null)
305                                 throw exc;
306                         return o;
307                 }
308
309                 internal static void ConvertValues (Binder binder, object[] args, ParameterInfo[] pinfo, CultureInfo culture, BindingFlags invokeAttr)
310                 {
311                         if (args == null) {
312                                 if (pinfo.Length == 0)
313                                         return;
314
315                                 throw new TargetParameterCountException ();
316                         }
317
318                         if (pinfo.Length != args.Length)
319                                 throw new TargetParameterCountException ();
320
321                         for (int i = 0; i < args.Length; ++i) {
322                                 var arg = args [i];
323                                 var pi = pinfo [i];
324                                 if (arg == Type.Missing) {
325                                         if (pi.DefaultValue == System.DBNull.Value)
326                                                 throw new ArgumentException(Environment.GetResourceString("Arg_VarMissNull"),"parameters");
327
328                                         args [i] = pi.DefaultValue;
329                                         continue;
330                                 }
331
332                                 var rt = (RuntimeType) pi.ParameterType;
333                                 args [i] = rt.CheckValue (arg, binder, culture, invokeAttr);
334                         }
335                 }
336
337                 public override RuntimeMethodHandle MethodHandle { 
338                         get {
339                                 return new RuntimeMethodHandle (mhandle);
340                         } 
341                 }
342                 
343                 public override MethodAttributes Attributes { 
344                         get {
345                                 return MonoMethodInfo.GetAttributes (mhandle);
346                         } 
347                 }
348
349                 public override CallingConventions CallingConvention { 
350                         get {
351                                 return MonoMethodInfo.GetCallingConvention (mhandle);
352                         }
353                 }
354                 
355                 public override Type ReflectedType {
356                         get {
357                                 return reftype;
358                         }
359                 }
360                 public override Type DeclaringType {
361                         get {
362                                 return MonoMethodInfo.GetDeclaringType (mhandle);
363                         }
364                 }
365                 public override string Name {
366                         get {
367                                 if (name != null)
368                                         return name;
369                                 return get_name (this);
370                         }
371                 }
372                 
373                 public override bool IsDefined (Type attributeType, bool inherit) {
374                         return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
375                 }
376
377                 public override object[] GetCustomAttributes( bool inherit) {
378                         return MonoCustomAttrs.GetCustomAttributes (this, inherit);
379                 }
380                 public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
381                         return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
382                 }
383
384                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
385                 internal static extern DllImportAttribute GetDllImportAttribute (IntPtr mhandle);
386
387                 internal object[] GetPseudoCustomAttributes ()
388                 {
389                         int count = 0;
390
391                         /* MS.NET doesn't report MethodImplAttribute */
392
393                         MonoMethodInfo info = MonoMethodInfo.GetMethodInfo (mhandle);
394                         if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
395                                 count ++;
396                         if ((info.attrs & MethodAttributes.PinvokeImpl) != 0)
397                                 count ++;
398                         
399                         if (count == 0)
400                                 return null;
401                         object[] attrs = new object [count];
402                         count = 0;
403
404                         if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
405                                 attrs [count ++] = new PreserveSigAttribute ();
406                         if ((info.attrs & MethodAttributes.PinvokeImpl) != 0) {
407                                 DllImportAttribute attr = GetDllImportAttribute (mhandle);
408                                 if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
409                                         attr.PreserveSig = true;
410                                 attrs [count ++] = attr;
411                         }
412
413                         return attrs;
414                 }
415
416                 public override MethodInfo MakeGenericMethod (Type [] methodInstantiation)
417                 {
418                         if (methodInstantiation == null)
419                                 throw new ArgumentNullException ("methodInstantiation");
420
421                         if (!IsGenericMethodDefinition)
422                                 throw new InvalidOperationException ("not a generic method definition");
423
424                         /*FIXME add GetGenericArgumentsLength() internal vcall to speed this up*/
425                         if (GetGenericArguments ().Length != methodInstantiation.Length)
426                                 throw new ArgumentException ("Incorrect length");
427
428                         bool hasUserType = false;
429                         foreach (Type type in methodInstantiation) {
430                                 if (type == null)
431                                         throw new ArgumentNullException ();
432                                 if (!(type is MonoType))
433                                         hasUserType = true;
434                         }
435
436                         if (hasUserType)
437 #if FULL_AOT_RUNTIME
438                                 throw new NotSupportedException ("User types are not supported under full aot");
439 #else
440                                 return new MethodOnTypeBuilderInst (this, methodInstantiation);
441 #endif
442
443                         MethodInfo ret = MakeGenericMethod_impl (methodInstantiation);
444                         if (ret == null)
445                                 throw new ArgumentException (String.Format ("The method has {0} generic parameter(s) but {1} generic argument(s) were provided.", GetGenericArguments ().Length, methodInstantiation.Length));
446                         return ret;
447                 }
448
449                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
450                 extern MethodInfo MakeGenericMethod_impl (Type [] types);
451
452                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
453                 public override extern Type [] GetGenericArguments ();
454
455                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
456                 extern MethodInfo GetGenericMethodDefinition_impl ();
457
458                 public override MethodInfo GetGenericMethodDefinition ()
459                 {
460                         MethodInfo res = GetGenericMethodDefinition_impl ();
461                         if (res == null)
462                                 throw new InvalidOperationException ();
463
464                         return res;
465                 }
466
467                 public override extern bool IsGenericMethodDefinition {
468                         [MethodImplAttribute(MethodImplOptions.InternalCall)]
469                         get;
470                 }
471
472                 public override extern bool IsGenericMethod {
473                         [MethodImplAttribute(MethodImplOptions.InternalCall)]
474                         get;
475                 }
476
477                 public override bool ContainsGenericParameters {
478                         get {
479                                 if (IsGenericMethod) {
480                                         foreach (Type arg in GetGenericArguments ())
481                                                 if (arg.ContainsGenericParameters)
482                                                         return true;
483                                 }
484                                 return DeclaringType.ContainsGenericParameters;
485                         }
486                 }
487
488                 public override MethodBody GetMethodBody () {
489                         return GetMethodBody (mhandle);
490                 }
491
492                 public override IList<CustomAttributeData> GetCustomAttributesData () {
493                         return CustomAttributeData.GetCustomAttributes (this);
494                 }
495
496                 //seclevel { transparent = 0, safe-critical = 1, critical = 2}
497                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
498                 public extern int get_core_clr_security_level ();
499
500                 public override bool IsSecurityTransparent {
501                         get { return get_core_clr_security_level () == 0; }
502                 }
503
504                 public override bool IsSecurityCritical {
505                         get { return get_core_clr_security_level () > 0; }
506                 }
507
508                 public override bool IsSecuritySafeCritical {
509                         get { return get_core_clr_security_level () == 1; }
510                 }
511         }
512         
513
514         abstract class RuntimeConstructorInfo : ConstructorInfo, ISerializable
515         {
516                 public override Module Module {
517                         get {
518                                 return GetRuntimeModule ();
519                         }
520                 }
521
522                 internal RuntimeModule GetRuntimeModule ()
523                 {
524                         return RuntimeTypeHandle.GetModule((RuntimeType)DeclaringType);
525                 }
526
527                 internal BindingFlags BindingFlags {
528                         get {
529                                 return 0;
530                         }
531                 }
532
533                 RuntimeType ReflectedTypeInternal {
534                         get {
535                                 return (RuntimeType) ReflectedType;
536                         }
537                 }
538
539         #region ISerializable Implementation
540         public void GetObjectData(SerializationInfo info, StreamingContext context)
541         {
542             if (info == null)
543                 throw new ArgumentNullException("info");
544             Contract.EndContractBlock();
545             MemberInfoSerializationHolder.GetSerializationInfo(
546                 info,
547                 Name,
548                 ReflectedTypeInternal,
549                 ToString(),
550                 SerializationToString(),
551                 MemberTypes.Constructor,
552                 null);
553         }
554
555         internal string SerializationToString()
556         {
557             // We don't need the return type for constructors.
558             return FormatNameAndSig(true);
559         }
560
561                 internal void SerializationInvoke (Object target, SerializationInfo info, StreamingContext context)
562                 {
563                         Invoke (target, new object[] { info, context });
564                 }
565        #endregion
566         }
567
568         [Serializable()]
569         [StructLayout (LayoutKind.Sequential)]
570         internal class MonoCMethod : RuntimeConstructorInfo
571         {
572 #pragma warning disable 649             
573                 internal IntPtr mhandle;
574                 string name;
575                 Type reftype;
576 #pragma warning restore 649             
577                 
578                 public override MethodImplAttributes GetMethodImplementationFlags ()
579                 {
580                         return MonoMethodInfo.GetMethodImplementationFlags (mhandle);
581                 }
582
583                 public override ParameterInfo[] GetParameters ()
584                 {
585                         return MonoMethodInfo.GetParametersInfo (mhandle, this);
586                 }
587
588                 internal override ParameterInfo[] GetParametersInternal ()
589                 {
590                         return MonoMethodInfo.GetParametersInfo (mhandle, this);
591                 }               
592
593                 internal override int GetParametersCount ()
594                 {
595                         var pi = MonoMethodInfo.GetParametersInfo (mhandle, this);
596                         return pi == null ? 0 : pi.Length;
597                 }
598
599                 /*
600                  * InternalInvoke() receives the parameters correctly converted by the binder
601                  * to match the types of the method signature.
602                  */
603                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
604                 internal extern Object InternalInvoke (Object obj, Object[] parameters, out Exception exc);
605
606                 [DebuggerHidden]
607                 [DebuggerStepThrough]
608                 public override object Invoke (object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) 
609                 {
610                         if (obj == null) {
611                                 if (!IsStatic)
612                                         throw new TargetException ("Instance constructor requires a target");
613                         } else if (!DeclaringType.IsInstanceOfType (obj)) {
614                                 throw new TargetException ("Constructor does not match target type");                           
615                         }
616
617                         return DoInvoke (obj, invokeAttr, binder, parameters, culture);
618                 }
619
620                 object DoInvoke (object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) 
621                 {
622                         if (binder == null)
623                                 binder = Type.DefaultBinder;
624
625                         ParameterInfo[] pinfo = MonoMethodInfo.GetParametersInfo (mhandle, this);
626
627                         MonoMethod.ConvertValues (binder, parameters, pinfo, culture, invokeAttr);
628
629 #if !NET_2_1
630                         if (SecurityManager.SecurityEnabled) {
631                                 // sadly Attributes doesn't tell us which kind of security action this is so
632                                 // we must do it the hard way - and it also means that we can skip calling
633                                 // Attribute (which is another an icall)
634                                 SecurityManager.ReflectedLinkDemandInvoke (this);
635                         }
636 #endif
637
638                         if (obj == null && DeclaringType.ContainsGenericParameters)
639                                 throw new MemberAccessException ("Cannot create an instance of " + DeclaringType + " because Type.ContainsGenericParameters is true.");
640
641                         if ((invokeAttr & BindingFlags.CreateInstance) != 0 && DeclaringType.IsAbstract) {
642                                 throw new MemberAccessException (String.Format ("Cannot create an instance of {0} because it is an abstract class", DeclaringType));
643                         }
644
645                         return InternalInvoke (obj, parameters);
646                 }
647
648                 public object InternalInvoke (object obj, object[] parameters)
649                 {
650                         Exception exc;
651                         object o = null;
652
653                         try {
654                                 o = InternalInvoke (obj, parameters, out exc);
655 #if NET_2_1
656                         } catch (MethodAccessException) {
657                                 throw;
658 #endif
659                         } catch (Exception e) {
660                                 throw new TargetInvocationException (e);
661                         }
662
663                         if (exc != null)
664                                 throw exc;
665
666                         return obj == null ? o : null;
667                 }
668
669                 [DebuggerHidden]
670                 [DebuggerStepThrough]
671                 public override Object Invoke (BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
672                 {
673                         return DoInvoke (null, invokeAttr, binder, parameters, culture);
674                 }
675
676                 public override RuntimeMethodHandle MethodHandle { 
677                         get {
678                                 return new RuntimeMethodHandle (mhandle);
679                         } 
680                 }
681                 
682                 public override MethodAttributes Attributes { 
683                         get {
684                                 return MonoMethodInfo.GetAttributes (mhandle);
685                         } 
686                 }
687
688                 public override CallingConventions CallingConvention { 
689                         get {
690                                 return MonoMethodInfo.GetCallingConvention (mhandle);
691                         }
692                 }
693                 
694                 public override bool ContainsGenericParameters {
695                         get {
696                                 return DeclaringType.ContainsGenericParameters;
697                         }
698                 }
699
700                 public override Type ReflectedType {
701                         get {
702                                 return reftype;
703                         }
704                 }
705                 public override Type DeclaringType {
706                         get {
707                                 return MonoMethodInfo.GetDeclaringType (mhandle);
708                         }
709                 }
710                 public override string Name {
711                         get {
712                                 if (name != null)
713                                         return name;
714                                 return MonoMethod.get_name (this);
715                         }
716                 }
717
718                 public override bool IsDefined (Type attributeType, bool inherit) {
719                         return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
720                 }
721
722                 public override object[] GetCustomAttributes( bool inherit) {
723                         return MonoCustomAttrs.GetCustomAttributes (this, inherit);
724                 }
725
726                 public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
727                         return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
728                 }
729
730                 public override MethodBody GetMethodBody () {
731                         return GetMethodBody (mhandle);
732                 }
733
734                 public override string ToString () {
735                         StringBuilder sb = new StringBuilder ();
736                         sb.Append ("Void ");
737                         sb.Append (Name);
738                         sb.Append ("(");
739                         ParameterInfo[] p = GetParameters ();
740                         for (int i = 0; i < p.Length; ++i) {
741                                 if (i > 0)
742                                         sb.Append (", ");
743                                 sb.Append (p[i].ParameterType.Name);
744                         }
745                         if (CallingConvention == CallingConventions.Any)
746                                 sb.Append (", ...");
747                         sb.Append (")");
748                         return sb.ToString ();
749                 }
750
751                 public override IList<CustomAttributeData> GetCustomAttributesData () {
752                         return CustomAttributeData.GetCustomAttributes (this);
753                 }
754         }
755 }