1 // TypeTest.cs - NUnit Test Cases for the System.Type class
4 // Zoltan Varga (vargaz@freemail.hu)
7 // (C) 2003 Ximian, Inc. http://www.ximian.com
10 using NUnit.Framework;
12 using System.Collections;
14 using System.Collections.Generic;
17 using System.Reflection;
18 using System.Reflection.Emit;
19 using System.Runtime.InteropServices;
21 using System.Globalization;
23 class NoNamespaceClass {
26 namespace MonoTests.System
28 class Super : ICloneable
30 public virtual object Clone ()
45 interface IFace2 : IFace1
50 interface IFace3 : IFace2
65 public abstract int this [byte i] {
69 public abstract int this [int i] {
73 public abstract void TestVoid ();
74 public abstract void TestInt (int i);
77 class DeriveVTable : Base
79 public override int this [byte i] {
83 public override int this [int i] {
87 public override void TestVoid ()
92 public override void TestInt (int i)
98 class NewVTable : DeriveVTable
100 public new int this [byte i] {
104 public new int this [int i] {
108 public new void TestVoid ()
113 public new void TestInt (int i)
118 public void Overload ()
122 public void Overload (int i)
126 public NewVTable (out int i)
131 public void byref_method (out int i)
139 public virtual int Foo {
145 class Derived1 : Base1
147 public override int Foo {
152 class Derived2 : Base1
166 get { throw new NotImplementedException (); }
169 public T Execute (T a)
179 public interface IBar<T>
183 public class Baz<T> : IBar<T>
187 public class Bug348522
189 public void Test (int __argument)
194 public class FirstMethodBinder : Binder
196 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
197 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
204 public override object ChangeType (object value, Type type1, CultureInfo culture)
209 // The rest is just to please the compiler
210 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
215 public override void ReorderArgumentArray(ref object[] a, object b)
219 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
224 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
232 public class TypeTest
234 private AssemblyBuilder assembly;
235 private ModuleBuilder module;
236 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
237 static int typeIndexer = 0;
242 AssemblyName assemblyName = new AssemblyName ();
243 assemblyName.Name = ASSEMBLY_NAME;
244 assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
245 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
246 module = assembly.DefineDynamicModule ("module1");
249 private string genTypeName ()
251 return "t" + (typeIndexer++);
254 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
258 private void GenericMethod<Q> (Q q)
263 public void TestIsAssignableFrom ()
265 // Simple tests for inheritance
266 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
267 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
268 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
269 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
272 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
273 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
274 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
275 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
277 // Tests for multiple dimensional arrays
278 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
279 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
280 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
281 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
283 // Tests for vectors<->one dimensional arrays */
284 #if TARGET_JVM // Lower bounds arrays are not supported for TARGET_JVM.
285 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1});
286 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
288 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
289 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
291 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
292 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
295 // Test that arrays of enums can be cast to their base types
296 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
298 // Test that arrays of valuetypes can't be cast to arrays of
300 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
301 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
302 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
304 // Test that arrays of enums can't be cast to arrays of references
305 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
306 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
307 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
309 // Check that ValueType and Enum are recognized as reference types
310 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
311 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
312 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
314 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
315 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
316 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
318 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
319 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
320 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
322 // Tests for byref types
323 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
324 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
325 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
327 // Tests for type parameters
329 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
330 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
331 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
336 public void TestIsSubclassOf ()
338 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
340 // Tests for byref types
341 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
342 Assert.IsTrue (!paramType.IsSubclassOf (typeof (ValueType)), "#02");
343 //Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
344 Assert.IsTrue (!paramType.IsSubclassOf (paramType), "#04");
348 public void TestGetMethodImpl ()
350 // Test binding of new slot methods (using no types)
351 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
352 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
354 // Test binding of new slot methods (using types)
355 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
356 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
358 // Test overload resolution
359 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
361 // Test byref parameters
362 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
363 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
364 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
368 [Category ("TargetJvmNotWorking")]
369 public void TestGetPropertyImpl ()
371 // Test getting property that is exact
372 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
374 // Test getting property that is not exact
375 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
377 // Test overriding of properties when only the set accessor is overriden
378 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
382 public void GetProperties ()
384 // Test hide-by-name-and-signature
385 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length);
386 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType);
389 [Test] // GetProperties (BindingFlags)
390 public void GetProperties_Flags ()
392 PropertyInfo [] props;
393 Type type = typeof (Bar);
396 flags = BindingFlags.Instance | BindingFlags.NonPublic;
397 props = type.GetProperties (flags);
399 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
400 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
401 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
402 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
404 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
406 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#A5");
408 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
409 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
410 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
411 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
412 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
413 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
414 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
415 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
416 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
417 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
418 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
419 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
420 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
421 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
422 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
423 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
424 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
425 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
426 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
428 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
430 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#A25");
432 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
433 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
434 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
435 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
436 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
438 flags = BindingFlags.Instance | BindingFlags.Public;
439 props = type.GetProperties (flags);
441 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
442 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
443 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
444 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
445 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
446 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
447 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
448 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
449 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
450 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
451 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
452 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
453 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
454 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
455 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
456 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
457 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
458 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
459 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
460 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
461 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
462 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
463 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
464 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
465 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
466 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
467 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
468 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
469 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
470 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
472 flags = BindingFlags.Static | BindingFlags.Public;
473 props = type.GetProperties (flags);
475 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
476 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
477 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
478 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
479 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
480 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
481 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
482 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
483 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
484 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
485 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
486 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
487 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
488 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
489 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
490 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
491 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
492 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
493 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
494 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
495 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
496 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
497 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
498 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
499 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
500 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
501 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
502 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
503 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
504 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
506 flags = BindingFlags.Static | BindingFlags.NonPublic;
507 props = type.GetProperties (flags);
509 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
510 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
511 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
512 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
513 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
514 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
515 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
516 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
517 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
518 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
519 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
520 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
521 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
522 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
523 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
524 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
525 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
526 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
527 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
528 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
529 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
530 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
531 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
532 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
533 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
534 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
535 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
536 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
537 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
538 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
540 flags = BindingFlags.Instance | BindingFlags.NonPublic |
541 BindingFlags.FlattenHierarchy;
542 props = type.GetProperties (flags);
544 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
545 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
546 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
547 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
549 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
551 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#E5");
553 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
554 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
555 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
556 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
557 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
558 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
559 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
560 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
561 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
562 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
563 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
564 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
565 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
566 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
567 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
568 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
569 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
570 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
571 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
573 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
575 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#E25");
577 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
578 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
579 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
580 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
581 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
583 flags = BindingFlags.Instance | BindingFlags.Public |
584 BindingFlags.FlattenHierarchy;
585 props = type.GetProperties (flags);
587 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
588 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
589 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
590 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
591 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
592 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
593 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
594 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
595 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
596 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
597 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
598 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
599 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
600 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
601 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
602 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
603 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
604 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
605 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
606 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
607 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
608 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
609 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
610 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
611 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
612 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
613 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
614 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
615 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
616 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
618 flags = BindingFlags.Static | BindingFlags.Public |
619 BindingFlags.FlattenHierarchy;
620 props = type.GetProperties (flags);
622 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
623 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
624 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
625 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
626 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
627 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
628 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
629 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
630 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
631 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
632 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
633 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
634 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
635 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
636 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
637 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
638 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
639 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
640 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
641 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
642 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
643 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
644 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
645 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
646 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
647 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
648 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
649 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
650 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
651 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
653 flags = BindingFlags.Static | BindingFlags.NonPublic |
654 BindingFlags.FlattenHierarchy;
655 props = type.GetProperties (flags);
657 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
658 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
659 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
660 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
661 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
662 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
663 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
664 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
665 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
666 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
667 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
668 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
669 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
670 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
672 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
674 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#H15");
676 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
677 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
678 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
679 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
680 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
681 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
682 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
683 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
684 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
685 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
686 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
687 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
688 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
689 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
691 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
693 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#H50");
696 flags = BindingFlags.Instance | BindingFlags.NonPublic |
697 BindingFlags.DeclaredOnly;
698 props = type.GetProperties (flags);
700 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
701 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
702 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
703 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
704 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
705 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
706 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
707 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
708 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
709 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
710 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
711 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
712 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
713 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
714 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
715 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
716 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
717 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
718 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
719 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
720 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
721 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
722 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
723 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
724 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
725 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
726 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
727 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
728 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
729 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
731 flags = BindingFlags.Instance | BindingFlags.Public |
732 BindingFlags.DeclaredOnly;
733 props = type.GetProperties (flags);
735 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
736 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
737 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
738 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
739 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
740 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
741 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
742 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
743 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
744 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
745 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
746 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
747 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
748 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
749 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
750 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
751 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
752 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
753 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
754 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
755 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
756 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
757 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
758 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
759 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
760 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
761 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
762 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
763 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
764 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
766 flags = BindingFlags.Static | BindingFlags.Public |
767 BindingFlags.DeclaredOnly;
768 props = type.GetProperties (flags);
770 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
771 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
772 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
773 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
774 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
775 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
776 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
777 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
778 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
779 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
780 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
781 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
782 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
783 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
784 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
785 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
786 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
787 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
788 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
789 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
790 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
791 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
792 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
793 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
794 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
795 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
796 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
797 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
798 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
799 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
801 flags = BindingFlags.Static | BindingFlags.NonPublic |
802 BindingFlags.DeclaredOnly;
803 props = type.GetProperties (flags);
805 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
806 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
807 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
808 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
809 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
810 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
811 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
812 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
813 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
814 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
815 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
816 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
817 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
818 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
819 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
820 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
821 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
822 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
823 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
824 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
825 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
826 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
827 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
828 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
829 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
830 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
831 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
832 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
833 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
834 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
836 flags = BindingFlags.Instance | BindingFlags.NonPublic |
838 props = type.GetProperties (flags);
840 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
841 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
842 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
843 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
845 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
847 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#M5");
849 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
850 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
851 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
852 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
853 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
854 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
855 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
856 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
857 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
858 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
859 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
860 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
861 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
862 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
863 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
864 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
865 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
866 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
867 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
869 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
871 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#M25");
873 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
874 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
875 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
876 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
877 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
879 flags = BindingFlags.Static | BindingFlags.NonPublic |
881 props = type.GetProperties (flags);
883 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
884 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
885 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
886 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
887 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
888 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
889 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
890 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
891 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
892 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
893 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
894 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
895 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
896 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
897 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
898 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
899 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
900 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
901 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
902 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
903 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
904 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
905 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
906 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
907 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
908 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
909 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
910 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
911 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
912 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
915 [Test] // GetProperty (String)
916 public void GetProperty1_Name_Null ()
918 Type type = typeof (Bar);
920 type.GetProperty ((string) null);
922 } catch (ArgumentNullException ex) {
923 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
924 Assert.IsNull (ex.InnerException, "#3");
925 Assert.IsNotNull (ex.Message, "#4");
926 Assert.IsNotNull (ex.ParamName, "#5");
927 Assert.AreEqual ("name", ex.ParamName, "#6");
931 [Test] // GetProperty (String, BindingFlags)
932 public void GetProperty2 ()
934 Type type = typeof (Bar);
937 flags = BindingFlags.Instance | BindingFlags.NonPublic;
939 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
940 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
941 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
942 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
944 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
946 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#A5");
948 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
949 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
950 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
951 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
952 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
953 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
954 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
955 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
956 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
957 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
958 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
959 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
960 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
961 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
962 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
963 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
964 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
965 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
966 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
968 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
970 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#A25");
972 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
973 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
974 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
975 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
976 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
978 flags = BindingFlags.Instance | BindingFlags.Public;
980 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
981 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
982 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
983 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
984 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
985 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
986 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
987 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
988 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
989 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
990 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
991 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
992 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
993 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
994 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
995 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
996 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
997 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
998 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
999 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1000 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1001 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1002 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1003 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1004 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1005 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1006 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1007 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1008 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1009 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1011 flags = BindingFlags.Static | BindingFlags.Public;
1013 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1014 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1015 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1016 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1017 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1018 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1019 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1020 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1021 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1022 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1023 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1024 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1025 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1026 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1027 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1028 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1029 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1030 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1031 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1032 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1033 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1034 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1035 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1036 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1037 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1038 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1039 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1040 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1041 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1042 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1044 flags = BindingFlags.Static | BindingFlags.NonPublic;
1046 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1047 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1048 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1049 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1050 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1051 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1052 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1053 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1054 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1055 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1056 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1057 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1058 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1059 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1060 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1061 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1062 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1063 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1064 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1065 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1066 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1067 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1068 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1069 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1070 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1071 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1072 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1073 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1074 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1075 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1077 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1078 BindingFlags.FlattenHierarchy;
1080 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1081 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1082 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1083 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1085 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1087 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#E5");
1089 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1090 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1091 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1092 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1093 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1094 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1095 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1096 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1097 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1098 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1099 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1100 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1101 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1102 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1103 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1104 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1105 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1106 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1107 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1109 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1111 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1113 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1114 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1115 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1116 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1117 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1119 flags = BindingFlags.Instance | BindingFlags.Public |
1120 BindingFlags.FlattenHierarchy;
1122 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1123 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1124 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1125 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1126 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1127 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1128 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1129 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1130 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1131 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1132 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1133 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1134 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1135 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1136 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1137 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1138 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1139 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1140 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1141 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1142 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1143 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1144 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1145 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1146 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1147 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1148 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1149 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1150 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1151 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1153 flags = BindingFlags.Static | BindingFlags.Public |
1154 BindingFlags.FlattenHierarchy;
1156 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1157 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1158 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1159 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1160 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1161 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1162 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1163 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1164 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1165 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1166 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1167 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1168 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1169 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1170 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1171 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1172 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1173 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1174 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1175 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1176 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1177 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1178 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1179 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1180 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1181 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1182 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1183 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1184 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1185 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1187 flags = BindingFlags.Static | BindingFlags.NonPublic |
1188 BindingFlags.FlattenHierarchy;
1190 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1191 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1192 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1193 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1194 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1195 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1196 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1197 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1198 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1199 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1200 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1201 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1202 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1203 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1205 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1207 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#H15");
1209 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1210 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1211 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1212 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1213 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1214 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1215 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1216 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1217 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1218 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1219 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1220 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1221 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1222 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1224 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1226 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#H60");
1229 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1230 BindingFlags.DeclaredOnly;
1232 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1233 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1234 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1235 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1236 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1237 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1238 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1239 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1240 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1241 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1242 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1243 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1244 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1245 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1246 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1247 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1248 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1249 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1250 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1251 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1252 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1253 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1254 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1255 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1256 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1257 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1258 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1259 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1260 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1261 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1263 flags = BindingFlags.Instance | BindingFlags.Public |
1264 BindingFlags.DeclaredOnly;
1266 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1267 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1268 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1269 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1270 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1271 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1272 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1273 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1274 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1275 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1276 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1277 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1278 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1279 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1280 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1281 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1282 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1283 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1284 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1285 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1286 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1287 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1288 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1289 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1290 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1291 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1292 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1293 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1294 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1295 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1297 flags = BindingFlags.Static | BindingFlags.Public |
1298 BindingFlags.DeclaredOnly;
1300 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1301 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1302 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1303 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1304 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1305 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1306 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1307 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1308 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1309 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1310 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1311 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1312 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1313 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1314 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1315 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1316 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1317 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1318 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1319 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1320 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1321 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1322 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1323 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1324 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1325 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1326 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1327 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1328 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1329 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1331 flags = BindingFlags.Static | BindingFlags.NonPublic |
1332 BindingFlags.DeclaredOnly;
1334 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1335 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1336 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1337 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1338 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1339 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1340 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1341 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1342 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1343 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1344 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1345 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1346 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1347 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1348 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1349 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1350 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1351 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1352 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1353 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1354 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1355 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1356 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1357 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1358 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1359 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1360 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1361 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1362 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1363 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1365 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1366 BindingFlags.Public;
1368 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1369 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1370 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1371 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1373 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1375 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#M5");
1377 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1378 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1379 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1380 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1381 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1382 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1383 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1384 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1385 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1386 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1387 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1388 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1389 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1390 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1391 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1392 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1393 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1394 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1395 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1397 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1399 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1401 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1402 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1403 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1404 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1405 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1407 flags = BindingFlags.Static | BindingFlags.NonPublic |
1408 BindingFlags.Public;
1410 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1411 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1412 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1413 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1414 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1415 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1416 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1417 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1418 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1419 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1420 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1421 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1422 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1423 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1424 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1425 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1426 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1427 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1428 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1429 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1430 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1431 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1432 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1433 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1434 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1435 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1436 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1437 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1438 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1439 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1442 [Test] // GetProperty (String, BindingFlags)
1443 public void GetProperty2_Name_Null ()
1445 Type type = typeof (Bar);
1447 type.GetProperty ((string) null);
1449 } catch (ArgumentNullException ex) {
1450 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1451 Assert.IsNull (ex.InnerException, "#3");
1452 Assert.IsNotNull (ex.Message, "#4");
1453 Assert.IsNotNull (ex.ParamName, "#5");
1454 Assert.AreEqual ("name", ex.ParamName, "#6");
1458 [Test] // GetProperty (String, Type)
1459 public void GetProperty3_Name_Null ()
1461 Type type = typeof (Bar);
1463 type.GetProperty ((string) null, typeof (int));
1465 } catch (ArgumentNullException ex) {
1466 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1467 Assert.IsNull (ex.InnerException, "#3");
1468 Assert.IsNotNull (ex.Message, "#4");
1469 Assert.IsNotNull (ex.ParamName, "#5");
1470 Assert.AreEqual ("name", ex.ParamName, "#6");
1474 [Test] // GetProperty (String, Type [])
1475 public void GetProperty4_Name_Null ()
1477 Type type = typeof (Bar);
1479 type.GetProperty ((string) null, Type.EmptyTypes);
1481 } catch (ArgumentNullException ex) {
1482 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1483 Assert.IsNull (ex.InnerException, "#3");
1484 Assert.IsNotNull (ex.Message, "#4");
1485 Assert.IsNotNull (ex.ParamName, "#5");
1486 Assert.AreEqual ("name", ex.ParamName, "#6");
1490 [Test] // GetProperty (String, Type, Type [])
1491 public void GetProperty5_Name_Null ()
1493 Type type = typeof (Bar);
1495 type.GetProperty ((string) null, typeof (int),
1498 } catch (ArgumentNullException ex) {
1499 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1500 Assert.IsNull (ex.InnerException, "#3");
1501 Assert.IsNotNull (ex.Message, "#4");
1502 Assert.IsNotNull (ex.ParamName, "#5");
1503 Assert.AreEqual ("name", ex.ParamName, "#6");
1507 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1508 public void GetProperty6_Name_Null ()
1510 Type type = typeof (Bar);
1512 type.GetProperty ((string) null, typeof (int),
1513 Type.EmptyTypes, null);
1515 } catch (ArgumentNullException ex) {
1516 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1517 Assert.IsNull (ex.InnerException, "#3");
1518 Assert.IsNotNull (ex.Message, "#4");
1519 Assert.IsNotNull (ex.ParamName, "#5");
1520 Assert.AreEqual ("name", ex.ParamName, "#6");
1524 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1525 public void GetProperty7_Name_Null ()
1527 Type type = typeof (Bar);
1529 type.GetProperty ((string) null, BindingFlags.Public,
1530 null, typeof (int), Type.EmptyTypes, null);
1532 } catch (ArgumentNullException ex) {
1533 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1534 Assert.IsNull (ex.InnerException, "#3");
1535 Assert.IsNotNull (ex.Message, "#4");
1536 Assert.IsNotNull (ex.ParamName, "#5");
1537 Assert.AreEqual ("name", ex.ParamName, "#6");
1542 public void GetProperty8_PropertyType ()
1544 Type type = typeof (Bar);
1545 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1546 null, typeof (int), Type.EmptyTypes, null), "#1");
1547 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1548 typeof (long), new Type[0], null), "#2");
1551 #if !TARGET_JVM // StructLayout not supported for TARGET_JVM
1552 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1557 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1564 public void StructLayoutAttribute ()
1566 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1567 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1569 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1570 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1571 Assert.AreEqual (4, attr2.Pack);
1572 Assert.AreEqual (64, attr2.Size);
1574 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1575 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1576 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1579 #endif // TARGET_JVM
1582 public void Namespace ()
1584 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1587 public static void Reflected (ref int a)
1594 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1595 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1599 public void GetInterfaces ()
1601 Type[] t = typeof (Duper).GetInterfaces ();
1602 Assert.AreEqual (1, t.Length);
1603 Assert.AreEqual (typeof (ICloneable), t[0]);
1605 Type[] t2 = typeof (IFace3).GetInterfaces ();
1606 Assert.AreEqual (2, t2.Length);
1612 public void GetFieldIgnoreCase ()
1614 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1628 public void GetPropertyAccessorModifiers ()
1630 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1631 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1636 public void IsAbstract ()
1638 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1639 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1640 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1641 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1642 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1643 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1647 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1648 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1649 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1654 public void IsCOMObject ()
1656 Type type = typeof (string);
1657 Assert.IsFalse (type.IsCOMObject, "#1");
1659 TypeBuilder tb = module.DefineType (genTypeName ());
1660 type = tb.CreateType ();
1661 Assert.IsFalse (type.IsCOMObject, "#2");
1665 public void IsImport ()
1667 Type type = typeof (string);
1668 Assert.IsFalse (type.IsImport, "#1");
1670 TypeBuilder tb = module.DefineType (genTypeName ());
1671 type = tb.CreateType ();
1672 Assert.IsFalse (type.IsImport, "#2");
1674 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1675 TypeAttributes.Interface | TypeAttributes.Abstract);
1676 type = tb.CreateType ();
1677 Assert.IsTrue (type.IsImport, "#3");
1681 public void IsInterface ()
1683 Assert.IsFalse (typeof (string).IsInterface, "#1");
1684 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1688 public void IsPrimitive () {
1689 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1690 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1691 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1695 public void IsValueType ()
1697 Assert.IsTrue (typeof (int).IsValueType, "#1");
1698 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1699 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1700 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1701 Assert.IsFalse (typeof (string).IsValueType, "#5");
1702 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1706 [Category("NotDotNet")]
1707 // Depends on the GAC working, which it doesn't durring make distcheck.
1708 [Category ("NotWorking")]
1709 public void GetTypeWithWhitespace ()
1711 Assert.IsNotNull (Type.GetType
1712 (@"System.Configuration.NameValueSectionHandler,
1717 PublicKeyToken=b77a5c561934e089"));
1721 public void GetTypeNonVectorArray ()
1723 Type t = Type.GetType ("System.String[*]");
1724 Assert.AreEqual ("System.String[*]", t.ToString ());
1728 public void ExerciseFilterName ()
1730 MemberInfo[] mi = typeof(Base).FindMembers(
1732 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1733 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1734 Type.FilterName, "*");
1735 Assert.AreEqual (4, mi.Length);
1736 mi = typeof(Base).FindMembers(
1738 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1739 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1740 Type.FilterName, "Test*");
1741 Assert.AreEqual (2, mi.Length);
1742 mi = typeof(Base).FindMembers(
1744 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1745 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1746 Type.FilterName, "TestVoid");
1747 Assert.AreEqual (1, mi.Length);
1748 mi = typeof(Base).FindMembers(
1750 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1751 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1752 Type.FilterName, "NonExistingMethod");
1753 Assert.AreEqual (0, mi.Length);
1757 public void ExerciseFilterNameIgnoreCase ()
1759 MemberInfo[] mi = typeof(Base).FindMembers(
1761 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1762 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1763 Type.FilterNameIgnoreCase, "*");
1764 Assert.AreEqual (4, mi.Length);
1765 mi = typeof(Base).FindMembers(
1767 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1768 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1769 Type.FilterNameIgnoreCase, "test*");
1770 Assert.AreEqual (2, mi.Length);
1771 mi = typeof(Base).FindMembers(
1773 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1774 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1775 Type.FilterNameIgnoreCase, "TESTVOID");
1776 Assert.AreEqual (1, mi.Length);
1777 mi = typeof(Base).FindMembers(
1779 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1780 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1781 Type.FilterNameIgnoreCase, "NonExistingMethod");
1782 Assert.AreEqual (0, mi.Length);
1788 public int property {
1791 public ByRef0 (int i) {}
1792 public void f (int i) {}
1796 public void ByrefTypes ()
1798 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1799 Assert.IsNotNull (t);
1800 Assert.IsTrue (t.IsByRef);
1801 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1802 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1803 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1804 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1806 Assert.IsNull (t.GetMethod ("f"));
1807 Assert.IsNull (t.GetField ("field"));
1808 Assert.IsNull (t.GetProperty ("property"));
1812 public void TestAssemblyQualifiedName ()
1814 Type t = Type.GetType ("System.Byte[]&");
1815 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1817 t = Type.GetType ("System.Byte*&");
1818 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1820 t = Type.GetType ("System.Byte&");
1821 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1830 public void CreateValueTypeNoCtor ()
1832 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1836 [ExpectedException (typeof (MissingMethodException))]
1837 public void CreateValueTypeNoCtorArgs ()
1839 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1842 internal static string bug336841 (string param1, params string [] param2)
1844 StringBuilder sb = new StringBuilder ();
1848 for (int i = 0; i < param2.Length; i++) {
1851 sb.Append (param2 [i]);
1853 return sb.ToString ();
1856 internal static string bug336841 (string param1)
1858 return "#B:" + param1;
1861 internal static string bug336841 (params string [] param1)
1863 StringBuilder sb = new StringBuilder ();
1865 for (int i = 0; i < param1.Length; i++) {
1868 sb.Append (param1 [i]);
1870 return sb.ToString ();
1874 public void InvokeMember_GetSetField ()
1876 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1877 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1878 BindingFlags.SetField, null, null, new object [] { 5 });
1880 Assert.AreEqual (5, X.Value, "#A1");
1881 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
1882 BindingFlags.Public | BindingFlags.Static |
1883 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1884 null, null, new object [0]), "#A2");
1885 Assert.AreEqual (5, Y.Value, "#A3");
1886 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
1887 BindingFlags.Public | BindingFlags.Static |
1888 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1889 null, null, new object [0]), "#A4");
1892 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1893 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1894 BindingFlags.GetField | BindingFlags.SetField,
1895 null, null, new object [] { 5 });
1896 Assert.Fail ("#B1");
1897 } catch (ArgumentException ex) {
1898 // Cannot specify both Get and Set on a field
1899 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1900 Assert.IsNull (ex.InnerException, "#B3");
1901 Assert.IsNotNull (ex.Message, "#B4");
1902 Assert.IsNotNull (ex.ParamName, "#B5");
1904 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1906 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1912 public void InvokeMember_GetSetProperty ()
1915 typeof (ArrayList).InvokeMember ("Item",
1916 BindingFlags.GetProperty | BindingFlags.SetProperty |
1917 BindingFlags.Instance | BindingFlags.Public,
1918 null, new ArrayList (), new object [] { 0, "bar" });
1920 } catch (ArgumentException ex) {
1921 // Cannot specify both Get and Set on a property
1922 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1923 Assert.IsNull (ex.InnerException, "#3");
1924 Assert.IsNotNull (ex.Message, "#4");
1925 Assert.IsNotNull (ex.ParamName, "#5");
1927 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
1929 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
1936 public void InvokeMember_InvokeMethod_Set ()
1939 typeof (ArrayList).InvokeMember ("ToString",
1940 BindingFlags.InvokeMethod | BindingFlags.SetField |
1941 BindingFlags.Instance | BindingFlags.Public,
1942 null, new ArrayList (), new object [0]);
1943 Assert.Fail ("#A1");
1944 } catch (ArgumentException ex) {
1945 // Cannot specify Set on a field and Invoke on a method
1946 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1947 Assert.IsNull (ex.InnerException, "#A3");
1948 Assert.IsNotNull (ex.Message, "#A4");
1949 Assert.IsNotNull (ex.ParamName, "#A5");
1951 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
1953 Assert.AreEqual ("invokeAttr", ex.ParamName, "#A6");
1958 typeof (ArrayList).InvokeMember ("ToString",
1959 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
1960 BindingFlags.Instance | BindingFlags.Public,
1961 null, new ArrayList (), new object [0]);
1962 Assert.Fail ("#B1");
1963 } catch (ArgumentException ex) {
1964 // Cannot specify Set on a property and Invoke on a method
1965 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1966 Assert.IsNull (ex.InnerException, "#B3");
1967 Assert.IsNotNull (ex.Message, "#B4");
1968 Assert.IsNotNull (ex.ParamName, "#B5");
1970 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1972 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1978 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
1980 object [] invokeargs = { 1 };
1981 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
1982 BindingFlags.Public | BindingFlags.NonPublic |
1983 BindingFlags.Instance | BindingFlags.CreateInstance,
1984 null, null, invokeargs);
1988 public void InvokeMember_Name_Null ()
1991 typeof (X).InvokeMember ((string) null,
1992 BindingFlags.Public | BindingFlags.Static |
1993 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
1994 null, null, new object [] { 5 });
1996 } catch (ArgumentNullException ex) {
1997 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1998 Assert.IsNull (ex.InnerException, "#3");
1999 Assert.IsNotNull (ex.Message, "#4");
2000 Assert.IsNotNull (ex.ParamName, "#5");
2001 Assert.AreEqual ("name", ex.ParamName, "#6");
2006 public void InvokeMember_NoOperation ()
2009 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2010 BindingFlags.Static, null, null, new object [0]);
2012 } catch (ArgumentException ex) {
2013 // Must specify binding flags describing the
2014 // invoke operation required
2015 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2016 Assert.IsNull (ex.InnerException, "#3");
2017 Assert.IsNotNull (ex.Message, "#4");
2018 Assert.IsNotNull (ex.ParamName, "#5");
2020 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2022 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2027 [Test] // bug #321735
2028 public void InvokeMember_SetFieldProperty ()
2030 ArrayList list = new ArrayList ();
2032 list.GetType ().InvokeMember ("Item",
2033 BindingFlags.SetField | BindingFlags.SetProperty |
2034 BindingFlags.Instance | BindingFlags.Public,
2035 null, list, new object [] { 0, "bar" });
2036 Assert.AreEqual ("bar", list [0]);
2040 public void InvokeMember_SetField_ProvidedArgs ()
2043 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2044 BindingFlags.Static | BindingFlags.SetField,
2045 null, null, new object [0]);
2046 Assert.Fail ("#A1");
2047 } catch (ArgumentException ex) {
2048 // Only the field value can be specified to set
2050 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2051 Assert.IsNull (ex.InnerException, "#A3");
2052 Assert.IsNotNull (ex.Message, "#A4");
2053 Assert.IsNotNull (ex.ParamName, "#A5");
2055 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2057 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2062 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2063 BindingFlags.Static | BindingFlags.SetField,
2065 Assert.Fail ("#B1");
2067 } catch (ArgumentNullException ex) {
2068 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2069 Assert.IsNull (ex.InnerException, "#B3");
2070 Assert.IsNotNull (ex.Message, "#B4");
2071 Assert.IsNotNull (ex.ParamName, "#B5");
2072 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2075 } catch (ArgumentException ex) {
2076 // Only the field value can be specified to set
2078 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2079 Assert.IsNull (ex.InnerException, "#B3");
2080 Assert.IsNotNull (ex.Message, "#B4");
2081 Assert.IsNotNull (ex.ParamName, "#B5");
2083 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2085 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
2091 [Test] // bug #336841
2092 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2093 public void InvokeMember_VarArgs ()
2095 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2096 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2097 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2098 BindingFlags.Instance;
2100 Type type = typeof (TypeTest);
2101 string result = (string) type.InvokeMember ("bug336841",
2102 flags, null, null, new object [] { "1" });
2103 Assert.IsNotNull (result, "#A1");
2104 Assert.AreEqual ("#B:1", result, "#A2");
2106 result = (string) type.InvokeMember ("bug336841", flags,
2107 null, null, new object [] { "1", "2", "3", "4" });
2108 Assert.IsNotNull (result, "#B1");
2109 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2113 [Test] // bug #348522
2114 public void InvokeMember_WithoutDefaultValue ()
2116 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;;
2118 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2119 new object [] {Missing.Value}, null, null, null);
2121 } catch (ArgumentException ex) {
2122 // Missing parameter does not have a default value
2123 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2124 Assert.IsNull (ex.InnerException, "#3");
2125 Assert.IsNotNull (ex.Message, "#4");
2126 Assert.IsNotNull (ex.ParamName, "#5");
2127 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2133 public static int Value;
2142 public Z (IComparable value)
2147 public static void Run ()
2155 public TakesInt (int x)
2160 public int Integer {
2167 public TakesObject (object x) {}
2170 [Test] // bug #75241
2171 public void GetConstructorNullInTypes ()
2173 // This ends up calling type.GetConstructor ()
2174 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2175 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2179 public void GetConstructor_TakeInt_Object ()
2181 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2185 public void GetCustomAttributes_All ()
2187 object [] attrs = typeof (A).GetCustomAttributes (false);
2188 Assert.AreEqual (2, attrs.Length, "#A1");
2189 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2190 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2192 attrs = typeof (BA).GetCustomAttributes (false);
2193 Assert.AreEqual (1, attrs.Length, "#B1");
2194 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2196 attrs = typeof (BA).GetCustomAttributes (true);
2197 Assert.AreEqual (2, attrs.Length, "#C1");
2198 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2199 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2201 attrs = typeof (CA).GetCustomAttributes (false);
2202 Assert.AreEqual (0, attrs.Length, "#D");
2204 attrs = typeof (CA).GetCustomAttributes (true);
2205 Assert.AreEqual (1, attrs.Length, "#E1");
2206 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2209 static bool HasAttribute (object [] attrs, Type attributeType)
2211 foreach (object attr in attrs)
2212 if (attr.GetType () == attributeType)
2218 public void GetCustomAttributes_Type ()
2220 object [] attrs = null;
2222 attrs = typeof (A).GetCustomAttributes (
2223 typeof (VolatileModifier), false);
2224 Assert.AreEqual (1, attrs.Length, "#A1");
2225 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2226 attrs = typeof (A).GetCustomAttributes (
2227 typeof (VolatileModifier), true);
2228 Assert.AreEqual (1, attrs.Length, "#A3");
2229 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2231 attrs = typeof (A).GetCustomAttributes (
2232 typeof (NemerleAttribute), false);
2233 Assert.AreEqual (1, attrs.Length, "#B1");
2234 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2235 attrs = typeof (A).GetCustomAttributes (
2236 typeof (NemerleAttribute), true);
2237 Assert.AreEqual (1, attrs.Length, "#B3");
2238 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2240 attrs = typeof (A).GetCustomAttributes (
2241 typeof (FooAttribute), false);
2242 Assert.AreEqual (1, attrs.Length, "#C1");
2243 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2244 attrs = typeof (A).GetCustomAttributes (
2245 typeof (FooAttribute), false);
2246 Assert.AreEqual (1, attrs.Length, "#C3");
2247 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2249 attrs = typeof (BA).GetCustomAttributes (
2250 typeof (VolatileModifier), false);
2251 Assert.AreEqual (0, attrs.Length, "#D1");
2252 attrs = typeof (BA).GetCustomAttributes (
2253 typeof (VolatileModifier), true);
2254 Assert.AreEqual (1, attrs.Length, "#D2");
2255 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2257 attrs = typeof (BA).GetCustomAttributes (
2258 typeof (NemerleAttribute), false);
2259 Assert.AreEqual (0, attrs.Length, "#E1");
2260 attrs = typeof (BA).GetCustomAttributes (
2261 typeof (NemerleAttribute), true);
2262 Assert.AreEqual (1, attrs.Length, "#E2");
2263 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2265 attrs = typeof (BA).GetCustomAttributes (
2266 typeof (FooAttribute), false);
2267 Assert.AreEqual (1, attrs.Length, "#F1");
2268 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2269 attrs = typeof (BA).GetCustomAttributes (
2270 typeof (FooAttribute), true);
2271 Assert.AreEqual (1, attrs.Length, "#F3");
2272 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2274 attrs = typeof (bug82431A1).GetCustomAttributes (
2275 typeof (InheritAttribute), false);
2276 Assert.AreEqual (1, attrs.Length, "#G1");
2277 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2278 attrs = typeof (bug82431A1).GetCustomAttributes (
2279 typeof (InheritAttribute), true);
2280 Assert.AreEqual (1, attrs.Length, "#G3");
2281 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2283 attrs = typeof (bug82431A1).GetCustomAttributes (
2284 typeof (NotInheritAttribute), false);
2285 Assert.AreEqual (1, attrs.Length, "#H1");
2286 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2287 attrs = typeof (bug82431A1).GetCustomAttributes (
2288 typeof (InheritAttribute), true);
2289 Assert.AreEqual (1, attrs.Length, "#H3");
2290 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2292 attrs = typeof (bug82431A2).GetCustomAttributes (
2293 typeof (InheritAttribute), false);
2294 Assert.AreEqual (0, attrs.Length, "#I1");
2295 attrs = typeof (bug82431A2).GetCustomAttributes (
2296 typeof (InheritAttribute), true);
2297 Assert.AreEqual (0, attrs.Length, "#I2");
2299 attrs = typeof (bug82431A2).GetCustomAttributes (
2300 typeof (NotInheritAttribute), false);
2301 Assert.AreEqual (0, attrs.Length, "#J1");
2302 attrs = typeof (bug82431A2).GetCustomAttributes (
2303 typeof (NotInheritAttribute), true);
2304 Assert.AreEqual (0, attrs.Length, "#J2");
2306 attrs = typeof (bug82431A3).GetCustomAttributes (
2307 typeof (InheritAttribute), false);
2308 Assert.AreEqual (2, attrs.Length, "#K1");
2309 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2310 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2311 attrs = typeof (bug82431A3).GetCustomAttributes (
2312 typeof (InheritAttribute), true);
2313 Assert.AreEqual (2, attrs.Length, "#K4");
2314 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2315 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2317 attrs = typeof (bug82431A3).GetCustomAttributes (
2318 typeof (NotInheritAttribute), false);
2319 Assert.AreEqual (1, attrs.Length, "#L1");
2320 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2321 attrs = typeof (bug82431A3).GetCustomAttributes (
2322 typeof (NotInheritAttribute), true);
2323 Assert.AreEqual (1, attrs.Length, "#L3");
2324 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2326 attrs = typeof (bug82431B1).GetCustomAttributes (
2327 typeof (InheritAttribute), false);
2328 Assert.AreEqual (1, attrs.Length, "#M1");
2329 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2330 attrs = typeof (bug82431B1).GetCustomAttributes (
2331 typeof (InheritAttribute), true);
2332 Assert.AreEqual (1, attrs.Length, "#M3");
2333 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2335 attrs = typeof (bug82431B1).GetCustomAttributes (
2336 typeof (NotInheritAttribute), false);
2337 Assert.AreEqual (0, attrs.Length, "#N1");
2338 attrs = typeof (bug82431B1).GetCustomAttributes (
2339 typeof (NotInheritAttribute), true);
2340 Assert.AreEqual (0, attrs.Length, "#N2");
2342 attrs = typeof (bug82431B2).GetCustomAttributes (
2343 typeof (InheritAttribute), false);
2344 Assert.AreEqual (0, attrs.Length, "#O1");
2345 attrs = typeof (bug82431B2).GetCustomAttributes (
2346 typeof (InheritAttribute), true);
2347 Assert.AreEqual (1, attrs.Length, "#O2");
2348 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2350 attrs = typeof (bug82431B2).GetCustomAttributes (
2351 typeof (NotInheritAttribute), false);
2352 Assert.AreEqual (0, attrs.Length, "#P1");
2353 attrs = typeof (bug82431B2).GetCustomAttributes (
2354 typeof (NotInheritAttribute), true);
2355 Assert.AreEqual (0, attrs.Length, "#P2");
2357 attrs = typeof (bug82431B3).GetCustomAttributes (
2358 typeof (InheritAttribute), false);
2359 Assert.AreEqual (1, attrs.Length, "#Q1");
2360 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2361 attrs = typeof (bug82431B3).GetCustomAttributes (
2362 typeof (InheritAttribute), true);
2363 Assert.AreEqual (2, attrs.Length, "#Q3");
2364 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2365 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2367 attrs = typeof (bug82431B3).GetCustomAttributes (
2368 typeof (NotInheritAttribute), false);
2369 Assert.AreEqual (1, attrs.Length, "#R1");
2370 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2371 attrs = typeof (bug82431B3).GetCustomAttributes (
2372 typeof (NotInheritAttribute), true);
2373 Assert.AreEqual (1, attrs.Length, "#R3");
2374 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2376 attrs = typeof (bug82431B4).GetCustomAttributes (
2377 typeof (InheritAttribute), false);
2378 Assert.AreEqual (0, attrs.Length, "#S1");
2379 attrs = typeof (bug82431B4).GetCustomAttributes (
2380 typeof (InheritAttribute), true);
2381 Assert.AreEqual (1, attrs.Length, "#S2");
2382 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2384 attrs = typeof (bug82431B4).GetCustomAttributes (
2385 typeof (NotInheritAttribute), false);
2386 Assert.AreEqual (0, attrs.Length, "#T1");
2387 attrs = typeof (bug82431B4).GetCustomAttributes (
2388 typeof (NotInheritAttribute), true);
2389 Assert.AreEqual (0, attrs.Length, "#T2");
2391 attrs = typeof (A).GetCustomAttributes (
2392 typeof (string), false);
2393 Assert.AreEqual (0, attrs.Length, "#U1");
2394 attrs = typeof (A).GetCustomAttributes (
2395 typeof (string), true);
2396 Assert.AreEqual (0, attrs.Length, "#U2");
2399 [Test] // bug #76150
2400 public void IsDefined ()
2402 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2403 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2404 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2405 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2407 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2408 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2409 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2410 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2411 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2412 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2413 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2414 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2415 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2416 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2417 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2418 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2422 public void IsDefined_AttributeType_Null ()
2425 typeof (BA).IsDefined ((Type) null, false);
2427 } catch (ArgumentNullException ex) {
2428 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2429 Assert.IsNull (ex.InnerException, "#3");
2430 Assert.IsNotNull (ex.Message, "#4");
2431 Assert.IsNotNull (ex.ParamName, "#5");
2432 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2436 [Test] // bug #82431
2438 [Category ("NotWorking")]
2440 public void IsDefined_Inherited ()
2442 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2443 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2444 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2445 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2446 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2447 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2448 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2449 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2451 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2452 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2453 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2454 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2455 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2456 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2458 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2459 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2461 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2462 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2465 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2466 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2467 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2468 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2470 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2471 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2473 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2475 Assert.IsTrue (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2477 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2479 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2480 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2481 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2482 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2484 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2485 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2486 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2487 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2489 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2490 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2491 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2492 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2494 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2495 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2496 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2497 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2499 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2500 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2501 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2502 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2505 [Test] // GetType (String)
2506 public void GetType1_TypeName_Null ()
2509 Type.GetType ((string) null);
2511 } catch (ArgumentNullException ex) {
2512 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2513 Assert.IsNull (ex.InnerException, "#3");
2514 Assert.IsNotNull (ex.Message, "#4");
2516 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2518 Assert.AreEqual ("className", ex.ParamName, "#5");
2523 [Test] // GetType (String, Boolean)
2524 public void GetType2_TypeName_Null ()
2527 Type.GetType ((string) null, false);
2529 } catch (ArgumentNullException ex) {
2530 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2531 Assert.IsNull (ex.InnerException, "#3");
2532 Assert.IsNotNull (ex.Message, "#4");
2534 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2536 Assert.AreEqual ("className", ex.ParamName, "#5");
2541 [Test] // GetType (String, Boolean, Boolean)
2542 public void GetType3_TypeName_Null ()
2545 Type.GetType ((string) null, false, false);
2547 } catch (ArgumentNullException ex) {
2548 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2549 Assert.IsNull (ex.InnerException, "#3");
2550 Assert.IsNotNull (ex.Message, "#4");
2552 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2554 Assert.AreEqual ("className", ex.ParamName, "#5");
2560 public void GetTypeArray_Args_Null ()
2563 Type.GetTypeArray ((object []) null);
2565 } catch (ArgumentNullException ex) {
2566 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2567 Assert.IsNull (ex.InnerException, "#3");
2568 Assert.IsNotNull (ex.Message, "#4");
2569 Assert.AreEqual ("args", ex.ParamName, "#5");
2574 public void GetTypeCode ()
2576 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2577 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2578 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2579 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2580 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2581 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2582 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2583 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2584 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2585 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2586 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2587 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2588 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2589 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2590 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2591 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2592 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2593 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2597 public void GetTypeFromHandle_Handle_Zero ()
2599 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2602 Assert.IsNull (Type.GetTypeFromHandle (handle));
2605 Type.GetTypeFromHandle (handle);
2607 } catch (ArgumentException ex) {
2608 // Handle is not initialized
2609 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2610 Assert.IsNull (ex.InnerException, "#3");
2611 Assert.IsNotNull (ex.Message, "#4");
2612 Assert.IsNull (ex.ParamName, "#5");
2618 public void GetTypeHandle_O_Null ()
2621 Type.GetTypeHandle (null);
2623 } catch (ArgumentNullException ex) {
2624 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2625 Assert.IsNull (ex.InnerException, "#3");
2626 Assert.IsNotNull (ex.Message, "#4");
2628 Assert.IsNull (ex.ParamName, "#5");
2630 Assert.AreEqual ("o", ex.ParamName, "#5");
2635 [Test] // GetConstructor (Type [])
2636 public void GetConstructor1 ()
2639 ConstructorInfo ctor;
2641 type = typeof (CtorsA);
2642 ctor = type.GetConstructor (Type.EmptyTypes);
2643 Assert.IsNotNull (ctor, "#A1");
2644 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2645 Assert.IsFalse (ctor.IsStatic, "#A3");
2646 Assert.IsTrue (ctor.IsPublic, "#A4");
2647 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2649 type = typeof (CtorsB);
2650 ctor = type.GetConstructor (Type.EmptyTypes);
2651 Assert.IsNotNull (ctor, "#B1");
2652 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2653 Assert.IsFalse (ctor.IsStatic, "#B3");
2654 Assert.IsTrue (ctor.IsPublic, "#B4");
2655 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2657 type = typeof (CtorsC);
2658 ctor = type.GetConstructor (Type.EmptyTypes);
2659 Assert.IsNull (ctor, "#C");
2661 type = typeof (CtorsC);
2662 ctor = type.GetConstructor (new Type [] { typeof (int) });
2663 Assert.IsNotNull (ctor, "#D1");
2664 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2665 Assert.IsFalse (ctor.IsStatic, "#D3");
2666 Assert.IsTrue (ctor.IsPublic, "#D4");
2667 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2670 [Test] // GetConstructor (Type [])
2671 public void GetConstructor1_Types_Null ()
2674 typeof (BindingFlags).GetConstructor (null);
2676 } catch (ArgumentNullException ex) {
2677 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2678 Assert.IsNull (ex.InnerException, "#3");
2679 Assert.IsNotNull (ex.Message, "#4");
2680 Assert.IsNotNull (ex.ParamName, "#5");
2681 Assert.AreEqual ("types", ex.ParamName, "#6");
2685 [Test] // GetConstructor (Type [])
2686 public void GetConstructor1_Types_ItemNull ()
2688 Type type = typeof (BindingFlags);
2690 type.GetConstructor (new Type[1] { null });
2691 Assert.Fail ("#A1");
2692 } catch (ArgumentNullException ex) {
2693 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2694 Assert.IsNull (ex.InnerException, "#A3");
2695 Assert.IsNotNull (ex.Message, "#A4");
2696 Assert.IsNotNull (ex.ParamName, "#A5");
2697 Assert.AreEqual ("types", ex.ParamName, "#A6");
2700 type = typeof (TakesInt);
2702 type.GetConstructor (new Type [1] { null });
2703 Assert.Fail ("#B1");
2704 } catch (ArgumentNullException ex) {
2705 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2706 Assert.IsNull (ex.InnerException, "#B3");
2707 Assert.IsNotNull (ex.Message, "#B4");
2708 Assert.IsNotNull (ex.ParamName, "#B5");
2709 Assert.AreEqual ("types", ex.ParamName, "#B6");
2713 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2714 public void GetConstructor2_Types_ItemNull ()
2716 Type type = typeof (BindingFlags);
2718 type.GetConstructor (BindingFlags.Default, null,
2719 new Type[1] { null }, null);
2721 } catch (ArgumentNullException ex) {
2722 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2723 Assert.IsNull (ex.InnerException, "#3");
2724 Assert.IsNotNull (ex.Message, "#4");
2725 Assert.IsNotNull (ex.ParamName, "#5");
2726 Assert.AreEqual ("types", ex.ParamName, "#6");
2730 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2731 public void GetConstructor3_Types_ItemNull ()
2733 Type type = typeof (BindingFlags);
2735 type.GetConstructor (BindingFlags.Default,
2736 null, CallingConventions.Any,
2737 new Type[1] { null }, null);
2739 } catch (ArgumentNullException ex) {
2740 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2741 Assert.IsNull (ex.InnerException, "#3");
2742 Assert.IsNotNull (ex.Message, "#4");
2743 Assert.IsNotNull (ex.ParamName, "#5");
2744 Assert.AreEqual ("types", ex.ParamName, "#6");
2749 public void GetMethod_Bug77367 ()
2751 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2755 #if !TARGET_JVM // Reflection.Emit is not supported for TARGET_JVM
2757 public void EqualsUnderlyingType ()
2759 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2760 TypeAttributes attribs = TypeAttributes.Public;
2762 AssemblyName name = new AssemblyName ();
2763 name.Name = "enumtest";
2764 AssemblyBuilder assembly =
2765 AppDomain.CurrentDomain.DefineDynamicAssembly (
2768 ModuleBuilder module = assembly.DefineDynamicModule
2769 ("m", "enumtest.dll");
2770 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2772 Assert.IsTrue (typeof (int).Equals (e));
2774 #endif // TARGET_JVM
2777 public void Equals_Type_Null ()
2779 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2780 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2784 public void GetElementType_Bug63841 ()
2786 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2791 public void FullNameGenerics ()
2793 Type fooType = typeof (Foo<>);
2794 FieldInfo [] fields = fooType.GetFields ();
2796 Assert.AreEqual (1, fields.Length, "#0");
2798 Assert.IsNotNull (fooType.FullName, "#1");
2799 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2801 FieldInfo field = fooType.GetField ("Whatever");
2802 Assert.IsNotNull (field, "#2");
2803 Assert.AreEqual (field, fields [0], "#2a");
2804 Assert.IsNull (field.FieldType.FullName, "#3");
2805 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2806 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2808 PropertyInfo prop = fooType.GetProperty ("Test");
2809 Assert.IsNotNull (prop, "#5");
2810 Assert.IsNull (prop.PropertyType.FullName, "#6");
2811 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2812 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2814 MethodInfo method = fooType.GetMethod("Execute");
2815 Assert.IsNotNull (method, "#8");
2816 Assert.IsNull (method.ReturnType.FullName, "#9");
2817 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2818 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2820 ParameterInfo[] parameters = method.GetParameters();
2821 Assert.AreEqual (1, parameters.Length, "#11");
2822 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2823 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2824 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2828 public void TypeParameterIsNotGeneric ()
2830 Type fooType = typeof (Foo<>);
2831 Type type_param = fooType.GetGenericArguments () [0];
2832 Assert.IsTrue (type_param.IsGenericParameter);
2833 Assert.IsFalse (type_param.IsGenericType);
2834 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2836 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2837 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2838 Assert.IsTrue (type_param.ContainsGenericParameters);
2842 public void IsAssignable ()
2844 Type foo_type = typeof (Foo<>);
2845 Type foo_int_type = typeof (Foo<int>);
2846 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
2847 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
2849 Type ibar_short_type = typeof (IBar<short>);
2850 Type ibar_int_type = typeof (IBar<int>);
2851 Type baz_short_type = typeof (Baz<short>);
2852 Type baz_int_type = typeof (Baz<int>);
2854 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
2855 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
2857 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
2858 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
2861 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
2862 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
2863 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
2867 public void IsInstanceOf ()
2869 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
2873 public void IsInstanceOfArrayOfNullable ()
2875 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
2879 public void ByrefType ()
2881 Type foo_type = typeof (Foo<>);
2882 Type type_param = foo_type.GetGenericArguments () [0];
2883 Type byref_type_param = type_param.MakeByRefType ();
2884 Assert.IsFalse (byref_type_param.IsGenericParameter);
2885 Assert.IsNull (byref_type_param.DeclaringType);
2889 public class ComFoo<T> {
2893 public void GetCustomAttributesGenericInstance ()
2895 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
2898 interface ByRef1<T> { void f (ref T t); }
2899 interface ByRef2 { void f<T> (ref T t); }
2901 interface ByRef3<T> where T:struct { void f (ref T? t); }
2902 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
2904 void CheckGenericByRef (Type t)
2906 string name = t.Name;
2907 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
2909 Assert.IsFalse (t.IsGenericType, name);
2910 Assert.IsFalse (t.IsGenericTypeDefinition, name);
2911 Assert.IsFalse (t.IsGenericParameter, name);
2915 public void GenericByRef ()
2917 CheckGenericByRef (typeof (ByRef1<>));
2918 CheckGenericByRef (typeof (ByRef2));
2919 CheckGenericByRef (typeof (ByRef3<>));
2920 CheckGenericByRef (typeof (ByRef4));
2923 public class Bug80242<T> {
2924 public interface IFoo { }
2925 public class Bar : IFoo { }
2926 public class Baz : Bar { }
2930 public void TestNestedTypes ()
2932 Type t = typeof (Bug80242<object>);
2933 Assert.IsFalse (t.IsGenericTypeDefinition);
2934 foreach (Type u in t.GetNestedTypes ()) {
2935 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
2936 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
2940 [Test] // bug #82211
2941 public void GetMembers_GenericArgument ()
2943 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
2944 MemberInfo [] members = argType.GetMembers ();
2945 Assert.IsNotNull (members, "#1");
2946 Assert.AreEqual (4, members.Length, "#2");
2950 [ExpectedException (typeof (ArgumentNullException))]
2951 public void ReflectionOnlyGetTypeNullTypeName ()
2953 Type.ReflectionOnlyGetType (null, false, false);
2957 public void ReflectionOnlyGetTypeDoNotThrow ()
2959 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
2963 [ExpectedException (typeof (FileNotFoundException))]
2964 public void ReflectionOnlyGetTypeThrow ()
2966 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
2970 public void ReflectionOnlyGetType ()
2972 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
2973 Assert.AreEqual ("System.Int32", t.FullName);
2976 [Test] //bug #331199
2977 //FIXME: 2.0 SP 1 has a diferent behavior
2978 public void MakeGenericType_UserDefinedType ()
2980 Type ut = new UserType (typeof (int));
2981 Type t = typeof (Foo<>).MakeGenericType (ut);
2982 Assert.IsTrue (t.IsGenericType, "#A1");
2983 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2985 Type arg = t.GetGenericArguments () [0];
2986 Assert.IsNotNull (arg, "#B1");
2987 Assert.IsFalse (arg.IsGenericType, "#B2");
2988 Assert.AreEqual (typeof (int), arg, "#B3");
2991 [Category ("NotWorking")]
2992 //We dont support instantiating a user type
2993 public void MakeGenericType_NestedUserDefinedType ()
2995 Type ut = new UserType (new UserType (typeof (int)));
2996 Type t = typeof (Foo<>).MakeGenericType (ut);
2997 Assert.IsTrue (t.IsGenericType, "#A1");
2998 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3000 Type arg = t.GetGenericArguments () [0];
3001 Assert.IsNotNull (arg, "#B1");
3002 Assert.IsFalse (arg.IsGenericType, "#B2");
3003 Assert.AreEqual (ut, arg, "#B3");
3007 [Category ("NotWorking")]
3008 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3010 Type ut = new UserType(typeof(int));
3011 Type t = typeof(Foo<>).MakeGenericType(ut);
3012 Assert.IsTrue (t.IsGenericType, "#1");
3014 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3018 public void MakeGenericType_BadUserType ()
3020 Type ut = new UserType (null);
3022 Type t = typeof (Foo<>).MakeGenericType (ut);
3024 } catch (ArgumentException) {
3029 public void MakeGenericType_WrongNumOfArguments ()
3032 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3034 } catch (ArgumentException) {
3038 [AttributeUsage (AttributeTargets.All)]
3039 public class DocAttribute : Attribute {
3040 public DocAttribute (string docs) {}
3043 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3044 where T : class, new ()
3047 public T Bar { get{return null;}}
3049 public void M<[Doc ("X")] X> (X x)
3054 [Test] //bug #377596
3055 public void GetGenericArguments_ArgumentsHaveAttributes ()
3057 Type type = typeof(GenericClassWithAttributes<,>);
3058 Type[] tArgs = type.GetGenericArguments ();
3059 MethodInfo m = type.GetMethod ("M");
3060 Type[] mArgs = m.GetGenericArguments ();
3061 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3062 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3063 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3067 public void EqualsUserType () {
3068 UserType2 t1 = new UserType2(null);
3069 UserType2 t2 = new UserType2(t1);
3070 Assert.IsTrue (t1.Equals(t2));
3074 public void GetHashCodeUserType () {
3075 UserType2 t1 = new UserType2(null);
3076 UserType2 t2 = new UserType2(t1);
3077 Assert.AreEqual (42, t2.GetHashCode());
3082 public void TypeGetMemberReturnTypeTest ()
3085 MemberTypes memtype;
3087 object [] flagsandtypes = new object [] {
3088 MemberTypes.All, typeof (MemberInfo []),
3089 MemberTypes.Constructor, typeof (ConstructorInfo []),
3090 MemberTypes.Custom, typeof (MemberInfo []),
3091 MemberTypes.Event, typeof (EventInfo []),
3092 MemberTypes.Field, typeof (FieldInfo []),
3093 MemberTypes.Method, typeof (MethodInfo []),
3094 MemberTypes.NestedType, typeof (Type []),
3095 MemberTypes.Property, typeof (PropertyInfo []),
3096 MemberTypes.TypeInfo, typeof (Type [])};
3098 for (int i=0; i < flagsandtypes.Length; i+=2) {
3099 memtype = (MemberTypes)flagsandtypes [i];
3100 testtype = (Type)flagsandtypes [i+1];
3101 obj = GetType ().GetMember ("DummyMember", memtype,
3102 BindingFlags.Public | BindingFlags.Instance);
3103 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3104 "Expected " + testtype.FullName);
3110 public void TypeNameStartsWithSpace ()
3112 Type t1 = Type.GetType ("System.Type, mscorlib");
3113 Type t2 = Type.GetType (" System.Type, mscorlib");
3114 Assert.AreEqual (t1, t2);
3117 static bool ContainsProperty (PropertyInfo [] props, string name)
3119 foreach (PropertyInfo p in props)
3125 public class NemerleAttribute : Attribute
3129 public class VolatileModifier : NemerleAttribute
3139 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3140 public class FooAttribute : Attribute
3144 public class BarAttribute : FooAttribute
3161 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
3162 public class InheritAttribute : Attribute
3166 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3167 public class NotInheritAttribute : InheritAttribute
3171 [NotInheritAttribute]
3172 public class bug82431A1
3176 public class bug82431A2 : bug82431A1
3180 [NotInheritAttribute]
3182 public class bug82431A3 : bug82431A1
3187 public class bug82431B1
3191 public class bug82431B2 : bug82431B1
3195 [NotInheritAttribute]
3196 public class bug82431B3 : bug82431B2
3200 public class bug82431B4 : bug82431B3
3208 public class Bug77367
3210 public void Run (bool b)
3217 private string PrivInstBlue
3219 get { return null; }
3222 protected string ProtInstBlue
3224 get { return null; }
3227 protected internal string ProIntInstBlue
3229 get { return null; }
3232 public long PubInstBlue
3236 if (PrivInstBlue == null)
3238 return long.MaxValue;
3242 internal int IntInstBlue
3247 private static string PrivStatBlue
3249 get { return null; }
3252 protected static string ProtStatBlue
3254 get { return null; }
3257 protected static internal string ProIntStatBlue
3259 get { return null; }
3262 public static long PubStatBlue
3266 if (PrivStatBlue == null)
3268 return long.MaxValue;
3272 internal static int IntStatBlue
3278 public class Foo : Blue
3280 private string PrivInstBase
3282 get { return null; }
3285 protected string ProtInstBase
3287 get { return null; }
3290 protected internal string ProIntInstBase
3292 get { return null; }
3295 public long PubInstBase
3299 if (PrivInstBase == null)
3301 return long.MaxValue;
3305 internal int IntInstBase
3310 private static string PrivStatBase
3312 get { return null; }
3315 protected static string ProtStatBase
3317 get { return null; }
3320 protected static internal string ProIntStatBase
3322 get { return null; }
3325 public static long PubStatBase
3329 if (PrivStatBase == null)
3331 return long.MaxValue;
3335 internal static int IntStatBase
3341 public class Bar : Foo
3343 private string PrivInst
3345 get { return null; }
3348 protected string ProtInst
3350 get { return null; }
3353 protected internal string ProIntInst
3355 get { return null; }
3362 if (PrivInst == null)
3364 return long.MaxValue;
3368 internal int IntInst
3373 private static string PrivStat
3375 get { return null; }
3378 protected static string ProtStat
3380 get { return null; }
3383 protected static internal string ProIntStat
3385 get { return null; }
3388 public static long PubStat
3392 if (PrivStat == null)
3394 return long.MaxValue;
3398 internal static int IntStat
3424 public CtorsC (int x)
3431 class UserType : Type
3433 protected Type type;
3435 public UserType(Type type) {
3439 public override Type UnderlyingSystemType { get { return this.type; } }
3441 public override Assembly Assembly { get { return this.type.Assembly; } }
3443 public override string AssemblyQualifiedName { get { return null; } }
3445 public override Type BaseType { get { return null; } }
3447 public override Module Module { get { return this.type.Module; } }
3449 public override string Namespace { get { return null; } }
3451 public override bool IsGenericParameter { get { return true; } }
3453 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
3455 public override bool ContainsGenericParameters { get { return true; } }
3457 public override string FullName { get { return this.type.Name; } }
3459 public override Guid GUID { get { throw new NotSupportedException(); } }
3462 protected override bool IsArrayImpl() {
3466 protected override bool IsByRefImpl()
3471 protected override bool IsCOMObjectImpl()
3476 protected override bool IsPointerImpl()
3481 protected override bool IsPrimitiveImpl()
3487 protected override TypeAttributes GetAttributeFlagsImpl()
3492 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
3493 CallingConventions callConvention, Type[] types,
3494 ParameterModifier[] modifiers)
3499 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
3504 public override Type GetElementType()
3509 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
3515 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
3521 public override Type GetInterface(string name, bool ignoreCase)
3526 public override Type[] GetInterfaces()
3531 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
3536 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
3541 public override object[] GetCustomAttributes(bool inherit)
3546 public override bool IsDefined(Type attributeType, bool inherit)
3551 public override string Name { get { return this.type.Name; } }
3553 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
3555 throw new NotImplementedException();
3558 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
3560 throw new NotImplementedException();
3563 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
3564 CallingConventions callConvention, Type[] types,
3565 ParameterModifier[] modifiers)
3570 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
3575 public override Type GetNestedType(string name, BindingFlags bindingAttr)
3580 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
3585 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
3590 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
3591 Type returnType, Type[] types, ParameterModifier[] modifiers)
3596 protected override bool HasElementTypeImpl()
3601 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
3602 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
3603 string[] namedParameters)
3605 throw new NotSupportedException();
3609 class UserType2 : UserType {
3610 public UserType2 (Type type) : base (type) {
3613 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
3615 public override int GetHashCode()
3619 return type.GetHashCode();