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.Threading;
13 using System.Collections;
14 using System.Collections.Generic;
16 using System.Reflection;
18 using System.Reflection.Emit;
20 using System.Runtime.InteropServices;
22 using System.Globalization;
24 class NoNamespaceClass {
27 namespace MonoTests.System
29 class Super : ICloneable
31 public virtual object Clone ()
46 interface IFace2 : IFace1
51 interface IFace3 : IFace2
66 public abstract int this [byte i] {
70 public abstract int this [int i] {
74 public abstract void TestVoid ();
75 public abstract void TestInt (int i);
78 class DeriveVTable : Base
80 public override int this [byte i] {
84 public override int this [int i] {
88 public override void TestVoid ()
93 public override void TestInt (int i)
99 class NewVTable : DeriveVTable
101 public new int this [byte i] {
105 public new int this [int i] {
109 public new void TestVoid ()
114 public new void TestInt (int i)
119 public void Overload ()
123 public void Overload (int i)
127 public NewVTable (out int i)
132 public void byref_method (out int i)
140 public virtual int Foo {
145 public event EventHandler E;
148 class Derived1 : Base1
150 public override int Foo {
155 class Derived2 : Base1
162 public event Action E;
170 get { throw new NotImplementedException (); }
173 public T Execute (T a)
178 public class Nested<K> {}
185 public interface IBar<T>
189 public class Baz<T> : IBar<T>
195 public static void Bang<S> () {}
198 public class Bug348522
200 public void Test (int __argument)
205 public class FirstMethodBinder : Binder
207 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
208 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
215 public override object ChangeType (object value, Type type1, CultureInfo culture)
220 // The rest is just to please the compiler
221 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
226 public override void ReorderArgumentArray(ref object[] a, object b)
230 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
235 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
242 public class TypeTest
245 private ModuleBuilder module;
247 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
248 static int typeIndexer = 0;
253 AssemblyName assemblyName = new AssemblyName ();
254 assemblyName.Name = ASSEMBLY_NAME;
256 var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
257 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
258 module = assembly.DefineDynamicModule ("module1");
262 private string genTypeName ()
264 return "t" + (typeIndexer++);
267 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
271 public interface IFace {
274 private void GenericMethod<Q, T1> (Q q, T1 t) where T1 : IFace
279 public void TestIsAssignableFrom ()
281 // Simple tests for inheritance
282 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
283 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
284 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
285 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
288 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
289 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
290 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
291 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
293 // Tests for multiple dimensional arrays
294 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
295 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
296 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
297 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
299 // Tests for vectors<->one dimensional arrays */
300 #if TARGET_JVM // Lower bounds arrays are not supported for TARGET_JVM.
301 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1});
302 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
304 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
305 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
307 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
308 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
311 // Test that arrays of enums can be cast to their base types
312 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
314 // Test that arrays of valuetypes can't be cast to arrays of
316 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
317 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
318 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
320 // Test that arrays of enums can't be cast to arrays of references
321 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
322 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
323 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
325 // Check that ValueType and Enum are recognized as reference types
326 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
327 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
328 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
330 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
331 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
332 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
334 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
335 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
336 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
338 // Tests for byref types
339 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
340 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
341 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
343 // Tests for type parameters
344 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
345 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
346 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
348 // Tests for parameters with generic constraints
349 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
350 Assert.IsTrue (typeof (IFace).IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
354 [ExpectedException (typeof (ArgumentException))]
355 public void GetInterfaceMapOnInterface ()
357 typeof (IList).GetInterfaceMap (typeof (ICollection));
361 public void TestIsSubclassOf ()
363 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
365 // Tests for byref types
366 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
367 Assert.IsTrue (!paramType.IsSubclassOf (typeof (ValueType)), "#02");
368 //Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
369 Assert.IsTrue (!paramType.IsSubclassOf (paramType), "#04");
373 public void TestGetMethodImpl ()
375 // Test binding of new slot methods (using no types)
376 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
377 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
379 // Test binding of new slot methods (using types)
380 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
381 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
383 // Test overload resolution
384 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
386 // Test byref parameters
387 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
388 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
389 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
393 [Category ("TargetJvmNotWorking")]
394 public void TestGetPropertyImpl ()
396 // Test getting property that is exact
397 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
399 // Test getting property that is not exact
400 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
402 // Test overriding of properties when only the set accessor is overriden
403 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
407 public void GetEvents ()
410 Assert.AreEqual (1, typeof (Derived2).GetEvents ().Length);
411 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetEvents ()[0].DeclaringType);
415 public void GetProperties ()
417 // Test hide-by-name-and-signature
418 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length);
419 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType);
422 [Test] // GetProperties (BindingFlags)
423 public void GetProperties_Flags ()
425 PropertyInfo [] props;
426 Type type = typeof (Bar);
429 flags = BindingFlags.Instance | BindingFlags.NonPublic;
430 props = type.GetProperties (flags);
432 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
433 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
434 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
435 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
436 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
437 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
438 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
439 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
440 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
441 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
442 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
443 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
444 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
445 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
446 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
447 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
448 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
449 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
450 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
451 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
452 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
453 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
454 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
455 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
456 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
457 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
458 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
459 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
460 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
461 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
463 flags = BindingFlags.Instance | BindingFlags.Public;
464 props = type.GetProperties (flags);
466 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
467 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
468 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
469 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
470 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
471 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
472 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
473 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
474 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
475 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
476 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
477 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
478 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
479 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
480 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
481 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
482 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
483 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
484 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
485 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
486 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
487 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
488 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
489 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
490 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
491 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
492 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
493 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
494 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
495 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
497 flags = BindingFlags.Static | BindingFlags.Public;
498 props = type.GetProperties (flags);
500 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
501 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
502 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
503 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
504 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
505 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
506 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
507 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
508 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
509 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
510 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
511 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
512 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
513 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
514 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
515 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
516 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
517 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
518 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
519 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
520 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
521 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
522 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
523 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
524 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
525 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
526 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
527 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
528 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
529 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
531 flags = BindingFlags.Static | BindingFlags.NonPublic;
532 props = type.GetProperties (flags);
534 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
535 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
536 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
537 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
538 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
539 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
540 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
541 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
542 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
543 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
544 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
545 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
546 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
547 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
548 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
549 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
550 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
551 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
552 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
553 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
554 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
555 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
556 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
557 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
558 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
559 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
560 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
561 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
562 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
563 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
565 flags = BindingFlags.Instance | BindingFlags.NonPublic |
566 BindingFlags.FlattenHierarchy;
567 props = type.GetProperties (flags);
569 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
570 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
571 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
572 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
573 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
574 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
575 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
576 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
577 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
578 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
579 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
580 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
581 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
582 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
583 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
584 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
585 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
586 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
587 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
588 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
589 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
590 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
591 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
592 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
593 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
594 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
595 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
596 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
597 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
598 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
600 flags = BindingFlags.Instance | BindingFlags.Public |
601 BindingFlags.FlattenHierarchy;
602 props = type.GetProperties (flags);
604 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
605 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
606 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
607 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
608 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
609 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
610 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
611 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
612 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
613 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
614 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
615 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
616 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
617 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
618 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
619 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
620 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
621 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
622 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
623 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
624 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
625 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
626 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
627 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
628 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
629 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
630 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
631 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
632 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
633 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
635 flags = BindingFlags.Static | BindingFlags.Public |
636 BindingFlags.FlattenHierarchy;
637 props = type.GetProperties (flags);
639 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
640 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
641 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
642 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
643 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
644 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
645 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
646 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
647 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
648 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
649 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
650 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
651 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
652 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
653 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
654 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
655 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
656 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
657 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
658 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
659 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
660 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
661 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
662 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
663 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
664 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
665 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
666 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
667 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
668 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
670 flags = BindingFlags.Static | BindingFlags.NonPublic |
671 BindingFlags.FlattenHierarchy;
672 props = type.GetProperties (flags);
674 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
675 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
676 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
677 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
678 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
679 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
680 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
681 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
682 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
683 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
684 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
685 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
686 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
687 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
688 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
689 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
690 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
691 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
692 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
693 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
694 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
695 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
696 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
697 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
698 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
699 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
700 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
701 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
702 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
703 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
705 flags = BindingFlags.Instance | BindingFlags.NonPublic |
706 BindingFlags.DeclaredOnly;
707 props = type.GetProperties (flags);
709 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
710 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
711 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
712 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
713 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
714 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
715 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
716 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
717 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
718 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
719 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
720 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
721 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
722 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
723 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
724 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
725 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
726 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
727 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
728 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
729 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
730 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
731 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
732 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
733 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
734 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
735 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
736 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
737 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
738 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
740 flags = BindingFlags.Instance | BindingFlags.Public |
741 BindingFlags.DeclaredOnly;
742 props = type.GetProperties (flags);
744 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
745 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
746 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
747 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
748 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
749 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
750 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
751 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
752 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
753 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
754 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
755 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
756 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
757 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
758 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
759 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
760 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
761 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
762 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
763 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
764 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
765 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
766 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
767 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
768 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
769 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
770 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
771 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
772 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
773 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
775 flags = BindingFlags.Static | BindingFlags.Public |
776 BindingFlags.DeclaredOnly;
777 props = type.GetProperties (flags);
779 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
780 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
781 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
782 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
783 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
784 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
785 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
786 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
787 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
788 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
789 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
790 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
791 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
792 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
793 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
794 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
795 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
796 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
797 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
798 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
799 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
800 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
801 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
802 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
803 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
804 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
805 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
806 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
807 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
808 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
810 flags = BindingFlags.Static | BindingFlags.NonPublic |
811 BindingFlags.DeclaredOnly;
812 props = type.GetProperties (flags);
814 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
815 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
816 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
817 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
818 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
819 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
820 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
821 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
822 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
823 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
824 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
825 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
826 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
827 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
828 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
829 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
830 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
831 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
832 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
833 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
834 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
835 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
836 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
837 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
838 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
839 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
840 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
841 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
842 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
843 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
845 flags = BindingFlags.Instance | BindingFlags.NonPublic |
847 props = type.GetProperties (flags);
849 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
850 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
851 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
852 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
853 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
854 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
855 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
856 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
857 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
858 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
859 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
860 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
861 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
862 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
863 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
864 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
865 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
866 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
867 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
868 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
869 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
870 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
871 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
872 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
873 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
874 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
875 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
876 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
877 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
878 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
880 flags = BindingFlags.Static | BindingFlags.NonPublic |
882 props = type.GetProperties (flags);
884 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
885 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
886 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
887 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
888 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
889 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
890 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
891 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
892 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
893 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
894 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
895 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
896 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
897 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
898 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
899 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
900 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
901 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
902 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
903 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
904 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
905 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
906 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
907 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
908 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
909 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
910 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
911 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
912 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
913 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
916 [Test] // GetProperty (String)
917 public void GetProperty1_Name_Null ()
919 Type type = typeof (Bar);
921 type.GetProperty ((string) null);
923 } catch (ArgumentNullException ex) {
924 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
925 Assert.IsNull (ex.InnerException, "#3");
926 Assert.IsNotNull (ex.Message, "#4");
927 Assert.IsNotNull (ex.ParamName, "#5");
928 Assert.AreEqual ("name", ex.ParamName, "#6");
932 [Test] // GetProperty (String, BindingFlags)
933 public void GetProperty2 ()
935 Type type = typeof (Bar);
938 flags = BindingFlags.Instance | BindingFlags.NonPublic;
940 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
941 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
942 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
943 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
944 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
945 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
946 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
947 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
948 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
949 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
950 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
951 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
952 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
953 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
954 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
955 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
956 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
957 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
958 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
959 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
960 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
961 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
962 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
963 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
964 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
965 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
966 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
967 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
968 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
969 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
971 flags = BindingFlags.Instance | BindingFlags.Public;
973 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
974 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
975 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
976 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
977 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
978 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
979 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
980 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
981 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
982 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
983 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
984 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
985 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
986 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
987 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
988 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
989 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
990 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
991 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
992 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
993 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
994 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
995 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
996 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
997 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
998 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
999 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1000 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1001 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1002 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1004 flags = BindingFlags.Static | BindingFlags.Public;
1006 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1007 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1008 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1009 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1010 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1011 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1012 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1013 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1014 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1015 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1016 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1017 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1018 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1019 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1020 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1021 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1022 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1023 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1024 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1025 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1026 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1027 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1028 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1029 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1030 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1031 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1032 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1033 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1034 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1035 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1037 flags = BindingFlags.Static | BindingFlags.NonPublic;
1039 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1040 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1041 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1042 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1043 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1044 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1045 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1046 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1047 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1048 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1049 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1050 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1051 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1052 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1053 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1054 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1055 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1056 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1057 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1058 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1059 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1060 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1061 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1062 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1063 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1064 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1065 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1066 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1067 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1068 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1070 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1071 BindingFlags.FlattenHierarchy;
1073 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1074 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1075 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1076 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1077 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1078 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1079 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1080 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1081 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1082 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1083 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1084 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1085 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1086 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1087 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1088 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1089 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1090 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1091 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1092 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1093 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1094 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1095 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1096 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1097 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1098 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1099 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1100 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1101 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1102 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1104 flags = BindingFlags.Instance | BindingFlags.Public |
1105 BindingFlags.FlattenHierarchy;
1107 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1108 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1109 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1110 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1111 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1112 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1113 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1114 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1115 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1116 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1117 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1118 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1119 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1120 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1121 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1122 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1123 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1124 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1125 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1126 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1127 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1128 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1129 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1130 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1131 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1132 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1133 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1134 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1135 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1136 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1138 flags = BindingFlags.Static | BindingFlags.Public |
1139 BindingFlags.FlattenHierarchy;
1141 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1142 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1143 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1144 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1145 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1146 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1147 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1148 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1149 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1150 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1151 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1152 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1153 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1154 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1155 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1156 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1157 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1158 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1159 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1160 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1161 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1162 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1163 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1164 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1165 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1166 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1167 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1168 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1169 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1170 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1172 flags = BindingFlags.Static | BindingFlags.NonPublic |
1173 BindingFlags.FlattenHierarchy;
1175 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1176 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1177 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1178 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1179 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1180 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1181 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1182 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1183 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1184 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1185 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1186 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1187 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1188 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1189 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1190 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1191 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1192 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1193 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1194 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1195 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1196 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1197 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1198 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1199 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1200 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1201 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1202 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1203 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1204 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1206 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1207 BindingFlags.DeclaredOnly;
1209 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1210 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1211 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1212 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1213 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1214 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1215 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1216 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1217 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1218 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1219 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1220 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1221 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1222 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1223 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1224 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1225 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1226 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1227 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1228 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1229 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1230 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1231 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1232 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1233 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1234 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1235 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1236 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1237 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1238 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1240 flags = BindingFlags.Instance | BindingFlags.Public |
1241 BindingFlags.DeclaredOnly;
1243 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1244 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1245 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1246 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1247 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1248 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1249 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1250 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1251 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1252 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1253 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1254 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1255 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1256 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1257 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1258 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1259 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1260 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1261 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1262 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1263 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1264 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1265 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1266 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1267 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1268 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1269 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1270 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1271 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1272 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1274 flags = BindingFlags.Static | BindingFlags.Public |
1275 BindingFlags.DeclaredOnly;
1277 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1278 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1279 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1280 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1281 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1282 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1283 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1284 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1285 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1286 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1287 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1288 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1289 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1290 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1291 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1292 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1293 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1294 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1295 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1296 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1297 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1298 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1299 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1300 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1301 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1302 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1303 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1304 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1305 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1306 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1308 flags = BindingFlags.Static | BindingFlags.NonPublic |
1309 BindingFlags.DeclaredOnly;
1311 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1312 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1313 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1314 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1315 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1316 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1317 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1318 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1319 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1320 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1321 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1322 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1323 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1324 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1325 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1326 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1327 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1328 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1329 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1330 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1331 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1332 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1333 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1334 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1335 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1336 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1337 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1338 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1339 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1340 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1342 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1343 BindingFlags.Public;
1345 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1346 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1347 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1348 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1349 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1350 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1351 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1352 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1353 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1354 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1355 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1356 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1357 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1358 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1359 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1360 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1361 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1362 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1363 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1364 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1365 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1366 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1367 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1368 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1369 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1370 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1371 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1372 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1373 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1374 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1376 flags = BindingFlags.Static | BindingFlags.NonPublic |
1377 BindingFlags.Public;
1379 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1380 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1381 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1382 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1383 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1384 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1385 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1386 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1387 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1388 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1389 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1390 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1391 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1392 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1393 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1394 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1395 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1396 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1397 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1398 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1399 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1400 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1401 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1402 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1403 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1404 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1405 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1406 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1407 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1408 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1411 [Test] // GetProperty (String, BindingFlags)
1412 public void GetProperty2_Name_Null ()
1414 Type type = typeof (Bar);
1416 type.GetProperty ((string) null);
1418 } catch (ArgumentNullException ex) {
1419 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1420 Assert.IsNull (ex.InnerException, "#3");
1421 Assert.IsNotNull (ex.Message, "#4");
1422 Assert.IsNotNull (ex.ParamName, "#5");
1423 Assert.AreEqual ("name", ex.ParamName, "#6");
1427 [Test] // GetProperty (String, Type)
1428 public void GetProperty3_Name_Null ()
1430 Type type = typeof (Bar);
1432 type.GetProperty ((string) null, typeof (int));
1434 } catch (ArgumentNullException ex) {
1435 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1436 Assert.IsNull (ex.InnerException, "#3");
1437 Assert.IsNotNull (ex.Message, "#4");
1438 Assert.IsNotNull (ex.ParamName, "#5");
1439 Assert.AreEqual ("name", ex.ParamName, "#6");
1443 [Test] // GetProperty (String, Type [])
1444 public void GetProperty4_Name_Null ()
1446 Type type = typeof (Bar);
1448 type.GetProperty ((string) null, Type.EmptyTypes);
1450 } catch (ArgumentNullException ex) {
1451 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1452 Assert.IsNull (ex.InnerException, "#3");
1453 Assert.IsNotNull (ex.Message, "#4");
1454 Assert.IsNotNull (ex.ParamName, "#5");
1455 Assert.AreEqual ("name", ex.ParamName, "#6");
1459 [Test] // GetProperty (String, Type, Type [])
1460 public void GetProperty5_Name_Null ()
1462 Type type = typeof (Bar);
1464 type.GetProperty ((string) null, typeof (int),
1467 } catch (ArgumentNullException ex) {
1468 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1469 Assert.IsNull (ex.InnerException, "#3");
1470 Assert.IsNotNull (ex.Message, "#4");
1471 Assert.IsNotNull (ex.ParamName, "#5");
1472 Assert.AreEqual ("name", ex.ParamName, "#6");
1476 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1477 public void GetProperty6_Name_Null ()
1479 Type type = typeof (Bar);
1481 type.GetProperty ((string) null, typeof (int),
1482 Type.EmptyTypes, null);
1484 } catch (ArgumentNullException ex) {
1485 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1486 Assert.IsNull (ex.InnerException, "#3");
1487 Assert.IsNotNull (ex.Message, "#4");
1488 Assert.IsNotNull (ex.ParamName, "#5");
1489 Assert.AreEqual ("name", ex.ParamName, "#6");
1493 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1494 public void GetProperty7_Name_Null ()
1496 Type type = typeof (Bar);
1498 type.GetProperty ((string) null, BindingFlags.Public,
1499 null, typeof (int), Type.EmptyTypes, null);
1501 } catch (ArgumentNullException ex) {
1502 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1503 Assert.IsNull (ex.InnerException, "#3");
1504 Assert.IsNotNull (ex.Message, "#4");
1505 Assert.IsNotNull (ex.ParamName, "#5");
1506 Assert.AreEqual ("name", ex.ParamName, "#6");
1511 public void GetProperty8_PropertyType ()
1513 Type type = typeof (Bar);
1514 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1515 null, typeof (int), Type.EmptyTypes, null), "#1");
1516 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1517 typeof (long), new Type[0], null), "#2");
1520 #if !TARGET_JVM // StructLayout not supported for TARGET_JVM
1521 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1526 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1532 public void StructLayoutAttribute ()
1534 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1535 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1537 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1538 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1539 Assert.AreEqual (4, attr2.Pack);
1540 Assert.AreEqual (64, attr2.Size);
1542 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1543 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1544 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1546 #endif // TARGET_JVM
1549 public void Namespace ()
1551 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1555 public void GenericParameterNamespace ()
1557 var t = typeof (Foo<>).GetGenericArguments () [0];
1559 Assert.AreEqual ("T", t.Name);
1560 Assert.AreEqual ("MonoTests.System", t.Namespace);
1562 var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
1564 Assert.AreEqual ("S", s.Name);
1565 Assert.AreEqual ("MonoTests.System", s.Namespace);
1568 public static void Reflected (ref int a)
1575 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1576 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1580 public void GetInterfaces ()
1582 Type[] t = typeof (Duper).GetInterfaces ();
1583 Assert.AreEqual (1, t.Length);
1584 Assert.AreEqual (typeof (ICloneable), t[0]);
1586 Type[] t2 = typeof (IFace3).GetInterfaces ();
1587 Assert.AreEqual (2, t2.Length);
1591 public void GetInterfacesGenericVarWithConstraints ()
1593 var a = typeof (TypeTest).GetMethod ("GenericMethod");
1595 var p = a.GetParameters ();
1596 var i = p[0].ParameterType.GetElementType ();
1600 public static void GenericMethod<T, T2> (T[] arr) where T: IComparable<T> {
1606 public void GetFieldIgnoreCase ()
1608 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1621 public void GetPropertyAccessorModifiers ()
1623 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1624 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1628 public void IsAbstract ()
1630 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1631 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1632 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1633 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1634 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1635 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1638 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1639 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1640 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1644 public void IsCOMObject ()
1646 Type type = typeof (string);
1647 Assert.IsFalse (type.IsCOMObject, "#1");
1649 TypeBuilder tb = module.DefineType (genTypeName ());
1650 type = tb.CreateType ();
1651 Assert.IsFalse (type.IsCOMObject, "#2");
1655 public void IsImport ()
1657 Type type = typeof (string);
1658 Assert.IsFalse (type.IsImport, "#1");
1660 TypeBuilder tb = module.DefineType (genTypeName ());
1661 type = tb.CreateType ();
1662 Assert.IsFalse (type.IsImport, "#2");
1664 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1665 TypeAttributes.Interface | TypeAttributes.Abstract);
1666 type = tb.CreateType ();
1667 Assert.IsTrue (type.IsImport, "#3");
1671 public void IsInterface ()
1673 Assert.IsFalse (typeof (string).IsInterface, "#1");
1674 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1678 public void IsPrimitive () {
1679 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1680 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1681 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1685 public void IsValueType ()
1687 Assert.IsTrue (typeof (int).IsValueType, "#1");
1688 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1689 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1690 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1691 Assert.IsFalse (typeof (string).IsValueType, "#5");
1692 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1696 [Category("NotDotNet")]
1697 // Depends on the GAC working, which it doesn't durring make distcheck.
1698 [Category ("NotWorking")]
1699 public void GetTypeWithWhitespace ()
1701 Assert.IsNotNull (Type.GetType
1702 (@"System.Configuration.NameValueSectionHandler,
1707 PublicKeyToken=b77a5c561934e089"));
1711 public void GetTypeNonVectorArray ()
1713 Type t = Type.GetType ("System.String[*]");
1714 Assert.AreEqual ("System.String[*]", t.ToString ());
1718 // feature not available when compiled under FULL_AOT_RUNTIME
1719 [ExpectedException (typeof (NotImplementedException))]
1722 public void TypeFromCLSID ()
1724 Guid CLSID_ShellDesktop = new Guid("00021400-0000-0000-c000-000000000046");
1725 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1727 Type t1 = Type.GetTypeFromCLSID (CLSID_ShellDesktop);
1729 Type t2 = Type.GetTypeFromCLSID (CLSID_Bogus);
1731 Assert.AreEqual (t1.FullName, "System.__ComObject");
1733 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1734 Environment.OSVersion.Platform == PlatformID.Win32NT)
1735 Activator.CreateInstance(t1);
1737 Assert.AreEqual (t2.FullName, "System.__ComObject");
1739 Assert.AreNotEqual (t1, t2);
1743 [Category("NotWorking")] // Mono throws TargetInvokationException
1744 [ExpectedException("System.Runtime.InteropServices.COMException")]
1745 public void TypeFromCLSIDBogus ()
1747 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1748 Type t = Type.GetTypeFromCLSID (CLSID_Bogus);
1749 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1750 Environment.OSVersion.Platform == PlatformID.Win32NT)
1751 Activator.CreateInstance(t);
1753 throw new COMException ();
1757 public void ExerciseFilterName ()
1759 MemberInfo[] mi = typeof(Base).FindMembers(
1761 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1762 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1763 Type.FilterName, "*");
1764 Assert.AreEqual (4, mi.Length);
1765 mi = typeof(Base).FindMembers(
1767 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1768 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1769 Type.FilterName, "Test*");
1770 Assert.AreEqual (2, mi.Length);
1771 mi = typeof(Base).FindMembers(
1773 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1774 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1775 Type.FilterName, "TestVoid");
1776 Assert.AreEqual (1, mi.Length);
1777 mi = typeof(Base).FindMembers(
1779 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1780 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1781 Type.FilterName, "NonExistingMethod");
1782 Assert.AreEqual (0, mi.Length);
1786 public void ExerciseFilterNameIgnoreCase ()
1788 MemberInfo[] mi = typeof(Base).FindMembers(
1790 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1791 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1792 Type.FilterNameIgnoreCase, "*");
1793 Assert.AreEqual (4, mi.Length);
1794 mi = typeof(Base).FindMembers(
1796 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1797 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1798 Type.FilterNameIgnoreCase, "test*");
1799 Assert.AreEqual (2, mi.Length);
1800 mi = typeof(Base).FindMembers(
1802 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1803 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1804 Type.FilterNameIgnoreCase, "TESTVOID");
1805 Assert.AreEqual (1, mi.Length);
1806 mi = typeof(Base).FindMembers(
1808 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1809 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1810 Type.FilterNameIgnoreCase, "NonExistingMethod");
1811 Assert.AreEqual (0, mi.Length);
1815 [ExpectedException (typeof (InvalidFilterCriteriaException))]
1816 public void FilterAttribute_Invalid ()
1818 Type.FilterAttribute (MethodBase.GetCurrentMethod (), (byte) 1);
1822 public void GenericParameterMemberType ()
1824 var t = typeof (Foo<>).GetGenericArguments () [0];
1825 Assert.IsNotNull (t);
1827 Assert.AreEqual (MemberTypes.TypeInfo, t.MemberType);
1833 public int property {
1836 public ByRef0 (int i) {}
1837 public void f (int i) {}
1841 public void ByrefTypes ()
1843 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1844 Assert.IsNotNull (t);
1845 Assert.IsTrue (t.IsByRef);
1846 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1847 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1848 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1849 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1851 Assert.IsNull (t.GetMethod ("f"));
1852 Assert.IsNull (t.GetField ("field"));
1853 Assert.IsNull (t.GetProperty ("property"));
1857 public void TestAssemblyQualifiedName ()
1859 Type t = Type.GetType ("System.Byte[]&");
1860 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1862 t = Type.GetType ("System.Byte*&");
1863 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1865 t = Type.GetType ("System.Byte&");
1866 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1875 public void CreateValueTypeNoCtor ()
1877 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1881 [ExpectedException (typeof (MissingMethodException))]
1882 public void CreateValueTypeNoCtorArgs ()
1884 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1887 internal static string bug336841 (string param1, params string [] param2)
1889 StringBuilder sb = new StringBuilder ();
1893 for (int i = 0; i < param2.Length; i++) {
1896 sb.Append (param2 [i]);
1898 return sb.ToString ();
1901 internal static string bug336841 (string param1)
1903 return "#B:" + param1;
1906 internal static string bug336841 (params string [] param1)
1908 StringBuilder sb = new StringBuilder ();
1910 for (int i = 0; i < param1.Length; i++) {
1913 sb.Append (param1 [i]);
1915 return sb.ToString ();
1919 public void InvokeMember_GetSetField ()
1921 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1922 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1923 BindingFlags.SetField, null, null, new object [] { 5 });
1925 Assert.AreEqual (5, X.Value, "#A1");
1926 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
1927 BindingFlags.Public | BindingFlags.Static |
1928 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1929 null, null, new object [0]), "#A2");
1930 Assert.AreEqual (5, Y.Value, "#A3");
1931 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
1932 BindingFlags.Public | BindingFlags.Static |
1933 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1934 null, null, new object [0]), "#A4");
1937 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1938 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1939 BindingFlags.GetField | BindingFlags.SetField,
1940 null, null, new object [] { 5 });
1941 Assert.Fail ("#B1");
1942 } catch (ArgumentException ex) {
1943 // Cannot specify both Get and Set on a field
1944 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1945 Assert.IsNull (ex.InnerException, "#B3");
1946 Assert.IsNotNull (ex.Message, "#B4");
1947 Assert.IsNotNull (ex.ParamName, "#B5");
1948 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1953 public void InvokeMember_GetSetProperty ()
1956 typeof (ArrayList).InvokeMember ("Item",
1957 BindingFlags.GetProperty | BindingFlags.SetProperty |
1958 BindingFlags.Instance | BindingFlags.Public,
1959 null, new ArrayList (), new object [] { 0, "bar" });
1961 } catch (ArgumentException ex) {
1962 // Cannot specify both Get and Set on a property
1963 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1964 Assert.IsNull (ex.InnerException, "#3");
1965 Assert.IsNotNull (ex.Message, "#4");
1966 Assert.IsNotNull (ex.ParamName, "#5");
1967 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
1973 public void InvokeMember_InvokeMethod_Set ()
1976 typeof (ArrayList).InvokeMember ("ToString",
1977 BindingFlags.InvokeMethod | BindingFlags.SetField |
1978 BindingFlags.Instance | BindingFlags.Public,
1979 null, new ArrayList (), new object [0]);
1980 Assert.Fail ("#A1");
1981 } catch (ArgumentException ex) {
1982 // Cannot specify Set on a field and Invoke on a method
1983 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1984 Assert.IsNull (ex.InnerException, "#A3");
1985 Assert.IsNotNull (ex.Message, "#A4");
1986 Assert.IsNotNull (ex.ParamName, "#A5");
1987 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
1991 typeof (ArrayList).InvokeMember ("ToString",
1992 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
1993 BindingFlags.Instance | BindingFlags.Public,
1994 null, new ArrayList (), new object [0]);
1995 Assert.Fail ("#B1");
1996 } catch (ArgumentException ex) {
1997 // Cannot specify Set on a property and Invoke on a method
1998 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1999 Assert.IsNull (ex.InnerException, "#B3");
2000 Assert.IsNotNull (ex.Message, "#B4");
2001 Assert.IsNotNull (ex.ParamName, "#B5");
2002 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2007 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
2009 object [] invokeargs = { 1 };
2010 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
2011 BindingFlags.Public | BindingFlags.NonPublic |
2012 BindingFlags.Instance | BindingFlags.CreateInstance,
2013 null, null, invokeargs);
2017 public void InvokeMember_Name_Null ()
2020 typeof (X).InvokeMember ((string) null,
2021 BindingFlags.Public | BindingFlags.Static |
2022 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
2023 null, null, new object [] { 5 });
2025 } catch (ArgumentNullException ex) {
2026 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2027 Assert.IsNull (ex.InnerException, "#3");
2028 Assert.IsNotNull (ex.Message, "#4");
2029 Assert.IsNotNull (ex.ParamName, "#5");
2030 Assert.AreEqual ("name", ex.ParamName, "#6");
2035 public void InvokeMember_NoOperation ()
2038 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2039 BindingFlags.Static, null, null, new object [0]);
2041 } catch (ArgumentException ex) {
2042 // Must specify binding flags describing the
2043 // invoke operation required
2044 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2045 Assert.IsNull (ex.InnerException, "#3");
2046 Assert.IsNotNull (ex.Message, "#4");
2047 Assert.IsNotNull (ex.ParamName, "#5");
2048 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2052 [Test] // bug #321735
2053 public void InvokeMember_SetFieldProperty ()
2055 ArrayList list = new ArrayList ();
2057 list.GetType ().InvokeMember ("Item",
2058 BindingFlags.SetField | BindingFlags.SetProperty |
2059 BindingFlags.Instance | BindingFlags.Public,
2060 null, list, new object [] { 0, "bar" });
2061 Assert.AreEqual ("bar", list [0]);
2065 public void InvokeMember_SetField_ProvidedArgs ()
2068 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2069 BindingFlags.Static | BindingFlags.SetField,
2070 null, null, new object [0]);
2071 Assert.Fail ("#A1");
2072 } catch (ArgumentException ex) {
2073 // Only the field value can be specified to set
2075 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2076 Assert.IsNull (ex.InnerException, "#A3");
2077 Assert.IsNotNull (ex.Message, "#A4");
2078 Assert.IsNotNull (ex.ParamName, "#A5");
2079 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2083 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2084 BindingFlags.Static | BindingFlags.SetField,
2086 Assert.Fail ("#B1");
2087 } catch (ArgumentNullException ex) {
2088 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2089 Assert.IsNull (ex.InnerException, "#B3");
2090 Assert.IsNotNull (ex.Message, "#B4");
2091 Assert.IsNotNull (ex.ParamName, "#B5");
2092 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2096 [Test] // bug #336841
2097 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2098 public void InvokeMember_VarArgs ()
2100 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2101 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2102 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2103 BindingFlags.Instance;
2105 Type type = typeof (TypeTest);
2106 string result = (string) type.InvokeMember ("bug336841",
2107 flags, null, null, new object [] { "1" });
2108 Assert.IsNotNull (result, "#A1");
2109 Assert.AreEqual ("#B:1", result, "#A2");
2111 result = (string) type.InvokeMember ("bug336841", flags,
2112 null, null, new object [] { "1", "2", "3", "4" });
2113 Assert.IsNotNull (result, "#B1");
2114 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2118 [Test] // bug #348522
2119 public void InvokeMember_WithoutDefaultValue ()
2121 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
2123 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2124 new object [] {Missing.Value}, null, null, null);
2126 } catch (ArgumentException ex) {
2127 // Missing parameter does not have a default value
2128 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2129 Assert.IsNull (ex.InnerException, "#3");
2130 Assert.IsNotNull (ex.Message, "#4");
2131 Assert.IsNotNull (ex.ParamName, "#5");
2132 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2137 public void TestMissing () {
2138 Assert.AreEqual (Type.Missing, Missing.Value);
2142 public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
2143 var l = typeof (List<>);
2144 var m = l.GetMethod ("ConvertAll");
2145 var infl = m.MakeGenericMethod (typeof (int));
2146 var res = m.GetGenericMethodDefinition ();
2147 Assert.AreEqual (m, res, "#1");
2151 public void InvokeMember_OutParam ()
2153 object[] args = new object[] { new string [0] };
2154 typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
2155 Assert.IsTrue (args [0] is string[]);
2156 Assert.AreEqual (10, ((string[])args[0]).Length);
2159 public static void OutTest (out string[] a1)
2161 a1 = new string [10];
2166 public static int Value;
2175 public Z (IComparable value)
2180 public static void Run ()
2188 public TakesInt (int x)
2193 public int Integer {
2200 public TakesObject (object x) {}
2203 [Test] // bug #75241
2204 public void GetConstructorNullInTypes ()
2206 // This ends up calling type.GetConstructor ()
2207 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2208 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2212 public void GetConstructor_TakeInt_Object ()
2214 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2218 public void GetCustomAttributes_All ()
2220 object [] attrs = typeof (A).GetCustomAttributes (false);
2221 Assert.AreEqual (2, attrs.Length, "#A1");
2222 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2223 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2225 attrs = typeof (BA).GetCustomAttributes (false);
2226 Assert.AreEqual (1, attrs.Length, "#B1");
2227 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2229 attrs = typeof (BA).GetCustomAttributes (true);
2230 Assert.AreEqual (2, attrs.Length, "#C1");
2231 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2232 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2234 attrs = typeof (CA).GetCustomAttributes (false);
2235 Assert.AreEqual (0, attrs.Length, "#D");
2237 attrs = typeof (CA).GetCustomAttributes (true);
2238 Assert.AreEqual (1, attrs.Length, "#E1");
2239 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2242 static bool HasAttribute (object [] attrs, Type attributeType)
2244 foreach (object attr in attrs)
2245 if (attr.GetType () == attributeType)
2251 public void GetCustomAttributes_Type ()
2253 object [] attrs = null;
2255 attrs = typeof (A).GetCustomAttributes (
2256 typeof (VolatileModifier), false);
2257 Assert.AreEqual (1, attrs.Length, "#A1");
2258 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2259 attrs = typeof (A).GetCustomAttributes (
2260 typeof (VolatileModifier), true);
2261 Assert.AreEqual (1, attrs.Length, "#A3");
2262 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2264 attrs = typeof (A).GetCustomAttributes (
2265 typeof (NemerleAttribute), false);
2266 Assert.AreEqual (1, attrs.Length, "#B1");
2267 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2268 attrs = typeof (A).GetCustomAttributes (
2269 typeof (NemerleAttribute), true);
2270 Assert.AreEqual (1, attrs.Length, "#B3");
2271 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2273 attrs = typeof (A).GetCustomAttributes (
2274 typeof (FooAttribute), false);
2275 Assert.AreEqual (1, attrs.Length, "#C1");
2276 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2277 attrs = typeof (A).GetCustomAttributes (
2278 typeof (FooAttribute), false);
2279 Assert.AreEqual (1, attrs.Length, "#C3");
2280 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2282 attrs = typeof (BA).GetCustomAttributes (
2283 typeof (VolatileModifier), false);
2284 Assert.AreEqual (0, attrs.Length, "#D1");
2285 attrs = typeof (BA).GetCustomAttributes (
2286 typeof (VolatileModifier), true);
2287 Assert.AreEqual (1, attrs.Length, "#D2");
2288 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2290 attrs = typeof (BA).GetCustomAttributes (
2291 typeof (NemerleAttribute), false);
2292 Assert.AreEqual (0, attrs.Length, "#E1");
2293 attrs = typeof (BA).GetCustomAttributes (
2294 typeof (NemerleAttribute), true);
2295 Assert.AreEqual (1, attrs.Length, "#E2");
2296 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2298 attrs = typeof (BA).GetCustomAttributes (
2299 typeof (FooAttribute), false);
2300 Assert.AreEqual (1, attrs.Length, "#F1");
2301 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2302 attrs = typeof (BA).GetCustomAttributes (
2303 typeof (FooAttribute), true);
2304 Assert.AreEqual (1, attrs.Length, "#F3");
2305 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2307 attrs = typeof (bug82431A1).GetCustomAttributes (
2308 typeof (InheritAttribute), false);
2309 Assert.AreEqual (1, attrs.Length, "#G1");
2310 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2311 attrs = typeof (bug82431A1).GetCustomAttributes (
2312 typeof (InheritAttribute), true);
2313 Assert.AreEqual (1, attrs.Length, "#G3");
2314 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2316 attrs = typeof (bug82431A1).GetCustomAttributes (
2317 typeof (NotInheritAttribute), false);
2318 Assert.AreEqual (1, attrs.Length, "#H1");
2319 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2320 attrs = typeof (bug82431A1).GetCustomAttributes (
2321 typeof (InheritAttribute), true);
2322 Assert.AreEqual (1, attrs.Length, "#H3");
2323 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2325 attrs = typeof (bug82431A2).GetCustomAttributes (
2326 typeof (InheritAttribute), false);
2327 Assert.AreEqual (0, attrs.Length, "#I1");
2328 attrs = typeof (bug82431A2).GetCustomAttributes (
2329 typeof (InheritAttribute), true);
2330 Assert.AreEqual (0, attrs.Length, "#I2");
2332 attrs = typeof (bug82431A2).GetCustomAttributes (
2333 typeof (NotInheritAttribute), false);
2334 Assert.AreEqual (0, attrs.Length, "#J1");
2335 attrs = typeof (bug82431A2).GetCustomAttributes (
2336 typeof (NotInheritAttribute), true);
2337 Assert.AreEqual (0, attrs.Length, "#J2");
2339 attrs = typeof (bug82431A3).GetCustomAttributes (
2340 typeof (InheritAttribute), false);
2341 Assert.AreEqual (2, attrs.Length, "#K1");
2342 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2343 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2344 attrs = typeof (bug82431A3).GetCustomAttributes (
2345 typeof (InheritAttribute), true);
2346 Assert.AreEqual (2, attrs.Length, "#K4");
2347 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2348 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2350 attrs = typeof (bug82431A3).GetCustomAttributes (
2351 typeof (NotInheritAttribute), false);
2352 Assert.AreEqual (1, attrs.Length, "#L1");
2353 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2354 attrs = typeof (bug82431A3).GetCustomAttributes (
2355 typeof (NotInheritAttribute), true);
2356 Assert.AreEqual (1, attrs.Length, "#L3");
2357 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2359 attrs = typeof (bug82431B1).GetCustomAttributes (
2360 typeof (InheritAttribute), false);
2361 Assert.AreEqual (1, attrs.Length, "#M1");
2362 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2363 attrs = typeof (bug82431B1).GetCustomAttributes (
2364 typeof (InheritAttribute), true);
2365 Assert.AreEqual (1, attrs.Length, "#M3");
2366 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2368 attrs = typeof (bug82431B1).GetCustomAttributes (
2369 typeof (NotInheritAttribute), false);
2370 Assert.AreEqual (0, attrs.Length, "#N1");
2371 attrs = typeof (bug82431B1).GetCustomAttributes (
2372 typeof (NotInheritAttribute), true);
2373 Assert.AreEqual (0, attrs.Length, "#N2");
2375 attrs = typeof (bug82431B2).GetCustomAttributes (
2376 typeof (InheritAttribute), false);
2377 Assert.AreEqual (0, attrs.Length, "#O1");
2378 attrs = typeof (bug82431B2).GetCustomAttributes (
2379 typeof (InheritAttribute), true);
2380 Assert.AreEqual (1, attrs.Length, "#O2");
2381 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2383 attrs = typeof (bug82431B2).GetCustomAttributes (
2384 typeof (NotInheritAttribute), false);
2385 Assert.AreEqual (0, attrs.Length, "#P1");
2386 attrs = typeof (bug82431B2).GetCustomAttributes (
2387 typeof (NotInheritAttribute), true);
2388 Assert.AreEqual (0, attrs.Length, "#P2");
2390 attrs = typeof (bug82431B3).GetCustomAttributes (
2391 typeof (InheritAttribute), false);
2392 Assert.AreEqual (1, attrs.Length, "#Q1");
2393 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2394 attrs = typeof (bug82431B3).GetCustomAttributes (
2395 typeof (InheritAttribute), true);
2396 Assert.AreEqual (2, attrs.Length, "#Q3");
2397 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2398 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2400 attrs = typeof (bug82431B3).GetCustomAttributes (
2401 typeof (NotInheritAttribute), false);
2402 Assert.AreEqual (1, attrs.Length, "#R1");
2403 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2404 attrs = typeof (bug82431B3).GetCustomAttributes (
2405 typeof (NotInheritAttribute), true);
2406 Assert.AreEqual (1, attrs.Length, "#R3");
2407 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2409 attrs = typeof (bug82431B4).GetCustomAttributes (
2410 typeof (InheritAttribute), false);
2411 Assert.AreEqual (0, attrs.Length, "#S1");
2412 attrs = typeof (bug82431B4).GetCustomAttributes (
2413 typeof (InheritAttribute), true);
2414 Assert.AreEqual (1, attrs.Length, "#S2");
2415 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2417 attrs = typeof (bug82431B4).GetCustomAttributes (
2418 typeof (NotInheritAttribute), false);
2419 Assert.AreEqual (0, attrs.Length, "#T1");
2420 attrs = typeof (bug82431B4).GetCustomAttributes (
2421 typeof (NotInheritAttribute), true);
2422 Assert.AreEqual (0, attrs.Length, "#T2");
2424 attrs = typeof (A).GetCustomAttributes (
2425 typeof (string), false);
2426 Assert.AreEqual (0, attrs.Length, "#U1");
2427 attrs = typeof (A).GetCustomAttributes (
2428 typeof (string), true);
2429 Assert.AreEqual (0, attrs.Length, "#U2");
2432 [Test] // bug #76150
2433 public void IsDefined ()
2435 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2436 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2437 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2438 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2440 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2441 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2442 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2443 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2444 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2445 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2446 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2447 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2448 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2449 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2450 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2451 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2455 public void IsDefined_AttributeType_Null ()
2458 typeof (BA).IsDefined ((Type) null, false);
2460 } catch (ArgumentNullException ex) {
2461 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2462 Assert.IsNull (ex.InnerException, "#3");
2463 Assert.IsNotNull (ex.Message, "#4");
2464 Assert.IsNotNull (ex.ParamName, "#5");
2465 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2469 [Test] // bug #82431
2470 [Category ("NotWorking")]
2471 public void IsDefined_Inherited ()
2473 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2474 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2475 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2476 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2477 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2478 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2479 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2480 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2482 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2483 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2484 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2485 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2486 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2487 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2488 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2489 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2491 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2492 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2493 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2494 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2496 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2497 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2498 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2499 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2501 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2502 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2503 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2504 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2506 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2507 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2508 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2509 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2511 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2512 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2513 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2514 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2516 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2517 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2518 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2519 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2521 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2522 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2523 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2524 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2527 class Bug13767Attribute : Attribute
2529 public object[] field;
2531 public Bug13767Attribute (params object[] args)
2537 public enum Bug13767Enum
2543 [Bug13767("Demo", new[] { Bug13767Enum.Value1, Bug13767Enum.Value0 })]
2544 public void Bug13767Method(string attributeName, Bug13767Enum[]options)
2550 public void CustomAttributeWithNestedArrayOfEnum ()
2552 var m = GetType ().GetMethod ("Bug13767Method");
2554 var attr = m.GetCustomAttributes (false);
2555 Assert.AreEqual (1, attr.Length, "#1");
2557 var tc = (Bug13767Attribute)attr[0];
2558 Assert.AreEqual (2, tc.field.Length, "#2");
2559 Assert.AreEqual ("Demo", tc.field[0], "#3");
2560 Assert.IsNotNull (tc.field[1], "#4");
2562 var arr = (Bug13767Enum[])tc.field [1];
2563 Assert.AreEqual (2, arr.Length, "#5");
2564 Assert.AreEqual (Bug13767Enum.Value1, arr [0], "#6");
2565 Assert.AreEqual (Bug13767Enum.Value0, arr [1], "#7");
2568 [Test] // GetType (String)
2569 public void GetType1_TypeName_Null ()
2572 Type.GetType ((string) null);
2574 } catch (ArgumentNullException ex) {
2575 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2576 Assert.IsNull (ex.InnerException, "#3");
2577 Assert.IsNotNull (ex.Message, "#4");
2578 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2582 [Test] // GetType (String, Boolean)
2583 public void GetType2_TypeName_Null ()
2586 Type.GetType ((string) null, false);
2588 } catch (ArgumentNullException ex) {
2589 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2590 Assert.IsNull (ex.InnerException, "#3");
2591 Assert.IsNotNull (ex.Message, "#4");
2592 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2596 [Test] // GetType (String, Boolean, Boolean)
2597 public void GetType3_TypeName_Null ()
2600 Type.GetType ((string) null, false, false);
2602 } catch (ArgumentNullException ex) {
2603 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2604 Assert.IsNull (ex.InnerException, "#3");
2605 Assert.IsNotNull (ex.Message, "#4");
2606 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2611 public void GetTypeArray_Args_Null ()
2614 Type.GetTypeArray ((object []) null);
2616 } catch (ArgumentNullException ex) {
2617 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2618 Assert.IsNull (ex.InnerException, "#3");
2619 Assert.IsNotNull (ex.Message, "#4");
2620 Assert.AreEqual ("args", ex.ParamName, "#5");
2625 public void GetTypeCode ()
2627 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2628 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2629 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2630 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2631 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2632 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2633 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2634 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2635 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2636 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2637 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2638 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2639 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2640 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2641 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2642 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2643 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2644 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2648 public void GetTypeFromHandle_Handle_Zero ()
2650 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2652 Assert.IsNull (Type.GetTypeFromHandle (handle));
2656 public void GetTypeHandle_O_Null ()
2659 Type.GetTypeHandle (null);
2661 } catch (ArgumentNullException ex) {
2662 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2663 Assert.IsNull (ex.InnerException, "#3");
2664 Assert.IsNotNull (ex.Message, "#4");
2665 Assert.IsNull (ex.ParamName, "#5");
2669 [Test] // GetConstructor (Type [])
2670 public void GetConstructor1 ()
2673 ConstructorInfo ctor;
2675 type = typeof (CtorsA);
2676 ctor = type.GetConstructor (Type.EmptyTypes);
2677 Assert.IsNotNull (ctor, "#A1");
2678 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2679 Assert.IsFalse (ctor.IsStatic, "#A3");
2680 Assert.IsTrue (ctor.IsPublic, "#A4");
2681 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2683 type = typeof (CtorsB);
2684 ctor = type.GetConstructor (Type.EmptyTypes);
2685 Assert.IsNotNull (ctor, "#B1");
2686 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2687 Assert.IsFalse (ctor.IsStatic, "#B3");
2688 Assert.IsTrue (ctor.IsPublic, "#B4");
2689 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2691 type = typeof (CtorsC);
2692 ctor = type.GetConstructor (Type.EmptyTypes);
2693 Assert.IsNull (ctor, "#C");
2695 type = typeof (CtorsC);
2696 ctor = type.GetConstructor (new Type [] { typeof (int) });
2697 Assert.IsNotNull (ctor, "#D1");
2698 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2699 Assert.IsFalse (ctor.IsStatic, "#D3");
2700 Assert.IsTrue (ctor.IsPublic, "#D4");
2701 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2704 [Test] // GetConstructor (Type [])
2705 public void GetConstructor1_Types_Null ()
2708 typeof (BindingFlags).GetConstructor (null);
2710 } catch (ArgumentNullException ex) {
2711 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2712 Assert.IsNull (ex.InnerException, "#3");
2713 Assert.IsNotNull (ex.Message, "#4");
2714 Assert.IsNotNull (ex.ParamName, "#5");
2715 Assert.AreEqual ("types", ex.ParamName, "#6");
2719 [Test] // GetConstructor (Type [])
2720 public void GetConstructor1_Types_ItemNull ()
2722 Type type = typeof (BindingFlags);
2724 type.GetConstructor (new Type[1] { null });
2725 Assert.Fail ("#A1");
2726 } catch (ArgumentNullException ex) {
2727 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2728 Assert.IsNull (ex.InnerException, "#A3");
2729 Assert.IsNotNull (ex.Message, "#A4");
2730 Assert.IsNotNull (ex.ParamName, "#A5");
2731 Assert.AreEqual ("types", ex.ParamName, "#A6");
2734 type = typeof (TakesInt);
2736 type.GetConstructor (new Type [1] { null });
2737 Assert.Fail ("#B1");
2738 } catch (ArgumentNullException ex) {
2739 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2740 Assert.IsNull (ex.InnerException, "#B3");
2741 Assert.IsNotNull (ex.Message, "#B4");
2742 Assert.IsNotNull (ex.ParamName, "#B5");
2743 Assert.AreEqual ("types", ex.ParamName, "#B6");
2747 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2748 public void GetConstructor2_Types_ItemNull ()
2750 Type type = typeof (BindingFlags);
2752 type.GetConstructor (BindingFlags.Default, null,
2753 new Type[1] { null }, null);
2755 } catch (ArgumentNullException ex) {
2756 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2757 Assert.IsNull (ex.InnerException, "#3");
2758 Assert.IsNotNull (ex.Message, "#4");
2759 Assert.IsNotNull (ex.ParamName, "#5");
2760 Assert.AreEqual ("types", ex.ParamName, "#6");
2764 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2765 public void GetConstructor3_Types_ItemNull ()
2767 Type type = typeof (BindingFlags);
2769 type.GetConstructor (BindingFlags.Default,
2770 null, CallingConventions.Any,
2771 new Type[1] { null }, null);
2773 } catch (ArgumentNullException ex) {
2774 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2775 Assert.IsNull (ex.InnerException, "#3");
2776 Assert.IsNotNull (ex.Message, "#4");
2777 Assert.IsNotNull (ex.ParamName, "#5");
2778 Assert.AreEqual ("types", ex.ParamName, "#6");
2783 public void GetMethod_Bug77367 ()
2785 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2789 #if !TARGET_JVM && !MOBILE // Reflection.Emit is not supported for TARGET_JVM
2791 public void EqualsUnderlyingType ()
2793 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2794 TypeAttributes attribs = TypeAttributes.Public;
2796 AssemblyName name = new AssemblyName ();
2797 name.Name = "enumtest";
2798 AssemblyBuilder assembly =
2799 AppDomain.CurrentDomain.DefineDynamicAssembly (
2802 ModuleBuilder module = assembly.DefineDynamicModule
2803 ("m", "enumtest.dll");
2804 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2806 Assert.IsTrue (typeof (int).Equals (e));
2808 #endif // TARGET_JVM
2811 public void Equals_Type_Null ()
2813 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2814 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2818 public void GetElementType_Bug63841 ()
2820 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2824 public void FullNameGenerics ()
2826 Type fooType = typeof (Foo<>);
2827 FieldInfo [] fields = fooType.GetFields ();
2829 Assert.AreEqual (1, fields.Length, "#0");
2831 Assert.IsNotNull (fooType.FullName, "#1");
2832 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2834 FieldInfo field = fooType.GetField ("Whatever");
2835 Assert.IsNotNull (field, "#2");
2836 Assert.AreEqual (field, fields [0], "#2a");
2837 Assert.IsNull (field.FieldType.FullName, "#3");
2838 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2839 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2841 PropertyInfo prop = fooType.GetProperty ("Test");
2842 Assert.IsNotNull (prop, "#5");
2843 Assert.IsNull (prop.PropertyType.FullName, "#6");
2844 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2845 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2847 MethodInfo method = fooType.GetMethod("Execute");
2848 Assert.IsNotNull (method, "#8");
2849 Assert.IsNull (method.ReturnType.FullName, "#9");
2850 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2851 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2853 ParameterInfo[] parameters = method.GetParameters();
2854 Assert.AreEqual (1, parameters.Length, "#11");
2855 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2856 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2857 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2861 public void TypeParameterIsNotGeneric ()
2863 Type fooType = typeof (Foo<>);
2864 Type type_param = fooType.GetGenericArguments () [0];
2865 Assert.IsTrue (type_param.IsGenericParameter);
2866 Assert.IsFalse (type_param.IsGenericType);
2867 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2869 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2870 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2871 Assert.IsTrue (type_param.ContainsGenericParameters);
2875 public void IsAssignable ()
2877 Type foo_type = typeof (Foo<>);
2878 Type foo_int_type = typeof (Foo<int>);
2879 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
2880 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
2882 Type ibar_short_type = typeof (IBar<short>);
2883 Type ibar_int_type = typeof (IBar<int>);
2884 Type baz_short_type = typeof (Baz<short>);
2885 Type baz_int_type = typeof (Baz<int>);
2887 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
2888 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
2890 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
2891 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
2894 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
2895 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
2896 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
2900 public void IsInstanceOf ()
2902 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
2906 public void IsInstanceOfArrayOfNullable ()
2908 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
2912 public void IsInstanceOfType_Null ()
2914 Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
2915 Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
2916 Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
2920 public void ByrefType ()
2922 Type foo_type = typeof (Foo<>);
2923 Type type_param = foo_type.GetGenericArguments () [0];
2924 Type byref_type_param = type_param.MakeByRefType ();
2925 Assert.IsFalse (byref_type_param.IsGenericParameter);
2926 Assert.IsNull (byref_type_param.DeclaringType);
2930 [ExpectedException (typeof (TypeLoadException))]
2931 public void MakeByRefByRef ()
2933 typeof (int).MakeByRefType ().MakeByRefType ();
2937 public void MakeArrayTypeTest ()
2939 // This should not crash:
2940 typeof (void).MakeArrayType ();
2945 public class ComFoo<T> {
2949 public void GetCustomAttributesGenericInstance ()
2951 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
2954 interface ByRef1<T> { void f (ref T t); }
2955 interface ByRef2 { void f<T> (ref T t); }
2957 interface ByRef3<T> where T:struct { void f (ref T? t); }
2958 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
2960 void CheckGenericByRef (Type t)
2962 string name = t.Name;
2963 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
2965 Assert.IsFalse (t.IsGenericType, name);
2966 Assert.IsFalse (t.IsGenericTypeDefinition, name);
2967 Assert.IsFalse (t.IsGenericParameter, name);
2971 public void GenericByRef ()
2973 CheckGenericByRef (typeof (ByRef1<>));
2974 CheckGenericByRef (typeof (ByRef2));
2975 CheckGenericByRef (typeof (ByRef3<>));
2976 CheckGenericByRef (typeof (ByRef4));
2979 public class Bug80242<T> {
2980 public interface IFoo { }
2981 public class Bar : IFoo { }
2982 public class Baz : Bar { }
2986 public void TestNestedTypes ()
2988 Type t = typeof (Bug80242<object>);
2989 Assert.IsFalse (t.IsGenericTypeDefinition);
2990 foreach (Type u in t.GetNestedTypes ()) {
2991 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
2992 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
2996 [Test] // bug #82211
2997 public void GetMembers_GenericArgument ()
2999 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
3000 MemberInfo [] members = argType.GetMembers ();
3001 Assert.IsNotNull (members, "#1");
3002 Assert.AreEqual (4, members.Length, "#2");
3006 [ExpectedException (typeof (ArgumentNullException))]
3007 public void ReflectionOnlyGetTypeNullTypeName ()
3009 Type.ReflectionOnlyGetType (null, false, false);
3013 public void ReflectionOnlyGetTypeDoNotThrow ()
3015 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
3019 [ExpectedException (typeof (FileNotFoundException))]
3020 public void ReflectionOnlyGetTypeThrow ()
3022 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
3026 public void ReflectionOnlyGetType ()
3028 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
3029 Assert.AreEqual ("System.Int32", t.FullName);
3034 [ExpectedException (typeof (NotSupportedException))]
3036 public void MakeGenericType_UserDefinedType ()
3038 Type ut = new UserType (typeof (int));
3039 Type t = typeof (Foo<>).MakeGenericType (ut);
3040 Assert.IsTrue (t.IsGenericType, "#A1");
3041 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3043 Type arg = t.GetGenericArguments () [0];
3044 Assert.IsNotNull (arg, "#B1");
3045 Assert.IsFalse (arg.IsGenericType, "#B2");
3046 Assert.AreEqual (ut, arg, "#B3");
3049 [Category ("NotWorking")]
3050 //We dont support instantiating a user type
3051 public void MakeGenericType_NestedUserDefinedType ()
3053 Type ut = new UserType (new UserType (typeof (int)));
3054 Type t = typeof (Foo<>).MakeGenericType (ut);
3055 Assert.IsTrue (t.IsGenericType, "#A1");
3056 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3058 Type arg = t.GetGenericArguments () [0];
3059 Assert.IsNotNull (arg, "#B1");
3060 Assert.IsFalse (arg.IsGenericType, "#B2");
3061 Assert.AreEqual (ut, arg, "#B3");
3065 [Category ("NotWorking")]
3066 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3068 Type ut = new UserType(typeof(int));
3069 Type t = typeof(Foo<>).MakeGenericType(ut);
3070 Assert.IsTrue (t.IsGenericType, "#1");
3072 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3077 [ExpectedException (typeof (NotSupportedException))]
3079 public void MakeGenericType_BadUserType ()
3081 Type ut = new UserType (null);
3082 Type t = typeof (Foo<>).MakeGenericType (ut);
3083 var g0 = t.GetGenericArguments () [0];
3084 Assert.AreSame (g0, ut, "#1");
3088 public void MakeGenericType_WrongNumOfArguments ()
3091 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3093 } catch (ArgumentException) {
3097 [AttributeUsage (AttributeTargets.All)]
3098 public class DocAttribute : Attribute {
3099 public DocAttribute (string docs) {}
3102 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3103 where T : class, new ()
3106 public T Bar { get{return null;}}
3108 public void M<[Doc ("X")] X> (X x)
3113 [Test] //bug #377596
3114 public void GetGenericArguments_ArgumentsHaveAttributes ()
3116 Type type = typeof(GenericClassWithAttributes<,>);
3117 Type[] tArgs = type.GetGenericArguments ();
3118 MethodInfo m = type.GetMethod ("M");
3119 Type[] mArgs = m.GetGenericArguments ();
3120 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3121 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3122 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3125 [Test] //bug #471255
3126 public void GetTypeCalledUsingReflection ()
3128 Type expectedType = Type.GetType ("NoNamespaceClass");
3129 Assert.IsNotNull (expectedType, "#1");
3130 MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
3131 object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3132 Assert.AreSame (expectedType, r, "#2");
3136 public void EqualsUserType () {
3137 UserType2 t1 = new UserType2(null);
3138 UserType2 t2 = new UserType2(t1);
3139 Assert.IsTrue (t1.Equals(t2));
3143 public void GetHashCodeUserType () {
3144 UserType2 t1 = new UserType2(null);
3145 UserType2 t2 = new UserType2(t1);
3146 Assert.AreEqual (42, t2.GetHashCode());
3150 public void IsGenericTypeDefinitionUserType () {
3151 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3155 public void IsGenericTypeUserType () {
3156 Assert.IsFalse (new UserType(null).IsGenericType);
3160 [ExpectedException (typeof (NotSupportedException))]
3161 public void GetGenericTypeDefinitionUserType () {
3162 new UserType(null).GetGenericTypeDefinition ();
3165 [ExpectedException (typeof (NotSupportedException))]
3166 public void GetGenericArgumentsUserType () {
3167 new UserType(null).GetGenericArguments ();
3171 [ExpectedException (typeof (InvalidOperationException))]
3172 public void GenericParameterPositionUserType () {
3173 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3177 public void TypeGetMemberReturnTypeTest ()
3180 MemberTypes memtype;
3182 object [] flagsandtypes = new object [] {
3183 MemberTypes.All, typeof (MemberInfo []),
3184 MemberTypes.Constructor, typeof (ConstructorInfo []),
3185 MemberTypes.Custom, typeof (MemberInfo []),
3186 MemberTypes.Event, typeof (EventInfo []),
3187 MemberTypes.Field, typeof (FieldInfo []),
3188 MemberTypes.Method, typeof (MethodInfo []),
3189 MemberTypes.NestedType, typeof (Type []),
3190 MemberTypes.Property, typeof (PropertyInfo []),
3191 MemberTypes.TypeInfo, typeof (Type [])};
3193 for (int i=0; i < flagsandtypes.Length; i+=2) {
3194 memtype = (MemberTypes)flagsandtypes [i];
3195 testtype = (Type)flagsandtypes [i+1];
3196 obj = GetType ().GetMember ("DummyMember", memtype,
3197 BindingFlags.Public | BindingFlags.Instance);
3198 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3199 "Expected " + testtype.FullName);
3205 public void TypeNameStartsWithSpace ()
3207 Type t1 = Type.GetType ("System.Type, mscorlib");
3208 Type t2 = Type.GetType (" System.Type, mscorlib");
3209 Assert.AreEqual (t1, t2);
3214 public void Bug506757 ()
3216 AssemblyName assemblyName = new AssemblyName ();
3217 assemblyName.Name = "customMod";
3218 assemblyName.Version = new Version (1, 2, 3, 4);
3220 AssemblyBuilder assembly
3221 = Thread.GetDomain().DefineDynamicAssembly(
3222 assemblyName, AssemblyBuilderAccess.RunAndSave);
3224 ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3226 TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3227 TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3228 TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3230 MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3231 MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3233 MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3234 MethodAttributes.FamORAssem;
3236 MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3237 MethodAttributes.Public;
3240 MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3241 m0.GetILGenerator ().Emit (OpCodes.Ret);
3243 MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3244 m1.GetILGenerator ().Emit (OpCodes.Ret);
3246 MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3247 m2.GetILGenerator ().Emit (OpCodes.Ret);
3250 type0.CreateType ();
3251 type1.CreateType ();
3252 Type t2 = type2.CreateType ();
3254 foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3255 Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3259 public void MakeArrayTypeOfOneDimension ()
3261 Type vector = typeof (int).MakeArrayType ();
3262 Type szarray = typeof (int).MakeArrayType (1);
3264 Assert.AreNotEqual (vector, szarray, "#1");
3265 Assert.AreEqual ("Int32[]", vector.Name, "#2");
3266 Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3269 public class DeclaringMethodFoo {
3270 public void Test<T> (T t) {}
3271 public void Test2<T> (ref T t) {}
3274 public class DeclaringMethodBar<T> {
3275 public void Test2 (ref T t) {}
3279 public void DeclaringMethodOnlyWorksWithGenericArgs ()
3281 MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3282 MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3284 Assert.AreEqual (testMethod, otherMethod,"#1");
3286 Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3289 var x = typeof (int).DeclaringMethod;
3291 } catch (InvalidOperationException) {}
3294 var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3296 } catch (InvalidOperationException) {}
3299 var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3301 } catch (InvalidOperationException) {}
3306 public void GetArrayRankThrowsForNonArrayType ()
3308 Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3309 Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3311 typeof (int).GetArrayRank ();
3313 } catch (ArgumentException) {}
3316 [Test] //Bug #564379
3317 public void GetMethodsReturnPublicMethodsInInterfaces ()
3319 Type t = typeof (NonClosingStream);
3320 MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3322 Assert.AreEqual (5, methods.Length, "#1");
3325 foreach (var m in methods) {
3326 if (m.Name.Equals ("ToString"))
3327 Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3328 else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3329 Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3330 else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3331 Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3333 Assert.Fail ("invalid method " + m);
3338 [Test] // Bug #574696
3339 public void GetMember_DoesntReturnPrivatePropOfParent ()
3341 BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
3342 Assert.AreEqual (1, typeof (Bar).GetMember ("PrivInst", flags).Length);
3343 Assert.AreEqual (0, typeof (Bar).GetMember ("PrivInstBase", flags).Length);
3344 Assert.AreEqual (1, typeof (Foo).GetMember ("PrivInstBase", flags).Length);
3347 [Test] // Bug #484246
3348 public void GetInterfaceCompareAgainstGTDNames ()
3350 var t = typeof (Dictionary<string,string>);
3351 var iface = typeof (IDictionary<string,string>);
3353 Assert.AreSame (iface, t.GetInterface ("System.Collections.Generic.IDictionary`2"), "#1");
3355 string name = "System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]";
3357 Assert.IsNull (t.GetInterface (name), "#2");
3361 public void RuntimeCorrectlyNormalizeGenericTypes ()
3363 Type lst = typeof (MList<>);
3364 Type arg = lst.GetGenericArguments ()[0];
3366 Type sup = lst.BaseType;
3367 Type sa0 = sup.GetGenericArguments ()[0];
3368 Type sa1 = sup.GetGenericArguments ()[1];
3370 Assert.IsTrue (sa1 == lst, "#1");
3371 Assert.IsTrue (sa0 == arg, "#2");
3373 Type inst = typeof (Cons<,>).MakeGenericType (arg, lst.MakeGenericType (arg));
3374 Assert.IsTrue (inst == sup, "#3");
3382 class MList<A> : Cons<A, MList<A>>
3387 [Test] // Bug #331126
3388 public void IsAssignableFromWorksCorrectlyWithByRefs ()
3390 Type int_byref = typeof (int).MakeByRefType ();
3391 Type obj_byref = typeof (object).MakeByRefType ();
3392 Type long_byref = typeof (long).MakeByRefType ();
3393 Type enum1_byref = typeof (AttributeTargets).MakeByRefType ();
3394 Type enum2_byref = typeof (PlatformID).MakeByRefType ();
3395 Type uint_byref = typeof (uint).MakeByRefType ();
3396 Type string_byref = typeof (object).MakeByRefType ();
3397 Type struct0_byref = typeof (Size4).MakeByRefType ();
3398 Type struct1_byref = typeof (Size4b).MakeByRefType ();
3399 Type mvar0_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[0].MakeByRefType ();
3400 Type mvar1_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[1].MakeByRefType ();
3402 Assert.IsFalse (typeof (int).IsAssignableFrom (int_byref), "#1");
3403 Assert.IsFalse (int_byref.IsAssignableFrom (typeof (int)), "#2");
3404 Assert.IsFalse (obj_byref.IsAssignableFrom (long_byref), "#3");
3405 Assert.IsFalse (long_byref.IsAssignableFrom (obj_byref), "#4");
3406 Assert.IsTrue (enum1_byref.IsAssignableFrom (enum2_byref), "#5");
3407 Assert.IsTrue (enum2_byref.IsAssignableFrom (enum1_byref), "#6");
3408 Assert.IsTrue (int_byref.IsAssignableFrom (enum2_byref), "#7");
3409 Assert.IsTrue (enum2_byref.IsAssignableFrom (int_byref), "#8");
3410 Assert.IsTrue (enum2_byref.IsAssignableFrom (uint_byref), "#9");
3411 Assert.IsTrue (uint_byref.IsAssignableFrom (enum2_byref), "#10");
3412 Assert.IsTrue (int_byref.IsAssignableFrom (uint_byref), "#11");
3413 Assert.IsTrue (uint_byref.IsAssignableFrom (int_byref), "#12");
3415 Assert.IsTrue (typeof (object).IsAssignableFrom (typeof (long)), "#13");
3417 Assert.IsTrue (obj_byref.IsAssignableFrom (string_byref), "#14");
3418 Assert.IsTrue (string_byref.IsAssignableFrom (obj_byref), "#15");
3420 Assert.IsFalse (uint_byref.IsAssignableFrom (struct0_byref), "#16");
3421 Assert.IsFalse (struct0_byref.IsAssignableFrom (int_byref), "#17");
3422 Assert.IsFalse (struct0_byref.IsAssignableFrom (struct1_byref), "#18");
3424 Assert.IsFalse (obj_byref.IsAssignableFrom (mvar0_byref), "#19");
3425 Assert.IsFalse (mvar0_byref.IsAssignableFrom (mvar1_byref), "#20");
3426 Assert.IsTrue (mvar0_byref.IsAssignableFrom (mvar0_byref), "#21");
3427 Assert.IsFalse (mvar0_byref.IsAssignableFrom (obj_byref), "#22");
3430 public void Bug331126<T,K> () {}
3432 public struct Size4 {
3436 public struct Size4b {
3440 [Test] // Bug #612780
3441 public void CannotMakeDerivedTypesFromTypedByRef ()
3444 typeof (global::System.TypedReference).MakeArrayType ();
3446 } catch (TypeLoadException) { }
3449 typeof (global::System.TypedReference).MakeByRefType ();
3451 } catch (TypeLoadException) { }
3454 typeof (global::System.TypedReference).MakePointerType ();
3456 } catch (TypeLoadException) { }
3461 public void DeclaringTypeOfGenericNestedTypeInstanceIsOpen ()
3463 var type = typeof (Foo<int>.Nested<string>);
3464 Assert.AreSame (typeof (Foo<>), type.DeclaringType, "#1");
3468 interface IGetInterfaceMap<in T>
3473 class GetInterfaceMap : IGetInterfaceMap<object>
3475 public string Bar (object t)
3477 return t.GetType ().FullName;
3482 public void GetInterfaceMapWorksWithVariantIfaces ()
3484 InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3485 Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3486 Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3488 res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3489 Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3490 Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3494 public class MyType : TypeDelegator {
3497 public override bool Equals (Type t) {
3499 return base.Equals (t);
3502 public override Type UnderlyingSystemType {
3505 return typeof (int);
3511 public void NewV4EqualsBehavior ()
3513 var ta = new MyType ();
3514 var tb = new MyType ();
3515 object a = ta, b = tb;
3518 Assert.AreEqual (1, ta.eq, "#1");
3519 Assert.AreEqual (0, ta.ust, "#2");
3521 Assert.AreEqual (2, ta.eq, "#3");
3522 Assert.AreEqual (1, ta.ust, "#4");
3523 Assert.AreEqual (0, tb.eq, "#5");
3524 Assert.AreEqual (1, tb.ust, "#6");
3527 public enum MyRealEnum : short {
3532 public enum MyRealEnum2 : byte {
3536 public enum MyRealEnum3 : short {
3540 public class MyEnum : TypeDelegator {
3541 public bool is_enum { get; set; }
3542 public int fields { get; set; }
3544 public override bool IsSubclassOf (Type c) {
3545 return c == typeof (Enum) && is_enum;
3548 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3551 FieldInfo[] res = new FieldInfo [fields];
3552 for (int i = 0; i < fields; ++i) {
3553 if ((bindingAttr & BindingFlags.Instance) != 0)
3554 res [i] = typeof (MyRealEnum).GetField ("value__");
3556 res [i] = typeof (MyRealEnum).GetField ("A");
3563 public void GetEnumUnderlyingType () {
3566 new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3568 } catch (ArgumentException) {}
3571 new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3573 } catch (ArgumentException) {}
3576 new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3578 } catch (ArgumentException) {}
3580 Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3584 public void GetEnumNames () {
3586 new MyEnum () { is_enum = false }.GetEnumNames ();
3588 } catch (ArgumentException) {}
3590 var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3591 Assert.AreEqual (1, res.Length, "#2");
3592 Assert.AreEqual ("A", res [0], "#3");
3594 res = typeof (MyRealEnum).GetEnumNames ();
3595 Assert.AreEqual (3, res.Length, "#4");
3596 Assert.AreEqual ("A", res [0], "#5");
3597 Assert.AreEqual ("B", res [1], "#6");
3598 Assert.AreEqual ("C", res [2], "#7");
3601 public enum OutOfOrderEnum : sbyte
3603 D = -1, C = 2, B = 1, A = 0
3607 public void GetEnumNamesSortsByUnsignedValue ()
3609 string[] names = typeof (OutOfOrderEnum).GetEnumNames ();
3610 Assert.AreEqual (4, names.Length);
3611 Assert.AreEqual ("A", names [0]);
3612 Assert.AreEqual ("B", names [1]);
3613 Assert.AreEqual ("C", names [2]);
3614 Assert.AreEqual ("D", names [3]);
3618 public void GetEnumValues () {
3620 new MyEnum () { is_enum = false }.GetEnumValues ();
3622 } catch (ArgumentException) {}
3625 new MyEnum () { is_enum = true }.GetEnumValues ();
3627 } catch (NotImplementedException) {}
3629 var array = typeof (MyRealEnum).GetEnumValues ();
3630 Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3631 MyRealEnum[] res = (MyRealEnum[])array;
3633 Assert.AreEqual (3, res.Length, "#4");
3634 Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3635 Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3636 Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3640 public void GetEnumValue () {
3642 typeof (MyRealEnum).GetEnumName (null);
3644 } catch (ArgumentException) { }
3647 new MyEnum () { is_enum = false }.GetEnumName (99);
3649 } catch (ArgumentException) { }
3652 Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3653 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
3654 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
3655 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
3657 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
3658 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
3659 Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
3660 Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
3662 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
3663 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
3665 typeof (MyRealEnum).GetEnumName (false);
3666 Assert.Fail ("#13");
3667 } catch (ArgumentException) { }
3669 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
3670 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
3672 typeof (MyRealEnum).GetEnumName ('c');
3673 Assert.Fail ("#16");
3674 } catch (ArgumentException) { }
3676 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
3677 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
3679 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
3680 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
3683 typeof (MyRealEnum).GetEnumName ((float)0);
3684 Assert.Fail ("#21");
3685 } catch (ArgumentException) { }
3687 typeof (MyRealEnum).GetEnumName ((double)0);
3688 Assert.Fail ("#22");
3689 } catch (ArgumentException) { }
3692 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
3693 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
3695 typeof (MyRealEnum2).GetEnumName (false);
3696 Assert.Fail ("#22", "#25");
3697 } catch (ArgumentException) { }
3699 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
3700 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
3703 typeof (MyRealEnum2).GetEnumName ('c');
3704 Assert.Fail ("#28");
3705 } catch (ArgumentException) { }
3707 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
3708 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
3710 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
3711 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
3714 typeof (MyRealEnum2).GetEnumName ((float)0);
3715 Assert.Fail ("#33");
3716 } catch (ArgumentException) { }
3718 typeof (MyRealEnum2).GetEnumName ((double)0);
3719 Assert.Fail ("#34");
3720 } catch (ArgumentException) { }
3722 Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
3726 public void IsEnumDefined () {
3728 typeof (MyRealEnum).IsEnumDefined (null);
3730 } catch (ArgumentException) { }
3733 new MyEnum () { is_enum = false }.IsEnumDefined (99);
3735 } catch (ArgumentException) { }
3738 typeof (MyRealEnum).IsEnumDefined (0);
3740 } catch (ArgumentException) { }
3743 typeof (MyRealEnum).IsEnumDefined ((ushort)0);
3745 } catch (ArgumentException) { }
3748 typeof (MyRealEnum).IsEnumDefined (MyRealEnum3.A);
3750 } catch (ArgumentException) { }
3753 typeof (MyRealEnum).IsEnumDefined (true);
3755 } catch (InvalidOperationException) { }
3758 typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
3760 } catch (ArgumentException) { }
3763 typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
3765 } catch (InvalidOperationException) { }
3767 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
3768 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
3769 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined (MyRealEnum.A), "#11");
3770 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ("d"), "#12");
3771 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ("A"), "#13");
3772 Assert.IsFalse (new MyEnum () { is_enum = true, fields = 1 }.IsEnumDefined ((short)99), "#14");
3777 public class Outer {
3778 public class Inner {}
3782 public class Outer<T> {
3783 public class Inner {}
3787 public void GetTypeWithDelegates () {
3788 var tname = typeof (MyRealEnum).AssemblyQualifiedName;
3789 var res = Type.GetType (tname, name => {
3790 return Assembly.Load (name);
3791 },(asm,name,ignore) => {
3792 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3794 Assert.AreEqual (typeof (MyRealEnum), res, "#1");
3797 tname = typeof (Dictionary<int, string>).AssemblyQualifiedName;
3798 res = Type.GetType (tname, name => {
3799 return Assembly.Load (name);
3800 },(asm,name,ignore) => {
3801 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3803 Assert.AreEqual (typeof (Dictionary<int, string>), res, "#2");
3806 tname = typeof (Foo<int>).AssemblyQualifiedName;
3807 res = Type.GetType (tname, name => {
3808 return Assembly.Load (name);
3809 },(asm,name,ignore) => {
3810 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3812 Assert.AreEqual (typeof (Foo<int>), res, "#3");
3815 tname = typeof (Outer.Inner).AssemblyQualifiedName;
3816 res = Type.GetType (tname, name => {
3817 return Assembly.Load (name);
3818 },(asm,name,ignore) => {
3819 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3821 Assert.AreEqual (typeof (Outer.Inner), res, "#4");
3824 tname = typeof (Outer<double>.Inner).AssemblyQualifiedName;
3825 res = Type.GetType (tname, name => {
3826 return Assembly.Load (name);
3827 },(asm,name,ignore) => {
3828 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3830 Assert.AreEqual (typeof (Outer<double>.Inner), res, "#5");
3833 tname = "System.Collections.Generic.List`1[System.Int32]";
3834 res = Type.GetType (tname, name => {
3835 return Assembly.Load (name);
3836 },(asm,name,ignore) => {
3837 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3839 Assert.AreEqual (typeof (List<int>), res, "#6");
3842 tname = typeof (Foo<>).FullName + "[,][]";
3843 res = Type.GetType (tname, name => {
3844 Console.WriteLine ("resolve-asm name {0}", name);
3845 return Assembly.Load (name);
3846 },(asm,name,ignore) => {
3847 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3849 Assert.AreEqual (typeof (Foo<>).MakeArrayType (2).MakeArrayType (), res, "#7");
3851 tname = string.Format("{0}[{1}][]*&", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName);
3852 res = Type.GetType (tname, name => {
3853 return Assembly.Load (name);
3854 },(asm,name,ignore) => {
3855 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3857 Assert.AreEqual (typeof (Foo<MyRealEnum>[]).MakePointerType ().MakeByRefType (), res, "#8");
3860 tname = typeof (MyRealEnum).FullName + "[][]";
3861 res = Type.GetType (tname, name => {
3862 return Assembly.Load (name);
3863 },(asm,name,ignore) => {
3864 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3866 Assert.AreEqual (typeof (MyRealEnum[][]), res, "#9");
3869 tname = typeof (MyRealEnum).FullName + "[*]";
3870 res = Type.GetType (tname, name => {
3871 return Assembly.Load (name);
3872 },(asm,name,ignore) => {
3873 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3875 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (1), res, "#10");
3878 tname = typeof (MyRealEnum).FullName + "&";
3879 res = Type.GetType (tname, name => {
3880 return Assembly.Load (name);
3881 },(asm,name,ignore) => {
3882 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3884 Assert.AreEqual (typeof (MyRealEnum).MakeByRefType (), res, "#11");
3887 tname = typeof (MyRealEnum).FullName + "*";
3888 res = Type.GetType (tname, name => {
3889 return Assembly.Load (name);
3890 },(asm,name,ignore) => {
3891 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3893 Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
3895 // assembly resolve without type resolve
3896 res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
3897 Assert.AreEqual (typeof (string), res);
3901 public class CustomGetType : TypeDelegator {
3904 public CustomGetType (string name) { this.name = name; }
3906 public override Type MakeGenericType (Type[] args) {
3907 return new CustomGetType ("GINST");
3910 public override Type GetNestedType(String name, BindingFlags bidingAttr) {
3911 return new CustomGetType ("NESTED");
3914 public override string ToString () { return "UT_" + name; }
3916 public override string Name {
3917 get { return "UT_" + name; }
3922 public void GetTypeWithDelegatesAndUserTypes ()
3924 var tname = "Magic[System.Int32]";
3925 var res = Type.GetType (tname, name => {
3926 return Assembly.Load (name);
3927 },(asm,name,ignore) => {
3928 if (name == "Magic") return new CustomGetType ("MAGIC");
3929 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3931 Assert.AreEqual ("UT_GINST", res.Name, "#1");
3934 tname = "Magic+MyRealEnum";
3935 res = Type.GetType (tname, name => {
3936 return Assembly.Load (name);
3937 },(asm,name,ignore) => {
3938 if (name == "Magic") return new CustomGetType ("MAGIC");
3939 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3941 Assert.AreEqual ("UT_NESTED", res.Name, "#2");
3944 void MustTLE (string tname) {
3946 var res = Type.GetType (tname, name => {
3947 return Assembly.Load (name);
3948 },(asm,name,ignore) => {
3949 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3951 Assert.Fail (tname);
3952 } catch (TypeLoadException) {}
3955 void MustANE (string tname) {
3957 var res = Type.GetType (tname, name => {
3958 return Assembly.Load (name);
3959 },(asm,name,ignore) => {
3960 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3962 Assert.Fail (tname);
3963 } catch (ArgumentNullException) {}
3966 void MustAE (string tname) {
3968 var res = Type.GetType (tname, name => {
3969 return Assembly.Load (name);
3970 },(asm,name,ignore) => {
3971 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3973 Assert.Fail (tname);
3974 } catch (ArgumentException) {}
3977 void MustFNFE (string tname) {
3979 var res = Type.GetType (tname, name => {
3980 return Assembly.Load (name);
3981 },(asm,name,ignore) => {
3982 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3984 Assert.Fail (tname);
3985 } catch (FileNotFoundException) {}
3989 public void NewGetTypeErrors () {
3991 MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
3992 MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
3993 MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));
3994 MustAE (string.Format ("{0}&*", typeof (MyRealEnum).FullName));
3995 MustAE (string.Format ("{0}&[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
3998 MustAE (string.Format ("{0}[[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
3999 MustAE (string.Format ("{0}[[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4000 MustAE (string.Format ("{0}[[{1}],", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4001 MustAE (string.Format ("{0}[[{1}]_", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4003 MustAE (string.Format ("{0}[{1}", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4004 MustAE (string.Format ("{0}[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4005 MustAE (string.Format ("{0}[{1},,", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4006 MustAE (string.Format ("{0}[{1} (", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4007 MustAE (string.Format ("{0}[", typeof (Foo<>).FullName));
4009 MustAE (string.Format ("{0}[**]", typeof (MyRealEnum).FullName));
4010 MustAE (string.Format ("{0}[*,*]", typeof (MyRealEnum).FullName));
4011 MustAE (string.Format ("{0}[*,]", typeof (MyRealEnum).FullName));
4012 MustAE (string.Format ("{0}[,*]", typeof (MyRealEnum).FullName));
4013 MustAE (string.Format ("{0}[,-]", typeof (MyRealEnum).FullName));
4014 MustAE (string.Format ("{0}[,{0}]", typeof (MyRealEnum).FullName));
4016 MustAE (string.Format ("{0}[{1}]]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4017 MustAE (string.Format ("{0}[,]]", typeof (MyRealEnum).FullName));
4020 string aqn = typeof (MyRealEnum).Assembly.FullName;
4021 MustFNFE (string.Format ("{0}, ZZZ{1}", typeof (MyRealEnum).FullName, aqn));
4022 MustTLE (string.Format ("{0}ZZZZ", typeof (MyRealEnum).FullName));
4023 MustTLE (string.Format ("{0}ZZZZ,{1}", typeof (MyRealEnum).FullName, aqn));
4026 delegate void MyAction<in T>(T ag);
4028 [Test] //bug #668506
4029 public void IsAssignableFromWithVariantDelegate () {
4030 Assert.IsFalse (typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>)), "#1");
4034 public void IsAssignableFromWithNullable () {
4035 Console.WriteLine(typeof(IEnumerable<int?>).IsAssignableFrom(typeof(IEnumerable<int>)));
4040 public void GetTypeParseGenericCorrectly () { //Bug #15124
4041 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
4042 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
4043 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
4044 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
4045 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
4046 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
4047 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
4048 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
4049 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
4050 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
4051 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
4052 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
4053 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
4054 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
4055 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
4058 public abstract class Stream : IDisposable
4060 public void Dispose ()
4062 Console.WriteLine ("stream::dispose");
4065 protected virtual void Dispose (bool disposing)
4070 public class NonClosingStream
4071 : Stream, IDisposable
4073 void IDisposable.Dispose()
4075 Console.WriteLine ("ncs::dispose");
4078 public override string ToString () { return ""; }
4081 static bool ContainsProperty (PropertyInfo [] props, string name)
4083 foreach (PropertyInfo p in props)
4089 public class NemerleAttribute : Attribute
4093 public class VolatileModifier : NemerleAttribute
4103 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4104 public class FooAttribute : Attribute
4108 public class BarAttribute : FooAttribute
4125 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
4126 public class InheritAttribute : Attribute
4130 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4131 public class NotInheritAttribute : InheritAttribute
4135 [NotInheritAttribute]
4136 public class bug82431A1
4140 public class bug82431A2 : bug82431A1
4144 [NotInheritAttribute]
4146 public class bug82431A3 : bug82431A1
4151 public class bug82431B1
4155 public class bug82431B2 : bug82431B1
4159 [NotInheritAttribute]
4160 public class bug82431B3 : bug82431B2
4164 public class bug82431B4 : bug82431B3
4172 public class Bug77367
4174 public void Run (bool b)
4181 private string PrivInstBlue
4183 get { return null; }
4186 protected string ProtInstBlue
4188 get { return null; }
4191 protected internal string ProIntInstBlue
4193 get { return null; }
4196 public long PubInstBlue
4200 if (PrivInstBlue == null)
4202 return long.MaxValue;
4206 internal int IntInstBlue
4211 private static string PrivStatBlue
4213 get { return null; }
4216 protected static string ProtStatBlue
4218 get { return null; }
4221 protected static internal string ProIntStatBlue
4223 get { return null; }
4226 public static long PubStatBlue
4230 if (PrivStatBlue == null)
4232 return long.MaxValue;
4236 internal static int IntStatBlue
4242 public class Foo : Blue
4244 private string PrivInstBase
4246 get { return null; }
4249 protected string ProtInstBase
4251 get { return null; }
4254 protected internal string ProIntInstBase
4256 get { return null; }
4259 public long PubInstBase
4263 if (PrivInstBase == null)
4265 return long.MaxValue;
4269 internal int IntInstBase
4274 private static string PrivStatBase
4276 get { return null; }
4279 protected static string ProtStatBase
4281 get { return null; }
4284 protected static internal string ProIntStatBase
4286 get { return null; }
4289 public static long PubStatBase
4293 if (PrivStatBase == null)
4295 return long.MaxValue;
4299 internal static int IntStatBase
4305 public class Bar : Foo
4307 private string PrivInst
4309 get { return null; }
4312 protected string ProtInst
4314 get { return null; }
4317 protected internal string ProIntInst
4319 get { return null; }
4326 if (PrivInst == null)
4328 return long.MaxValue;
4332 internal int IntInst
4337 private static string PrivStat
4339 get { return null; }
4342 protected static string ProtStat
4344 get { return null; }
4347 protected static internal string ProIntStat
4349 get { return null; }
4352 public static long PubStat
4356 if (PrivStat == null)
4358 return long.MaxValue;
4362 internal static int IntStat
4388 public CtorsC (int x)
4394 class UserType : Type
4396 protected Type type;
4398 public UserType(Type type) {
4402 public override Type UnderlyingSystemType { get { return this.type; } }
4404 public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
4406 public override string AssemblyQualifiedName { get { return null; } }
4408 public override Type BaseType { get { return null; } }
4410 public override Module Module { get { return this.type.Module; } }
4412 public override string Namespace { get { return null; } }
4414 public override bool IsGenericParameter { get { return true; } }
4416 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
4418 public override bool ContainsGenericParameters { get { return true; } }
4420 public override string FullName { get { return this.type.Name; } }
4422 public override Guid GUID { get { throw new NotSupportedException(); } }
4425 protected override bool IsArrayImpl() {
4429 protected override bool IsByRefImpl()
4434 protected override bool IsCOMObjectImpl()
4439 protected override bool IsPointerImpl()
4444 protected override bool IsPrimitiveImpl()
4450 protected override TypeAttributes GetAttributeFlagsImpl()
4455 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
4456 CallingConventions callConvention, Type[] types,
4457 ParameterModifier[] modifiers)
4462 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
4467 public override Type GetElementType()
4472 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
4478 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
4484 public override Type GetInterface(string name, bool ignoreCase)
4489 public override Type[] GetInterfaces()
4494 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
4499 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
4504 public override object[] GetCustomAttributes(bool inherit)
4509 public override bool IsDefined(Type attributeType, bool inherit)
4514 public override string Name { get { return this.type.Name; } }
4516 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
4518 throw new NotImplementedException();
4521 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
4523 throw new NotImplementedException();
4526 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
4527 CallingConventions callConvention, Type[] types,
4528 ParameterModifier[] modifiers)
4533 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
4538 public override Type GetNestedType(string name, BindingFlags bindingAttr)
4543 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
4548 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
4553 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
4554 Type returnType, Type[] types, ParameterModifier[] modifiers)
4559 protected override bool HasElementTypeImpl()
4564 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
4565 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
4566 string[] namedParameters)
4568 throw new NotSupportedException();
4572 class UserType2 : UserType {
4573 public UserType2 (Type type) : base (type) {
4576 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
4578 public override int GetHashCode()
4582 return type.GetHashCode();