Merge pull request #475 from pruiz/xamarin-bug-7408
[mono.git] / mcs / class / corlib / System.Reflection.Emit / MethodBuilder.cs
1 //
2 // System.Reflection.Emit/MethodBuilder.cs
3 //
4 // Author:
5 //   Paolo Molaro (lupus@ximian.com)
6 //
7 // (C) 2001 Ximian, Inc.  http://www.ximian.com
8 //
9
10 //
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32
33 #if !FULL_AOT_RUNTIME
34 using System;
35 using System.Reflection;
36 using System.Reflection.Emit;
37 using System.Globalization;
38 using System.Security;
39 using System.Security.Permissions;
40 using System.Runtime.CompilerServices;
41 using System.Runtime.InteropServices;
42 using System.Diagnostics.SymbolStore;
43
44 namespace System.Reflection.Emit
45 {
46         [ComVisible (true)]
47         [ComDefaultInterface (typeof (_MethodBuilder))]
48         [ClassInterface (ClassInterfaceType.None)]
49         [StructLayout (LayoutKind.Sequential)]
50         public sealed class MethodBuilder : MethodInfo, _MethodBuilder
51         {
52 #pragma warning disable 169, 414
53                 private RuntimeMethodHandle mhandle;
54                 private Type rtype;
55                 internal Type[] parameters;
56                 private MethodAttributes attrs; /* It's used directly by MCS */
57                 private MethodImplAttributes iattrs;
58                 private string name;
59                 private int table_idx;
60                 private byte[] code;
61                 private ILGenerator ilgen;
62                 private TypeBuilder type;
63                 internal ParameterBuilder[] pinfo;
64                 private CustomAttributeBuilder[] cattrs;
65                 private MethodInfo[] override_methods;
66                 private string pi_dll;
67                 private string pi_entry;
68                 private CharSet charset;
69                 private uint extra_flags; /* this encodes set_last_error etc */
70                 private CallingConvention native_cc;
71                 private CallingConventions call_conv;
72                 private bool init_locals = true;
73                 private IntPtr generic_container;
74                 internal GenericTypeParameterBuilder[] generic_params;
75                 private Type[] returnModReq;
76                 private Type[] returnModOpt;
77                 private Type[][] paramModReq;
78                 private Type[][] paramModOpt;
79                 private RefEmitPermissionSet[] permissions;
80 #pragma warning restore 169, 414
81
82                 internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnModReq, Type[] returnModOpt, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt)
83                 {
84                         this.name = name;
85                         this.attrs = attributes;
86                         this.call_conv = callingConvention;
87                         this.rtype = returnType;
88                         this.returnModReq = returnModReq;
89                         this.returnModOpt = returnModOpt;
90                         this.paramModReq = paramModReq;
91                         this.paramModOpt = paramModOpt;
92                         // The MSDN docs does not specify this, but the MS MethodBuilder
93                         // appends a HasThis flag if the method is not static
94                         if ((attributes & MethodAttributes.Static) == 0)
95                                 this.call_conv |= CallingConventions.HasThis;
96                         if (parameterTypes != null) {
97                                 for (int i = 0; i < parameterTypes.Length; ++i)
98                                         if (parameterTypes [i] == null)
99                                                 throw new ArgumentException ("Elements of the parameterTypes array cannot be null", "parameterTypes");
100
101                                 this.parameters = new Type [parameterTypes.Length];
102                                 System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
103                         }
104                         type = tb;
105                         table_idx = get_next_table_index (this, 0x06, true);
106
107                         ((ModuleBuilder)tb.Module).RegisterToken (this, GetToken ().Token);
108                 }
109
110                 internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes, 
111                                                                 CallingConventions callingConvention, Type returnType, Type[] returnModReq, Type[] returnModOpt, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt, 
112                         String dllName, String entryName, CallingConvention nativeCConv, CharSet nativeCharset) 
113                         : this (tb, name, attributes, callingConvention, returnType, returnModReq, returnModOpt, parameterTypes, paramModReq, paramModOpt)
114                 {
115                         pi_dll = dllName;
116                         pi_entry = entryName;
117                         native_cc = nativeCConv;
118                         charset = nativeCharset;
119                 }
120
121                 public override bool ContainsGenericParameters {
122                         get { throw new NotSupportedException (); }
123                 }
124
125                 public bool InitLocals {
126                         get {return init_locals;}
127                         set {init_locals = value;}
128                 }
129
130                 internal TypeBuilder TypeBuilder {
131                         get {return type;}
132                 }
133
134                 public override RuntimeMethodHandle MethodHandle {
135                         get {
136                                 throw NotSupported ();
137                         }
138                 }
139
140                 public override Type ReturnType {
141                         get { return rtype; }
142                 }
143
144                 public override Type ReflectedType {
145                         get { return type; }
146                 }
147
148                 public override Type DeclaringType {
149                         get { return type; }
150                 }
151
152                 public override string Name {
153                         get { return name; }
154                 }
155
156                 public override MethodAttributes Attributes {
157                         get { return attrs; }
158                 }
159
160                 public override ICustomAttributeProvider ReturnTypeCustomAttributes {
161                         get { return null; }
162                 }
163
164                 public override CallingConventions CallingConvention {
165                         get { return call_conv; }
166                 }
167
168                 [MonoTODO("Not implemented")]
169                 public string Signature {
170                         get {
171                                 throw new NotImplementedException ();
172                         }
173                 }
174
175                 /* Used by mcs */
176                 internal bool BestFitMapping {
177                         set {
178                                 extra_flags = (uint) ((extra_flags & ~0x30) | (uint)(value ? 0x10 : 0x20));
179                         }
180                 }
181
182                 /* Used by mcs */
183                 internal bool ThrowOnUnmappableChar {
184                         set {
185                                 extra_flags = (uint) ((extra_flags & ~0x3000) | (uint)(value ? 0x1000 : 0x2000));
186                         }
187                 }
188
189                 /* Used by mcs */
190                 internal bool ExactSpelling {
191                         set {
192                                 extra_flags = (uint) ((extra_flags & ~0x01) | (uint)(value ? 0x01 : 0x00));
193                         }
194                 }
195
196                 /* Used by mcs */
197                 internal bool SetLastError {
198                         set {
199                                 extra_flags = (uint) ((extra_flags & ~0x40) | (uint)(value ? 0x40 : 0x00));
200                         }
201                 }
202
203                 public MethodToken GetToken()
204                 {
205                         return new MethodToken(0x06000000 | table_idx);
206                 }
207                 
208                 public override MethodInfo GetBaseDefinition()
209                 {
210                         return this;
211                 }
212
213                 public override MethodImplAttributes GetMethodImplementationFlags()
214                 {
215                         return iattrs;
216                 }
217
218                 public override ParameterInfo[] GetParameters()
219                 {
220                         if (!type.is_created)
221                                 throw NotSupported ();
222                         if (parameters == null)
223                                 return null;
224
225                         ParameterInfo[] retval = new ParameterInfo [parameters.Length];
226                         for (int i = 0; i < parameters.Length; i++) {
227                                 retval [i] = new ParameterInfo (pinfo == null ? null : pinfo [i + 1], parameters [i], this, i + 1);
228                         }
229                         return retval;
230                 }
231                 
232                 internal override int GetParameterCount ()
233                 {
234                         if (parameters == null)
235                                 return 0;
236                         
237                         return parameters.Length;
238                 }
239
240                 internal override Type GetParameterType (int pos) {
241                         return parameters [pos];
242                 }
243
244                 public Module GetModule ()
245                 {
246                         return type.Module;
247                 }
248
249                 public void CreateMethodBody (byte[] il, int count)
250                 {
251                         if ((il != null) && ((count < 0) || (count > il.Length)))
252                                 throw new ArgumentOutOfRangeException ("Index was out of range.  Must be non-negative and less than the size of the collection.");
253
254                         if ((code != null) || type.is_created)
255                                 throw new InvalidOperationException ("Type definition of the method is complete.");
256
257                         if (il == null)
258                                 code = null;
259                         else {
260                                 code = new byte [count];
261                                 System.Array.Copy(il, code, count);
262                         }
263                 }
264
265                 public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
266                 {
267                         throw NotSupported ();
268                 }
269
270                 public override bool IsDefined (Type attributeType, bool inherit)
271                 {
272                         throw NotSupported ();
273                 }
274
275                 public override object[] GetCustomAttributes (bool inherit)
276                 {
277                         /*
278                          * On MS.NET, this always returns not_supported, but we can't do this
279                          * since there would be no way to obtain custom attributes of 
280                          * dynamically created ctors.
281                          */
282                         if (type.is_created)
283                                 return MonoCustomAttrs.GetCustomAttributes (this, inherit);
284                         else
285                                 throw NotSupported ();
286                 }
287
288                 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
289                 {
290                         if (type.is_created)
291                                 return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
292                         else
293                                 throw NotSupported ();
294                 }
295
296                 public ILGenerator GetILGenerator ()
297                 {
298                         return GetILGenerator (64);
299                 }
300
301                 public ILGenerator GetILGenerator (int size)
302                 {
303                         if (((iattrs & MethodImplAttributes.CodeTypeMask) != 
304                                  MethodImplAttributes.IL) ||
305                                 ((iattrs & MethodImplAttributes.ManagedMask) != 
306                                  MethodImplAttributes.Managed))
307                                 throw new InvalidOperationException ("Method body should not exist.");
308                         if (ilgen != null)
309                                 return ilgen;
310                         ilgen = new ILGenerator (type.Module, ((ModuleBuilder)type.Module).GetTokenGenerator (), size);
311                         return ilgen;
312                 }
313                 
314                 public ParameterBuilder DefineParameter (int position, ParameterAttributes attributes, string strParamName)
315                 {
316                         RejectIfCreated ();
317                         
318                         //
319                         // Extension: Mono allows position == 0 for the return attribute
320                         //
321                         if ((position < 0) || (position > parameters.Length))
322                                 throw new ArgumentOutOfRangeException ("position");
323
324                         ParameterBuilder pb = new ParameterBuilder (this, position, attributes, strParamName);
325                         if (pinfo == null)
326                                 pinfo = new ParameterBuilder [parameters.Length + 1];
327                         pinfo [position] = pb;
328                         return pb;
329                 }
330
331                 internal void check_override ()
332                 {
333                         if (override_methods != null) {
334                                 foreach (var m in override_methods) {
335                                         if (m.IsVirtual && !IsVirtual)
336                                                 throw new TypeLoadException (String.Format("Method '{0}' override '{1}' but it is not virtual", name, m));
337                                 }
338                         }
339                 }
340
341                 internal void fixup ()
342                 {
343                         if (((attrs & (MethodAttributes.Abstract | MethodAttributes.PinvokeImpl)) == 0) && ((iattrs & (MethodImplAttributes.Runtime | MethodImplAttributes.InternalCall)) == 0)) {
344                                 // do not allow zero length method body on MS.NET 2.0 (and higher)
345                                 if (((ilgen == null) || (ilgen.ILOffset == 0)) && (code == null || code.Length == 0))
346                                         throw new InvalidOperationException (
347                                                                              String.Format ("Method '{0}.{1}' does not have a method body.",
348                                                                                             DeclaringType.FullName, Name));
349                         }
350                         if (ilgen != null)
351                                 ilgen.label_fixup ();
352                 }
353                 
354                 internal void GenerateDebugInfo (ISymbolWriter symbolWriter)
355                 {
356                         if (ilgen != null && ilgen.HasDebugInfo) {
357                                 SymbolToken token = new SymbolToken (GetToken().Token);
358                                 symbolWriter.OpenMethod (token);
359                                 symbolWriter.SetSymAttribute (token, "__name", System.Text.Encoding.UTF8.GetBytes (Name));
360                                 ilgen.GenerateDebugInfo (symbolWriter);
361                                 symbolWriter.CloseMethod ();
362                         }
363                 }
364
365                 public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
366                 {
367                         if (customBuilder == null)
368                                 throw new ArgumentNullException ("customBuilder");
369
370                         switch (customBuilder.Ctor.ReflectedType.FullName) {
371                                 case "System.Runtime.CompilerServices.MethodImplAttribute":
372                                         byte[] data = customBuilder.Data;
373                                         int impla; // the (stupid) ctor takes a short or an int ... 
374                                         impla = (int)data [2];
375                                         impla |= ((int)data [3]) << 8;
376                                         iattrs |= (MethodImplAttributes)impla;
377                                         return;
378
379                                 case "System.Runtime.InteropServices.DllImportAttribute":
380                                         CustomAttributeBuilder.CustomAttributeInfo attr = CustomAttributeBuilder.decode_cattr (customBuilder);
381                                         bool preserveSig = true;
382
383                                         /*
384                                          * It would be easier to construct a DllImportAttribute from
385                                          * the custom attribute builder, but the DllImportAttribute 
386                                          * does not contain all the information required here, ie.
387                                          * - some parameters, like BestFitMapping has three values
388                                          *   ("on", "off", "missing"), but DllImportAttribute only
389                                          *   contains two (on/off).
390                                          * - PreserveSig is true by default, while it is false by
391                                          *   default in DllImportAttribute.
392                                          */
393
394                                         pi_dll = (string)attr.ctorArgs[0];
395                                         if (pi_dll == null || pi_dll.Length == 0)
396                                                 throw new ArgumentException ("DllName cannot be empty");
397
398                                         native_cc = System.Runtime.InteropServices.CallingConvention.Winapi;
399
400                                         for (int i = 0; i < attr.namedParamNames.Length; ++i) {
401                                                 string name = attr.namedParamNames [i];
402                                                 object value = attr.namedParamValues [i];
403
404                                                 if (name == "CallingConvention")
405                                                         native_cc = (CallingConvention)value;
406                                                 else if (name == "CharSet")
407                                                         charset = (CharSet)value;
408                                                 else if (name == "EntryPoint")
409                                                         pi_entry = (string)value;
410                                                 else if (name == "ExactSpelling")
411                                                         ExactSpelling = (bool)value;
412                                                 else if (name == "SetLastError")
413                                                         SetLastError = (bool)value;
414                                                 else if (name == "PreserveSig")
415                                                         preserveSig = (bool)value;
416                                         else if (name == "BestFitMapping")
417                                                 BestFitMapping = (bool)value;
418                                         else if (name == "ThrowOnUnmappableChar")
419                                                 ThrowOnUnmappableChar = (bool)value;
420                                         }
421
422                                         attrs |= MethodAttributes.PinvokeImpl;
423                                         if (preserveSig)
424                                                 iattrs |= MethodImplAttributes.PreserveSig;
425                                         return;
426
427                                 case "System.Runtime.InteropServices.PreserveSigAttribute":
428                                         iattrs |= MethodImplAttributes.PreserveSig;
429                                         return;
430                                 case "System.Runtime.CompilerServices.SpecialNameAttribute":
431                                         attrs |= MethodAttributes.SpecialName;
432                                         return;
433                                 case "System.Security.SuppressUnmanagedCodeSecurityAttribute":
434                                         attrs |= MethodAttributes.HasSecurity;
435                                         break;
436                         }
437
438                         if (cattrs != null) {
439                                 CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
440                                 cattrs.CopyTo (new_array, 0);
441                                 new_array [cattrs.Length] = customBuilder;
442                                 cattrs = new_array;
443                         } else {
444                                 cattrs = new CustomAttributeBuilder [1];
445                                 cattrs [0] = customBuilder;
446                         }
447                 }
448
449                 [ComVisible (true)]
450                 public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
451                 {
452                         if (con == null)
453                                 throw new ArgumentNullException ("con");
454                         if (binaryAttribute == null)
455                                 throw new ArgumentNullException ("binaryAttribute");
456                         SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
457                 }
458
459                 public void SetImplementationFlags (MethodImplAttributes attributes)
460                 {
461                         RejectIfCreated ();
462                         iattrs = attributes;
463                 }
464
465                 public void AddDeclarativeSecurity (SecurityAction action, PermissionSet pset)
466                 {
467 #if !NET_2_1
468                         if (pset == null)
469                                 throw new ArgumentNullException ("pset");
470                         if ((action == SecurityAction.RequestMinimum) ||
471                                 (action == SecurityAction.RequestOptional) ||
472                                 (action == SecurityAction.RequestRefuse))
473                                 throw new ArgumentOutOfRangeException ("Request* values are not permitted", "action");
474
475                         RejectIfCreated ();
476
477                         if (permissions != null) {
478                                 /* Check duplicate actions */
479                                 foreach (RefEmitPermissionSet set in permissions)
480                                         if (set.action == action)
481                                                 throw new InvalidOperationException ("Multiple permission sets specified with the same SecurityAction.");
482
483                                 RefEmitPermissionSet[] new_array = new RefEmitPermissionSet [permissions.Length + 1];
484                                 permissions.CopyTo (new_array, 0);
485                                 permissions = new_array;
486                         }
487                         else
488                                 permissions = new RefEmitPermissionSet [1];
489
490                         permissions [permissions.Length - 1] = new RefEmitPermissionSet (action, pset.ToXml ().ToString ());
491                         attrs |= MethodAttributes.HasSecurity;
492 #endif
493                 }
494
495                 [Obsolete ("An alternate API is available: Emit the MarshalAs custom attribute instead.")]
496                 public void SetMarshal (UnmanagedMarshal unmanagedMarshal)
497                 {
498                         RejectIfCreated ();
499                         throw new NotImplementedException ();
500                 }
501
502                 [MonoTODO]
503                 public void SetSymCustomAttribute (string name, byte[] data)
504                 {
505                         RejectIfCreated ();
506                         throw new NotImplementedException ();
507                 }
508
509                 public override string ToString()
510                 {
511                         return "MethodBuilder [" + type.Name + "::" + name + "]";
512                 }
513
514                 [MonoTODO]
515                 public override bool Equals (object obj)
516                 {
517                         return base.Equals (obj);
518                 }
519
520                 public override int GetHashCode ()
521                 {
522                         return name.GetHashCode ();
523                 }
524
525                 internal override int get_next_table_index (object obj, int table, bool inc)
526                 {
527                         return type.get_next_table_index (obj, table, inc);
528                 }
529
530                 void ExtendArray<T> (ref T[] array, T elem) {
531                         if (array == null) {
532                                 array = new T [1];
533                         } else {
534                                 var newa = new T [array.Length + 1];
535                                 Array.Copy (array, newa, array.Length);
536                                 array = newa;
537                         }
538                         array [array.Length - 1] = elem;
539                 }
540
541                 internal void set_override (MethodInfo mdecl)
542                 {
543                         ExtendArray<MethodInfo> (ref override_methods, mdecl);
544                 }
545
546                 private void RejectIfCreated ()
547                 {
548                         if (type.is_created)
549                                 throw new InvalidOperationException ("Type definition of the method is complete.");
550                 }
551
552                 private Exception NotSupported ()
553                 {
554                         return new NotSupportedException ("The invoked member is not supported in a dynamic module.");
555                 }
556
557                 public override MethodInfo MakeGenericMethod (params Type [] typeArguments)
558                 {
559                         if (!IsGenericMethodDefinition)
560                                 throw new InvalidOperationException ("Method is not a generic method definition");
561                         if (typeArguments == null)
562                                 throw new ArgumentNullException ("typeArguments");
563                         if (generic_params.Length != typeArguments.Length)
564                                 throw new ArgumentException ("Incorrect length", "typeArguments");
565                         foreach (Type type in typeArguments) {
566                                 if (type == null)
567                                         throw new ArgumentNullException ("typeArguments");
568                         }
569
570                         return new MethodOnTypeBuilderInst (this, typeArguments);
571                 }
572
573                 public override bool IsGenericMethodDefinition {
574                         get {
575                                 return generic_params != null;
576                         }
577                 }
578
579                 public override bool IsGenericMethod {
580                         get {
581                                 return generic_params != null;
582                         }
583                 }
584
585                 public override MethodInfo GetGenericMethodDefinition ()
586                 {
587                         if (!IsGenericMethodDefinition)
588                                 throw new InvalidOperationException ();
589
590                         return this;
591                 }
592
593                 public override Type[] GetGenericArguments ()
594                 {
595                         if (generic_params == null)
596                                 return null;
597
598                         Type[] result = new Type [generic_params.Length];
599                         for (int i = 0; i < generic_params.Length; i++)
600                                 result [i] = generic_params [i];
601
602                         return result;
603                 }
604
605                 public GenericTypeParameterBuilder[] DefineGenericParameters (params string[] names)
606                 {
607                         if (names == null)
608                                 throw new ArgumentNullException ("names");
609                         if (names.Length == 0)
610                                 throw new ArgumentException ("names");
611
612                         generic_params = new GenericTypeParameterBuilder [names.Length];
613                         for (int i = 0; i < names.Length; i++) {
614                                 string item = names [i];
615                                 if (item == null)
616                                         throw new ArgumentNullException ("names");
617                                 generic_params [i] = new GenericTypeParameterBuilder (type, this, item, i);
618                         }
619
620                         return generic_params;
621                 }
622
623                 public void SetReturnType (Type returnType)
624                 {
625                         rtype = returnType;
626                 }
627
628                 public void SetParameters (params Type[] parameterTypes)
629                 {
630                         if (parameterTypes != null) {
631                                 for (int i = 0; i < parameterTypes.Length; ++i)
632                                         if (parameterTypes [i] == null)
633                                                 throw new ArgumentException ("Elements of the parameterTypes array cannot be null", "parameterTypes");
634
635                                 this.parameters = new Type [parameterTypes.Length];
636                                 System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
637                         }
638                 }
639
640                 public void SetSignature (Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
641                 {
642                         SetReturnType (returnType);
643                         SetParameters (parameterTypes);
644                         this.returnModReq = returnTypeRequiredCustomModifiers;
645                         this.returnModOpt = returnTypeOptionalCustomModifiers;
646                         this.paramModReq = parameterTypeRequiredCustomModifiers;
647                         this.paramModOpt = parameterTypeOptionalCustomModifiers;
648                 }
649
650                 public override Module Module {
651                         get {
652                                 return base.Module;
653                         }
654                 }
655
656                 void _MethodBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
657                 {
658                         throw new NotImplementedException ();
659                 }
660
661                 void _MethodBuilder.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
662                 {
663                         throw new NotImplementedException ();
664                 }
665
666                 void _MethodBuilder.GetTypeInfoCount (out uint pcTInfo)
667                 {
668                         throw new NotImplementedException ();
669                 }
670
671                 void _MethodBuilder.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
672                 {
673                         throw new NotImplementedException ();
674                 }
675
676 #if NET_4_0 || MOONLIGHT
677                 public override ParameterInfo ReturnParameter {
678                         get { return base.ReturnParameter; }
679                 }
680 #endif
681         }
682 }
683 #endif