* Makefile: Build the make-map.exe in Mono.Unix.Native; add /nowarn:0618 to
[mono.git] / mcs / class / corlib / System.Reflection.Emit / PropertyBuilder.cs
1
2 //
3 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
12 // 
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
15 // 
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24
25 //
26 // System.Reflection.Emit/PropertyBuilder.cs
27 //
28 // Author:
29 //   Paolo Molaro (lupus@ximian.com)
30 //
31 // (C) 2001 Ximian, Inc.  http://www.ximian.com
32 //
33
34 using System;
35 using System.Reflection;
36 using System.Reflection.Emit;
37 using System.Globalization;
38 using System.Runtime.CompilerServices;
39 using System.Runtime.InteropServices;
40
41 namespace System.Reflection.Emit {
42 #if NET_2_0
43         [ComVisible (true)]
44         [ComDefaultInterface (typeof (_PropertyBuilder))]
45 #endif
46         [ClassInterface (ClassInterfaceType.None)]
47         public sealed class PropertyBuilder : PropertyInfo, _PropertyBuilder {
48                 private PropertyAttributes attrs;
49                 private string name;
50                 private Type type;
51                 private Type[] parameters;
52                 private CustomAttributeBuilder[] cattrs;
53                 private object def_value;
54                 private MethodBuilder set_method;
55                 private MethodBuilder get_method;
56                 private int table_idx = 0;
57                 internal TypeBuilder typeb;
58                 private Type[] returnModReq;
59                 private Type[] returnModOpt;
60                 private Type[][] paramModReq;
61                 private Type[][] paramModOpt;
62                 
63                 internal PropertyBuilder (TypeBuilder tb, string name, PropertyAttributes attributes, Type returnType, Type[] returnModReq, Type[] returnModOpt, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt) {
64                         this.name = name;
65                         this.attrs = attributes;
66                         this.type = returnType;
67                         this.returnModReq = returnModReq;
68                         this.returnModOpt = returnModOpt;
69                         this.paramModReq = paramModReq;
70                         this.paramModOpt = paramModOpt;
71                         if (parameterTypes != null) {
72                                 this.parameters = new Type [parameterTypes.Length];
73                                 System.Array.Copy (parameterTypes, this.parameters, this.parameters.Length);
74                         }
75                         typeb = tb;
76                         table_idx = tb.get_next_table_index (this, 0x17, true);
77                 }
78
79                 public override PropertyAttributes Attributes {
80                         get {return attrs;}
81                 }
82                 public override bool CanRead {
83                         get {return get_method != null;}
84                 }
85                 public override bool CanWrite {
86                         get {return set_method != null;}
87                 }
88                 public override Type DeclaringType {
89                         get {return typeb;}
90                 }
91                 public override string Name {
92                         get {return name;}
93                 }
94                 public PropertyToken PropertyToken {
95                         get {return new PropertyToken ();}
96                 }
97                 public override Type PropertyType {
98                         get {return type;}
99                 }
100                 public override Type ReflectedType {
101                         get {return typeb;}
102                 }
103                 public void AddOtherMethod( MethodBuilder mdBuilder) {
104                 }
105                 public override MethodInfo[] GetAccessors( bool nonPublic) {
106                         return null;
107                 }
108                 public override object[] GetCustomAttributes(bool inherit) {
109                         return null;
110                 }
111                 public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
112                         return null;
113                 }
114                 public override MethodInfo GetGetMethod( bool nonPublic) {
115                         return get_method;
116                 }
117                 public override ParameterInfo[] GetIndexParameters() {
118                         return null;
119                 }
120                 public override MethodInfo GetSetMethod( bool nonPublic) {
121                         return set_method;
122                 }
123                 public override object GetValue(object obj, object[] index) {
124                         return null;
125                 }
126                 public override object GetValue( object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
127                         return null;
128                 }
129                 public override bool IsDefined( Type attributeType, bool inherit) {
130                         return false;
131                 }
132                 public void SetConstant( object defaultValue) {
133                         def_value = defaultValue;
134                 }
135                 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
136 #if NET_2_0
137                         string attrname = customBuilder.Ctor.ReflectedType.FullName;
138                         if (attrname == "System.Runtime.CompilerServices.SpecialNameAttribute") {
139                                 attrs |= PropertyAttributes.SpecialName;
140                                 return;
141                         }
142 #endif
143                         if (cattrs != null) {
144                                 CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
145                                 cattrs.CopyTo (new_array, 0);
146                                 new_array [cattrs.Length] = customBuilder;
147                                 cattrs = new_array;
148                         } else {
149                                 cattrs = new CustomAttributeBuilder [1];
150                                 cattrs [0] = customBuilder;
151                         }
152                 }
153
154 #if NET_2_0
155                 [ComVisible (true)]
156 #endif
157                 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
158                         SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
159                 }
160                 public void SetGetMethod( MethodBuilder mdBuilder) {
161                         get_method = mdBuilder;
162                 }
163                 public void SetSetMethod( MethodBuilder mdBuilder) {
164                         set_method = mdBuilder;
165                 }
166                 public override void SetValue( object obj, object value, object[] index) {
167                 }
168                 public override void SetValue( object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
169                 }
170
171 #if NET_2_0
172                 public override Module Module {
173                         get {
174                                 return base.Module;
175                         }
176                 }
177 #endif
178
179                 void _PropertyBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
180                 {
181                         throw new NotImplementedException ();
182                 }
183
184                 void _PropertyBuilder.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
185                 {
186                         throw new NotImplementedException ();
187                 }
188
189                 void _PropertyBuilder.GetTypeInfoCount (out uint pcTInfo)
190                 {
191                         throw new NotImplementedException ();
192                 }
193
194                 void _PropertyBuilder.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
195                 {
196                         throw new NotImplementedException ();
197                 }
198         }
199 }
200