(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / corlib / System.Reflection / ParameterInfo.cs
blobc85803e9a78d9e04477f2d92a2e17c6a5966d016
1 // System.Reflection.ParameterInfo
2 //
3 // Sean MacIsaac (macisaac@ximian.com)
4 //
5 // (C) 2001 Ximian, Inc.
7 //
8 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Reflection.Emit;
31 using System.Runtime.CompilerServices;
32 using System.Runtime.InteropServices;
34 namespace System.Reflection
36 [Serializable]
37 public class ParameterInfo : ICustomAttributeProvider
39 protected Type ClassImpl;
40 protected object DefaultValueImpl;
41 protected MemberInfo MemberImpl;
42 protected string NameImpl;
43 protected int PositionImpl;
44 protected ParameterAttributes AttrsImpl;
45 private UnmanagedMarshal marshalAs;
47 protected ParameterInfo () {
50 internal ParameterInfo (ParameterBuilder pb, Type type, MemberInfo member, int position) {
51 this.ClassImpl = type;
52 this.MemberImpl = member;
53 if (pb != null) {
54 this.NameImpl = pb.Name;
55 this.PositionImpl = pb.Position - 1; // ParameterInfo.Position is zero-based
56 this.AttrsImpl = (ParameterAttributes) pb.Attributes;
57 } else {
58 this.NameImpl = "";
59 this.PositionImpl = position - 1;
60 this.AttrsImpl = ParameterAttributes.None;
64 /* to build a ParameterInfo for the return type of a method */
65 internal ParameterInfo (Type type, MemberInfo member) {
66 this.ClassImpl = type;
67 this.MemberImpl = member;
68 this.NameImpl = "";
69 this.PositionImpl = -1; // since parameter positions are zero-based, return type pos is -1
70 this.AttrsImpl = ParameterAttributes.Retval;
73 public virtual Type ParameterType {
74 get {return ClassImpl;}
76 public virtual ParameterAttributes Attributes {
77 get {return AttrsImpl;}
79 public virtual object DefaultValue {
80 get {return DefaultValueImpl;}
83 public bool IsIn {
84 get {return (AttrsImpl & ParameterAttributes.In) != 0;}
87 public bool IsLcid {
88 get {return (AttrsImpl & ParameterAttributes.Lcid) != 0;}
91 public bool IsOptional {
92 get {return (AttrsImpl & ParameterAttributes.Optional) != 0;}
95 public bool IsOut {
96 get {return (AttrsImpl & ParameterAttributes.Out) != 0;}
99 public bool IsRetval {
100 get {return (AttrsImpl & ParameterAttributes.Retval) != 0;}
103 public virtual MemberInfo Member {
104 get {return MemberImpl;}
107 public virtual string Name {
108 get {return NameImpl;}
111 public virtual int Position {
112 get {return PositionImpl;}
115 #if NET_2_0 || BOOTSTRAP_NET_2_0
116 public
117 #else
118 internal
119 #endif
120 virtual extern int MetadataToken {
121 [MethodImplAttribute (MethodImplOptions.InternalCall)]
122 get;
125 public virtual object[] GetCustomAttributes (bool inherit)
127 return MonoCustomAttrs.GetCustomAttributes (this, inherit);
130 public virtual object[] GetCustomAttributes (Type attributeType, bool inherit)
132 return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
135 public virtual bool IsDefined( Type attributeType, bool inherit) {
136 return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
139 internal object[] GetPseudoCustomAttributes () {
140 int count = 0;
142 if (IsIn)
143 count ++;
144 if (IsOut)
145 count ++;
146 if (IsOptional)
147 count ++;
148 if (marshalAs != null)
149 count ++;
151 if (count == 0)
152 return null;
153 object[] attrs = new object [count];
154 count = 0;
156 if (IsIn)
157 attrs [count ++] = new InAttribute ();
158 if (IsOptional)
159 attrs [count ++] = new OptionalAttribute ();
160 if (IsOut)
161 attrs [count ++] = new OutAttribute ();
163 if (marshalAs != null)
164 attrs [count ++] = marshalAs.ToMarshalAsAttribute ();
166 return attrs;
169 #if NET_2_0 || BOOTSTRAP_NET_2_0
170 [MonoTODO]
171 public virtual Type[] OptionalCustomModifiers {
172 get {
173 throw new NotImplementedException ();
177 [MonoTODO]
178 public virtual Type[] RequiredCustomModifiers {
179 get {
180 throw new NotImplementedException ();
183 #endif