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 [ExpectedException (typeof (ArgumentException))]
337 public void GetInterfaceMapOnInterface ()
339 typeof (IList).GetInterfaceMap (typeof (ICollection));
343 public void TestIsSubclassOf ()
345 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
347 // Tests for byref types
348 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
349 Assert.IsTrue (!paramType.IsSubclassOf (typeof (ValueType)), "#02");
350 //Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
351 Assert.IsTrue (!paramType.IsSubclassOf (paramType), "#04");
355 public void TestGetMethodImpl ()
357 // Test binding of new slot methods (using no types)
358 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
359 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
361 // Test binding of new slot methods (using types)
362 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
363 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
365 // Test overload resolution
366 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
368 // Test byref parameters
369 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
370 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
371 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
375 [Category ("TargetJvmNotWorking")]
376 public void TestGetPropertyImpl ()
378 // Test getting property that is exact
379 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
381 // Test getting property that is not exact
382 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
384 // Test overriding of properties when only the set accessor is overriden
385 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
389 public void GetProperties ()
391 // Test hide-by-name-and-signature
392 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length);
393 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType);
396 [Test] // GetProperties (BindingFlags)
397 public void GetProperties_Flags ()
399 PropertyInfo [] props;
400 Type type = typeof (Bar);
403 flags = BindingFlags.Instance | BindingFlags.NonPublic;
404 props = type.GetProperties (flags);
406 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
407 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
408 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
409 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
411 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
413 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#A5");
415 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
416 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
417 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
418 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
419 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
420 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
421 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
422 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
423 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
424 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
425 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
426 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
427 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
428 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
429 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
430 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
431 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
432 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
433 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
435 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
437 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#A25");
439 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
440 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
441 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
442 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
443 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
445 flags = BindingFlags.Instance | BindingFlags.Public;
446 props = type.GetProperties (flags);
448 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
449 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
450 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
451 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
452 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
453 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
454 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
455 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
456 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
457 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
458 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
459 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
460 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
461 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
462 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
463 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
464 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
465 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
466 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
467 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
468 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
469 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
470 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
471 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
472 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
473 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
474 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
475 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
476 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
477 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
479 flags = BindingFlags.Static | BindingFlags.Public;
480 props = type.GetProperties (flags);
482 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
483 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
484 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
485 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
486 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
487 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
488 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
489 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
490 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
491 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
492 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
493 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
494 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
495 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
496 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
497 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
498 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
499 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
500 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
501 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
502 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
503 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
504 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
505 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
506 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
507 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
508 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
509 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
510 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
511 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
513 flags = BindingFlags.Static | BindingFlags.NonPublic;
514 props = type.GetProperties (flags);
516 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
517 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
518 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
519 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
520 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
521 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
522 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
523 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
524 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
525 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
526 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
527 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
528 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
529 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
530 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
531 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
532 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
533 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
534 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
535 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
536 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
537 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
538 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
539 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
540 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
541 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
542 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
543 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
544 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
545 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
547 flags = BindingFlags.Instance | BindingFlags.NonPublic |
548 BindingFlags.FlattenHierarchy;
549 props = type.GetProperties (flags);
551 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
552 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
553 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
554 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
556 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
558 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#E5");
560 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
561 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
562 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
563 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
564 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
565 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
566 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
567 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
568 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
569 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
570 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
571 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
572 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
573 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
574 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
575 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
576 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
577 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
578 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
580 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
582 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#E25");
584 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
585 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
586 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
587 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
588 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
590 flags = BindingFlags.Instance | BindingFlags.Public |
591 BindingFlags.FlattenHierarchy;
592 props = type.GetProperties (flags);
594 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
595 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
596 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
597 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
598 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
599 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
600 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
601 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
602 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
603 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
604 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
605 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
606 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
607 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
608 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
609 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
610 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
611 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
612 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
613 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
614 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
615 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
616 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
617 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
618 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
619 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
620 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
621 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
622 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
623 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
625 flags = BindingFlags.Static | BindingFlags.Public |
626 BindingFlags.FlattenHierarchy;
627 props = type.GetProperties (flags);
629 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
630 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
631 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
632 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
633 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
634 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
635 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
636 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
637 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
638 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
639 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
640 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
641 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
642 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
643 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
644 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
645 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
646 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
647 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
648 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
649 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
650 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
651 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
652 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
653 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
654 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
655 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
656 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
657 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
658 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
660 flags = BindingFlags.Static | BindingFlags.NonPublic |
661 BindingFlags.FlattenHierarchy;
662 props = type.GetProperties (flags);
664 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
665 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
666 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
667 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
668 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
669 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
670 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
671 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
672 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
673 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
674 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
675 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
676 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
677 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
679 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
681 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#H15");
683 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
684 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
685 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
686 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
687 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
688 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
689 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
690 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
691 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
692 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
693 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
694 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
695 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
696 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
698 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
700 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#H50");
703 flags = BindingFlags.Instance | BindingFlags.NonPublic |
704 BindingFlags.DeclaredOnly;
705 props = type.GetProperties (flags);
707 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
708 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
709 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
710 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
711 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
712 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
713 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
714 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
715 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
716 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
717 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
718 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
719 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
720 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
721 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
722 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
723 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
724 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
725 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
726 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
727 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
728 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
729 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
730 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
731 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
732 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
733 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
734 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
735 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
736 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
738 flags = BindingFlags.Instance | BindingFlags.Public |
739 BindingFlags.DeclaredOnly;
740 props = type.GetProperties (flags);
742 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
743 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
744 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
745 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
746 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
747 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
748 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
749 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
750 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
751 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
752 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
753 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
754 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
755 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
756 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
757 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
758 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
759 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
760 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
761 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
762 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
763 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
764 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
765 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
766 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
767 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
768 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
769 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
770 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
771 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
773 flags = BindingFlags.Static | BindingFlags.Public |
774 BindingFlags.DeclaredOnly;
775 props = type.GetProperties (flags);
777 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
778 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
779 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
780 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
781 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
782 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
783 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
784 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
785 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
786 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
787 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
788 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
789 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
790 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
791 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
792 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
793 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
794 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
795 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
796 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
797 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
798 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
799 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
800 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
801 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
802 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
803 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
804 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
805 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
806 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
808 flags = BindingFlags.Static | BindingFlags.NonPublic |
809 BindingFlags.DeclaredOnly;
810 props = type.GetProperties (flags);
812 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
813 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
814 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
815 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
816 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
817 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
818 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
819 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
820 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
821 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
822 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
823 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
824 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
825 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
826 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
827 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
828 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
829 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
830 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
831 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
832 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
833 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
834 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
835 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
836 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
837 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
838 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
839 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
840 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
841 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
843 flags = BindingFlags.Instance | BindingFlags.NonPublic |
845 props = type.GetProperties (flags);
847 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
848 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
849 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
850 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
852 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
854 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#M5");
856 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
857 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
858 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
859 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
860 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
861 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
862 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
863 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
864 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
865 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
866 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
867 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
868 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
869 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
870 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
871 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
872 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
873 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
874 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
876 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
878 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#M25");
880 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
881 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
882 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
883 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
884 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
886 flags = BindingFlags.Static | BindingFlags.NonPublic |
888 props = type.GetProperties (flags);
890 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
891 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
892 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
893 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
894 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
895 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
896 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
897 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
898 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
899 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
900 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
901 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
902 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
903 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
904 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
905 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
906 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
907 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
908 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
909 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
910 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
911 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
912 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
913 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
914 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
915 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
916 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
917 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
918 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
919 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
922 [Test] // GetProperty (String)
923 public void GetProperty1_Name_Null ()
925 Type type = typeof (Bar);
927 type.GetProperty ((string) null);
929 } catch (ArgumentNullException ex) {
930 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
931 Assert.IsNull (ex.InnerException, "#3");
932 Assert.IsNotNull (ex.Message, "#4");
933 Assert.IsNotNull (ex.ParamName, "#5");
934 Assert.AreEqual ("name", ex.ParamName, "#6");
938 [Test] // GetProperty (String, BindingFlags)
939 public void GetProperty2 ()
941 Type type = typeof (Bar);
944 flags = BindingFlags.Instance | BindingFlags.NonPublic;
946 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
947 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
948 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
949 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
951 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
953 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#A5");
955 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
956 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
957 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
958 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
959 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
960 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
961 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
962 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
963 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
964 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
965 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
966 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
967 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
968 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
969 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
970 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
971 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
972 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
973 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
975 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
977 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#A25");
979 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
980 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
981 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
982 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
983 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
985 flags = BindingFlags.Instance | BindingFlags.Public;
987 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
988 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
989 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
990 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
991 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
992 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
993 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
994 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
995 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
996 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
997 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
998 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
999 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
1000 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
1001 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
1002 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
1003 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
1004 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
1005 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
1006 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1007 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1008 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1009 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1010 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1011 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1012 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1013 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1014 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1015 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1016 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1018 flags = BindingFlags.Static | BindingFlags.Public;
1020 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1021 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1022 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1023 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1024 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1025 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1026 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1027 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1028 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1029 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1030 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1031 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1032 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1033 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1034 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1035 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1036 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1037 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1038 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1039 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1040 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1041 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1042 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1043 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1044 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1045 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1046 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1047 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1048 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1049 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1051 flags = BindingFlags.Static | BindingFlags.NonPublic;
1053 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1054 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1055 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1056 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1057 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1058 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1059 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1060 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1061 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1062 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1063 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1064 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1065 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1066 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1067 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1068 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1069 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1070 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1071 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1072 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1073 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1074 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1075 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1076 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1077 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1078 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1079 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1080 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1081 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1082 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1084 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1085 BindingFlags.FlattenHierarchy;
1087 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1088 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1089 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1090 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1092 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1094 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#E5");
1096 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1097 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1098 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1099 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1100 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1101 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1102 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1103 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1104 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1105 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1106 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1107 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1108 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1109 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1110 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1111 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1112 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1113 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1114 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1116 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1118 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1120 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1121 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1122 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1123 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1124 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1126 flags = BindingFlags.Instance | BindingFlags.Public |
1127 BindingFlags.FlattenHierarchy;
1129 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1130 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1131 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1132 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1133 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1134 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1135 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1136 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1137 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1138 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1139 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1140 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1141 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1142 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1143 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1144 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1145 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1146 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1147 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1148 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1149 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1150 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1151 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1152 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1153 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1154 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1155 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1156 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1157 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1158 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1160 flags = BindingFlags.Static | BindingFlags.Public |
1161 BindingFlags.FlattenHierarchy;
1163 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1164 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1165 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1166 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1167 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1168 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1169 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1170 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1171 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1172 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1173 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1174 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1175 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1176 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1177 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1178 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1179 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1180 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1181 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1182 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1183 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1184 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1185 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1186 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1187 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1188 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1189 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1190 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1191 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1192 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1194 flags = BindingFlags.Static | BindingFlags.NonPublic |
1195 BindingFlags.FlattenHierarchy;
1197 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1198 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1199 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1200 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1201 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1202 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1203 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1204 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1205 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1206 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1207 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1208 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1209 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1210 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1212 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1214 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#H15");
1216 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1217 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1218 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1219 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1220 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1221 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1222 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1223 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1224 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1225 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1226 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1227 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1228 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1229 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1231 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1233 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#H60");
1236 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1237 BindingFlags.DeclaredOnly;
1239 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1240 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1241 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1242 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1243 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1244 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1245 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1246 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1247 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1248 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1249 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1250 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1251 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1252 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1253 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1254 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1255 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1256 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1257 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1258 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1259 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1260 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1261 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1262 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1263 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1264 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1265 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1266 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1267 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1268 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1270 flags = BindingFlags.Instance | BindingFlags.Public |
1271 BindingFlags.DeclaredOnly;
1273 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1274 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1275 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1276 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1277 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1278 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1279 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1280 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1281 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1282 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1283 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1284 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1285 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1286 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1287 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1288 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1289 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1290 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1291 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1292 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1293 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1294 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1295 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1296 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1297 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1298 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1299 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1300 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1301 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1302 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1304 flags = BindingFlags.Static | BindingFlags.Public |
1305 BindingFlags.DeclaredOnly;
1307 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1308 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1309 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1310 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1311 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1312 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1313 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1314 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1315 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1316 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1317 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1318 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1319 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1320 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1321 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1322 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1323 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1324 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1325 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1326 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1327 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1328 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1329 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1330 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1331 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1332 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1333 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1334 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1335 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1336 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1338 flags = BindingFlags.Static | BindingFlags.NonPublic |
1339 BindingFlags.DeclaredOnly;
1341 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1342 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1343 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1344 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1345 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1346 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1347 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1348 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1349 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1350 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1351 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1352 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1353 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1354 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1355 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1356 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1357 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1358 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1359 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1360 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1361 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1362 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1363 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1364 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1365 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1366 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1367 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1368 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1369 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1370 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1372 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1373 BindingFlags.Public;
1375 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1376 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1377 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1378 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1380 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1382 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#M5");
1384 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1385 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1386 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1387 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1388 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1389 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1390 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1391 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1392 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1393 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1394 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1395 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1396 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1397 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1398 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1399 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1400 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1401 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1402 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1404 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1406 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1408 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1409 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1410 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1411 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1412 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1414 flags = BindingFlags.Static | BindingFlags.NonPublic |
1415 BindingFlags.Public;
1417 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1418 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1419 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1420 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1421 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1422 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1423 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1424 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1425 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1426 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1427 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1428 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1429 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1430 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1431 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1432 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1433 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1434 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1435 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1436 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1437 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1438 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1439 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1440 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1441 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1442 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1443 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1444 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1445 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1446 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1449 [Test] // GetProperty (String, BindingFlags)
1450 public void GetProperty2_Name_Null ()
1452 Type type = typeof (Bar);
1454 type.GetProperty ((string) null);
1456 } catch (ArgumentNullException ex) {
1457 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1458 Assert.IsNull (ex.InnerException, "#3");
1459 Assert.IsNotNull (ex.Message, "#4");
1460 Assert.IsNotNull (ex.ParamName, "#5");
1461 Assert.AreEqual ("name", ex.ParamName, "#6");
1465 [Test] // GetProperty (String, Type)
1466 public void GetProperty3_Name_Null ()
1468 Type type = typeof (Bar);
1470 type.GetProperty ((string) null, typeof (int));
1472 } catch (ArgumentNullException ex) {
1473 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1474 Assert.IsNull (ex.InnerException, "#3");
1475 Assert.IsNotNull (ex.Message, "#4");
1476 Assert.IsNotNull (ex.ParamName, "#5");
1477 Assert.AreEqual ("name", ex.ParamName, "#6");
1481 [Test] // GetProperty (String, Type [])
1482 public void GetProperty4_Name_Null ()
1484 Type type = typeof (Bar);
1486 type.GetProperty ((string) null, Type.EmptyTypes);
1488 } catch (ArgumentNullException ex) {
1489 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1490 Assert.IsNull (ex.InnerException, "#3");
1491 Assert.IsNotNull (ex.Message, "#4");
1492 Assert.IsNotNull (ex.ParamName, "#5");
1493 Assert.AreEqual ("name", ex.ParamName, "#6");
1497 [Test] // GetProperty (String, Type, Type [])
1498 public void GetProperty5_Name_Null ()
1500 Type type = typeof (Bar);
1502 type.GetProperty ((string) null, typeof (int),
1505 } catch (ArgumentNullException ex) {
1506 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1507 Assert.IsNull (ex.InnerException, "#3");
1508 Assert.IsNotNull (ex.Message, "#4");
1509 Assert.IsNotNull (ex.ParamName, "#5");
1510 Assert.AreEqual ("name", ex.ParamName, "#6");
1514 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1515 public void GetProperty6_Name_Null ()
1517 Type type = typeof (Bar);
1519 type.GetProperty ((string) null, typeof (int),
1520 Type.EmptyTypes, null);
1522 } catch (ArgumentNullException ex) {
1523 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1524 Assert.IsNull (ex.InnerException, "#3");
1525 Assert.IsNotNull (ex.Message, "#4");
1526 Assert.IsNotNull (ex.ParamName, "#5");
1527 Assert.AreEqual ("name", ex.ParamName, "#6");
1531 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1532 public void GetProperty7_Name_Null ()
1534 Type type = typeof (Bar);
1536 type.GetProperty ((string) null, BindingFlags.Public,
1537 null, typeof (int), Type.EmptyTypes, null);
1539 } catch (ArgumentNullException ex) {
1540 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1541 Assert.IsNull (ex.InnerException, "#3");
1542 Assert.IsNotNull (ex.Message, "#4");
1543 Assert.IsNotNull (ex.ParamName, "#5");
1544 Assert.AreEqual ("name", ex.ParamName, "#6");
1549 public void GetProperty8_PropertyType ()
1551 Type type = typeof (Bar);
1552 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1553 null, typeof (int), Type.EmptyTypes, null), "#1");
1554 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1555 typeof (long), new Type[0], null), "#2");
1558 #if !TARGET_JVM // StructLayout not supported for TARGET_JVM
1559 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1564 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1571 public void StructLayoutAttribute ()
1573 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1574 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1576 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1577 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1578 Assert.AreEqual (4, attr2.Pack);
1579 Assert.AreEqual (64, attr2.Size);
1581 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1582 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1583 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1586 #endif // TARGET_JVM
1589 public void Namespace ()
1591 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1594 public static void Reflected (ref int a)
1601 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1602 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1606 public void GetInterfaces ()
1608 Type[] t = typeof (Duper).GetInterfaces ();
1609 Assert.AreEqual (1, t.Length);
1610 Assert.AreEqual (typeof (ICloneable), t[0]);
1612 Type[] t2 = typeof (IFace3).GetInterfaces ();
1613 Assert.AreEqual (2, t2.Length);
1619 public void GetFieldIgnoreCase ()
1621 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1635 public void GetPropertyAccessorModifiers ()
1637 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1638 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1643 public void IsAbstract ()
1645 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1646 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1647 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1648 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1649 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1650 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1654 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1655 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1656 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1661 public void IsCOMObject ()
1663 Type type = typeof (string);
1664 Assert.IsFalse (type.IsCOMObject, "#1");
1666 TypeBuilder tb = module.DefineType (genTypeName ());
1667 type = tb.CreateType ();
1668 Assert.IsFalse (type.IsCOMObject, "#2");
1672 public void IsImport ()
1674 Type type = typeof (string);
1675 Assert.IsFalse (type.IsImport, "#1");
1677 TypeBuilder tb = module.DefineType (genTypeName ());
1678 type = tb.CreateType ();
1679 Assert.IsFalse (type.IsImport, "#2");
1681 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1682 TypeAttributes.Interface | TypeAttributes.Abstract);
1683 type = tb.CreateType ();
1684 Assert.IsTrue (type.IsImport, "#3");
1688 public void IsInterface ()
1690 Assert.IsFalse (typeof (string).IsInterface, "#1");
1691 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1695 public void IsPrimitive () {
1696 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1697 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1698 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1702 public void IsValueType ()
1704 Assert.IsTrue (typeof (int).IsValueType, "#1");
1705 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1706 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1707 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1708 Assert.IsFalse (typeof (string).IsValueType, "#5");
1709 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1713 [Category("NotDotNet")]
1714 // Depends on the GAC working, which it doesn't durring make distcheck.
1715 [Category ("NotWorking")]
1716 public void GetTypeWithWhitespace ()
1718 Assert.IsNotNull (Type.GetType
1719 (@"System.Configuration.NameValueSectionHandler,
1724 PublicKeyToken=b77a5c561934e089"));
1728 public void GetTypeNonVectorArray ()
1730 Type t = Type.GetType ("System.String[*]");
1731 Assert.AreEqual ("System.String[*]", t.ToString ());
1735 public void ExerciseFilterName ()
1737 MemberInfo[] mi = typeof(Base).FindMembers(
1739 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1740 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1741 Type.FilterName, "*");
1742 Assert.AreEqual (4, mi.Length);
1743 mi = typeof(Base).FindMembers(
1745 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1746 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1747 Type.FilterName, "Test*");
1748 Assert.AreEqual (2, mi.Length);
1749 mi = typeof(Base).FindMembers(
1751 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1752 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1753 Type.FilterName, "TestVoid");
1754 Assert.AreEqual (1, mi.Length);
1755 mi = typeof(Base).FindMembers(
1757 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1758 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1759 Type.FilterName, "NonExistingMethod");
1760 Assert.AreEqual (0, mi.Length);
1764 public void ExerciseFilterNameIgnoreCase ()
1766 MemberInfo[] mi = typeof(Base).FindMembers(
1768 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1769 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1770 Type.FilterNameIgnoreCase, "*");
1771 Assert.AreEqual (4, mi.Length);
1772 mi = typeof(Base).FindMembers(
1774 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1775 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1776 Type.FilterNameIgnoreCase, "test*");
1777 Assert.AreEqual (2, mi.Length);
1778 mi = typeof(Base).FindMembers(
1780 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1781 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1782 Type.FilterNameIgnoreCase, "TESTVOID");
1783 Assert.AreEqual (1, mi.Length);
1784 mi = typeof(Base).FindMembers(
1786 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1787 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1788 Type.FilterNameIgnoreCase, "NonExistingMethod");
1789 Assert.AreEqual (0, mi.Length);
1795 public int property {
1798 public ByRef0 (int i) {}
1799 public void f (int i) {}
1803 public void ByrefTypes ()
1805 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1806 Assert.IsNotNull (t);
1807 Assert.IsTrue (t.IsByRef);
1808 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1809 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1810 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1811 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1813 Assert.IsNull (t.GetMethod ("f"));
1814 Assert.IsNull (t.GetField ("field"));
1815 Assert.IsNull (t.GetProperty ("property"));
1819 public void TestAssemblyQualifiedName ()
1821 Type t = Type.GetType ("System.Byte[]&");
1822 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1824 t = Type.GetType ("System.Byte*&");
1825 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1827 t = Type.GetType ("System.Byte&");
1828 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1837 public void CreateValueTypeNoCtor ()
1839 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1843 [ExpectedException (typeof (MissingMethodException))]
1844 public void CreateValueTypeNoCtorArgs ()
1846 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1849 internal static string bug336841 (string param1, params string [] param2)
1851 StringBuilder sb = new StringBuilder ();
1855 for (int i = 0; i < param2.Length; i++) {
1858 sb.Append (param2 [i]);
1860 return sb.ToString ();
1863 internal static string bug336841 (string param1)
1865 return "#B:" + param1;
1868 internal static string bug336841 (params string [] param1)
1870 StringBuilder sb = new StringBuilder ();
1872 for (int i = 0; i < param1.Length; i++) {
1875 sb.Append (param1 [i]);
1877 return sb.ToString ();
1881 public void InvokeMember_GetSetField ()
1883 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1884 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1885 BindingFlags.SetField, null, null, new object [] { 5 });
1887 Assert.AreEqual (5, X.Value, "#A1");
1888 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
1889 BindingFlags.Public | BindingFlags.Static |
1890 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1891 null, null, new object [0]), "#A2");
1892 Assert.AreEqual (5, Y.Value, "#A3");
1893 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
1894 BindingFlags.Public | BindingFlags.Static |
1895 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1896 null, null, new object [0]), "#A4");
1899 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1900 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1901 BindingFlags.GetField | BindingFlags.SetField,
1902 null, null, new object [] { 5 });
1903 Assert.Fail ("#B1");
1904 } catch (ArgumentException ex) {
1905 // Cannot specify both Get and Set on a field
1906 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1907 Assert.IsNull (ex.InnerException, "#B3");
1908 Assert.IsNotNull (ex.Message, "#B4");
1909 Assert.IsNotNull (ex.ParamName, "#B5");
1911 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1913 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1919 public void InvokeMember_GetSetProperty ()
1922 typeof (ArrayList).InvokeMember ("Item",
1923 BindingFlags.GetProperty | BindingFlags.SetProperty |
1924 BindingFlags.Instance | BindingFlags.Public,
1925 null, new ArrayList (), new object [] { 0, "bar" });
1927 } catch (ArgumentException ex) {
1928 // Cannot specify both Get and Set on a property
1929 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1930 Assert.IsNull (ex.InnerException, "#3");
1931 Assert.IsNotNull (ex.Message, "#4");
1932 Assert.IsNotNull (ex.ParamName, "#5");
1934 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
1936 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
1943 public void InvokeMember_InvokeMethod_Set ()
1946 typeof (ArrayList).InvokeMember ("ToString",
1947 BindingFlags.InvokeMethod | BindingFlags.SetField |
1948 BindingFlags.Instance | BindingFlags.Public,
1949 null, new ArrayList (), new object [0]);
1950 Assert.Fail ("#A1");
1951 } catch (ArgumentException ex) {
1952 // Cannot specify Set on a field and Invoke on a method
1953 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1954 Assert.IsNull (ex.InnerException, "#A3");
1955 Assert.IsNotNull (ex.Message, "#A4");
1956 Assert.IsNotNull (ex.ParamName, "#A5");
1958 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
1960 Assert.AreEqual ("invokeAttr", ex.ParamName, "#A6");
1965 typeof (ArrayList).InvokeMember ("ToString",
1966 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
1967 BindingFlags.Instance | BindingFlags.Public,
1968 null, new ArrayList (), new object [0]);
1969 Assert.Fail ("#B1");
1970 } catch (ArgumentException ex) {
1971 // Cannot specify Set on a property and Invoke on a method
1972 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1973 Assert.IsNull (ex.InnerException, "#B3");
1974 Assert.IsNotNull (ex.Message, "#B4");
1975 Assert.IsNotNull (ex.ParamName, "#B5");
1977 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1979 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1985 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
1987 object [] invokeargs = { 1 };
1988 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
1989 BindingFlags.Public | BindingFlags.NonPublic |
1990 BindingFlags.Instance | BindingFlags.CreateInstance,
1991 null, null, invokeargs);
1995 public void InvokeMember_Name_Null ()
1998 typeof (X).InvokeMember ((string) null,
1999 BindingFlags.Public | BindingFlags.Static |
2000 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
2001 null, null, new object [] { 5 });
2003 } catch (ArgumentNullException ex) {
2004 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2005 Assert.IsNull (ex.InnerException, "#3");
2006 Assert.IsNotNull (ex.Message, "#4");
2007 Assert.IsNotNull (ex.ParamName, "#5");
2008 Assert.AreEqual ("name", ex.ParamName, "#6");
2013 public void InvokeMember_NoOperation ()
2016 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2017 BindingFlags.Static, null, null, new object [0]);
2019 } catch (ArgumentException ex) {
2020 // Must specify binding flags describing the
2021 // invoke operation required
2022 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2023 Assert.IsNull (ex.InnerException, "#3");
2024 Assert.IsNotNull (ex.Message, "#4");
2025 Assert.IsNotNull (ex.ParamName, "#5");
2027 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2029 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2034 [Test] // bug #321735
2035 public void InvokeMember_SetFieldProperty ()
2037 ArrayList list = new ArrayList ();
2039 list.GetType ().InvokeMember ("Item",
2040 BindingFlags.SetField | BindingFlags.SetProperty |
2041 BindingFlags.Instance | BindingFlags.Public,
2042 null, list, new object [] { 0, "bar" });
2043 Assert.AreEqual ("bar", list [0]);
2047 public void InvokeMember_SetField_ProvidedArgs ()
2050 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2051 BindingFlags.Static | BindingFlags.SetField,
2052 null, null, new object [0]);
2053 Assert.Fail ("#A1");
2054 } catch (ArgumentException ex) {
2055 // Only the field value can be specified to set
2057 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2058 Assert.IsNull (ex.InnerException, "#A3");
2059 Assert.IsNotNull (ex.Message, "#A4");
2060 Assert.IsNotNull (ex.ParamName, "#A5");
2062 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2064 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2069 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2070 BindingFlags.Static | BindingFlags.SetField,
2072 Assert.Fail ("#B1");
2074 } catch (ArgumentNullException ex) {
2075 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2076 Assert.IsNull (ex.InnerException, "#B3");
2077 Assert.IsNotNull (ex.Message, "#B4");
2078 Assert.IsNotNull (ex.ParamName, "#B5");
2079 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2082 } catch (ArgumentException ex) {
2083 // Only the field value can be specified to set
2085 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2086 Assert.IsNull (ex.InnerException, "#B3");
2087 Assert.IsNotNull (ex.Message, "#B4");
2088 Assert.IsNotNull (ex.ParamName, "#B5");
2090 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2092 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
2098 [Test] // bug #336841
2099 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2100 public void InvokeMember_VarArgs ()
2102 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2103 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2104 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2105 BindingFlags.Instance;
2107 Type type = typeof (TypeTest);
2108 string result = (string) type.InvokeMember ("bug336841",
2109 flags, null, null, new object [] { "1" });
2110 Assert.IsNotNull (result, "#A1");
2111 Assert.AreEqual ("#B:1", result, "#A2");
2113 result = (string) type.InvokeMember ("bug336841", flags,
2114 null, null, new object [] { "1", "2", "3", "4" });
2115 Assert.IsNotNull (result, "#B1");
2116 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2120 [Test] // bug #348522
2121 public void InvokeMember_WithoutDefaultValue ()
2123 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;;
2125 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2126 new object [] {Missing.Value}, null, null, null);
2128 } catch (ArgumentException ex) {
2129 // Missing parameter does not have a default value
2130 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2131 Assert.IsNull (ex.InnerException, "#3");
2132 Assert.IsNotNull (ex.Message, "#4");
2133 Assert.IsNotNull (ex.ParamName, "#5");
2134 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2140 public static int Value;
2149 public Z (IComparable value)
2154 public static void Run ()
2162 public TakesInt (int x)
2167 public int Integer {
2174 public TakesObject (object x) {}
2177 [Test] // bug #75241
2178 public void GetConstructorNullInTypes ()
2180 // This ends up calling type.GetConstructor ()
2181 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2182 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2186 public void GetConstructor_TakeInt_Object ()
2188 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2192 public void GetCustomAttributes_All ()
2194 object [] attrs = typeof (A).GetCustomAttributes (false);
2195 Assert.AreEqual (2, attrs.Length, "#A1");
2196 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2197 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2199 attrs = typeof (BA).GetCustomAttributes (false);
2200 Assert.AreEqual (1, attrs.Length, "#B1");
2201 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2203 attrs = typeof (BA).GetCustomAttributes (true);
2204 Assert.AreEqual (2, attrs.Length, "#C1");
2205 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2206 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2208 attrs = typeof (CA).GetCustomAttributes (false);
2209 Assert.AreEqual (0, attrs.Length, "#D");
2211 attrs = typeof (CA).GetCustomAttributes (true);
2212 Assert.AreEqual (1, attrs.Length, "#E1");
2213 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2216 static bool HasAttribute (object [] attrs, Type attributeType)
2218 foreach (object attr in attrs)
2219 if (attr.GetType () == attributeType)
2225 public void GetCustomAttributes_Type ()
2227 object [] attrs = null;
2229 attrs = typeof (A).GetCustomAttributes (
2230 typeof (VolatileModifier), false);
2231 Assert.AreEqual (1, attrs.Length, "#A1");
2232 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2233 attrs = typeof (A).GetCustomAttributes (
2234 typeof (VolatileModifier), true);
2235 Assert.AreEqual (1, attrs.Length, "#A3");
2236 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2238 attrs = typeof (A).GetCustomAttributes (
2239 typeof (NemerleAttribute), false);
2240 Assert.AreEqual (1, attrs.Length, "#B1");
2241 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2242 attrs = typeof (A).GetCustomAttributes (
2243 typeof (NemerleAttribute), true);
2244 Assert.AreEqual (1, attrs.Length, "#B3");
2245 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2247 attrs = typeof (A).GetCustomAttributes (
2248 typeof (FooAttribute), false);
2249 Assert.AreEqual (1, attrs.Length, "#C1");
2250 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2251 attrs = typeof (A).GetCustomAttributes (
2252 typeof (FooAttribute), false);
2253 Assert.AreEqual (1, attrs.Length, "#C3");
2254 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2256 attrs = typeof (BA).GetCustomAttributes (
2257 typeof (VolatileModifier), false);
2258 Assert.AreEqual (0, attrs.Length, "#D1");
2259 attrs = typeof (BA).GetCustomAttributes (
2260 typeof (VolatileModifier), true);
2261 Assert.AreEqual (1, attrs.Length, "#D2");
2262 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2264 attrs = typeof (BA).GetCustomAttributes (
2265 typeof (NemerleAttribute), false);
2266 Assert.AreEqual (0, attrs.Length, "#E1");
2267 attrs = typeof (BA).GetCustomAttributes (
2268 typeof (NemerleAttribute), true);
2269 Assert.AreEqual (1, attrs.Length, "#E2");
2270 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2272 attrs = typeof (BA).GetCustomAttributes (
2273 typeof (FooAttribute), false);
2274 Assert.AreEqual (1, attrs.Length, "#F1");
2275 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2276 attrs = typeof (BA).GetCustomAttributes (
2277 typeof (FooAttribute), true);
2278 Assert.AreEqual (1, attrs.Length, "#F3");
2279 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2281 attrs = typeof (bug82431A1).GetCustomAttributes (
2282 typeof (InheritAttribute), false);
2283 Assert.AreEqual (1, attrs.Length, "#G1");
2284 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2285 attrs = typeof (bug82431A1).GetCustomAttributes (
2286 typeof (InheritAttribute), true);
2287 Assert.AreEqual (1, attrs.Length, "#G3");
2288 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2290 attrs = typeof (bug82431A1).GetCustomAttributes (
2291 typeof (NotInheritAttribute), false);
2292 Assert.AreEqual (1, attrs.Length, "#H1");
2293 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2294 attrs = typeof (bug82431A1).GetCustomAttributes (
2295 typeof (InheritAttribute), true);
2296 Assert.AreEqual (1, attrs.Length, "#H3");
2297 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2299 attrs = typeof (bug82431A2).GetCustomAttributes (
2300 typeof (InheritAttribute), false);
2301 Assert.AreEqual (0, attrs.Length, "#I1");
2302 attrs = typeof (bug82431A2).GetCustomAttributes (
2303 typeof (InheritAttribute), true);
2304 Assert.AreEqual (0, attrs.Length, "#I2");
2306 attrs = typeof (bug82431A2).GetCustomAttributes (
2307 typeof (NotInheritAttribute), false);
2308 Assert.AreEqual (0, attrs.Length, "#J1");
2309 attrs = typeof (bug82431A2).GetCustomAttributes (
2310 typeof (NotInheritAttribute), true);
2311 Assert.AreEqual (0, attrs.Length, "#J2");
2313 attrs = typeof (bug82431A3).GetCustomAttributes (
2314 typeof (InheritAttribute), false);
2315 Assert.AreEqual (2, attrs.Length, "#K1");
2316 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2317 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2318 attrs = typeof (bug82431A3).GetCustomAttributes (
2319 typeof (InheritAttribute), true);
2320 Assert.AreEqual (2, attrs.Length, "#K4");
2321 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2322 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2324 attrs = typeof (bug82431A3).GetCustomAttributes (
2325 typeof (NotInheritAttribute), false);
2326 Assert.AreEqual (1, attrs.Length, "#L1");
2327 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2328 attrs = typeof (bug82431A3).GetCustomAttributes (
2329 typeof (NotInheritAttribute), true);
2330 Assert.AreEqual (1, attrs.Length, "#L3");
2331 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2333 attrs = typeof (bug82431B1).GetCustomAttributes (
2334 typeof (InheritAttribute), false);
2335 Assert.AreEqual (1, attrs.Length, "#M1");
2336 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2337 attrs = typeof (bug82431B1).GetCustomAttributes (
2338 typeof (InheritAttribute), true);
2339 Assert.AreEqual (1, attrs.Length, "#M3");
2340 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2342 attrs = typeof (bug82431B1).GetCustomAttributes (
2343 typeof (NotInheritAttribute), false);
2344 Assert.AreEqual (0, attrs.Length, "#N1");
2345 attrs = typeof (bug82431B1).GetCustomAttributes (
2346 typeof (NotInheritAttribute), true);
2347 Assert.AreEqual (0, attrs.Length, "#N2");
2349 attrs = typeof (bug82431B2).GetCustomAttributes (
2350 typeof (InheritAttribute), false);
2351 Assert.AreEqual (0, attrs.Length, "#O1");
2352 attrs = typeof (bug82431B2).GetCustomAttributes (
2353 typeof (InheritAttribute), true);
2354 Assert.AreEqual (1, attrs.Length, "#O2");
2355 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2357 attrs = typeof (bug82431B2).GetCustomAttributes (
2358 typeof (NotInheritAttribute), false);
2359 Assert.AreEqual (0, attrs.Length, "#P1");
2360 attrs = typeof (bug82431B2).GetCustomAttributes (
2361 typeof (NotInheritAttribute), true);
2362 Assert.AreEqual (0, attrs.Length, "#P2");
2364 attrs = typeof (bug82431B3).GetCustomAttributes (
2365 typeof (InheritAttribute), false);
2366 Assert.AreEqual (1, attrs.Length, "#Q1");
2367 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2368 attrs = typeof (bug82431B3).GetCustomAttributes (
2369 typeof (InheritAttribute), true);
2370 Assert.AreEqual (2, attrs.Length, "#Q3");
2371 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2372 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2374 attrs = typeof (bug82431B3).GetCustomAttributes (
2375 typeof (NotInheritAttribute), false);
2376 Assert.AreEqual (1, attrs.Length, "#R1");
2377 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2378 attrs = typeof (bug82431B3).GetCustomAttributes (
2379 typeof (NotInheritAttribute), true);
2380 Assert.AreEqual (1, attrs.Length, "#R3");
2381 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2383 attrs = typeof (bug82431B4).GetCustomAttributes (
2384 typeof (InheritAttribute), false);
2385 Assert.AreEqual (0, attrs.Length, "#S1");
2386 attrs = typeof (bug82431B4).GetCustomAttributes (
2387 typeof (InheritAttribute), true);
2388 Assert.AreEqual (1, attrs.Length, "#S2");
2389 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2391 attrs = typeof (bug82431B4).GetCustomAttributes (
2392 typeof (NotInheritAttribute), false);
2393 Assert.AreEqual (0, attrs.Length, "#T1");
2394 attrs = typeof (bug82431B4).GetCustomAttributes (
2395 typeof (NotInheritAttribute), true);
2396 Assert.AreEqual (0, attrs.Length, "#T2");
2398 attrs = typeof (A).GetCustomAttributes (
2399 typeof (string), false);
2400 Assert.AreEqual (0, attrs.Length, "#U1");
2401 attrs = typeof (A).GetCustomAttributes (
2402 typeof (string), true);
2403 Assert.AreEqual (0, attrs.Length, "#U2");
2406 [Test] // bug #76150
2407 public void IsDefined ()
2409 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2410 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2411 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2412 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2414 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2415 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2416 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2417 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2418 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2419 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2420 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2421 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2422 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2423 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2424 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2425 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2429 public void IsDefined_AttributeType_Null ()
2432 typeof (BA).IsDefined ((Type) null, false);
2434 } catch (ArgumentNullException ex) {
2435 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2436 Assert.IsNull (ex.InnerException, "#3");
2437 Assert.IsNotNull (ex.Message, "#4");
2438 Assert.IsNotNull (ex.ParamName, "#5");
2439 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2443 [Test] // bug #82431
2445 [Category ("NotWorking")]
2447 public void IsDefined_Inherited ()
2449 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2450 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2451 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2452 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2453 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2454 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2455 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2456 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2458 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2459 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2460 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2461 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2462 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2463 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2465 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2466 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2468 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2469 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2472 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2473 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2474 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2475 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2477 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2478 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2480 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2482 Assert.IsTrue (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2484 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2486 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2487 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2488 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2489 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2491 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2492 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2493 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2494 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2496 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2497 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2498 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2499 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2501 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2502 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2503 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2504 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2506 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2507 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2508 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2509 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2512 [Test] // GetType (String)
2513 public void GetType1_TypeName_Null ()
2516 Type.GetType ((string) null);
2518 } catch (ArgumentNullException ex) {
2519 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2520 Assert.IsNull (ex.InnerException, "#3");
2521 Assert.IsNotNull (ex.Message, "#4");
2523 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2525 Assert.AreEqual ("className", ex.ParamName, "#5");
2530 [Test] // GetType (String, Boolean)
2531 public void GetType2_TypeName_Null ()
2534 Type.GetType ((string) null, false);
2536 } catch (ArgumentNullException ex) {
2537 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2538 Assert.IsNull (ex.InnerException, "#3");
2539 Assert.IsNotNull (ex.Message, "#4");
2541 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2543 Assert.AreEqual ("className", ex.ParamName, "#5");
2548 [Test] // GetType (String, Boolean, Boolean)
2549 public void GetType3_TypeName_Null ()
2552 Type.GetType ((string) null, false, false);
2554 } catch (ArgumentNullException ex) {
2555 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2556 Assert.IsNull (ex.InnerException, "#3");
2557 Assert.IsNotNull (ex.Message, "#4");
2559 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2561 Assert.AreEqual ("className", ex.ParamName, "#5");
2567 public void GetTypeArray_Args_Null ()
2570 Type.GetTypeArray ((object []) null);
2572 } catch (ArgumentNullException ex) {
2573 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2574 Assert.IsNull (ex.InnerException, "#3");
2575 Assert.IsNotNull (ex.Message, "#4");
2576 Assert.AreEqual ("args", ex.ParamName, "#5");
2581 public void GetTypeCode ()
2583 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2584 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2585 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2586 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2587 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2588 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2589 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2590 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2591 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2592 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2593 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2594 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2595 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2596 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2597 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2598 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2599 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2600 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2604 public void GetTypeFromHandle_Handle_Zero ()
2606 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2609 Assert.IsNull (Type.GetTypeFromHandle (handle));
2612 Type.GetTypeFromHandle (handle);
2614 } catch (ArgumentException ex) {
2615 // Handle is not initialized
2616 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2617 Assert.IsNull (ex.InnerException, "#3");
2618 Assert.IsNotNull (ex.Message, "#4");
2619 Assert.IsNull (ex.ParamName, "#5");
2625 public void GetTypeHandle_O_Null ()
2628 Type.GetTypeHandle (null);
2630 } catch (ArgumentNullException ex) {
2631 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2632 Assert.IsNull (ex.InnerException, "#3");
2633 Assert.IsNotNull (ex.Message, "#4");
2635 Assert.IsNull (ex.ParamName, "#5");
2637 Assert.AreEqual ("o", ex.ParamName, "#5");
2642 [Test] // GetConstructor (Type [])
2643 public void GetConstructor1 ()
2646 ConstructorInfo ctor;
2648 type = typeof (CtorsA);
2649 ctor = type.GetConstructor (Type.EmptyTypes);
2650 Assert.IsNotNull (ctor, "#A1");
2651 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2652 Assert.IsFalse (ctor.IsStatic, "#A3");
2653 Assert.IsTrue (ctor.IsPublic, "#A4");
2654 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2656 type = typeof (CtorsB);
2657 ctor = type.GetConstructor (Type.EmptyTypes);
2658 Assert.IsNotNull (ctor, "#B1");
2659 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2660 Assert.IsFalse (ctor.IsStatic, "#B3");
2661 Assert.IsTrue (ctor.IsPublic, "#B4");
2662 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2664 type = typeof (CtorsC);
2665 ctor = type.GetConstructor (Type.EmptyTypes);
2666 Assert.IsNull (ctor, "#C");
2668 type = typeof (CtorsC);
2669 ctor = type.GetConstructor (new Type [] { typeof (int) });
2670 Assert.IsNotNull (ctor, "#D1");
2671 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2672 Assert.IsFalse (ctor.IsStatic, "#D3");
2673 Assert.IsTrue (ctor.IsPublic, "#D4");
2674 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2677 [Test] // GetConstructor (Type [])
2678 public void GetConstructor1_Types_Null ()
2681 typeof (BindingFlags).GetConstructor (null);
2683 } catch (ArgumentNullException ex) {
2684 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2685 Assert.IsNull (ex.InnerException, "#3");
2686 Assert.IsNotNull (ex.Message, "#4");
2687 Assert.IsNotNull (ex.ParamName, "#5");
2688 Assert.AreEqual ("types", ex.ParamName, "#6");
2692 [Test] // GetConstructor (Type [])
2693 public void GetConstructor1_Types_ItemNull ()
2695 Type type = typeof (BindingFlags);
2697 type.GetConstructor (new Type[1] { null });
2698 Assert.Fail ("#A1");
2699 } catch (ArgumentNullException ex) {
2700 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2701 Assert.IsNull (ex.InnerException, "#A3");
2702 Assert.IsNotNull (ex.Message, "#A4");
2703 Assert.IsNotNull (ex.ParamName, "#A5");
2704 Assert.AreEqual ("types", ex.ParamName, "#A6");
2707 type = typeof (TakesInt);
2709 type.GetConstructor (new Type [1] { null });
2710 Assert.Fail ("#B1");
2711 } catch (ArgumentNullException ex) {
2712 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2713 Assert.IsNull (ex.InnerException, "#B3");
2714 Assert.IsNotNull (ex.Message, "#B4");
2715 Assert.IsNotNull (ex.ParamName, "#B5");
2716 Assert.AreEqual ("types", ex.ParamName, "#B6");
2720 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2721 public void GetConstructor2_Types_ItemNull ()
2723 Type type = typeof (BindingFlags);
2725 type.GetConstructor (BindingFlags.Default, null,
2726 new Type[1] { null }, null);
2728 } catch (ArgumentNullException ex) {
2729 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2730 Assert.IsNull (ex.InnerException, "#3");
2731 Assert.IsNotNull (ex.Message, "#4");
2732 Assert.IsNotNull (ex.ParamName, "#5");
2733 Assert.AreEqual ("types", ex.ParamName, "#6");
2737 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2738 public void GetConstructor3_Types_ItemNull ()
2740 Type type = typeof (BindingFlags);
2742 type.GetConstructor (BindingFlags.Default,
2743 null, CallingConventions.Any,
2744 new Type[1] { null }, null);
2746 } catch (ArgumentNullException ex) {
2747 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2748 Assert.IsNull (ex.InnerException, "#3");
2749 Assert.IsNotNull (ex.Message, "#4");
2750 Assert.IsNotNull (ex.ParamName, "#5");
2751 Assert.AreEqual ("types", ex.ParamName, "#6");
2756 public void GetMethod_Bug77367 ()
2758 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2762 #if !TARGET_JVM // Reflection.Emit is not supported for TARGET_JVM
2764 public void EqualsUnderlyingType ()
2766 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2767 TypeAttributes attribs = TypeAttributes.Public;
2769 AssemblyName name = new AssemblyName ();
2770 name.Name = "enumtest";
2771 AssemblyBuilder assembly =
2772 AppDomain.CurrentDomain.DefineDynamicAssembly (
2775 ModuleBuilder module = assembly.DefineDynamicModule
2776 ("m", "enumtest.dll");
2777 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2779 Assert.IsTrue (typeof (int).Equals (e));
2781 #endif // TARGET_JVM
2784 public void Equals_Type_Null ()
2786 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2787 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2791 public void GetElementType_Bug63841 ()
2793 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2798 public void FullNameGenerics ()
2800 Type fooType = typeof (Foo<>);
2801 FieldInfo [] fields = fooType.GetFields ();
2803 Assert.AreEqual (1, fields.Length, "#0");
2805 Assert.IsNotNull (fooType.FullName, "#1");
2806 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2808 FieldInfo field = fooType.GetField ("Whatever");
2809 Assert.IsNotNull (field, "#2");
2810 Assert.AreEqual (field, fields [0], "#2a");
2811 Assert.IsNull (field.FieldType.FullName, "#3");
2812 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2813 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2815 PropertyInfo prop = fooType.GetProperty ("Test");
2816 Assert.IsNotNull (prop, "#5");
2817 Assert.IsNull (prop.PropertyType.FullName, "#6");
2818 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2819 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2821 MethodInfo method = fooType.GetMethod("Execute");
2822 Assert.IsNotNull (method, "#8");
2823 Assert.IsNull (method.ReturnType.FullName, "#9");
2824 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2825 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2827 ParameterInfo[] parameters = method.GetParameters();
2828 Assert.AreEqual (1, parameters.Length, "#11");
2829 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2830 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2831 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2835 public void TypeParameterIsNotGeneric ()
2837 Type fooType = typeof (Foo<>);
2838 Type type_param = fooType.GetGenericArguments () [0];
2839 Assert.IsTrue (type_param.IsGenericParameter);
2840 Assert.IsFalse (type_param.IsGenericType);
2841 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2843 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2844 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2845 Assert.IsTrue (type_param.ContainsGenericParameters);
2849 public void IsAssignable ()
2851 Type foo_type = typeof (Foo<>);
2852 Type foo_int_type = typeof (Foo<int>);
2853 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
2854 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
2856 Type ibar_short_type = typeof (IBar<short>);
2857 Type ibar_int_type = typeof (IBar<int>);
2858 Type baz_short_type = typeof (Baz<short>);
2859 Type baz_int_type = typeof (Baz<int>);
2861 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
2862 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
2864 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
2865 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
2868 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
2869 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
2870 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
2874 public void IsInstanceOf ()
2876 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
2880 public void IsInstanceOfArrayOfNullable ()
2882 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
2886 public void ByrefType ()
2888 Type foo_type = typeof (Foo<>);
2889 Type type_param = foo_type.GetGenericArguments () [0];
2890 Type byref_type_param = type_param.MakeByRefType ();
2891 Assert.IsFalse (byref_type_param.IsGenericParameter);
2892 Assert.IsNull (byref_type_param.DeclaringType);
2896 public class ComFoo<T> {
2900 public void GetCustomAttributesGenericInstance ()
2902 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
2905 interface ByRef1<T> { void f (ref T t); }
2906 interface ByRef2 { void f<T> (ref T t); }
2908 interface ByRef3<T> where T:struct { void f (ref T? t); }
2909 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
2911 void CheckGenericByRef (Type t)
2913 string name = t.Name;
2914 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
2916 Assert.IsFalse (t.IsGenericType, name);
2917 Assert.IsFalse (t.IsGenericTypeDefinition, name);
2918 Assert.IsFalse (t.IsGenericParameter, name);
2922 public void GenericByRef ()
2924 CheckGenericByRef (typeof (ByRef1<>));
2925 CheckGenericByRef (typeof (ByRef2));
2926 CheckGenericByRef (typeof (ByRef3<>));
2927 CheckGenericByRef (typeof (ByRef4));
2930 public class Bug80242<T> {
2931 public interface IFoo { }
2932 public class Bar : IFoo { }
2933 public class Baz : Bar { }
2937 public void TestNestedTypes ()
2939 Type t = typeof (Bug80242<object>);
2940 Assert.IsFalse (t.IsGenericTypeDefinition);
2941 foreach (Type u in t.GetNestedTypes ()) {
2942 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
2943 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
2947 [Test] // bug #82211
2948 public void GetMembers_GenericArgument ()
2950 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
2951 MemberInfo [] members = argType.GetMembers ();
2952 Assert.IsNotNull (members, "#1");
2953 Assert.AreEqual (4, members.Length, "#2");
2957 [ExpectedException (typeof (ArgumentNullException))]
2958 public void ReflectionOnlyGetTypeNullTypeName ()
2960 Type.ReflectionOnlyGetType (null, false, false);
2964 public void ReflectionOnlyGetTypeDoNotThrow ()
2966 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
2970 [ExpectedException (typeof (FileNotFoundException))]
2971 public void ReflectionOnlyGetTypeThrow ()
2973 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
2977 public void ReflectionOnlyGetType ()
2979 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
2980 Assert.AreEqual ("System.Int32", t.FullName);
2983 [Test] //bug #331199
2984 //FIXME: 2.0 SP 1 has a diferent behavior
2985 public void MakeGenericType_UserDefinedType ()
2987 Type ut = new UserType (typeof (int));
2988 Type t = typeof (Foo<>).MakeGenericType (ut);
2989 Assert.IsTrue (t.IsGenericType, "#A1");
2990 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2992 Type arg = t.GetGenericArguments () [0];
2993 Assert.IsNotNull (arg, "#B1");
2994 Assert.IsFalse (arg.IsGenericType, "#B2");
2995 Assert.AreEqual (typeof (int), arg, "#B3");
2998 [Category ("NotWorking")]
2999 //We dont support instantiating a user type
3000 public void MakeGenericType_NestedUserDefinedType ()
3002 Type ut = new UserType (new UserType (typeof (int)));
3003 Type t = typeof (Foo<>).MakeGenericType (ut);
3004 Assert.IsTrue (t.IsGenericType, "#A1");
3005 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3007 Type arg = t.GetGenericArguments () [0];
3008 Assert.IsNotNull (arg, "#B1");
3009 Assert.IsFalse (arg.IsGenericType, "#B2");
3010 Assert.AreEqual (ut, arg, "#B3");
3014 [Category ("NotWorking")]
3015 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3017 Type ut = new UserType(typeof(int));
3018 Type t = typeof(Foo<>).MakeGenericType(ut);
3019 Assert.IsTrue (t.IsGenericType, "#1");
3021 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3025 public void MakeGenericType_BadUserType ()
3027 Type ut = new UserType (null);
3029 Type t = typeof (Foo<>).MakeGenericType (ut);
3031 } catch (ArgumentException) {
3036 public void MakeGenericType_WrongNumOfArguments ()
3039 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3041 } catch (ArgumentException) {
3045 [AttributeUsage (AttributeTargets.All)]
3046 public class DocAttribute : Attribute {
3047 public DocAttribute (string docs) {}
3050 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3051 where T : class, new ()
3054 public T Bar { get{return null;}}
3056 public void M<[Doc ("X")] X> (X x)
3061 [Test] //bug #377596
3062 public void GetGenericArguments_ArgumentsHaveAttributes ()
3064 Type type = typeof(GenericClassWithAttributes<,>);
3065 Type[] tArgs = type.GetGenericArguments ();
3066 MethodInfo m = type.GetMethod ("M");
3067 Type[] mArgs = m.GetGenericArguments ();
3068 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3069 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3070 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3073 [Test] //bug #471255
3074 public void GetTypeCalledUsingReflection ()
3076 Type expectedType = Type.GetType ("NoNamespaceClass");
3077 Assert.IsNotNull (expectedType, "#1");
3078 MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
3079 object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3080 Assert.AreSame (expectedType, r, "#2");
3084 public void EqualsUserType () {
3085 UserType2 t1 = new UserType2(null);
3086 UserType2 t2 = new UserType2(t1);
3087 Assert.IsTrue (t1.Equals(t2));
3091 public void GetHashCodeUserType () {
3092 UserType2 t1 = new UserType2(null);
3093 UserType2 t2 = new UserType2(t1);
3094 Assert.AreEqual (42, t2.GetHashCode());
3098 public void IsGenericTypeDefinitionUserType () {
3099 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3103 public void IsGenericTypeUserType () {
3104 Assert.IsFalse (new UserType(null).IsGenericType);
3108 [ExpectedException (typeof (NotSupportedException))]
3109 public void GetGenericTypeDefinitionUserType () {
3110 new UserType(null).GetGenericTypeDefinition ();
3113 [ExpectedException (typeof (NotSupportedException))]
3114 public void GetGenericArgumentsUserType () {
3115 new UserType(null).GetGenericArguments ();
3119 [ExpectedException (typeof (InvalidOperationException))]
3120 public void GenericParameterPositionUserType () {
3121 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3126 public void TypeGetMemberReturnTypeTest ()
3129 MemberTypes memtype;
3131 object [] flagsandtypes = new object [] {
3132 MemberTypes.All, typeof (MemberInfo []),
3133 MemberTypes.Constructor, typeof (ConstructorInfo []),
3134 MemberTypes.Custom, typeof (MemberInfo []),
3135 MemberTypes.Event, typeof (EventInfo []),
3136 MemberTypes.Field, typeof (FieldInfo []),
3137 MemberTypes.Method, typeof (MethodInfo []),
3138 MemberTypes.NestedType, typeof (Type []),
3139 MemberTypes.Property, typeof (PropertyInfo []),
3140 MemberTypes.TypeInfo, typeof (Type [])};
3142 for (int i=0; i < flagsandtypes.Length; i+=2) {
3143 memtype = (MemberTypes)flagsandtypes [i];
3144 testtype = (Type)flagsandtypes [i+1];
3145 obj = GetType ().GetMember ("DummyMember", memtype,
3146 BindingFlags.Public | BindingFlags.Instance);
3147 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3148 "Expected " + testtype.FullName);
3154 public void TypeNameStartsWithSpace ()
3156 Type t1 = Type.GetType ("System.Type, mscorlib");
3157 Type t2 = Type.GetType (" System.Type, mscorlib");
3158 Assert.AreEqual (t1, t2);
3161 static bool ContainsProperty (PropertyInfo [] props, string name)
3163 foreach (PropertyInfo p in props)
3169 public class NemerleAttribute : Attribute
3173 public class VolatileModifier : NemerleAttribute
3183 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3184 public class FooAttribute : Attribute
3188 public class BarAttribute : FooAttribute
3205 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
3206 public class InheritAttribute : Attribute
3210 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3211 public class NotInheritAttribute : InheritAttribute
3215 [NotInheritAttribute]
3216 public class bug82431A1
3220 public class bug82431A2 : bug82431A1
3224 [NotInheritAttribute]
3226 public class bug82431A3 : bug82431A1
3231 public class bug82431B1
3235 public class bug82431B2 : bug82431B1
3239 [NotInheritAttribute]
3240 public class bug82431B3 : bug82431B2
3244 public class bug82431B4 : bug82431B3
3252 public class Bug77367
3254 public void Run (bool b)
3261 private string PrivInstBlue
3263 get { return null; }
3266 protected string ProtInstBlue
3268 get { return null; }
3271 protected internal string ProIntInstBlue
3273 get { return null; }
3276 public long PubInstBlue
3280 if (PrivInstBlue == null)
3282 return long.MaxValue;
3286 internal int IntInstBlue
3291 private static string PrivStatBlue
3293 get { return null; }
3296 protected static string ProtStatBlue
3298 get { return null; }
3301 protected static internal string ProIntStatBlue
3303 get { return null; }
3306 public static long PubStatBlue
3310 if (PrivStatBlue == null)
3312 return long.MaxValue;
3316 internal static int IntStatBlue
3322 public class Foo : Blue
3324 private string PrivInstBase
3326 get { return null; }
3329 protected string ProtInstBase
3331 get { return null; }
3334 protected internal string ProIntInstBase
3336 get { return null; }
3339 public long PubInstBase
3343 if (PrivInstBase == null)
3345 return long.MaxValue;
3349 internal int IntInstBase
3354 private static string PrivStatBase
3356 get { return null; }
3359 protected static string ProtStatBase
3361 get { return null; }
3364 protected static internal string ProIntStatBase
3366 get { return null; }
3369 public static long PubStatBase
3373 if (PrivStatBase == null)
3375 return long.MaxValue;
3379 internal static int IntStatBase
3385 public class Bar : Foo
3387 private string PrivInst
3389 get { return null; }
3392 protected string ProtInst
3394 get { return null; }
3397 protected internal string ProIntInst
3399 get { return null; }
3406 if (PrivInst == null)
3408 return long.MaxValue;
3412 internal int IntInst
3417 private static string PrivStat
3419 get { return null; }
3422 protected static string ProtStat
3424 get { return null; }
3427 protected static internal string ProIntStat
3429 get { return null; }
3432 public static long PubStat
3436 if (PrivStat == null)
3438 return long.MaxValue;
3442 internal static int IntStat
3468 public CtorsC (int x)
3475 class UserType : Type
3477 protected Type type;
3479 public UserType(Type type) {
3483 public override Type UnderlyingSystemType { get { return this.type; } }
3485 public override Assembly Assembly { get { return this.type.Assembly; } }
3487 public override string AssemblyQualifiedName { get { return null; } }
3489 public override Type BaseType { get { return null; } }
3491 public override Module Module { get { return this.type.Module; } }
3493 public override string Namespace { get { return null; } }
3495 public override bool IsGenericParameter { get { return true; } }
3497 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
3499 public override bool ContainsGenericParameters { get { return true; } }
3501 public override string FullName { get { return this.type.Name; } }
3503 public override Guid GUID { get { throw new NotSupportedException(); } }
3506 protected override bool IsArrayImpl() {
3510 protected override bool IsByRefImpl()
3515 protected override bool IsCOMObjectImpl()
3520 protected override bool IsPointerImpl()
3525 protected override bool IsPrimitiveImpl()
3531 protected override TypeAttributes GetAttributeFlagsImpl()
3536 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
3537 CallingConventions callConvention, Type[] types,
3538 ParameterModifier[] modifiers)
3543 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
3548 public override Type GetElementType()
3553 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
3559 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
3565 public override Type GetInterface(string name, bool ignoreCase)
3570 public override Type[] GetInterfaces()
3575 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
3580 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
3585 public override object[] GetCustomAttributes(bool inherit)
3590 public override bool IsDefined(Type attributeType, bool inherit)
3595 public override string Name { get { return this.type.Name; } }
3597 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
3599 throw new NotImplementedException();
3602 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
3604 throw new NotImplementedException();
3607 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
3608 CallingConventions callConvention, Type[] types,
3609 ParameterModifier[] modifiers)
3614 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
3619 public override Type GetNestedType(string name, BindingFlags bindingAttr)
3624 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
3629 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
3634 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
3635 Type returnType, Type[] types, ParameterModifier[] modifiers)
3640 protected override bool HasElementTypeImpl()
3645 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
3646 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
3647 string[] namedParameters)
3649 throw new NotSupportedException();
3653 class UserType2 : UserType {
3654 public UserType2 (Type type) : base (type) {
3657 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
3659 public override int GetHashCode()
3663 return type.GetHashCode();