1 // TypeTest.cs - NUnit Test Cases for the System.Type class
4 // Zoltan Varga (vargaz@freemail.hu)
7 // (C) 2003 Ximian, Inc. http://www.ximian.com
10 using NUnit.Framework;
12 using System.Collections;
14 using System.Collections.Generic;
17 using System.Reflection;
18 using System.Reflection.Emit;
19 using System.Runtime.InteropServices;
21 using System.Globalization;
23 class NoNamespaceClass {
26 namespace MonoTests.System
28 class Super : ICloneable
30 public virtual object Clone ()
45 interface IFace2 : IFace1
50 interface IFace3 : IFace2
65 public abstract int this [byte i] {
69 public abstract int this [int i] {
73 public abstract void TestVoid ();
74 public abstract void TestInt (int i);
77 class DeriveVTable : Base
79 public override int this [byte i] {
83 public override int this [int i] {
87 public override void TestVoid ()
92 public override void TestInt (int i)
98 class NewVTable : DeriveVTable
100 public new int this [byte i] {
104 public new int this [int i] {
108 public new void TestVoid ()
113 public new void TestInt (int i)
118 public void Overload ()
122 public void Overload (int i)
126 public NewVTable (out int i)
131 public void byref_method (out int i)
139 public virtual int Foo {
145 class Derived1 : Base1
147 public override int Foo {
152 class Derived2 : Base1
166 get { throw new NotImplementedException (); }
169 public T Execute (T a)
179 public interface IBar<T>
183 public class Baz<T> : IBar<T>
187 public class Bug348522
189 public void Test (int __argument)
194 public class FirstMethodBinder : Binder
196 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
197 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
204 public override object ChangeType (object value, Type type1, CultureInfo culture)
209 // The rest is just to please the compiler
210 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
215 public override void ReorderArgumentArray(ref object[] a, object b)
219 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
224 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
232 public class TypeTest
234 private AssemblyBuilder assembly;
235 private ModuleBuilder module;
236 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
237 static int typeIndexer = 0;
242 AssemblyName assemblyName = new AssemblyName ();
243 assemblyName.Name = ASSEMBLY_NAME;
244 assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
245 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
246 module = assembly.DefineDynamicModule ("module1");
249 private string genTypeName ()
251 return "t" + (typeIndexer++);
254 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
258 private void GenericMethod<Q> (Q q)
263 public void TestIsAssignableFrom ()
265 // Simple tests for inheritance
266 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
267 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
268 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
269 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
272 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
273 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
274 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
275 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
277 // Tests for multiple dimensional arrays
278 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
279 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
280 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
281 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
283 // Tests for vectors<->one dimensional arrays */
284 #if TARGET_JVM // Lower bounds arrays are not supported for TARGET_JVM.
285 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1});
286 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
288 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
289 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
291 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
292 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
295 // Test that arrays of enums can be cast to their base types
296 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
298 // Test that arrays of valuetypes can't be cast to arrays of
300 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
301 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
302 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
304 // Test that arrays of enums can't be cast to arrays of references
305 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
306 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
307 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
309 // Check that ValueType and Enum are recognized as reference types
310 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
311 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
312 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
314 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
315 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
316 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
318 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
319 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
320 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
322 // Tests for byref types
323 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
324 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
325 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
327 // Tests for type parameters
329 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
330 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
331 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
336 public void TestIsSubclassOf ()
338 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
340 // Tests for byref types
341 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
342 Assert.IsTrue (!paramType.IsSubclassOf (typeof (ValueType)), "#02");
343 //Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
344 Assert.IsTrue (!paramType.IsSubclassOf (paramType), "#04");
348 public void TestGetMethodImpl ()
350 // Test binding of new slot methods (using no types)
351 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
352 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
354 // Test binding of new slot methods (using types)
355 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
356 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
358 // Test overload resolution
359 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
361 // Test byref parameters
362 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
363 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
364 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
368 [Category ("TargetJvmNotWorking")]
369 public void TestGetPropertyImpl ()
371 // Test getting property that is exact
372 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
374 // Test getting property that is not exact
375 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
377 // Test overriding of properties when only the set accessor is overriden
378 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
382 public void GetProperties ()
384 // Test hide-by-name-and-signature
385 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length);
386 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType);
389 [Test] // GetProperties (BindingFlags)
390 public void GetProperties_Flags ()
392 PropertyInfo [] props;
393 Type type = typeof (Bar);
396 flags = BindingFlags.Instance | BindingFlags.NonPublic;
397 props = type.GetProperties (flags);
399 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
400 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
401 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
402 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
404 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
406 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#A5");
408 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
409 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
410 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
411 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
412 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
413 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
414 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
415 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
416 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
417 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
418 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
419 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
420 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
421 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
422 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
423 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
424 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
425 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
426 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
428 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
430 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#A25");
432 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
433 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
434 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
435 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
436 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
438 flags = BindingFlags.Instance | BindingFlags.Public;
439 props = type.GetProperties (flags);
441 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
442 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
443 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
444 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
445 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
446 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
447 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
448 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
449 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
450 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
451 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
452 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
453 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
454 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
455 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
456 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
457 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
458 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
459 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
460 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
461 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
462 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
463 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
464 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
465 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
466 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
467 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
468 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
469 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
470 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
472 flags = BindingFlags.Static | BindingFlags.Public;
473 props = type.GetProperties (flags);
475 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
476 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
477 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
478 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
479 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
480 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
481 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
482 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
483 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
484 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
485 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
486 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
487 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
488 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
489 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
490 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
491 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
492 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
493 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
494 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
495 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
496 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
497 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
498 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
499 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
500 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
501 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
502 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
503 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
504 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
506 flags = BindingFlags.Static | BindingFlags.NonPublic;
507 props = type.GetProperties (flags);
509 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
510 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
511 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
512 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
513 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
514 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
515 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
516 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
517 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
518 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
519 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
520 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
521 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
522 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
523 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
524 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
525 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
526 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
527 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
528 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
529 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
530 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
531 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
532 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
533 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
534 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
535 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
536 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
537 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
538 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
540 flags = BindingFlags.Instance | BindingFlags.NonPublic |
541 BindingFlags.FlattenHierarchy;
542 props = type.GetProperties (flags);
544 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
545 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
546 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
547 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
549 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
551 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#E5");
553 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
554 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
555 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
556 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
557 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
558 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
559 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
560 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
561 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
562 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
563 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
564 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
565 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
566 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
567 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
568 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
569 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
570 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
571 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
573 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
575 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#E25");
577 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
578 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
579 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
580 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
581 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
583 flags = BindingFlags.Instance | BindingFlags.Public |
584 BindingFlags.FlattenHierarchy;
585 props = type.GetProperties (flags);
587 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
588 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
589 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
590 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
591 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
592 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
593 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
594 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
595 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
596 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
597 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
598 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
599 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
600 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
601 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
602 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
603 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
604 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
605 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
606 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
607 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
608 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
609 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
610 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
611 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
612 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
613 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
614 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
615 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
616 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
618 flags = BindingFlags.Static | BindingFlags.Public |
619 BindingFlags.FlattenHierarchy;
620 props = type.GetProperties (flags);
622 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
623 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
624 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
625 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
626 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
627 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
628 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
629 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
630 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
631 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
632 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
633 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
634 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
635 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
636 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
637 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
638 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
639 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
640 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
641 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
642 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
643 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
644 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
645 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
646 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
647 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
648 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
649 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
650 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
651 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
653 flags = BindingFlags.Static | BindingFlags.NonPublic |
654 BindingFlags.FlattenHierarchy;
655 props = type.GetProperties (flags);
657 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
658 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
659 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
660 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
661 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
662 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
663 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
664 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
665 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
666 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
667 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
668 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
669 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
670 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
672 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
674 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#H15");
676 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
677 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
678 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
679 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
680 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
681 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
682 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
683 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
684 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
685 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
686 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
687 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
688 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
689 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
691 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
693 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#H50");
696 flags = BindingFlags.Instance | BindingFlags.NonPublic |
697 BindingFlags.DeclaredOnly;
698 props = type.GetProperties (flags);
700 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
701 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
702 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
703 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
704 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
705 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
706 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
707 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
708 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
709 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
710 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
711 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
712 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
713 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
714 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
715 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
716 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
717 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
718 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
719 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
720 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
721 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
722 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
723 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
724 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
725 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
726 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
727 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
728 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
729 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
731 flags = BindingFlags.Instance | BindingFlags.Public |
732 BindingFlags.DeclaredOnly;
733 props = type.GetProperties (flags);
735 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
736 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
737 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
738 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
739 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
740 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
741 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
742 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
743 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
744 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
745 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
746 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
747 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
748 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
749 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
750 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
751 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
752 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
753 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
754 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
755 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
756 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
757 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
758 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
759 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
760 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
761 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
762 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
763 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
764 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
766 flags = BindingFlags.Static | BindingFlags.Public |
767 BindingFlags.DeclaredOnly;
768 props = type.GetProperties (flags);
770 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
771 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
772 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
773 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
774 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
775 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
776 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
777 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
778 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
779 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
780 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
781 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
782 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
783 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
784 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
785 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
786 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
787 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
788 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
789 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
790 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
791 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
792 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
793 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
794 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
795 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
796 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
797 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
798 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
799 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
801 flags = BindingFlags.Static | BindingFlags.NonPublic |
802 BindingFlags.DeclaredOnly;
803 props = type.GetProperties (flags);
805 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
806 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
807 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
808 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
809 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
810 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
811 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
812 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
813 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
814 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
815 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
816 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
817 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
818 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
819 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
820 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
821 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
822 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
823 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
824 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
825 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
826 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
827 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
828 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
829 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
830 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
831 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
832 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
833 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
834 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
836 flags = BindingFlags.Instance | BindingFlags.NonPublic |
838 props = type.GetProperties (flags);
840 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
841 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
842 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
843 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
845 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
847 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#M5");
849 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
850 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
851 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
852 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
853 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
854 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
855 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
856 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
857 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
858 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
859 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
860 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
861 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
862 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
863 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
864 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
865 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
866 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
867 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
869 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
871 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#M25");
873 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
874 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
875 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
876 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
877 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
879 flags = BindingFlags.Static | BindingFlags.NonPublic |
881 props = type.GetProperties (flags);
883 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
884 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
885 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
886 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
887 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
888 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
889 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
890 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
891 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
892 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
893 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
894 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
895 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
896 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
897 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
898 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
899 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
900 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
901 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
902 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
903 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
904 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
905 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
906 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
907 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
908 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
909 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
910 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
911 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
912 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
915 [Test] // GetProperty (String)
916 public void GetProperty1_Name_Null ()
918 Type type = typeof (Bar);
920 type.GetProperty ((string) null);
922 } catch (ArgumentNullException ex) {
923 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
924 Assert.IsNull (ex.InnerException, "#3");
925 Assert.IsNotNull (ex.Message, "#4");
926 Assert.IsNotNull (ex.ParamName, "#5");
927 Assert.AreEqual ("name", ex.ParamName, "#6");
931 [Test] // GetProperty (String, BindingFlags)
932 public void GetProperty2 ()
934 Type type = typeof (Bar);
937 flags = BindingFlags.Instance | BindingFlags.NonPublic;
939 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
940 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
941 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
942 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
944 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
946 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#A5");
948 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
949 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
950 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
951 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
952 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
953 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
954 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
955 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
956 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
957 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
958 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
959 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
960 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
961 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
962 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
963 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
964 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
965 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
966 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
968 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
970 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#A25");
972 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
973 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
974 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
975 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
976 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
978 flags = BindingFlags.Instance | BindingFlags.Public;
980 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
981 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
982 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
983 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
984 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
985 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
986 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
987 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
988 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
989 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
990 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
991 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
992 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
993 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
994 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
995 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
996 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
997 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
998 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
999 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1000 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1001 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1002 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1003 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1004 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1005 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1006 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1007 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1008 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1009 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1011 flags = BindingFlags.Static | BindingFlags.Public;
1013 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1014 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1015 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1016 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1017 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1018 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1019 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1020 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1021 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1022 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1023 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1024 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1025 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1026 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1027 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1028 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1029 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1030 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1031 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1032 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1033 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1034 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1035 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1036 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1037 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1038 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1039 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1040 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1041 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1042 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1044 flags = BindingFlags.Static | BindingFlags.NonPublic;
1046 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1047 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1048 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1049 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1050 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1051 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1052 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1053 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1054 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1055 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1056 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1057 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1058 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1059 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1060 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1061 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1062 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1063 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1064 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1065 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1066 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1067 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1068 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1069 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1070 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1071 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1072 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1073 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1074 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1075 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1077 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1078 BindingFlags.FlattenHierarchy;
1080 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1081 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1082 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1083 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1085 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1087 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#E5");
1089 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1090 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1091 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1092 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1093 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1094 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1095 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1096 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1097 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1098 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1099 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1100 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1101 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1102 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1103 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1104 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1105 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1106 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1107 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1109 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1111 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1113 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1114 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1115 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1116 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1117 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1119 flags = BindingFlags.Instance | BindingFlags.Public |
1120 BindingFlags.FlattenHierarchy;
1122 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1123 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1124 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1125 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1126 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1127 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1128 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1129 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1130 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1131 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1132 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1133 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1134 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1135 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1136 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1137 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1138 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1139 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1140 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1141 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1142 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1143 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1144 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1145 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1146 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1147 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1148 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1149 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1150 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1151 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1153 flags = BindingFlags.Static | BindingFlags.Public |
1154 BindingFlags.FlattenHierarchy;
1156 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1157 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1158 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1159 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1160 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1161 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1162 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1163 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1164 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1165 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1166 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1167 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1168 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1169 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1170 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1171 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1172 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1173 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1174 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1175 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1176 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1177 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1178 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1179 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1180 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1181 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1182 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1183 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1184 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1185 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1187 flags = BindingFlags.Static | BindingFlags.NonPublic |
1188 BindingFlags.FlattenHierarchy;
1190 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1191 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1192 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1193 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1194 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1195 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1196 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1197 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1198 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1199 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1200 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1201 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1202 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1203 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1205 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1207 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#H15");
1209 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1210 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1211 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1212 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1213 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1214 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1215 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1216 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1217 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1218 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1219 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1220 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1221 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1222 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1224 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1226 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#H60");
1229 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1230 BindingFlags.DeclaredOnly;
1232 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1233 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1234 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1235 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1236 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1237 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1238 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1239 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1240 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1241 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1242 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1243 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1244 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1245 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1246 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1247 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1248 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1249 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1250 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1251 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1252 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1253 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1254 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1255 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1256 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1257 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1258 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1259 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1260 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1261 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1263 flags = BindingFlags.Instance | BindingFlags.Public |
1264 BindingFlags.DeclaredOnly;
1266 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1267 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1268 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1269 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1270 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1271 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1272 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1273 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1274 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1275 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1276 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1277 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1278 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1279 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1280 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1281 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1282 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1283 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1284 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1285 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1286 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1287 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1288 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1289 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1290 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1291 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1292 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1293 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1294 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1295 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1297 flags = BindingFlags.Static | BindingFlags.Public |
1298 BindingFlags.DeclaredOnly;
1300 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1301 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1302 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1303 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1304 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1305 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1306 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1307 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1308 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1309 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1310 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1311 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1312 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1313 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1314 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1315 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1316 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1317 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1318 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1319 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1320 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1321 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1322 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1323 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1324 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1325 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1326 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1327 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1328 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1329 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1331 flags = BindingFlags.Static | BindingFlags.NonPublic |
1332 BindingFlags.DeclaredOnly;
1334 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1335 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1336 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1337 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1338 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1339 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1340 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1341 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1342 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1343 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1344 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1345 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1346 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1347 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1348 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1349 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1350 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1351 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1352 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1353 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1354 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1355 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1356 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1357 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1358 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1359 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1360 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1361 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1362 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1363 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1365 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1366 BindingFlags.Public;
1368 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1369 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1370 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1371 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1373 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1375 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#M5");
1377 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1378 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1379 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1380 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1381 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1382 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1383 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1384 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1385 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1386 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1387 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1388 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1389 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1390 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1391 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1392 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1393 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1394 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1395 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1397 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1399 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1401 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1402 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1403 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1404 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1405 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1407 flags = BindingFlags.Static | BindingFlags.NonPublic |
1408 BindingFlags.Public;
1410 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1411 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1412 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1413 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1414 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1415 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1416 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1417 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1418 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1419 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1420 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1421 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1422 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1423 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1424 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1425 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1426 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1427 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1428 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1429 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1430 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1431 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1432 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1433 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1434 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1435 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1436 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1437 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1438 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1439 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1442 [Test] // GetProperty (String, BindingFlags)
1443 public void GetProperty2_Name_Null ()
1445 Type type = typeof (Bar);
1447 type.GetProperty ((string) null);
1449 } catch (ArgumentNullException ex) {
1450 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1451 Assert.IsNull (ex.InnerException, "#3");
1452 Assert.IsNotNull (ex.Message, "#4");
1453 Assert.IsNotNull (ex.ParamName, "#5");
1454 Assert.AreEqual ("name", ex.ParamName, "#6");
1458 [Test] // GetProperty (String, Type)
1459 public void GetProperty3_Name_Null ()
1461 Type type = typeof (Bar);
1463 type.GetProperty ((string) null, typeof (int));
1465 } catch (ArgumentNullException ex) {
1466 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1467 Assert.IsNull (ex.InnerException, "#3");
1468 Assert.IsNotNull (ex.Message, "#4");
1469 Assert.IsNotNull (ex.ParamName, "#5");
1470 Assert.AreEqual ("name", ex.ParamName, "#6");
1474 [Test] // GetProperty (String, Type [])
1475 public void GetProperty4_Name_Null ()
1477 Type type = typeof (Bar);
1479 type.GetProperty ((string) null, Type.EmptyTypes);
1481 } catch (ArgumentNullException ex) {
1482 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1483 Assert.IsNull (ex.InnerException, "#3");
1484 Assert.IsNotNull (ex.Message, "#4");
1485 Assert.IsNotNull (ex.ParamName, "#5");
1486 Assert.AreEqual ("name", ex.ParamName, "#6");
1490 [Test] // GetProperty (String, Type, Type [])
1491 public void GetProperty5_Name_Null ()
1493 Type type = typeof (Bar);
1495 type.GetProperty ((string) null, typeof (int),
1498 } catch (ArgumentNullException ex) {
1499 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1500 Assert.IsNull (ex.InnerException, "#3");
1501 Assert.IsNotNull (ex.Message, "#4");
1502 Assert.IsNotNull (ex.ParamName, "#5");
1503 Assert.AreEqual ("name", ex.ParamName, "#6");
1507 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1508 public void GetProperty6_Name_Null ()
1510 Type type = typeof (Bar);
1512 type.GetProperty ((string) null, typeof (int),
1513 Type.EmptyTypes, null);
1515 } catch (ArgumentNullException ex) {
1516 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1517 Assert.IsNull (ex.InnerException, "#3");
1518 Assert.IsNotNull (ex.Message, "#4");
1519 Assert.IsNotNull (ex.ParamName, "#5");
1520 Assert.AreEqual ("name", ex.ParamName, "#6");
1524 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1525 public void GetProperty7_Name_Null ()
1527 Type type = typeof (Bar);
1529 type.GetProperty ((string) null, BindingFlags.Public,
1530 null, typeof (int), Type.EmptyTypes, null);
1532 } catch (ArgumentNullException ex) {
1533 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1534 Assert.IsNull (ex.InnerException, "#3");
1535 Assert.IsNotNull (ex.Message, "#4");
1536 Assert.IsNotNull (ex.ParamName, "#5");
1537 Assert.AreEqual ("name", ex.ParamName, "#6");
1541 #if !TARGET_JVM // StructLayout not supported for TARGET_JVM
1542 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1547 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1554 public void StructLayoutAttribute ()
1556 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1557 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1559 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1560 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1561 Assert.AreEqual (4, attr2.Pack);
1562 Assert.AreEqual (64, attr2.Size);
1564 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1565 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1566 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1569 #endif // TARGET_JVM
1572 public void Namespace ()
1574 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1577 public static void Reflected (ref int a)
1584 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1588 public void GetInterfaces ()
1590 Type[] t = typeof (Duper).GetInterfaces ();
1591 Assert.AreEqual (1, t.Length);
1592 Assert.AreEqual (typeof (ICloneable), t[0]);
1594 Type[] t2 = typeof (IFace3).GetInterfaces ();
1595 Assert.AreEqual (2, t2.Length);
1601 public void GetFieldIgnoreCase ()
1603 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1617 public void GetPropertyAccessorModifiers ()
1619 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1620 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1625 public void IsAbstract ()
1627 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1628 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1629 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1630 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1631 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1632 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1636 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1637 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1638 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1643 public void IsCOMObject ()
1645 Type type = typeof (string);
1646 Assert.IsFalse (type.IsCOMObject, "#1");
1648 TypeBuilder tb = module.DefineType (genTypeName ());
1649 type = tb.CreateType ();
1650 Assert.IsFalse (type.IsCOMObject, "#2");
1654 public void IsImport ()
1656 Type type = typeof (string);
1657 Assert.IsFalse (type.IsImport, "#1");
1659 TypeBuilder tb = module.DefineType (genTypeName ());
1660 type = tb.CreateType ();
1661 Assert.IsFalse (type.IsImport, "#2");
1663 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1664 TypeAttributes.Interface | TypeAttributes.Abstract);
1665 type = tb.CreateType ();
1666 Assert.IsTrue (type.IsImport, "#3");
1670 public void IsInterface ()
1672 Assert.IsFalse (typeof (string).IsInterface, "#1");
1673 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1677 public void IsPrimitive () {
1678 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1679 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1680 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1684 public void IsValueType ()
1686 Assert.IsTrue (typeof (int).IsValueType, "#1");
1687 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1688 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1689 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1690 Assert.IsFalse (typeof (string).IsValueType, "#5");
1691 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1695 [Category("NotDotNet")]
1696 // Depends on the GAC working, which it doesn't durring make distcheck.
1697 [Category ("NotWorking")]
1698 public void GetTypeWithWhitespace ()
1700 Assert.IsNotNull (Type.GetType
1701 (@"System.Configuration.NameValueSectionHandler,
1706 PublicKeyToken=b77a5c561934e089"));
1710 public void GetTypeNonVectorArray ()
1712 Type t = Type.GetType ("System.String[*]");
1713 Assert.AreEqual ("System.String[*]", t.ToString ());
1717 public void ExerciseFilterName ()
1719 MemberInfo[] mi = typeof(Base).FindMembers(
1721 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1722 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1723 Type.FilterName, "*");
1724 Assert.AreEqual (4, mi.Length);
1725 mi = typeof(Base).FindMembers(
1727 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1728 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1729 Type.FilterName, "Test*");
1730 Assert.AreEqual (2, mi.Length);
1731 mi = typeof(Base).FindMembers(
1733 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1734 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1735 Type.FilterName, "TestVoid");
1736 Assert.AreEqual (1, mi.Length);
1737 mi = typeof(Base).FindMembers(
1739 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1740 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1741 Type.FilterName, "NonExistingMethod");
1742 Assert.AreEqual (0, mi.Length);
1746 public void ExerciseFilterNameIgnoreCase ()
1748 MemberInfo[] mi = typeof(Base).FindMembers(
1750 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1751 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1752 Type.FilterNameIgnoreCase, "*");
1753 Assert.AreEqual (4, mi.Length);
1754 mi = typeof(Base).FindMembers(
1756 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1757 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1758 Type.FilterNameIgnoreCase, "test*");
1759 Assert.AreEqual (2, mi.Length);
1760 mi = typeof(Base).FindMembers(
1762 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1763 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1764 Type.FilterNameIgnoreCase, "TESTVOID");
1765 Assert.AreEqual (1, mi.Length);
1766 mi = typeof(Base).FindMembers(
1768 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1769 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1770 Type.FilterNameIgnoreCase, "NonExistingMethod");
1771 Assert.AreEqual (0, mi.Length);
1777 public int property {
1780 public ByRef0 (int i) {}
1781 public void f (int i) {}
1785 public void ByrefTypes ()
1787 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1788 Assert.IsNotNull (t);
1789 Assert.IsTrue (t.IsByRef);
1790 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1791 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1792 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1793 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1795 Assert.IsNull (t.GetMethod ("f"));
1796 Assert.IsNull (t.GetField ("field"));
1797 Assert.IsNull (t.GetProperty ("property"));
1801 public void TestAssemblyQualifiedName ()
1803 Type t = Type.GetType ("System.Byte[]&");
1804 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1806 t = Type.GetType ("System.Byte*&");
1807 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1809 t = Type.GetType ("System.Byte&");
1810 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1819 public void CreateValueTypeNoCtor ()
1821 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1825 [ExpectedException (typeof (MissingMethodException))]
1826 public void CreateValueTypeNoCtorArgs ()
1828 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1831 static string bug336841 (string param1, params string [] param2)
1833 StringBuilder sb = new StringBuilder ();
1837 for (int i = 0; i < param2.Length; i++) {
1840 sb.Append (param2 [i]);
1842 return sb.ToString ();
1845 static string bug336841 (string param1)
1847 return "#B:" + param1;
1850 static string bug336841 (params string [] param1)
1852 StringBuilder sb = new StringBuilder ();
1854 for (int i = 0; i < param1.Length; i++) {
1857 sb.Append (param1 [i]);
1859 return sb.ToString ();
1863 public void InvokeMember_GetSetField ()
1865 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1866 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1867 BindingFlags.SetField, null, null, new object [] { 5 });
1869 Assert.AreEqual (5, X.Value, "#A1");
1870 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
1871 BindingFlags.Public | BindingFlags.Static |
1872 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1873 null, null, new object [0]), "#A2");
1874 Assert.AreEqual (5, Y.Value, "#A3");
1875 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
1876 BindingFlags.Public | BindingFlags.Static |
1877 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1878 null, null, new object [0]), "#A4");
1881 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1882 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1883 BindingFlags.GetField | BindingFlags.SetField,
1884 null, null, new object [] { 5 });
1885 Assert.Fail ("#B1");
1886 } catch (ArgumentException ex) {
1887 // Cannot specify both Get and Set on a field
1888 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1889 Assert.IsNull (ex.InnerException, "#B3");
1890 Assert.IsNotNull (ex.Message, "#B4");
1891 Assert.IsNotNull (ex.ParamName, "#B5");
1893 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1895 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1901 public void InvokeMember_GetSetProperty ()
1904 typeof (ArrayList).InvokeMember ("Item",
1905 BindingFlags.GetProperty | BindingFlags.SetProperty |
1906 BindingFlags.Instance | BindingFlags.Public,
1907 null, new ArrayList (), new object [] { 0, "bar" });
1909 } catch (ArgumentException ex) {
1910 // Cannot specify both Get and Set on a property
1911 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1912 Assert.IsNull (ex.InnerException, "#3");
1913 Assert.IsNotNull (ex.Message, "#4");
1914 Assert.IsNotNull (ex.ParamName, "#5");
1916 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
1918 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
1925 public void InvokeMember_InvokeMethod_Set ()
1928 typeof (ArrayList).InvokeMember ("ToString",
1929 BindingFlags.InvokeMethod | BindingFlags.SetField |
1930 BindingFlags.Instance | BindingFlags.Public,
1931 null, new ArrayList (), new object [0]);
1932 Assert.Fail ("#A1");
1933 } catch (ArgumentException ex) {
1934 // Cannot specify Set on a field and Invoke on a method
1935 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1936 Assert.IsNull (ex.InnerException, "#A3");
1937 Assert.IsNotNull (ex.Message, "#A4");
1938 Assert.IsNotNull (ex.ParamName, "#A5");
1940 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
1942 Assert.AreEqual ("invokeAttr", ex.ParamName, "#A6");
1947 typeof (ArrayList).InvokeMember ("ToString",
1948 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
1949 BindingFlags.Instance | BindingFlags.Public,
1950 null, new ArrayList (), new object [0]);
1951 Assert.Fail ("#B1");
1952 } catch (ArgumentException ex) {
1953 // Cannot specify Set on a property and Invoke on a method
1954 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1955 Assert.IsNull (ex.InnerException, "#B3");
1956 Assert.IsNotNull (ex.Message, "#B4");
1957 Assert.IsNotNull (ex.ParamName, "#B5");
1959 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1961 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1967 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
1969 object [] invokeargs = { 1 };
1970 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
1971 BindingFlags.Public | BindingFlags.NonPublic |
1972 BindingFlags.Instance | BindingFlags.CreateInstance,
1973 null, null, invokeargs);
1977 public void InvokeMember_Name_Null ()
1980 typeof (X).InvokeMember ((string) null,
1981 BindingFlags.Public | BindingFlags.Static |
1982 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
1983 null, null, new object [] { 5 });
1985 } catch (ArgumentNullException ex) {
1986 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1987 Assert.IsNull (ex.InnerException, "#3");
1988 Assert.IsNotNull (ex.Message, "#4");
1989 Assert.IsNotNull (ex.ParamName, "#5");
1990 Assert.AreEqual ("name", ex.ParamName, "#6");
1995 public void InvokeMember_NoOperation ()
1998 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
1999 BindingFlags.Static, null, null, new object [0]);
2001 } catch (ArgumentException ex) {
2002 // Must specify binding flags describing the
2003 // invoke operation required
2004 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2005 Assert.IsNull (ex.InnerException, "#3");
2006 Assert.IsNotNull (ex.Message, "#4");
2007 Assert.IsNotNull (ex.ParamName, "#5");
2009 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2011 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2016 [Test] // bug #321735
2017 public void InvokeMember_SetFieldProperty ()
2019 ArrayList list = new ArrayList ();
2021 list.GetType ().InvokeMember ("Item",
2022 BindingFlags.SetField | BindingFlags.SetProperty |
2023 BindingFlags.Instance | BindingFlags.Public,
2024 null, list, new object [] { 0, "bar" });
2025 Assert.AreEqual ("bar", list [0]);
2029 public void InvokeMember_SetField_ProvidedArgs ()
2032 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2033 BindingFlags.Static | BindingFlags.SetField,
2034 null, null, new object [0]);
2035 Assert.Fail ("#A1");
2036 } catch (ArgumentException ex) {
2037 // Only the field value can be specified to set
2039 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2040 Assert.IsNull (ex.InnerException, "#A3");
2041 Assert.IsNotNull (ex.Message, "#A4");
2042 Assert.IsNotNull (ex.ParamName, "#A5");
2044 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2046 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2051 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2052 BindingFlags.Static | BindingFlags.SetField,
2054 Assert.Fail ("#B1");
2056 } catch (ArgumentNullException ex) {
2057 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2058 Assert.IsNull (ex.InnerException, "#B3");
2059 Assert.IsNotNull (ex.Message, "#B4");
2060 Assert.IsNotNull (ex.ParamName, "#B5");
2061 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2064 } catch (ArgumentException ex) {
2065 // Only the field value can be specified to set
2067 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2068 Assert.IsNull (ex.InnerException, "#B3");
2069 Assert.IsNotNull (ex.Message, "#B4");
2070 Assert.IsNotNull (ex.ParamName, "#B5");
2072 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2074 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
2080 [Test] // bug #336841
2081 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2082 public void InvokeMember_VarArgs ()
2084 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2085 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2086 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2087 BindingFlags.Instance;
2089 Type type = typeof (TypeTest);
2090 string result = (string) type.InvokeMember ("bug336841",
2091 flags, null, null, new object [] { "1" });
2092 Assert.IsNotNull (result, "#A1");
2093 Assert.AreEqual ("#B:1", result, "#A2");
2095 result = (string) type.InvokeMember ("bug336841", flags,
2096 null, null, new object [] { "1", "2", "3", "4" });
2097 Assert.IsNotNull (result, "#B1");
2098 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2102 [Test] // bug #348522
2103 public void InvokeMember_WithoutDefaultValue ()
2105 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;;
2107 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2108 new object [] {Missing.Value}, null, null, null);
2110 } catch (ArgumentException ex) {
2111 // Missing parameter does not have a default value
2112 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2113 Assert.IsNull (ex.InnerException, "#3");
2114 Assert.IsNotNull (ex.Message, "#4");
2115 Assert.IsNotNull (ex.ParamName, "#5");
2116 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2122 public static int Value;
2131 public Z (IComparable value)
2136 public static void Run ()
2144 public TakesInt (int x)
2149 public int Integer {
2156 public TakesObject (object x) {}
2159 [Test] // bug #75241
2160 public void GetConstructorNullInTypes ()
2162 // This ends up calling type.GetConstructor ()
2163 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2164 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2168 public void GetConstructor_TakeInt_Object ()
2170 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2174 public void GetCustomAttributes_All ()
2176 object [] attrs = typeof (A).GetCustomAttributes (false);
2177 Assert.AreEqual (2, attrs.Length, "#A1");
2178 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2179 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2181 attrs = typeof (BA).GetCustomAttributes (false);
2182 Assert.AreEqual (1, attrs.Length, "#B1");
2183 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2185 attrs = typeof (BA).GetCustomAttributes (true);
2186 Assert.AreEqual (2, attrs.Length, "#C1");
2187 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2188 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2190 attrs = typeof (CA).GetCustomAttributes (false);
2191 Assert.AreEqual (0, attrs.Length, "#D");
2193 attrs = typeof (CA).GetCustomAttributes (true);
2194 Assert.AreEqual (1, attrs.Length, "#E1");
2195 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2198 static bool HasAttribute (object [] attrs, Type attributeType)
2200 foreach (object attr in attrs)
2201 if (attr.GetType () == attributeType)
2207 public void GetCustomAttributes_Type ()
2209 object [] attrs = null;
2211 attrs = typeof (A).GetCustomAttributes (
2212 typeof (VolatileModifier), false);
2213 Assert.AreEqual (1, attrs.Length, "#A1");
2214 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2215 attrs = typeof (A).GetCustomAttributes (
2216 typeof (VolatileModifier), true);
2217 Assert.AreEqual (1, attrs.Length, "#A3");
2218 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2220 attrs = typeof (A).GetCustomAttributes (
2221 typeof (NemerleAttribute), false);
2222 Assert.AreEqual (1, attrs.Length, "#B1");
2223 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2224 attrs = typeof (A).GetCustomAttributes (
2225 typeof (NemerleAttribute), true);
2226 Assert.AreEqual (1, attrs.Length, "#B3");
2227 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2229 attrs = typeof (A).GetCustomAttributes (
2230 typeof (FooAttribute), false);
2231 Assert.AreEqual (1, attrs.Length, "#C1");
2232 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2233 attrs = typeof (A).GetCustomAttributes (
2234 typeof (FooAttribute), false);
2235 Assert.AreEqual (1, attrs.Length, "#C3");
2236 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2238 attrs = typeof (BA).GetCustomAttributes (
2239 typeof (VolatileModifier), false);
2240 Assert.AreEqual (0, attrs.Length, "#D1");
2241 attrs = typeof (BA).GetCustomAttributes (
2242 typeof (VolatileModifier), true);
2243 Assert.AreEqual (1, attrs.Length, "#D2");
2244 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2246 attrs = typeof (BA).GetCustomAttributes (
2247 typeof (NemerleAttribute), false);
2248 Assert.AreEqual (0, attrs.Length, "#E1");
2249 attrs = typeof (BA).GetCustomAttributes (
2250 typeof (NemerleAttribute), true);
2251 Assert.AreEqual (1, attrs.Length, "#E2");
2252 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2254 attrs = typeof (BA).GetCustomAttributes (
2255 typeof (FooAttribute), false);
2256 Assert.AreEqual (1, attrs.Length, "#F1");
2257 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2258 attrs = typeof (BA).GetCustomAttributes (
2259 typeof (FooAttribute), true);
2260 Assert.AreEqual (1, attrs.Length, "#F3");
2261 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2263 attrs = typeof (bug82431A1).GetCustomAttributes (
2264 typeof (InheritAttribute), false);
2265 Assert.AreEqual (1, attrs.Length, "#G1");
2266 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2267 attrs = typeof (bug82431A1).GetCustomAttributes (
2268 typeof (InheritAttribute), true);
2269 Assert.AreEqual (1, attrs.Length, "#G3");
2270 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2272 attrs = typeof (bug82431A1).GetCustomAttributes (
2273 typeof (NotInheritAttribute), false);
2274 Assert.AreEqual (1, attrs.Length, "#H1");
2275 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2276 attrs = typeof (bug82431A1).GetCustomAttributes (
2277 typeof (InheritAttribute), true);
2278 Assert.AreEqual (1, attrs.Length, "#H3");
2279 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2281 attrs = typeof (bug82431A2).GetCustomAttributes (
2282 typeof (InheritAttribute), false);
2283 Assert.AreEqual (0, attrs.Length, "#I1");
2284 attrs = typeof (bug82431A2).GetCustomAttributes (
2285 typeof (InheritAttribute), true);
2286 Assert.AreEqual (0, attrs.Length, "#I2");
2288 attrs = typeof (bug82431A2).GetCustomAttributes (
2289 typeof (NotInheritAttribute), false);
2290 Assert.AreEqual (0, attrs.Length, "#J1");
2291 attrs = typeof (bug82431A2).GetCustomAttributes (
2292 typeof (NotInheritAttribute), true);
2293 Assert.AreEqual (0, attrs.Length, "#J2");
2295 attrs = typeof (bug82431A3).GetCustomAttributes (
2296 typeof (InheritAttribute), false);
2297 Assert.AreEqual (2, attrs.Length, "#K1");
2298 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2299 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2300 attrs = typeof (bug82431A3).GetCustomAttributes (
2301 typeof (InheritAttribute), true);
2302 Assert.AreEqual (2, attrs.Length, "#K4");
2303 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2304 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2306 attrs = typeof (bug82431A3).GetCustomAttributes (
2307 typeof (NotInheritAttribute), false);
2308 Assert.AreEqual (1, attrs.Length, "#L1");
2309 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2310 attrs = typeof (bug82431A3).GetCustomAttributes (
2311 typeof (NotInheritAttribute), true);
2312 Assert.AreEqual (1, attrs.Length, "#L3");
2313 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2315 attrs = typeof (bug82431B1).GetCustomAttributes (
2316 typeof (InheritAttribute), false);
2317 Assert.AreEqual (1, attrs.Length, "#M1");
2318 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2319 attrs = typeof (bug82431B1).GetCustomAttributes (
2320 typeof (InheritAttribute), true);
2321 Assert.AreEqual (1, attrs.Length, "#M3");
2322 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2324 attrs = typeof (bug82431B1).GetCustomAttributes (
2325 typeof (NotInheritAttribute), false);
2326 Assert.AreEqual (0, attrs.Length, "#N1");
2327 attrs = typeof (bug82431B1).GetCustomAttributes (
2328 typeof (NotInheritAttribute), true);
2329 Assert.AreEqual (0, attrs.Length, "#N2");
2331 attrs = typeof (bug82431B2).GetCustomAttributes (
2332 typeof (InheritAttribute), false);
2333 Assert.AreEqual (0, attrs.Length, "#O1");
2334 attrs = typeof (bug82431B2).GetCustomAttributes (
2335 typeof (InheritAttribute), true);
2336 Assert.AreEqual (1, attrs.Length, "#O2");
2337 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2339 attrs = typeof (bug82431B2).GetCustomAttributes (
2340 typeof (NotInheritAttribute), false);
2341 Assert.AreEqual (0, attrs.Length, "#P1");
2342 attrs = typeof (bug82431B2).GetCustomAttributes (
2343 typeof (NotInheritAttribute), true);
2344 Assert.AreEqual (0, attrs.Length, "#P2");
2346 attrs = typeof (bug82431B3).GetCustomAttributes (
2347 typeof (InheritAttribute), false);
2348 Assert.AreEqual (1, attrs.Length, "#Q1");
2349 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2350 attrs = typeof (bug82431B3).GetCustomAttributes (
2351 typeof (InheritAttribute), true);
2352 Assert.AreEqual (2, attrs.Length, "#Q3");
2353 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2354 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2356 attrs = typeof (bug82431B3).GetCustomAttributes (
2357 typeof (NotInheritAttribute), false);
2358 Assert.AreEqual (1, attrs.Length, "#R1");
2359 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2360 attrs = typeof (bug82431B3).GetCustomAttributes (
2361 typeof (NotInheritAttribute), true);
2362 Assert.AreEqual (1, attrs.Length, "#R3");
2363 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2365 attrs = typeof (bug82431B4).GetCustomAttributes (
2366 typeof (InheritAttribute), false);
2367 Assert.AreEqual (0, attrs.Length, "#S1");
2368 attrs = typeof (bug82431B4).GetCustomAttributes (
2369 typeof (InheritAttribute), true);
2370 Assert.AreEqual (1, attrs.Length, "#S2");
2371 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2373 attrs = typeof (bug82431B4).GetCustomAttributes (
2374 typeof (NotInheritAttribute), false);
2375 Assert.AreEqual (0, attrs.Length, "#T1");
2376 attrs = typeof (bug82431B4).GetCustomAttributes (
2377 typeof (NotInheritAttribute), true);
2378 Assert.AreEqual (0, attrs.Length, "#T2");
2380 attrs = typeof (A).GetCustomAttributes (
2381 typeof (string), false);
2382 Assert.AreEqual (0, attrs.Length, "#U1");
2383 attrs = typeof (A).GetCustomAttributes (
2384 typeof (string), true);
2385 Assert.AreEqual (0, attrs.Length, "#U2");
2388 [Test] // bug #76150
2389 public void IsDefined ()
2391 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2392 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2393 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2394 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2396 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2397 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2398 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2399 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2400 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2401 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2402 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2403 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2404 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2405 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2406 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2407 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2411 public void IsDefined_AttributeType_Null ()
2414 typeof (BA).IsDefined ((Type) null, false);
2416 } catch (ArgumentNullException ex) {
2417 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2418 Assert.IsNull (ex.InnerException, "#3");
2419 Assert.IsNotNull (ex.Message, "#4");
2420 Assert.IsNotNull (ex.ParamName, "#5");
2421 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2425 [Test] // bug #82431
2427 [Category ("NotWorking")]
2429 public void IsDefined_Inherited ()
2431 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2432 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2433 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2434 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2435 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2436 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2437 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2438 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2440 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2441 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2442 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2443 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2444 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2445 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2447 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2448 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2450 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2451 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2454 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2455 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2456 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2457 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2459 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2460 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2462 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2464 Assert.IsTrue (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2466 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2468 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2469 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2470 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2471 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2473 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2474 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2475 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2476 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2478 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2479 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2480 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2481 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2483 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2484 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2485 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2486 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2488 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2489 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2490 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2491 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2495 public void GetTypeCode ()
2497 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2498 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2499 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2500 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2501 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2502 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2503 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2504 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2505 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2506 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2507 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2508 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2509 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2510 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2511 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2512 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2513 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2514 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2517 [Test] // GetConstructor (Type [])
2518 public void GetConstructor1 ()
2521 ConstructorInfo ctor;
2523 type = typeof (CtorsA);
2524 ctor = type.GetConstructor (Type.EmptyTypes);
2525 Assert.IsNotNull (ctor, "#A1");
2526 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2527 Assert.IsFalse (ctor.IsStatic, "#A3");
2528 Assert.IsTrue (ctor.IsPublic, "#A4");
2529 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2531 type = typeof (CtorsB);
2532 ctor = type.GetConstructor (Type.EmptyTypes);
2533 Assert.IsNotNull (ctor, "#B1");
2534 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2535 Assert.IsFalse (ctor.IsStatic, "#B3");
2536 Assert.IsTrue (ctor.IsPublic, "#B4");
2537 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2539 type = typeof (CtorsC);
2540 ctor = type.GetConstructor (Type.EmptyTypes);
2541 Assert.IsNull (ctor, "#C");
2543 type = typeof (CtorsC);
2544 ctor = type.GetConstructor (new Type [] { typeof (int) });
2545 Assert.IsNotNull (ctor, "#D1");
2546 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2547 Assert.IsFalse (ctor.IsStatic, "#D3");
2548 Assert.IsTrue (ctor.IsPublic, "#D4");
2549 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2552 [Test] // GetConstructor (Type [])
2553 public void GetConstructor1_Types_Null ()
2556 typeof (BindingFlags).GetConstructor (null);
2558 } catch (ArgumentNullException ex) {
2559 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2560 Assert.IsNull (ex.InnerException, "#3");
2561 Assert.IsNotNull (ex.Message, "#4");
2562 Assert.IsNotNull (ex.ParamName, "#5");
2563 Assert.AreEqual ("types", ex.ParamName, "#6");
2567 [Test] // GetConstructor (Type [])
2568 public void GetConstructor1_Types_ItemNull ()
2570 Type type = typeof (BindingFlags);
2572 type.GetConstructor (new Type[1] { null });
2573 Assert.Fail ("#A1");
2574 } catch (ArgumentNullException ex) {
2575 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2576 Assert.IsNull (ex.InnerException, "#A3");
2577 Assert.IsNotNull (ex.Message, "#A4");
2578 Assert.IsNotNull (ex.ParamName, "#A5");
2579 Assert.AreEqual ("types", ex.ParamName, "#A6");
2582 type = typeof (TakesInt);
2584 type.GetConstructor (new Type [1] { null });
2585 Assert.Fail ("#B1");
2586 } catch (ArgumentNullException ex) {
2587 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2588 Assert.IsNull (ex.InnerException, "#B3");
2589 Assert.IsNotNull (ex.Message, "#B4");
2590 Assert.IsNotNull (ex.ParamName, "#B5");
2591 Assert.AreEqual ("types", ex.ParamName, "#B6");
2595 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2596 public void GetConstructor2_Types_ItemNull ()
2598 Type type = typeof (BindingFlags);
2600 type.GetConstructor (BindingFlags.Default, null,
2601 new Type[1] { null }, null);
2603 } catch (ArgumentNullException ex) {
2604 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2605 Assert.IsNull (ex.InnerException, "#3");
2606 Assert.IsNotNull (ex.Message, "#4");
2607 Assert.IsNotNull (ex.ParamName, "#5");
2608 Assert.AreEqual ("types", ex.ParamName, "#6");
2612 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2613 public void GetConstructor3_Types_ItemNull ()
2615 Type type = typeof (BindingFlags);
2617 type.GetConstructor (BindingFlags.Default,
2618 null, CallingConventions.Any,
2619 new Type[1] { null }, null);
2621 } catch (ArgumentNullException ex) {
2622 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2623 Assert.IsNull (ex.InnerException, "#3");
2624 Assert.IsNotNull (ex.Message, "#4");
2625 Assert.IsNotNull (ex.ParamName, "#5");
2626 Assert.AreEqual ("types", ex.ParamName, "#6");
2631 public void GetMethod_Bug77367 ()
2633 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2637 #if !TARGET_JVM // Reflection.Emit is not supported for TARGET_JVM
2639 public void EqualsUnderlyingType ()
2641 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2642 TypeAttributes attribs = TypeAttributes.Public;
2644 AssemblyName name = new AssemblyName ();
2645 name.Name = "enumtest";
2646 AssemblyBuilder assembly =
2647 AppDomain.CurrentDomain.DefineDynamicAssembly (
2650 ModuleBuilder module = assembly.DefineDynamicModule
2651 ("m", "enumtest.dll");
2652 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2654 Assert.IsTrue (typeof (int).Equals (e));
2656 #endif // TARGET_JVM
2659 public void Equals_Type_Null ()
2661 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2662 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2666 public void GetElementType_Bug63841 ()
2668 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2673 public void FullNameGenerics ()
2675 Type fooType = typeof (Foo<>);
2676 FieldInfo [] fields = fooType.GetFields ();
2678 Assert.AreEqual (1, fields.Length, "#0");
2680 Assert.IsNotNull (fooType.FullName, "#1");
2681 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2683 FieldInfo field = fooType.GetField ("Whatever");
2684 Assert.IsNotNull (field, "#2");
2685 Assert.AreEqual (field, fields [0], "#2a");
2686 Assert.IsNull (field.FieldType.FullName, "#3");
2687 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2688 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2690 PropertyInfo prop = fooType.GetProperty ("Test");
2691 Assert.IsNotNull (prop, "#5");
2692 Assert.IsNull (prop.PropertyType.FullName, "#6");
2693 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2694 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2696 MethodInfo method = fooType.GetMethod("Execute");
2697 Assert.IsNotNull (method, "#8");
2698 Assert.IsNull (method.ReturnType.FullName, "#9");
2699 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2700 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2702 ParameterInfo[] parameters = method.GetParameters();
2703 Assert.AreEqual (1, parameters.Length, "#11");
2704 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2705 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2706 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2710 public void TypeParameterIsNotGeneric ()
2712 Type fooType = typeof (Foo<>);
2713 Type type_param = fooType.GetGenericArguments () [0];
2714 Assert.IsTrue (type_param.IsGenericParameter);
2715 Assert.IsFalse (type_param.IsGenericType);
2716 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2718 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2719 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2720 Assert.IsTrue (type_param.ContainsGenericParameters);
2724 public void IsAssignable ()
2726 Type foo_type = typeof (Foo<>);
2727 Type foo_int_type = typeof (Foo<int>);
2728 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
2729 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
2731 Type ibar_short_type = typeof (IBar<short>);
2732 Type ibar_int_type = typeof (IBar<int>);
2733 Type baz_short_type = typeof (Baz<short>);
2734 Type baz_int_type = typeof (Baz<int>);
2736 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
2737 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
2739 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
2740 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
2743 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
2744 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
2745 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
2749 public void IsInstanceOf ()
2751 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
2755 public void ByrefType ()
2757 Type foo_type = typeof (Foo<>);
2758 Type type_param = foo_type.GetGenericArguments () [0];
2759 Type byref_type_param = type_param.MakeByRefType ();
2760 Assert.IsFalse (byref_type_param.IsGenericParameter);
2761 Assert.IsNull (byref_type_param.DeclaringType);
2765 public class ComFoo<T> {
2769 public void GetCustomAttributesGenericInstance ()
2771 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
2774 interface ByRef1<T> { void f (ref T t); }
2775 interface ByRef2 { void f<T> (ref T t); }
2777 interface ByRef3<T> where T:struct { void f (ref T? t); }
2778 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
2780 void CheckGenericByRef (Type t)
2782 string name = t.Name;
2783 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
2785 Assert.IsFalse (t.IsGenericType, name);
2786 Assert.IsFalse (t.IsGenericTypeDefinition, name);
2787 Assert.IsFalse (t.IsGenericParameter, name);
2791 public void GenericByRef ()
2793 CheckGenericByRef (typeof (ByRef1<>));
2794 CheckGenericByRef (typeof (ByRef2));
2795 CheckGenericByRef (typeof (ByRef3<>));
2796 CheckGenericByRef (typeof (ByRef4));
2799 public class Bug80242<T> {
2800 public interface IFoo { }
2801 public class Bar : IFoo { }
2802 public class Baz : Bar { }
2806 public void TestNestedTypes ()
2808 Type t = typeof (Bug80242<object>);
2809 Assert.IsFalse (t.IsGenericTypeDefinition);
2810 foreach (Type u in t.GetNestedTypes ()) {
2811 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
2812 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
2816 [Test] // bug #82211
2817 public void GetMembers_GenericArgument ()
2819 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
2820 MemberInfo [] members = argType.GetMembers ();
2821 Assert.IsNotNull (members, "#1");
2822 Assert.AreEqual (4, members.Length, "#2");
2826 [ExpectedException (typeof (ArgumentNullException))]
2827 public void ReflectionOnlyGetTypeNullTypeName ()
2829 Type.ReflectionOnlyGetType (null, false, false);
2833 public void ReflectionOnlyGetTypeDoNotThrow ()
2835 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
2839 [ExpectedException (typeof (FileNotFoundException))]
2840 public void ReflectionOnlyGetTypeThrow ()
2842 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
2846 public void ReflectionOnlyGetType ()
2848 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
2849 Assert.AreEqual ("System.Int32", t.FullName);
2852 [Test] //bug #331199
2853 //FIXME: 2.0 SP 1 has a diferent behavior
2854 public void MakeGenericType_UserDefinedType ()
2856 Type ut = new UserType (typeof (int));
2857 Type t = typeof (Foo<>).MakeGenericType (ut);
2858 Assert.IsTrue (t.IsGenericType, "#A1");
2859 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2861 Type arg = t.GetGenericArguments () [0];
2862 Assert.IsNotNull (arg, "#B1");
2863 Assert.IsFalse (arg.IsGenericType, "#B2");
2864 Assert.AreEqual (typeof (int), arg, "#B3");
2867 [Category ("NotWorking")]
2868 //We dont support instantiating a user type
2869 public void MakeGenericType_NestedUserDefinedType ()
2871 Type ut = new UserType (new UserType (typeof (int)));
2872 Type t = typeof (Foo<>).MakeGenericType (ut);
2873 Assert.IsTrue (t.IsGenericType, "#A1");
2874 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2876 Type arg = t.GetGenericArguments () [0];
2877 Assert.IsNotNull (arg, "#B1");
2878 Assert.IsFalse (arg.IsGenericType, "#B2");
2879 Assert.AreEqual (ut, arg, "#B3");
2883 [Category ("NotWorking")]
2884 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
2886 Type ut = new UserType(typeof(int));
2887 Type t = typeof(Foo<>).MakeGenericType(ut);
2888 Assert.IsTrue (t.IsGenericType, "#1");
2890 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
2894 public void MakeGenericType_BadUserType ()
2896 Type ut = new UserType (null);
2898 Type t = typeof (Foo<>).MakeGenericType (ut);
2900 } catch (ArgumentException) {
2905 public void MakeGenericType_WrongNumOfArguments ()
2908 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
2910 } catch (ArgumentException) {
2914 [AttributeUsage (AttributeTargets.All)]
2915 public class DocAttribute : Attribute {
2916 public DocAttribute (string docs) {}
2919 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
2920 where T : class, new ()
2923 public T Bar { get{return null;}}
2925 public void M<[Doc ("X")] X> (X x)
2930 [Test] //bug #377596
2931 public void GetGenericArguments_ArgumentsHaveAttributes ()
2933 Type type = typeof(GenericClassWithAttributes<,>);
2934 Type[] tArgs = type.GetGenericArguments ();
2935 MethodInfo m = type.GetMethod ("M");
2936 Type[] mArgs = m.GetGenericArguments ();
2937 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
2938 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
2939 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
2944 static bool ContainsProperty (PropertyInfo [] props, string name)
2946 foreach (PropertyInfo p in props)
2952 public class NemerleAttribute : Attribute
2956 public class VolatileModifier : NemerleAttribute
2966 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
2967 public class FooAttribute : Attribute
2971 public class BarAttribute : FooAttribute
2988 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
2989 public class InheritAttribute : Attribute
2993 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
2994 public class NotInheritAttribute : InheritAttribute
2998 [NotInheritAttribute]
2999 public class bug82431A1
3003 public class bug82431A2 : bug82431A1
3007 [NotInheritAttribute]
3009 public class bug82431A3 : bug82431A1
3014 public class bug82431B1
3018 public class bug82431B2 : bug82431B1
3022 [NotInheritAttribute]
3023 public class bug82431B3 : bug82431B2
3027 public class bug82431B4 : bug82431B3
3035 public class Bug77367
3037 public void Run (bool b)
3044 private string PrivInstBlue
3046 get { return null; }
3049 protected string ProtInstBlue
3051 get { return null; }
3054 protected internal string ProIntInstBlue
3056 get { return null; }
3059 public long PubInstBlue
3063 if (PrivInstBlue == null)
3065 return long.MaxValue;
3069 internal int IntInstBlue
3074 private static string PrivStatBlue
3076 get { return null; }
3079 protected static string ProtStatBlue
3081 get { return null; }
3084 protected static internal string ProIntStatBlue
3086 get { return null; }
3089 public static long PubStatBlue
3093 if (PrivStatBlue == null)
3095 return long.MaxValue;
3099 internal static int IntStatBlue
3105 public class Foo : Blue
3107 private string PrivInstBase
3109 get { return null; }
3112 protected string ProtInstBase
3114 get { return null; }
3117 protected internal string ProIntInstBase
3119 get { return null; }
3122 public long PubInstBase
3126 if (PrivInstBase == null)
3128 return long.MaxValue;
3132 internal int IntInstBase
3137 private static string PrivStatBase
3139 get { return null; }
3142 protected static string ProtStatBase
3144 get { return null; }
3147 protected static internal string ProIntStatBase
3149 get { return null; }
3152 public static long PubStatBase
3156 if (PrivStatBase == null)
3158 return long.MaxValue;
3162 internal static int IntStatBase
3168 public class Bar : Foo
3170 private string PrivInst
3172 get { return null; }
3175 protected string ProtInst
3177 get { return null; }
3180 protected internal string ProIntInst
3182 get { return null; }
3189 if (PrivInst == null)
3191 return long.MaxValue;
3195 internal int IntInst
3200 private static string PrivStat
3202 get { return null; }
3205 protected static string ProtStat
3207 get { return null; }
3210 protected static internal string ProIntStat
3212 get { return null; }
3215 public static long PubStat
3219 if (PrivStat == null)
3221 return long.MaxValue;
3225 internal static int IntStat
3251 public CtorsC (int x)
3258 class UserType : Type
3262 public UserType(Type type) {
3266 public override Type UnderlyingSystemType { get { return this.type; } }
3268 public override Assembly Assembly { get { return this.type.Assembly; } }
3270 public override string AssemblyQualifiedName { get { return null; } }
3272 public override Type BaseType { get { return null; } }
3274 public override Module Module { get { return this.type.Module; } }
3276 public override string Namespace { get { return null; } }
3278 public override bool IsGenericParameter { get { return true; } }
3280 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
3282 public override bool ContainsGenericParameters { get { return true; } }
3284 public override string FullName { get { return this.type.Name; } }
3286 public override Guid GUID { get { throw new NotSupportedException(); } }
3289 protected override bool IsArrayImpl() {
3293 protected override bool IsByRefImpl()
3298 protected override bool IsCOMObjectImpl()
3303 protected override bool IsPointerImpl()
3308 protected override bool IsPrimitiveImpl()
3314 protected override TypeAttributes GetAttributeFlagsImpl()
3319 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
3320 CallingConventions callConvention, Type[] types,
3321 ParameterModifier[] modifiers)
3326 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
3331 public override Type GetElementType()
3336 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
3342 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
3348 public override Type GetInterface(string name, bool ignoreCase)
3353 public override Type[] GetInterfaces()
3358 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
3363 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
3368 public override object[] GetCustomAttributes(bool inherit)
3373 public override bool IsDefined(Type attributeType, bool inherit)
3378 public override string Name { get { return this.type.Name; } }
3380 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
3382 throw new NotImplementedException();
3385 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
3387 throw new NotImplementedException();
3390 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
3391 CallingConventions callConvention, Type[] types,
3392 ParameterModifier[] modifiers)
3397 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
3402 public override Type GetNestedType(string name, BindingFlags bindingAttr)
3407 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
3412 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
3417 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
3418 Type returnType, Type[] types, ParameterModifier[] modifiers)
3423 protected override bool HasElementTypeImpl()
3428 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
3429 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
3430 string[] namedParameters)
3432 throw new NotSupportedException();