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;
17 using System.Reflection.Emit;
18 using System.Runtime.InteropServices;
20 using System.Globalization;
22 class NoNamespaceClass {
25 namespace MonoTests.System
27 class Super : ICloneable
29 public virtual object Clone ()
44 interface IFace2 : IFace1
49 interface IFace3 : IFace2
64 public abstract int this [byte i] {
68 public abstract int this [int i] {
72 public abstract void TestVoid ();
73 public abstract void TestInt (int i);
76 class DeriveVTable : Base
78 public override int this [byte i] {
82 public override int this [int i] {
86 public override void TestVoid ()
91 public override void TestInt (int i)
97 class NewVTable : DeriveVTable
99 public new int this [byte i] {
103 public new int this [int i] {
107 public new void TestVoid ()
112 public new void TestInt (int i)
117 public void Overload ()
121 public void Overload (int i)
125 public NewVTable (out int i)
130 public void byref_method (out int i)
138 public virtual int Foo {
144 class Derived1 : Base1
146 public override int Foo {
151 class Derived2 : Base1
164 get { throw new NotImplementedException (); }
167 public T Execute (T a)
177 public interface IBar<T>
181 public class Baz<T> : IBar<T>
187 public static void Bang<S> () {}
190 public class Bug348522
192 public void Test (int __argument)
197 public class FirstMethodBinder : Binder
199 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
200 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
207 public override object ChangeType (object value, Type type1, CultureInfo culture)
212 // The rest is just to please the compiler
213 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
218 public override void ReorderArgumentArray(ref object[] a, object b)
222 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
227 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
235 public class TypeTest
237 private AssemblyBuilder assembly;
238 private ModuleBuilder module;
239 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
240 static int typeIndexer = 0;
245 AssemblyName assemblyName = new AssemblyName ();
246 assemblyName.Name = ASSEMBLY_NAME;
247 assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
248 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
249 module = assembly.DefineDynamicModule ("module1");
252 private string genTypeName ()
254 return "t" + (typeIndexer++);
257 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
261 private void GenericMethod<Q> (Q q)
266 public void TestIsAssignableFrom ()
268 // Simple tests for inheritance
269 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
270 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
271 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
272 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
275 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
276 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
277 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
278 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
280 // Tests for multiple dimensional arrays
281 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
282 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
283 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
284 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
286 // Tests for vectors<->one dimensional arrays */
287 #if TARGET_JVM // Lower bounds arrays are not supported for TARGET_JVM.
288 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1});
289 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
291 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
292 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
294 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
295 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
298 // Test that arrays of enums can be cast to their base types
299 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
301 // Test that arrays of valuetypes can't be cast to arrays of
303 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
304 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
305 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
307 // Test that arrays of enums can't be cast to arrays of references
308 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
309 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
310 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
312 // Check that ValueType and Enum are recognized as reference types
313 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
314 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
315 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
317 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
318 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
319 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
321 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
322 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
323 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
325 // Tests for byref types
326 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
327 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
328 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
330 // Tests for type parameters
331 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
332 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
333 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
337 [ExpectedException (typeof (ArgumentException))]
338 public void GetInterfaceMapOnInterface ()
340 typeof (IList).GetInterfaceMap (typeof (ICollection));
344 public void TestIsSubclassOf ()
346 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
348 // Tests for byref types
349 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
350 Assert.IsTrue (!paramType.IsSubclassOf (typeof (ValueType)), "#02");
351 //Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
352 Assert.IsTrue (!paramType.IsSubclassOf (paramType), "#04");
356 public void TestGetMethodImpl ()
358 // Test binding of new slot methods (using no types)
359 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
360 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
362 // Test binding of new slot methods (using types)
363 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
364 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
366 // Test overload resolution
367 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
369 // Test byref parameters
370 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
371 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
372 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
376 [Category ("TargetJvmNotWorking")]
377 public void TestGetPropertyImpl ()
379 // Test getting property that is exact
380 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
382 // Test getting property that is not exact
383 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
385 // Test overriding of properties when only the set accessor is overriden
386 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
390 public void GetProperties ()
392 // Test hide-by-name-and-signature
393 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length);
394 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType);
397 [Test] // GetProperties (BindingFlags)
398 public void GetProperties_Flags ()
400 PropertyInfo [] props;
401 Type type = typeof (Bar);
404 flags = BindingFlags.Instance | BindingFlags.NonPublic;
405 props = type.GetProperties (flags);
407 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
408 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
409 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
410 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
411 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
412 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
413 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
414 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
415 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
416 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
417 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
418 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
419 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
420 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
421 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
422 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
423 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
424 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
425 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
426 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
427 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
428 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
429 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
430 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
431 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
432 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
433 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
434 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
435 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
436 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
438 flags = BindingFlags.Instance | BindingFlags.Public;
439 props = type.GetProperties (flags);
441 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
442 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
443 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
444 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
445 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
446 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
447 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
448 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
449 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
450 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
451 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
452 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
453 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
454 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
455 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
456 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
457 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
458 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
459 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
460 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
461 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
462 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
463 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
464 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
465 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
466 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
467 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
468 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
469 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
470 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
472 flags = BindingFlags.Static | BindingFlags.Public;
473 props = type.GetProperties (flags);
475 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
476 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
477 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
478 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
479 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
480 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
481 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
482 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
483 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
484 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
485 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
486 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
487 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
488 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
489 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
490 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
491 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
492 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
493 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
494 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
495 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
496 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
497 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
498 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
499 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
500 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
501 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
502 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
503 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
504 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
506 flags = BindingFlags.Static | BindingFlags.NonPublic;
507 props = type.GetProperties (flags);
509 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
510 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
511 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
512 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
513 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
514 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
515 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
516 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
517 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
518 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
519 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
520 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
521 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
522 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
523 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
524 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
525 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
526 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
527 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
528 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
529 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
530 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
531 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
532 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
533 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
534 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
535 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
536 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
537 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
538 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
540 flags = BindingFlags.Instance | BindingFlags.NonPublic |
541 BindingFlags.FlattenHierarchy;
542 props = type.GetProperties (flags);
544 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
545 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
546 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
547 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
548 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
549 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
550 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
551 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
552 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
553 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
554 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
555 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
556 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
557 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
558 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
559 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
560 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
561 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
562 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
563 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
564 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
565 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
566 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
567 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
568 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
569 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
570 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
571 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
572 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
573 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
575 flags = BindingFlags.Instance | BindingFlags.Public |
576 BindingFlags.FlattenHierarchy;
577 props = type.GetProperties (flags);
579 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
580 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
581 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
582 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
583 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
584 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
585 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
586 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
587 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
588 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
589 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
590 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
591 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
592 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
593 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
594 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
595 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
596 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
597 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
598 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
599 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
600 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
601 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
602 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
603 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
604 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
605 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
606 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
607 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
608 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
610 flags = BindingFlags.Static | BindingFlags.Public |
611 BindingFlags.FlattenHierarchy;
612 props = type.GetProperties (flags);
614 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
615 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
616 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
617 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
618 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
619 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
620 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
621 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
622 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
623 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
624 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
625 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
626 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
627 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
628 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
629 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
630 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
631 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
632 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
633 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
634 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
635 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
636 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
637 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
638 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
639 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
640 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
641 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
642 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
643 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
645 flags = BindingFlags.Static | BindingFlags.NonPublic |
646 BindingFlags.FlattenHierarchy;
647 props = type.GetProperties (flags);
649 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
650 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
651 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
652 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
653 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
654 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
655 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
656 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
657 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
658 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
659 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
660 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
661 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
662 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
663 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
664 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
665 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
666 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
667 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
668 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
669 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
670 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
671 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
672 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
673 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
674 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
675 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
676 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
677 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
678 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
680 flags = BindingFlags.Instance | BindingFlags.NonPublic |
681 BindingFlags.DeclaredOnly;
682 props = type.GetProperties (flags);
684 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
685 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
686 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
687 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
688 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
689 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
690 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
691 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
692 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
693 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
694 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
695 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
696 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
697 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
698 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
699 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
700 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
701 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
702 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
703 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
704 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
705 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
706 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
707 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
708 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
709 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
710 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
711 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
712 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
713 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
715 flags = BindingFlags.Instance | BindingFlags.Public |
716 BindingFlags.DeclaredOnly;
717 props = type.GetProperties (flags);
719 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
720 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
721 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
722 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
723 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
724 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
725 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
726 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
727 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
728 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
729 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
730 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
731 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
732 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
733 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
734 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
735 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
736 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
737 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
738 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
739 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
740 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
741 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
742 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
743 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
744 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
745 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
746 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
747 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
748 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
750 flags = BindingFlags.Static | BindingFlags.Public |
751 BindingFlags.DeclaredOnly;
752 props = type.GetProperties (flags);
754 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
755 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
756 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
757 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
758 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
759 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
760 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
761 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
762 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
763 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
764 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
765 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
766 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
767 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
768 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
769 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
770 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
771 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
772 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
773 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
774 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
775 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
776 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
777 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
778 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
779 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
780 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
781 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
782 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
783 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
785 flags = BindingFlags.Static | BindingFlags.NonPublic |
786 BindingFlags.DeclaredOnly;
787 props = type.GetProperties (flags);
789 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
790 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
791 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
792 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
793 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
794 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
795 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
796 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
797 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
798 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
799 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
800 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
801 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
802 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
803 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
804 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
805 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
806 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
807 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
808 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
809 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
810 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
811 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
812 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
813 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
814 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
815 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
816 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
817 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
818 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
820 flags = BindingFlags.Instance | BindingFlags.NonPublic |
822 props = type.GetProperties (flags);
824 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
825 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
826 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
827 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
828 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
829 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
830 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
831 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
832 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
833 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
834 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
835 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
836 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
837 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
838 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
839 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
840 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
841 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
842 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
843 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
844 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
845 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
846 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
847 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
848 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
849 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
850 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
851 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
852 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
853 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
855 flags = BindingFlags.Static | BindingFlags.NonPublic |
857 props = type.GetProperties (flags);
859 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
860 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
861 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
862 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
863 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
864 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
865 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
866 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
867 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
868 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
869 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
870 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
871 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
872 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
873 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
874 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
875 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
876 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
877 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
878 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
879 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
880 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
881 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
882 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
883 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
884 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
885 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
886 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
887 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
888 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
891 [Test] // GetProperty (String)
892 public void GetProperty1_Name_Null ()
894 Type type = typeof (Bar);
896 type.GetProperty ((string) null);
898 } catch (ArgumentNullException ex) {
899 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
900 Assert.IsNull (ex.InnerException, "#3");
901 Assert.IsNotNull (ex.Message, "#4");
902 Assert.IsNotNull (ex.ParamName, "#5");
903 Assert.AreEqual ("name", ex.ParamName, "#6");
907 [Test] // GetProperty (String, BindingFlags)
908 public void GetProperty2 ()
910 Type type = typeof (Bar);
913 flags = BindingFlags.Instance | BindingFlags.NonPublic;
915 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
916 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
917 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
918 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
919 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
920 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
921 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
922 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
923 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
924 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
925 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
926 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
927 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
928 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
929 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
930 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
931 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
932 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
933 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
934 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
935 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
936 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
937 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
938 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
939 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
940 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
941 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
942 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
943 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
944 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
946 flags = BindingFlags.Instance | BindingFlags.Public;
948 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
949 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
950 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
951 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
952 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
953 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
954 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
955 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
956 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
957 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
958 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
959 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
960 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
961 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
962 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
963 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
964 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
965 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
966 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
967 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
968 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
969 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
970 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
971 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
972 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
973 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
974 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
975 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
976 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
977 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
979 flags = BindingFlags.Static | BindingFlags.Public;
981 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
982 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
983 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
984 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
985 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
986 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
987 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
988 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
989 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
990 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
991 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
992 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
993 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
994 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
995 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
996 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
997 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
998 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
999 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1000 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1001 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1002 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1003 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1004 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1005 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1006 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1007 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1008 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1009 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1010 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1012 flags = BindingFlags.Static | BindingFlags.NonPublic;
1014 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1015 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1016 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1017 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1018 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1019 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1020 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1021 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1022 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1023 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1024 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1025 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1026 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1027 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1028 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1029 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1030 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1031 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1032 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1033 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1034 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1035 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1036 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1037 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1038 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1039 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1040 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1041 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1042 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1043 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1045 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1046 BindingFlags.FlattenHierarchy;
1048 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1049 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1050 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1051 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1052 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1053 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1054 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1055 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1056 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1057 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1058 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1059 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1060 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1061 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1062 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1063 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1064 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1065 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1066 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1067 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1068 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1069 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1070 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1071 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1072 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1073 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1074 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1075 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1076 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1077 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1079 flags = BindingFlags.Instance | BindingFlags.Public |
1080 BindingFlags.FlattenHierarchy;
1082 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1083 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1084 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1085 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1086 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1087 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1088 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1089 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1090 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1091 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1092 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1093 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1094 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1095 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1096 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1097 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1098 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1099 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1100 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1101 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1102 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1103 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1104 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1105 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1106 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1107 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1108 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1109 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1110 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1111 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1113 flags = BindingFlags.Static | BindingFlags.Public |
1114 BindingFlags.FlattenHierarchy;
1116 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1117 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1118 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1119 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1120 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1121 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1122 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1123 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1124 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1125 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1126 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1127 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1128 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1129 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1130 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1131 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1132 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1133 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1134 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1135 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1136 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1137 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1138 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1139 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1140 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1141 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1142 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1143 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1144 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1145 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1147 flags = BindingFlags.Static | BindingFlags.NonPublic |
1148 BindingFlags.FlattenHierarchy;
1150 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1151 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1152 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1153 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1154 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1155 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1156 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1157 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1158 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1159 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1160 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1161 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1162 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1163 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1164 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1165 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1166 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1167 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1168 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1169 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1170 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1171 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1172 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1173 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1174 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1175 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1176 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1177 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1178 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1179 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1181 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1182 BindingFlags.DeclaredOnly;
1184 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1185 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1186 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1187 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1188 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1189 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1190 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1191 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1192 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1193 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1194 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1195 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1196 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1197 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1198 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1199 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1200 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1201 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1202 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1203 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1204 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1205 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1206 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1207 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1208 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1209 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1210 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1211 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1212 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1213 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1215 flags = BindingFlags.Instance | BindingFlags.Public |
1216 BindingFlags.DeclaredOnly;
1218 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1219 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1220 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1221 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1222 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1223 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1224 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1225 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1226 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1227 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1228 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1229 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1230 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1231 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1232 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1233 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1234 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1235 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1236 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1237 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1238 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1239 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1240 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1241 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1242 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1243 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1244 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1245 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1246 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1247 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1249 flags = BindingFlags.Static | BindingFlags.Public |
1250 BindingFlags.DeclaredOnly;
1252 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1253 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1254 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1255 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1256 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1257 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1258 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1259 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1260 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1261 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1262 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1263 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1264 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1265 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1266 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1267 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1268 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1269 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1270 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1271 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1272 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1273 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1274 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1275 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1276 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1277 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1278 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1279 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1280 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1281 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1283 flags = BindingFlags.Static | BindingFlags.NonPublic |
1284 BindingFlags.DeclaredOnly;
1286 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1287 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1288 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1289 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1290 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1291 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1292 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1293 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1294 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1295 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1296 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1297 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1298 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1299 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1300 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1301 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1302 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1303 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1304 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1305 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1306 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1307 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1308 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1309 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1310 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1311 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1312 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1313 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1314 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1315 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1317 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1318 BindingFlags.Public;
1320 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1321 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1322 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1323 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1324 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1325 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1326 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1327 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1328 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1329 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1330 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1331 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1332 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1333 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1334 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1335 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1336 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1337 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1338 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1339 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1340 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1341 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1342 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1343 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1344 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1345 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1346 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1347 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1348 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1349 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1351 flags = BindingFlags.Static | BindingFlags.NonPublic |
1352 BindingFlags.Public;
1354 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1355 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1356 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1357 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1358 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1359 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1360 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1361 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1362 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1363 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1364 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1365 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1366 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1367 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1368 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1369 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1370 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1371 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1372 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1373 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1374 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1375 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1376 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1377 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1378 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1379 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1380 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1381 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1382 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1383 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1386 [Test] // GetProperty (String, BindingFlags)
1387 public void GetProperty2_Name_Null ()
1389 Type type = typeof (Bar);
1391 type.GetProperty ((string) null);
1393 } catch (ArgumentNullException ex) {
1394 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1395 Assert.IsNull (ex.InnerException, "#3");
1396 Assert.IsNotNull (ex.Message, "#4");
1397 Assert.IsNotNull (ex.ParamName, "#5");
1398 Assert.AreEqual ("name", ex.ParamName, "#6");
1402 [Test] // GetProperty (String, Type)
1403 public void GetProperty3_Name_Null ()
1405 Type type = typeof (Bar);
1407 type.GetProperty ((string) null, typeof (int));
1409 } catch (ArgumentNullException ex) {
1410 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1411 Assert.IsNull (ex.InnerException, "#3");
1412 Assert.IsNotNull (ex.Message, "#4");
1413 Assert.IsNotNull (ex.ParamName, "#5");
1414 Assert.AreEqual ("name", ex.ParamName, "#6");
1418 [Test] // GetProperty (String, Type [])
1419 public void GetProperty4_Name_Null ()
1421 Type type = typeof (Bar);
1423 type.GetProperty ((string) null, Type.EmptyTypes);
1425 } catch (ArgumentNullException ex) {
1426 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1427 Assert.IsNull (ex.InnerException, "#3");
1428 Assert.IsNotNull (ex.Message, "#4");
1429 Assert.IsNotNull (ex.ParamName, "#5");
1430 Assert.AreEqual ("name", ex.ParamName, "#6");
1434 [Test] // GetProperty (String, Type, Type [])
1435 public void GetProperty5_Name_Null ()
1437 Type type = typeof (Bar);
1439 type.GetProperty ((string) null, typeof (int),
1442 } catch (ArgumentNullException ex) {
1443 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1444 Assert.IsNull (ex.InnerException, "#3");
1445 Assert.IsNotNull (ex.Message, "#4");
1446 Assert.IsNotNull (ex.ParamName, "#5");
1447 Assert.AreEqual ("name", ex.ParamName, "#6");
1451 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1452 public void GetProperty6_Name_Null ()
1454 Type type = typeof (Bar);
1456 type.GetProperty ((string) null, typeof (int),
1457 Type.EmptyTypes, null);
1459 } catch (ArgumentNullException ex) {
1460 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1461 Assert.IsNull (ex.InnerException, "#3");
1462 Assert.IsNotNull (ex.Message, "#4");
1463 Assert.IsNotNull (ex.ParamName, "#5");
1464 Assert.AreEqual ("name", ex.ParamName, "#6");
1468 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1469 public void GetProperty7_Name_Null ()
1471 Type type = typeof (Bar);
1473 type.GetProperty ((string) null, BindingFlags.Public,
1474 null, typeof (int), Type.EmptyTypes, null);
1476 } catch (ArgumentNullException ex) {
1477 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1478 Assert.IsNull (ex.InnerException, "#3");
1479 Assert.IsNotNull (ex.Message, "#4");
1480 Assert.IsNotNull (ex.ParamName, "#5");
1481 Assert.AreEqual ("name", ex.ParamName, "#6");
1486 public void GetProperty8_PropertyType ()
1488 Type type = typeof (Bar);
1489 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1490 null, typeof (int), Type.EmptyTypes, null), "#1");
1491 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1492 typeof (long), new Type[0], null), "#2");
1495 #if !TARGET_JVM // StructLayout not supported for TARGET_JVM
1496 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1501 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1507 public void StructLayoutAttribute ()
1509 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1510 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1512 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1513 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1514 Assert.AreEqual (4, attr2.Pack);
1515 Assert.AreEqual (64, attr2.Size);
1517 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1518 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1519 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1521 #endif // TARGET_JVM
1524 public void Namespace ()
1526 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1530 public void GenericParameterNamespace ()
1532 var t = typeof (Foo<>).GetGenericArguments () [0];
1534 Assert.AreEqual ("T", t.Name);
1535 Assert.AreEqual ("MonoTests.System", t.Namespace);
1537 var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
1539 Assert.AreEqual ("S", s.Name);
1540 Assert.AreEqual ("MonoTests.System", s.Namespace);
1543 public static void Reflected (ref int a)
1550 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1551 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1555 public void GetInterfaces ()
1557 Type[] t = typeof (Duper).GetInterfaces ();
1558 Assert.AreEqual (1, t.Length);
1559 Assert.AreEqual (typeof (ICloneable), t[0]);
1561 Type[] t2 = typeof (IFace3).GetInterfaces ();
1562 Assert.AreEqual (2, t2.Length);
1566 public void GetInterfacesGenericVarWithConstraints ()
1568 var a = typeof (TypeTest).GetMethod ("GenericMethod");
1570 var p = a.GetParameters ();
1571 var i = p[0].ParameterType.GetElementType ();
1575 public static void GenericMethod<T> (T[] arr) where T: IComparable<T> {
1581 public void GetFieldIgnoreCase ()
1583 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1596 public void GetPropertyAccessorModifiers ()
1598 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1599 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1603 public void IsAbstract ()
1605 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1606 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1607 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1608 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1609 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1610 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1613 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1614 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1615 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1619 public void IsCOMObject ()
1621 Type type = typeof (string);
1622 Assert.IsFalse (type.IsCOMObject, "#1");
1624 TypeBuilder tb = module.DefineType (genTypeName ());
1625 type = tb.CreateType ();
1626 Assert.IsFalse (type.IsCOMObject, "#2");
1630 public void IsImport ()
1632 Type type = typeof (string);
1633 Assert.IsFalse (type.IsImport, "#1");
1635 TypeBuilder tb = module.DefineType (genTypeName ());
1636 type = tb.CreateType ();
1637 Assert.IsFalse (type.IsImport, "#2");
1639 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1640 TypeAttributes.Interface | TypeAttributes.Abstract);
1641 type = tb.CreateType ();
1642 Assert.IsTrue (type.IsImport, "#3");
1646 public void IsInterface ()
1648 Assert.IsFalse (typeof (string).IsInterface, "#1");
1649 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1653 public void IsPrimitive () {
1654 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1655 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1656 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1660 public void IsValueType ()
1662 Assert.IsTrue (typeof (int).IsValueType, "#1");
1663 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1664 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1665 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1666 Assert.IsFalse (typeof (string).IsValueType, "#5");
1667 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1671 [Category("NotDotNet")]
1672 // Depends on the GAC working, which it doesn't durring make distcheck.
1673 [Category ("NotWorking")]
1674 public void GetTypeWithWhitespace ()
1676 Assert.IsNotNull (Type.GetType
1677 (@"System.Configuration.NameValueSectionHandler,
1682 PublicKeyToken=b77a5c561934e089"));
1686 public void GetTypeNonVectorArray ()
1688 Type t = Type.GetType ("System.String[*]");
1689 Assert.AreEqual ("System.String[*]", t.ToString ());
1693 public void ExerciseFilterName ()
1695 MemberInfo[] mi = typeof(Base).FindMembers(
1697 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1698 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1699 Type.FilterName, "*");
1700 Assert.AreEqual (4, mi.Length);
1701 mi = typeof(Base).FindMembers(
1703 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1704 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1705 Type.FilterName, "Test*");
1706 Assert.AreEqual (2, mi.Length);
1707 mi = typeof(Base).FindMembers(
1709 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1710 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1711 Type.FilterName, "TestVoid");
1712 Assert.AreEqual (1, mi.Length);
1713 mi = typeof(Base).FindMembers(
1715 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1716 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1717 Type.FilterName, "NonExistingMethod");
1718 Assert.AreEqual (0, mi.Length);
1722 public void ExerciseFilterNameIgnoreCase ()
1724 MemberInfo[] mi = typeof(Base).FindMembers(
1726 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1727 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1728 Type.FilterNameIgnoreCase, "*");
1729 Assert.AreEqual (4, mi.Length);
1730 mi = typeof(Base).FindMembers(
1732 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1733 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1734 Type.FilterNameIgnoreCase, "test*");
1735 Assert.AreEqual (2, mi.Length);
1736 mi = typeof(Base).FindMembers(
1738 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1739 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1740 Type.FilterNameIgnoreCase, "TESTVOID");
1741 Assert.AreEqual (1, mi.Length);
1742 mi = typeof(Base).FindMembers(
1744 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1745 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1746 Type.FilterNameIgnoreCase, "NonExistingMethod");
1747 Assert.AreEqual (0, mi.Length);
1751 public void GenericParameterMemberType ()
1753 var t = typeof (Foo<>).GetGenericArguments () [0];
1754 Assert.IsNotNull (t);
1756 Assert.AreEqual (MemberTypes.TypeInfo, t.MemberType);
1762 public int property {
1765 public ByRef0 (int i) {}
1766 public void f (int i) {}
1770 public void ByrefTypes ()
1772 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1773 Assert.IsNotNull (t);
1774 Assert.IsTrue (t.IsByRef);
1775 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1776 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1777 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1778 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1780 Assert.IsNull (t.GetMethod ("f"));
1781 Assert.IsNull (t.GetField ("field"));
1782 Assert.IsNull (t.GetProperty ("property"));
1786 public void TestAssemblyQualifiedName ()
1788 Type t = Type.GetType ("System.Byte[]&");
1789 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1791 t = Type.GetType ("System.Byte*&");
1792 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1794 t = Type.GetType ("System.Byte&");
1795 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1804 public void CreateValueTypeNoCtor ()
1806 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1810 [ExpectedException (typeof (MissingMethodException))]
1811 public void CreateValueTypeNoCtorArgs ()
1813 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1816 internal static string bug336841 (string param1, params string [] param2)
1818 StringBuilder sb = new StringBuilder ();
1822 for (int i = 0; i < param2.Length; i++) {
1825 sb.Append (param2 [i]);
1827 return sb.ToString ();
1830 internal static string bug336841 (string param1)
1832 return "#B:" + param1;
1835 internal static string bug336841 (params string [] param1)
1837 StringBuilder sb = new StringBuilder ();
1839 for (int i = 0; i < param1.Length; i++) {
1842 sb.Append (param1 [i]);
1844 return sb.ToString ();
1848 public void InvokeMember_GetSetField ()
1850 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1851 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1852 BindingFlags.SetField, null, null, new object [] { 5 });
1854 Assert.AreEqual (5, X.Value, "#A1");
1855 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
1856 BindingFlags.Public | BindingFlags.Static |
1857 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1858 null, null, new object [0]), "#A2");
1859 Assert.AreEqual (5, Y.Value, "#A3");
1860 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
1861 BindingFlags.Public | BindingFlags.Static |
1862 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1863 null, null, new object [0]), "#A4");
1866 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1867 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1868 BindingFlags.GetField | BindingFlags.SetField,
1869 null, null, new object [] { 5 });
1870 Assert.Fail ("#B1");
1871 } catch (ArgumentException ex) {
1872 // Cannot specify both Get and Set on a field
1873 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1874 Assert.IsNull (ex.InnerException, "#B3");
1875 Assert.IsNotNull (ex.Message, "#B4");
1876 Assert.IsNotNull (ex.ParamName, "#B5");
1877 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1882 public void InvokeMember_GetSetProperty ()
1885 typeof (ArrayList).InvokeMember ("Item",
1886 BindingFlags.GetProperty | BindingFlags.SetProperty |
1887 BindingFlags.Instance | BindingFlags.Public,
1888 null, new ArrayList (), new object [] { 0, "bar" });
1890 } catch (ArgumentException ex) {
1891 // Cannot specify both Get and Set on a property
1892 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1893 Assert.IsNull (ex.InnerException, "#3");
1894 Assert.IsNotNull (ex.Message, "#4");
1895 Assert.IsNotNull (ex.ParamName, "#5");
1896 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
1902 public void InvokeMember_InvokeMethod_Set ()
1905 typeof (ArrayList).InvokeMember ("ToString",
1906 BindingFlags.InvokeMethod | BindingFlags.SetField |
1907 BindingFlags.Instance | BindingFlags.Public,
1908 null, new ArrayList (), new object [0]);
1909 Assert.Fail ("#A1");
1910 } catch (ArgumentException ex) {
1911 // Cannot specify Set on a field and Invoke on a method
1912 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1913 Assert.IsNull (ex.InnerException, "#A3");
1914 Assert.IsNotNull (ex.Message, "#A4");
1915 Assert.IsNotNull (ex.ParamName, "#A5");
1916 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
1920 typeof (ArrayList).InvokeMember ("ToString",
1921 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
1922 BindingFlags.Instance | BindingFlags.Public,
1923 null, new ArrayList (), new object [0]);
1924 Assert.Fail ("#B1");
1925 } catch (ArgumentException ex) {
1926 // Cannot specify Set on a property and Invoke on a method
1927 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1928 Assert.IsNull (ex.InnerException, "#B3");
1929 Assert.IsNotNull (ex.Message, "#B4");
1930 Assert.IsNotNull (ex.ParamName, "#B5");
1931 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1936 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
1938 object [] invokeargs = { 1 };
1939 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
1940 BindingFlags.Public | BindingFlags.NonPublic |
1941 BindingFlags.Instance | BindingFlags.CreateInstance,
1942 null, null, invokeargs);
1946 public void InvokeMember_Name_Null ()
1949 typeof (X).InvokeMember ((string) null,
1950 BindingFlags.Public | BindingFlags.Static |
1951 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
1952 null, null, new object [] { 5 });
1954 } catch (ArgumentNullException ex) {
1955 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1956 Assert.IsNull (ex.InnerException, "#3");
1957 Assert.IsNotNull (ex.Message, "#4");
1958 Assert.IsNotNull (ex.ParamName, "#5");
1959 Assert.AreEqual ("name", ex.ParamName, "#6");
1964 public void InvokeMember_NoOperation ()
1967 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
1968 BindingFlags.Static, null, null, new object [0]);
1970 } catch (ArgumentException ex) {
1971 // Must specify binding flags describing the
1972 // invoke operation required
1973 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1974 Assert.IsNull (ex.InnerException, "#3");
1975 Assert.IsNotNull (ex.Message, "#4");
1976 Assert.IsNotNull (ex.ParamName, "#5");
1977 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
1981 [Test] // bug #321735
1982 public void InvokeMember_SetFieldProperty ()
1984 ArrayList list = new ArrayList ();
1986 list.GetType ().InvokeMember ("Item",
1987 BindingFlags.SetField | BindingFlags.SetProperty |
1988 BindingFlags.Instance | BindingFlags.Public,
1989 null, list, new object [] { 0, "bar" });
1990 Assert.AreEqual ("bar", list [0]);
1994 public void InvokeMember_SetField_ProvidedArgs ()
1997 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1998 BindingFlags.Static | BindingFlags.SetField,
1999 null, null, new object [0]);
2000 Assert.Fail ("#A1");
2001 } catch (ArgumentException ex) {
2002 // Only the field value can be specified to set
2004 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2005 Assert.IsNull (ex.InnerException, "#A3");
2006 Assert.IsNotNull (ex.Message, "#A4");
2007 Assert.IsNotNull (ex.ParamName, "#A5");
2008 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2012 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2013 BindingFlags.Static | BindingFlags.SetField,
2015 Assert.Fail ("#B1");
2016 } catch (ArgumentNullException ex) {
2017 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2018 Assert.IsNull (ex.InnerException, "#B3");
2019 Assert.IsNotNull (ex.Message, "#B4");
2020 Assert.IsNotNull (ex.ParamName, "#B5");
2021 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2025 [Test] // bug #336841
2026 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2027 public void InvokeMember_VarArgs ()
2029 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2030 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2031 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2032 BindingFlags.Instance;
2034 Type type = typeof (TypeTest);
2035 string result = (string) type.InvokeMember ("bug336841",
2036 flags, null, null, new object [] { "1" });
2037 Assert.IsNotNull (result, "#A1");
2038 Assert.AreEqual ("#B:1", result, "#A2");
2040 result = (string) type.InvokeMember ("bug336841", flags,
2041 null, null, new object [] { "1", "2", "3", "4" });
2042 Assert.IsNotNull (result, "#B1");
2043 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2047 [Test] // bug #348522
2048 public void InvokeMember_WithoutDefaultValue ()
2050 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
2052 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2053 new object [] {Missing.Value}, null, null, null);
2055 } catch (ArgumentException ex) {
2056 // Missing parameter does not have a default value
2057 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2058 Assert.IsNull (ex.InnerException, "#3");
2059 Assert.IsNotNull (ex.Message, "#4");
2060 Assert.IsNotNull (ex.ParamName, "#5");
2061 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2066 public void TestMissing () {
2067 Assert.AreEqual (Type.Missing, Missing.Value);
2071 public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
2072 var l = typeof (List<>);
2073 var m = l.GetMethod ("ConvertAll");
2074 var infl = m.MakeGenericMethod (typeof (int));
2075 var res = m.GetGenericMethodDefinition ();
2076 Assert.AreEqual (m, res, "#1");
2080 public void InvokeMember_OutParam ()
2082 object[] args = new object[] { new string [0] };
2083 typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
2084 Assert.IsTrue (args [0] is string[]);
2085 Assert.AreEqual (10, ((string[])args[0]).Length);
2088 public static void OutTest (out string[] a1)
2090 a1 = new string [10];
2095 public static int Value;
2104 public Z (IComparable value)
2109 public static void Run ()
2117 public TakesInt (int x)
2122 public int Integer {
2129 public TakesObject (object x) {}
2132 [Test] // bug #75241
2133 public void GetConstructorNullInTypes ()
2135 // This ends up calling type.GetConstructor ()
2136 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2137 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2141 public void GetConstructor_TakeInt_Object ()
2143 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2147 public void GetCustomAttributes_All ()
2149 object [] attrs = typeof (A).GetCustomAttributes (false);
2150 Assert.AreEqual (2, attrs.Length, "#A1");
2151 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2152 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2154 attrs = typeof (BA).GetCustomAttributes (false);
2155 Assert.AreEqual (1, attrs.Length, "#B1");
2156 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2158 attrs = typeof (BA).GetCustomAttributes (true);
2159 Assert.AreEqual (2, attrs.Length, "#C1");
2160 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2161 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2163 attrs = typeof (CA).GetCustomAttributes (false);
2164 Assert.AreEqual (0, attrs.Length, "#D");
2166 attrs = typeof (CA).GetCustomAttributes (true);
2167 Assert.AreEqual (1, attrs.Length, "#E1");
2168 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2171 static bool HasAttribute (object [] attrs, Type attributeType)
2173 foreach (object attr in attrs)
2174 if (attr.GetType () == attributeType)
2180 public void GetCustomAttributes_Type ()
2182 object [] attrs = null;
2184 attrs = typeof (A).GetCustomAttributes (
2185 typeof (VolatileModifier), false);
2186 Assert.AreEqual (1, attrs.Length, "#A1");
2187 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2188 attrs = typeof (A).GetCustomAttributes (
2189 typeof (VolatileModifier), true);
2190 Assert.AreEqual (1, attrs.Length, "#A3");
2191 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2193 attrs = typeof (A).GetCustomAttributes (
2194 typeof (NemerleAttribute), false);
2195 Assert.AreEqual (1, attrs.Length, "#B1");
2196 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2197 attrs = typeof (A).GetCustomAttributes (
2198 typeof (NemerleAttribute), true);
2199 Assert.AreEqual (1, attrs.Length, "#B3");
2200 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2202 attrs = typeof (A).GetCustomAttributes (
2203 typeof (FooAttribute), false);
2204 Assert.AreEqual (1, attrs.Length, "#C1");
2205 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2206 attrs = typeof (A).GetCustomAttributes (
2207 typeof (FooAttribute), false);
2208 Assert.AreEqual (1, attrs.Length, "#C3");
2209 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2211 attrs = typeof (BA).GetCustomAttributes (
2212 typeof (VolatileModifier), false);
2213 Assert.AreEqual (0, attrs.Length, "#D1");
2214 attrs = typeof (BA).GetCustomAttributes (
2215 typeof (VolatileModifier), true);
2216 Assert.AreEqual (1, attrs.Length, "#D2");
2217 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2219 attrs = typeof (BA).GetCustomAttributes (
2220 typeof (NemerleAttribute), false);
2221 Assert.AreEqual (0, attrs.Length, "#E1");
2222 attrs = typeof (BA).GetCustomAttributes (
2223 typeof (NemerleAttribute), true);
2224 Assert.AreEqual (1, attrs.Length, "#E2");
2225 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2227 attrs = typeof (BA).GetCustomAttributes (
2228 typeof (FooAttribute), false);
2229 Assert.AreEqual (1, attrs.Length, "#F1");
2230 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2231 attrs = typeof (BA).GetCustomAttributes (
2232 typeof (FooAttribute), true);
2233 Assert.AreEqual (1, attrs.Length, "#F3");
2234 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2236 attrs = typeof (bug82431A1).GetCustomAttributes (
2237 typeof (InheritAttribute), false);
2238 Assert.AreEqual (1, attrs.Length, "#G1");
2239 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2240 attrs = typeof (bug82431A1).GetCustomAttributes (
2241 typeof (InheritAttribute), true);
2242 Assert.AreEqual (1, attrs.Length, "#G3");
2243 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2245 attrs = typeof (bug82431A1).GetCustomAttributes (
2246 typeof (NotInheritAttribute), false);
2247 Assert.AreEqual (1, attrs.Length, "#H1");
2248 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2249 attrs = typeof (bug82431A1).GetCustomAttributes (
2250 typeof (InheritAttribute), true);
2251 Assert.AreEqual (1, attrs.Length, "#H3");
2252 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2254 attrs = typeof (bug82431A2).GetCustomAttributes (
2255 typeof (InheritAttribute), false);
2256 Assert.AreEqual (0, attrs.Length, "#I1");
2257 attrs = typeof (bug82431A2).GetCustomAttributes (
2258 typeof (InheritAttribute), true);
2259 Assert.AreEqual (0, attrs.Length, "#I2");
2261 attrs = typeof (bug82431A2).GetCustomAttributes (
2262 typeof (NotInheritAttribute), false);
2263 Assert.AreEqual (0, attrs.Length, "#J1");
2264 attrs = typeof (bug82431A2).GetCustomAttributes (
2265 typeof (NotInheritAttribute), true);
2266 Assert.AreEqual (0, attrs.Length, "#J2");
2268 attrs = typeof (bug82431A3).GetCustomAttributes (
2269 typeof (InheritAttribute), false);
2270 Assert.AreEqual (2, attrs.Length, "#K1");
2271 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2272 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2273 attrs = typeof (bug82431A3).GetCustomAttributes (
2274 typeof (InheritAttribute), true);
2275 Assert.AreEqual (2, attrs.Length, "#K4");
2276 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2277 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2279 attrs = typeof (bug82431A3).GetCustomAttributes (
2280 typeof (NotInheritAttribute), false);
2281 Assert.AreEqual (1, attrs.Length, "#L1");
2282 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2283 attrs = typeof (bug82431A3).GetCustomAttributes (
2284 typeof (NotInheritAttribute), true);
2285 Assert.AreEqual (1, attrs.Length, "#L3");
2286 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2288 attrs = typeof (bug82431B1).GetCustomAttributes (
2289 typeof (InheritAttribute), false);
2290 Assert.AreEqual (1, attrs.Length, "#M1");
2291 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2292 attrs = typeof (bug82431B1).GetCustomAttributes (
2293 typeof (InheritAttribute), true);
2294 Assert.AreEqual (1, attrs.Length, "#M3");
2295 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2297 attrs = typeof (bug82431B1).GetCustomAttributes (
2298 typeof (NotInheritAttribute), false);
2299 Assert.AreEqual (0, attrs.Length, "#N1");
2300 attrs = typeof (bug82431B1).GetCustomAttributes (
2301 typeof (NotInheritAttribute), true);
2302 Assert.AreEqual (0, attrs.Length, "#N2");
2304 attrs = typeof (bug82431B2).GetCustomAttributes (
2305 typeof (InheritAttribute), false);
2306 Assert.AreEqual (0, attrs.Length, "#O1");
2307 attrs = typeof (bug82431B2).GetCustomAttributes (
2308 typeof (InheritAttribute), true);
2309 Assert.AreEqual (1, attrs.Length, "#O2");
2310 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2312 attrs = typeof (bug82431B2).GetCustomAttributes (
2313 typeof (NotInheritAttribute), false);
2314 Assert.AreEqual (0, attrs.Length, "#P1");
2315 attrs = typeof (bug82431B2).GetCustomAttributes (
2316 typeof (NotInheritAttribute), true);
2317 Assert.AreEqual (0, attrs.Length, "#P2");
2319 attrs = typeof (bug82431B3).GetCustomAttributes (
2320 typeof (InheritAttribute), false);
2321 Assert.AreEqual (1, attrs.Length, "#Q1");
2322 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2323 attrs = typeof (bug82431B3).GetCustomAttributes (
2324 typeof (InheritAttribute), true);
2325 Assert.AreEqual (2, attrs.Length, "#Q3");
2326 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2327 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2329 attrs = typeof (bug82431B3).GetCustomAttributes (
2330 typeof (NotInheritAttribute), false);
2331 Assert.AreEqual (1, attrs.Length, "#R1");
2332 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2333 attrs = typeof (bug82431B3).GetCustomAttributes (
2334 typeof (NotInheritAttribute), true);
2335 Assert.AreEqual (1, attrs.Length, "#R3");
2336 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2338 attrs = typeof (bug82431B4).GetCustomAttributes (
2339 typeof (InheritAttribute), false);
2340 Assert.AreEqual (0, attrs.Length, "#S1");
2341 attrs = typeof (bug82431B4).GetCustomAttributes (
2342 typeof (InheritAttribute), true);
2343 Assert.AreEqual (1, attrs.Length, "#S2");
2344 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2346 attrs = typeof (bug82431B4).GetCustomAttributes (
2347 typeof (NotInheritAttribute), false);
2348 Assert.AreEqual (0, attrs.Length, "#T1");
2349 attrs = typeof (bug82431B4).GetCustomAttributes (
2350 typeof (NotInheritAttribute), true);
2351 Assert.AreEqual (0, attrs.Length, "#T2");
2353 attrs = typeof (A).GetCustomAttributes (
2354 typeof (string), false);
2355 Assert.AreEqual (0, attrs.Length, "#U1");
2356 attrs = typeof (A).GetCustomAttributes (
2357 typeof (string), true);
2358 Assert.AreEqual (0, attrs.Length, "#U2");
2361 [Test] // bug #76150
2362 public void IsDefined ()
2364 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2365 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2366 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2367 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2369 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2370 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2371 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2372 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2373 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2374 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2375 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2376 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2377 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2378 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2379 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2380 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2384 public void IsDefined_AttributeType_Null ()
2387 typeof (BA).IsDefined ((Type) null, false);
2389 } catch (ArgumentNullException ex) {
2390 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2391 Assert.IsNull (ex.InnerException, "#3");
2392 Assert.IsNotNull (ex.Message, "#4");
2393 Assert.IsNotNull (ex.ParamName, "#5");
2394 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2398 [Test] // bug #82431
2399 [Category ("NotWorking")]
2400 public void IsDefined_Inherited ()
2402 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2403 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2404 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2405 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2406 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2407 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2408 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2409 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2411 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2412 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2413 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2414 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2415 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2416 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2417 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2418 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2420 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2421 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2422 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2423 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2425 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2426 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2427 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2428 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2430 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2431 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2432 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2433 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2435 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2436 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2437 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2438 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2440 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2441 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2442 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2443 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2445 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2446 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2447 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2448 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2450 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2451 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2452 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2453 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2456 [Test] // GetType (String)
2457 public void GetType1_TypeName_Null ()
2460 Type.GetType ((string) null);
2462 } catch (ArgumentNullException ex) {
2463 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2464 Assert.IsNull (ex.InnerException, "#3");
2465 Assert.IsNotNull (ex.Message, "#4");
2466 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2470 [Test] // GetType (String, Boolean)
2471 public void GetType2_TypeName_Null ()
2474 Type.GetType ((string) null, false);
2476 } catch (ArgumentNullException ex) {
2477 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2478 Assert.IsNull (ex.InnerException, "#3");
2479 Assert.IsNotNull (ex.Message, "#4");
2480 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2484 [Test] // GetType (String, Boolean, Boolean)
2485 public void GetType3_TypeName_Null ()
2488 Type.GetType ((string) null, false, false);
2490 } catch (ArgumentNullException ex) {
2491 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2492 Assert.IsNull (ex.InnerException, "#3");
2493 Assert.IsNotNull (ex.Message, "#4");
2494 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2499 public void GetTypeArray_Args_Null ()
2502 Type.GetTypeArray ((object []) null);
2504 } catch (ArgumentNullException ex) {
2505 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2506 Assert.IsNull (ex.InnerException, "#3");
2507 Assert.IsNotNull (ex.Message, "#4");
2508 Assert.AreEqual ("args", ex.ParamName, "#5");
2513 public void GetTypeCode ()
2515 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2516 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2517 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2518 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2519 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2520 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2521 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2522 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2523 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2524 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2525 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2526 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2527 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2528 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2529 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2530 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2531 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2532 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2536 public void GetTypeFromHandle_Handle_Zero ()
2538 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2540 Assert.IsNull (Type.GetTypeFromHandle (handle));
2544 public void GetTypeHandle_O_Null ()
2547 Type.GetTypeHandle (null);
2549 } catch (ArgumentNullException ex) {
2550 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2551 Assert.IsNull (ex.InnerException, "#3");
2552 Assert.IsNotNull (ex.Message, "#4");
2553 Assert.IsNull (ex.ParamName, "#5");
2557 [Test] // GetConstructor (Type [])
2558 public void GetConstructor1 ()
2561 ConstructorInfo ctor;
2563 type = typeof (CtorsA);
2564 ctor = type.GetConstructor (Type.EmptyTypes);
2565 Assert.IsNotNull (ctor, "#A1");
2566 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2567 Assert.IsFalse (ctor.IsStatic, "#A3");
2568 Assert.IsTrue (ctor.IsPublic, "#A4");
2569 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2571 type = typeof (CtorsB);
2572 ctor = type.GetConstructor (Type.EmptyTypes);
2573 Assert.IsNotNull (ctor, "#B1");
2574 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2575 Assert.IsFalse (ctor.IsStatic, "#B3");
2576 Assert.IsTrue (ctor.IsPublic, "#B4");
2577 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2579 type = typeof (CtorsC);
2580 ctor = type.GetConstructor (Type.EmptyTypes);
2581 Assert.IsNull (ctor, "#C");
2583 type = typeof (CtorsC);
2584 ctor = type.GetConstructor (new Type [] { typeof (int) });
2585 Assert.IsNotNull (ctor, "#D1");
2586 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2587 Assert.IsFalse (ctor.IsStatic, "#D3");
2588 Assert.IsTrue (ctor.IsPublic, "#D4");
2589 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2592 [Test] // GetConstructor (Type [])
2593 public void GetConstructor1_Types_Null ()
2596 typeof (BindingFlags).GetConstructor (null);
2598 } catch (ArgumentNullException ex) {
2599 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2600 Assert.IsNull (ex.InnerException, "#3");
2601 Assert.IsNotNull (ex.Message, "#4");
2602 Assert.IsNotNull (ex.ParamName, "#5");
2603 Assert.AreEqual ("types", ex.ParamName, "#6");
2607 [Test] // GetConstructor (Type [])
2608 public void GetConstructor1_Types_ItemNull ()
2610 Type type = typeof (BindingFlags);
2612 type.GetConstructor (new Type[1] { null });
2613 Assert.Fail ("#A1");
2614 } catch (ArgumentNullException ex) {
2615 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2616 Assert.IsNull (ex.InnerException, "#A3");
2617 Assert.IsNotNull (ex.Message, "#A4");
2618 Assert.IsNotNull (ex.ParamName, "#A5");
2619 Assert.AreEqual ("types", ex.ParamName, "#A6");
2622 type = typeof (TakesInt);
2624 type.GetConstructor (new Type [1] { null });
2625 Assert.Fail ("#B1");
2626 } catch (ArgumentNullException ex) {
2627 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2628 Assert.IsNull (ex.InnerException, "#B3");
2629 Assert.IsNotNull (ex.Message, "#B4");
2630 Assert.IsNotNull (ex.ParamName, "#B5");
2631 Assert.AreEqual ("types", ex.ParamName, "#B6");
2635 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2636 public void GetConstructor2_Types_ItemNull ()
2638 Type type = typeof (BindingFlags);
2640 type.GetConstructor (BindingFlags.Default, null,
2641 new Type[1] { null }, null);
2643 } catch (ArgumentNullException ex) {
2644 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2645 Assert.IsNull (ex.InnerException, "#3");
2646 Assert.IsNotNull (ex.Message, "#4");
2647 Assert.IsNotNull (ex.ParamName, "#5");
2648 Assert.AreEqual ("types", ex.ParamName, "#6");
2652 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2653 public void GetConstructor3_Types_ItemNull ()
2655 Type type = typeof (BindingFlags);
2657 type.GetConstructor (BindingFlags.Default,
2658 null, CallingConventions.Any,
2659 new Type[1] { null }, 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.IsNotNull (ex.ParamName, "#5");
2666 Assert.AreEqual ("types", ex.ParamName, "#6");
2671 public void GetMethod_Bug77367 ()
2673 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2677 #if !TARGET_JVM // Reflection.Emit is not supported for TARGET_JVM
2679 public void EqualsUnderlyingType ()
2681 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2682 TypeAttributes attribs = TypeAttributes.Public;
2684 AssemblyName name = new AssemblyName ();
2685 name.Name = "enumtest";
2686 AssemblyBuilder assembly =
2687 AppDomain.CurrentDomain.DefineDynamicAssembly (
2690 ModuleBuilder module = assembly.DefineDynamicModule
2691 ("m", "enumtest.dll");
2692 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2694 Assert.IsTrue (typeof (int).Equals (e));
2696 #endif // TARGET_JVM
2699 public void Equals_Type_Null ()
2701 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2702 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2706 public void GetElementType_Bug63841 ()
2708 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2712 public void FullNameGenerics ()
2714 Type fooType = typeof (Foo<>);
2715 FieldInfo [] fields = fooType.GetFields ();
2717 Assert.AreEqual (1, fields.Length, "#0");
2719 Assert.IsNotNull (fooType.FullName, "#1");
2720 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2722 FieldInfo field = fooType.GetField ("Whatever");
2723 Assert.IsNotNull (field, "#2");
2724 Assert.AreEqual (field, fields [0], "#2a");
2725 Assert.IsNull (field.FieldType.FullName, "#3");
2726 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2727 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2729 PropertyInfo prop = fooType.GetProperty ("Test");
2730 Assert.IsNotNull (prop, "#5");
2731 Assert.IsNull (prop.PropertyType.FullName, "#6");
2732 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2733 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2735 MethodInfo method = fooType.GetMethod("Execute");
2736 Assert.IsNotNull (method, "#8");
2737 Assert.IsNull (method.ReturnType.FullName, "#9");
2738 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2739 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2741 ParameterInfo[] parameters = method.GetParameters();
2742 Assert.AreEqual (1, parameters.Length, "#11");
2743 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2744 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2745 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2749 public void TypeParameterIsNotGeneric ()
2751 Type fooType = typeof (Foo<>);
2752 Type type_param = fooType.GetGenericArguments () [0];
2753 Assert.IsTrue (type_param.IsGenericParameter);
2754 Assert.IsFalse (type_param.IsGenericType);
2755 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2757 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2758 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2759 Assert.IsTrue (type_param.ContainsGenericParameters);
2763 public void IsAssignable ()
2765 Type foo_type = typeof (Foo<>);
2766 Type foo_int_type = typeof (Foo<int>);
2767 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
2768 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
2770 Type ibar_short_type = typeof (IBar<short>);
2771 Type ibar_int_type = typeof (IBar<int>);
2772 Type baz_short_type = typeof (Baz<short>);
2773 Type baz_int_type = typeof (Baz<int>);
2775 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
2776 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
2778 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
2779 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
2782 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
2783 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
2784 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
2788 public void IsInstanceOf ()
2790 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
2794 public void IsInstanceOfArrayOfNullable ()
2796 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
2800 public void IsInstanceOfType_Null ()
2802 Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
2803 Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
2804 Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
2808 public void ByrefType ()
2810 Type foo_type = typeof (Foo<>);
2811 Type type_param = foo_type.GetGenericArguments () [0];
2812 Type byref_type_param = type_param.MakeByRefType ();
2813 Assert.IsFalse (byref_type_param.IsGenericParameter);
2814 Assert.IsNull (byref_type_param.DeclaringType);
2818 [ExpectedException (typeof (TypeLoadException))]
2819 public void MakeByRefByRef ()
2821 typeof (int).MakeByRefType ().MakeByRefType ();
2825 public void MakeArrayTypeTest ()
2827 // This should not crash:
2828 typeof (void).MakeArrayType ();
2833 public class ComFoo<T> {
2837 public void GetCustomAttributesGenericInstance ()
2839 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
2842 interface ByRef1<T> { void f (ref T t); }
2843 interface ByRef2 { void f<T> (ref T t); }
2845 interface ByRef3<T> where T:struct { void f (ref T? t); }
2846 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
2848 void CheckGenericByRef (Type t)
2850 string name = t.Name;
2851 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
2853 Assert.IsFalse (t.IsGenericType, name);
2854 Assert.IsFalse (t.IsGenericTypeDefinition, name);
2855 Assert.IsFalse (t.IsGenericParameter, name);
2859 public void GenericByRef ()
2861 CheckGenericByRef (typeof (ByRef1<>));
2862 CheckGenericByRef (typeof (ByRef2));
2863 CheckGenericByRef (typeof (ByRef3<>));
2864 CheckGenericByRef (typeof (ByRef4));
2867 public class Bug80242<T> {
2868 public interface IFoo { }
2869 public class Bar : IFoo { }
2870 public class Baz : Bar { }
2874 public void TestNestedTypes ()
2876 Type t = typeof (Bug80242<object>);
2877 Assert.IsFalse (t.IsGenericTypeDefinition);
2878 foreach (Type u in t.GetNestedTypes ()) {
2879 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
2880 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
2884 [Test] // bug #82211
2885 public void GetMembers_GenericArgument ()
2887 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
2888 MemberInfo [] members = argType.GetMembers ();
2889 Assert.IsNotNull (members, "#1");
2890 Assert.AreEqual (4, members.Length, "#2");
2894 [ExpectedException (typeof (ArgumentNullException))]
2895 public void ReflectionOnlyGetTypeNullTypeName ()
2897 Type.ReflectionOnlyGetType (null, false, false);
2901 public void ReflectionOnlyGetTypeDoNotThrow ()
2903 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
2907 [ExpectedException (typeof (FileNotFoundException))]
2908 public void ReflectionOnlyGetTypeThrow ()
2910 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
2914 public void ReflectionOnlyGetType ()
2916 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
2917 Assert.AreEqual ("System.Int32", t.FullName);
2920 [Test] //bug #331199
2921 public void MakeGenericType_UserDefinedType ()
2923 Type ut = new UserType (typeof (int));
2924 Type t = typeof (Foo<>).MakeGenericType (ut);
2925 Assert.IsTrue (t.IsGenericType, "#A1");
2926 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2928 Type arg = t.GetGenericArguments () [0];
2929 Assert.IsNotNull (arg, "#B1");
2930 Assert.IsFalse (arg.IsGenericType, "#B2");
2931 Assert.AreEqual (ut, arg, "#B3");
2934 [Category ("NotWorking")]
2935 //We dont support instantiating a user type
2936 public void MakeGenericType_NestedUserDefinedType ()
2938 Type ut = new UserType (new UserType (typeof (int)));
2939 Type t = typeof (Foo<>).MakeGenericType (ut);
2940 Assert.IsTrue (t.IsGenericType, "#A1");
2941 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2943 Type arg = t.GetGenericArguments () [0];
2944 Assert.IsNotNull (arg, "#B1");
2945 Assert.IsFalse (arg.IsGenericType, "#B2");
2946 Assert.AreEqual (ut, arg, "#B3");
2950 [Category ("NotWorking")]
2951 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
2953 Type ut = new UserType(typeof(int));
2954 Type t = typeof(Foo<>).MakeGenericType(ut);
2955 Assert.IsTrue (t.IsGenericType, "#1");
2957 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
2961 public void MakeGenericType_BadUserType ()
2963 Type ut = new UserType (null);
2965 Type t = typeof (Foo<>).MakeGenericType (ut);
2967 } catch (ArgumentException) {
2972 public void MakeGenericType_WrongNumOfArguments ()
2975 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
2977 } catch (ArgumentException) {
2981 [AttributeUsage (AttributeTargets.All)]
2982 public class DocAttribute : Attribute {
2983 public DocAttribute (string docs) {}
2986 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
2987 where T : class, new ()
2990 public T Bar { get{return null;}}
2992 public void M<[Doc ("X")] X> (X x)
2997 [Test] //bug #377596
2998 public void GetGenericArguments_ArgumentsHaveAttributes ()
3000 Type type = typeof(GenericClassWithAttributes<,>);
3001 Type[] tArgs = type.GetGenericArguments ();
3002 MethodInfo m = type.GetMethod ("M");
3003 Type[] mArgs = m.GetGenericArguments ();
3004 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3005 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3006 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3009 [Test] //bug #471255
3010 public void GetTypeCalledUsingReflection ()
3012 Type expectedType = Type.GetType ("NoNamespaceClass");
3013 Assert.IsNotNull (expectedType, "#1");
3014 MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
3015 object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3016 Assert.AreSame (expectedType, r, "#2");
3020 public void EqualsUserType () {
3021 UserType2 t1 = new UserType2(null);
3022 UserType2 t2 = new UserType2(t1);
3023 Assert.IsTrue (t1.Equals(t2));
3027 public void GetHashCodeUserType () {
3028 UserType2 t1 = new UserType2(null);
3029 UserType2 t2 = new UserType2(t1);
3030 Assert.AreEqual (42, t2.GetHashCode());
3034 public void IsGenericTypeDefinitionUserType () {
3035 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3039 public void IsGenericTypeUserType () {
3040 Assert.IsFalse (new UserType(null).IsGenericType);
3044 [ExpectedException (typeof (NotSupportedException))]
3045 public void GetGenericTypeDefinitionUserType () {
3046 new UserType(null).GetGenericTypeDefinition ();
3049 [ExpectedException (typeof (NotSupportedException))]
3050 public void GetGenericArgumentsUserType () {
3051 new UserType(null).GetGenericArguments ();
3055 [ExpectedException (typeof (InvalidOperationException))]
3056 public void GenericParameterPositionUserType () {
3057 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3061 public void TypeGetMemberReturnTypeTest ()
3064 MemberTypes memtype;
3066 object [] flagsandtypes = new object [] {
3067 MemberTypes.All, typeof (MemberInfo []),
3068 MemberTypes.Constructor, typeof (ConstructorInfo []),
3069 MemberTypes.Custom, typeof (MemberInfo []),
3070 MemberTypes.Event, typeof (EventInfo []),
3071 MemberTypes.Field, typeof (FieldInfo []),
3072 MemberTypes.Method, typeof (MethodInfo []),
3073 MemberTypes.NestedType, typeof (Type []),
3074 MemberTypes.Property, typeof (PropertyInfo []),
3075 MemberTypes.TypeInfo, typeof (Type [])};
3077 for (int i=0; i < flagsandtypes.Length; i+=2) {
3078 memtype = (MemberTypes)flagsandtypes [i];
3079 testtype = (Type)flagsandtypes [i+1];
3080 obj = GetType ().GetMember ("DummyMember", memtype,
3081 BindingFlags.Public | BindingFlags.Instance);
3082 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3083 "Expected " + testtype.FullName);
3089 public void TypeNameStartsWithSpace ()
3091 Type t1 = Type.GetType ("System.Type, mscorlib");
3092 Type t2 = Type.GetType (" System.Type, mscorlib");
3093 Assert.AreEqual (t1, t2);
3098 public void Bug506757 ()
3100 AssemblyName assemblyName = new AssemblyName ();
3101 assemblyName.Name = "customMod";
3102 assemblyName.Version = new Version (1, 2, 3, 4);
3104 AssemblyBuilder assembly
3105 = Thread.GetDomain().DefineDynamicAssembly(
3106 assemblyName, AssemblyBuilderAccess.RunAndSave);
3108 ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3110 TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3111 TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3112 TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3114 MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3115 MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3117 MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3118 MethodAttributes.FamORAssem;
3120 MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3121 MethodAttributes.Public;
3124 MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3125 m0.GetILGenerator ().Emit (OpCodes.Ret);
3127 MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3128 m1.GetILGenerator ().Emit (OpCodes.Ret);
3130 MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3131 m2.GetILGenerator ().Emit (OpCodes.Ret);
3134 type0.CreateType ();
3135 type1.CreateType ();
3136 Type t2 = type2.CreateType ();
3138 foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3139 Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3143 public void MakeArrayTypeOfOneDimension ()
3145 Type vector = typeof (int).MakeArrayType ();
3146 Type szarray = typeof (int).MakeArrayType (1);
3148 Assert.AreNotEqual (vector, szarray, "#1");
3149 Assert.AreEqual ("Int32[]", vector.Name, "#2");
3150 Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3153 public class DeclaringMethodFoo {
3154 public void Test<T> (T t) {}
3155 public void Test2<T> (ref T t) {}
3158 public class DeclaringMethodBar<T> {
3159 public void Test2 (ref T t) {}
3163 public void DeclaringMethodOnlyWorksWithGenericArgs ()
3165 MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3166 MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3168 Assert.AreEqual (testMethod, otherMethod,"#1");
3170 Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3173 var x = typeof (int).DeclaringMethod;
3175 } catch (InvalidOperationException) {}
3178 var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3180 } catch (InvalidOperationException) {}
3183 var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3185 } catch (InvalidOperationException) {}
3190 public void GetArrayRankThrowsForNonArrayType ()
3192 Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3193 Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3195 typeof (int).GetArrayRank ();
3197 } catch (ArgumentException) {}
3200 [Test] //Bug #564379
3201 public void GetMethodsReturnPublicMethodsInInterfaces ()
3203 Type t = typeof (NonClosingStream);
3204 MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3206 Assert.AreEqual (5, methods.Length, "#1");
3209 foreach (var m in methods) {
3210 if (m.Name.Equals ("ToString"))
3211 Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3212 else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3213 Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3214 else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3215 Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3217 Assert.Fail ("invalid method " + m);
3223 interface IGetInterfaceMap<in T>
3228 class GetInterfaceMap : IGetInterfaceMap<object>
3230 public string Bar (object t)
3232 return t.GetType ().FullName;
3237 public void GetInterfaceMapWorksWithVariantIfaces ()
3239 InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3240 Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3241 Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3243 res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3244 Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3245 Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3249 public class MyType : TypeDelegator {
3252 public override bool Equals (Type t) {
3254 return base.Equals (t);
3257 public override Type UnderlyingSystemType {
3260 return typeof (int);
3266 public void NewV4EqualsBehavior ()
3268 var ta = new MyType ();
3269 var tb = new MyType ();
3270 object a = ta, b = tb;
3273 Assert.AreEqual (1, ta.eq, "#1");
3274 Assert.AreEqual (2, ta.ust, "#2");
3276 Assert.AreEqual (2, ta.eq, "#3");
3277 Assert.AreEqual (3, ta.ust, "#4");
3278 Assert.AreEqual (0, tb.eq, "#5");
3279 Assert.AreEqual (1, tb.ust, "#6");
3282 public enum MyRealEnum : short {
3287 public enum MyRealEnum2 : byte {
3290 public class MyEnum : TypeDelegator {
3291 public bool is_enum { get; set; }
3292 public int fields { get; set; }
3294 public override bool IsSubclassOf (Type c) {
3295 return c == typeof (Enum) && is_enum;
3298 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3301 FieldInfo[] res = new FieldInfo [fields];
3302 for (int i = 0; i < fields; ++i) {
3303 if ((bindingAttr & BindingFlags.Instance) != 0)
3304 res [i] = typeof (MyRealEnum).GetField ("value__");
3306 res [i] = typeof (MyRealEnum).GetField ("A");
3313 public void GetEnumUnderlyingType () {
3316 new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3318 } catch (ArgumentException) {}
3321 new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3323 } catch (ArgumentException) {}
3326 new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3328 } catch (ArgumentException) {}
3330 Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3334 public void GetEnumNames () {
3336 new MyEnum () { is_enum = false }.GetEnumNames ();
3338 } catch (ArgumentException) {}
3340 var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3341 Assert.AreEqual (1, res.Length, "#2");
3342 Assert.AreEqual ("A", res [0], "#3");
3344 res = typeof (MyRealEnum).GetEnumNames ();
3345 Assert.AreEqual (3, res.Length, "#4");
3346 Assert.AreEqual ("A", res [0], "#5");
3347 Assert.AreEqual ("B", res [1], "#6");
3348 Assert.AreEqual ("C", res [2], "#7");
3352 public void GetEnumValues () {
3354 new MyEnum () { is_enum = false }.GetEnumValues ();
3356 } catch (ArgumentException) {}
3359 new MyEnum () { is_enum = true }.GetEnumValues ();
3361 } catch (NotImplementedException) {}
3363 var array = typeof (MyRealEnum).GetEnumValues ();
3364 Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3365 MyRealEnum[] res = (MyRealEnum[])array;
3367 Assert.AreEqual (3, res.Length, "#4");
3368 Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3369 Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3370 Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3374 public void GetEnumValue () {
3376 typeof (MyRealEnum).GetEnumName (null);
3378 } catch (ArgumentException) { }
3381 new MyEnum () { is_enum = false }.GetEnumName (99);
3383 } catch (ArgumentException) { }
3386 Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3387 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
3388 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
3389 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
3391 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
3392 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
3393 Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
3394 Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
3396 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
3397 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
3399 typeof (MyRealEnum).GetEnumName (false);
3400 Assert.Fail ("#13");
3401 } catch (ArgumentException) { }
3403 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
3404 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
3406 typeof (MyRealEnum).GetEnumName ('c');
3407 Assert.Fail ("#16");
3408 } catch (ArgumentException) { }
3410 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
3411 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
3413 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
3414 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
3417 typeof (MyRealEnum).GetEnumName ((float)0);
3418 Assert.Fail ("#21");
3419 } catch (ArgumentException) { }
3421 typeof (MyRealEnum).GetEnumName ((double)0);
3422 Assert.Fail ("#22");
3423 } catch (ArgumentException) { }
3426 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
3427 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
3429 typeof (MyRealEnum2).GetEnumName (false);
3430 Assert.Fail ("#22", "#25");
3431 } catch (ArgumentException) { }
3433 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
3434 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
3437 typeof (MyRealEnum2).GetEnumName ('c');
3438 Assert.Fail ("#28");
3439 } catch (ArgumentException) { }
3441 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
3442 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
3444 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
3445 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
3448 typeof (MyRealEnum2).GetEnumName ((float)0);
3449 Assert.Fail ("#33");
3450 } catch (ArgumentException) { }
3452 typeof (MyRealEnum2).GetEnumName ((double)0);
3453 Assert.Fail ("#34");
3454 } catch (ArgumentException) { }
3456 Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
3460 public abstract class Stream : IDisposable
3462 public void Dispose ()
3464 Console.WriteLine ("stream::dispose");
3467 protected virtual void Dispose (bool disposing)
3472 public class NonClosingStream
3473 : Stream, IDisposable
3475 void IDisposable.Dispose()
3477 Console.WriteLine ("ncs::dispose");
3480 public override string ToString () { return ""; }
3483 static bool ContainsProperty (PropertyInfo [] props, string name)
3485 foreach (PropertyInfo p in props)
3491 public class NemerleAttribute : Attribute
3495 public class VolatileModifier : NemerleAttribute
3505 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3506 public class FooAttribute : Attribute
3510 public class BarAttribute : FooAttribute
3527 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
3528 public class InheritAttribute : Attribute
3532 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3533 public class NotInheritAttribute : InheritAttribute
3537 [NotInheritAttribute]
3538 public class bug82431A1
3542 public class bug82431A2 : bug82431A1
3546 [NotInheritAttribute]
3548 public class bug82431A3 : bug82431A1
3553 public class bug82431B1
3557 public class bug82431B2 : bug82431B1
3561 [NotInheritAttribute]
3562 public class bug82431B3 : bug82431B2
3566 public class bug82431B4 : bug82431B3
3574 public class Bug77367
3576 public void Run (bool b)
3583 private string PrivInstBlue
3585 get { return null; }
3588 protected string ProtInstBlue
3590 get { return null; }
3593 protected internal string ProIntInstBlue
3595 get { return null; }
3598 public long PubInstBlue
3602 if (PrivInstBlue == null)
3604 return long.MaxValue;
3608 internal int IntInstBlue
3613 private static string PrivStatBlue
3615 get { return null; }
3618 protected static string ProtStatBlue
3620 get { return null; }
3623 protected static internal string ProIntStatBlue
3625 get { return null; }
3628 public static long PubStatBlue
3632 if (PrivStatBlue == null)
3634 return long.MaxValue;
3638 internal static int IntStatBlue
3644 public class Foo : Blue
3646 private string PrivInstBase
3648 get { return null; }
3651 protected string ProtInstBase
3653 get { return null; }
3656 protected internal string ProIntInstBase
3658 get { return null; }
3661 public long PubInstBase
3665 if (PrivInstBase == null)
3667 return long.MaxValue;
3671 internal int IntInstBase
3676 private static string PrivStatBase
3678 get { return null; }
3681 protected static string ProtStatBase
3683 get { return null; }
3686 protected static internal string ProIntStatBase
3688 get { return null; }
3691 public static long PubStatBase
3695 if (PrivStatBase == null)
3697 return long.MaxValue;
3701 internal static int IntStatBase
3707 public class Bar : Foo
3709 private string PrivInst
3711 get { return null; }
3714 protected string ProtInst
3716 get { return null; }
3719 protected internal string ProIntInst
3721 get { return null; }
3728 if (PrivInst == null)
3730 return long.MaxValue;
3734 internal int IntInst
3739 private static string PrivStat
3741 get { return null; }
3744 protected static string ProtStat
3746 get { return null; }
3749 protected static internal string ProIntStat
3751 get { return null; }
3754 public static long PubStat
3758 if (PrivStat == null)
3760 return long.MaxValue;
3764 internal static int IntStat
3790 public CtorsC (int x)
3796 class UserType : Type
3798 protected Type type;
3800 public UserType(Type type) {
3804 public override Type UnderlyingSystemType { get { return this.type; } }
3806 public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
3808 public override string AssemblyQualifiedName { get { return null; } }
3810 public override Type BaseType { get { return null; } }
3812 public override Module Module { get { return this.type.Module; } }
3814 public override string Namespace { get { return null; } }
3816 public override bool IsGenericParameter { get { return true; } }
3818 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
3820 public override bool ContainsGenericParameters { get { return true; } }
3822 public override string FullName { get { return this.type.Name; } }
3824 public override Guid GUID { get { throw new NotSupportedException(); } }
3827 protected override bool IsArrayImpl() {
3831 protected override bool IsByRefImpl()
3836 protected override bool IsCOMObjectImpl()
3841 protected override bool IsPointerImpl()
3846 protected override bool IsPrimitiveImpl()
3852 protected override TypeAttributes GetAttributeFlagsImpl()
3857 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
3858 CallingConventions callConvention, Type[] types,
3859 ParameterModifier[] modifiers)
3864 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
3869 public override Type GetElementType()
3874 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
3880 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
3886 public override Type GetInterface(string name, bool ignoreCase)
3891 public override Type[] GetInterfaces()
3896 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
3901 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
3906 public override object[] GetCustomAttributes(bool inherit)
3911 public override bool IsDefined(Type attributeType, bool inherit)
3916 public override string Name { get { return this.type.Name; } }
3918 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
3920 throw new NotImplementedException();
3923 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
3925 throw new NotImplementedException();
3928 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
3929 CallingConventions callConvention, Type[] types,
3930 ParameterModifier[] modifiers)
3935 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
3940 public override Type GetNestedType(string name, BindingFlags bindingAttr)
3945 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
3950 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
3955 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
3956 Type returnType, Type[] types, ParameterModifier[] modifiers)
3961 protected override bool HasElementTypeImpl()
3966 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
3967 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
3968 string[] namedParameters)
3970 throw new NotSupportedException();
3974 class UserType2 : UserType {
3975 public UserType2 (Type type) : base (type) {
3978 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
3980 public override int GetHashCode()
3984 return type.GetHashCode();