New tests.
[mono.git] / mcs / class / corlib / System.Reflection.Emit / MonoArrayMethod.cs
1 //
2 // System.Reflection/MonoMethod.cs
3 // The class used to represent methods from the mono runtime.
4 //
5 // Author:
6 //   Paolo Molaro (lupus@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 //
12 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 // 
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 // 
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 //
33
34 using System;
35 using System.Globalization;
36 using System.Runtime.CompilerServices;
37 using System.Runtime.InteropServices;
38
39 namespace System.Reflection {
40         internal class MonoArrayMethod: MethodInfo {
41 #pragma warning disable 649
42                 internal RuntimeMethodHandle mhandle;
43                 internal Type parent;
44                 internal Type ret;
45                 internal Type[] parameters;
46                 internal string name;
47                 internal int table_idx;
48                 internal CallingConventions call_conv;
49 #pragma warning restore 649             
50
51                 internal MonoArrayMethod (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
52                         name = methodName;
53                         parent = arrayClass;
54                         ret = returnType;
55                         parameters = (Type[])parameterTypes.Clone();
56                         call_conv = callingConvention;
57                 }
58                 
59                 [MonoTODO("Always returns this")]
60                 public override MethodInfo GetBaseDefinition() {
61                         return this; /* FIXME */
62                 }
63                 public override Type ReturnType {
64                         get {
65                                 return ret;
66                         }
67                 }
68
69                 [MonoTODO("Not implemented.  Always returns null")]
70                 public override ICustomAttributeProvider ReturnTypeCustomAttributes { 
71                         get {return null;}
72                 }
73                 
74                 [MonoTODO("Not implemented.  Always returns zero")]
75                 public override MethodImplAttributes GetMethodImplementationFlags() {
76                         return (MethodImplAttributes)0;
77                 }
78
79                 [MonoTODO("Not implemented.  Always returns an empty array")]
80                 public override ParameterInfo[] GetParameters() {
81                         return new ParameterInfo [0];
82                 }
83                 
84                 [MonoTODO("Not implemented.  Always returns 0")]
85                 internal override int GetParameterCount ()
86                 {
87                         return 0;
88                 }               
89
90                 [MonoTODO("Not implemented")]
91                 public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
92                         throw new NotImplementedException ();
93                 }
94
95                 public override RuntimeMethodHandle MethodHandle { 
96                         get {return mhandle;} 
97                 }
98
99                 [MonoTODO("Not implemented.  Always returns zero")]
100                 public override MethodAttributes Attributes { 
101                         get {
102                                 return (MethodAttributes)0;
103                         } 
104                 }
105                 
106                 public override Type ReflectedType {
107                         get {
108                                 return parent;
109                         }
110                 }
111                 public override Type DeclaringType {
112                         get {
113                                 return parent;
114                         }
115                 }
116                 public override string Name {
117                         get {
118                                 return name;
119                         }
120                 }
121                 
122                 public override bool IsDefined (Type attributeType, bool inherit) {
123                         return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
124                 }
125
126                 public override object[] GetCustomAttributes( bool inherit) {
127                         return MonoCustomAttrs.GetCustomAttributes (this, inherit);
128                 }
129                 public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
130                         return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
131                 }
132
133                 public override string ToString () {
134                         string parms = String.Empty;
135                         ParameterInfo[] p = GetParameters ();
136                         for (int i = 0; i < p.Length; ++i) {
137                                 if (i > 0)
138                                         parms = parms + ", ";
139                                 parms = parms + p [i].ParameterType.Name;
140                         }
141                         if (ReturnType != null)
142                                 return ReturnType.Name+" "+Name+"("+parms+")";
143                         else
144                                 return "void "+Name+"("+parms+")";
145                 }
146         }
147 }