* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / corlib / Test / System.Reflection.Emit / CustomAttributeBuilderTest.cs
1 // CustomAttributeBuilderTest.cs
2 //
3 // Author: Vineeth N <nvineeth@yahoo.com>
4 //
5 // (C) 2004 Ximian, Inc. http://www.ximian.com
6 //
7 using System;
8 using System.Reflection;
9 using System.Reflection.Emit;
10 using System.Threading;
11 using NUnit.Framework;
12
13 namespace MonoTests.System.Reflection.Emit
14 {
15         /// <summary>
16         /// TestFixture for CustomAttributeBuilderTest.
17         /// The members to be tested are as follows:
18         /// 4 constructors:
19         /// 1) public CustomAttributeBuilder(ConstructorInfo, object[]);
20         /// 2) public CustomAttributeBuilder(ConstructorInfo, object[], FieldInfo[], object[]);
21         /// 3) public CustomAttributeBuilder(ConstructorInfo, object[], PropertyInfo[], object[]);
22         /// 4) public CustomAttributeBuilder(ConstructorInfo, object[], PropertyInfo[], object[], FieldInfo[], object[]);
23         /// and the exceptions that are thrown.
24         /// In the implementation , it can be seen that the first
25         /// three type of  constructors call the 4th type of ctor, which takes 6 args
26         /// by filling args and substituting null as required.
27         /// For testing constructors we have use 4 different test functions,
28         /// Various exceptions have been checked for 4th type of consturctor.
29         /// </summary>
30
31         [TestFixture]
32         public class CustomAttributeBuilderTest : Assertion
33         {
34                 
35                 // the CustomAttribute class is used for testing and it has to be public
36                 //since it will be associated with a class that belongs to another assembly 
37
38                 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Class)]
39                 public class CustomAttribute: Attribute
40                 {
41                         private string attr1;
42                         private string attr2;
43                         public string Feild; //used for testing the second type of constructor
44
45                         public CustomAttribute () {}
46                         public CustomAttribute (String s1 , String s2)
47                         {
48                                 attr1 = s1;
49                                 attr2=s2;
50                         }
51
52                         private CustomAttribute (String s1) {}
53                         static CustomAttribute () {}
54
55                         public string AttributeOne
56                         {
57                                 get { return attr1; }
58                                 set { attr1 = value; }
59                         }
60                         
61                         public string AttributeTwo
62                         {
63                                 get { return attr2; }
64                                 //the set is skipped and is used later in testing
65                         }
66
67                 }
68                 
69                 private class TempClass
70                 {
71                         //used for testing the ArgumentException
72                         public string Field;
73                         public string FieldProperty
74                         {
75                                 get { return Field; }
76                                 set { Field = value; }
77                         }
78                 }
79
80                 
81
82                 
83                 [Test]
84                 public void CtorOneTest ()
85                 {
86                         //test for the constructor with signature--
87                         // public CustomAttributeBuilder(ConstructorInfo, object[]);
88                         /*
89                          * WE build a imaginary type as follows
90                          * class TestType
91                          * {
92                          *      [CustomAttribute("one","two")]
93                          *      public string Str;
94                          * 
95                          *      [CustomAttribute("hello","world")]
96                          *      public void Print()
97                          *      {Console.WriteLine("Hello World"); }
98                          * 
99                          * }
100                          * And then check for the validity of attributes in the test functions
101                          */
102                         AssemblyName asmName = new AssemblyName ();
103                         asmName.Name = "TestAssembly.dll";
104
105                         AssemblyBuilder asmBuilder = Thread.GetDomain ().DefineDynamicAssembly (
106                                 asmName , AssemblyBuilderAccess.Run);
107                         
108                         ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule ("TestModule");
109                         
110                         TypeBuilder typeBuilder = modBuilder.DefineType ("TestType",
111                                 TypeAttributes.Public);
112
113                         Type[] ctorParams = new Type[] { typeof (string),typeof (string) };
114                         
115                         ConstructorInfo classCtorInfo = 
116                                 typeof (CustomAttribute).GetConstructor (ctorParams);
117
118                         CustomAttributeBuilder feildCABuilder = new CustomAttributeBuilder (
119                                 classCtorInfo,
120                                 new object [] { "one","two" }
121                                 ),
122                                 methodCABuilder = new CustomAttributeBuilder (
123                                 classCtorInfo,
124                                 new object [] { "hello","world" }
125                                 );
126                         //now let's build a feild of type string and associate a attribute with it
127                         FieldBuilder fieldBuilder= typeBuilder.DefineField ("Str",
128                                 typeof (string), FieldAttributes.Public);
129                         fieldBuilder.SetCustomAttribute (feildCABuilder);
130                         //now build a method 
131                         MethodBuilder methodBuilder= typeBuilder.DefineMethod ("Print",
132                                 MethodAttributes.Public, null, null);
133                         methodBuilder.SetCustomAttribute (methodCABuilder);
134                         ILGenerator methodIL = methodBuilder.GetILGenerator ();
135                         methodIL.EmitWriteLine ("Hello, world!");
136                         methodIL.Emit (OpCodes.Ret);
137                         
138                         // create the type
139                         Type myType = typeBuilder.CreateType ();
140
141                         //Now check for the validity of the attributes.
142                         object testInstance = Activator.CreateInstance (myType);
143
144                         //check the validity of the attribute associated with Print method 
145                         
146                         object [] methodAttrs =  myType.GetMember ("Print") [0].GetCustomAttributes (true);
147                         AssertEquals ("#method Print has exactly one attribute", methodAttrs.Length, 1);
148                         CustomAttribute methodAttr = methodAttrs [0] as CustomAttribute;
149                         AssertEquals ("#AttributeOne", methodAttr.AttributeOne, "hello");
150                         AssertEquals ("#AttributeTwo", methodAttr.AttributeTwo, "world");
151                         
152                         //check the validity of the attribute associated with Str feild
153
154                         object [] fieldAttrs = myType.GetField ("Str").GetCustomAttributes (true);
155                         AssertEquals("#feild Str has exactly one attribute", fieldAttrs.Length, 1);
156                         CustomAttribute fieldAttr = fieldAttrs [0] as CustomAttribute;
157                         AssertEquals("#AttributeOne", fieldAttr.AttributeOne, "one");
158                         AssertEquals("#AttributeTwo", fieldAttr.AttributeTwo, "two");
159                 }
160
161                 [Test]
162                 public void CtorTwoTest ()
163                 {
164                         //test for the constructor with signature--
165                         // CustomAttributeBuilder Constructor (ConstructorInfo, Object[], FieldInfo[], Object[]) ;
166                         /*
167                          * WE build a imaginary type as follows
168                          * [CustomAttribute("Test","Type")]
169                          * public class TestType
170                          * {
171                          * 
172                          * }
173                          * We also set the "Feild" of class CustomAttribute and the value;
174                          * And then check for the validity of attributes in the test functions
175                          */
176                                                                         
177                         AssemblyName asmName = new AssemblyName ();
178                         asmName.Name = "TestAssembly.dll";
179
180                         AssemblyBuilder asmBuilder = Thread.GetDomain ().DefineDynamicAssembly (
181                                 asmName, AssemblyBuilderAccess.Run);
182                         
183                         ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule ("TestModule");
184                         
185                         TypeBuilder typeBuilder = modBuilder.DefineType ("TestType",
186                                 TypeAttributes.Public);
187
188                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
189                         
190                         ConstructorInfo classCtorInfo = 
191                                 typeof (CustomAttribute).GetConstructor (ctorParams);
192
193                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
194                                 classCtorInfo,
195                                 new object [] { "Test","Type" },
196                                 typeof(CustomAttribute).GetFields(),
197                                 new object [] { "TestCase" }
198                                 ); 
199                                 
200                         typeBuilder.SetCustomAttribute (typeCABuilder);
201                         
202                         // create the type
203                         Type myType = typeBuilder.CreateType ();
204
205                         //Now check for the validity of the attributes.
206                         object testInstance = Activator.CreateInstance (myType);
207
208                         //check the validity of the attribute associated with Print method 
209                         object [] customAttrs = myType.GetCustomAttributes (false);
210                         AssertEquals ("#TestType has exactly one attribute", customAttrs.Length, 1);
211
212                         //Custom Attributes of TestType
213                         CustomAttribute attr = customAttrs [0] as CustomAttribute;
214                         AssertEquals ("#AttributeOne", attr.AttributeOne, "Test");
215                         AssertEquals ("#AttributeTwo", attr.AttributeTwo, "Type");
216                         AssertEquals ("#CustomAttribute.Feild",attr.Feild, "TestCase");
217
218                 }
219
220                 [Test]
221                 public void CtorThreeTest ()
222                 {
223                         //test for the constructor with signature--
224                         // CustomAttributeBuilder Constructor (ConstructorInfo, Object[], PropertyInfo[], Object[]) ;
225                         /*
226                          * WE build a imaginary type as follows
227                          * [CustomAttribute()]
228                          * public class TestType
229                          * {
230                          * 
231                          * }
232                          * We also set the "AttributeOne" of class CustomAttribute by means of the constuctor
233                          * And then check for the validity of attribute state 
234                          */
235                         
236                         AssemblyName asmName = new AssemblyName ();
237                         asmName.Name = "TestAssembly.dll";
238
239                         AssemblyBuilder asmBuilder = Thread.GetDomain ().DefineDynamicAssembly (
240                                 asmName, AssemblyBuilderAccess.Run);
241                         
242                         ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule ("TestModule");
243                         
244                         TypeBuilder typeBuilder = modBuilder.DefineType ("TestType",
245                                 TypeAttributes.Public);
246                                                                 
247                         Type [] ctorParams = new Type [] { };
248
249                         ConstructorInfo classCtorInfo = 
250                                 typeof (CustomAttribute).GetConstructor (ctorParams);
251
252                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
253                                 classCtorInfo,
254                                 new object [] { },
255                                 new PropertyInfo []{ typeof (CustomAttribute).GetProperty ("AttributeOne") },
256                                 new object [] { "TestCase" }
257                                 ); 
258                                 
259                         typeBuilder.SetCustomAttribute (typeCABuilder);
260                         
261                         // create the type
262                         Type myType = typeBuilder.CreateType ();
263
264                         //Now check for the validity of the attributes.
265                         object testInstance = Activator.CreateInstance (myType);
266
267                         //check the validity of the attribute associated with Print method 
268                         object [] customAttrs = myType.GetCustomAttributes (false);
269                         AssertEquals ("#TestType has exactly one attribute", customAttrs.Length , 1);
270
271                         //Custom Attributes of TestType
272                         CustomAttribute attr = customAttrs [0] as CustomAttribute;
273                         AssertEquals("#AttributeOne", attr.AttributeOne, "TestCase");
274                 }
275
276                 [Test]
277                 public void CtorFourTest ()
278                 {
279                         //test for the constructor with signature--
280                         //public CustomAttributeBuilder(ConstructorInfo, object[], PropertyInfo[], object[], FieldInfo[], object[]);
281                         /*
282                          * WE build a imaginary type as follows
283                          * [CustomAttribute()]
284                          * public class TestType
285                          * {
286                          * 
287                          * }
288                          * We also set the "AttributeOne" property ,
289                          * and "Feild" of class CustomAttribute 
290                          * by means of the constuctor of CustomAttributeBuilder
291                          * And then check for the validity 
292                          */
293                                         
294                         AssemblyName asmName = new AssemblyName ();
295                         asmName.Name = "TestAssembly.dll";
296
297                         AssemblyBuilder asmBuilder = Thread.GetDomain ().DefineDynamicAssembly (
298                                 asmName , AssemblyBuilderAccess.Run);
299                         
300                         ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule ("TestModule");
301                         
302                         TypeBuilder typeBuilder = modBuilder.DefineType ("TestType",
303                                 TypeAttributes.Public);
304                 
305                         Type [] ctorParams = new Type [] { };
306                         
307                         ConstructorInfo classCtorInfo = 
308                                 typeof (CustomAttribute).GetConstructor (ctorParams);
309
310                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder(
311                                 classCtorInfo,
312                                 new object [] { },
313                                 new PropertyInfo []{ typeof (CustomAttribute).GetProperty ("AttributeOne") },
314                                 new object [] { "TestCase" },
315                                 typeof(CustomAttribute).GetFields (),
316                                 new object [] { "FieldValue" }
317                                 ); 
318                                 
319                         typeBuilder.SetCustomAttribute (typeCABuilder);
320                         
321                         // create the type
322                         Type myType = typeBuilder.CreateType ();
323
324                         //Now check for the validity of the attributes.
325                         object testInstance = Activator.CreateInstance (myType);
326
327                         //check the validity of the attribute associated with Print method 
328                         object [] customAttrs = myType.GetCustomAttributes (false);
329                         AssertEquals("#TestType has exactly one attribute",customAttrs.Length , 1);
330
331                         //Custom Attributes of TestType
332                         CustomAttribute attr = customAttrs [0] as CustomAttribute;
333                         AssertEquals ("#AttributeOne", attr.AttributeOne, "TestCase");
334                         AssertEquals ("#Field ", attr.Feild, "FieldValue");
335                 }
336         
337                 
338                 [Test]
339                 [ExpectedException (typeof (ArgumentException))]
340                 public void ArgumentExceptionTest_1 ()
341                 {
342                         //here the constructor is static 
343                                         
344                         Type [] ctorParams = new Type [] { };
345                         
346                         ConstructorInfo classCtorInfo = 
347                                 typeof (CustomAttribute).GetConstructor (BindingFlags.Static | BindingFlags.NonPublic,
348                                                 null, ctorParams, null);
349
350                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
351                                 classCtorInfo,
352                                 new object [] { },
353                                 new PropertyInfo [] { typeof (CustomAttribute).GetProperty ("AttributeOne") },
354                                 new object [] { "TestCase" },
355                                 typeof (CustomAttribute).GetFields (),
356                                 new object [] { "FieldValue" }
357                                 );
358                 }
359
360                 
361                 [Test]
362                 [ExpectedException (typeof (ArgumentException))]
363                 public void ArgumentExceptionTest_2 ()
364                 {
365                         //here the consturctor is private
366                                         
367                         Type [] ctorParams = new Type[] {typeof(string) };
368                         
369                         ConstructorInfo classCtorInfo = 
370                                 typeof (CustomAttribute).GetConstructor (BindingFlags.Instance |
371                                                 BindingFlags.NonPublic, null, ctorParams, null);
372
373                         Assert ("#Custom Attribute has private constuctor ", classCtorInfo != null);
374
375                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
376                                 classCtorInfo,
377                                 new object [] { "hello" },
378                                 new PropertyInfo []{ typeof (CustomAttribute).GetProperty ("AttributeOne") },
379                                 new object [] { "TestCase" },
380                                 typeof (CustomAttribute).GetFields (),
381                                 new object [] { "FieldValue" }
382                                 );
383                 }
384
385                 
386                 [Test]
387                 [ExpectedException (typeof (ArgumentException))]
388                 public void ArgumentExceptionTest_3 ()
389                 {
390                         // The lengths of the namedProperties and 
391                         //propertyValues arrays are different. 
392                         
393                         Type [] ctorParams = new Type [] { };
394                         
395                         ConstructorInfo classCtorInfo = 
396                                 typeof (CustomAttribute).GetConstructor (ctorParams);
397
398                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
399                                 classCtorInfo,
400                                 new object [] { },
401                                 new PropertyInfo [] { typeof (CustomAttribute).GetProperty ("AttributeOne") },
402                                 new object [] { "TestCase","extra arg" },//<--here is the error
403                                 typeof (CustomAttribute).GetFields (),
404                                 new object [] { "FieldValue" }
405                                 );
406                 }
407
408
409                 [Test]
410                 [ExpectedException (typeof (ArgumentException))]
411                 public void ArgumentExceptionTest_4()
412                 {
413                         //The length of the namedFields and
414                         //namedValues are different 
415                         
416                         Type [] ctorParams = new Type [] { };
417                         
418                         ConstructorInfo classCtorInfo = 
419                                 typeof (CustomAttribute).GetConstructor (ctorParams);
420
421                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
422                                 classCtorInfo,
423                                 new object [] { },
424                                 new PropertyInfo [] { typeof (CustomAttribute).GetProperty ("AttributeOne") },
425                                 new object [] { "TestCase" },
426                                 typeof (CustomAttribute).GetFields (),
427                                 new object [] { }//<--here is the error
428                                 );
429                 }
430
431
432                 [Test]
433                 [ExpectedException (typeof (ArgumentException))]
434                 public void ArgumentExceptionTest_6 ()
435                 {
436                         //The type of supplied argument does not
437                         //match the type of the parameter declared 
438                         //in the constructor.
439                         
440                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
441                         
442                         ConstructorInfo classCtorInfo = 
443                                 typeof (CustomAttribute).GetConstructor (ctorParams);
444
445                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
446                                 classCtorInfo,
447                                 new object [] { "1", 123 },//<--here is the error,(int instead of string)
448                                 new PropertyInfo[]{ typeof (CustomAttribute).GetProperty ("AttributeOne") },
449                                 new object [] { "TestCase" },
450                                 typeof (CustomAttribute).GetFields (),
451                                 new object [] { "FeildValue" }
452                                 );
453                 }
454
455
456                 [Test]
457                 [ExpectedException (typeof (ArgumentException))]
458                 public void ArgumentExceptionTest_7 ()
459                 {
460                         //A property has no setter.(CustomAttribute.AttributeTwo)
461                                                 
462                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
463                         
464                         ConstructorInfo classCtorInfo = 
465                                 typeof (CustomAttribute).GetConstructor (ctorParams);
466
467                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
468                                 classCtorInfo,
469                                 new object [] { "1","2" },
470                                 new PropertyInfo []{ typeof (CustomAttribute).GetProperty ("AttributeTwo") },
471                                 new object [] { "TestCase" },
472                                 typeof (CustomAttribute).GetFields (),
473                                 new object [] { "FeildValue" }
474                                 ); 
475                 }
476
477
478                 [Test]
479                 [ExpectedException (typeof (ArgumentException))]
480                 public void ArgumentExceptionTest_8 ()
481                 {
482                         //A property doesnot belong to same class
483                         
484                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
485                         
486                         ConstructorInfo classCtorInfo = 
487                                 typeof (CustomAttribute).GetConstructor (ctorParams);
488
489                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
490                                 classCtorInfo,
491                                 new object [] { "1","2" },
492                                 new PropertyInfo [] { typeof (TempClass).GetProperty ("FieldProperty")}, //here is the error
493                                 new object [] { "TestCase" },
494                                 typeof (CustomAttribute).GetFields (),
495                                 new object [] { "FeildValue" }
496                                 );
497                 }
498
499
500                 [Test]
501                 [ExpectedException (typeof (ArgumentException))]
502                 public void ArgumentExceptionTest_9 ()
503                 {
504                         //A field doesnot belong to same class
505                         
506                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
507                         
508                         ConstructorInfo classCtorInfo = 
509                                 typeof (CustomAttribute).GetConstructor (ctorParams);
510
511                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
512                                 classCtorInfo,
513                                 new object [] { "1","2" },
514                                 new PropertyInfo []{ typeof (CustomAttribute).GetProperty ("AttributeOne") },
515                                 new object [] {"TestCase"},
516                                 typeof (TempClass).GetFields (), //<-- fields of TempClass are passed
517                                 new object [] { "FeildValue" }
518                                 );
519                 }
520
521
522                 [Test]
523                 [ExpectedException (typeof (ArgumentException))]
524                 public void ArgumentExceptionTest_10 ()
525                 {
526                         //The types of the property values do 
527                         //not match the types of the named properties.
528                         
529                                         
530                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
531                         
532                         ConstructorInfo classCtorInfo = 
533                                 typeof (CustomAttribute).GetConstructor (ctorParams);
534
535                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
536                                 classCtorInfo,
537                                 new object [] { "1","2" },
538                                 new PropertyInfo []{ typeof (CustomAttribute).GetProperty ("AttributeOne") },
539                                 new object [] { (long)1212121212 }, //<---type mismatch error(long for string)
540                                 typeof (CustomAttribute).GetFields (),
541                                 new object [] { "FeildValue" }
542                                 );
543                 }
544
545
546                 [Test]
547                 [ExpectedException (typeof (ArgumentException))]
548                 public void ArgumentExceptionTest_11 ()
549                 {
550                         //The types of the field values do 
551                         //not match the types of the named properties.
552                         
553                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
554                         
555                         ConstructorInfo classCtorInfo = 
556                                 typeof (CustomAttribute).GetConstructor (ctorParams);
557
558                         Assert ("#ctor not null", classCtorInfo != null);
559                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
560                                 classCtorInfo,
561                                 new object [] { "1","2" },
562                                 new PropertyInfo [] { typeof (CustomAttribute).GetProperty ("AttributeOne") },
563                                 new object [] { "One" },
564                                 typeof (CustomAttribute).GetFields (),
565                                 new object []{ 12.1212 } //<---type mismatch error(double for string)
566                                 ); 
567                 }
568
569
570                 [Test]
571                 [ExpectedException (typeof (ArgumentNullException))]
572                 public void ArgumentNullException_1 ()
573                 {
574                         //the ctor value array (2nd argument) is null
575                         Type [] ctorParams = new Type [] { typeof (string),typeof (string) };
576                         
577                         ConstructorInfo classCtorInfo = 
578                                 typeof (CustomAttribute).GetConstructor (ctorParams);
579
580                         Assert ("#ctor not null", classCtorInfo != null);
581                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
582                                 classCtorInfo,
583                                 null, //<-- here is the error
584                                 new PropertyInfo [] { typeof (CustomAttribute).GetProperty ("AttributeOne") },
585                                 new object [] { "One" },
586                                 typeof (CustomAttribute).GetFields (),
587                                 new object [] { "feild" }
588                                 );
589                 }
590
591
592                 [Test]
593                 [ExpectedException (typeof (ArgumentNullException))]
594                 public void ArgumentNullException_2 ()
595                 {
596                         //the property value array (4th argument) is null
597                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
598                         
599                         ConstructorInfo classCtorInfo = 
600                                 typeof (CustomAttribute).GetConstructor (ctorParams);
601
602                         Assert ("#ctor not null", classCtorInfo != null);
603                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
604                                 classCtorInfo,
605                                 new object [] { "one","two" },
606                                 new PropertyInfo []{ typeof (CustomAttribute).GetProperty ("AttributeOne") },
607                                 null, // <-- here is the error
608                                 typeof (CustomAttribute).GetFields (),
609                                 new object [] { "feild" }
610                                 );
611                 }
612
613
614                 [Test]
615                 [ExpectedException (typeof (ArgumentNullException))]
616                 public void ArgumentNullException_3 ()
617                 {
618                         //the field value array (6th argument) is null
619                         Type [] ctorParams = new Type [] { typeof (string), typeof (string) };
620                         
621                         ConstructorInfo classCtorInfo = 
622                                 typeof (CustomAttribute).GetConstructor (ctorParams);
623
624                         Assert ("#ctor not null", classCtorInfo != null);
625                         CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
626                                 classCtorInfo,
627                                 new object [] { "one","two" },
628                                 new PropertyInfo [] { typeof (CustomAttribute).GetProperty ("AttributeOne") },
629                                 new object [] {"property"},
630                                 typeof (CustomAttribute).GetFields (),
631                                 null // <-- here is the error
632                                 );
633                 }
634         }
635 }
636