2010-03-11 Rodrigo Kumpera <rkumpera@novell.com>
[mono-project.git] / mcs / class / corlib / Test / System.Reflection.Emit / TypeBuilderTest.cs
blob8f75a5e34f1ba8b40a6d8fae822a53f4f9ea8a64
1 //
2 // TypeBuilderTest.cs - NUnit Test Cases for the TypeBuilder class
3 //
4 // Zoltan Varga (vargaz@freemail.hu)
5 //
6 // (C) Ximian, Inc. http://www.ximian.com
7 //
8 // TODO:
9 // - implement a mechnanism for easier testing of null argument exceptions
10 // - with overloaded methods like DefineNestedType (), check the defaults
11 // on the shorter versions.
12 // - ToString on enums with the flags attribute set should print all
13 // values which match, e.g. 0 == AutoLayou,AnsiClass,NotPublic
16 using System;
17 using System.Collections;
18 using System.Threading;
19 using System.Reflection;
20 using System.Reflection.Emit;
21 using System.IO;
22 using System.Security;
23 using System.Security.Permissions;
24 using System.Runtime.InteropServices;
25 using NUnit.Framework;
26 using System.Runtime.CompilerServices;
28 #if NET_2_0
29 using System.Collections.Generic;
30 #endif
32 namespace MonoTests.System.Reflection.Emit
34 public interface EmptyInterface
38 public interface OneMethodInterface
40 void foo ();
43 public class SimpleTestAttribute : Attribute
46 public class EmptyIfaceImpl : EmptyInterface
50 #if NET_2_0
51 public class Gen<T> {
52 public static T field = default(T);
54 #endif
56 [TestFixture]
57 public class TypeBuilderTest
59 private interface AnInterface
63 public interface Foo
67 public interface Bar : Foo
71 public interface Baz : Bar
75 public interface IMoveable
79 public interface IThrowable : IMoveable
83 public interface ILiquid
87 public interface IWater : ILiquid
91 public interface IAir
95 public interface IDestroyable
98 #if NET_2_0
100 public class Tuple <A,B> {
101 A a;
102 B b;
104 #endif
106 private AssemblyBuilder assembly;
108 private ModuleBuilder module;
110 static string ASSEMBLY_NAME = "MonoTests.System.Reflection.Emit.TypeBuilderTest";
112 [SetUp]
113 protected void SetUp ()
115 AssemblyName assemblyName = new AssemblyName ();
116 assemblyName.Name = ASSEMBLY_NAME;
118 assembly =
119 Thread.GetDomain ().DefineDynamicAssembly (
120 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
122 module = assembly.DefineDynamicModule ("module1");
125 static int typeIndexer = 0;
127 // Return a unique type name
128 private string genTypeName ()
130 return "t" + (typeIndexer++);
133 private string nullName ()
135 return String.Format ("{0}", (char) 0);
138 [Test]
139 public void TestAssembly ()
141 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
142 Assert.AreEqual (assembly, tb.Assembly);
145 [Test]
146 public void TestAssemblyQualifiedName ()
148 TypeBuilder tb = module.DefineType ("A.B.C.D", TypeAttributes.Public);
149 Assert.AreEqual ("A.B.C.D, " + assembly.GetName ().FullName,
150 tb.AssemblyQualifiedName);
153 [Test]
154 public void TestAttributes ()
156 TypeAttributes attrs = TypeAttributes.Public | TypeAttributes.BeforeFieldInit;
157 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
158 Assert.AreEqual (attrs, tb.Attributes);
161 [Test]
162 public void TestBaseTypeClass ()
164 TypeAttributes attrs = TypeAttributes.Public;
165 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
166 Assert.AreEqual (typeof (object), tb.BaseType, "#1");
168 TypeBuilder tb2 = module.DefineType (genTypeName (), attrs, tb);
169 Assert.AreEqual (tb, tb2.BaseType, "#2");
172 [Test] // bug #71301
173 public void TestBaseTypeInterface ()
175 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
176 Assert.IsNull (tb3.BaseType);
179 [Test]
180 public void TestDeclaringType ()
182 TypeAttributes attrs = 0;
183 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
184 Assert.IsNull (tb.DeclaringType, "#1");
186 attrs = TypeAttributes.NestedPublic;
187 TypeBuilder tb2 = tb.DefineNestedType (genTypeName (), attrs);
188 TypeBuilder tb3 = tb2.DefineNestedType (genTypeName (), attrs);
189 Assert.AreEqual (tb3.DeclaringType.DeclaringType, tb, "#2");
192 [Test]
193 public void TestFullName ()
195 string name = genTypeName ();
196 TypeAttributes attrs = 0;
197 TypeBuilder tb = module.DefineType (name, attrs);
198 Assert.AreEqual (name, tb.FullName, "#1");
200 string name2 = genTypeName ();
201 attrs = TypeAttributes.NestedPublic;
202 TypeBuilder tb2 = tb.DefineNestedType (name2, attrs);
204 string name3 = genTypeName ();
205 attrs = TypeAttributes.NestedPublic;
206 TypeBuilder tb3 = tb2.DefineNestedType (name3, attrs);
208 Assert.AreEqual (name + "+" + name2 + "+" + name3, tb3.FullName, "#2");
211 [Test]
212 public void DefineCtorUsingDefineMethod ()
214 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Class);
215 MethodBuilder mb = tb.DefineMethod(
216 ".ctor", MethodAttributes.Public | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName,
217 null, null);
218 ILGenerator ilgen = mb.GetILGenerator();
219 ilgen.Emit(OpCodes.Ldarg_0);
220 ilgen.Emit(OpCodes.Call,
221 typeof(object).GetConstructor(Type.EmptyTypes));
222 ilgen.Emit(OpCodes.Ret);
223 Type t = tb.CreateType();
225 Assert.AreEqual (1, t.GetConstructors ().Length);
228 [Test]
229 public void TestGUIDIncomplete ()
231 TypeBuilder tb = module.DefineType (genTypeName ());
232 try {
233 Guid g = tb.GUID;
234 Assert.Fail ("#1");
235 } catch (NotSupportedException ex) {
236 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
237 Assert.IsNull (ex.InnerException, "#3");
238 Assert.IsNotNull (ex.Message, "#4");
242 [Test] // bug #71302
243 [Category ("NotWorking")]
244 public void TestGUIDComplete ()
246 TypeBuilder tb = module.DefineType (genTypeName ());
247 tb.CreateType ();
248 Assert.IsTrue (tb.GUID != Guid.Empty);
251 [Test]
252 [Category ("NotWorking")]
253 public void TestFixedGUIDComplete ()
255 TypeBuilder tb = module.DefineType (genTypeName ());
257 Guid guid = Guid.NewGuid ();
259 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
260 new Type [] { typeof (string) });
262 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
263 new object [] { guid.ToString ("D") }, new FieldInfo [0], new object [0]);
265 tb.SetCustomAttribute (caBuilder);
266 tb.CreateType ();
267 Assert.AreEqual (guid, tb.GUID);
270 [Test]
271 public void TestHasElementType_Incomplete ()
273 // According to the MSDN docs, this member works, but in reality, it
274 // returns a NotSupportedException
275 TypeBuilder tb = module.DefineType (genTypeName ());
276 #if NET_2_0
277 Assert.IsFalse (tb.HasElementType);
278 #else
279 try {
280 bool b = tb.HasElementType;
281 Assert.Fail ("#1: " + b);
282 } catch (NotSupportedException ex) {
283 // The invoked member is not supported in a
284 // dynamic module
285 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
286 Assert.IsNull (ex.InnerException, "#3");
287 Assert.IsNotNull (ex.Message, "#4");
289 #endif
292 [Test]
293 #if ONLY_1_1
294 [Category ("NotWorking")]
295 #endif
296 public void TestHasElementType_Complete ()
298 // According to the MSDN docs, this member works, but in reality, it
299 // returns a NotSupportedException
300 TypeBuilder tb = module.DefineType (genTypeName ());
301 tb.CreateType ();
302 #if NET_2_0
303 Assert.IsFalse (tb.HasElementType);
304 #else
305 try {
306 bool b = tb.HasElementType;
307 Assert.Fail ("#1: " + b);
308 } catch (NotSupportedException ex) {
309 // The invoked member is not supported in a
310 // dynamic module
311 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
312 Assert.IsNull (ex.InnerException, "#3");
313 Assert.IsNotNull (ex.Message, "#4");
315 #endif
318 [Test] // bug #324692
319 public void CreateType_Enum_NoInstanceField ()
321 TypeBuilder tb = module.DefineType (genTypeName (),
322 TypeAttributes.Sealed | TypeAttributes.Serializable,
323 typeof (Enum));
325 try {
326 tb.CreateType ();
327 Assert.Fail ("#1: must throw TypeLoadException");
328 } catch (TypeLoadException) {
331 #if NET_2_0
332 //Assert.IsTrue (tb.IsCreated (), "#2");
333 #endif
336 [Test] // bug #324692
337 #if ONLY_1_1
338 [Category ("NotWorking")] // we do not throw IOE when repeatedly invoking CreateType
339 #endif
340 public void TestCreateTypeReturnsNullOnSecondCallForBadType ()
342 TypeBuilder tb = module.DefineType (genTypeName (),
343 TypeAttributes.Sealed | TypeAttributes.Serializable,
344 typeof (Enum));
346 try {
347 tb.CreateType ();
348 Assert.Fail ("#A1");
349 } catch (TypeLoadException ex) {
350 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A2");
351 Assert.IsNull (ex.InnerException, "#A3");
352 Assert.IsNotNull (ex.Message, "#A4");
355 #if NET_2_0
356 //Assert.IsTrue (tb.IsCreated (), "#B1");
357 Assert.IsNull (tb.CreateType (), "#B2");
358 //Assert.IsTrue (tb.IsCreated (), "#B3");
359 #else
360 try {
361 tb.CreateType ();
362 Assert.Fail ("#B1");
363 } catch (InvalidOperationException ex) {
364 // Unable to change after type has been created
365 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
366 Assert.IsNull (ex.InnerException, "#B3");
367 Assert.IsNotNull (ex.Message, "#B4");
369 #endif
372 [Test]
373 public void TestEnumWithEmptyInterfaceBuildsOk ()
375 TypeBuilder tb = module.DefineType (genTypeName (),
376 TypeAttributes.Sealed | TypeAttributes.Serializable,
377 typeof (Enum));
378 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
379 FieldAttributes.Private | FieldAttributes.RTSpecialName);
381 tb.AddInterfaceImplementation (typeof (EmptyInterface));
383 try {
384 tb.CreateType ();
385 } catch (TypeLoadException) {
386 Assert.Fail ("#1: must build enum type ok");
389 #if NET_2_0
390 Assert.IsTrue (tb.IsCreated (), "#2");
391 #endif
394 [Test]
395 [Category ("NotWorking")]
396 public void TestEnumWithNonEmptyInterfaceBuildsFails ()
398 TypeBuilder tb = module.DefineType (genTypeName (),
399 TypeAttributes.Sealed | TypeAttributes.Serializable,
400 typeof (Enum));
401 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
402 FieldAttributes.Private | FieldAttributes.RTSpecialName);
404 tb.AddInterfaceImplementation (typeof (OneMethodInterface));
406 try {
407 tb.CreateType ();
408 Assert.Fail ("#1: type doesn't have all interface methods");
409 } catch (TypeLoadException) {
412 #if NET_2_0
413 Assert.IsTrue (tb.IsCreated (), "#2");
414 #endif
417 [Test]
418 [Category ("NotWorking")]
419 public void TestTypeDontImplementInterfaceMethodBuildsFails ()
421 TypeBuilder tb = module.DefineType (genTypeName (),
422 TypeAttributes.Sealed | TypeAttributes.Serializable,
423 typeof (object));
425 tb.AddInterfaceImplementation (typeof (OneMethodInterface));
427 try {
428 tb.CreateType ();
429 Assert.Fail ("#1: type doesn't have all interface methods");
430 } catch (TypeLoadException) {
433 #if NET_2_0
434 Assert.IsTrue (tb.IsCreated (), "#2");
435 #endif
438 [Test]
439 public void TestEnumWithSequentialLayoutBuildsFails ()
441 TypeBuilder tb = module.DefineType (genTypeName (),
442 TypeAttributes.Sealed | TypeAttributes.Serializable |
443 TypeAttributes.SequentialLayout, typeof (Enum));
444 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
445 FieldAttributes.Private | FieldAttributes.RTSpecialName);
447 try {
448 tb.CreateType ();
449 Assert.Fail ("#1: type doesn't have all interface methods");
450 } catch (TypeLoadException) {
453 #if NET_2_0
454 //Assert.IsTrue (tb.IsCreated (), "#2");
455 #endif
458 [Test]
459 public void TestEnumWithExplicitLayoutBuildsFails ()
461 TypeBuilder tb = module.DefineType (genTypeName (),
462 TypeAttributes.Sealed | TypeAttributes.Serializable |
463 TypeAttributes.ExplicitLayout, typeof (Enum));
464 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
465 FieldAttributes.Private | FieldAttributes.RTSpecialName);
467 try {
468 tb.CreateType ();
469 Assert.Fail ("#1: type doesn't have all interface methods");
470 } catch (TypeLoadException) {
473 #if NET_2_0
474 //Assert.IsTrue (tb.IsCreated (), "#2");
475 #endif
478 [Test]
479 public void TestEnumWithMethodsBuildFails ()
481 TypeBuilder tb = module.DefineType ("FooEnum7",
482 TypeAttributes.Sealed | TypeAttributes.Serializable,
483 typeof (Enum));
484 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
485 FieldAttributes.Private | FieldAttributes.RTSpecialName);
487 MethodBuilder methodBuilder = tb.DefineMethod("mmm",
488 MethodAttributes.Public | MethodAttributes.Virtual,
489 null,
490 new Type[] { });
492 methodBuilder.GetILGenerator().Emit(OpCodes.Ret);
493 try {
494 tb.CreateType ();
495 Assert.Fail ("#1: enum has method");
496 } catch (TypeLoadException) {
499 #if NET_2_0
500 //Assert.IsTrue (tb.IsCreated (), "#2");
501 #endif
504 [Test]
505 public void TestEnumWithBadTypeValueFieldBuildFails ()
507 Type[] badTypes = {
508 typeof (object),
509 typeof (string),
510 typeof (DateTime)
513 foreach (Type type in badTypes) {
514 TypeBuilder tb = module.DefineType (genTypeName (),
515 TypeAttributes.Sealed | TypeAttributes.Serializable,
516 typeof (Enum));
517 tb.DefineField ("value__", type, FieldAttributes.SpecialName |
518 FieldAttributes.Private | FieldAttributes.RTSpecialName);
520 try {
521 tb.CreateType ();
522 Assert.Fail ("#1: enum using bad type: " + type);
523 } catch (TypeLoadException) {
526 #if NET_2_0
527 //Assert.IsTrue (tb.IsCreated (), "#2");
528 #endif
532 [Test]
533 public void TestEnumWithGoodTypeValueFieldBuildOk ()
535 Type[] goodTypes = {
536 typeof (byte),typeof (sbyte),typeof (bool),
537 typeof (ushort),typeof (short),typeof (char),
538 typeof (uint),typeof (int),
539 typeof (ulong),typeof (long),
540 typeof (UIntPtr),typeof (IntPtr),
543 foreach (Type type in goodTypes) {
544 TypeBuilder tb = module.DefineType (genTypeName (),
545 TypeAttributes.Sealed | TypeAttributes.Serializable,
546 typeof (Enum));
547 tb.DefineField ("value__", type, FieldAttributes.SpecialName |
548 FieldAttributes.Private | FieldAttributes.RTSpecialName);
550 try {
551 tb.CreateType ();
552 } catch (TypeLoadException) {
553 Assert.Fail ("#1: enum using good type: " + type);
558 [Test]
559 public void TestEnumWithMultipleValueFieldsBuildFals ()
561 TypeBuilder tb = module.DefineType (genTypeName (),
562 TypeAttributes.Sealed | TypeAttributes.Serializable,
563 typeof (Enum));
564 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
565 FieldAttributes.Private | FieldAttributes.RTSpecialName);
566 tb.DefineField ("value2__", typeof (int), FieldAttributes.SpecialName |
567 FieldAttributes.Private | FieldAttributes.RTSpecialName);
569 try {
570 tb.CreateType ();
571 Assert.Fail ("#1: invalid enum type");
572 } catch (TypeLoadException) {
575 #if NET_2_0
576 //Assert.IsTrue (tb.IsCreated (), "#2");
577 #endif
580 [Test]
581 [Category ("NotWorking")]
582 public void TestEnumWithEmptyInterfaceCanBeCasted ()
584 TypeBuilder tb = module.DefineType (genTypeName (),
585 TypeAttributes.Sealed | TypeAttributes.Serializable,
586 typeof (Enum));
587 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
588 FieldAttributes.Private | FieldAttributes.RTSpecialName);
589 tb.AddInterfaceImplementation (typeof (EmptyInterface));
591 try {
592 tb.CreateType ();
593 } catch (TypeLoadException) {
594 Assert.Fail ("#1: must build enum type ok");
597 try {
598 EmptyInterface obj = (EmptyInterface) Activator.CreateInstance (tb);
599 Assert.IsNotNull (obj, "#2");
600 } catch (TypeLoadException) {
601 Assert.Fail ("#3: must cast enum to interface");
605 [Test]
606 public void TestEnumWithValueFieldBuildOk ()
608 TypeBuilder tb = module.DefineType (genTypeName (),
609 TypeAttributes.Sealed | TypeAttributes.Serializable,
610 typeof (Enum));
611 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
612 FieldAttributes.Private | FieldAttributes.RTSpecialName);
614 try {
615 tb.CreateType ();
616 } catch (TypeLoadException) {
617 Assert.Fail ("#1: must build enum type ok");
621 [Test]
622 public void TestIsAbstract ()
624 TypeBuilder tb = module.DefineType (genTypeName ());
625 Assert.IsFalse (tb.IsAbstract, "#1");
627 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Abstract);
628 Assert.IsTrue (tb2.IsAbstract, "#2");
631 [Test]
632 public void TestIsAnsiClass ()
634 TypeBuilder tb = module.DefineType (genTypeName ());
635 Assert.IsTrue (tb.IsAnsiClass, "#1");
637 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.UnicodeClass);
638 Assert.IsFalse (tb2.IsAnsiClass, "#2");
641 [Test]
642 public void TestIsArray ()
644 // How can a TypeBuilder be an array ?
645 string name = genTypeName ();
646 TypeBuilder tb = module.DefineType (name);
647 Assert.IsFalse (tb.IsArray);
650 [Test]
651 public void TestIsAutoClass ()
653 TypeBuilder tb = module.DefineType (genTypeName ());
654 Assert.IsFalse (tb.IsAutoClass, "#1");
656 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.AutoClass);
657 Assert.IsTrue (tb2.IsAutoClass, "#2");
660 [Test]
661 public void TestIsAutoLayout ()
663 TypeBuilder tb = module.DefineType (genTypeName ());
664 Assert.IsTrue (tb.IsAutoLayout, "#1");
666 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.ExplicitLayout);
667 Assert.IsFalse (tb2.IsAutoLayout, "#2");
670 [Test]
671 public void TestIsByRef ()
673 // How can a TypeBuilder be ByRef ?
674 TypeBuilder tb = module.DefineType (genTypeName ());
675 Assert.IsFalse (tb.IsByRef);
678 [Test]
679 public void TestIsClass ()
681 TypeBuilder tb = module.DefineType (genTypeName ());
682 Assert.IsTrue (tb.IsClass, "#1");
684 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
685 Assert.IsFalse (tb2.IsClass, "#2");
687 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
688 Assert.IsFalse (tb3.IsClass, "#3");
690 TypeBuilder tb4 = module.DefineType (genTypeName (), 0, typeof (Enum));
691 Assert.IsFalse (tb4.IsClass, "#4");
694 [Test] // bug #71304
695 public void TestIsCOMObject ()
697 TypeBuilder tb = module.DefineType (genTypeName ());
698 Assert.IsFalse (tb.IsCOMObject, "#1");
700 tb = module.DefineType (genTypeName (), TypeAttributes.Import);
701 Assert.IsTrue (tb.IsCOMObject, "#2");
704 [Test]
705 public void TestIsContextful ()
707 TypeBuilder tb = module.DefineType (genTypeName ());
708 Assert.IsFalse (tb.IsContextful, "#1");
710 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (ContextBoundObject));
711 Assert.IsTrue (tb2.IsContextful, "#2");
714 [Test]
715 public void TestIsEnum ()
717 TypeBuilder tb = module.DefineType (genTypeName ());
718 Assert.IsFalse (tb.IsEnum, "#1");
720 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (ValueType));
721 Assert.IsFalse (tb2.IsEnum, "#2");
723 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (Enum));
724 Assert.IsTrue (tb3.IsEnum, "#3");
727 [Test]
728 public void TestIsExplicitLayout ()
730 TypeBuilder tb = module.DefineType (genTypeName ());
731 Assert.IsFalse (tb.IsExplicitLayout, "#1");
733 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.ExplicitLayout);
734 Assert.IsTrue (tb2.IsExplicitLayout, "#2");
737 [Test]
738 public void TestIsImport ()
740 TypeBuilder tb = module.DefineType (genTypeName ());
741 Assert.IsFalse (tb.IsImport, "#1");
743 tb = module.DefineType (genTypeName (), TypeAttributes.Import);
744 Assert.IsTrue (tb.IsImport, "#2");
747 [Test]
748 public void TestIsInterface ()
750 TypeBuilder tb = module.DefineType (genTypeName ());
751 Assert.IsFalse (tb.IsInterface, "#1");
753 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
754 Assert.IsTrue (tb2.IsInterface, "#2");
756 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
757 Assert.IsFalse (tb3.IsInterface, "#3");
760 [Test]
761 public void TestIsLayoutSequential ()
763 TypeBuilder tb = module.DefineType (genTypeName ());
764 Assert.IsFalse (tb.IsLayoutSequential, "#1");
766 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.SequentialLayout);
767 Assert.IsTrue (tb2.IsLayoutSequential, "#2");
770 [Test]
771 public void TestIsMarshalByRef ()
773 TypeBuilder tb = module.DefineType (genTypeName ());
774 Assert.IsFalse (tb.IsMarshalByRef, "#1");
776 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (MarshalByRefObject));
777 Assert.IsTrue (tb2.IsMarshalByRef, "#2");
779 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ContextBoundObject));
780 Assert.IsTrue (tb3.IsMarshalByRef, "#3");
783 // TODO: Visibility properties
785 [Test]
786 public void TestIsPointer ()
788 // How can this be true?
789 TypeBuilder tb = module.DefineType (genTypeName ());
790 Assert.IsFalse (tb.IsPointer);
793 [Test]
794 public void TestIsPrimitive ()
796 TypeBuilder tb = module.DefineType ("int");
797 Assert.IsFalse (tb.IsPrimitive);
800 [Test]
801 public void IsSealed ()
803 TypeBuilder tb = module.DefineType (genTypeName ());
804 Assert.IsFalse (tb.IsSealed, "#1");
806 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
807 Assert.IsTrue (tb2.IsSealed, "#2");
810 static string CreateTempAssembly ()
812 FileStream f = null;
813 string path;
814 Random rnd;
815 int num = 0;
817 rnd = new Random ();
818 do {
819 num = rnd.Next ();
820 num++;
821 path = Path.Combine (Path.GetTempPath (), "tmp" + num.ToString ("x") + ".dll");
823 try {
824 f = new FileStream (path, FileMode.CreateNew);
825 } catch { }
826 } while (f == null);
828 f.Close ();
831 return "tmp" + num.ToString ("x") + ".dll";
834 [Test]
835 public void IsSerializable ()
837 TypeBuilder tb = module.DefineType (genTypeName ());
838 Assert.IsFalse (tb.IsSerializable, "#1");
840 ConstructorInfo [] ctors = typeof (SerializableAttribute).GetConstructors (BindingFlags.Instance | BindingFlags.Public);
841 Assert.IsTrue (ctors.Length > 0, "#2");
843 tb.SetCustomAttribute (new CustomAttributeBuilder (ctors [0], new object [0]));
844 Type createdType = tb.CreateType ();
846 string an = CreateTempAssembly ();
847 assembly.Save (an);
848 Assert.IsTrue (createdType.IsSerializable, "#3");
849 File.Delete (Path.Combine (Path.GetTempPath (), an));
852 [Test]
853 public void TestIsSpecialName ()
855 TypeBuilder tb = module.DefineType (genTypeName ());
856 Assert.IsFalse (tb.IsSpecialName, "#1");
858 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.SpecialName);
859 Assert.IsTrue (tb2.IsSpecialName, "#2");
862 [Test]
863 public void TestIsUnicodeClass ()
865 TypeBuilder tb = module.DefineType (genTypeName ());
866 Assert.IsFalse (tb.IsUnicodeClass, "#1");
868 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.UnicodeClass);
869 Assert.IsTrue (tb2.IsUnicodeClass, "#2");
872 [Test]
873 public void TestIsValueType ()
875 TypeBuilder tb = module.DefineType (genTypeName ());
876 Assert.IsFalse (tb.IsValueType, "#1");
878 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
879 Assert.IsFalse (tb2.IsValueType, "#2");
881 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
882 Assert.IsTrue (tb3.IsValueType, "#3");
884 TypeBuilder tb4 = module.DefineType (genTypeName (), 0, typeof (Enum));
885 Assert.IsTrue (tb4.IsValueType, "#4");
888 [Test]
889 public void TestMemberType ()
891 TypeBuilder tb = module.DefineType (genTypeName ());
892 Assert.AreEqual (MemberTypes.TypeInfo, tb.MemberType);
895 [Test]
896 public void TestModule ()
898 TypeBuilder tb = module.DefineType (genTypeName ());
899 Assert.AreEqual (module, tb.Module);
902 [Test]
903 public void TestName ()
905 TypeBuilder tb = module.DefineType ("A");
906 Assert.AreEqual ("A", tb.Name, "#1");
908 TypeBuilder tb2 = module.DefineType ("A.B.C.D.E");
909 Assert.AreEqual ("E", tb2.Name, "#2");
911 TypeBuilder tb3 = tb2.DefineNestedType ("A");
912 Assert.AreEqual ("A", tb3.Name, "#3");
914 /* Is .E a valid name ?
915 TypeBuilder tb4 = module.DefineType (".E");
916 Assert.AreEqual ("E", tb4.Name);
920 [Test]
921 public void TestNamespace ()
923 TypeBuilder tb = module.DefineType ("A");
924 Assert.AreEqual (string.Empty, tb.Namespace, "#1");
926 TypeBuilder tb2 = module.DefineType ("A.B.C.D.E");
927 Assert.AreEqual ("A.B.C.D", tb2.Namespace, "#2");
929 TypeBuilder tb3 = tb2.DefineNestedType ("A");
930 Assert.AreEqual (string.Empty, tb3.Namespace, "#3");
932 /* Is .E a valid name ?
933 TypeBuilder tb4 = module.DefineType (".E");
934 Assert.AreEqual ("E", tb4.Name);
938 [Test]
939 public void TestPackingSize ()
941 TypeBuilder tb = module.DefineType (genTypeName ());
942 Assert.AreEqual (PackingSize.Unspecified, tb.PackingSize, "#1");
944 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (object),
945 PackingSize.Size16, 16);
946 Assert.AreEqual (PackingSize.Size16, tb2.PackingSize, "#2");
949 [Test]
950 public void TestReflectedType ()
952 // It is the same as DeclaringType, but why?
953 TypeBuilder tb = module.DefineType (genTypeName ());
954 Assert.IsNull (tb.ReflectedType, "#1");
956 TypeBuilder tb2 = tb.DefineNestedType (genTypeName ());
957 Assert.AreEqual (tb, tb2.ReflectedType, "#2");
960 [Test]
961 public void SetParent_Parent_Null ()
963 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class,
964 typeof (Attribute));
965 #if NET_2_0
966 tb.SetParent (null);
967 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
968 #else
969 try {
970 tb.SetParent (null);
971 Assert.Fail ("#A1");
972 } catch (ArgumentNullException ex) {
973 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
974 Assert.IsNull (ex.InnerException, "#A3");
975 Assert.IsNotNull (ex.Message, "#A4");
976 Assert.AreEqual ("parent", ex.ParamName, "#A5");
978 #endif
980 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
981 TypeAttributes.Abstract);
982 #if NET_2_0
983 tb.SetParent (null);
984 Assert.IsNull (tb.BaseType, "#B1");
985 #else
986 try {
987 tb.SetParent (null);
988 Assert.Fail ("#B1");
989 } catch (ArgumentNullException ex) {
990 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
991 Assert.IsNull (ex.InnerException, "#B3");
992 Assert.IsNotNull (ex.Message, "#B4");
993 Assert.AreEqual ("parent", ex.ParamName, "#B5");
995 #endif
997 #if NET_2_0
998 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
999 TypeAttributes.Abstract, typeof (ICloneable));
1000 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#C1");
1001 tb.SetParent (null);
1002 Assert.IsNull (tb.BaseType, "#C2");
1004 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
1005 typeof (IDisposable));
1006 try {
1007 tb.SetParent (null);
1008 Assert.Fail ("#D1");
1009 } catch (InvalidOperationException ex) {
1010 // Interface must be declared abstract
1011 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1012 Assert.IsNull (ex.InnerException, "#D3");
1013 Assert.IsNotNull (ex.Message, "#D4");
1015 #endif
1018 [Test]
1019 public void SetParent_Parent_Interface ()
1021 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class);
1022 tb.SetParent (typeof (ICloneable));
1023 Assert.AreEqual (typeof (ICloneable), tb.BaseType);
1026 [Test]
1027 public void TestSetParentIncomplete ()
1029 TypeBuilder tb = module.DefineType (genTypeName ());
1030 tb.SetParent (typeof (Attribute));
1031 Assert.AreEqual (typeof (Attribute), tb.BaseType, "#1");
1033 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
1034 TypeAttributes.Abstract);
1035 tb.SetParent (typeof (IDisposable));
1036 Assert.AreEqual (typeof (IDisposable), tb.BaseType, "#2");
1038 tb = module.DefineType (genTypeName ());
1039 tb.SetParent (typeof (IDisposable));
1040 Assert.AreEqual (typeof (IDisposable), tb.BaseType, "#3");
1042 #if NET_2_0
1043 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
1044 TypeAttributes.Abstract, typeof (IDisposable));
1045 tb.SetParent (typeof (ICloneable));
1046 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#4");
1048 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
1049 TypeAttributes.Abstract, typeof (IDisposable));
1050 tb.SetParent (typeof (ICloneable));
1051 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#5");
1052 #endif
1055 [Test]
1056 public void TestSetParentComplete ()
1058 TypeBuilder tb = module.DefineType (genTypeName ());
1059 tb.CreateType ();
1060 try {
1061 tb.SetParent (typeof (Attribute));
1062 Assert.Fail ("#1");
1063 } catch (InvalidOperationException ex) {
1064 // Unable to change after type has been created
1065 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1066 Assert.IsNull (ex.InnerException, "#3");
1067 Assert.IsNotNull (ex.Message, "#4");
1071 [Test]
1072 public void TestSize ()
1075 TypeBuilder tb = module.DefineType (genTypeName ());
1076 Assert.AreEqual (0, tb.Size, "#1");
1077 tb.CreateType ();
1078 Assert.AreEqual (0, tb.Size, "#2");
1082 TypeBuilder tb = module.DefineType (genTypeName (), 0, typeof (object),
1083 PackingSize.Size16, 32);
1084 Assert.AreEqual (32, tb.Size, "#3");
1088 [Test]
1089 public void TestTypeHandle ()
1091 TypeBuilder tb = module.DefineType (genTypeName ());
1092 try {
1093 RuntimeTypeHandle handle = tb.TypeHandle;
1094 Assert.Fail ("#1:" + handle);
1095 } catch (NotSupportedException ex) {
1096 // The invoked member is not supported in a
1097 // dynamic module
1098 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1099 Assert.IsNull (ex.InnerException, "#3");
1100 Assert.IsNotNull (ex.Message, "#4");
1104 [Test]
1105 public void TestTypeInitializerIncomplete ()
1107 TypeBuilder tb = module.DefineType (genTypeName ());
1108 try {
1109 ConstructorInfo cb = tb.TypeInitializer;
1110 Assert.Fail ("#1:" + (cb != null));
1111 } catch (NotSupportedException ex) {
1112 // The invoked member is not supported in a
1113 // dynamic module
1114 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1115 Assert.IsNull (ex.InnerException, "#3");
1116 Assert.IsNotNull (ex.Message, "#4");
1120 [Test]
1121 public void TestTypeInitializerComplete ()
1123 TypeBuilder tb = module.DefineType (genTypeName ());
1124 tb.CreateType ();
1125 ConstructorInfo cb = tb.TypeInitializer;
1128 [Test]
1129 public void TestTypeToken ()
1131 TypeBuilder tb = module.DefineType (genTypeName ());
1132 TypeToken token = tb.TypeToken;
1135 [Test]
1136 public void UnderlyingSystemType ()
1138 TypeBuilder tb;
1139 Type emitted_type;
1141 tb = module.DefineType (genTypeName ());
1142 Assert.AreSame (tb, tb.UnderlyingSystemType, "#A1");
1143 emitted_type = tb.CreateType ();
1144 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#A2");
1146 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1147 Assert.AreSame (tb, tb.UnderlyingSystemType, "#B1");
1148 emitted_type = tb.CreateType ();
1149 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#B2");
1151 tb = module.DefineType (genTypeName (), 0, typeof (ValueType));
1152 Assert.AreSame (tb, tb.UnderlyingSystemType, "#C1");
1153 emitted_type = tb.CreateType ();
1154 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#C2");
1156 tb = module.DefineType (genTypeName (), 0, typeof (Enum));
1157 try {
1158 Type t = tb.UnderlyingSystemType;
1159 Assert.Fail ("#D1:" + t);
1160 } catch (InvalidOperationException ex) {
1161 // Underlying type information on enumeration
1162 // is not specified
1163 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1164 Assert.IsNull (ex.InnerException, "#D3");
1165 Assert.IsNotNull (ex.Message, "#D4");
1167 tb.DefineField ("val", typeof (int), FieldAttributes.Private);
1168 Assert.AreEqual (typeof (int), tb.UnderlyingSystemType, "#D5");
1169 emitted_type = tb.CreateType ();
1170 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#D6");
1172 tb = module.DefineType (genTypeName (), 0, typeof (Enum));
1173 tb.DefineField ("val", typeof (int), FieldAttributes.Static);
1174 try {
1175 Type t = tb.UnderlyingSystemType;
1176 Assert.Fail ("#E1:" + t);
1177 } catch (InvalidOperationException ex) {
1178 // Underlying type information on enumeration
1179 // is not specified
1180 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1181 Assert.IsNull (ex.InnerException, "#E3");
1182 Assert.IsNotNull (ex.Message, "#E4");
1184 tb.DefineField ("foo", typeof (long), FieldAttributes.Private);
1185 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E5");
1186 tb.DefineField ("bar", typeof (short), FieldAttributes.Private);
1187 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E6");
1188 tb.DefineField ("boo", typeof (int), FieldAttributes.Static);
1189 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E7");
1192 [Test]
1193 public void AddInterfaceImplementation_InterfaceType_Null ()
1195 TypeBuilder tb = module.DefineType (genTypeName ());
1196 try {
1197 tb.AddInterfaceImplementation (null);
1198 Assert.Fail ("#1");
1199 } catch (ArgumentNullException ex) {
1200 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1201 Assert.IsNull (ex.InnerException, "#3");
1202 Assert.IsNotNull (ex.Message, "#4");
1203 Assert.AreEqual ("interfaceType", ex.ParamName, "#5");
1207 [Test]
1208 public void TestAddInterfaceImplementation ()
1210 TypeBuilder tb = module.DefineType (genTypeName ());
1211 tb.AddInterfaceImplementation (typeof (AnInterface));
1212 tb.AddInterfaceImplementation (typeof (AnInterface));
1214 Type t = tb.CreateType ();
1215 Assert.AreEqual (1, tb.GetInterfaces ().Length, "#2");
1217 // Can not be called on a created type
1218 try {
1219 tb.AddInterfaceImplementation (typeof (AnInterface));
1220 Assert.Fail ("#3");
1221 } catch (InvalidOperationException) {
1225 [Test]
1226 #if ONLY_1_1
1227 [Category ("NotWorking")] // we allow CreateType to be invoked multiple times
1228 #endif
1229 public void TestCreateType_Created ()
1231 TypeBuilder tb = module.DefineType (genTypeName ());
1232 #if NET_2_0
1233 Assert.IsFalse (tb.IsCreated (), "#A1");
1234 #endif
1235 Type emittedType1 = tb.CreateType ();
1236 #if NET_2_0
1237 Assert.IsTrue (tb.IsCreated (), "#A2");
1238 #endif
1239 Assert.IsNotNull (emittedType1, "#A3");
1241 #if NET_2_0
1242 Type emittedType2 = tb.CreateType ();
1243 Assert.IsNotNull (emittedType2, "#B1");
1244 Assert.IsTrue (tb.IsCreated (), "#B2");
1245 Assert.AreSame (emittedType1, emittedType2, "#B3");
1246 #else
1247 try {
1248 tb.CreateType ();
1249 Assert.Fail ("#B1");
1250 } catch (InvalidOperationException ex) {
1251 // Unable to change after type has been created
1252 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
1253 Assert.IsNull (ex.InnerException, "#B3");
1254 Assert.IsNotNull (ex.Message, "#B4");
1256 #endif
1259 [Test]
1260 public void TestDefineConstructor ()
1262 TypeBuilder tb = module.DefineType (genTypeName ());
1264 ConstructorBuilder cb = tb.DefineConstructor (0, 0, null);
1265 cb.GetILGenerator ().Emit (OpCodes.Ret);
1266 tb.CreateType ();
1268 // Can not be called on a created type
1269 try {
1270 tb.DefineConstructor (0, 0, null);
1271 Assert.Fail ("#1");
1272 } catch (InvalidOperationException ex) {
1273 // Unable to change after type has been created
1274 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1275 Assert.IsNull (ex.InnerException, "#3");
1276 Assert.IsNotNull (ex.Message, "#4");
1280 [Test]
1281 public void DefineDefaultConstructor ()
1283 TypeBuilder tb = module.DefineType (genTypeName ());
1284 tb.DefineDefaultConstructor (0);
1285 tb.CreateType ();
1287 // Can not be called on a created type, altough the MSDN docs does not mention this
1288 try {
1289 tb.DefineDefaultConstructor (0);
1290 Assert.Fail ("#1");
1291 } catch (InvalidOperationException ex) {
1292 // Unable to change after type has been created
1293 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1294 Assert.IsNull (ex.InnerException, "#3");
1295 Assert.IsNotNull (ex.Message, "#4");
1299 [Test]
1300 public void DefineDefaultConstructor_Parent_DefaultCtorInaccessible ()
1302 TypeBuilder tb;
1304 tb = module.DefineType (genTypeName ());
1305 tb.DefineDefaultConstructor (MethodAttributes.Private);
1306 Type parent_type = tb.CreateType ();
1308 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1309 parent_type);
1310 tb.DefineDefaultConstructor (MethodAttributes.Public);
1311 Type emitted_type = tb.CreateType ();
1312 try {
1313 Activator.CreateInstance (emitted_type);
1314 Assert.Fail ("#1");
1315 } catch (TargetInvocationException ex) {
1316 Assert.AreEqual (typeof (TargetInvocationException), ex.GetType (), "#2");
1317 Assert.IsNotNull (ex.InnerException, "#3");
1318 Assert.IsNotNull (ex.Message, "#4");
1320 MethodAccessException mae = ex.InnerException as MethodAccessException;
1321 Assert.IsNotNull (mae, "#5");
1322 Assert.AreEqual (typeof (MethodAccessException), mae.GetType (), "#6");
1323 Assert.IsNull (mae.InnerException, "#7");
1324 Assert.IsNotNull (mae.Message, "#8");
1325 Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#9:" + mae.Message);
1326 Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#10:" + mae.Message);
1330 [Test]
1331 public void DefineDefaultConstructor_Parent_DefaultCtorMissing ()
1333 TypeBuilder tb;
1335 tb = module.DefineType (genTypeName ());
1336 ConstructorBuilder cb = tb.DefineConstructor (
1337 MethodAttributes.Public,
1338 CallingConventions.Standard,
1339 new Type [] { typeof (string) });
1340 cb.GetILGenerator ().Emit (OpCodes.Ret);
1341 Type parent_type = tb.CreateType ();
1343 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1344 parent_type);
1345 try {
1346 tb.DefineDefaultConstructor (MethodAttributes.Public);
1347 Assert.Fail ("#1");
1348 } catch (NotSupportedException ex) {
1349 // Parent does not have a default constructor.
1350 // The default constructor must be explicitly defined
1351 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1352 Assert.IsNull (ex.InnerException, "#3");
1353 Assert.IsNotNull (ex.Message, "#4");
1357 [Test]
1358 public void DefineEvent_Name_NullChar ()
1360 TypeBuilder tb = module.DefineType (genTypeName ());
1362 try {
1363 tb.DefineEvent ("\0test", EventAttributes.None,
1364 typeof (int));
1365 Assert.Fail ("#A1");
1366 } catch (ArgumentException ex) {
1367 // Illegal name
1368 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1369 Assert.IsNull (ex.InnerException, "#A3");
1370 Assert.IsNotNull (ex.Message, "#A4");
1371 Assert.AreEqual ("name", ex.ParamName, "#A5");
1374 EventBuilder eb = tb.DefineEvent ("te\0st", EventAttributes.None,
1375 typeof (int));
1376 Assert.IsNotNull (eb, "#B1");
1379 [Test]
1380 public void TestDefineEvent ()
1382 TypeBuilder tb = module.DefineType (genTypeName ());
1384 // Test invalid arguments
1385 try {
1386 tb.DefineEvent (null, 0, typeof (int));
1387 Assert.Fail ("#A1");
1388 } catch (ArgumentNullException ex) {
1389 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1390 Assert.IsNull (ex.InnerException, "#A3");
1391 Assert.IsNotNull (ex.Message, "#A4");
1392 Assert.AreEqual ("name", ex.ParamName, "#A5");
1395 try {
1396 tb.DefineEvent ("FOO", 0, null);
1397 Assert.Fail ("#B1");
1398 } catch (ArgumentNullException ex) {
1399 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1400 Assert.IsNull (ex.InnerException, "#B3");
1401 Assert.IsNotNull (ex.Message, "#B4");
1402 Assert.AreEqual ("type", ex.ParamName, "#B5");
1405 try {
1406 tb.DefineEvent (string.Empty, 0, typeof (int));
1407 Assert.Fail ("#C1");
1408 } catch (ArgumentException ex) {
1409 // Empty name is not legal
1410 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1411 Assert.IsNull (ex.InnerException, "#C3");
1412 Assert.IsNotNull (ex.Message, "#C4");
1413 Assert.AreEqual ("name", ex.ParamName, "#C5");
1416 tb.CreateType ();
1418 // Can not be called on a created type
1419 try {
1420 tb.DefineEvent ("BAR", 0, typeof (int));
1421 Assert.Fail ("#D1");
1422 } catch (InvalidOperationException ex) {
1423 // Unable to change after type has been created
1424 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1425 Assert.IsNull (ex.InnerException, "#D3");
1426 Assert.IsNotNull (ex.Message, "#D4");
1430 [Test] // DefineField (String, Type, FieldAttributes)
1431 public void DefineField1 ()
1433 TypeBuilder tb = module.DefineType (genTypeName ());
1435 // Check invalid arguments
1436 try {
1437 tb.DefineField (null, typeof (int), 0);
1438 Assert.Fail ("#A1");
1439 } catch (ArgumentNullException ex) {
1440 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1441 Assert.IsNull (ex.InnerException, "#A3");
1442 Assert.IsNotNull (ex.Message, "#A4");
1443 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1446 try {
1447 tb.DefineField (string.Empty, typeof (int), 0);
1448 Assert.Fail ("#B1");
1449 } catch (ArgumentException ex) {
1450 // Empty name is not legal
1451 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1452 Assert.IsNull (ex.InnerException, "#B3");
1453 Assert.IsNotNull (ex.Message, "#B4");
1454 Assert.AreEqual ("fieldName", ex.ParamName, "#B5");
1457 try {
1458 // Strangely, 'A<NULL>' is accepted...
1459 string name = String.Format ("{0}", (char) 0);
1460 tb.DefineField (name, typeof (int), 0);
1461 Assert.Fail ("#C1");
1462 } catch (ArgumentException ex) {
1463 // Illegal name
1464 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1465 Assert.IsNull (ex.InnerException, "#C3");
1466 Assert.IsNotNull (ex.Message, "#C4");
1467 Assert.AreEqual ("fieldName", ex.ParamName, "#C5");
1470 try {
1471 tb.DefineField ("A", typeof (void), 0);
1472 Assert.Fail ("#D1");
1473 } catch (ArgumentException ex) {
1474 // Bad field type in defining field
1475 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1476 Assert.IsNull (ex.InnerException, "#D3");
1477 Assert.IsNotNull (ex.Message, "#D4");
1478 Assert.IsNull (ex.ParamName, "#D5");
1481 tb.CreateType ();
1483 // Can not be called on a created type
1484 try {
1485 tb.DefineField ("B", typeof (int), 0);
1486 Assert.Fail ("#E1");
1487 } catch (InvalidOperationException ex) {
1488 // Unable to change after type has been created
1489 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1490 Assert.IsNull (ex.InnerException, "#E3");
1491 Assert.IsNotNull (ex.Message, "#E4");
1495 [Test] // DefineField (String, Type, FieldAttributes)
1496 public void DefineField1_Name_NullChar ()
1498 TypeBuilder tb = module.DefineType (genTypeName ());
1500 try {
1501 tb.DefineField ("\0test", typeof (int),
1502 FieldAttributes.Private);
1503 Assert.Fail ("#A1");
1504 } catch (ArgumentException ex) {
1505 // Illegal name
1506 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1507 Assert.IsNull (ex.InnerException, "#A3");
1508 Assert.IsNotNull (ex.Message, "#A4");
1509 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1512 FieldBuilder fb = tb.DefineField ("te\0st", typeof (int),
1513 FieldAttributes.Private);
1514 Assert.IsNotNull (fb, "#B1");
1515 Assert.AreEqual ("te\0st", fb.Name, "#B2");
1518 [Test] // DefineField (String, Type, FieldAttributes)
1519 public void DefineField1_Type_Null ()
1521 TypeBuilder tb = module.DefineType (genTypeName ());
1523 try {
1524 tb.DefineField ("test", (Type) null,
1525 FieldAttributes.Private);
1526 Assert.Fail ("#1");
1527 } catch (ArgumentNullException ex) {
1528 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1529 Assert.IsNull (ex.InnerException, "#3");
1530 Assert.IsNotNull (ex.Message, "#4");
1531 Assert.AreEqual ("type", ex.ParamName, "#5");
1535 #if NET_2_0
1536 [Test] // DefineField (String, Type, Type [], Type [], FieldAttributes)
1537 public void DefineField2_Type_Null ()
1539 TypeBuilder tb = module.DefineType (genTypeName ());
1541 try {
1542 tb.DefineField ("test", (Type) null, Type.EmptyTypes,
1543 Type.EmptyTypes, FieldAttributes.Private);
1544 Assert.Fail ("#1");
1545 } catch (ArgumentNullException ex) {
1546 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1547 Assert.IsNull (ex.InnerException, "#3");
1548 Assert.IsNotNull (ex.Message, "#4");
1549 Assert.AreEqual ("type", ex.ParamName, "#5");
1552 #endif
1554 [Test]
1555 public void TestDefineInitializedData ()
1557 TypeBuilder tb = module.DefineType (genTypeName ());
1559 // Check invalid arguments
1560 try {
1561 tb.DefineInitializedData (null, new byte [1], 0);
1562 Assert.Fail ("#A1");
1563 } catch (ArgumentNullException ex) {
1564 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1565 Assert.IsNull (ex.InnerException, "#A3");
1566 Assert.IsNotNull (ex.Message, "#A4");
1567 Assert.AreEqual ("name", ex.ParamName, "#A5");
1570 try {
1571 tb.DefineInitializedData ("FOO", null, 0);
1572 Assert.Fail ("#B1");
1573 } catch (ArgumentNullException ex) {
1574 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1575 Assert.IsNull (ex.InnerException, "#B3");
1576 Assert.IsNotNull (ex.Message, "#B4");
1577 Assert.AreEqual ("data", ex.ParamName, "#B5");
1580 try {
1581 tb.DefineInitializedData (string.Empty, new byte [1], 0);
1582 Assert.Fail ("#C1");
1583 } catch (ArgumentException ex) {
1584 // Empty name is not legal
1585 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1586 Assert.IsNull (ex.InnerException, "#C3");
1587 Assert.IsNotNull (ex.Message, "#C4");
1588 Assert.AreEqual ("name", ex.ParamName, "#C5");
1591 // The size of the data is less than or equal to zero ???
1592 try {
1593 tb.DefineInitializedData ("BAR", new byte [0], 0);
1594 Assert.Fail ("#D1");
1595 } catch (ArgumentException ex) {
1596 // Data size must be > 0 and < 0x3f0000
1597 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1598 Assert.IsNull (ex.InnerException, "#D3");
1599 Assert.IsNotNull (ex.Message, "#D4");
1600 Assert.IsNull (ex.ParamName, "#D5");
1603 try {
1604 string name = String.Format ("{0}", (char) 0);
1605 tb.DefineInitializedData (name, new byte [1], 0);
1606 Assert.Fail ("#E1");
1607 } catch (ArgumentException ex) {
1608 // Illegal name
1609 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#E2");
1610 Assert.IsNull (ex.InnerException, "#E3");
1611 Assert.IsNotNull (ex.Message, "#E4");
1612 Assert.AreEqual ("fieldName", ex.ParamName, "#E5");
1615 tb.CreateType ();
1617 // Can not be called on a created type, altough the MSDN docs does not mention this
1618 try {
1619 tb.DefineInitializedData ("BAR2", new byte [1], 0);
1620 Assert.Fail ("#F1");
1621 } catch (InvalidOperationException ex) {
1622 // Unable to change after type has been created
1623 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
1624 Assert.IsNull (ex.InnerException, "#F3");
1625 Assert.IsNotNull (ex.Message, "#F4");
1629 [Test]
1630 public void DefineUninitializedDataInvalidArgs ()
1632 TypeBuilder tb = module.DefineType (genTypeName ());
1634 try {
1635 tb.DefineUninitializedData (null, 1, 0);
1636 Assert.Fail ("#A1");
1637 } catch (ArgumentNullException ex) {
1638 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1639 Assert.IsNull (ex.InnerException, "#A3");
1640 Assert.IsNotNull (ex.Message, "#A4");
1641 Assert.AreEqual ("name", ex.ParamName, "#A5");
1644 try {
1645 tb.DefineUninitializedData (string.Empty, 1, 0);
1646 Assert.Fail ("#B1");
1647 } catch (ArgumentException ex) {
1648 // Empty name is not legal
1649 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1650 Assert.IsNull (ex.InnerException, "#B3");
1651 Assert.IsNotNull (ex.Message, "#B4");
1652 Assert.AreEqual ("name", ex.ParamName, "#B5");
1655 // The size of the data is less than or equal to zero ???
1656 try {
1657 tb.DefineUninitializedData ("BAR", 0, 0);
1658 Assert.Fail ("#C1");
1659 } catch (ArgumentException ex) {
1660 // Data size must be > 0 and < 0x3f0000
1661 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1662 Assert.IsNull (ex.InnerException, "#C3");
1663 Assert.IsNotNull (ex.Message, "#C4");
1664 Assert.IsNull (ex.ParamName, "#C5");
1667 try {
1668 string name = String.Format ("{0}", (char) 0);
1669 tb.DefineUninitializedData (name, 1, 0);
1670 Assert.Fail ("#D1");
1671 } catch (ArgumentException ex) {
1672 // Illegal name
1673 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1674 Assert.IsNull (ex.InnerException, "#D3");
1675 Assert.IsNotNull (ex.Message, "#D4");
1676 Assert.AreEqual ("fieldName", ex.ParamName, "#D5");
1680 [Test]
1681 public void DefineUninitializedDataAlreadyCreated ()
1683 TypeBuilder tb = module.DefineType (genTypeName ());
1684 tb.CreateType ();
1685 try {
1686 tb.DefineUninitializedData ("BAR2", 1, 0);
1687 Assert.Fail ("#1");
1688 } catch (InvalidOperationException ex) {
1689 // Unable to change after type has been created
1690 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1691 Assert.IsNull (ex.InnerException, "#3");
1692 Assert.IsNotNull (ex.Message, "#4");
1696 [Test]
1697 public void DefineUninitializedData ()
1699 TypeBuilder tb = module.DefineType (genTypeName ());
1701 tb.DefineUninitializedData ("foo", 4, FieldAttributes.Public);
1703 Type t = tb.CreateType ();
1705 object o = Activator.CreateInstance (t);
1707 FieldInfo fi = t.GetField ("foo");
1709 object fieldVal = fi.GetValue (o);
1711 IntPtr ptr = Marshal.AllocHGlobal (4);
1712 Marshal.StructureToPtr (fieldVal, ptr, true);
1713 Marshal.FreeHGlobal (ptr);
1716 [Test]
1717 public void DefineMethod_Name_NullChar ()
1719 TypeBuilder tb = module.DefineType (genTypeName ());
1720 try {
1721 tb.DefineMethod ("\0test", MethodAttributes.Private,
1722 typeof (string), Type.EmptyTypes);
1723 Assert.Fail ("#A1");
1724 } catch (ArgumentException ex) {
1725 // Illegal name
1726 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1727 Assert.IsNull (ex.InnerException, "#A3");
1728 Assert.IsNotNull (ex.Message, "#A4");
1729 Assert.AreEqual ("name", ex.ParamName, "#A5");
1732 MethodBuilder mb = tb.DefineMethod ("te\0st", MethodAttributes.Private,
1733 typeof (string), Type.EmptyTypes);
1734 Assert.IsNotNull (mb, "#B1");
1735 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1738 [Test]
1739 public void TestDefineMethod ()
1741 TypeBuilder tb = module.DefineType (genTypeName ());
1743 // Check invalid arguments
1744 try {
1745 tb.DefineMethod (null, 0, null, null);
1746 Assert.Fail ("#A1");
1747 } catch (ArgumentNullException ex) {
1748 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1749 Assert.IsNull (ex.InnerException, "#A3");
1750 Assert.IsNotNull (ex.Message, "#A4");
1751 Assert.AreEqual ("name", ex.ParamName, "#A5");
1754 try {
1755 tb.DefineMethod (string.Empty, 0, null, null);
1756 Assert.Fail ("#B1");
1757 } catch (ArgumentException ex) {
1758 // Empty name is not legal
1759 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1760 Assert.IsNull (ex.InnerException, "#B3");
1761 Assert.IsNotNull (ex.Message, "#B4");
1762 Assert.AreEqual ("name", ex.ParamName, "#B5");
1765 // Check non-virtual methods on an interface
1766 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1767 try {
1768 tb2.DefineMethod ("FOO", MethodAttributes.Abstract, null, null);
1769 Assert.Fail ("#C1");
1770 } catch (ArgumentException ex) {
1771 // Interface method must be abstract and virtual
1772 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1773 Assert.IsNull (ex.InnerException, "#C3");
1774 Assert.IsNotNull (ex.Message, "#C4");
1775 Assert.IsNull (ex.ParamName, "#C5");
1778 // Check static methods on an interface
1779 tb2.DefineMethod ("BAR", MethodAttributes.Public | MethodAttributes.Static,
1780 typeof (void),
1781 Type.EmptyTypes);
1783 tb.CreateType ();
1784 // Can not be called on a created type
1785 try {
1786 tb.DefineMethod ("bar", 0, null, null);
1787 Assert.Fail ("#D1");
1788 } catch (InvalidOperationException ex) {
1789 // Unable to change after type has been created
1790 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1791 Assert.IsNull (ex.InnerException, "#D3");
1792 Assert.IsNotNull (ex.Message, "#D4");
1796 [Test] // bug #327484
1797 [Category ("NotWorking")]
1798 public void TestDefineMethod_Abstract ()
1800 TypeBuilder tb = module.DefineType (genTypeName ());
1801 tb.DefineMethod ("Run", MethodAttributes.Public |
1802 MethodAttributes.Abstract | MethodAttributes.Virtual,
1803 typeof (void), Type.EmptyTypes);
1805 try {
1806 tb.CreateType ();
1807 Assert.Fail ("#A1");
1808 } catch (InvalidOperationException ex) {
1809 // Type must be declared abstract if any of its
1810 // methods are abstract
1811 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1812 Assert.IsNull (ex.InnerException, "#A3");
1813 Assert.IsNotNull (ex.Message, "#A4");
1816 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract);
1817 tb.DefineMethod ("Run", MethodAttributes.Public |
1818 MethodAttributes.Abstract, typeof (void),
1819 Type.EmptyTypes);
1821 try {
1822 tb.CreateType ();
1823 Assert.Fail ("#B1");
1824 } catch (TypeLoadException ex) {
1825 // Non-virtual abstract method
1826 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B2");
1827 Assert.IsNull (ex.InnerException, "#B3");
1828 Assert.IsNotNull (ex.Message, "#B4");
1831 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract |
1832 TypeAttributes.Public);
1833 tb.DefineMethod ("Run", MethodAttributes.Public |
1834 MethodAttributes.Abstract | MethodAttributes.Virtual,
1835 typeof (void), Type.EmptyTypes);
1836 Type emittedType = tb.CreateType ();
1838 MethodInfo mi1 = emittedType.GetMethod ("Run");
1839 Assert.IsNotNull (mi1, "#C1");
1840 Assert.IsTrue (mi1.IsAbstract, "#C2");
1842 MethodInfo mi2 = tb.GetMethod ("Run");
1843 Assert.IsNotNull (mi2, "#D1");
1844 Assert.IsTrue (mi2.IsAbstract, "#D2");
1847 // TODO: DefineMethodOverride
1849 [Test]
1850 public void TestDefineNestedType ()
1852 TypeBuilder tb = module.DefineType (genTypeName ());
1854 // Check invalid arguments
1855 try {
1856 tb.DefineNestedType (null);
1857 Assert.Fail ("#A1");
1858 } catch (ArgumentNullException ex) {
1859 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1860 Assert.IsNull (ex.InnerException, "#A3");
1861 Assert.IsNotNull (ex.Message, "#A4");
1862 Assert.AreEqual ("fullname", ex.ParamName, "#A5");
1865 try {
1866 tb.DefineNestedType (string.Empty);
1867 Assert.Fail ("#B1");
1868 } catch (ArgumentException ex) {
1869 // Empty name is not legal
1870 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1871 Assert.IsNull (ex.InnerException, "#B3");
1872 Assert.IsNotNull (ex.Message, "#B4");
1873 Assert.AreEqual ("fullname", ex.ParamName, "#B5");
1876 try {
1877 tb.DefineNestedType (nullName ());
1878 Assert.Fail ("#C1");
1879 } catch (ArgumentException ex) {
1880 // Illegal name
1881 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1882 Assert.IsNull (ex.InnerException, "#C3");
1883 Assert.IsNotNull (ex.Message, "#C4");
1884 Assert.AreEqual ("fullname", ex.ParamName, "#C5");
1887 // If I fix the code so this works then mcs breaks -> how can mcs
1888 // works under MS .NET in the first place ???
1890 try {
1891 tb.DefineNestedType ("AA", TypeAttributes.Public, null, null);
1892 Fail ("Nested visibility must be specified.");
1894 catch (ArgumentException) {
1898 try {
1899 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1900 new Type [1]);
1901 Assert.Fail ("#D1");
1902 } catch (ArgumentNullException ex) {
1903 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#D2");
1904 Assert.IsNull (ex.InnerException, "#D3");
1905 Assert.IsNotNull (ex.Message, "#D4");
1906 Assert.AreEqual ("interfaces", ex.ParamName, "#D5");
1909 // I think this should reject non-interfaces, but it does not
1910 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1911 new Type [1] { typeof (object) });
1913 // Normal invocation
1914 tb.DefineNestedType ("Nest");
1916 tb.CreateType ();
1918 // According to the MSDN docs, this cannnot be called after the type
1919 // is created, but it works.
1920 tb.DefineNestedType ("Nest2");
1922 // According to the MSDN docs, a Sealed class can't contain nested
1923 // types, but this is not true
1924 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
1925 tb2.DefineNestedType ("AA");
1927 // According to the MSDN docs, interfaces can only contain interfaces,
1928 // but this is not true
1929 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1931 tb3.DefineNestedType ("AA");
1933 // Check shorter versions
1935 TypeBuilder nested = tb.DefineNestedType ("N1");
1937 Assert.AreEqual ("N1", nested.Name, "#E1");
1938 Assert.AreEqual (typeof (object), nested.BaseType, "#E2");
1939 Assert.AreEqual (TypeAttributes.NestedPrivate, nested.Attributes, "#E3");
1940 Assert.AreEqual (0, nested.GetInterfaces ().Length, "#E4");
1943 // TODO:
1946 [Test]
1947 public void DefinePInvokeMethod_Name_NullChar ()
1949 TypeBuilder tb = module.DefineType (genTypeName ());
1950 try {
1951 tb.DefinePInvokeMethod ("\0test", "B", "C",
1952 MethodAttributes.Private, CallingConventions.Standard,
1953 typeof (string),Type.EmptyTypes, CallingConvention.Cdecl,
1954 CharSet.Unicode);
1955 Assert.Fail ("#A1");
1956 } catch (ArgumentException ex) {
1957 // Illegal name
1958 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1959 Assert.IsNull (ex.InnerException, "#A3");
1960 Assert.IsNotNull (ex.Message, "#A4");
1961 Assert.AreEqual ("name", ex.ParamName, "#A5");
1964 MethodBuilder mb = tb.DefinePInvokeMethod ("te\0st", "B", "C",
1965 MethodAttributes.Private, CallingConventions.Standard,
1966 typeof (string), Type.EmptyTypes, CallingConvention.Cdecl,
1967 CharSet.Unicode);
1968 Assert.IsNotNull (mb, "#B1");
1969 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1972 [Test]
1973 public void TestDefinePInvokeMethod ()
1975 TypeBuilder tb = module.DefineType (genTypeName ());
1977 tb.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1979 // Try invalid parameters
1980 try {
1981 tb.DefinePInvokeMethod (null, "B", "C", 0, 0, null, null, 0, 0);
1982 Assert.Fail ("#A1");
1983 } catch (ArgumentNullException ex) {
1984 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1985 Assert.IsNull (ex.InnerException, "#A3");
1986 Assert.IsNotNull (ex.Message, "#A4");
1987 Assert.AreEqual ("name", ex.ParamName, "#A5");
1989 // etc...
1991 // Try invalid attributes
1992 try {
1993 tb.DefinePInvokeMethod ("A2", "B", "C", MethodAttributes.Abstract, 0, null, null, 0, 0);
1994 Assert.Fail ("#B1");
1995 } catch (ArgumentException ex) {
1996 // PInvoke methods must be static and native and
1997 // cannot be abstract
1998 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1999 Assert.IsNull (ex.InnerException, "#B3");
2000 Assert.IsNotNull (ex.Message, "#B4");
2001 Assert.IsNull (ex.ParamName, "#B5");
2004 // Try an interface parent
2005 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
2007 try {
2008 tb2.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
2009 Assert.Fail ("#C1");
2010 } catch (ArgumentException ex) {
2011 // PInvoke methods cannot exist on interfaces
2012 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2013 Assert.IsNull (ex.InnerException, "#B3");
2014 Assert.IsNotNull (ex.Message, "#B4");
2015 Assert.IsNull (ex.ParamName, "#B5");
2019 [Test]
2020 public void DefineProperty_Name_NullChar ()
2022 TypeBuilder tb = module.DefineType (genTypeName ());
2024 try {
2025 tb.DefineProperty ("\0test", 0, typeof (string), Type.EmptyTypes);
2026 Assert.Fail ("#A1");
2027 } catch (ArgumentException ex) {
2028 // Illegal name
2029 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2030 Assert.IsNull (ex.InnerException, "#A3");
2031 Assert.IsNotNull (ex.Message, "#A4");
2032 Assert.AreEqual ("name", ex.ParamName, "#A5");
2035 PropertyBuilder pb = tb.DefineProperty ("te\0st", 0,
2036 typeof (string), Type.EmptyTypes);
2037 Assert.IsNotNull (pb, "#B1");
2038 Assert.AreEqual ("te\0st", pb.Name, "#B2");
2041 [Test]
2042 public void DefineProperty_ParameterTypes_ItemNull ()
2044 TypeBuilder tb = module.DefineType (genTypeName ());
2046 try {
2047 tb.DefineProperty ("A", 0, typeof (string), new Type [1]);
2048 Assert.Fail ("#1");
2049 } catch (ArgumentNullException ex) {
2050 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2051 Assert.IsNull (ex.InnerException, "#3");
2052 Assert.IsNotNull (ex.Message, "#4");
2056 [Test]
2057 public void DefineProperty_ReturnType_Null ()
2059 TypeBuilder tb = module.DefineType (genTypeName ());
2060 tb.DefineProperty ("A", 0, null, Type.EmptyTypes);
2063 [Test]
2064 public void GetMethod_WorksWithTypeBuilderParameter () {
2065 TypeBuilder tb = module.DefineType (genTypeName ());
2066 var garg = tb.DefineGenericParameters ("T") [0];
2067 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2069 var mi = TypeBuilder.GetMethod (tb, mb);
2070 var decl = mi.DeclaringType;
2072 Assert.IsTrue (decl.IsGenericType, "#1");
2073 Assert.IsFalse (decl.IsGenericTypeDefinition, "#2");
2074 Assert.AreEqual (tb, decl.GetGenericTypeDefinition (), "#3");
2075 Assert.AreEqual (garg, decl.GetGenericArguments () [0], "#4");
2078 [Test]
2079 public void GetConstructor_FailWithTypeBuilderParameter () {
2080 TypeBuilder tb = module.DefineType (genTypeName ());
2081 var garg = tb.DefineGenericParameters ("T") [0];
2082 var cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2084 try {
2085 TypeBuilder.GetConstructor (tb, cb);
2086 Assert.Fail ("#1");
2087 } catch (ArgumentException ex) {
2088 Assert.AreEqual ("type", ex.ParamName, "#2");
2092 [Test]
2093 public void GetField_FailWithTypeBuilderParameter () {
2094 TypeBuilder tb = module.DefineType (genTypeName ());
2095 var garg = tb.DefineGenericParameters ("T") [0];
2096 var fb = tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
2098 try {
2099 TypeBuilder.GetField (tb, fb);
2100 Assert.Fail ("#1");
2101 } catch (ArgumentException ex) {
2102 Assert.AreEqual ("type", ex.ParamName, "#2");
2106 [Test]
2107 public void GetMethod_RejectMethodFromInflatedTypeBuilder () {
2108 TypeBuilder tb = module.DefineType (genTypeName ());
2109 tb.DefineGenericParameters ("T");
2110 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2112 Type ginst = tb.MakeGenericType (typeof (int));
2114 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2115 try {
2116 TypeBuilder.GetMethod (ginst, mi);
2117 Assert.Fail ("#1");
2118 } catch (ArgumentException ex) {
2119 Assert.AreEqual ("method", ex.ParamName, "#5");
2123 [Test]
2124 public void GetMethod_WorkWithInstancesOfCreatedTypeBuilder () {
2125 TypeBuilder tb = module.DefineType (genTypeName ());
2126 tb.DefineGenericParameters ("T");
2127 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2128 ILGenerator ig = mb.GetILGenerator ();
2129 ig.Emit (OpCodes.Ret);
2131 tb.CreateType ();
2133 MethodInfo mi = TypeBuilder.GetMethod (tb.MakeGenericType (typeof (int)), mb);
2134 Assert.IsNotNull (mi);
2137 [Test]
2138 [Category ("NotDotNet")]
2139 [Category ("NotWorking")]
2140 public void GetMethod_AcceptMethodFromInflatedTypeBuilder_UnderCompilerContext () {
2141 AssemblyName assemblyName = new AssemblyName ();
2142 assemblyName.Name = ASSEMBLY_NAME;
2144 assembly =
2145 Thread.GetDomain ().DefineDynamicAssembly (
2146 assemblyName, AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800, Path.GetTempPath ());
2148 module = assembly.DefineDynamicModule ("module1");
2150 TypeBuilder tb = module.DefineType (genTypeName ());
2151 tb.DefineGenericParameters ("T");
2152 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2154 Type ginst = tb.MakeGenericType (typeof (int));
2156 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2158 try {
2159 TypeBuilder.GetMethod (ginst, mi);
2160 } catch (ArgumentException ex) {
2161 Assert.Fail ("#1");
2166 [Test]
2167 // Test that changes made to the method builder after a call to GetMethod ()
2168 // are visible
2169 public void TestGetMethod ()
2171 TypeBuilder tb = module.DefineType (genTypeName ());
2172 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2174 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2175 ILGenerator ig;
2176 ig = cb.GetILGenerator ();
2177 ig.Emit (OpCodes.Ret);
2179 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2181 // Create a method builder but do not emit IL yet
2182 MethodBuilder mb1 = tb.DefineMethod ("create", MethodAttributes.Public|MethodAttributes.Static, fooOfT, Type.EmptyTypes);
2184 Type t = tb.MakeGenericType (typeof (int));
2186 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2188 ig = mb.GetILGenerator ();
2189 ig.Emit (OpCodes.Call, TypeBuilder.GetMethod (t, mb1));
2190 ig.Emit (OpCodes.Ret);
2192 // Finish the method
2193 ig = mb1.GetILGenerator ();
2194 ig.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (fooOfT, cb));
2195 ig.Emit (OpCodes.Ret);
2197 Type t2 = tb.CreateType ();
2199 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2202 [Test]
2203 public void TestGetConstructor ()
2205 TypeBuilder tb = module.DefineType (genTypeName ());
2206 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2208 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2209 ILGenerator ig;
2211 Type t = tb.MakeGenericType (typeof (int));
2213 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2215 ig = mb.GetILGenerator ();
2217 ConstructorInfo ci = TypeBuilder.GetConstructor (t, cb);
2219 ig.Emit (OpCodes.Newobj, ci);
2220 ig.Emit (OpCodes.Ret);
2222 // Finish the ctorbuilder
2223 ig = cb.GetILGenerator ();
2224 ig.Emit (OpCodes.Ret);
2226 Type t2 = tb.CreateType ();
2228 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2231 [Test]
2232 [ExpectedException (typeof (ArgumentException))]
2233 public void Static_GetConstructor_TypeNull ()
2235 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2236 // null is non-generic (from exception message)
2237 TypeBuilder.GetConstructor (null, ci);
2240 [Test]
2241 [ExpectedException (typeof (ArgumentException))]
2242 public void Static_GetConstructor_TypeGeneric ()
2244 Type t = typeof (List<>).MakeGenericType (typeof (int));
2245 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2246 // type is not 'TypeBuilder' (from exception message)
2247 TypeBuilder.GetConstructor (t, ci);
2250 [Test]
2251 public void Static_GetConstructor_TypeBuilderGeneric_ConstructorInfoNull ()
2253 TypeBuilder tb = module.DefineType ("XXX");
2254 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2255 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2256 try {
2257 TypeBuilder.GetConstructor (fooOfT, null);
2258 Assert.Fail ("Expected NullReferenceException");
2260 catch (NullReferenceException) {
2264 [Test] //#536243
2265 public void CreateTypeThrowsForMethodsWithBadLabels ()
2267 TypeBuilder tb = module.DefineType (genTypeName ());
2269 MethodBuilder mb = tb.DefineMethod("F", MethodAttributes.Public, typeof(string), null);
2270 ILGenerator il_gen = mb.GetILGenerator ();
2271 il_gen.DefineLabel ();
2272 il_gen.Emit (OpCodes.Leave, new Label ());
2273 try {
2274 tb.CreateType ();
2275 Assert.Fail ();
2276 } catch (ArgumentException) {}
2279 [Test]
2280 [Category ("NotWorking")]
2281 public void TestIsDefinedIncomplete ()
2283 TypeBuilder tb = module.DefineType (genTypeName ());
2284 try {
2285 tb.IsDefined (typeof (int), true);
2286 Assert.Fail ("#1");
2287 } catch (NotSupportedException ex) {
2288 // The invoked member is not supported in a
2289 // dynamic module
2290 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2291 Assert.IsNull (ex.InnerException, "#3");
2292 Assert.IsNotNull (ex.Message, "#4");
2296 [Test]
2297 public void TestIsDefinedComplete ()
2299 TypeBuilder tb = module.DefineType (genTypeName ());
2301 ConstructorInfo obsoleteCtor = typeof (ObsoleteAttribute).GetConstructor (
2302 new Type [] { typeof (string) });
2304 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (obsoleteCtor,
2305 new object [] { "obsolete message" }, new FieldInfo [0], new object [0]);
2307 tb.SetCustomAttribute (caBuilder);
2308 tb.CreateType ();
2309 Assert.IsTrue (tb.IsDefined (typeof (ObsoleteAttribute), false));
2312 [Test]
2313 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=293659
2314 public void IsDefined_AttributeType_Null ()
2316 TypeBuilder tb = module.DefineType (genTypeName ());
2317 tb.CreateType ();
2319 try {
2320 tb.IsDefined ((Type) null, false);
2321 Assert.Fail ("#1");
2322 } catch (ArgumentNullException ex) {
2323 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2324 Assert.IsNull (ex.InnerException, "#3");
2325 Assert.IsNotNull (ex.Message, "#4");
2326 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
2330 [Test] // GetConstructor (Type [])
2331 public void GetConstructor1_Incomplete ()
2333 TypeBuilder tb = module.DefineType (genTypeName ());
2334 ConstructorBuilder cb = tb.DefineConstructor (
2335 MethodAttributes.Public,
2336 CallingConventions.Standard,
2337 Type.EmptyTypes);
2338 cb.GetILGenerator ().Emit (OpCodes.Ret);
2340 try {
2341 tb.GetConstructor (Type.EmptyTypes);
2342 Assert.Fail ("#1");
2343 } catch (NotSupportedException ex) {
2344 // The invoked member is not supported in a
2345 // dynamic module
2346 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2347 Assert.IsNull (ex.InnerException, "#3");
2348 Assert.IsNotNull (ex.Message, "#4");
2352 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2353 public void GetConstructor2_Complete ()
2355 BindingFlags flags;
2356 ConstructorInfo ctor;
2358 TypeBuilder redType = module.DefineType (genTypeName (),
2359 TypeAttributes.Public);
2360 CreateMembers (redType, "Red", true);
2362 TypeBuilder greenType = module.DefineType (genTypeName (),
2363 TypeAttributes.Public, redType);
2364 CreateMembers (greenType, "Green", false);
2365 ConstructorBuilder cb = greenType.DefineConstructor (
2366 MethodAttributes.Public,
2367 CallingConventions.Standard,
2368 Type.EmptyTypes);
2369 cb.GetILGenerator ().Emit (OpCodes.Ret);
2371 redType.CreateType ();
2372 greenType.CreateType ();
2374 flags = BindingFlags.Instance | BindingFlags.NonPublic;
2376 ctor = greenType.GetConstructor (flags, null,
2377 new Type [] { typeof (int), typeof (int) },
2378 new ParameterModifier [0]);
2379 Assert.IsNull (ctor, "#A1");
2381 ctor = greenType.GetConstructor (flags, null,
2382 new Type [] { typeof (string) },
2383 new ParameterModifier [0]);
2384 Assert.IsNull (ctor, "#A2");
2386 ctor = greenType.GetConstructor (flags, null,
2387 new Type [] { typeof (string), typeof (string) },
2388 new ParameterModifier [0]);
2389 Assert.IsNull (ctor, "#A3");
2391 ctor = greenType.GetConstructor (flags, null,
2392 new Type [] { typeof (int) },
2393 new ParameterModifier [0]);
2394 Assert.IsNull (ctor, "#A4");
2396 ctor = greenType.GetConstructor (flags, null,
2397 new Type [] { typeof (int), typeof (bool) },
2398 new ParameterModifier [0]);
2399 Assert.IsNull (ctor, "#A5");
2401 ctor = greenType.GetConstructor (flags, null,
2402 new Type [] { typeof (string), typeof (int) },
2403 new ParameterModifier [0]);
2404 Assert.IsNull (ctor, "#A6");
2406 ctor = greenType.GetConstructor (flags, null,
2407 Type.EmptyTypes,
2408 new ParameterModifier [0]);
2409 Assert.IsNull (ctor, "#A7");
2411 ctor = redType.GetConstructor (flags, null,
2412 new Type [] { typeof (int), typeof (int) },
2413 new ParameterModifier [0]);
2414 Assert.IsNotNull (ctor, "#A8a");
2415 Assert.IsTrue (ctor.IsPrivate, "#A8b");
2416 Assert.IsFalse (ctor.IsStatic, "#A8c");
2417 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A8d");
2418 Assert.IsFalse (ctor is ConstructorBuilder, "#A8e");
2420 ctor = redType.GetConstructor (flags, null,
2421 new Type [] { typeof (string) },
2422 new ParameterModifier [0]);
2423 Assert.IsNotNull (ctor, "#A9a");
2424 Assert.IsTrue (ctor.IsFamily, "#A9b");
2425 Assert.IsFalse (ctor.IsStatic, "#A9c");
2426 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A9d");
2427 Assert.IsFalse (ctor is ConstructorBuilder, "#A9e");
2429 ctor = redType.GetConstructor (flags, null,
2430 new Type [] { typeof (string), typeof (string) },
2431 new ParameterModifier [0]);
2432 Assert.IsNotNull (ctor, "#A10a");
2433 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#A10b");
2434 Assert.IsFalse (ctor.IsStatic, "#A10c");
2435 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A10d");
2436 Assert.IsFalse (ctor is ConstructorBuilder, "#A10e");
2438 ctor = redType.GetConstructor (flags, null,
2439 new Type [] { typeof (int) },
2440 new ParameterModifier [0]);
2441 Assert.IsNotNull (ctor, "#A11a");
2442 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#A11b");
2443 Assert.IsFalse (ctor.IsStatic, "#A11c");
2444 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A11d");
2445 Assert.IsFalse (ctor is ConstructorBuilder, "#A11e");
2447 ctor = redType.GetConstructor (flags, null,
2448 new Type [] { typeof (int), typeof (bool) },
2449 new ParameterModifier [0]);
2450 Assert.IsNull (ctor, "#A12");
2452 ctor = redType.GetConstructor (flags, null,
2453 new Type [] { typeof (string), typeof (int) },
2454 new ParameterModifier [0]);
2455 Assert.IsNotNull (ctor, "#A13a");
2456 Assert.IsTrue (ctor.IsAssembly, "#A13b");
2457 Assert.IsFalse (ctor.IsStatic, "#A13c");
2458 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A13d");
2459 Assert.IsFalse (ctor is ConstructorBuilder, "#A13e");
2461 ctor = redType.GetConstructor (flags, null,
2462 Type.EmptyTypes,
2463 new ParameterModifier [0]);
2464 Assert.IsNull (ctor, "#A14");
2466 flags = BindingFlags.Instance | BindingFlags.Public;
2468 ctor = greenType.GetConstructor (flags, null,
2469 new Type [] { typeof (int), typeof (int) },
2470 new ParameterModifier [0]);
2471 Assert.IsNull (ctor, "#B1");
2473 ctor = greenType.GetConstructor (flags, null,
2474 new Type [] { typeof (string) },
2475 new ParameterModifier [0]);
2476 Assert.IsNull (ctor, "#B2");
2478 ctor = greenType.GetConstructor (flags, null,
2479 new Type [] { typeof (string), typeof (string) },
2480 new ParameterModifier [0]);
2481 Assert.IsNull (ctor, "#B3");
2483 ctor = greenType.GetConstructor (flags, null,
2484 new Type [] { typeof (int) },
2485 new ParameterModifier [0]);
2486 Assert.IsNull (ctor, "#B4");
2488 ctor = greenType.GetConstructor (flags, null,
2489 new Type [] { typeof (int), typeof (bool) },
2490 new ParameterModifier [0]);
2491 Assert.IsNull (ctor, "#B5");
2493 ctor = greenType.GetConstructor (flags, null,
2494 new Type [] { typeof (string), typeof (int) },
2495 new ParameterModifier [0]);
2496 Assert.IsNull (ctor, "#B6");
2498 ctor = greenType.GetConstructor (flags, null,
2499 Type.EmptyTypes,
2500 new ParameterModifier [0]);
2501 Assert.IsNotNull (ctor, "#B7a");
2502 Assert.IsTrue (ctor.IsPublic, "#B7b");
2503 Assert.IsFalse (ctor.IsStatic, "#B7c");
2504 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B7d");
2505 Assert.IsFalse (ctor is ConstructorBuilder, "#B7e");
2507 ctor = redType.GetConstructor (flags, null,
2508 new Type [] { typeof (int), typeof (int) },
2509 new ParameterModifier [0]);
2510 Assert.IsNull (ctor, "#B8");
2512 ctor = redType.GetConstructor (flags, null,
2513 new Type [] { typeof (string) },
2514 new ParameterModifier [0]);
2515 Assert.IsNull (ctor, "#B9");
2517 ctor = redType.GetConstructor (flags, null,
2518 new Type [] { typeof (string), typeof (string) },
2519 new ParameterModifier [0]);
2520 Assert.IsNull (ctor, "#B10");
2522 ctor = redType.GetConstructor (flags, null,
2523 new Type [] { typeof (int) },
2524 new ParameterModifier [0]);
2525 Assert.IsNull (ctor, "#B11");
2527 ctor = redType.GetConstructor (flags, null,
2528 new Type [] { typeof (int), typeof (bool) },
2529 new ParameterModifier [0]);
2530 Assert.IsNotNull (ctor, "#B12a");
2531 Assert.IsTrue (ctor.IsPublic, "#B12b");
2532 Assert.IsFalse (ctor.IsStatic, "#B12c");
2533 Assert.AreEqual (2, ctor.GetParameters ().Length, "#B12d");
2534 Assert.IsFalse (ctor is ConstructorBuilder, "#B12e");
2536 ctor = redType.GetConstructor (flags, null,
2537 new Type [] { typeof (string), typeof (int) },
2538 new ParameterModifier [0]);
2539 Assert.IsNull (ctor, "#B13");
2541 ctor = redType.GetConstructor (flags, null,
2542 Type.EmptyTypes,
2543 new ParameterModifier [0]);
2544 Assert.IsNull (ctor, "#B14");
2546 flags = BindingFlags.Static | BindingFlags.Public;
2548 ctor = greenType.GetConstructor (flags, null,
2549 new Type [] { typeof (int), typeof (int) },
2550 new ParameterModifier [0]);
2551 Assert.IsNull (ctor, "#C1");
2553 ctor = greenType.GetConstructor (flags, null,
2554 new Type [] { typeof (string) },
2555 new ParameterModifier [0]);
2556 Assert.IsNull (ctor, "#C2");
2558 ctor = greenType.GetConstructor (flags, null,
2559 new Type [] { typeof (string), typeof (string) },
2560 new ParameterModifier [0]);
2561 Assert.IsNull (ctor, "#C3");
2563 ctor = greenType.GetConstructor (flags, null,
2564 new Type [] { typeof (int) },
2565 new ParameterModifier [0]);
2566 Assert.IsNull (ctor, "#C4");
2568 ctor = greenType.GetConstructor (flags, null,
2569 new Type [] { typeof (int), typeof (bool) },
2570 new ParameterModifier [0]);
2571 Assert.IsNull (ctor, "#C5");
2573 ctor = greenType.GetConstructor (flags, null,
2574 new Type [] { typeof (string), typeof (int) },
2575 new ParameterModifier [0]);
2576 Assert.IsNull (ctor, "#C6");
2578 ctor = greenType.GetConstructor (flags, null,
2579 Type.EmptyTypes,
2580 new ParameterModifier [0]);
2581 Assert.IsNull (ctor, "#C7");
2583 ctor = redType.GetConstructor (flags, null,
2584 new Type [] { typeof (int), typeof (int) },
2585 new ParameterModifier [0]);
2586 Assert.IsNull (ctor, "#C8");
2588 ctor = redType.GetConstructor (flags, null,
2589 new Type [] { typeof (string) },
2590 new ParameterModifier [0]);
2591 Assert.IsNull (ctor, "#C9");
2593 ctor = redType.GetConstructor (flags, null,
2594 new Type [] { typeof (string), typeof (string) },
2595 new ParameterModifier [0]);
2596 Assert.IsNull (ctor, "#C10");
2598 ctor = redType.GetConstructor (flags, null,
2599 new Type [] { typeof (int) },
2600 new ParameterModifier [0]);
2601 Assert.IsNull (ctor, "#C11a");
2603 ctor = redType.GetConstructor (flags, null,
2604 new Type [] { typeof (int), typeof (bool) },
2605 new ParameterModifier [0]);
2606 Assert.IsNull (ctor, "#C12");
2608 ctor = redType.GetConstructor (flags, null,
2609 new Type [] { typeof (string), typeof (int) },
2610 new ParameterModifier [0]);
2611 Assert.IsNull (ctor, "#C13");
2613 ctor = redType.GetConstructor (flags, null,
2614 Type.EmptyTypes,
2615 new ParameterModifier [0]);
2616 Assert.IsNull (ctor, "#C14");
2618 flags = BindingFlags.Static | BindingFlags.NonPublic;
2620 ctor = greenType.GetConstructor (flags, null,
2621 new Type [] { typeof (int), typeof (int) },
2622 new ParameterModifier [0]);
2623 Assert.IsNull (ctor, "#D1");
2625 ctor = greenType.GetConstructor (flags, null,
2626 new Type [] { typeof (string) },
2627 new ParameterModifier [0]);
2628 Assert.IsNull (ctor, "#D2");
2630 ctor = greenType.GetConstructor (flags, null,
2631 new Type [] { typeof (string), typeof (string) },
2632 new ParameterModifier [0]);
2633 Assert.IsNull (ctor, "#D3");
2635 ctor = greenType.GetConstructor (flags, null,
2636 new Type [] { typeof (int) },
2637 new ParameterModifier [0]);
2638 Assert.IsNull (ctor, "#D4");
2640 ctor = greenType.GetConstructor (flags, null,
2641 new Type [] { typeof (int), typeof (bool) },
2642 new ParameterModifier [0]);
2643 Assert.IsNull (ctor, "#D5");
2645 ctor = greenType.GetConstructor (flags, null,
2646 new Type [] { typeof (string), typeof (int) },
2647 new ParameterModifier [0]);
2648 Assert.IsNull (ctor, "#D6");
2650 ctor = greenType.GetConstructor (flags, null,
2651 Type.EmptyTypes,
2652 new ParameterModifier [0]);
2653 Assert.IsNull (ctor, "#D7");
2655 ctor = redType.GetConstructor (flags, null,
2656 new Type [] { typeof (int), typeof (int) },
2657 new ParameterModifier [0]);
2658 Assert.IsNull (ctor, "#D8");
2660 ctor = redType.GetConstructor (flags, null,
2661 new Type [] { typeof (string) },
2662 new ParameterModifier [0]);
2663 Assert.IsNull (ctor, "#D9");
2665 ctor = redType.GetConstructor (flags, null,
2666 new Type [] { typeof (string), typeof (string) },
2667 new ParameterModifier [0]);
2668 Assert.IsNull (ctor, "#D10");
2670 ctor = redType.GetConstructor (flags, null,
2671 new Type [] { typeof (int) },
2672 new ParameterModifier [0]);
2673 Assert.IsNull (ctor, "#D11");
2675 ctor = redType.GetConstructor (flags, null,
2676 new Type [] { typeof (int), typeof (bool) },
2677 new ParameterModifier [0]);
2678 Assert.IsNull (ctor, "#D12");
2680 ctor = redType.GetConstructor (flags, null,
2681 new Type [] { typeof (string), typeof (int) },
2682 new ParameterModifier [0]);
2683 Assert.IsNull (ctor, "#D13");
2685 ctor = redType.GetConstructor (flags, null,
2686 Type.EmptyTypes,
2687 new ParameterModifier [0]);
2688 Assert.IsNotNull (ctor, "#D14a");
2689 Assert.IsTrue (ctor.IsPrivate, "#D14b");
2690 Assert.IsTrue (ctor.IsStatic, "#B14c");
2691 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B14d");
2692 Assert.IsFalse (ctor is ConstructorBuilder, "#B14e");
2694 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2695 BindingFlags.FlattenHierarchy;
2697 ctor = greenType.GetConstructor (flags, null,
2698 new Type [] { typeof (int), typeof (int) },
2699 new ParameterModifier [0]);
2700 Assert.IsNull (ctor, "#E1");
2702 ctor = greenType.GetConstructor (flags, null,
2703 new Type [] { typeof (string) },
2704 new ParameterModifier [0]);
2705 Assert.IsNull (ctor, "#E2");
2707 ctor = greenType.GetConstructor (flags, null,
2708 new Type [] { typeof (string), typeof (string) },
2709 new ParameterModifier [0]);
2710 Assert.IsNull (ctor, "#E3");
2712 ctor = greenType.GetConstructor (flags, null,
2713 new Type [] { typeof (int) },
2714 new ParameterModifier [0]);
2715 Assert.IsNull (ctor, "#E4");
2717 ctor = greenType.GetConstructor (flags, null,
2718 new Type [] { typeof (int), typeof (bool) },
2719 new ParameterModifier [0]);
2720 Assert.IsNull (ctor, "#E5");
2722 ctor = greenType.GetConstructor (flags, null,
2723 new Type [] { typeof (string), typeof (int) },
2724 new ParameterModifier [0]);
2725 Assert.IsNull (ctor, "#E6");
2727 ctor = greenType.GetConstructor (flags, null,
2728 Type.EmptyTypes,
2729 new ParameterModifier [0]);
2730 Assert.IsNull (ctor, "#E7");
2732 ctor = redType.GetConstructor (flags, null,
2733 new Type [] { typeof (int), typeof (int) },
2734 new ParameterModifier [0]);
2735 Assert.IsNotNull (ctor, "#E8a");
2736 Assert.IsTrue (ctor.IsPrivate, "#E8b");
2737 Assert.IsFalse (ctor.IsStatic, "#E8c");
2738 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E8d");
2739 Assert.IsFalse (ctor is ConstructorBuilder, "#E8e");
2741 ctor = redType.GetConstructor (flags, null,
2742 new Type [] { typeof (string) },
2743 new ParameterModifier [0]);
2744 Assert.IsNotNull (ctor, "#E9a");
2745 Assert.IsTrue (ctor.IsFamily, "#E9b");
2746 Assert.IsFalse (ctor.IsStatic, "#E9c");
2747 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E9d");
2748 Assert.IsFalse (ctor is ConstructorBuilder, "#E9e");
2750 ctor = redType.GetConstructor (flags, null,
2751 new Type [] { typeof (string), typeof (string) },
2752 new ParameterModifier [0]);
2753 Assert.IsNotNull (ctor, "#E10a");
2754 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#E10b");
2755 Assert.IsFalse (ctor.IsStatic, "#E10c");
2756 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E10d");
2757 Assert.IsFalse (ctor is ConstructorBuilder, "#E10e");
2759 ctor = redType.GetConstructor (flags, null,
2760 new Type [] { typeof (int) },
2761 new ParameterModifier [0]);
2762 Assert.IsNotNull (ctor, "#E11a");
2763 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#E11b");
2764 Assert.IsFalse (ctor.IsStatic, "#E11c");
2765 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E11d");
2766 Assert.IsFalse (ctor is ConstructorBuilder, "#E11e");
2768 ctor = redType.GetConstructor (flags, null,
2769 new Type [] { typeof (int), typeof (bool) },
2770 new ParameterModifier [0]);
2771 Assert.IsNull (ctor, "#E12");
2773 ctor = redType.GetConstructor (flags, null,
2774 new Type [] { typeof (string), typeof (int) },
2775 new ParameterModifier [0]);
2776 Assert.IsNotNull (ctor, "#E13a");
2777 Assert.IsTrue (ctor.IsAssembly, "#E13b");
2778 Assert.IsFalse (ctor.IsStatic, "#E13c");
2779 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E13d");
2780 Assert.IsFalse (ctor is ConstructorBuilder, "#E13e");
2782 ctor = redType.GetConstructor (flags, null,
2783 Type.EmptyTypes,
2784 new ParameterModifier [0]);
2785 Assert.IsNull (ctor, "#E14");
2787 flags = BindingFlags.Instance | BindingFlags.Public |
2788 BindingFlags.FlattenHierarchy;
2790 ctor = greenType.GetConstructor (flags, null,
2791 new Type [] { typeof (int), typeof (int) },
2792 new ParameterModifier [0]);
2793 Assert.IsNull (ctor, "#F1");
2795 ctor = greenType.GetConstructor (flags, null,
2796 new Type [] { typeof (string) },
2797 new ParameterModifier [0]);
2798 Assert.IsNull (ctor, "#F2");
2800 ctor = greenType.GetConstructor (flags, null,
2801 new Type [] { typeof (string), typeof (string) },
2802 new ParameterModifier [0]);
2803 Assert.IsNull (ctor, "#F3");
2805 ctor = greenType.GetConstructor (flags, null,
2806 new Type [] { typeof (int) },
2807 new ParameterModifier [0]);
2808 Assert.IsNull (ctor, "#F4");
2810 ctor = greenType.GetConstructor (flags, null,
2811 new Type [] { typeof (int), typeof (bool) },
2812 new ParameterModifier [0]);
2813 Assert.IsNull (ctor, "#F5");
2815 ctor = greenType.GetConstructor (flags, null,
2816 new Type [] { typeof (string), typeof (int) },
2817 new ParameterModifier [0]);
2818 Assert.IsNull (ctor, "#F6");
2820 ctor = greenType.GetConstructor (flags, null,
2821 Type.EmptyTypes,
2822 new ParameterModifier [0]);
2823 Assert.IsNotNull (ctor, "#F7a");
2824 Assert.IsTrue (ctor.IsPublic, "#F7b");
2825 Assert.IsFalse (ctor.IsStatic, "#F7c");
2826 Assert.AreEqual (0, ctor.GetParameters ().Length, "#F7d");
2827 Assert.IsFalse (ctor is ConstructorBuilder, "#F7e");
2829 ctor = redType.GetConstructor (flags, null,
2830 new Type [] { typeof (int), typeof (int) },
2831 new ParameterModifier [0]);
2832 Assert.IsNull (ctor, "#F8");
2834 ctor = redType.GetConstructor (flags, null,
2835 new Type [] { typeof (string) },
2836 new ParameterModifier [0]);
2837 Assert.IsNull (ctor, "#F9");
2839 ctor = redType.GetConstructor (flags, null,
2840 new Type [] { typeof (string), typeof (string) },
2841 new ParameterModifier [0]);
2842 Assert.IsNull (ctor, "#F10");
2844 ctor = redType.GetConstructor (flags, null,
2845 new Type [] { typeof (int) },
2846 new ParameterModifier [0]);
2847 Assert.IsNull (ctor, "#F11");
2849 ctor = redType.GetConstructor (flags, null,
2850 new Type [] { typeof (int), typeof (bool) },
2851 new ParameterModifier [0]);
2852 Assert.IsNotNull (ctor, "#F12a");
2853 Assert.IsTrue (ctor.IsPublic, "#F12b");
2854 Assert.IsFalse (ctor.IsStatic, "#F12c");
2855 Assert.AreEqual (2, ctor.GetParameters ().Length, "#F12d");
2856 Assert.IsFalse (ctor is ConstructorBuilder, "#F12e");
2858 ctor = redType.GetConstructor (flags, null,
2859 new Type [] { typeof (string), typeof (int) },
2860 new ParameterModifier [0]);
2861 Assert.IsNull (ctor, "#F13");
2863 ctor = redType.GetConstructor (flags, null,
2864 Type.EmptyTypes,
2865 new ParameterModifier [0]);
2866 Assert.IsNull (ctor, "#F14");
2868 flags = BindingFlags.Static | BindingFlags.Public |
2869 BindingFlags.FlattenHierarchy;
2871 ctor = greenType.GetConstructor (flags, null,
2872 new Type [] { typeof (int), typeof (int) },
2873 new ParameterModifier [0]);
2874 Assert.IsNull (ctor, "#G1");
2876 ctor = greenType.GetConstructor (flags, null,
2877 new Type [] { typeof (string) },
2878 new ParameterModifier [0]);
2879 Assert.IsNull (ctor, "#G2");
2881 ctor = greenType.GetConstructor (flags, null,
2882 new Type [] { typeof (string), typeof (string) },
2883 new ParameterModifier [0]);
2884 Assert.IsNull (ctor, "#G3");
2886 ctor = greenType.GetConstructor (flags, null,
2887 new Type [] { typeof (int) },
2888 new ParameterModifier [0]);
2889 Assert.IsNull (ctor, "#G4");
2891 ctor = greenType.GetConstructor (flags, null,
2892 new Type [] { typeof (int), typeof (bool) },
2893 new ParameterModifier [0]);
2894 Assert.IsNull (ctor, "#G5");
2896 ctor = greenType.GetConstructor (flags, null,
2897 new Type [] { typeof (string), typeof (int) },
2898 new ParameterModifier [0]);
2899 Assert.IsNull (ctor, "#G6");
2901 ctor = greenType.GetConstructor (flags, null,
2902 Type.EmptyTypes,
2903 new ParameterModifier [0]);
2904 Assert.IsNull (ctor, "#G7");
2906 ctor = redType.GetConstructor (flags, null,
2907 new Type [] { typeof (int), typeof (int) },
2908 new ParameterModifier [0]);
2909 Assert.IsNull (ctor, "#G8");
2911 ctor = redType.GetConstructor (flags, null,
2912 new Type [] { typeof (string) },
2913 new ParameterModifier [0]);
2914 Assert.IsNull (ctor, "#G9");
2916 ctor = redType.GetConstructor (flags, null,
2917 new Type [] { typeof (string), typeof (string) },
2918 new ParameterModifier [0]);
2919 Assert.IsNull (ctor, "#G10");
2921 ctor = redType.GetConstructor (flags, null,
2922 new Type [] { typeof (int) },
2923 new ParameterModifier [0]);
2924 Assert.IsNull (ctor, "#G11");
2926 ctor = redType.GetConstructor (flags, null,
2927 new Type [] { typeof (int), typeof (bool) },
2928 new ParameterModifier [0]);
2929 Assert.IsNull (ctor, "#G12");
2931 ctor = redType.GetConstructor (flags, null,
2932 new Type [] { typeof (string), typeof (int) },
2933 new ParameterModifier [0]);
2934 Assert.IsNull (ctor, "#G13");
2936 ctor = redType.GetConstructor (flags, null,
2937 Type.EmptyTypes,
2938 new ParameterModifier [0]);
2939 Assert.IsNull (ctor, "#G14");
2941 flags = BindingFlags.Static | BindingFlags.NonPublic |
2942 BindingFlags.FlattenHierarchy;
2944 ctor = greenType.GetConstructor (flags, null,
2945 new Type [] { typeof (int), typeof (int) },
2946 new ParameterModifier [0]);
2947 Assert.IsNull (ctor, "#H1");
2949 ctor = greenType.GetConstructor (flags, null,
2950 new Type [] { typeof (string) },
2951 new ParameterModifier [0]);
2952 Assert.IsNull (ctor, "#H2");
2954 ctor = greenType.GetConstructor (flags, null,
2955 new Type [] { typeof (string), typeof (string) },
2956 new ParameterModifier [0]);
2957 Assert.IsNull (ctor, "#H3");
2959 ctor = greenType.GetConstructor (flags, null,
2960 new Type [] { typeof (int) },
2961 new ParameterModifier [0]);
2962 Assert.IsNull (ctor, "#H4");
2964 ctor = greenType.GetConstructor (flags, null,
2965 new Type [] { typeof (int), typeof (bool) },
2966 new ParameterModifier [0]);
2967 Assert.IsNull (ctor, "#H5");
2969 ctor = greenType.GetConstructor (flags, null,
2970 new Type [] { typeof (string), typeof (int) },
2971 new ParameterModifier [0]);
2972 Assert.IsNull (ctor, "#H6");
2974 ctor = greenType.GetConstructor (flags, null,
2975 Type.EmptyTypes,
2976 new ParameterModifier [0]);
2977 Assert.IsNull (ctor, "#H7");
2979 ctor = redType.GetConstructor (flags, null,
2980 new Type [] { typeof (int), typeof (int) },
2981 new ParameterModifier [0]);
2982 Assert.IsNull (ctor, "#H8");
2984 ctor = redType.GetConstructor (flags, null,
2985 new Type [] { typeof (string) },
2986 new ParameterModifier [0]);
2987 Assert.IsNull (ctor, "#H9");
2989 ctor = redType.GetConstructor (flags, null,
2990 new Type [] { typeof (string), typeof (string) },
2991 new ParameterModifier [0]);
2992 Assert.IsNull (ctor, "#H10");
2994 ctor = redType.GetConstructor (flags, null,
2995 new Type [] { typeof (int) },
2996 new ParameterModifier [0]);
2997 Assert.IsNull (ctor, "#H11");
2999 ctor = redType.GetConstructor (flags, null,
3000 new Type [] { typeof (int), typeof (bool) },
3001 new ParameterModifier [0]);
3002 Assert.IsNull (ctor, "#H12");
3004 ctor = redType.GetConstructor (flags, null,
3005 new Type [] { typeof (string), typeof (int) },
3006 new ParameterModifier [0]);
3007 Assert.IsNull (ctor, "#H13");
3009 ctor = redType.GetConstructor (flags, null,
3010 Type.EmptyTypes,
3011 new ParameterModifier [0]);
3012 Assert.IsNotNull (ctor, "#H14");
3013 Assert.IsTrue (ctor.IsPrivate, "#H14b");
3014 Assert.IsTrue (ctor.IsStatic, "#H14c");
3015 Assert.AreEqual (0, ctor.GetParameters ().Length, "#H14d");
3016 Assert.IsFalse (ctor is ConstructorBuilder, "#H14e");
3018 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3019 BindingFlags.DeclaredOnly;
3021 ctor = greenType.GetConstructor (flags, null,
3022 new Type [] { typeof (int), typeof (int) },
3023 new ParameterModifier [0]);
3024 Assert.IsNull (ctor, "#I1");
3026 ctor = greenType.GetConstructor (flags, null,
3027 new Type [] { typeof (string) },
3028 new ParameterModifier [0]);
3029 Assert.IsNull (ctor, "#I2");
3031 ctor = greenType.GetConstructor (flags, null,
3032 new Type [] { typeof (string), typeof (string) },
3033 new ParameterModifier [0]);
3034 Assert.IsNull (ctor, "#I3");
3036 ctor = greenType.GetConstructor (flags, null,
3037 new Type [] { typeof (int) },
3038 new ParameterModifier [0]);
3039 Assert.IsNull (ctor, "#I4");
3041 ctor = greenType.GetConstructor (flags, null,
3042 new Type [] { typeof (int), typeof (bool) },
3043 new ParameterModifier [0]);
3044 Assert.IsNull (ctor, "#I5");
3046 ctor = greenType.GetConstructor (flags, null,
3047 new Type [] { typeof (string), typeof (int) },
3048 new ParameterModifier [0]);
3049 Assert.IsNull (ctor, "#I6");
3051 ctor = greenType.GetConstructor (flags, null,
3052 Type.EmptyTypes,
3053 new ParameterModifier [0]);
3054 Assert.IsNull (ctor, "#I7");
3056 ctor = redType.GetConstructor (flags, null,
3057 new Type [] { typeof (int), typeof (int) },
3058 new ParameterModifier [0]);
3059 Assert.IsNotNull (ctor, "#I8a");
3060 Assert.IsTrue (ctor.IsPrivate, "#I8b");
3061 Assert.IsFalse (ctor.IsStatic, "#I8c");
3062 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I8d");
3063 Assert.IsFalse (ctor is ConstructorBuilder, "#I8e");
3065 ctor = redType.GetConstructor (flags, null,
3066 new Type [] { typeof (string) },
3067 new ParameterModifier [0]);
3068 Assert.IsNotNull (ctor, "#I9a");
3069 Assert.IsTrue (ctor.IsFamily, "#I9b");
3070 Assert.IsFalse (ctor.IsStatic, "#I9c");
3071 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I9d");
3072 Assert.IsFalse (ctor is ConstructorBuilder, "#I9e");
3074 ctor = redType.GetConstructor (flags, null,
3075 new Type [] { typeof (string), typeof (string) },
3076 new ParameterModifier [0]);
3077 Assert.IsNotNull (ctor, "#I10a");
3078 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#I10b");
3079 Assert.IsFalse (ctor.IsStatic, "#I10c");
3080 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I10d");
3081 Assert.IsFalse (ctor is ConstructorBuilder, "#I10e");
3083 ctor = redType.GetConstructor (flags, null,
3084 new Type [] { typeof (int) },
3085 new ParameterModifier [0]);
3086 Assert.IsNotNull (ctor, "#I11a");
3087 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#I11b");
3088 Assert.IsFalse (ctor.IsStatic, "#I11c");
3089 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I11d");
3090 Assert.IsFalse (ctor is ConstructorBuilder, "#I11e");
3092 ctor = redType.GetConstructor (flags, null,
3093 new Type [] { typeof (int), typeof (bool) },
3094 new ParameterModifier [0]);
3095 Assert.IsNull (ctor, "#I12");
3097 ctor = redType.GetConstructor (flags, null,
3098 new Type [] { typeof (string), typeof (int) },
3099 new ParameterModifier [0]);
3100 Assert.IsNotNull (ctor, "#I13a");
3101 Assert.IsTrue (ctor.IsAssembly, "#I13b");
3102 Assert.IsFalse (ctor.IsStatic, "#I13c");
3103 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I13d");
3104 Assert.IsFalse (ctor is ConstructorBuilder, "#I13e");
3106 ctor = redType.GetConstructor (flags, null,
3107 Type.EmptyTypes,
3108 new ParameterModifier [0]);
3109 Assert.IsNull (ctor, "#I14");
3111 flags = BindingFlags.Instance | BindingFlags.Public |
3112 BindingFlags.DeclaredOnly;
3114 ctor = greenType.GetConstructor (flags, null,
3115 new Type [] { typeof (int), typeof (int) },
3116 new ParameterModifier [0]);
3117 Assert.IsNull (ctor, "#J1");
3119 ctor = greenType.GetConstructor (flags, null,
3120 new Type [] { typeof (string) },
3121 new ParameterModifier [0]);
3122 Assert.IsNull (ctor, "#J2");
3124 ctor = greenType.GetConstructor (flags, null,
3125 new Type [] { typeof (string), typeof (string) },
3126 new ParameterModifier [0]);
3127 Assert.IsNull (ctor, "#J3");
3129 ctor = greenType.GetConstructor (flags, null,
3130 new Type [] { typeof (int) },
3131 new ParameterModifier [0]);
3132 Assert.IsNull (ctor, "#J4");
3134 ctor = greenType.GetConstructor (flags, null,
3135 new Type [] { typeof (int), typeof (bool) },
3136 new ParameterModifier [0]);
3137 Assert.IsNull (ctor, "#J5");
3139 ctor = greenType.GetConstructor (flags, null,
3140 new Type [] { typeof (string), typeof (int) },
3141 new ParameterModifier [0]);
3142 Assert.IsNull (ctor, "#J6");
3144 ctor = greenType.GetConstructor (flags, null,
3145 Type.EmptyTypes,
3146 new ParameterModifier [0]);
3147 Assert.IsNotNull (ctor, "#J7a");
3148 Assert.IsTrue (ctor.IsPublic, "#J7b");
3149 Assert.IsFalse (ctor.IsStatic, "#J7c");
3150 Assert.AreEqual (0, ctor.GetParameters ().Length, "#J7d");
3151 Assert.IsFalse (ctor is ConstructorBuilder, "#J7e");
3153 ctor = redType.GetConstructor (flags, null,
3154 new Type [] { typeof (int), typeof (int) },
3155 new ParameterModifier [0]);
3156 Assert.IsNull (ctor, "#J8");
3158 ctor = redType.GetConstructor (flags, null,
3159 new Type [] { typeof (string) },
3160 new ParameterModifier [0]);
3161 Assert.IsNull (ctor, "#J9");
3163 ctor = redType.GetConstructor (flags, null,
3164 new Type [] { typeof (string), typeof (string) },
3165 new ParameterModifier [0]);
3166 Assert.IsNull (ctor, "#J10");
3168 ctor = redType.GetConstructor (flags, null,
3169 new Type [] { typeof (int) },
3170 new ParameterModifier [0]);
3171 Assert.IsNull (ctor, "#J11");
3173 ctor = redType.GetConstructor (flags, null,
3174 new Type [] { typeof (int), typeof (bool) },
3175 new ParameterModifier [0]);
3176 Assert.IsNotNull (ctor, "#J12a");
3177 Assert.IsTrue (ctor.IsPublic, "#J12b");
3178 Assert.IsFalse (ctor.IsStatic, "#J12c");
3179 Assert.AreEqual (2, ctor.GetParameters ().Length, "#J12d");
3180 Assert.IsFalse (ctor is ConstructorBuilder, "#J12e");
3182 ctor = redType.GetConstructor (flags, null,
3183 new Type [] { typeof (string), typeof (int) },
3184 new ParameterModifier [0]);
3185 Assert.IsNull (ctor, "#J13");
3187 ctor = redType.GetConstructor (flags, null,
3188 Type.EmptyTypes,
3189 new ParameterModifier [0]);
3190 Assert.IsNull (ctor, "#J14");
3192 flags = BindingFlags.Static | BindingFlags.Public |
3193 BindingFlags.DeclaredOnly;
3195 ctor = greenType.GetConstructor (flags, null,
3196 new Type [] { typeof (int), typeof (int) },
3197 new ParameterModifier [0]);
3198 Assert.IsNull (ctor, "#K1");
3200 ctor = greenType.GetConstructor (flags, null,
3201 new Type [] { typeof (string) },
3202 new ParameterModifier [0]);
3203 Assert.IsNull (ctor, "#K2");
3205 ctor = greenType.GetConstructor (flags, null,
3206 new Type [] { typeof (string), typeof (string) },
3207 new ParameterModifier [0]);
3208 Assert.IsNull (ctor, "#K3");
3210 ctor = greenType.GetConstructor (flags, null,
3211 new Type [] { typeof (int) },
3212 new ParameterModifier [0]);
3213 Assert.IsNull (ctor, "#K4");
3215 ctor = greenType.GetConstructor (flags, null,
3216 new Type [] { typeof (int), typeof (bool) },
3217 new ParameterModifier [0]);
3218 Assert.IsNull (ctor, "#K5");
3220 ctor = greenType.GetConstructor (flags, null,
3221 new Type [] { typeof (string), typeof (int) },
3222 new ParameterModifier [0]);
3223 Assert.IsNull (ctor, "#K6");
3225 ctor = greenType.GetConstructor (flags, null,
3226 Type.EmptyTypes,
3227 new ParameterModifier [0]);
3228 Assert.IsNull (ctor, "#K7");
3230 ctor = redType.GetConstructor (flags, null,
3231 new Type [] { typeof (int), typeof (int) },
3232 new ParameterModifier [0]);
3233 Assert.IsNull (ctor, "#K8");
3235 ctor = redType.GetConstructor (flags, null,
3236 new Type [] { typeof (string) },
3237 new ParameterModifier [0]);
3238 Assert.IsNull (ctor, "#K9");
3240 ctor = redType.GetConstructor (flags, null,
3241 new Type [] { typeof (string), typeof (string) },
3242 new ParameterModifier [0]);
3243 Assert.IsNull (ctor, "#K10");
3245 ctor = redType.GetConstructor (flags, null,
3246 new Type [] { typeof (int) },
3247 new ParameterModifier [0]);
3248 Assert.IsNull (ctor, "#K11");
3250 ctor = redType.GetConstructor (flags, null,
3251 new Type [] { typeof (int), typeof (bool) },
3252 new ParameterModifier [0]);
3253 Assert.IsNull (ctor, "#K12");
3255 ctor = redType.GetConstructor (flags, null,
3256 new Type [] { typeof (string), typeof (int) },
3257 new ParameterModifier [0]);
3258 Assert.IsNull (ctor, "#K13");
3260 ctor = redType.GetConstructor (flags, null,
3261 Type.EmptyTypes,
3262 new ParameterModifier [0]);
3263 Assert.IsNull (ctor, "#K14");
3265 flags = BindingFlags.Static | BindingFlags.NonPublic |
3266 BindingFlags.DeclaredOnly;
3268 ctor = greenType.GetConstructor (flags, null,
3269 new Type [] { typeof (int), typeof (int) },
3270 new ParameterModifier [0]);
3271 Assert.IsNull (ctor, "#L1");
3273 ctor = greenType.GetConstructor (flags, null,
3274 new Type [] { typeof (string) },
3275 new ParameterModifier [0]);
3276 Assert.IsNull (ctor, "#L2");
3278 ctor = greenType.GetConstructor (flags, null,
3279 new Type [] { typeof (string), typeof (string) },
3280 new ParameterModifier [0]);
3281 Assert.IsNull (ctor, "#L3");
3283 ctor = greenType.GetConstructor (flags, null,
3284 new Type [] { typeof (int) },
3285 new ParameterModifier [0]);
3286 Assert.IsNull (ctor, "#L4");
3288 ctor = greenType.GetConstructor (flags, null,
3289 new Type [] { typeof (int), typeof (bool) },
3290 new ParameterModifier [0]);
3291 Assert.IsNull (ctor, "#L5");
3293 ctor = greenType.GetConstructor (flags, null,
3294 new Type [] { typeof (string), typeof (int) },
3295 new ParameterModifier [0]);
3296 Assert.IsNull (ctor, "#L6");
3298 ctor = greenType.GetConstructor (flags, null,
3299 Type.EmptyTypes,
3300 new ParameterModifier [0]);
3301 Assert.IsNull (ctor, "#L7");
3303 ctor = redType.GetConstructor (flags, null,
3304 new Type [] { typeof (int), typeof (int) },
3305 new ParameterModifier [0]);
3306 Assert.IsNull (ctor, "#L8");
3308 ctor = redType.GetConstructor (flags, null,
3309 new Type [] { typeof (string) },
3310 new ParameterModifier [0]);
3311 Assert.IsNull (ctor, "#L9");
3313 ctor = redType.GetConstructor (flags, null,
3314 new Type [] { typeof (string), typeof (string) },
3315 new ParameterModifier [0]);
3316 Assert.IsNull (ctor, "#L10");
3318 ctor = redType.GetConstructor (flags, null,
3319 new Type [] { typeof (int) },
3320 new ParameterModifier [0]);
3321 Assert.IsNull (ctor, "#L11");
3323 ctor = redType.GetConstructor (flags, null,
3324 new Type [] { typeof (int), typeof (bool) },
3325 new ParameterModifier [0]);
3326 Assert.IsNull (ctor, "#L12");
3328 ctor = redType.GetConstructor (flags, null,
3329 new Type [] { typeof (string), typeof (int) },
3330 new ParameterModifier [0]);
3331 Assert.IsNull (ctor, "#L13");
3333 ctor = redType.GetConstructor (flags, null,
3334 Type.EmptyTypes,
3335 new ParameterModifier [0]);
3336 Assert.IsNotNull (ctor, "#L14a");
3337 Assert.IsTrue (ctor.IsPrivate, "#L14b");
3338 Assert.IsTrue (ctor.IsStatic, "#L14c");
3339 Assert.AreEqual (0, ctor.GetParameters ().Length, "#L14d");
3340 Assert.IsFalse (ctor is ConstructorBuilder, "#L14e");
3342 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3343 BindingFlags.Public;
3345 ctor = greenType.GetConstructor (flags, null,
3346 new Type [] { typeof (int), typeof (int) },
3347 new ParameterModifier [0]);
3348 Assert.IsNull (ctor, "#M1");
3350 ctor = greenType.GetConstructor (flags, null,
3351 new Type [] { typeof (string) },
3352 new ParameterModifier [0]);
3353 Assert.IsNull (ctor, "#M2");
3355 ctor = greenType.GetConstructor (flags, null,
3356 new Type [] { typeof (string), typeof (string) },
3357 new ParameterModifier [0]);
3358 Assert.IsNull (ctor, "#M3");
3360 ctor = greenType.GetConstructor (flags, null,
3361 new Type [] { typeof (int) },
3362 new ParameterModifier [0]);
3363 Assert.IsNull (ctor, "#M4");
3365 ctor = greenType.GetConstructor (flags, null,
3366 new Type [] { typeof (int), typeof (bool) },
3367 new ParameterModifier [0]);
3368 Assert.IsNull (ctor, "#M5");
3370 ctor = greenType.GetConstructor (flags, null,
3371 new Type [] { typeof (string), typeof (int) },
3372 new ParameterModifier [0]);
3373 Assert.IsNull (ctor, "#M6");
3375 ctor = greenType.GetConstructor (flags, null,
3376 Type.EmptyTypes,
3377 new ParameterModifier [0]);
3378 Assert.IsNotNull (ctor, "#M7a");
3379 Assert.IsTrue (ctor.IsPublic, "#M7b");
3380 Assert.IsFalse (ctor.IsStatic, "#M7c");
3381 Assert.AreEqual (0, ctor.GetParameters ().Length, "#M7d");
3382 Assert.IsFalse (ctor is ConstructorBuilder, "#M7e");
3384 ctor = redType.GetConstructor (flags, null,
3385 new Type [] { typeof (int), typeof (int) },
3386 new ParameterModifier [0]);
3387 Assert.IsNotNull (ctor, "#M8a");
3388 Assert.IsTrue (ctor.IsPrivate, "#M8b");
3389 Assert.IsFalse (ctor.IsStatic, "#M8c");
3390 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M8d");
3391 Assert.IsFalse (ctor is ConstructorBuilder, "#M8e");
3393 ctor = redType.GetConstructor (flags, null,
3394 new Type [] { typeof (string) },
3395 new ParameterModifier [0]);
3396 Assert.IsNotNull (ctor, "#M9a");
3397 Assert.IsTrue (ctor.IsFamily, "#M9b");
3398 Assert.IsFalse (ctor.IsStatic, "#M9c");
3399 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M9d");
3400 Assert.IsFalse (ctor is ConstructorBuilder, "#M9e");
3402 ctor = redType.GetConstructor (flags, null,
3403 new Type [] { typeof (string), typeof (string) },
3404 new ParameterModifier [0]);
3405 Assert.IsNotNull (ctor, "#M10a");
3406 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#M10b");
3407 Assert.IsFalse (ctor.IsStatic, "#M10c");
3408 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M10d");
3409 Assert.IsFalse (ctor is ConstructorBuilder, "#M10e");
3411 ctor = redType.GetConstructor (flags, null,
3412 new Type [] { typeof (int) },
3413 new ParameterModifier [0]);
3414 Assert.IsNotNull (ctor, "#M11a");
3415 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#M11b");
3416 Assert.IsFalse (ctor.IsStatic, "#M11c");
3417 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M11d");
3418 Assert.IsFalse (ctor is ConstructorBuilder, "#M11e");
3420 ctor = redType.GetConstructor (flags, null,
3421 new Type [] { typeof (int), typeof (bool) },
3422 new ParameterModifier [0]);
3423 Assert.IsNotNull (ctor, "#M12a");
3424 Assert.IsTrue (ctor.IsPublic, "#M12b");
3425 Assert.IsFalse (ctor.IsStatic, "#M12c");
3426 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M12d");
3427 Assert.IsFalse (ctor is ConstructorBuilder, "#M12e");
3429 ctor = redType.GetConstructor (flags, null,
3430 new Type [] { typeof (string), typeof (int) },
3431 new ParameterModifier [0]);
3432 Assert.IsNotNull (ctor, "#M13a");
3433 Assert.IsTrue (ctor.IsAssembly, "#M13b");
3434 Assert.IsFalse (ctor.IsStatic, "#M13c");
3435 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M13d");
3436 Assert.IsFalse (ctor is ConstructorBuilder, "#M13e");
3438 ctor = redType.GetConstructor (flags, null,
3439 Type.EmptyTypes,
3440 new ParameterModifier [0]);
3441 Assert.IsNull (ctor, "#M14");
3443 flags = BindingFlags.Static | BindingFlags.NonPublic |
3444 BindingFlags.Public;
3446 ctor = greenType.GetConstructor (flags, null,
3447 new Type [] { typeof (int), typeof (int) },
3448 new ParameterModifier [0]);
3449 Assert.IsNull (ctor, "#N1");
3451 ctor = greenType.GetConstructor (flags, null,
3452 new Type [] { typeof (string) },
3453 new ParameterModifier [0]);
3454 Assert.IsNull (ctor, "#N2");
3456 ctor = greenType.GetConstructor (flags, null,
3457 new Type [] { typeof (string), typeof (string) },
3458 new ParameterModifier [0]);
3459 Assert.IsNull (ctor, "#N3");
3461 ctor = greenType.GetConstructor (flags, null,
3462 new Type [] { typeof (int) },
3463 new ParameterModifier [0]);
3464 Assert.IsNull (ctor, "#N4");
3466 ctor = greenType.GetConstructor (flags, null,
3467 new Type [] { typeof (int), typeof (bool) },
3468 new ParameterModifier [0]);
3469 Assert.IsNull (ctor, "#N5");
3471 ctor = greenType.GetConstructor (flags, null,
3472 new Type [] { typeof (string), typeof (int) },
3473 new ParameterModifier [0]);
3474 Assert.IsNull (ctor, "#N6");
3476 ctor = greenType.GetConstructor (flags, null,
3477 Type.EmptyTypes,
3478 new ParameterModifier [0]);
3479 Assert.IsNull (ctor, "#N7");
3481 ctor = redType.GetConstructor (flags, null,
3482 new Type [] { typeof (int), typeof (int) },
3483 new ParameterModifier [0]);
3484 Assert.IsNull (ctor, "#N8");
3486 ctor = redType.GetConstructor (flags, null,
3487 new Type [] { typeof (string) },
3488 new ParameterModifier [0]);
3489 Assert.IsNull (ctor, "#N9");
3491 ctor = redType.GetConstructor (flags, null,
3492 new Type [] { typeof (string), typeof (string) },
3493 new ParameterModifier [0]);
3494 Assert.IsNull (ctor, "#N10");
3496 ctor = redType.GetConstructor (flags, null,
3497 new Type [] { typeof (int) },
3498 new ParameterModifier [0]);
3499 Assert.IsNull (ctor, "#N11");
3501 ctor = redType.GetConstructor (flags, null,
3502 new Type [] { typeof (int), typeof (bool) },
3503 new ParameterModifier [0]);
3504 Assert.IsNull (ctor, "#N12");
3506 ctor = redType.GetConstructor (flags, null,
3507 new Type [] { typeof (string), typeof (int) },
3508 new ParameterModifier [0]);
3509 Assert.IsNull (ctor, "#N13");
3511 ctor = redType.GetConstructor (flags, null,
3512 Type.EmptyTypes,
3513 new ParameterModifier [0]);
3514 Assert.IsNotNull (ctor, "#N14a");
3515 Assert.IsTrue (ctor.IsPrivate, "#N14b");
3516 Assert.IsTrue (ctor.IsStatic, "#N14c");
3517 Assert.AreEqual (0, ctor.GetParameters ().Length, "#N14d");
3518 Assert.IsFalse (ctor is ConstructorBuilder, "#N14e");
3521 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
3522 public void GetConstructor2_Incomplete ()
3524 TypeBuilder tb = module.DefineType (genTypeName ());
3525 ConstructorBuilder cb = tb.DefineConstructor (
3526 MethodAttributes.Public,
3527 CallingConventions.Standard,
3528 Type.EmptyTypes);
3529 cb.GetILGenerator ().Emit (OpCodes.Ret);
3531 try {
3532 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3533 null, Type.EmptyTypes, new ParameterModifier [0]);
3534 Assert.Fail ("#1");
3535 } catch (NotSupportedException ex) {
3536 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3537 Assert.IsNull (ex.InnerException, "#3");
3538 Assert.IsNotNull (ex.Message, "#4");
3542 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
3543 public void GetConstructor3_Incomplete ()
3545 TypeBuilder tb = module.DefineType (genTypeName ());
3546 ConstructorBuilder cb = tb.DefineConstructor (
3547 MethodAttributes.Public,
3548 CallingConventions.Standard,
3549 Type.EmptyTypes);
3550 cb.GetILGenerator ().Emit (OpCodes.Ret);
3552 try {
3553 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3554 null, CallingConventions.Standard, Type.EmptyTypes,
3555 new ParameterModifier [0]);
3556 Assert.Fail ("#1");
3557 } catch (NotSupportedException ex) {
3558 // The invoked member is not supported in a
3559 // dynamic module
3560 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3561 Assert.IsNull (ex.InnerException, "#3");
3562 Assert.IsNotNull (ex.Message, "#4");
3566 [Test] // GetConstructors ()
3567 [Category ("NotWorking")] // mcs depends on this
3568 public void GetConstructors1_Incomplete ()
3570 TypeBuilder tb = module.DefineType (genTypeName ());
3571 ConstructorBuilder cb = tb.DefineConstructor (
3572 MethodAttributes.Public,
3573 CallingConventions.Standard,
3574 Type.EmptyTypes);
3575 cb.GetILGenerator ().Emit (OpCodes.Ret);
3577 try {
3578 tb.GetConstructors ();
3579 Assert.Fail ("#1");
3580 } catch (NotSupportedException ex) {
3581 // The invoked member is not supported in a
3582 // dynamic module
3583 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3584 Assert.IsNull (ex.InnerException, "#3");
3585 Assert.IsNotNull (ex.Message, "#4");
3589 [Test] // GetConstructors (BindingFlags)
3590 public void GetConstructors2_Complete ()
3592 BindingFlags flags;
3593 ConstructorInfo [] ctors;
3595 TypeBuilder redType = module.DefineType (genTypeName (),
3596 TypeAttributes.Public);
3597 CreateMembers (redType, "Red", true);
3599 TypeBuilder greenType = module.DefineType (genTypeName (),
3600 TypeAttributes.Public, redType);
3601 CreateMembers (greenType, "Green", false);
3602 ConstructorBuilder cb = greenType.DefineConstructor (
3603 MethodAttributes.Public,
3604 CallingConventions.Standard,
3605 Type.EmptyTypes);
3606 cb.GetILGenerator ().Emit (OpCodes.Ret);
3608 redType.CreateType ();
3609 greenType.CreateType ();
3611 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3613 ctors = greenType.GetConstructors (flags);
3614 Assert.AreEqual (0, ctors.Length, "#A1");
3616 ctors = redType.GetConstructors (flags);
3617 Assert.AreEqual (5, ctors.Length, "#A2");
3618 Assert.IsTrue (ctors [0].IsPrivate, "#A3a");
3619 Assert.IsFalse (ctors [0].IsStatic, "#A3b");
3620 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#A3c");
3621 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#A3d");
3622 Assert.IsTrue (ctors [1].IsFamily, "#A4a");
3623 Assert.IsFalse (ctors [1].IsStatic, "#A4b");
3624 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#A4c");
3625 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#A4d");
3626 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#A5a");
3627 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3628 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#A5c");
3629 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#A5d");
3630 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#A6a");
3631 Assert.IsFalse (ctors [3].IsStatic, "#A6b");
3632 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#A6c");
3633 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#A6d");
3634 Assert.IsTrue (ctors [4].IsAssembly, "#A7a");
3635 Assert.IsFalse (ctors [4].IsStatic, "#A7b");
3636 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#A7c");
3637 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#A7d");
3639 flags = BindingFlags.Instance | BindingFlags.Public;
3641 ctors = greenType.GetConstructors (flags);
3642 Assert.AreEqual (1, ctors.Length, "#B1");
3643 Assert.IsTrue (ctors [0].IsPublic, "#B2a");
3644 Assert.IsFalse (ctors [0].IsStatic, "#B2b");
3645 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#B2c");
3646 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B2d");
3648 ctors = redType.GetConstructors (flags);
3649 Assert.AreEqual (1, ctors.Length, "#B3");
3650 Assert.IsTrue (ctors [0].IsPublic, "#B4a");
3651 Assert.IsFalse (ctors [0].IsStatic, "#B4b");
3652 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#B4c");
3653 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B4d");
3655 flags = BindingFlags.Static | BindingFlags.Public;
3657 ctors = greenType.GetConstructors (flags);
3658 Assert.AreEqual (0, ctors.Length, "#C1");
3660 ctors = redType.GetConstructors (flags);
3661 Assert.AreEqual (0, ctors.Length, "#C2");
3663 flags = BindingFlags.Static | BindingFlags.NonPublic;
3665 ctors = greenType.GetConstructors (flags);
3666 Assert.AreEqual (0, ctors.Length, "#D1");
3668 ctors = redType.GetConstructors (flags);
3669 Assert.AreEqual (1, ctors.Length, "#D2");
3670 Assert.IsTrue (ctors [0].IsPrivate, "#D3a");
3671 Assert.IsTrue (ctors [0].IsStatic, "#D3b");
3672 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#D3c");
3673 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#D3d");
3675 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3676 BindingFlags.FlattenHierarchy;
3678 ctors = greenType.GetConstructors (flags);
3679 Assert.AreEqual (0, ctors.Length, "#E1");
3681 ctors = redType.GetConstructors (flags);
3682 Assert.AreEqual (5, ctors.Length, "#E2");
3683 Assert.IsTrue (ctors [0].IsPrivate, "#E3a");
3684 Assert.IsFalse (ctors [0].IsStatic, "#E3b");
3685 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#E3c");
3686 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#E3d");
3687 Assert.IsTrue (ctors [1].IsFamily, "#E4a");
3688 Assert.IsFalse (ctors [1].IsStatic, "#E4b");
3689 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#E4c");
3690 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#E4d");
3691 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#E5a");
3692 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3693 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#E5c");
3694 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#E5d");
3695 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#E6a");
3696 Assert.IsFalse (ctors [3].IsStatic, "#E6b");
3697 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#E6c");
3698 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#E6d");
3699 Assert.IsTrue (ctors [4].IsAssembly, "#E7a");
3700 Assert.IsFalse (ctors [4].IsStatic, "#E7b");
3701 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#E7c");
3702 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#E7d");
3704 flags = BindingFlags.Instance | BindingFlags.Public |
3705 BindingFlags.FlattenHierarchy;
3707 ctors = greenType.GetConstructors (flags);
3708 Assert.AreEqual (1, ctors.Length, "#F1");
3709 Assert.IsTrue (ctors [0].IsPublic, "#F2a");
3710 Assert.IsFalse (ctors [0].IsStatic, "#F2b");
3711 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#F2c");
3712 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F2d");
3714 ctors = redType.GetConstructors (flags);
3715 Assert.AreEqual (1, ctors.Length, "#F3");
3716 Assert.IsTrue (ctors [0].IsPublic, "#F4a");
3717 Assert.IsFalse (ctors [0].IsStatic, "#F4b");
3718 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#F4c");
3719 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F4d");
3721 flags = BindingFlags.Static | BindingFlags.Public |
3722 BindingFlags.FlattenHierarchy;
3724 ctors = greenType.GetConstructors (flags);
3725 Assert.AreEqual (0, ctors.Length, "#G1");
3727 ctors = redType.GetConstructors (flags);
3728 Assert.AreEqual (0, ctors.Length, "#G2");
3730 flags = BindingFlags.Static | BindingFlags.NonPublic |
3731 BindingFlags.FlattenHierarchy;
3733 ctors = greenType.GetConstructors (flags);
3734 Assert.AreEqual (0, ctors.Length, "#H1");
3736 ctors = redType.GetConstructors (flags);
3737 Assert.AreEqual (1, ctors.Length, "#H2");
3738 Assert.IsTrue (ctors [0].IsPrivate, "#H3a");
3739 Assert.IsTrue (ctors [0].IsStatic, "#H3b");
3740 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#H3c");
3741 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#H3d");
3743 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3744 BindingFlags.DeclaredOnly;
3746 ctors = greenType.GetConstructors (flags);
3747 Assert.AreEqual (0, ctors.Length, "#I1");
3749 ctors = redType.GetConstructors (flags);
3750 Assert.AreEqual (5, ctors.Length, "#I2");
3751 Assert.IsTrue (ctors [0].IsPrivate, "#I3a");
3752 Assert.IsFalse (ctors [0].IsStatic, "#I3b");
3753 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#I3c");
3754 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#I3d");
3755 Assert.IsTrue (ctors [1].IsFamily, "#I4a");
3756 Assert.IsFalse (ctors [1].IsStatic, "#I4b");
3757 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#I4c");
3758 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#I4d");
3759 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#I5a");
3760 Assert.IsFalse (ctors [2].IsStatic, "#I5b");
3761 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#I5c");
3762 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#I5d");
3763 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#I6a");
3764 Assert.IsFalse (ctors [3].IsStatic, "#I6b");
3765 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#I6c");
3766 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#I6d");
3767 Assert.IsTrue (ctors [4].IsAssembly, "#I7a");
3768 Assert.IsFalse (ctors [4].IsStatic, "#I7b");
3769 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#I7c");
3770 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#I7d");
3772 flags = BindingFlags.Instance | BindingFlags.Public |
3773 BindingFlags.DeclaredOnly;
3775 ctors = greenType.GetConstructors (flags);
3776 Assert.AreEqual (1, ctors.Length, "#J1");
3777 Assert.IsTrue (ctors [0].IsPublic, "#J2a");
3778 Assert.IsFalse (ctors [0].IsStatic, "#J2b");
3779 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#J2c");
3780 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J2d");
3782 ctors = redType.GetConstructors (flags);
3783 Assert.AreEqual (1, ctors.Length, "#J3");
3784 Assert.IsTrue (ctors [0].IsPublic, "#J4a");
3785 Assert.IsFalse (ctors [0].IsStatic, "#J4b");
3786 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#J4c");
3787 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J4d");
3789 flags = BindingFlags.Static | BindingFlags.Public |
3790 BindingFlags.DeclaredOnly;
3792 ctors = greenType.GetConstructors (flags);
3793 Assert.AreEqual (0, ctors.Length, "#K1");
3795 ctors = redType.GetConstructors (flags);
3796 Assert.AreEqual (0, ctors.Length, "#K2");
3798 flags = BindingFlags.Static | BindingFlags.NonPublic |
3799 BindingFlags.DeclaredOnly;
3801 ctors = greenType.GetConstructors (flags);
3802 Assert.AreEqual (0, ctors.Length, "#L1");
3804 ctors = redType.GetConstructors (flags);
3805 Assert.AreEqual (1, ctors.Length, "#L2");
3806 Assert.IsTrue (ctors [0].IsPrivate, "#L3a");
3807 Assert.IsTrue (ctors [0].IsStatic, "#L3b");
3808 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#L3c");
3809 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#L3d");
3811 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3812 BindingFlags.Public;
3814 ctors = greenType.GetConstructors (flags);
3815 Assert.AreEqual (1, ctors.Length, "#M1");
3816 Assert.IsTrue (ctors [0].IsPublic, "#M2a");
3817 Assert.IsFalse (ctors [0].IsStatic, "#M2b");
3818 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#M2c");
3819 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M2d");
3821 ctors = redType.GetConstructors (flags);
3822 Assert.AreEqual (6, ctors.Length, "#M3");
3823 Assert.IsTrue (ctors [0].IsPrivate, "#M4a");
3824 Assert.IsFalse (ctors [0].IsStatic, "#M4b");
3825 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#M4c");
3826 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M4d");
3827 Assert.IsTrue (ctors [1].IsFamily, "#M5a");
3828 Assert.IsFalse (ctors [1].IsStatic, "#M5b");
3829 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#M5c");
3830 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#M5d");
3831 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#M6a");
3832 Assert.IsFalse (ctors [2].IsStatic, "#M6b");
3833 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#M6c");
3834 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#M6d");
3835 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#M7a");
3836 Assert.IsFalse (ctors [3].IsStatic, "#M7b");
3837 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#M7c");
3838 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#M7d");
3839 Assert.IsTrue (ctors [4].IsPublic, "#M8a");
3840 Assert.IsFalse (ctors [4].IsStatic, "#M8b");
3841 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#M8c");
3842 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#M8d");
3843 Assert.IsTrue (ctors [5].IsAssembly, "#M9a");
3844 Assert.IsFalse (ctors [5].IsStatic, "#M9b");
3845 Assert.AreEqual (2, ctors [5].GetParameters ().Length, "#M9c");
3846 Assert.IsFalse (ctors [5] is ConstructorBuilder, "#M9d");
3848 flags = BindingFlags.Static | BindingFlags.NonPublic |
3849 BindingFlags.Public;
3851 ctors = greenType.GetConstructors (flags);
3852 Assert.AreEqual (0, ctors.Length, "#N1");
3854 ctors = redType.GetConstructors (flags);
3855 Assert.AreEqual (1, ctors.Length, "#N2");
3856 Assert.IsTrue (ctors [0].IsPrivate, "#N3a");
3857 Assert.IsTrue (ctors [0].IsStatic, "#N3b");
3858 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#N3c");
3859 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#N3d");
3862 [Test] // GetConstructors (BindingFlags)
3863 [Category ("NotWorking")] // mcs depends on this
3864 public void GetConstructors2_Incomplete ()
3866 TypeBuilder tb = module.DefineType (genTypeName ());
3867 ConstructorBuilder cb = tb.DefineConstructor (
3868 MethodAttributes.Public,
3869 CallingConventions.Standard,
3870 Type.EmptyTypes);
3871 cb.GetILGenerator ().Emit (OpCodes.Ret);
3873 try {
3874 tb.GetConstructors (BindingFlags.Public |
3875 BindingFlags.Instance);
3876 Assert.Fail ("#1");
3877 } catch (NotSupportedException ex) {
3878 // The invoked member is not supported in a
3879 // dynamic module
3880 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3881 Assert.IsNull (ex.InnerException, "#3");
3882 Assert.IsNotNull (ex.Message, "#4");
3886 [Test]
3887 public void TestGetCustomAttributesIncomplete ()
3889 TypeBuilder tb = module.DefineType (genTypeName ());
3890 try {
3891 tb.GetCustomAttributes (false);
3892 Assert.Fail ("#1");
3893 } catch (NotSupportedException ex) {
3894 // The invoked member is not supported in a
3895 // dynamic module
3896 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3897 Assert.IsNull (ex.InnerException, "#3");
3898 Assert.IsNotNull (ex.Message, "#4");
3902 [Test]
3903 public void TestGetCustomAttributesComplete ()
3905 TypeBuilder tb = module.DefineType (genTypeName ());
3907 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3908 new Type [] { typeof (string) });
3910 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3911 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3913 tb.SetCustomAttribute (caBuilder);
3914 tb.CreateType ();
3916 Assert.AreEqual (1, tb.GetCustomAttributes (false).Length);
3919 [Test]
3920 public void TestGetCustomAttributesOfTypeIncomplete ()
3922 TypeBuilder tb = module.DefineType (genTypeName ());
3923 try {
3924 tb.GetCustomAttributes (typeof (ObsoleteAttribute), false);
3925 Assert.Fail ("#1");
3926 } catch (NotSupportedException ex) {
3927 // The invoked member is not supported in a
3928 // dynamic module
3929 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3930 Assert.IsNull (ex.InnerException, "#3");
3931 Assert.IsNotNull (ex.Message, "#4");
3935 [Test]
3936 public void TestGetCustomAttributesOfTypeComplete ()
3938 TypeBuilder tb = module.DefineType (genTypeName ());
3940 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3941 new Type [] { typeof (string) });
3943 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3944 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3946 tb.SetCustomAttribute (caBuilder);
3947 tb.CreateType ();
3949 Assert.AreEqual (1, tb.GetCustomAttributes (typeof (GuidAttribute), false).Length, "#1");
3950 Assert.AreEqual (0, tb.GetCustomAttributes (typeof (ObsoleteAttribute), false).Length, "#2");
3953 [Test]
3954 public void TestGetCustomAttributesOfNullTypeComplete ()
3956 TypeBuilder tb = module.DefineType (genTypeName ());
3957 tb.CreateType ();
3958 try {
3959 tb.GetCustomAttributes (null, false);
3960 Assert.Fail ("#1");
3961 } catch (ArgumentNullException ex) {
3962 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
3963 Assert.IsNull (ex.InnerException, "#3");
3964 Assert.IsNotNull (ex.Message, "#4");
3965 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
3969 [Test]
3970 [Ignore ("mcs depends on this")]
3971 public void TestGetEventsIncomplete ()
3973 TypeBuilder tb = module.DefineType (genTypeName ());
3974 try {
3975 tb.GetEvents ();
3976 Assert.Fail ("#1");
3977 } catch (NotSupportedException ex) {
3978 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3979 Assert.IsNull (ex.InnerException, "#3");
3980 Assert.IsNotNull (ex.Message, "#4");
3981 throw;
3985 [Test]
3986 public void TestGetEventsComplete ()
3988 TypeBuilder tb = module.DefineType (genTypeName ());
3990 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3991 typeof (void), new Type [] { typeof (Object) });
3992 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
3994 // create public event
3995 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
3996 typeof (ResolveEventHandler));
3997 eventbuilder.SetRaiseMethod (onclickMethod);
3999 Type emittedType = tb.CreateType ();
4001 Assert.AreEqual (1, tb.GetEvents ().Length, "#1");
4002 Assert.AreEqual (tb.GetEvents ().Length, emittedType.GetEvents ().Length, "#2");
4006 [Test]
4007 [Ignore ("mcs depends on this")]
4008 public void TestGetEventsFlagsIncomplete ()
4010 TypeBuilder tb = module.DefineType (genTypeName ());
4011 try {
4012 tb.GetEvents (BindingFlags.Public);
4013 Assert.Fail ("#1");
4014 } catch (NotSupportedException ex) {
4015 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4016 Assert.IsNull (ex.InnerException, "#3");
4017 Assert.IsNotNull (ex.Message, "#4");
4018 throw;
4022 [Test]
4023 public void TestGetEventsFlagsComplete ()
4025 TypeBuilder tb = module.DefineType (genTypeName ());
4027 MethodBuilder onchangeMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4028 typeof (void), new Type [] { typeof (Object) });
4029 onchangeMethod.GetILGenerator ().Emit (OpCodes.Ret);
4031 // create public event
4032 EventBuilder changeEvent = tb.DefineEvent ("Change", EventAttributes.None,
4033 typeof (ResolveEventHandler));
4034 changeEvent.SetRaiseMethod (onchangeMethod);
4036 // create non-public event
4037 EventBuilder redoChangeEvent = tb.DefineEvent ("RedoChange", EventAttributes.None,
4038 typeof (ResolveEventHandler));
4040 Type emittedType = tb.CreateType ();
4042 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
4043 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4044 Assert.AreEqual (2, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
4045 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length,
4046 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
4047 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length,
4048 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4049 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length,
4050 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
4053 [Test]
4054 public void TestGetEventsFlagsComplete_Inheritance ()
4056 EventInfo [] events;
4057 BindingFlags flags;
4059 TypeBuilder blueType = module.DefineType (genTypeName (),
4060 TypeAttributes.Public);
4061 CreateMembers (blueType, "Blue", false);
4063 TypeBuilder redType = module.DefineType (genTypeName (),
4064 TypeAttributes.Public, blueType);
4065 CreateMembers (redType, "Red", false);
4067 TypeBuilder greenType = module.DefineType (genTypeName (),
4068 TypeAttributes.Public, redType);
4069 CreateMembers (greenType, "Green", false);
4071 blueType.CreateType ();
4072 redType.CreateType ();
4073 greenType.CreateType ();
4075 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4076 events = greenType.GetEvents (flags);
4078 Assert.AreEqual (13, events.Length, "#A1");
4079 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#A2");
4080 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#A3");
4081 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#A4");
4082 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#A5");
4083 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#A6");
4084 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#A7");
4085 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#A8");
4086 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#A9");
4087 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#A10");
4088 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#A11");
4089 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#A12");
4090 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#A13");
4091 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#A14");
4093 flags = BindingFlags.Instance | BindingFlags.Public;
4094 events = greenType.GetEvents (flags);
4096 Assert.AreEqual (3, events.Length, "#B1");
4097 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#B2");
4098 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#B3");
4099 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#B4");
4101 flags = BindingFlags.Static | BindingFlags.Public;
4102 events = greenType.GetEvents (flags);
4104 Assert.AreEqual (1, events.Length, "#C1");
4105 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#C2");
4107 flags = BindingFlags.Static | BindingFlags.NonPublic;
4108 events = greenType.GetEvents (flags);
4110 Assert.AreEqual (5, events.Length, "#D1");
4111 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#D2");
4112 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#D3");
4113 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#D4");
4114 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#D5");
4115 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#D6");
4117 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4118 BindingFlags.FlattenHierarchy;
4119 events = greenType.GetEvents (flags);
4121 Assert.AreEqual (13, events.Length, "#E1");
4122 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#E2");
4123 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#E3");
4124 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#E4");
4125 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#E5");
4126 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#E6");
4127 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#E7");
4128 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#E8");
4129 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#E9");
4130 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#E10");
4131 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#E11");
4132 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#E12");
4133 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#E13");
4134 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#E14");
4136 flags = BindingFlags.Instance | BindingFlags.Public |
4137 BindingFlags.FlattenHierarchy;
4138 events = greenType.GetEvents (flags);
4140 Assert.AreEqual (3, events.Length, "#F1");
4141 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#F2");
4142 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#F3");
4143 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#F4");
4145 flags = BindingFlags.Static | BindingFlags.Public |
4146 BindingFlags.FlattenHierarchy;
4147 events = greenType.GetEvents (flags);
4149 Assert.AreEqual (3, events.Length, "#G1");
4150 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#G2");
4151 Assert.AreEqual ("OnPublicStaticRed", events [1].Name, "#G3");
4152 Assert.AreEqual ("OnPublicStaticBlue", events [2].Name, "#G4");
4154 flags = BindingFlags.Static | BindingFlags.NonPublic |
4155 BindingFlags.FlattenHierarchy;
4156 events = greenType.GetEvents (flags);
4158 Assert.AreEqual (13, events.Length, "#H1");
4159 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#H2");
4160 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#H3");
4161 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#H4");
4162 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#H5");
4163 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#H6");
4164 Assert.AreEqual ("OnFamilyStaticRed", events [5].Name, "#H7");
4165 Assert.AreEqual ("OnFamANDAssemStaticRed", events [6].Name, "#H8");
4166 Assert.AreEqual ("OnFamORAssemStaticRed", events [7].Name, "#H9");
4167 Assert.AreEqual ("OnAssemblyStaticRed", events [8].Name, "#H10");
4168 Assert.AreEqual ("OnFamilyStaticBlue", events [9].Name, "#H11");
4169 Assert.AreEqual ("OnFamANDAssemStaticBlue", events [10].Name, "#H12");
4170 Assert.AreEqual ("OnFamORAssemStaticBlue", events [11].Name, "#H13");
4171 Assert.AreEqual ("OnAssemblyStaticBlue", events [12].Name, "#H14");
4173 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4174 BindingFlags.DeclaredOnly;
4175 events = greenType.GetEvents (flags);
4177 Assert.AreEqual (5, events.Length, "#I1");
4178 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#I2");
4179 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#I3");
4180 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#I4");
4181 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#I5");
4182 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#I6");
4184 flags = BindingFlags.Instance | BindingFlags.Public |
4185 BindingFlags.DeclaredOnly;
4186 events = greenType.GetEvents (flags);
4188 Assert.AreEqual (1, events.Length, "#J1");
4189 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#J2");
4191 flags = BindingFlags.Static | BindingFlags.Public |
4192 BindingFlags.DeclaredOnly;
4193 events = greenType.GetEvents (flags);
4195 Assert.AreEqual (1, events.Length, "#K1");
4196 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#K2");
4198 flags = BindingFlags.Static | BindingFlags.NonPublic |
4199 BindingFlags.DeclaredOnly;
4200 events = greenType.GetEvents (flags);
4202 Assert.AreEqual (5, events.Length, "#L1");
4203 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#L2");
4204 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#L3");
4205 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#L4");
4206 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#L5");
4207 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#L6");
4209 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4210 BindingFlags.Public;
4211 events = greenType.GetEvents (flags);
4213 Assert.AreEqual (16, events.Length, "#M1");
4214 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#M2");
4215 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#M3");
4216 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#M4");
4217 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#M5");
4218 Assert.AreEqual ("OnPublicInstanceGreen", events [4].Name, "#M6");
4219 Assert.AreEqual ("OnAssemblyInstanceGreen", events [5].Name, "#M7");
4220 Assert.AreEqual ("OnFamilyInstanceRed", events [6].Name, "#M8");
4221 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [7].Name, "#M9");
4222 Assert.AreEqual ("OnFamORAssemInstanceRed", events [8].Name, "#M10");
4223 Assert.AreEqual ("OnPublicInstanceRed", events [9].Name, "#M11");
4224 Assert.AreEqual ("OnAssemblyInstanceRed", events [10].Name, "#M12");
4225 Assert.AreEqual ("OnFamilyInstanceBlue", events [11].Name, "#M13");
4226 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [12].Name, "#M14");
4227 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [13].Name, "#M15");
4228 Assert.AreEqual ("OnPublicInstanceBlue", events [14].Name, "#M16");
4229 Assert.AreEqual ("OnAssemblyInstanceBlue", events [15].Name, "#M17");
4231 flags = BindingFlags.Static | BindingFlags.NonPublic |
4232 BindingFlags.Public;
4233 events = greenType.GetEvents (flags);
4235 Assert.AreEqual (6, events.Length, "#N1");
4236 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#N2");
4237 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#N3");
4238 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#N4");
4239 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#N5");
4240 Assert.AreEqual ("OnPublicStaticGreen", events [4].Name, "#N6");
4241 Assert.AreEqual ("OnAssemblyStaticGreen", events [5].Name, "#N7");
4244 [Test]
4245 [Ignore ("mcs depends on this")]
4246 public void TestGetEventIncomplete ()
4248 TypeBuilder tb = module.DefineType (genTypeName ());
4249 try {
4250 tb.GetEvent ("FOO");
4251 Assert.Fail ("#1");
4252 } catch (NotSupportedException ex) {
4253 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4254 Assert.IsNull (ex.InnerException, "#3");
4255 Assert.IsNotNull (ex.Message, "#4");
4256 throw;
4260 [Test]
4261 public void TestGetEventComplete ()
4263 TypeBuilder tb = module.DefineType (genTypeName ());
4265 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4266 typeof (void), new Type [] { typeof (Object) });
4267 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4269 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4270 typeof (ResolveEventHandler));
4271 eventbuilder.SetRaiseMethod (onclickMethod);
4273 Type emittedType = tb.CreateType ();
4275 Assert.IsNotNull (tb.GetEvent ("Change"));
4276 Assert.AreEqual (tb.GetEvent ("Change"), emittedType.GetEvent ("Change"));
4277 Assert.IsNull (tb.GetEvent ("NotChange"));
4278 Assert.AreEqual (tb.GetEvent ("NotChange"), emittedType.GetEvent ("NotChange"));
4281 [Test]
4282 [Ignore ("mcs depends on this")]
4283 public void TestGetEventFlagsIncomplete ()
4285 TypeBuilder tb = module.DefineType (genTypeName ());
4286 try {
4287 tb.GetEvent ("FOO", BindingFlags.Public);
4288 Assert.Fail ("#1");
4289 } catch (NotSupportedException ex) {
4290 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4291 Assert.IsNull (ex.InnerException, "#3");
4292 Assert.IsNotNull (ex.Message, "#4");
4293 throw;
4297 [Test]
4298 public void TestGetEventFlagsComplete ()
4300 TypeBuilder tb = module.DefineType (genTypeName ());
4302 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4303 typeof (void), new Type [] { typeof (Object) });
4304 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4306 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4307 typeof (ResolveEventHandler));
4308 eventbuilder.SetRaiseMethod (onclickMethod);
4310 Type emittedType = tb.CreateType ();
4312 Assert.IsNotNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4313 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public),
4314 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4315 Assert.IsNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4316 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic),
4317 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4320 [Test]
4321 public void TestGetEventFlagsComplete_Inheritance ()
4323 BindingFlags flags;
4325 TypeBuilder blueType = module.DefineType (genTypeName (),
4326 TypeAttributes.Public);
4327 CreateMembers (blueType, "Blue", false);
4329 TypeBuilder redType = module.DefineType (genTypeName (),
4330 TypeAttributes.Public, blueType);
4331 CreateMembers (redType, "Red", false);
4333 TypeBuilder greenType = module.DefineType (genTypeName (),
4334 TypeAttributes.Public, redType);
4335 CreateMembers (greenType, "Green", false);
4337 blueType.CreateType ();
4338 redType.CreateType ();
4339 greenType.CreateType ();
4341 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4343 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#A1");
4344 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#A2");
4345 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#A3");
4346 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#A4");
4347 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#A5");
4348 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#A6");
4349 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#A7");
4350 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#A8");
4351 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#A9");
4352 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#A10");
4353 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#A11");
4354 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#A12");
4355 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#A13");
4356 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#A14");
4357 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#A15");
4358 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#A16");
4359 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#A17");
4360 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#A18");
4361 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#A19");
4362 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#A20");
4363 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#A21");
4364 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#A22");
4365 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#A23");
4366 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#A24");
4367 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#A25");
4368 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#A26");
4369 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#A27");
4370 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#A28");
4371 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#A29");
4372 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#A30");
4373 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#A31");
4374 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#A32");
4375 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#A33");
4376 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#A34");
4377 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#A35");
4378 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#A36");
4380 flags = BindingFlags.Instance | BindingFlags.Public;
4382 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#B1");
4383 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#B2");
4384 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#B3");
4385 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#B4");
4386 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#B5");
4387 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#B6");
4388 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#B7");
4389 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#B8");
4390 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#B9");
4391 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#B10");
4392 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#B11");
4393 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#B12");
4394 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#B13");
4395 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#B14");
4396 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#B15");
4397 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#B16");
4398 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#B17");
4399 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#B18");
4400 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#B19");
4401 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#B20");
4402 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#B21");
4403 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#B22");
4404 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#B23");
4405 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#B24");
4406 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#B25");
4407 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#B26");
4408 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#B27");
4409 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#B28");
4410 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#B29");
4411 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#B30");
4412 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#B31");
4413 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#B32");
4414 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#B33");
4415 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#B34");
4416 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#B35");
4417 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#B36");
4419 flags = BindingFlags.Static | BindingFlags.Public;
4421 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#C1");
4422 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#C2");
4423 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#C3");
4424 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#C4");
4425 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#C5");
4426 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#C6");
4427 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#C7");
4428 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#C8");
4429 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#C9");
4430 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#C10");
4431 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#C11");
4432 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#C12");
4433 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#C13");
4434 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#C14");
4435 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#C15");
4436 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#C16");
4437 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#C17");
4438 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#C18");
4439 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#C19");
4440 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#C20");
4441 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#C21");
4442 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#C22");
4443 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#C23");
4444 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#C24");
4445 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#C25");
4446 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#C26");
4447 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#C27");
4448 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#C28");
4449 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#C29");
4450 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#C30");
4451 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#C31");
4452 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#C32");
4453 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#C33");
4454 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#C34");
4455 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#C35");
4456 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#C36");
4458 flags = BindingFlags.Static | BindingFlags.NonPublic;
4460 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#D1");
4461 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#D2");
4462 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#D3");
4463 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#D4");
4464 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#D5");
4465 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#D6");
4466 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#D7");
4467 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#D8");
4468 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#D9");
4469 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#D10");
4470 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#D11");
4471 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#D12");
4472 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#D13");
4473 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#D14");
4474 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#D15");
4475 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#D16");
4476 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#D17");
4477 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#D18");
4478 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#D19");
4479 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#D20");
4480 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#D21");
4481 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#D22");
4482 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#D23");
4483 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#D24");
4484 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#D25");
4485 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#D26");
4486 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#D27");
4487 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#D28");
4488 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#D29");
4489 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#D30");
4490 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#D31");
4491 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#D32");
4492 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#D33");
4493 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#D34");
4494 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#D35");
4495 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#D36");
4497 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4498 BindingFlags.FlattenHierarchy;
4500 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#E1");
4501 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#E2");
4502 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#E3");
4503 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#E4");
4504 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#E5");
4505 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#E6");
4506 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#E7");
4507 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#E8");
4508 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#E9");
4509 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#E10");
4510 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#E11");
4511 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#E12");
4512 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#E13");
4513 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#E14");
4514 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#E15");
4515 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#E16");
4516 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#E17");
4517 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#E18");
4518 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#E19");
4519 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#E20");
4520 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#E21");
4521 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#E22");
4522 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#E23");
4523 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#E24");
4524 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#E25");
4525 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#E26");
4526 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#E27");
4527 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#E28");
4528 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#E29");
4529 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#E30");
4530 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#E31");
4531 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#E32");
4532 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#E33");
4533 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#E34");
4534 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#E35");
4535 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#E36");
4537 flags = BindingFlags.Instance | BindingFlags.Public |
4538 BindingFlags.FlattenHierarchy;
4540 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#F1");
4541 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#F2");
4542 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#F3");
4543 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#F4");
4544 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#F5");
4545 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#F6");
4546 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#F7");
4547 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#F8");
4548 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#F9");
4549 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#F10");
4550 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#F11");
4551 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#F12");
4552 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#F13");
4553 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#F14");
4554 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#F15");
4555 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#F16");
4556 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#F17");
4557 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#F18");
4558 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#F19");
4559 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#F20");
4560 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#F21");
4561 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#F22");
4562 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#F23");
4563 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#F24");
4564 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#F25");
4565 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#F26");
4566 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#F27");
4567 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#F28");
4568 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#F29");
4569 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#F30");
4570 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#F31");
4571 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#F32");
4572 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#F33");
4573 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#F34");
4574 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#F35");
4575 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#F36");
4577 flags = BindingFlags.Static | BindingFlags.Public |
4578 BindingFlags.FlattenHierarchy;
4580 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#G1");
4581 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#G2");
4582 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#G3");
4583 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#G4");
4584 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#G5");
4585 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#G6");
4586 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#G7");
4587 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#G8");
4588 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#G9");
4589 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#G10");
4590 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#G11");
4591 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#G12");
4592 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#G13");
4593 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#G14");
4594 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#G15");
4595 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#G16");
4596 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#G17");
4597 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#G18");
4598 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#G19");
4599 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#G20");
4600 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#G21");
4601 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#G22");
4602 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#G23");
4603 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#G24");
4604 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#G25");
4605 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#G26");
4606 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#G27");
4607 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#G28");
4608 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#G29");
4609 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#G30");
4610 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#G31");
4611 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#G32");
4612 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#G33");
4613 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#G34");
4614 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#G35");
4615 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#G36");
4617 flags = BindingFlags.Static | BindingFlags.NonPublic |
4618 BindingFlags.FlattenHierarchy;
4620 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#H1");
4621 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#H2");
4622 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#H3");
4623 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#H4");
4624 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#H5");
4625 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#H6");
4626 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#H7");
4627 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#H8");
4628 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#H9");
4629 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#H10");
4630 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#H11");
4631 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#H12");
4632 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#H13");
4633 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#H14");
4634 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#H15");
4635 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#H16");
4636 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#H17");
4637 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#H18");
4638 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#H19");
4639 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#H20");
4640 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#H21");
4641 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#H22");
4642 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#H23");
4643 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#H24");
4644 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#H25");
4645 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#H26");
4646 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#H27");
4647 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#H28");
4648 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#H29");
4649 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#H30");
4650 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#H31");
4651 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#H32");
4652 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#H33");
4653 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#H34");
4654 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#H35");
4655 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#H36");
4657 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4658 BindingFlags.DeclaredOnly;
4660 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#I1");
4661 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#I2");
4662 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#I3");
4663 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#I4");
4664 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#I5");
4665 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#I6");
4666 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#I7");
4667 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#I8");
4668 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#I9");
4669 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#I10");
4670 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#I11");
4671 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#I12");
4672 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#I13");
4673 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#I14");
4674 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#I15");
4675 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#I16");
4676 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#I17");
4677 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#I18");
4678 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#I19");
4679 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#I20");
4680 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#I21");
4681 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#I22");
4682 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#I23");
4683 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#I24");
4684 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#I25");
4685 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#I26");
4686 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#I27");
4687 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#I28");
4688 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#I29");
4689 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#I30");
4690 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#I31");
4691 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#I32");
4692 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#I33");
4693 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#I34");
4694 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#I35");
4695 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#I36");
4697 flags = BindingFlags.Instance | BindingFlags.Public |
4698 BindingFlags.DeclaredOnly;
4700 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#J1");
4701 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#J2");
4702 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#J3");
4703 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#J4");
4704 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#J5");
4705 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#J6");
4706 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#J7");
4707 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#J8");
4708 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#J9");
4709 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#J10");
4710 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#J11");
4711 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#J12");
4712 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#J13");
4713 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#J14");
4714 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#J15");
4715 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#J16");
4716 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#J17");
4717 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#J18");
4718 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#J19");
4719 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#J20");
4720 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#J21");
4721 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#J22");
4722 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#J23");
4723 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#J24");
4724 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#J25");
4725 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#J26");
4726 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#J27");
4727 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#J28");
4728 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#J29");
4729 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#J30");
4730 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#J31");
4731 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#J32");
4732 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#J33");
4733 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#J34");
4734 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#J35");
4735 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#J36");
4737 flags = BindingFlags.Static | BindingFlags.Public |
4738 BindingFlags.DeclaredOnly;
4740 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#K1");
4741 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#K2");
4742 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#K3");
4743 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#K4");
4744 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#K5");
4745 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#K6");
4746 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#K7");
4747 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#K8");
4748 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#K9");
4749 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#K10");
4750 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#K11");
4751 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#K12");
4752 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#K13");
4753 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#K14");
4754 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#K15");
4755 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#K16");
4756 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#K17");
4757 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#K18");
4758 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#K19");
4759 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#K20");
4760 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#K21");
4761 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#K22");
4762 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#K23");
4763 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#K24");
4764 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#K25");
4765 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#K26");
4766 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#K27");
4767 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#K28");
4768 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#K29");
4769 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#K30");
4770 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#K31");
4771 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#K32");
4772 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#K33");
4773 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#K34");
4774 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#K35");
4775 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#K36");
4777 flags = BindingFlags.Static | BindingFlags.NonPublic |
4778 BindingFlags.DeclaredOnly;
4780 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#L1");
4781 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#L2");
4782 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#L3");
4783 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#L4");
4784 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#L5");
4785 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#L6");
4786 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#L7");
4787 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#L8");
4788 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#L9");
4789 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#L10");
4790 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#L11");
4791 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#L12");
4792 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#L13");
4793 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#L14");
4794 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#L15");
4795 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#L16");
4796 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#L17");
4797 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#L18");
4798 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#L19");
4799 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#L20");
4800 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#L21");
4801 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#L22");
4802 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#L23");
4803 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#L24");
4804 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#L25");
4805 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#L26");
4806 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#L27");
4807 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#L28");
4808 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#L29");
4809 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#L30");
4810 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#L31");
4811 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#L32");
4812 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#L33");
4813 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#L34");
4814 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#L35");
4815 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#L36");
4817 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4818 BindingFlags.Public;
4820 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#M1");
4821 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#M2");
4822 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#M3");
4823 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#M4");
4824 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#M5");
4825 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#M6");
4826 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#M7");
4827 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#M8");
4828 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#M9");
4829 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#M10");
4830 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#M11");
4831 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#M12");
4832 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#M13");
4833 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#M14");
4834 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#M15");
4835 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#M16");
4836 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#M17");
4837 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#M18");
4838 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#M19");
4839 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#M20");
4840 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#M21");
4841 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#M22");
4842 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#M23");
4843 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#M24");
4844 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#M25");
4845 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#M26");
4846 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#M27");
4847 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#M28");
4848 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#M29");
4849 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#M30");
4850 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#M31");
4851 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#M32");
4852 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#M33");
4853 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#M34");
4854 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#M35");
4855 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#M36");
4857 flags = BindingFlags.Static | BindingFlags.NonPublic |
4858 BindingFlags.Public;
4860 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#N1");
4861 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#N2");
4862 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#N3");
4863 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#N4");
4864 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#N5");
4865 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#N6");
4866 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#N7");
4867 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#N8");
4868 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#N9");
4869 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#N10");
4870 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#N11");
4871 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#N12");
4872 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#N13");
4873 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#N14");
4874 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#N15");
4875 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#N16");
4876 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#N17");
4877 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#N18");
4878 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#N19");
4879 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#N20");
4880 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#N21");
4881 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#N22");
4882 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#N23");
4883 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#N24");
4884 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#N25");
4885 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#N26");
4886 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#N27");
4887 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#N28");
4888 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#N29");
4889 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#N30");
4890 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#N31");
4891 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#N32");
4892 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#N33");
4893 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#N34");
4894 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#N35");
4895 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#N36");
4898 [Test]
4899 [Category ("NotWorking")] // mcs depends on this
4900 public void TestGetFieldsIncomplete_MS ()
4902 TypeBuilder tb = module.DefineType (genTypeName ());
4903 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4904 try {
4905 tb.GetFields ();
4906 Assert.Fail ("#1");
4907 } catch (NotSupportedException ex) {
4908 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4909 Assert.IsNull (ex.InnerException, "#3");
4910 Assert.IsNotNull (ex.Message, "#4");
4914 [Test]
4915 [Category ("NotDotNet")] // mcs depends on this
4916 public void TestGetFieldsIncomplete_Mono ()
4918 TypeBuilder tb = module.DefineType (genTypeName ());
4919 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4920 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4921 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4922 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4924 FieldInfo [] fields = tb.GetFields ();
4925 Assert.AreEqual (2, fields.Length, "#A1");
4926 Assert.AreEqual ("Sex", fields [0].Name, "#A2");
4927 Assert.AreEqual ("MALE", fields [1].Name, "#A3");
4929 #if NET_2_0
4930 tb = module.DefineType (genTypeName ());
4931 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4932 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4933 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4934 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4935 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4936 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4938 fields = tb.GetFields ();
4939 Assert.AreEqual (4, fields.Length, "#B1");
4940 Assert.AreEqual ("First", fields [0].Name, "#B2");
4941 Assert.AreEqual ("Second", fields [1].Name, "#B3");
4942 Assert.AreEqual ("Sex", fields [2].Name, "#B4");
4943 Assert.AreEqual ("MALE", fields [3].Name, "#B5");
4944 #endif
4947 [Test]
4948 public void TestGetFieldsComplete ()
4950 TypeBuilder tb = module.DefineType (genTypeName ());
4951 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4953 Type emittedType = tb.CreateType ();
4954 FieldInfo [] dynamicFields = tb.GetFields ();
4955 FieldInfo [] emittedFields = emittedType.GetFields ();
4957 Assert.AreEqual (1, dynamicFields.Length, "#A1");
4958 Assert.AreEqual (dynamicFields.Length, emittedFields.Length, "#A2");
4959 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#A3");
4960 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#A4");
4962 // bug #81638
4963 object value = Activator.CreateInstance (emittedType);
4964 emittedFields [0].SetValue (value, 5);
4965 Assert.AreEqual (5, emittedFields [0].GetValue (value), "#B1");
4966 Assert.AreEqual (5, dynamicFields [0].GetValue (value), "#B2");
4967 dynamicFields [0].SetValue (value, 4);
4968 Assert.AreEqual (4, emittedFields [0].GetValue (value), "#B3");
4969 Assert.AreEqual (4, dynamicFields [0].GetValue (value), "#B4");
4972 #if NET_2_0
4973 [Test] // bug #82625 / 325292
4974 public void TestGetFieldsComplete_Generic ()
4976 // FIXME: merge this with TestGetFieldsComplete when
4977 // bug #82625 is fixed
4979 TypeBuilder tb;
4980 Type emittedType;
4981 FieldInfo [] dynamicFields;
4982 FieldInfo [] emittedFields;
4984 tb = module.DefineType (genTypeName ());
4985 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4986 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4987 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4988 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4989 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4990 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4992 emittedType = tb.CreateType ();
4993 dynamicFields = tb.GetFields ();
4994 emittedFields = emittedType.GetFields ();
4996 Assert.AreEqual (4, dynamicFields.Length, "#C1");
4997 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#C2");
4998 Assert.IsFalse ((dynamicFields [1]) is FieldBuilder, "#C3");
4999 Assert.IsFalse ((dynamicFields [2]) is FieldBuilder, "#C4");
5000 Assert.IsFalse ((dynamicFields [3]) is FieldBuilder, "#C5");
5001 Assert.AreEqual ("First", dynamicFields [0].Name, "#C6");
5002 Assert.AreEqual ("Second", dynamicFields [1].Name, "#C7");
5003 Assert.AreEqual ("Sex", dynamicFields [2].Name, "#C8");
5004 Assert.AreEqual ("MALE", dynamicFields [3].Name, "#C9");
5006 Assert.AreEqual (4, emittedFields.Length, "#D1");
5007 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#D2");
5008 Assert.IsFalse ((emittedFields [1]) is FieldBuilder, "#D3");
5009 Assert.IsFalse ((emittedFields [2]) is FieldBuilder, "#D4");
5010 Assert.IsFalse ((emittedFields [3]) is FieldBuilder, "#D5");
5011 Assert.AreEqual ("First", emittedFields [0].Name, "#D6");
5012 Assert.AreEqual ("Second", emittedFields [1].Name, "#D7");
5013 Assert.AreEqual ("Sex", emittedFields [2].Name, "#D8");
5014 Assert.AreEqual ("MALE", emittedFields [3].Name, "#D9");
5016 #endif
5018 [Test]
5019 [Category ("NotWorking")] // mcs depends on this
5020 public void TestGetFieldsFlagsIncomplete_MS ()
5022 TypeBuilder tb = module.DefineType (genTypeName ());
5023 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5024 try {
5025 tb.GetFields (BindingFlags.Instance | BindingFlags.Public);
5026 Assert.Fail ("#1");
5027 } catch (NotSupportedException ex) {
5028 // The invoked member is not supported in a
5029 // dynamic module
5030 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5031 Assert.IsNull (ex.InnerException, "#3");
5032 Assert.IsNotNull (ex.Message, "#4");
5036 [Test]
5037 [Category ("NotDotNet")] // mcs depends on this
5038 public void TestGetFieldsFlagsIncomplete_Mono ()
5040 FieldInfo [] fields;
5042 TypeBuilder tb = module.DefineType (genTypeName ());
5043 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
5044 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
5045 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
5046 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
5048 fields = tb.GetFields (BindingFlags.Public |
5049 BindingFlags.NonPublic | BindingFlags.Instance);
5050 Assert.AreEqual (2, fields.Length, "#A1");
5051 Assert.AreEqual ("name", fields [0].Name, "#A2");
5052 Assert.AreEqual ("Sex", fields [1].Name, "#A3");
5054 fields = tb.GetFields (BindingFlags.Public |
5055 BindingFlags.Instance | BindingFlags.Static);
5056 Assert.AreEqual (2, fields.Length, "#B1");
5057 Assert.AreEqual ("Sex", fields [0].Name, "#B2");
5058 Assert.AreEqual ("MALE", fields [1].Name, "#B3");
5060 fields = tb.GetFields (BindingFlags.Public |
5061 BindingFlags.NonPublic | BindingFlags.Instance |
5062 BindingFlags.Static);
5063 Assert.AreEqual (4, fields.Length, "#C1");
5064 Assert.AreEqual ("name", fields [0].Name, "#C2");
5065 Assert.AreEqual ("Sex", fields [1].Name, "#C3");
5066 Assert.AreEqual ("MALE", fields [2].Name, "#C4");
5067 Assert.AreEqual ("FEMALE", fields [3].Name, "#C5");
5070 [Test]
5071 public void TestGetFieldsFlagsComplete ()
5073 TypeBuilder tb = module.DefineType (genTypeName ());
5074 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5076 Type emittedType = tb.CreateType ();
5078 Assert.AreEqual (1, tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
5079 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length,
5080 emittedType.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
5081 Assert.AreEqual (0, tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
5082 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length,
5083 emittedType.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
5086 [Test]
5087 public void TestGetFieldsFlagsComplete_Inheritance ()
5089 FieldInfo [] fields;
5090 BindingFlags flags;
5092 TypeBuilder blueType = module.DefineType (genTypeName (),
5093 TypeAttributes.Public);
5094 CreateMembers (blueType, "Blue", false);
5096 TypeBuilder redType = module.DefineType (genTypeName (),
5097 TypeAttributes.Public, blueType);
5098 CreateMembers (redType, "Red", false);
5100 TypeBuilder greenType = module.DefineType (genTypeName (),
5101 TypeAttributes.Public, redType);
5102 CreateMembers (greenType, "Green", false);
5104 blueType.CreateType ();
5105 redType.CreateType ();
5106 greenType.CreateType ();
5108 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5109 fields = greenType.GetFields (flags);
5111 Assert.AreEqual (13, fields.Length, "#A1");
5112 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#A2");
5113 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#A3");
5114 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#A4");
5115 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#A5");
5116 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#A6");
5117 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#A7");
5118 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#A8");
5119 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#A9");
5120 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#A10");
5121 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#A11");
5122 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#A12");
5123 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#A13");
5124 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#A14");
5126 flags = BindingFlags.Instance | BindingFlags.Public;
5127 fields = greenType.GetFields (flags);
5129 Assert.AreEqual (3, fields.Length, "#B1");
5130 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#B2");
5131 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#B3");
5132 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#B4");
5134 flags = BindingFlags.Static | BindingFlags.Public;
5135 fields = greenType.GetFields (flags);
5137 Assert.AreEqual (1, fields.Length, "#C1");
5138 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#C2");
5140 flags = BindingFlags.Static | BindingFlags.NonPublic;
5141 fields = greenType.GetFields (flags);
5143 Assert.AreEqual (5, fields.Length, "#D1");
5144 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#D2");
5145 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#D3");
5146 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#D4");
5147 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#D5");
5148 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#D6");
5150 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5151 BindingFlags.FlattenHierarchy;
5152 fields = greenType.GetFields (flags);
5154 Assert.AreEqual (13, fields.Length, "#E1");
5155 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#E2");
5156 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#E3");
5157 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#E4");
5158 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#E5");
5159 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#E6");
5160 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#E7");
5161 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#E8");
5162 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#E9");
5163 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#E10");
5164 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#E11");
5165 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#E12");
5166 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#E13");
5167 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#E14");
5169 flags = BindingFlags.Instance | BindingFlags.Public |
5170 BindingFlags.FlattenHierarchy;
5171 fields = greenType.GetFields (flags);
5173 Assert.AreEqual (3, fields.Length, "#F1");
5174 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#F2");
5175 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#F3");
5176 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#F4");
5178 flags = BindingFlags.Static | BindingFlags.Public |
5179 BindingFlags.FlattenHierarchy;
5180 fields = greenType.GetFields (flags);
5182 Assert.AreEqual (3, fields.Length, "#G1");
5183 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#G2");
5184 Assert.AreEqual ("publicStaticRed", fields [1].Name, "#G3");
5185 Assert.AreEqual ("publicStaticBlue", fields [2].Name, "#G4");
5187 flags = BindingFlags.Static | BindingFlags.NonPublic |
5188 BindingFlags.FlattenHierarchy;
5189 fields = greenType.GetFields (flags);
5191 Assert.AreEqual (13, fields.Length, "#H1");
5192 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#H2");
5193 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#H3");
5194 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#H4");
5195 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#H5");
5196 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#H6");
5197 Assert.AreEqual ("familyStaticRed", fields [5].Name, "#H7");
5198 Assert.AreEqual ("famANDAssemStaticRed", fields [6].Name, "#H8");
5199 Assert.AreEqual ("famORAssemStaticRed", fields [7].Name, "#H9");
5200 Assert.AreEqual ("assemblyStaticRed", fields [8].Name, "#H10");
5201 Assert.AreEqual ("familyStaticBlue", fields [9].Name, "#H11");
5202 Assert.AreEqual ("famANDAssemStaticBlue", fields [10].Name, "#H12");
5203 Assert.AreEqual ("famORAssemStaticBlue", fields [11].Name, "#H13");
5204 Assert.AreEqual ("assemblyStaticBlue", fields [12].Name, "#H14");
5206 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5207 BindingFlags.DeclaredOnly;
5208 fields = greenType.GetFields (flags);
5210 Assert.AreEqual (5, fields.Length, "#I1");
5211 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#I2");
5212 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#I3");
5213 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#I4");
5214 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#I5");
5215 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#I6");
5217 flags = BindingFlags.Instance | BindingFlags.Public |
5218 BindingFlags.DeclaredOnly;
5219 fields = greenType.GetFields (flags);
5221 Assert.AreEqual (1, fields.Length, "#J1");
5222 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#J2");
5224 flags = BindingFlags.Static | BindingFlags.Public |
5225 BindingFlags.DeclaredOnly;
5226 fields = greenType.GetFields (flags);
5228 Assert.AreEqual (1, fields.Length, "#K1");
5229 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#K2");
5231 flags = BindingFlags.Static | BindingFlags.NonPublic |
5232 BindingFlags.DeclaredOnly;
5233 fields = greenType.GetFields (flags);
5235 Assert.AreEqual (5, fields.Length, "#L1");
5236 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#L2");
5237 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#L3");
5238 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#L4");
5239 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#L5");
5240 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#L6");
5242 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5243 BindingFlags.Public;
5244 fields = greenType.GetFields (flags);
5246 Assert.AreEqual (16, fields.Length, "#M1");
5247 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#M2");
5248 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#M3");
5249 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#M4");
5250 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#M5");
5251 Assert.AreEqual ("publicInstanceGreen", fields [4].Name, "#M6");
5252 Assert.AreEqual ("assemblyInstanceGreen", fields [5].Name, "#M7");
5253 Assert.AreEqual ("familyInstanceRed", fields [6].Name, "#M8");
5254 Assert.AreEqual ("famANDAssemInstanceRed", fields [7].Name, "#M9");
5255 Assert.AreEqual ("famORAssemInstanceRed", fields [8].Name, "#M10");
5256 Assert.AreEqual ("publicInstanceRed", fields [9].Name, "#M11");
5257 Assert.AreEqual ("assemblyInstanceRed", fields [10].Name, "#M12");
5258 Assert.AreEqual ("familyInstanceBlue", fields [11].Name, "#M13");
5259 Assert.AreEqual ("famANDAssemInstanceBlue", fields [12].Name, "#M14");
5260 Assert.AreEqual ("famORAssemInstanceBlue", fields [13].Name, "#M15");
5261 Assert.AreEqual ("publicInstanceBlue", fields [14].Name, "#M16");
5262 Assert.AreEqual ("assemblyInstanceBlue", fields [15].Name, "#M17");
5264 flags = BindingFlags.Static | BindingFlags.NonPublic |
5265 BindingFlags.Public;
5266 fields = greenType.GetFields (flags);
5268 Assert.AreEqual (6, fields.Length, "#N1");
5269 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#N2");
5270 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#N3");
5271 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#N4");
5272 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#N5");
5273 Assert.AreEqual ("publicStaticGreen", fields [4].Name, "#N6");
5274 Assert.AreEqual ("assemblyStaticGreen", fields [5].Name, "#N7");
5277 [Test]
5278 [Category ("NotWorking")] // mcs depends on this
5279 public void TestGetFieldIncomplete_MS ()
5281 TypeBuilder tb = module.DefineType (genTypeName ());
5282 tb.DefineField ("test", typeof (int), FieldAttributes.Public);
5283 try {
5284 tb.GetField ("test");
5285 Assert.Fail ("#1");
5286 } catch (NotSupportedException ex) {
5287 // The invoked member is not supported in a
5288 // dynamic module
5289 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5290 Assert.IsNull (ex.InnerException, "#3");
5291 Assert.IsNotNull (ex.Message, "#4");
5295 [Test]
5296 [Category ("NotDotNet")] // mcs depends on this
5297 public void TestGetFieldIncomplete_Mono ()
5299 TypeBuilder tb = module.DefineType (genTypeName ());
5300 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5301 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5303 FieldInfo field = tb.GetField ("TestField");
5304 Assert.IsNotNull (field, "#A1");
5305 Assert.AreEqual ("TestField", field.Name, "#A2");
5306 Assert.IsTrue (field is FieldBuilder, "#A3");
5308 Assert.IsNull (tb.GetField ("OtherField"), "#B1");
5309 Assert.IsNull (tb.GetField ("TestOtherField"), "#B2");
5312 [Test]
5313 public void TestGetFieldComplete ()
5315 TypeBuilder tb = module.DefineType (genTypeName ());
5316 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5318 Type emittedType = tb.CreateType ();
5320 FieldInfo dynamicField = tb.GetField ("TestField");
5321 FieldInfo emittedField = emittedType.GetField ("TestField");
5322 Assert.IsNotNull (dynamicField, "#A1");
5323 Assert.AreEqual (dynamicField.Name, emittedField.Name, "#A2");
5324 Assert.IsNull (tb.GetField ("TestOtherField"), "#A3");
5325 Assert.IsFalse (emittedField is FieldBuilder, "#A4");
5326 Assert.IsFalse (dynamicField is FieldBuilder, "#A5");
5328 // bug #81638
5329 object value = Activator.CreateInstance (emittedType);
5330 emittedField.SetValue (value, 5);
5331 Assert.AreEqual (5, emittedField.GetValue (value), "#B1");
5332 Assert.AreEqual (5, dynamicField.GetValue (value), "#B2");
5333 dynamicField.SetValue (value, 4);
5334 Assert.AreEqual (4, emittedField.GetValue (value), "#B3");
5335 Assert.AreEqual (4, dynamicField.GetValue (value), "#B4");
5338 [Test] // bug #81640
5339 public void TestGetFieldComplete_Type ()
5341 TypeBuilder tb = module.DefineType (genTypeName ());
5342 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5343 Type emittedType = tb.CreateType ();
5344 FieldInfo dynamicField = tb.GetField ("TestField");
5345 Assert.IsFalse (dynamicField is FieldBuilder, "#1");
5347 object value = Activator.CreateInstance (emittedType);
5348 Assert.AreEqual (0, dynamicField.GetValue (value), "#2");
5351 [Test]
5352 [Category ("NotWorking")] // mcs depends on this
5353 public void TestGetFieldFlagsIncomplete_MS ()
5355 TypeBuilder tb = module.DefineType (genTypeName ());
5356 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5357 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5358 try {
5359 tb.GetField ("test", BindingFlags.Public);
5360 Assert.Fail ("#1");
5361 } catch (NotSupportedException ex) {
5362 // The invoked member is not supported in a
5363 // dynamic module
5364 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5365 Assert.IsNull (ex.InnerException, "#3");
5366 Assert.IsNotNull (ex.Message, "#4");
5370 [Test]
5371 [Category ("NotDotNet")] // mcs depends on this
5372 public void TestGetFieldFlagsIncomplete_Mono ()
5374 TypeBuilder tb = module.DefineType (genTypeName ());
5375 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5376 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5378 FieldInfo field = tb.GetField ("TestField", BindingFlags.Public
5379 | BindingFlags.Instance);
5380 Assert.IsNotNull (field, "#A1");
5381 Assert.AreEqual ("TestField", field.Name, "#A2");
5382 Assert.IsTrue (field is FieldBuilder, "#A3");
5384 field = tb.GetField ("OtherField", BindingFlags.NonPublic |
5385 BindingFlags.Instance);
5386 Assert.IsNotNull (field, "#B1");
5387 Assert.AreEqual ("OtherField", field.Name, "#B2");
5388 Assert.IsTrue (field is FieldBuilder, "#B3");
5390 Assert.IsNull (tb.GetField ("TestField", BindingFlags.NonPublic |
5391 BindingFlags.Instance), "#C1");
5392 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Public |
5393 BindingFlags.Static), "#C2");
5394 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5395 BindingFlags.Instance), "#C3");
5396 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5397 BindingFlags.Static), "#C4");
5398 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.NonPublic |
5399 BindingFlags.Instance), "#C5");
5400 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.Public |
5401 BindingFlags.Instance), "#C6");
5404 [Test]
5405 public void TestGetFieldFlagsComplete ()
5407 TypeBuilder tb = module.DefineType (genTypeName ());
5408 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5410 Type emittedType = tb.CreateType ();
5412 Assert.IsNotNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public));
5413 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name,
5414 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name);
5415 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5416 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic),
5417 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5420 [Test]
5421 public void TestGetFieldFlagsComplete_Inheritance ()
5423 BindingFlags flags;
5425 TypeBuilder blueType = module.DefineType (genTypeName (),
5426 TypeAttributes.Public);
5427 CreateMembers (blueType, "Blue", false);
5429 TypeBuilder redType = module.DefineType (genTypeName (),
5430 TypeAttributes.Public, blueType);
5431 CreateMembers (redType, "Red", false);
5433 TypeBuilder greenType = module.DefineType (genTypeName (),
5434 TypeAttributes.Public, redType);
5435 CreateMembers (greenType, "Green", false);
5437 blueType.CreateType ();
5438 redType.CreateType ();
5439 greenType.CreateType ();
5441 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5443 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#A1");
5444 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#A2");
5445 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#A3");
5446 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#A4");
5447 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#A5");
5448 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#A6");
5449 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#A7");
5450 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#A8");
5451 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#A9");
5452 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#A10");
5453 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#A11");
5454 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#A12");
5455 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#A13");
5456 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#A14");
5457 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#A15");
5458 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#A16");
5459 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#A17");
5460 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#A18");
5461 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#A19");
5462 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#A20");
5463 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#A21");
5464 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#A22");
5465 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#A23");
5466 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#A24");
5467 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#A25");
5468 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#A26");
5469 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#A27");
5470 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#A28");
5471 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#A29");
5472 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#A30");
5473 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#A31");
5474 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#A32");
5475 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#A33");
5476 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#A34");
5477 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#A35");
5478 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#A36");
5480 flags = BindingFlags.Instance | BindingFlags.Public;
5482 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#B1");
5483 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#B2");
5484 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#B3");
5485 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#B4");
5486 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#B5");
5487 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#B6");
5488 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#B7");
5489 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#B8");
5490 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#B9");
5491 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#B10");
5492 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#B11");
5493 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#B12");
5494 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#B13");
5495 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#B14");
5496 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#B15");
5497 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#B16");
5498 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#B17");
5499 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#B18");
5500 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#B19");
5501 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#B20");
5502 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#B21");
5503 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#B22");
5504 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#B23");
5505 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#B24");
5506 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#B25");
5507 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#B26");
5508 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#B27");
5509 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#B28");
5510 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#B29");
5511 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#B30");
5512 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#B31");
5513 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#B32");
5514 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#B33");
5515 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#B34");
5516 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#B35");
5517 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#B36");
5519 flags = BindingFlags.Static | BindingFlags.Public;
5521 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#C1");
5522 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#C2");
5523 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#C3");
5524 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#C4");
5525 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#C5");
5526 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#C6");
5527 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#C7");
5528 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#C8");
5529 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#C9");
5530 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#C10");
5531 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#C11");
5532 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#C12");
5533 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#C13");
5534 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#C14");
5535 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#C15");
5536 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#C16");
5537 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#C17");
5538 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#C18");
5539 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#C19");
5540 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#C20");
5541 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#C21");
5542 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#C22");
5543 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#C23");
5544 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#C24");
5545 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#C25");
5546 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#C26");
5547 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#C27");
5548 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#C28");
5549 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#C29");
5550 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#C30");
5551 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#C31");
5552 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#C32");
5553 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#C33");
5554 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#C34");
5555 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#C35");
5556 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#C36");
5558 flags = BindingFlags.Static | BindingFlags.NonPublic;
5560 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#D1");
5561 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#D2");
5562 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#D3");
5563 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#D4");
5564 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#D5");
5565 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#D6");
5566 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#D7");
5567 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#D8");
5568 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#D9");
5569 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#D10");
5570 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#D11");
5571 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#D12");
5572 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#D13");
5573 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#D14");
5574 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#D15");
5575 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#D16");
5576 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#D17");
5577 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#D18");
5578 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#D19");
5579 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#D20");
5580 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#D21");
5581 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#D22");
5582 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#D23");
5583 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#D24");
5584 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#D25");
5585 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#D26");
5586 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#D27");
5587 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#D28");
5588 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#D29");
5589 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#D30");
5590 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#D31");
5591 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#D32");
5592 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#D33");
5593 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#D34");
5594 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#D35");
5595 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#D36");
5597 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5598 BindingFlags.FlattenHierarchy;
5600 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#E1");
5601 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#E2");
5602 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#E3");
5603 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#E4");
5604 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#E5");
5605 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#E6");
5606 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#E7");
5607 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#E8");
5608 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#E9");
5609 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#E10");
5610 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#E11");
5611 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#E12");
5612 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#E13");
5613 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#E14");
5614 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#E15");
5615 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#E16");
5616 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#E17");
5617 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#E18");
5618 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#E19");
5619 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#E20");
5620 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#E21");
5621 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#E22");
5622 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#E23");
5623 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#E24");
5624 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#E25");
5625 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#E26");
5626 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#E27");
5627 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#E28");
5628 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#E29");
5629 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#E30");
5630 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#E31");
5631 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#E32");
5632 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#E33");
5633 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#E34");
5634 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#E35");
5635 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#E36");
5637 flags = BindingFlags.Instance | BindingFlags.Public |
5638 BindingFlags.FlattenHierarchy;
5640 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#F1");
5641 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#F2");
5642 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#F3");
5643 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#F4");
5644 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#F5");
5645 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#F6");
5646 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#F7");
5647 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#F8");
5648 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#F9");
5649 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#F10");
5650 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#F11");
5651 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#F12");
5652 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#F13");
5653 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#F14");
5654 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#F15");
5655 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#F16");
5656 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#F17");
5657 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#F18");
5658 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#F19");
5659 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#F20");
5660 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#F21");
5661 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#F22");
5662 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#F23");
5663 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#F24");
5664 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#F25");
5665 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#F26");
5666 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#F27");
5667 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#F28");
5668 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#F29");
5669 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#F30");
5670 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#F31");
5671 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#F32");
5672 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#F33");
5673 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#F34");
5674 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#F35");
5675 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#F36");
5677 flags = BindingFlags.Static | BindingFlags.Public |
5678 BindingFlags.FlattenHierarchy;
5680 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#G1");
5681 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#G2");
5682 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#G3");
5683 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#G4");
5684 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#G5");
5685 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#G6");
5686 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#G7");
5687 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#G8");
5688 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#G9");
5689 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#G10");
5690 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#G11");
5691 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#G12");
5692 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#G13");
5693 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#G14");
5694 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#G15");
5695 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#G16");
5696 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#G17");
5697 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#G18");
5698 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#G19");
5699 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#G20");
5700 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#G21");
5701 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#G22");
5702 Assert.IsNotNull (greenType.GetField ("publicStaticBlue", flags), "#G23");
5703 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#G24");
5704 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#G25");
5705 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#G26");
5706 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#G27");
5707 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#G28");
5708 Assert.IsNotNull (greenType.GetField ("publicStaticRed", flags), "#G29");
5709 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#G30");
5710 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#G31");
5711 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#G32");
5712 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#G33");
5713 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#G34");
5714 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#G35");
5715 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#G36");
5717 flags = BindingFlags.Static | BindingFlags.NonPublic |
5718 BindingFlags.FlattenHierarchy;
5720 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#H1");
5721 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#H2");
5722 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#H3");
5723 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#H4");
5724 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#H5");
5725 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#H6");
5726 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#H7");
5727 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#H8");
5728 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#H9");
5729 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#H10");
5730 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#H11");
5731 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#H12");
5732 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#H13");
5733 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#H14");
5734 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#H15");
5735 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#H16");
5736 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#H17");
5737 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#H18");
5738 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#H19");
5739 Assert.IsNotNull (greenType.GetField ("familyStaticBlue", flags), "#H20");
5740 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#H21");
5741 Assert.IsNotNull (greenType.GetField ("famORAssemStaticBlue", flags), "#H22");
5742 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#H23");
5743 Assert.IsNotNull (greenType.GetField ("assemblyStaticBlue", flags), "#H24");
5744 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#H25");
5745 Assert.IsNotNull (greenType.GetField ("familyStaticRed", flags), "#H26");
5746 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticRed", flags), "#H27");
5747 Assert.IsNotNull (greenType.GetField ("famORAssemStaticRed", flags), "#H28");
5748 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#H29");
5749 Assert.IsNotNull (greenType.GetField ("assemblyStaticRed", flags), "#H30");
5750 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#H31");
5751 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#H32");
5752 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#H33");
5753 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#H34");
5754 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#H35");
5755 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#H36");
5757 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5758 BindingFlags.DeclaredOnly;
5760 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#I1");
5761 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#I2");
5762 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#I3");
5763 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#I4");
5764 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#I5");
5765 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#I6");
5766 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#I7");
5767 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#I8");
5768 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#I9");
5769 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#I10");
5770 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#I11");
5771 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#I12");
5772 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#I13");
5773 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#I14");
5774 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#I15");
5775 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#I16");
5776 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#I17");
5777 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#I18");
5778 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#I19");
5779 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#I20");
5780 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#I21");
5781 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#I22");
5782 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#I23");
5783 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#I24");
5784 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#I25");
5785 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#I26");
5786 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#I27");
5787 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#I28");
5788 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#I29");
5789 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#I30");
5790 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#I31");
5791 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#I32");
5792 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#I33");
5793 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#I34");
5794 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#I35");
5795 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#I36");
5797 flags = BindingFlags.Instance | BindingFlags.Public |
5798 BindingFlags.DeclaredOnly;
5800 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#J1");
5801 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#J2");
5802 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#J3");
5803 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#J4");
5804 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#J5");
5805 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#J6");
5806 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#J7");
5807 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#J8");
5808 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#J9");
5809 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#J10");
5810 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#J11");
5811 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#J12");
5812 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#J13");
5813 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#J14");
5814 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#J15");
5815 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#J16");
5816 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#J17");
5817 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#J18");
5818 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#J19");
5819 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#J20");
5820 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#J21");
5821 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#J22");
5822 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#J23");
5823 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#J24");
5824 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#J25");
5825 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#J26");
5826 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#J27");
5827 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#J28");
5828 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#J29");
5829 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#J30");
5830 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#J31");
5831 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#J32");
5832 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#J33");
5833 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#J34");
5834 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#J35");
5835 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#J36");
5837 flags = BindingFlags.Static | BindingFlags.Public |
5838 BindingFlags.DeclaredOnly;
5840 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#K1");
5841 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#K2");
5842 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#K3");
5843 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#K4");
5844 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#K5");
5845 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#K6");
5846 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#K7");
5847 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#K8");
5848 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#K9");
5849 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#K10");
5850 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#K11");
5851 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#K12");
5852 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#K13");
5853 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#K14");
5854 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#K15");
5855 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#K16");
5856 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#K17");
5857 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#K18");
5858 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#K19");
5859 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#K20");
5860 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#K21");
5861 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#K22");
5862 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#K23");
5863 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#K24");
5864 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#K25");
5865 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#K26");
5866 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#K27");
5867 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#K28");
5868 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#K29");
5869 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#K30");
5870 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#K31");
5871 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#K32");
5872 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#K33");
5873 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#K34");
5874 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#K35");
5875 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#K36");
5877 flags = BindingFlags.Static | BindingFlags.NonPublic |
5878 BindingFlags.DeclaredOnly;
5880 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#L1");
5881 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#L2");
5882 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#L3");
5883 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#L4");
5884 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#L5");
5885 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#L6");
5886 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#L7");
5887 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#L8");
5888 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#L9");
5889 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#L10");
5890 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#L11");
5891 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#L12");
5892 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#L13");
5893 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#L14");
5894 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#L15");
5895 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#L16");
5896 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#L17");
5897 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#L18");
5898 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#L19");
5899 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#L20");
5900 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#L21");
5901 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#L22");
5902 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#L23");
5903 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#L24");
5904 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#L25");
5905 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#L26");
5906 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#L27");
5907 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#L28");
5908 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#L29");
5909 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#L30");
5910 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#L31");
5911 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#L32");
5912 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#L33");
5913 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#L34");
5914 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#L35");
5915 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#L36");
5917 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5918 BindingFlags.Public;
5920 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#M1");
5921 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#M2");
5922 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#M3");
5923 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#M4");
5924 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#M5");
5925 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#M6");
5926 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#M7");
5927 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#M8");
5928 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#M9");
5929 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#M10");
5930 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#M11");
5931 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#M12");
5932 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#M13");
5933 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#M14");
5934 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#M15");
5935 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#M16");
5936 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#M17");
5937 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#M18");
5938 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#M19");
5939 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#M20");
5940 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#M21");
5941 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#M22");
5942 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#M23");
5943 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#M24");
5944 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#M25");
5945 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#M26");
5946 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#M27");
5947 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#M28");
5948 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#M29");
5949 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#M30");
5950 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#M31");
5951 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#M32");
5952 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#M33");
5953 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#M34");
5954 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#M35");
5955 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#M36");
5957 flags = BindingFlags.Static | BindingFlags.NonPublic |
5958 BindingFlags.Public;
5960 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#N1");
5961 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#N2");
5962 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#N3");
5963 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#N4");
5964 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#N5");
5965 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#N6");
5966 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#N7");
5967 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#N8");
5968 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#N9");
5969 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#N10");
5970 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#N11");
5971 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#N12");
5972 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#N13");
5973 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#N14");
5974 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#N15");
5975 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#N16");
5976 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#N17");
5977 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#N18");
5978 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#N19");
5979 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#N20");
5980 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#N21");
5981 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#N22");
5982 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#N23");
5983 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#N24");
5984 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#N25");
5985 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#N26");
5986 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#N27");
5987 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#N28");
5988 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#N29");
5989 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#N30");
5990 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#N31");
5991 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#N32");
5992 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#N33");
5993 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#N34");
5994 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#N35");
5995 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#N36");
5998 [Test]
5999 [Category ("NotDotNet")] // mcs depends on this
6000 public void TestGetPropertiesIncomplete_Mono ()
6002 TypeBuilder tb = module.DefineType (genTypeName ());
6003 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
6004 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
6005 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
6007 PropertyInfo [] properties = tb.GetProperties ();
6008 Assert.AreEqual (2, properties.Length, "#1");
6009 Assert.AreEqual ("Name", properties [0].Name, "#2");
6010 Assert.AreEqual ("FirstName", properties [1].Name, "#3");
6013 [Test]
6014 [Category ("NotWorking")] // mcs depends on this
6015 public void TestGetPropertiesIncomplete_MS ()
6017 TypeBuilder tb = module.DefineType (genTypeName ());
6018 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
6019 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
6020 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
6022 try {
6023 tb.GetProperties ();
6024 Assert.Fail ("#1");
6025 } catch (NotSupportedException ex) {
6026 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6027 Assert.IsNull (ex.InnerException, "#3");
6028 Assert.IsNotNull (ex.Message, "#4");
6032 [Test]
6033 public void TestGetPropertiesComplete ()
6035 TypeBuilder tb = module.DefineType (genTypeName ());
6036 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6038 Type emittedType = tb.CreateType ();
6040 Assert.AreEqual (1, tb.GetProperties ().Length);
6041 Assert.AreEqual (tb.GetProperties ().Length, emittedType.GetProperties ().Length);
6044 [Test]
6045 [Category ("NotDotNet")] // mcs depends on this
6046 public void TestGetPropertiesFlagsIncomplete_Mono ()
6048 PropertyInfo [] properties;
6050 TypeBuilder tb = module.DefineType (genTypeName ());
6051 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
6052 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
6053 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
6055 properties = tb.GetProperties (BindingFlags.Public |
6056 BindingFlags.NonPublic | BindingFlags.Instance);
6057 Assert.AreEqual (3, properties.Length, "#A1");
6058 Assert.AreEqual ("Name", properties [0].Name, "#A2");
6059 Assert.AreEqual ("Income", properties [1].Name, "#A3");
6060 Assert.AreEqual ("FirstName", properties [2].Name, "#A4");
6062 properties = tb.GetProperties (BindingFlags.Public |
6063 BindingFlags.Instance);
6064 Assert.AreEqual (2, properties.Length, "#B1");
6065 Assert.AreEqual ("Name", properties [0].Name, "#B2");
6066 Assert.AreEqual ("FirstName", properties [1].Name, "#B3");
6068 properties = tb.GetProperties (BindingFlags.NonPublic |
6069 BindingFlags.Instance);
6070 Assert.AreEqual (1, properties.Length, "#C1");
6071 Assert.AreEqual ("Income", properties [0].Name, "#C2");
6074 [Test]
6075 [Category ("NotWorking")] // mcs depends on this
6076 public void TestGetPropertiesFlagsIncomplete_MS ()
6078 TypeBuilder tb = module.DefineType (genTypeName ());
6079 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
6080 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
6081 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
6083 try {
6084 tb.GetProperties (BindingFlags.Public);
6085 Assert.Fail ("#1");
6086 } catch (NotSupportedException ex) {
6087 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6088 Assert.IsNull (ex.InnerException, "#3");
6089 Assert.IsNotNull (ex.Message, "#4");
6093 [Test]
6094 public void TestGetPropertiesFlagsComplete ()
6096 TypeBuilder tb = module.DefineType (genTypeName ());
6097 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6099 Type emittedType = tb.CreateType ();
6101 Assert.AreEqual (1, tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
6102 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length,
6103 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
6104 Assert.AreEqual (0, tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
6105 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length,
6106 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
6109 [Test]
6110 public void TestGetPropertiesFlagsComplete_Inheritance ()
6112 PropertyInfo [] props;
6113 BindingFlags flags;
6115 TypeBuilder blueType = module.DefineType (genTypeName (),
6116 TypeAttributes.Public);
6117 CreateMembers (blueType, "Blue", false);
6119 TypeBuilder redType = module.DefineType (genTypeName (),
6120 TypeAttributes.Public, blueType);
6121 CreateMembers (redType, "Red", false);
6123 TypeBuilder greenType = module.DefineType (genTypeName (),
6124 TypeAttributes.Public, redType);
6125 CreateMembers (greenType, "Green", false);
6127 blueType.CreateType ();
6128 redType.CreateType ();
6129 greenType.CreateType ();
6131 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6132 props = greenType.GetProperties (flags);
6134 #if NET_2_0
6135 Assert.AreEqual (13, props.Length, "#A1");
6136 #else
6137 Assert.AreEqual (11, props.Length, "#A1");
6138 #endif
6139 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#A2");
6140 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#A3");
6141 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#A4");
6142 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#A5");
6143 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#A6");
6144 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#A7");
6145 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#A8");
6146 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#A9");
6147 #if NET_2_0
6148 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#A10");
6149 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#A11");
6150 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#A12");
6151 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#A13");
6152 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#A15");
6153 #else
6154 Assert.AreEqual ("FamilyInstanceBlue", props [8].Name, "#A10");
6155 Assert.AreEqual ("FamANDAssemInstanceBlue", props [9].Name, "#A11");
6156 Assert.AreEqual ("FamORAssemInstanceBlue", props [10].Name, "#A12");
6157 #endif
6159 flags = BindingFlags.Instance | BindingFlags.Public;
6160 props = greenType.GetProperties (flags);
6162 Assert.AreEqual (3, props.Length, "#B1");
6163 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#B2");
6164 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#B3");
6165 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#B4");
6167 flags = BindingFlags.Static | BindingFlags.Public;
6168 props = greenType.GetProperties (flags);
6170 Assert.AreEqual (1, props.Length, "#C1");
6171 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#C2");
6173 flags = BindingFlags.Static | BindingFlags.NonPublic;
6174 props = greenType.GetProperties (flags);
6176 Assert.AreEqual (5, props.Length, "#D1");
6177 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#D2");
6178 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#D3");
6179 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#D4");
6180 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#D5");
6181 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#D6");
6183 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6184 BindingFlags.FlattenHierarchy;
6185 props = greenType.GetProperties (flags);
6187 #if NET_2_0
6188 Assert.AreEqual (13, props.Length, "#E1");
6189 #else
6190 Assert.AreEqual (11, props.Length, "#E1");
6191 #endif
6192 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#E2");
6193 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#E3");
6194 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#E4");
6195 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#E5");
6196 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#E6");
6197 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#E7");
6198 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#E8");
6199 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#E9");
6200 #if NET_2_0
6201 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#E10");
6202 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#E11");
6203 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#E12");
6204 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#E13");
6205 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#E14");
6206 #else
6207 Assert.AreEqual ("FamilyInstanceBlue", props [8].Name, "#E10");
6208 Assert.AreEqual ("FamANDAssemInstanceBlue", props [9].Name, "#E11");
6209 Assert.AreEqual ("FamORAssemInstanceBlue", props [10].Name, "#E12");
6210 #endif
6212 flags = BindingFlags.Instance | BindingFlags.Public |
6213 BindingFlags.FlattenHierarchy;
6214 props = greenType.GetProperties (flags);
6216 Assert.AreEqual (3, props.Length, "#F1");
6217 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#F2");
6218 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#F3");
6219 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#F4");
6221 flags = BindingFlags.Static | BindingFlags.Public |
6222 BindingFlags.FlattenHierarchy;
6223 props = greenType.GetProperties (flags);
6225 Assert.AreEqual (3, props.Length, "#G1");
6226 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#G2");
6227 Assert.AreEqual ("PublicStaticRed", props [1].Name, "#G3");
6228 Assert.AreEqual ("PublicStaticBlue", props [2].Name, "#G4");
6230 flags = BindingFlags.Static | BindingFlags.NonPublic |
6231 BindingFlags.FlattenHierarchy;
6232 props = greenType.GetProperties (flags);
6234 #if NET_2_0
6235 Assert.AreEqual (13, props.Length, "#H1");
6236 #else
6237 Assert.AreEqual (11, props.Length, "#H1");
6238 #endif
6239 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#H2");
6240 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#H3");
6241 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#H4");
6242 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#H5");
6243 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#H6");
6244 Assert.AreEqual ("FamilyStaticRed", props [5].Name, "#H7");
6245 Assert.AreEqual ("FamANDAssemStaticRed", props [6].Name, "#H8");
6246 Assert.AreEqual ("FamORAssemStaticRed", props [7].Name, "#H9");
6247 #if NET_2_0
6248 Assert.AreEqual ("AssemblyStaticRed", props [8].Name, "#H10");
6249 Assert.AreEqual ("FamilyStaticBlue", props [9].Name, "#H11");
6250 Assert.AreEqual ("FamANDAssemStaticBlue", props [10].Name, "#H12");
6251 Assert.AreEqual ("FamORAssemStaticBlue", props [11].Name, "#H13");
6252 Assert.AreEqual ("AssemblyStaticBlue", props [12].Name, "#H14");
6253 #else
6254 Assert.AreEqual ("FamilyStaticBlue", props [8].Name, "#H10");
6255 Assert.AreEqual ("FamANDAssemStaticBlue", props [9].Name, "#H11");
6256 Assert.AreEqual ("FamORAssemStaticBlue", props [10].Name, "#H12");
6257 #endif
6259 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6260 BindingFlags.DeclaredOnly;
6261 props = greenType.GetProperties (flags);
6263 Assert.AreEqual (5, props.Length, "#I1");
6264 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#I2");
6265 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#I3");
6266 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#I4");
6267 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#I5");
6268 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#I6");
6270 flags = BindingFlags.Instance | BindingFlags.Public |
6271 BindingFlags.DeclaredOnly;
6272 props = greenType.GetProperties (flags);
6274 Assert.AreEqual (1, props.Length, "#J1");
6275 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#J2");
6277 flags = BindingFlags.Static | BindingFlags.Public |
6278 BindingFlags.DeclaredOnly;
6279 props = greenType.GetProperties (flags);
6281 Assert.AreEqual (1, props.Length, "#K1");
6282 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#K2");
6284 flags = BindingFlags.Static | BindingFlags.NonPublic |
6285 BindingFlags.DeclaredOnly;
6286 props = greenType.GetProperties (flags);
6288 Assert.AreEqual (5, props.Length, "#L1");
6289 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#L2");
6290 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#L3");
6291 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#L4");
6292 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#L5");
6293 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#L6");
6295 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6296 BindingFlags.Public;
6297 props = greenType.GetProperties (flags);
6299 #if NET_2_0
6300 Assert.AreEqual (16, props.Length, "#M1");
6301 #else
6302 Assert.AreEqual (14, props.Length, "#M1");
6303 #endif
6304 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#M2");
6305 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#M3");
6306 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#M4");
6307 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#M5");
6308 Assert.AreEqual ("PublicInstanceGreen", props [4].Name, "#M6");
6309 Assert.AreEqual ("AssemblyInstanceGreen", props [5].Name, "#M7");
6310 Assert.AreEqual ("FamilyInstanceRed", props [6].Name, "#M8");
6311 Assert.AreEqual ("FamANDAssemInstanceRed", props [7].Name, "#M9");
6312 Assert.AreEqual ("FamORAssemInstanceRed", props [8].Name, "#M10");
6313 Assert.AreEqual ("PublicInstanceRed", props [9].Name, "#M11");
6314 #if NET_2_0
6315 Assert.AreEqual ("AssemblyInstanceRed", props [10].Name, "#M12");
6316 Assert.AreEqual ("FamilyInstanceBlue", props [11].Name, "#M13");
6317 Assert.AreEqual ("FamANDAssemInstanceBlue", props [12].Name, "#M14");
6318 Assert.AreEqual ("FamORAssemInstanceBlue", props [13].Name, "#M15");
6319 Assert.AreEqual ("PublicInstanceBlue", props [14].Name, "#M16");
6320 Assert.AreEqual ("AssemblyInstanceBlue", props [15].Name, "#M17");
6321 #else
6322 Assert.AreEqual ("FamilyInstanceBlue", props [10].Name, "#M12");
6323 Assert.AreEqual ("FamANDAssemInstanceBlue", props [11].Name, "#M13");
6324 Assert.AreEqual ("FamORAssemInstanceBlue", props [12].Name, "#M14");
6325 Assert.AreEqual ("PublicInstanceBlue", props [13].Name, "#M15");
6326 #endif
6328 flags = BindingFlags.Static | BindingFlags.NonPublic |
6329 BindingFlags.Public;
6330 props = greenType.GetProperties (flags);
6332 Assert.AreEqual (6, props.Length, "#N1");
6333 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#N2");
6334 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#N3");
6335 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#N4");
6336 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#N5");
6337 Assert.AreEqual ("PublicStaticGreen", props [4].Name, "#N6");
6338 Assert.AreEqual ("AssemblyStaticGreen", props [5].Name, "#N7");
6341 [Test]
6342 public void TestGetPropertyIncomplete ()
6344 TypeBuilder tb = module.DefineType (genTypeName ());
6345 try {
6346 tb.GetProperty ("test");
6347 Assert.Fail ("#1");
6348 } catch (NotSupportedException ex) {
6349 // The invoked member is not supported in a
6350 // dynamic module
6351 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6352 Assert.IsNull (ex.InnerException, "#3");
6353 Assert.IsNotNull (ex.Message, "#4");
6357 [Test]
6358 public void TestGetPropertyComplete ()
6360 TypeBuilder tb = module.DefineType (genTypeName ());
6361 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6363 Type emittedType = tb.CreateType ();
6365 Assert.IsNotNull (emittedType.GetProperty ("CustomerName"));
6366 Assert.IsNull (emittedType.GetProperty ("OtherCustomerName"));
6368 try {
6369 tb.GetProperty ("CustomerName");
6370 Assert.Fail ("#1");
6371 } catch (NotSupportedException ex) {
6372 // The invoked member is not supported in a
6373 // dynamic module
6374 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6375 Assert.IsNull (ex.InnerException, "#3");
6376 Assert.IsNotNull (ex.Message, "#4");
6380 [Test]
6381 public void TestGetPropertyFlagsIncomplete ()
6383 TypeBuilder tb = module.DefineType (genTypeName ());
6384 try {
6385 tb.GetProperty ("test", BindingFlags.Public);
6386 Assert.Fail ("#1");
6387 } catch (NotSupportedException ex) {
6388 // The invoked member is not supported in a
6389 // dynamic module
6390 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6391 Assert.IsNull (ex.InnerException, "#3");
6392 Assert.IsNotNull (ex.Message, "#4");
6396 [Test]
6397 public void TestGetPropertyFlagsComplete ()
6399 TypeBuilder tb = module.DefineType (genTypeName ());
6400 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6402 Type emittedType = tb.CreateType ();
6404 Assert.IsNotNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6405 BindingFlags.Public));
6406 Assert.IsNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6407 BindingFlags.NonPublic));
6409 try {
6410 tb.GetProperty ("CustomerName", BindingFlags.Instance | BindingFlags.Public);
6411 Assert.Fail ("#1");
6412 } catch (NotSupportedException ex) {
6413 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6414 Assert.IsNull (ex.InnerException, "#3");
6415 Assert.IsNotNull (ex.Message, "#4");
6419 [Test]
6420 public void TestGetMethodFlagsComplete ()
6422 BindingFlags flags;
6424 TypeBuilder blueType = module.DefineType (genTypeName (),
6425 TypeAttributes.Public);
6426 CreateMembers (blueType, "Blue", false);
6428 TypeBuilder redType = module.DefineType (genTypeName (),
6429 TypeAttributes.Public, blueType);
6430 CreateMembers (redType, "Red", false);
6432 TypeBuilder greenType = module.DefineType (genTypeName (),
6433 TypeAttributes.Public, redType);
6434 CreateMembers (greenType, "Green", false);
6436 blueType.CreateType ();
6437 redType.CreateType ();
6438 greenType.CreateType ();
6440 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6442 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#A1");
6443 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#A2");
6444 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#A3");
6445 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#A4");
6446 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#A5");
6447 #if NET_2_0
6448 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#A6");
6449 #else
6450 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#A6");
6451 #endif
6452 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#A7");
6453 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#A8");
6454 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#A9");
6455 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#A10");
6456 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#A11");
6457 #if NET_2_0
6458 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#A12");
6459 #else
6460 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#A12");
6461 #endif
6462 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#A13");
6463 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#A14");
6464 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#A15");
6465 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#A16");
6466 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#A17");
6467 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#A18");
6468 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#A19");
6469 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#A20");
6470 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#A21");
6471 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#A22");
6472 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#A23");
6473 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#A24");
6474 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#A25");
6475 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#A26");
6476 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#A27");
6477 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#A28");
6478 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#A29");
6479 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#A30");
6480 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#A31");
6481 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#A32");
6482 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#A33");
6483 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#A34");
6484 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#A35");
6485 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#A36");
6487 flags = BindingFlags.Instance | BindingFlags.Public;
6489 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#B1");
6490 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#B2");
6491 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#B3");
6492 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#B4");
6493 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#B5");
6494 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#B6");
6495 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#B7");
6496 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#B8");
6497 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#B9");
6498 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#B10");
6499 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#B11");
6500 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#B12");
6501 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#B13");
6502 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#B14");
6503 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#B15");
6504 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#B16");
6505 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#B17");
6506 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#B18");
6507 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#B19");
6508 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#B20");
6509 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#B21");
6510 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#B22");
6511 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#B23");
6512 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#B24");
6513 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#B25");
6514 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#B26");
6515 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#B27");
6516 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#B28");
6517 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#B29");
6518 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#B30");
6519 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#B31");
6520 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#B32");
6521 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#B33");
6522 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#B34");
6523 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#B35");
6524 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#B36");
6526 flags = BindingFlags.Static | BindingFlags.Public;
6528 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#C1");
6529 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#C2");
6530 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#C3");
6531 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#C4");
6532 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#C5");
6533 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#C6");
6534 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#C7");
6535 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#C8");
6536 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#C9");
6537 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#C10");
6538 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#C11");
6539 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#C12");
6540 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#C13");
6541 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#C14");
6542 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#C15");
6543 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#C16");
6544 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#C17");
6545 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#C18");
6546 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#C19");
6547 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#C20");
6548 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#C21");
6549 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#C22");
6550 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#C23");
6551 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#C24");
6552 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#C25");
6553 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#C26");
6554 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#C27");
6555 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#C28");
6556 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#C29");
6557 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#C30");
6558 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#C31");
6559 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#C32");
6560 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#C33");
6561 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#C34");
6562 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#C35");
6563 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#C36");
6565 flags = BindingFlags.Static | BindingFlags.NonPublic;
6567 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#D1");
6568 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#D2");
6569 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#D3");
6570 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#D4");
6571 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#D5");
6572 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#D6");
6573 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#D7");
6574 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#D8");
6575 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#D9");
6576 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#D10");
6577 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#D11");
6578 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#D12");
6579 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#D13");
6580 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#D14");
6581 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#D15");
6582 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#D16");
6583 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#D17");
6584 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#D18");
6585 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#D19");
6586 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#D20");
6587 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#D21");
6588 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#D22");
6589 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#D23");
6590 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#D24");
6591 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#D25");
6592 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#D26");
6593 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#D27");
6594 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#D28");
6595 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#D29");
6596 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#D30");
6597 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#D31");
6598 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#D32");
6599 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#D33");
6600 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#D34");
6601 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#D35");
6602 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#D36");
6604 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6605 BindingFlags.FlattenHierarchy;
6607 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#E1");
6608 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#E2");
6609 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#E3");
6610 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#E4");
6611 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#E5");
6612 #if NET_2_0
6613 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#E6");
6614 #else
6615 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#E6");
6616 #endif
6617 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#E7");
6618 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#E8");
6619 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#E9");
6620 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#E10");
6621 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#E11");
6622 #if NET_2_0
6623 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#E12");
6624 #else
6625 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#E12");
6626 #endif
6627 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#E13");
6628 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#E14");
6629 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#E15");
6630 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#E16");
6631 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#E17");
6632 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#E18");
6633 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#E19");
6634 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#E20");
6635 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#E21");
6636 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#E22");
6637 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#E23");
6638 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#E24");
6639 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#E25");
6640 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#E26");
6641 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#E27");
6642 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#E28");
6643 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#E29");
6644 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#E30");
6645 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#E31");
6646 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#E32");
6647 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#E33");
6648 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#E34");
6649 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#E35");
6650 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#E36");
6652 flags = BindingFlags.Instance | BindingFlags.Public |
6653 BindingFlags.FlattenHierarchy;
6655 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#F1");
6656 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#F2");
6657 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#F3");
6658 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#F4");
6659 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#F5");
6660 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#F6");
6661 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#F7");
6662 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#F8");
6663 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#F9");
6664 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#F10");
6665 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#F11");
6666 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#F12");
6667 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#F13");
6668 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#F14");
6669 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#F15");
6670 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#F16");
6671 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#F17");
6672 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#F18");
6673 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#F19");
6674 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#F20");
6675 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#F21");
6676 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#F22");
6677 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#F23");
6678 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#F24");
6679 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#F25");
6680 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#F26");
6681 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#F27");
6682 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#F28");
6683 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#F29");
6684 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#F30");
6685 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#F31");
6686 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#F32");
6687 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#F33");
6688 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#F34");
6689 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#F35");
6690 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#F36");
6692 flags = BindingFlags.Static | BindingFlags.Public |
6693 BindingFlags.FlattenHierarchy;
6695 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#G1");
6696 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#G2");
6697 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#G3");
6698 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#G4");
6699 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#G5");
6700 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#G6");
6701 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#G7");
6702 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#G8");
6703 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#G9");
6704 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#G10");
6705 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#G11");
6706 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#G12");
6707 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#G13");
6708 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#G14");
6709 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#G15");
6710 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#G16");
6711 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#G17");
6712 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#G18");
6713 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#G19");
6714 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#G20");
6715 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#G21");
6716 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#G22");
6717 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#G23");
6718 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#G24");
6719 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#G25");
6720 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#G26");
6721 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#G27");
6722 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#G28");
6723 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#G29");
6724 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#G30");
6725 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#G31");
6726 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#G32");
6727 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#G33");
6728 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#G34");
6729 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#G35");
6730 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#G36");
6732 flags = BindingFlags.Static | BindingFlags.NonPublic |
6733 BindingFlags.FlattenHierarchy;
6735 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#H1");
6736 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#H2");
6737 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#H3");
6738 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#H4");
6739 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#H5");
6740 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#H6");
6741 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#H7");
6742 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#H8");
6743 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#H9");
6744 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#H10");
6745 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#H11");
6746 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#H12");
6747 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#H13");
6748 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#H14");
6749 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#H15");
6750 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#H16");
6751 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#H17");
6752 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#H18");
6753 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#H19");
6754 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#H20");
6755 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#H21");
6756 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#H22");
6757 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#H23");
6758 #if NET_2_0
6759 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#H24");
6760 #else
6761 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#H24");
6762 #endif
6763 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#H25");
6764 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#H26");
6765 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#H27");
6766 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#H28");
6767 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#H29");
6768 #if NET_2_0
6769 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#H30");
6770 #else
6771 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#H30");
6772 #endif
6773 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#H31");
6774 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#H32");
6775 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#H33");
6776 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#H34");
6777 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#H35");
6778 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#H36");
6780 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6781 BindingFlags.DeclaredOnly;
6783 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#I1");
6784 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#I2");
6785 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#I3");
6786 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#I4");
6787 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#I5");
6788 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#I6");
6789 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#I7");
6790 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#I8");
6791 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#I9");
6792 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#I10");
6793 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#I11");
6794 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#I12");
6795 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#I13");
6796 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#I14");
6797 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#I15");
6798 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#I16");
6799 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#I17");
6800 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#I18");
6801 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#I19");
6802 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#I20");
6803 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#I21");
6804 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#I22");
6805 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#I23");
6806 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#I24");
6807 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#I25");
6808 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#I26");
6809 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#I27");
6810 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#I28");
6811 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#I29");
6812 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#I30");
6813 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#I31");
6814 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#I32");
6815 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#I33");
6816 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#I34");
6817 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#I35");
6818 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#I36");
6820 flags = BindingFlags.Instance | BindingFlags.Public |
6821 BindingFlags.DeclaredOnly;
6823 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#J1");
6824 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#J2");
6825 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#J3");
6826 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#J4");
6827 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#J5");
6828 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#J6");
6829 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#J7");
6830 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#J8");
6831 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#J9");
6832 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#J10");
6833 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#J11");
6834 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#J12");
6835 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#J13");
6836 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#J14");
6837 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#J15");
6838 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#J16");
6839 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#J17");
6840 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#J18");
6841 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#J19");
6842 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#J20");
6843 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#J21");
6844 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#J22");
6845 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#J23");
6846 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#J24");
6847 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#J25");
6848 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#J26");
6849 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#J27");
6850 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#J28");
6851 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#J29");
6852 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#J30");
6853 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#J31");
6854 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#J32");
6855 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#J33");
6856 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#J34");
6857 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#J35");
6858 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#J36");
6860 flags = BindingFlags.Static | BindingFlags.Public |
6861 BindingFlags.DeclaredOnly;
6863 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#K1");
6864 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#K2");
6865 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#K3");
6866 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#K4");
6867 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#K5");
6868 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#K6");
6869 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#K7");
6870 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#K8");
6871 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#K9");
6872 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#K10");
6873 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#K11");
6874 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#K12");
6875 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#K13");
6876 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#K14");
6877 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#K15");
6878 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#K16");
6879 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#K17");
6880 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#K18");
6881 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#K19");
6882 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#K20");
6883 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#K21");
6884 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#K22");
6885 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#K23");
6886 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#K24");
6887 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#K25");
6888 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#K26");
6889 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#K27");
6890 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#K28");
6891 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#K29");
6892 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#K30");
6893 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#K31");
6894 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#K32");
6895 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#K33");
6896 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#K34");
6897 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#K35");
6898 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#K36");
6900 flags = BindingFlags.Static | BindingFlags.NonPublic |
6901 BindingFlags.DeclaredOnly;
6903 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#L1");
6904 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#L2");
6905 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#L3");
6906 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#L4");
6907 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#L5");
6908 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#L6");
6909 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#L7");
6910 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#L8");
6911 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#L9");
6912 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#L10");
6913 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#L11");
6914 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#L12");
6915 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#L13");
6916 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#L14");
6917 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#L15");
6918 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#L16");
6919 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#L17");
6920 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#L18");
6921 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#L19");
6922 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#L20");
6923 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#L21");
6924 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#L22");
6925 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#L23");
6926 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#L24");
6927 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#L25");
6928 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#L26");
6929 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#L27");
6930 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#L28");
6931 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#L29");
6932 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#L30");
6933 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#L31");
6934 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#L32");
6935 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#L33");
6936 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#L34");
6937 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#L35");
6938 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#L36");
6940 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6941 BindingFlags.Public;
6943 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#M1");
6944 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#M2");
6945 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#M3");
6946 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#M4");
6947 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#M5");
6948 #if NET_2_0
6949 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#M6");
6950 #else
6951 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#M6");
6952 #endif
6953 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#M7");
6954 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#M8");
6955 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#M9");
6956 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#M10");
6957 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#M11");
6958 #if NET_2_0
6959 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#M12");
6960 #else
6961 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#M12");
6962 #endif
6963 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#M13");
6964 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#M14");
6965 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#M15");
6966 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#M16");
6967 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#M17");
6968 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#M18");
6969 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#M19");
6970 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#M20");
6971 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#M21");
6972 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#M22");
6973 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#M23");
6974 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#M24");
6975 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#M25");
6976 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#M26");
6977 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#M27");
6978 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#M28");
6979 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#M29");
6980 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#M30");
6981 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#M31");
6982 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#M32");
6983 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#M33");
6984 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#M34");
6985 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#M35");
6986 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#M36");
6988 flags = BindingFlags.Static | BindingFlags.NonPublic |
6989 BindingFlags.Public;
6991 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#N1");
6992 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#N2");
6993 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#N3");
6994 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#N4");
6995 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#N5");
6996 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#N6");
6997 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#N7");
6998 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#N8");
6999 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#N9");
7000 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#N10");
7001 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#N11");
7002 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#N12");
7003 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#N13");
7004 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#N14");
7005 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#N15");
7006 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#N16");
7007 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#N17");
7008 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#N18");
7009 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#N19");
7010 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#N20");
7011 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#N21");
7012 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#N22");
7013 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#N23");
7014 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#N24");
7015 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#N25");
7016 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#N26");
7017 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#N27");
7018 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#N28");
7019 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#N29");
7020 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#N30");
7021 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#N31");
7022 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#N32");
7023 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#N33");
7024 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#N34");
7025 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#N35");
7026 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#N36");
7029 [Test]
7030 [Category ("NotDotNet")] // mcs depends on this
7031 public void TestGetMethodsIncomplete_Mono ()
7033 MethodBuilder mb;
7034 ILGenerator ilgen;
7036 TypeBuilder tb = module.DefineType (genTypeName (),
7037 TypeAttributes.Abstract);
7038 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7039 typeof (void), Type.EmptyTypes);
7040 ilgen = mb.GetILGenerator ();
7041 ilgen.Emit (OpCodes.Ret);
7043 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7044 typeof (void), Type.EmptyTypes);
7045 ilgen = mb.GetILGenerator ();
7046 ilgen.Emit (OpCodes.Ret);
7048 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7049 MethodAttributes.Static,
7050 typeof (void), Type.EmptyTypes);
7051 ilgen = mb.GetILGenerator ();
7052 ilgen.Emit (OpCodes.Ret);
7054 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7055 MethodAttributes.Abstract | MethodAttributes.Virtual,
7056 typeof (void), Type.EmptyTypes);
7058 MethodInfo [] methods = tb.GetMethods ();
7059 Assert.AreEqual (7, methods.Length, "#A");
7061 Assert.AreEqual ("Equals", methods [0].Name, "#B1");
7062 Assert.IsFalse (methods [0].IsStatic, "#B2");
7063 Assert.IsFalse (methods [0].IsAbstract, "#B3");
7065 Assert.AreEqual ("GetHashCode", methods [1].Name, "#C1");
7066 Assert.IsFalse (methods [1].IsStatic, "#C2");
7067 Assert.IsFalse (methods [1].IsAbstract, "#C3");
7069 Assert.AreEqual ("GetType", methods [2].Name, "#D1");
7070 Assert.IsFalse (methods [2].IsStatic, "#D2");
7071 Assert.IsFalse (methods [2].IsAbstract, "#D3");
7073 Assert.AreEqual ("ToString", methods [3].Name, "#E1");
7074 Assert.IsFalse (methods [3].IsStatic, "#E2");
7075 Assert.IsFalse (methods [3].IsAbstract, "#E3");
7077 Assert.AreEqual ("Hello", methods [4].Name, "#F1");
7078 Assert.IsFalse (methods [4].IsStatic, "#F2");
7079 Assert.IsFalse (methods [4].IsAbstract, "#F3");
7081 Assert.AreEqual ("Execute", methods [5].Name, "#G1");
7082 Assert.IsTrue (methods [5].IsStatic, "#G2");
7083 Assert.IsFalse (methods [5].IsAbstract, "#G3");
7085 Assert.AreEqual ("Init", methods [6].Name, "#H1");
7086 Assert.IsFalse (methods [6].IsStatic, "#H2");
7087 Assert.IsTrue (methods [6].IsAbstract, "#H3");
7090 [Test]
7091 [Category ("NotWorking")] // mcs depends on this
7092 public void TestGetMethodsIncomplete_MS ()
7094 MethodBuilder mb;
7095 ILGenerator ilgen;
7097 TypeBuilder tb = module.DefineType (genTypeName (),
7098 TypeAttributes.Abstract);
7099 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7100 typeof (void), Type.EmptyTypes);
7101 ilgen = mb.GetILGenerator ();
7102 ilgen.Emit (OpCodes.Ret);
7104 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7105 typeof (void), Type.EmptyTypes);
7106 ilgen = mb.GetILGenerator ();
7107 ilgen.Emit (OpCodes.Ret);
7109 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7110 MethodAttributes.Static,
7111 typeof (void), Type.EmptyTypes);
7112 ilgen = mb.GetILGenerator ();
7113 ilgen.Emit (OpCodes.Ret);
7115 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7116 MethodAttributes.Abstract | MethodAttributes.Virtual,
7117 typeof (void), Type.EmptyTypes);
7119 try {
7120 tb.GetMethods ();
7121 Assert.Fail ("#1");
7122 } catch (NotSupportedException ex) {
7123 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
7124 Assert.IsNull (ex.InnerException, "#3");
7125 Assert.IsNotNull (ex.Message, "#4");
7129 [Test]
7130 public void TestGetMethodsComplete ()
7132 MethodBuilder mb;
7133 ILGenerator ilgen;
7134 MethodInfo mi;
7136 TypeBuilder tb = module.DefineType (genTypeName (),
7137 TypeAttributes.Abstract);
7138 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7139 typeof (string), Type.EmptyTypes);
7140 ilgen = mb.GetILGenerator ();
7141 ilgen.Emit (OpCodes.Ldstr, "Hi! ");
7142 ilgen.Emit (OpCodes.Ldarg_1);
7143 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
7144 new Type [] { typeof (string), typeof (string) });
7145 ilgen.Emit (OpCodes.Call, infoMethod);
7146 ilgen.Emit (OpCodes.Ret);
7148 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7149 typeof (void), Type.EmptyTypes);
7150 ilgen = mb.GetILGenerator ();
7151 ilgen.Emit (OpCodes.Ret);
7153 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7154 MethodAttributes.Static,
7155 typeof (void), Type.EmptyTypes);
7156 ilgen = mb.GetILGenerator ();
7157 ilgen.Emit (OpCodes.Ret);
7159 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7160 MethodAttributes.Abstract | MethodAttributes.Virtual,
7161 typeof (void), Type.EmptyTypes);
7163 Type emittedType = tb.CreateType ();
7165 MethodInfo [] methods = emittedType.GetMethods ();
7166 Assert.AreEqual (7, methods.Length, "#A1");
7167 Assert.AreEqual (7, tb.GetMethods ().Length, "#A2");
7169 mi = GetMethodByName (methods, "Hello");
7170 Assert.IsNotNull (mi, "#B1");
7171 Assert.IsFalse (mi.IsStatic, "#B2");
7172 Assert.IsFalse (mi.IsAbstract, "#B3");
7174 mi = GetMethodByName (methods, "Execute");
7175 Assert.IsNotNull (mi, "#C1");
7176 Assert.IsTrue (mi.IsStatic, "#C2");
7177 Assert.IsFalse (mi.IsAbstract, "#C3");
7179 mi = GetMethodByName (methods, "Init");
7180 Assert.IsNotNull (mi, "#D1");
7181 Assert.IsFalse (mi.IsStatic, "#D2");
7182 Assert.IsTrue (mi.IsAbstract, "#D3");
7184 mi = GetMethodByName (methods, "GetType");
7185 Assert.IsNotNull (mi, "#E1");
7186 Assert.IsFalse (methods [3].IsStatic, "#E2");
7187 Assert.IsFalse (methods [3].IsAbstract, "#E3");
7189 mi = GetMethodByName (methods, "ToString");
7190 Assert.IsNotNull (mi, "#F1");
7191 Assert.IsFalse (mi.IsStatic, "#F2");
7192 Assert.IsFalse (mi.IsAbstract, "#F3");
7194 mi = GetMethodByName (methods, "Equals");
7195 Assert.IsNotNull (mi, "#G1");
7196 Assert.IsFalse (mi.IsStatic, "#G2");
7197 Assert.IsFalse (mi.IsAbstract, "#G3");
7199 mi = GetMethodByName (methods, "GetHashCode");
7200 Assert.IsNotNull (mi, "#H1");
7201 Assert.IsFalse (mi.IsStatic, "#H2");
7202 Assert.IsFalse (mi.IsAbstract, "#H3");
7205 [Test]
7206 [Category ("NotDotNet")] // mcs depends on this
7207 public void TestGetMethodsFlagsIncomplete_Inheritance ()
7209 MethodInfo [] methods;
7210 BindingFlags flags;
7212 TypeBuilder blueType = module.DefineType (genTypeName (),
7213 TypeAttributes.Public);
7214 CreateMembers (blueType, "Blue", false);
7216 TypeBuilder redType = module.DefineType (genTypeName (),
7217 TypeAttributes.Public, blueType);
7218 CreateMembers (redType, "Red", false);
7220 TypeBuilder greenType = module.DefineType (genTypeName (),
7221 TypeAttributes.Public, redType);
7222 CreateMembers (greenType, "Green", false);
7224 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7225 methods = greenType.GetMethods (flags);
7227 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7228 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7229 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7230 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7231 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7232 #if NET_2_0
7233 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7234 #else
7235 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7236 #endif
7237 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7238 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7239 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7240 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7241 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7242 #if NET_2_0
7243 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7244 #else
7245 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7246 #endif
7247 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7248 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7249 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7250 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7251 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7252 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7253 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7254 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7255 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7256 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7257 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7258 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7259 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7260 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7261 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7262 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7263 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7264 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7265 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7266 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7267 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7268 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7269 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7270 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7272 flags = BindingFlags.Instance | BindingFlags.Public;
7273 methods = greenType.GetMethods (flags);
7275 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7276 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7277 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7278 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7279 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7280 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7281 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7282 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7283 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7284 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7285 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7286 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7287 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7288 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7289 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7290 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7291 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7292 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7293 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7294 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7295 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7296 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7297 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7298 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7299 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7300 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7301 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7302 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7303 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7304 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7305 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7306 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7307 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7308 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7309 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7310 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7312 flags = BindingFlags.Static | BindingFlags.Public;
7313 methods = greenType.GetMethods (flags);
7315 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7316 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7317 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7318 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7319 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7320 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7321 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7322 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7323 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7324 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7325 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7326 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7327 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7328 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7329 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7330 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7331 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7332 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7333 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7334 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7335 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7336 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7337 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7338 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7339 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7340 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7341 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7342 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7343 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7344 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7345 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7346 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7347 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7348 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7349 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7350 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7352 flags = BindingFlags.Static | BindingFlags.NonPublic;
7353 methods = greenType.GetMethods (flags);
7355 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7356 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7357 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7358 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7359 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7360 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7361 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7362 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7363 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7364 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7365 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7366 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7367 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7368 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7369 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7370 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7371 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7372 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7373 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7374 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7375 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7376 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7377 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7378 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7379 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7380 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7381 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7382 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7383 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7384 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7385 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7386 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7387 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7388 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7389 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7390 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7392 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7393 BindingFlags.FlattenHierarchy;
7394 methods = greenType.GetMethods (flags);
7396 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7397 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7398 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7399 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7400 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7401 #if NET_2_0
7402 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7403 #else
7404 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7405 #endif
7406 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7407 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7408 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7409 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7410 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7411 #if NET_2_0
7412 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7413 #else
7414 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7415 #endif
7416 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7417 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7418 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7419 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7420 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7421 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7422 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7423 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7424 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7425 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7426 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7427 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7428 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7429 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7430 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7431 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7432 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7433 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7434 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7435 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7436 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7437 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7438 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7439 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7441 flags = BindingFlags.Instance | BindingFlags.Public |
7442 BindingFlags.FlattenHierarchy;
7443 methods = greenType.GetMethods (flags);
7445 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7446 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7447 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7448 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7449 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7450 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7451 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7452 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7453 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7454 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7455 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7456 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7457 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7458 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7459 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7460 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7461 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
7462 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
7463 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
7464 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
7465 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
7466 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
7467 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
7468 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
7469 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
7470 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
7471 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
7472 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
7473 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
7474 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
7475 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
7476 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
7477 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
7478 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
7479 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
7480 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
7482 flags = BindingFlags.Static | BindingFlags.Public |
7483 BindingFlags.FlattenHierarchy;
7484 methods = greenType.GetMethods (flags);
7486 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
7487 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
7488 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
7489 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
7490 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
7491 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
7492 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
7493 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
7494 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
7495 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
7496 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
7497 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
7498 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
7499 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
7500 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
7501 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
7502 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
7503 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
7504 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
7505 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
7506 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
7507 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
7508 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
7509 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
7510 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
7511 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
7512 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
7513 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
7514 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
7515 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
7516 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
7517 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
7518 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
7519 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
7520 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
7521 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
7523 flags = BindingFlags.Static | BindingFlags.NonPublic |
7524 BindingFlags.FlattenHierarchy;
7525 methods = greenType.GetMethods (flags);
7527 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
7528 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
7529 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
7530 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
7531 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
7532 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
7533 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
7534 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
7535 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
7536 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
7537 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
7538 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
7539 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
7540 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
7541 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
7542 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
7543 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
7544 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
7545 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
7546 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
7547 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
7548 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
7549 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
7550 #if NET_2_0
7551 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
7552 #else
7553 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
7554 #endif
7555 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
7556 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
7557 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
7558 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
7559 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
7560 #if NET_2_0
7561 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
7562 #else
7563 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
7564 #endif
7565 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
7566 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
7567 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
7568 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
7569 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
7570 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
7572 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7573 BindingFlags.DeclaredOnly;
7574 methods = greenType.GetMethods (flags);
7576 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
7577 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
7578 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
7579 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
7580 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
7581 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
7582 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
7583 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
7584 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
7585 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
7586 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
7587 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
7588 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
7589 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
7590 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
7591 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
7592 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
7593 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
7594 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
7595 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
7596 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
7597 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
7598 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
7599 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
7600 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
7601 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
7602 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
7603 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
7604 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
7605 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
7606 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
7607 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
7608 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
7609 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
7610 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
7611 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
7613 flags = BindingFlags.Instance | BindingFlags.Public |
7614 BindingFlags.DeclaredOnly;
7615 methods = greenType.GetMethods (flags);
7617 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
7618 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
7619 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
7620 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
7621 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
7622 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
7623 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
7624 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
7625 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
7626 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
7627 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
7628 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
7629 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
7630 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
7631 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
7632 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
7633 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
7634 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
7635 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
7636 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
7637 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
7638 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
7639 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
7640 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
7641 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
7642 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
7643 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
7644 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
7645 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
7646 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
7647 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
7648 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
7649 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
7650 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
7651 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
7652 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
7654 flags = BindingFlags.Static | BindingFlags.Public |
7655 BindingFlags.DeclaredOnly;
7656 methods = greenType.GetMethods (flags);
7658 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
7659 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
7660 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
7661 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
7662 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
7663 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
7664 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
7665 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
7666 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
7667 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
7668 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
7669 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
7670 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
7671 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
7672 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
7673 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
7674 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
7675 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
7676 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
7677 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
7678 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
7679 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
7680 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
7681 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
7682 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
7683 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
7684 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
7685 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
7686 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
7687 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
7688 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
7689 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
7690 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
7691 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
7692 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
7693 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
7695 flags = BindingFlags.Static | BindingFlags.NonPublic |
7696 BindingFlags.DeclaredOnly;
7697 methods = greenType.GetMethods (flags);
7699 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
7700 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
7701 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
7702 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
7703 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
7704 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
7705 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
7706 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
7707 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
7708 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
7709 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
7710 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
7711 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
7712 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
7713 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
7714 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
7715 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
7716 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
7717 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
7718 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
7719 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
7720 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
7721 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
7722 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
7723 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
7724 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
7725 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
7726 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
7727 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
7728 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
7729 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
7730 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
7731 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
7732 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
7733 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
7734 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
7736 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7737 BindingFlags.Public;
7738 methods = greenType.GetMethods (flags);
7740 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
7741 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
7742 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
7743 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
7744 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
7745 #if NET_2_0
7746 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
7747 #else
7748 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
7749 #endif
7750 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
7751 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
7752 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
7753 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
7754 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
7755 #if NET_2_0
7756 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
7757 #else
7758 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
7759 #endif
7760 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
7761 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
7762 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
7763 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
7764 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
7765 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
7766 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
7767 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
7768 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
7769 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
7770 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
7771 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
7772 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
7773 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
7774 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
7775 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
7776 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
7777 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
7778 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
7779 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
7780 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
7781 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
7782 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
7783 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
7785 flags = BindingFlags.Static | BindingFlags.NonPublic |
7786 BindingFlags.Public;
7787 methods = greenType.GetMethods (flags);
7789 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
7790 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
7791 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
7792 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
7793 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
7794 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
7795 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
7796 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
7797 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
7798 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
7799 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
7800 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
7801 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
7802 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
7803 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
7804 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
7805 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
7806 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
7807 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
7808 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
7809 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
7810 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
7811 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
7812 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
7813 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
7814 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
7815 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
7816 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
7817 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
7818 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
7819 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
7820 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
7821 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
7822 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
7823 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
7824 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
7827 [Test]
7828 [Category ("NotDotNet")] // mcs depends on this
7829 public void TestGetMethodsFlagsIncomplete_Mono ()
7831 MethodBuilder mb;
7832 ILGenerator ilgen;
7833 MethodInfo [] methods;
7835 TypeBuilder tb = module.DefineType (genTypeName (),
7836 TypeAttributes.Abstract);
7837 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7838 typeof (void), Type.EmptyTypes);
7839 ilgen = mb.GetILGenerator ();
7840 ilgen.Emit (OpCodes.Ret);
7842 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7843 typeof (void), Type.EmptyTypes);
7844 ilgen = mb.GetILGenerator ();
7845 ilgen.Emit (OpCodes.Ret);
7847 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7848 MethodAttributes.Static,
7849 typeof (void), Type.EmptyTypes);
7850 ilgen = mb.GetILGenerator ();
7851 ilgen.Emit (OpCodes.Ret);
7853 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7854 MethodAttributes.Abstract | MethodAttributes.Virtual,
7855 typeof (void), Type.EmptyTypes);
7857 methods = tb.GetMethods (BindingFlags.Public |
7858 BindingFlags.Instance);
7859 Assert.AreEqual (6, methods.Length, "#A1");
7860 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#A2");
7861 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#A3");
7862 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#A4");
7863 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#A5");
7864 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#A6");
7866 methods = tb.GetMethods (BindingFlags.Public |
7867 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7868 Assert.AreEqual (2, methods.Length, "#B1");
7869 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#B2");
7870 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#B3");
7872 methods = tb.GetMethods (BindingFlags.Public |
7873 BindingFlags.Instance | BindingFlags.Static);
7874 Assert.AreEqual (7, methods.Length, "#C1");
7875 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#C2");
7876 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#C3");
7877 Assert.IsNotNull (GetMethodByName (methods, "Execute"), "#C4");
7878 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#C5");
7879 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#C6");
7880 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#C7");
7882 methods = tb.GetMethods (BindingFlags.NonPublic |
7883 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7884 Assert.AreEqual (1, methods.Length, "#D1");
7885 Assert.IsNotNull (GetMethodByName (methods, "Run"), "#D2");
7889 [Test]
7890 [Category ("NotWorking")] // mcs depends on this
7891 public void TestGetMethodsFlagsIncomplete_MS ()
7893 MethodBuilder mb;
7894 ILGenerator ilgen;
7896 TypeBuilder tb = module.DefineType (genTypeName (),
7897 TypeAttributes.Abstract);
7898 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7899 typeof (void), Type.EmptyTypes);
7900 ilgen = mb.GetILGenerator ();
7901 ilgen.Emit (OpCodes.Ret);
7903 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7904 typeof (void), Type.EmptyTypes);
7905 ilgen = mb.GetILGenerator ();
7906 ilgen.Emit (OpCodes.Ret);
7908 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7909 MethodAttributes.Static,
7910 typeof (void), Type.EmptyTypes);
7911 ilgen = mb.GetILGenerator ();
7912 ilgen.Emit (OpCodes.Ret);
7914 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7915 MethodAttributes.Abstract | MethodAttributes.Virtual,
7916 typeof (void), Type.EmptyTypes);
7918 try {
7919 tb.GetMethods (BindingFlags.Public | BindingFlags.Instance);
7920 Assert.Fail ("#1");
7921 } catch (NotSupportedException ex) {
7922 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
7923 Assert.IsNull (ex.InnerException, "#3");
7924 Assert.IsNotNull (ex.Message, "#4");
7928 [Test]
7929 public void TestGetMethodsFlagsComplete ()
7931 TypeBuilder tb = module.DefineType (genTypeName ());
7932 MethodBuilder helloMethod = tb.DefineMethod ("HelloMethod",
7933 MethodAttributes.Public, typeof (string), Type.EmptyTypes);
7934 ILGenerator helloMethodIL = helloMethod.GetILGenerator ();
7935 helloMethodIL.Emit (OpCodes.Ldstr, "Hi! ");
7936 helloMethodIL.Emit (OpCodes.Ldarg_1);
7937 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
7938 new Type [] { typeof (string), typeof (string) });
7939 helloMethodIL.Emit (OpCodes.Call, infoMethod);
7940 helloMethodIL.Emit (OpCodes.Ret);
7942 Type emittedType = tb.CreateType ();
7944 Assert.AreEqual (1, tb.GetMethods (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Length, "#1");
7945 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length,
7946 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length, "#2");
7947 Assert.AreEqual (0, tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).Length, "#3");
7948 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length,
7949 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length, "#4");
7952 [Test]
7953 public void TestGetMethodsFlagsComplete_Inheritance ()
7955 MethodInfo [] methods;
7956 BindingFlags flags;
7958 TypeBuilder blueType = module.DefineType (genTypeName (),
7959 TypeAttributes.Public);
7960 CreateMembers (blueType, "Blue", false);
7962 TypeBuilder redType = module.DefineType (genTypeName (),
7963 TypeAttributes.Public, blueType);
7964 CreateMembers (redType, "Red", false);
7966 TypeBuilder greenType = module.DefineType (genTypeName (),
7967 TypeAttributes.Public, redType);
7968 CreateMembers (greenType, "Green", false);
7970 blueType.CreateType ();
7971 redType.CreateType ();
7972 greenType.CreateType ();
7974 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7975 methods = greenType.GetMethods (flags);
7977 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7978 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7979 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7980 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7981 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7982 #if NET_2_0
7983 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7984 #else
7985 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7986 #endif
7987 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7988 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7989 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7990 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7991 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7992 #if NET_2_0
7993 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7994 #else
7995 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7996 #endif
7997 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7998 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7999 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
8000 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
8001 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
8002 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
8003 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
8004 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
8005 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
8006 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
8007 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
8008 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
8009 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
8010 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
8011 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
8012 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
8013 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
8014 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
8015 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
8016 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
8017 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
8018 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
8019 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
8020 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
8022 flags = BindingFlags.Instance | BindingFlags.Public;
8023 methods = greenType.GetMethods (flags);
8025 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
8026 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
8027 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
8028 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
8029 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
8030 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
8031 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
8032 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
8033 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
8034 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
8035 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
8036 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
8037 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
8038 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
8039 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
8040 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
8041 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
8042 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
8043 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
8044 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
8045 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
8046 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
8047 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
8048 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
8049 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
8050 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
8051 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
8052 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
8053 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
8054 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
8055 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
8056 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
8057 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
8058 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
8059 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
8060 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
8062 flags = BindingFlags.Static | BindingFlags.Public;
8063 methods = greenType.GetMethods (flags);
8065 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
8066 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
8067 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
8068 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
8069 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
8070 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
8071 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
8072 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
8073 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
8074 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
8075 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
8076 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
8077 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
8078 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
8079 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
8080 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
8081 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
8082 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
8083 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
8084 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
8085 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
8086 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
8087 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
8088 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
8089 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
8090 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
8091 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
8092 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
8093 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
8094 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
8095 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
8096 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
8097 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
8098 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
8099 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
8100 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
8102 flags = BindingFlags.Static | BindingFlags.NonPublic;
8103 methods = greenType.GetMethods (flags);
8105 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
8106 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
8107 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
8108 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
8109 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
8110 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
8111 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
8112 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
8113 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
8114 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
8115 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
8116 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
8117 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
8118 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
8119 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
8120 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
8121 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
8122 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
8123 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
8124 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
8125 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
8126 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
8127 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
8128 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
8129 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
8130 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
8131 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
8132 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
8133 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
8134 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
8135 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
8136 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
8137 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
8138 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
8139 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
8140 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
8142 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8143 BindingFlags.FlattenHierarchy;
8144 methods = greenType.GetMethods (flags);
8146 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
8147 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
8148 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
8149 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
8150 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
8151 #if NET_2_0
8152 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
8153 #else
8154 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
8155 #endif
8156 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
8157 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
8158 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
8159 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
8160 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
8161 #if NET_2_0
8162 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
8163 #else
8164 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
8165 #endif
8166 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
8167 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
8168 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
8169 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
8170 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
8171 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
8172 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
8173 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
8174 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
8175 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
8176 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
8177 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
8178 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
8179 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
8180 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
8181 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
8182 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
8183 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
8184 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
8185 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
8186 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
8187 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
8188 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
8189 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
8191 flags = BindingFlags.Instance | BindingFlags.Public |
8192 BindingFlags.FlattenHierarchy;
8193 methods = greenType.GetMethods (flags);
8195 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
8196 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
8197 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
8198 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
8199 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
8200 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
8201 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
8202 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
8203 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
8204 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
8205 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
8206 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
8207 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
8208 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
8209 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
8210 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
8211 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
8212 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
8213 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
8214 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
8215 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
8216 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
8217 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
8218 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
8219 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
8220 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
8221 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
8222 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
8223 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
8224 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
8225 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
8226 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
8227 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
8228 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
8229 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
8230 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
8232 flags = BindingFlags.Static | BindingFlags.Public |
8233 BindingFlags.FlattenHierarchy;
8234 methods = greenType.GetMethods (flags);
8236 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
8237 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
8238 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
8239 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
8240 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
8241 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
8242 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
8243 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
8244 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
8245 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
8246 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
8247 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
8248 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
8249 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
8250 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
8251 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
8252 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
8253 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
8254 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
8255 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
8256 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
8257 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
8258 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
8259 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
8260 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
8261 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
8262 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
8263 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
8264 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
8265 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
8266 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
8267 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
8268 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
8269 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
8270 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
8271 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
8273 flags = BindingFlags.Static | BindingFlags.NonPublic |
8274 BindingFlags.FlattenHierarchy;
8275 methods = greenType.GetMethods (flags);
8277 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
8278 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
8279 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
8280 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
8281 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
8282 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
8283 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
8284 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
8285 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
8286 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
8287 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
8288 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
8289 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
8290 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
8291 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
8292 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
8293 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
8294 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
8295 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
8296 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
8297 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
8298 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
8299 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
8300 #if NET_2_0
8301 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
8302 #else
8303 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
8304 #endif
8305 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
8306 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
8307 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
8308 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
8309 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
8310 #if NET_2_0
8311 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
8312 #else
8313 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
8314 #endif
8315 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
8316 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
8317 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
8318 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
8319 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
8320 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
8322 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8323 BindingFlags.DeclaredOnly;
8324 methods = greenType.GetMethods (flags);
8326 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
8327 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
8328 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
8329 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
8330 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
8331 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
8332 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
8333 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
8334 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
8335 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
8336 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
8337 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
8338 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
8339 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
8340 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
8341 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
8342 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
8343 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
8344 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
8345 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
8346 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
8347 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
8348 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
8349 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
8350 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
8351 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
8352 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
8353 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
8354 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
8355 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
8356 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
8357 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
8358 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
8359 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
8360 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
8361 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
8363 flags = BindingFlags.Instance | BindingFlags.Public |
8364 BindingFlags.DeclaredOnly;
8365 methods = greenType.GetMethods (flags);
8367 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
8368 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
8369 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
8370 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
8371 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
8372 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
8373 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
8374 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
8375 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
8376 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
8377 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
8378 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
8379 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
8380 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
8381 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
8382 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
8383 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
8384 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
8385 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
8386 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
8387 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
8388 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
8389 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
8390 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
8391 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
8392 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
8393 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
8394 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
8395 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
8396 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
8397 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
8398 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
8399 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
8400 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
8401 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
8402 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
8404 flags = BindingFlags.Static | BindingFlags.Public |
8405 BindingFlags.DeclaredOnly;
8406 methods = greenType.GetMethods (flags);
8408 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
8409 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
8410 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
8411 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
8412 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
8413 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
8414 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
8415 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
8416 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
8417 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
8418 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
8419 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
8420 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
8421 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
8422 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
8423 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
8424 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
8425 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
8426 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
8427 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
8428 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
8429 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
8430 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
8431 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
8432 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
8433 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
8434 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
8435 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
8436 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
8437 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
8438 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
8439 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
8440 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
8441 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
8442 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
8443 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
8445 flags = BindingFlags.Static | BindingFlags.NonPublic |
8446 BindingFlags.DeclaredOnly;
8447 methods = greenType.GetMethods (flags);
8449 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
8450 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
8451 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
8452 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
8453 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
8454 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
8455 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
8456 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
8457 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
8458 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
8459 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
8460 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
8461 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
8462 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
8463 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
8464 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
8465 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
8466 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
8467 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
8468 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
8469 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
8470 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
8471 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
8472 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
8473 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
8474 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
8475 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
8476 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
8477 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
8478 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
8479 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
8480 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
8481 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
8482 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
8483 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
8484 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
8486 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8487 BindingFlags.Public;
8488 methods = greenType.GetMethods (flags);
8490 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
8491 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
8492 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
8493 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
8494 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
8495 #if NET_2_0
8496 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
8497 #else
8498 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
8499 #endif
8500 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
8501 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
8502 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
8503 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
8504 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
8505 #if NET_2_0
8506 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
8507 #else
8508 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
8509 #endif
8510 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
8511 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
8512 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
8513 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
8514 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
8515 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
8516 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
8517 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
8518 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
8519 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
8520 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
8521 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
8522 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
8523 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
8524 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
8525 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
8526 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
8527 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
8528 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
8529 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
8530 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
8531 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
8532 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
8533 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
8535 flags = BindingFlags.Static | BindingFlags.NonPublic |
8536 BindingFlags.Public;
8537 methods = greenType.GetMethods (flags);
8539 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
8540 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
8541 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
8542 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
8543 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
8544 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
8545 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
8546 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
8547 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
8548 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
8549 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
8550 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
8551 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
8552 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
8553 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
8554 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
8555 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
8556 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
8557 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
8558 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
8559 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
8560 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
8561 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
8562 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
8563 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
8564 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
8565 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
8566 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
8567 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
8568 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
8569 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
8570 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
8571 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
8572 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
8573 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
8574 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
8577 [Test]
8578 public void TestGetMemberIncomplete ()
8580 TypeBuilder tb = module.DefineType (genTypeName ());
8581 try {
8582 tb.GetMember ("FOO", MemberTypes.All, BindingFlags.Public);
8583 Assert.Fail ("#1");
8584 } catch (NotSupportedException ex) {
8585 // The invoked member is not supported in a
8586 // dynamic module
8587 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8588 Assert.IsNull (ex.InnerException, "#3");
8589 Assert.IsNotNull (ex.Message, "#4");
8593 [Test]
8594 public void TestGetMemberComplete ()
8596 TypeBuilder tb = module.DefineType (genTypeName ());
8597 tb.DefineField ("FOO", typeof (int), FieldAttributes.Private);
8599 Type emittedType = tb.CreateType ();
8601 Assert.AreEqual (1, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.NonPublic).Length);
8602 Assert.AreEqual (0, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.Public).Length);
8605 [Test]
8606 public void TestGetMembersIncomplete ()
8608 TypeBuilder tb = module.DefineType (genTypeName ());
8609 try {
8610 tb.GetMembers ();
8611 Assert.Fail ("#1");
8612 } catch (NotSupportedException ex) {
8613 // The invoked member is not supported in a
8614 // dynamic module
8615 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8616 Assert.IsNull (ex.InnerException, "#3");
8617 Assert.IsNotNull (ex.Message, "#4");
8621 [Test]
8622 public void TestGetMembersComplete ()
8624 TypeBuilder tb = module.DefineType (genTypeName ());
8625 Type emittedType = tb.CreateType ();
8627 Assert.AreEqual (tb.GetMembers ().Length, emittedType.GetMembers ().Length);
8630 [Test]
8631 public void TestGetMembersFlagsIncomplete ()
8633 TypeBuilder tb = module.DefineType (genTypeName ());
8634 try {
8635 tb.GetMembers (BindingFlags.Public);
8636 Assert.Fail ("#1");
8637 } catch (NotSupportedException ex) {
8638 // The invoked member is not supported in a
8639 // dynamic module
8640 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8641 Assert.IsNull (ex.InnerException, "#3");
8642 Assert.IsNotNull (ex.Message, "#4");
8646 [Test]
8647 public void TestGetMembersFlagsComplete ()
8649 TypeBuilder tb = module.DefineType (genTypeName ());
8650 tb.DefineField ("FOO", typeof (int), FieldAttributes.Public);
8652 Type emittedType = tb.CreateType ();
8654 Assert.IsTrue (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length != 0);
8655 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length,
8656 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length);
8657 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length,
8658 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length);
8661 [Test]
8662 public void TestGetInterfaceIncomplete ()
8664 TypeBuilder tb = module.DefineType (genTypeName ());
8665 try {
8666 tb.GetInterface ("FOO", true);
8667 Assert.Fail ("#1");
8668 } catch (NotSupportedException ex) {
8669 // The invoked member is not supported in a
8670 // dynamic module
8671 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8672 Assert.IsNull (ex.InnerException, "#3");
8673 Assert.IsNotNull (ex.Message, "#4");
8677 [Test]
8678 public void TestGetInterfaces ()
8680 TypeBuilder tb = module.DefineType (genTypeName ());
8681 Type [] interfaces = tb.GetInterfaces ();
8682 Assert.AreEqual (0, interfaces.Length);
8684 TypeBuilder tbInterface = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
8685 Type emittedInterface = tbInterface.CreateType ();
8687 tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { emittedInterface });
8688 interfaces = tb.GetInterfaces ();
8689 Assert.AreEqual (1, interfaces.Length);
8692 [Test]
8693 public void TestAddDeclarativeSecurityAlreadyCreated ()
8695 TypeBuilder tb = module.DefineType (genTypeName ());
8696 tb.CreateType ();
8698 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8699 try {
8700 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8701 Assert.Fail ("#1");
8702 } catch (InvalidOperationException ex) {
8703 // Unable to change after type has been created
8704 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8705 Assert.IsNull (ex.InnerException, "#3");
8706 Assert.IsNotNull (ex.Message, "#4");
8710 [Test]
8711 public void TestAddDeclarativeSecurityNullPermissionSet ()
8713 TypeBuilder tb = module.DefineType (genTypeName ());
8714 try {
8715 tb.AddDeclarativeSecurity (SecurityAction.Demand, null);
8716 Assert.Fail ("#1");
8717 } catch (ArgumentNullException ex) {
8718 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
8719 Assert.IsNull (ex.InnerException, "#3");
8720 Assert.IsNotNull (ex.Message, "#4");
8721 Assert.AreEqual ("pset", ex.ParamName, "#5");
8726 [Test]
8727 public void TestAddDeclarativeSecurityInvalidAction ()
8729 TypeBuilder tb = module.DefineType (genTypeName ());
8731 SecurityAction [] actions = new SecurityAction [] {
8732 SecurityAction.RequestMinimum,
8733 SecurityAction.RequestOptional,
8734 SecurityAction.RequestRefuse };
8735 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8737 foreach (SecurityAction action in actions) {
8738 try {
8739 tb.AddDeclarativeSecurity (action, set);
8740 Assert.Fail ();
8741 } catch (ArgumentOutOfRangeException) {
8746 [Test]
8747 public void TestAddDeclarativeSecurityDuplicateAction ()
8749 TypeBuilder tb = module.DefineType (genTypeName ());
8751 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8752 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8753 try {
8754 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8755 Assert.Fail ("#1");
8756 } catch (InvalidOperationException ex) {
8757 // Multiple permission sets specified with the
8758 // same SecurityAction
8759 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8760 Assert.IsNull (ex.InnerException, "#3");
8761 Assert.IsNotNull (ex.Message, "#4");
8765 [Test]
8766 public void TestEnums ()
8768 TypeAttributes typeAttrs = TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed;
8769 TypeBuilder enumToCreate = module.DefineType (genTypeName (), typeAttrs,
8770 typeof (Enum));
8771 enumToCreate.SetCustomAttribute (new CustomAttributeBuilder (typeof (FlagsAttribute).GetConstructors () [0], Type.EmptyTypes));
8772 // add value__ field, see DefineEnum method of ModuleBuilder
8773 enumToCreate.DefineField ("value__", typeof (Int32),
8774 FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
8776 // add enum entries
8777 FieldBuilder fb = enumToCreate.DefineField ("A", enumToCreate,
8778 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8779 fb.SetConstant ((Int32) 0);
8781 fb = enumToCreate.DefineField ("B", enumToCreate,
8782 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8783 fb.SetConstant ((Int32) 1);
8785 fb = enumToCreate.DefineField ("C", enumToCreate,
8786 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8787 fb.SetConstant ((Int32) 2);
8789 Type enumType = enumToCreate.CreateType ();
8791 object enumVal = Enum.ToObject (enumType, (Int32) 3);
8793 Assert.AreEqual ("B, C", enumVal.ToString ());
8794 Assert.AreEqual (3, (Int32) enumVal);
8797 [Test]
8798 public void DefineEnum ()
8800 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8801 TypeAttributes.Public);
8802 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8803 TypeAttributes.Public, typeof (int));
8804 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8805 enumBuilder.CreateType ();
8806 typeBuilder.CreateType ();
8809 [Test]
8810 [Category ("NotWorking")]
8811 public void DefineEnumThrowIfTypeBuilderCalledBeforeEnumBuilder ()
8813 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8814 TypeAttributes.Public);
8815 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8816 TypeAttributes.Public, typeof (int));
8817 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8818 try {
8819 typeBuilder.CreateType ();
8820 Assert.Fail ("#1");
8821 } catch (TypeLoadException) {
8822 // Could not load type '...' from assembly
8823 // 'MonoTests.System.Reflection.Emit.TypeBuilderTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
8825 #if NET_2_0
8826 Assert.IsTrue (typeBuilder.IsCreated (), "#2");
8827 Assert.IsNull (typeBuilder.CreateType (), "#3");
8828 #else
8829 try {
8830 typeBuilder.CreateType ();
8831 } catch (InvalidOperationException ex) {
8832 // Unable to change after type has been created
8833 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
8834 Assert.IsNull (ex.InnerException, "#B3");
8835 Assert.IsNotNull (ex.Message, "#B4");
8837 #endif
8840 [Test]
8841 public void SetCustomAttribute_SuppressUnmanagedCodeSecurity ()
8843 TypeBuilder tb = module.DefineType (genTypeName ());
8844 ConstructorInfo attrCtor = typeof (SuppressUnmanagedCodeSecurityAttribute).
8845 GetConstructor (Type.EmptyTypes);
8846 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
8847 attrCtor, new object [0]);
8848 Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#1");
8849 tb.SetCustomAttribute (caBuilder);
8850 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#2");
8851 Type emittedType = tb.CreateType ();
8852 Assert.AreEqual (TypeAttributes.HasSecurity, emittedType.Attributes & TypeAttributes.HasSecurity, "#3");
8853 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#4");
8854 object [] emittedAttrs = emittedType.GetCustomAttributes (typeof (SuppressUnmanagedCodeSecurityAttribute), true);
8855 Assert.AreEqual (1, emittedAttrs.Length, "#5");
8858 private PropertyBuilder DefineStringProperty (TypeBuilder tb, string propertyName, string fieldName, MethodAttributes methodAttribs)
8860 // define the field holding the property value
8861 FieldBuilder fieldBuilder = tb.DefineField (fieldName,
8862 typeof (string), FieldAttributes.Private);
8864 PropertyBuilder propertyBuilder = tb.DefineProperty (
8865 propertyName, PropertyAttributes.HasDefault, typeof (string),
8866 new Type [] { typeof (string) });
8868 // First, we'll define the behavior of the "get" property for CustomerName as a method.
8869 MethodBuilder getMethodBuilder = tb.DefineMethod ("Get" + propertyName,
8870 methodAttribs,
8871 typeof (string),
8872 new Type [] { });
8874 ILGenerator getIL = getMethodBuilder.GetILGenerator ();
8876 getIL.Emit (OpCodes.Ldarg_0);
8877 getIL.Emit (OpCodes.Ldfld, fieldBuilder);
8878 getIL.Emit (OpCodes.Ret);
8880 // Now, we'll define the behavior of the "set" property for CustomerName.
8881 MethodBuilder setMethodBuilder = tb.DefineMethod ("Set" + propertyName,
8882 methodAttribs,
8883 null,
8884 new Type [] { typeof (string) });
8886 ILGenerator setIL = setMethodBuilder.GetILGenerator ();
8888 setIL.Emit (OpCodes.Ldarg_0);
8889 setIL.Emit (OpCodes.Ldarg_1);
8890 setIL.Emit (OpCodes.Stfld, fieldBuilder);
8891 setIL.Emit (OpCodes.Ret);
8893 // Last, we must map the two methods created above to our PropertyBuilder to
8894 // their corresponding behaviors, "get" and "set" respectively.
8895 propertyBuilder.SetGetMethod (getMethodBuilder);
8896 propertyBuilder.SetSetMethod (setMethodBuilder);
8897 return propertyBuilder;
8900 static int handler_called = 0;
8902 [Test]
8903 public void TestTypeResolve ()
8905 string typeName = genTypeName ();
8907 ResolveEventHandler handler = new ResolveEventHandler (TypeResolve);
8908 AppDomain.CurrentDomain.TypeResolve += handler;
8909 handler_called = 0;
8910 Type t = Type.GetType (typeName);
8911 Assert.AreEqual (typeName, t.Name);
8912 Assert.AreEqual (1, handler_called);
8913 AppDomain.CurrentDomain.TypeResolve -= handler;
8916 Assembly TypeResolve (object sender, ResolveEventArgs args)
8918 TypeBuilder tb = module.DefineType (args.Name, TypeAttributes.Public);
8919 tb.CreateType ();
8920 handler_called++;
8921 return tb.Assembly;
8924 [Test]
8925 public void IsAssignableFrom_Created ()
8927 TypeBuilder tb = module.DefineType (genTypeName (),
8928 TypeAttributes.Public, typeof (MemoryStream),
8929 new Type [] { typeof (IThrowable), typeof (Bar) });
8930 tb.AddInterfaceImplementation (typeof (IDestroyable));
8931 Type emitted_type = tb.CreateType ();
8933 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8934 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8935 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8936 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8937 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb), "#A5");
8938 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#A6");
8939 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#A7");
8940 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#A8");
8941 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#A9");
8942 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#A10");
8943 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#A11");
8944 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#A12");
8945 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A13");
8946 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A14");
8947 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A15");
8948 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A16");
8949 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A17");
8950 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A18");
8952 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#B1");
8953 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#B2");
8954 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#B3");
8955 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#B4");
8956 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#B5");
8957 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#B6");
8958 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#B7");
8959 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#B8");
8960 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#B9");
8961 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#B10");
8963 Assert.IsTrue (tb.IsAssignableFrom (tb), "#C1");
8964 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#C2");
8965 Assert.IsTrue (tb.IsAssignableFrom (emitted_type), "#C3");
8966 Assert.IsTrue (emitted_type.IsAssignableFrom (tb), "#C4");
8967 Assert.IsFalse (emitted_type.IsAssignableFrom ((Type) null), "#C5");
8969 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type), "#D1");
8970 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IThrowable)), "#D2");
8971 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type), "#D3");
8972 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IMoveable)), "#D4");
8973 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type), "#D5");
8974 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Foo)), "#D6");
8975 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type), "#D7");
8976 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Bar)), "#D8");
8977 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type), "#D9");
8978 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Baz)), "#D10");
8979 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type), "#D11");
8980 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDestroyable)), "#D12");
8981 Assert.IsFalse (typeof (IAir).IsAssignableFrom (emitted_type), "#D13");
8982 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IAir)), "#D14");
8983 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type), "#D15");
8984 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IWater)), "#D16");
8985 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type), "#D17");
8986 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (ILiquid)), "#D18");
8988 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type), "#E1");
8989 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (MemoryStream)), "#E2");
8990 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type), "#E3");
8991 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Stream)), "#E4");
8992 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type), "#E5");
8993 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (FileStream)), "#E6");
8994 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type), "#E7");
8995 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (object)), "#E8");
8996 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type), "#E9");
8997 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDisposable)), "#E10");
8999 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9000 tb.FullName + "[]")), "#F1");
9001 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9002 tb.FullName + "[]")), "#F2");
9003 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9004 tb.FullName + "[]")), "#F3");
9006 TypeBuilder tb2 = module.DefineType (genTypeName (),
9007 TypeAttributes.Public, tb,
9008 new Type [] { typeof (IAir) });
9009 Type emitted_type2 = tb2.CreateType ();
9011 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#G1");
9012 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#G2");
9013 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#G3");
9014 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#G4");
9015 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#G5");
9016 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#G6");
9017 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#G7");
9018 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#G8");
9019 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#G9");
9020 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#G10");
9021 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#G11");
9022 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDestroyable)), "#G12");
9023 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#G13");
9024 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#G14");
9025 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#G15");
9026 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#G16");
9027 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#G17");
9028 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#G18");
9030 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#H1");
9031 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#H2");
9032 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#H3");
9033 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#H4");
9034 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#H5");
9035 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#H6");
9036 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#H7");
9037 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#H8");
9038 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#H9");
9039 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#H10");
9041 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#I1");
9042 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#I2");
9043 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type2), "#I3");
9044 Assert.IsFalse (tb2.IsAssignableFrom (emitted_type), "#I4");
9045 Assert.IsFalse (tb2.IsAssignableFrom ((Type) null), "#I5");
9046 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type2), "#I6");
9047 Assert.IsFalse (emitted_type2.IsAssignableFrom (emitted_type), "#I7");
9048 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb2), "#I8");
9049 Assert.IsFalse (emitted_type2.IsAssignableFrom (tb), "#I9");
9050 Assert.IsFalse (emitted_type2.IsAssignableFrom ((Type) null), "#I10");
9051 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#I11");
9052 Assert.IsTrue (tb.IsAssignableFrom (emitted_type2), "#I12");
9053 Assert.IsTrue (emitted_type.IsAssignableFrom (tb2), "#I13");
9054 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type2), "#I14");
9056 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type2), "#J1");
9057 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IThrowable)), "#J2");
9058 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type2), "#J3");
9059 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IMoveable)), "#J4");
9060 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type2), "#J5");
9061 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Foo)), "#J6");
9062 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type2), "#J7");
9063 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Bar)), "#J8");
9064 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type2), "#J9");
9065 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Baz)), "#J10");
9066 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#J11");
9067 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDestroyable)), "#J12");
9068 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type2), "#J13");
9069 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IAir)), "#J14");
9070 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type2), "#J15");
9071 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IWater)), "#J16");
9072 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type2), "#J17");
9073 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (ILiquid)), "#J18");
9075 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type2), "#K1");
9076 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (MemoryStream)), "#K2");
9077 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type2), "#K3");
9078 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Stream)), "#K4");
9079 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type2), "#K5");
9080 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (FileStream)), "#K6");
9081 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type2), "#K7");
9082 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (object)), "#K8");
9083 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type2), "#K9");
9084 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDisposable)), "#K10");
9086 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9087 tb2.FullName + "[]")), "#L1");
9088 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9089 tb2.FullName + "[]")), "#L2");
9090 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9091 tb2.FullName + "[]")), "#L3");
9093 TypeBuilder tb3 = module.DefineType (genTypeName (),
9094 TypeAttributes.Public, tb2,
9095 new Type [] { typeof (IWater) });
9096 Type emitted_type3 = tb3.CreateType ();
9098 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#M1");
9099 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#M2");
9100 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#M3");
9101 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#M4");
9102 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#M5");
9103 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#M6");
9104 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#M7");
9105 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#M8");
9106 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#M9");
9107 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#M10");
9108 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb3), "#M11");
9109 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDestroyable)), "#M12");
9110 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#M13");
9111 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#M14");
9112 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#M15");
9113 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#M16");
9114 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (tb3), "#M17");
9115 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#M18");
9117 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#N1");
9118 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#N2");
9119 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#N3");
9120 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#N4");
9121 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#N5");
9122 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#N6");
9123 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#N7");
9124 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#N8");
9125 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#N9");
9126 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#N10");
9128 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#O1");
9129 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#O2");
9130 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#O3");
9131 Assert.IsTrue (tb3.IsAssignableFrom (emitted_type3), "#O4");
9132 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type2), "#O5");
9133 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type), "#O6");
9134 Assert.IsFalse (tb3.IsAssignableFrom ((Type) null), "#O7");
9135 Assert.IsTrue (emitted_type3.IsAssignableFrom (emitted_type3), "#O8");
9136 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type2), "#O9");
9137 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type), "#O10");
9138 Assert.IsTrue (emitted_type3.IsAssignableFrom (tb3), "#O11");
9139 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb2), "#O12");
9140 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb), "#O13");
9141 Assert.IsFalse (emitted_type3.IsAssignableFrom ((Type) null), "#O14");
9142 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#O15");
9143 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type3), "#O16");
9144 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type3), "#O17");
9145 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb3), "#O18");
9146 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#O19");
9147 Assert.IsTrue (tb.IsAssignableFrom (emitted_type3), "#O20");
9148 Assert.IsTrue (emitted_type.IsAssignableFrom (tb3), "#021");
9149 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type3), "#O22");
9151 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type3), "#P1");
9152 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IThrowable)), "#P2");
9153 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type3), "#P3");
9154 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IMoveable)), "#P4");
9155 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type3), "#P5");
9156 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Foo)), "#P6");
9157 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type3), "#P7");
9158 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Bar)), "#P8");
9159 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type3), "#P9");
9160 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Baz)), "#P10");
9161 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type3), "#P11");
9162 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDestroyable)), "#P12");
9163 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type3), "#P13");
9164 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IAir)), "#P14");
9165 Assert.IsTrue (typeof (IWater).IsAssignableFrom (emitted_type3), "#P15");
9166 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IWater)), "#P16");
9167 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (emitted_type3), "#P17");
9168 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (ILiquid)), "#P18");
9170 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type3), "#Q1");
9171 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (MemoryStream)), "#Q2");
9172 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type3), "#Q3");
9173 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Stream)), "#Q4");
9174 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type3), "#Q5");
9175 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (FileStream)), "#Q6");
9176 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type3), "#Q7");
9177 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (object)), "#Q8");
9178 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type3), "#Q9");
9179 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDisposable)), "#Q10");
9181 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9182 tb3.FullName + "[]")), "#R1");
9183 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9184 tb3.FullName + "[]")), "#R2");
9185 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9186 tb3.FullName + "[]")), "#R3");
9188 #if NET_2_0
9189 TypeBuilder tb4 = module.DefineType (genTypeName (),
9190 TypeAttributes.Public, null,
9191 new Type [] { typeof (IWater) });
9192 tb4.DefineGenericParameters ("T");
9194 Type inst = tb4.MakeGenericType (typeof (int));
9195 Type emitted_type4 = tb4.CreateType ();
9196 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (inst));
9197 // This returns True if CreateType () is called _before_ MakeGenericType...
9198 //Assert.IsFalse (typeof (IWater).IsAssignableFrom (inst));
9199 #endif
9202 [Test]
9203 public void IsAssignableFrom_NotCreated ()
9205 TypeBuilder tb = module.DefineType (genTypeName (),
9206 TypeAttributes.Public, typeof (MemoryStream),
9207 new Type [] {
9208 typeof (IThrowable), typeof (Bar),
9209 typeof (IComparable)
9212 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9213 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9214 //Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
9215 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
9216 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb), "#A5");
9217 Assert.IsFalse (tb.IsAssignableFrom (typeof (IComparable)), "#A6");
9218 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A7");
9219 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A8");
9220 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A9");
9221 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A10");
9222 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A11");
9223 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A12");
9225 //Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb), "#B1");
9226 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#B2");
9227 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#B3");
9228 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#B4");
9229 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#B5");
9230 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#B6");
9232 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#C1");
9233 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#C2");
9234 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#C3");
9235 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#C4");
9236 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#C5");
9237 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#C6");
9238 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#C7");
9239 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#C8");
9240 Assert.IsFalse (typeof (IDisposable).IsAssignableFrom (tb), "#C9");
9241 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#C10");
9243 Assert.IsTrue (tb.IsAssignableFrom (tb), "#D1");
9244 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#D2");
9246 TypeBuilder tb2 = module.DefineType (genTypeName (),
9247 TypeAttributes.Public, tb,
9248 new Type [] { typeof (IAir) });
9250 Assert.IsFalse (typeof (IThrowable).IsAssignableFrom (tb2), "#E1");
9251 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#E2");
9252 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb2), "#E3");
9253 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#E4");
9254 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (tb2), "#E5");
9255 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IComparable)), "#E6");
9256 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#E7");
9257 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#E8");
9258 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#E9");
9259 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#E10");
9260 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#E11");
9261 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#E12");
9263 Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb2), "#F1");
9264 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#F2");
9265 Assert.IsFalse (typeof (Bar).IsAssignableFrom (tb2), "#F3");
9266 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#F4");
9267 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#F5");
9268 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#F6");
9270 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#G1");
9271 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#G2");
9272 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#G3");
9273 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#G4");
9274 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#G5");
9275 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#G6");
9276 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#G7");
9277 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#G8");
9278 Assert.IsFalse (typeof (IDisposable).IsAssignableFrom (tb2), "#G9");
9279 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#G10");
9281 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#H1");
9282 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#H2");
9283 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#H3");
9285 TypeBuilder tb3 = module.DefineType (genTypeName (),
9286 TypeAttributes.Public, tb2,
9287 new Type [] { typeof (IWater) });
9289 Assert.IsFalse (typeof (IThrowable).IsAssignableFrom (tb3), "#I1");
9290 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#I2");
9291 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb3), "#I3");
9292 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#I4");
9293 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (tb3), "#I5");
9294 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IComparable)), "#I6");
9295 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb3), "#I7");
9296 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#I8");
9297 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#I9");
9298 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#I10");
9299 //Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb3), "#I11");
9300 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#I12");
9302 Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb3), "#J1");
9303 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#J2");
9304 Assert.IsFalse (typeof (Bar).IsAssignableFrom (tb3), "#J3");
9305 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#J4");
9306 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#J5");
9307 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#J6");
9309 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#K1");
9310 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#K2");
9311 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#K3");
9312 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#K4");
9313 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#K5");
9314 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#K6");
9315 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#K7");
9316 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#K8");
9317 Assert.IsFalse (typeof (IDisposable).IsAssignableFrom (tb3), "#K9");
9318 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#K10");
9320 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#L1");
9321 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#L2");
9322 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#L3");
9323 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#L4");
9324 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#L5");
9327 [Test]
9328 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9329 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_Mono ()
9331 TypeBuilder tb = module.DefineType (genTypeName (),
9332 TypeAttributes.Public, typeof (FormatException),
9333 new Type [] { typeof (IThrowable) });
9334 tb.AddInterfaceImplementation (typeof (IDestroyable));
9336 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9337 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9339 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9340 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9343 [Test]
9344 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9345 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_MS ()
9347 TypeBuilder tb = module.DefineType (genTypeName (),
9348 TypeAttributes.Public, typeof (FormatException),
9349 new Type [] { typeof (IThrowable) });
9350 tb.AddInterfaceImplementation (typeof (IDestroyable));
9352 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9353 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9355 Assert.IsFalse (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9356 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9360 [Test]
9361 [Category ("NotDotNet")]
9362 public void IsAssignableFrom_NotCreated_Array ()
9364 TypeBuilder tb = module.DefineType (genTypeName (),
9365 TypeAttributes.Public, typeof (FormatException),
9366 new Type [] {
9367 typeof (IThrowable), typeof (Bar),
9368 typeof (IComparable)
9371 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9372 tb.FullName + "[]")), "#1");
9373 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9374 tb.FullName + "[]")), "#2");
9375 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9376 tb.FullName + "[]")), "#3");
9379 [Test]
9380 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9381 public void IsAssignableFrom_NotCreated_BaseInterface_Mono ()
9383 TypeBuilder tb = module.DefineType (genTypeName (),
9384 TypeAttributes.Public, typeof (FormatException),
9385 new Type [] {
9386 typeof (IThrowable), typeof (Bar),
9387 typeof (IComparable)
9390 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9391 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9394 [Test]
9395 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9396 public void IsAssignableFrom_NotCreated_BaseInterface_MS ()
9398 TypeBuilder tb = module.DefineType (genTypeName (),
9399 TypeAttributes.Public, typeof (FormatException),
9400 new Type [] {
9401 typeof (IThrowable), typeof (Bar),
9402 typeof (IComparable)
9405 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9406 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9409 [Test]
9410 public void CreateType_EmptyMethodBody ()
9412 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9414 tb.DefineMethod ("foo", MethodAttributes.Public, typeof (void), new Type [] { });
9415 try {
9416 tb.CreateType ();
9417 Assert.Fail ("#1");
9418 } catch (InvalidOperationException ex) {
9419 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9420 Assert.IsNull (ex.InnerException, "#3");
9421 Assert.IsNotNull (ex.Message, "#4");
9425 [Test]
9426 public void CreateType_EmptyCtorBody ()
9428 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9430 tb.DefineConstructor (0, CallingConventions.Standard, null);
9431 try {
9432 tb.CreateType ();
9433 Assert.Fail ("#1");
9434 } catch (InvalidOperationException ex) {
9435 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9436 Assert.IsNull (ex.InnerException, "#3");
9437 Assert.IsNotNull (ex.Message, "#4");
9441 [Test]
9442 #if ONLY_1_1
9443 [Category ("NotDotNet")] // Parent type was not extensible by the given type
9444 #endif
9445 [Category ("NotWorking")]
9446 public void CreateType_Interface_ParentInvalid ()
9448 TypeBuilder tb;
9450 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9451 typeof (Exception));
9452 Assert.AreEqual (typeof (Exception), tb.BaseType, "#A1");
9453 try {
9454 tb.CreateType ();
9455 Assert.Fail ("#A2");
9456 } catch (TypeLoadException ex) {
9457 // Could not load interface 't5' from assembly '...'
9458 // because it must extend from Object
9459 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A3");
9460 Assert.IsNull (ex.InnerException, "#A4");
9461 Assert.IsNotNull (ex.Message, "#A5");
9462 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#A6");
9463 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#A7");
9466 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9467 typeof (object));
9468 Assert.AreEqual (typeof (object), tb.BaseType, "#B1");
9469 try {
9470 tb.CreateType ();
9471 Assert.Fail ("#B2");
9472 } catch (TypeLoadException ex) {
9473 // Failure has occurred while loading a type
9474 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B3");
9475 Assert.IsNull (ex.InnerException, "#B4");
9476 Assert.IsNotNull (ex.Message, "#B5");
9479 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9480 typeof (EmptyInterface));
9481 Assert.AreEqual (typeof (EmptyInterface), tb.BaseType, "#C1");
9482 try {
9483 tb.CreateType ();
9484 Assert.Fail ("#C2");
9485 } catch (TypeLoadException ex) {
9486 // Could not load interface 't5' from assembly '...'
9487 // because the parent type is an interface
9488 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#C3");
9489 Assert.IsNull (ex.InnerException, "#C4");
9490 Assert.IsNotNull (ex.Message, "#C5");
9491 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#C6");
9492 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#C7");
9496 [Test]
9497 public void CreateType_Parent_DefaultCtorMissing ()
9499 TypeBuilder tb;
9501 tb = module.DefineType (genTypeName ());
9502 ConstructorBuilder cb = tb.DefineConstructor (
9503 MethodAttributes.Public,
9504 CallingConventions.Standard,
9505 new Type [] { typeof (string) });
9506 cb.GetILGenerator ().Emit (OpCodes.Ret);
9507 Type parent_type = tb.CreateType ();
9509 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
9510 parent_type);
9511 try {
9512 tb.CreateType ();
9513 Assert.Fail ("#1");
9514 } catch (NotSupportedException ex) {
9515 // Parent does not have a default constructor.
9516 // The default constructor must be explicitly defined
9517 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
9518 Assert.IsNull (ex.InnerException, "#3");
9519 Assert.IsNotNull (ex.Message, "#4");
9523 [Test]
9524 public void CreateType_Parent_Null ()
9526 TypeBuilder tb;
9527 Type emitted_type;
9529 tb = module.DefineType (genTypeName (), TypeAttributes.Public, null);
9530 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
9531 emitted_type = tb.CreateType ();
9532 Assert.AreEqual (typeof (object), emitted_type.BaseType, "#A2");
9534 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract, null);
9535 Assert.IsNull (tb.BaseType, "#B1");
9536 emitted_type = tb.CreateType ();
9537 Assert.IsNull (emitted_type.BaseType, "#B2");
9540 #if NET_2_0
9541 [Test]
9542 [Category ("NotWorking")]
9543 public void DefineGenericParameters_AlreadyDefined ()
9545 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9546 tb.DefineGenericParameters ("K");
9547 try {
9548 tb.DefineGenericParameters ("V");
9549 Assert.Fail ("#1");
9550 } catch (InvalidOperationException ex) {
9551 // Operation is not valid due to the current
9552 // state of the object
9553 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9554 Assert.IsNull (ex.InnerException, "#3");
9555 Assert.IsNotNull (ex.Message, "#4");
9559 [Test]
9560 public void DefineGenericParameters_Names_Empty ()
9562 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9564 try {
9565 tb.DefineGenericParameters (new string [0]);
9566 Assert.Fail ("#1");
9567 } catch (ArgumentException ex) {
9568 // Value does not fall within the expected range
9569 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9570 Assert.IsNull (ex.InnerException, "#3");
9571 Assert.IsNotNull (ex.Message, "#4");
9572 Assert.IsNull (ex.ParamName, "#5");
9576 [Test]
9577 public void DefineGenericParameters_Names_Null ()
9579 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9581 try {
9582 tb.DefineGenericParameters ((string []) null);
9583 Assert.Fail ("#A1");
9584 } catch (ArgumentNullException ex) {
9585 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9586 Assert.IsNull (ex.InnerException, "#A3");
9587 Assert.IsNotNull (ex.Message, "#A4");
9588 Assert.AreEqual ("names", ex.ParamName, "#A5");
9591 try {
9592 tb.DefineGenericParameters ("K", null, "V");
9593 Assert.Fail ("#B1");
9594 } catch (ArgumentNullException ex) {
9595 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9596 Assert.IsNull (ex.InnerException, "#B3");
9597 Assert.IsNotNull (ex.Message, "#B4");
9598 Assert.AreEqual ("names", ex.ParamName, "#B5");
9602 [Test]
9603 public void GenericType ()
9605 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9606 tb.DefineGenericParameters ("T");
9608 Assert.IsTrue (tb.IsGenericType, "#A1");
9609 Assert.IsTrue (tb.IsGenericTypeDefinition, "#A2");
9610 Assert.IsTrue (tb.ContainsGenericParameters, "#A3");
9611 Assert.IsFalse (tb.IsGenericParameter, "#A4");
9613 Type[] args = tb.GetGenericArguments ();
9614 Assert.IsFalse (args [0].IsGenericType, "#B1");
9615 Assert.IsFalse (args [0].IsGenericTypeDefinition, "#B2");
9616 Assert.IsTrue (args [0].ContainsGenericParameters, "#B3");
9617 Assert.IsTrue (args [0].IsGenericParameter, "#B4");
9620 [Test]
9621 public void MakeGenericType ()
9623 TypeBuilder tb;
9624 Type generic_type;
9626 tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9627 tb.DefineGenericParameters ("T");
9629 generic_type = tb.MakeGenericType (typeof (int));
9630 Assert.IsTrue (generic_type.IsGenericType, "#A1");
9631 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A2");
9632 Assert.IsFalse (generic_type.ContainsGenericParameters, "#A3");
9633 Assert.IsFalse (generic_type.IsGenericParameter, "#A4");
9635 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9636 Assert.IsTrue (generic_type.IsGenericType, "#B1");
9637 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B2");
9638 Assert.IsTrue (generic_type.ContainsGenericParameters, "#B3");
9639 Assert.IsFalse (generic_type.IsGenericParameter, "#B4");
9641 tb = module.DefineType (genTypeName (), TypeAttributes.Interface
9642 | TypeAttributes.Abstract | TypeAttributes.Public);
9643 tb.DefineGenericParameters ("T");
9645 generic_type = tb.MakeGenericType (typeof (int));
9646 Assert.IsTrue (generic_type.IsGenericType, "#C1");
9647 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#C2");
9648 Assert.IsFalse (generic_type.ContainsGenericParameters, "#C3");
9649 Assert.IsFalse (generic_type.IsGenericParameter, "#C4");
9651 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9652 Assert.IsTrue (generic_type.IsGenericType, "#D1");
9653 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#D2");
9654 Assert.IsTrue (generic_type.ContainsGenericParameters, "#D3");
9655 Assert.IsFalse (generic_type.IsGenericParameter, "#D4");
9658 [Test]
9659 public void MakeGenericType_NoGenericTypeDefinition ()
9661 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9662 try {
9663 tb.MakeGenericType (typeof (int));
9664 Assert.Fail ("#1");
9665 } catch (InvalidOperationException ex) {
9666 // Operation is not valid due to the current
9667 // state of the object
9668 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9669 Assert.IsNull (ex.InnerException, "#3");
9670 Assert.IsNotNull (ex.Message, "#4");
9674 [Test]
9675 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9676 public void MakeGenericType_TypeArguments_Null_Mono ()
9678 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9679 tb.DefineGenericParameters ("K", "V");
9681 try {
9682 tb.MakeGenericType ((Type []) null);
9683 Assert.Fail ("#A1");
9684 } catch (ArgumentNullException ex) {
9685 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9686 Assert.IsNull (ex.InnerException, "#A3");
9687 Assert.IsNotNull (ex.Message, "#A4");
9688 Assert.AreEqual ("typeArguments", ex.ParamName, "#A5");
9691 try {
9692 tb.MakeGenericType (typeof (string), (Type) null);
9693 Assert.Fail ("#B1");
9694 } catch (ArgumentNullException ex) {
9695 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9696 Assert.IsNull (ex.InnerException, "#B3");
9697 Assert.IsNotNull (ex.Message, "#B4");
9698 Assert.AreEqual ("typeArguments", ex.ParamName, "#B5");
9702 [Test]
9703 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9704 public void MakeGenericType_TypeArguments_Null_MS ()
9706 Type generic_type;
9707 Type [] type_args;
9709 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9710 tb.DefineGenericParameters ("K", "V");
9712 generic_type = tb.MakeGenericType ((Type []) null);
9713 Assert.IsNotNull (generic_type, "#A1");
9714 Assert.IsTrue (generic_type.IsGenericType, "#A2");
9715 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A3");
9716 type_args = generic_type.GetGenericArguments ();
9717 Assert.IsNull (type_args, "#A4");
9719 generic_type = tb.MakeGenericType (typeof (string), (Type) null);
9720 Assert.IsNotNull (generic_type, "#B1");
9721 Assert.IsTrue (generic_type.IsGenericType, "#B2");
9722 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B3");
9723 type_args = generic_type.GetGenericArguments ();
9724 Assert.IsNotNull (type_args, "#B4");
9725 Assert.AreEqual (2, type_args.Length, "#B5");
9726 Assert.AreEqual (typeof (string), type_args [0], "#B6");
9727 Assert.IsNull (type_args [1], "#B7");
9730 [Test]
9731 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9732 public void MakeGenericType_TypeArguments_Mismatch_Mono ()
9734 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9735 tb.DefineGenericParameters ("K", "V");
9736 try {
9737 tb.MakeGenericType (typeof (int));
9738 Assert.Fail ("#1");
9739 } catch (ArgumentException ex) {
9740 // The type or method has 2 generic prarameter(s)
9741 // but 1 generic argument(s) were provided. A
9742 // generic argument must be provided for each
9743 // generic parameter
9744 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9745 Assert.IsNull (ex.InnerException, "#3");
9746 Assert.IsNotNull (ex.Message, "#4");
9747 Assert.AreEqual ("typeArguments", ex.ParamName, "#5");
9751 [Test]
9752 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9753 public void MakeGenericType_TypeArguments_Mismatch_MS ()
9755 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9756 tb.DefineGenericParameters ("K", "V");
9758 Type generic_type = tb.MakeGenericType (typeof (int));
9759 Assert.IsTrue (generic_type.IsGenericType, "#1");
9760 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#2");
9761 Type [] type_args = generic_type.GetGenericArguments ();
9762 Assert.IsNotNull (type_args, "#3");
9763 Assert.AreEqual (1, type_args.Length, "#4");
9764 Assert.AreEqual (typeof (int), type_args [0], "#5");
9767 [Test]
9768 public void MakeArrayType_Complete ()
9770 // reference type
9771 TypeBuilder tb = module.DefineType (genTypeName (),
9772 TypeAttributes.Sealed | TypeAttributes.Serializable,
9773 typeof (ContextBoundObject));
9774 Type emittedType = tb.CreateType ();
9775 Type arrayType = tb.MakeArrayType ();
9776 Assert.IsTrue (arrayType.IsArray, "#A1");
9777 Assert.IsTrue (arrayType.HasElementType, "#A2");
9778 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9779 Assert.IsFalse (tb.HasElementType, "#A4");
9780 Assert.IsTrue (tb.IsCreated (), "#A5");
9782 // value type
9783 tb = module.DefineType (genTypeName (),
9784 TypeAttributes.Sealed | TypeAttributes.Serializable,
9785 typeof (ValueType));
9786 emittedType = tb.CreateType ();
9787 arrayType = tb.MakeArrayType ();
9788 Assert.IsTrue (arrayType.IsArray, "#B1");
9789 Assert.IsTrue (arrayType.HasElementType, "#B2");
9790 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9791 Assert.IsFalse (tb.HasElementType, "#B4");
9792 Assert.IsTrue (tb.IsCreated (), "#B5");
9794 tb = module.DefineType (genTypeName (),
9795 TypeAttributes.Sealed | TypeAttributes.Serializable,
9796 typeof (Enum));
9797 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
9798 FieldAttributes.Private | FieldAttributes.RTSpecialName);
9799 emittedType = tb.CreateType ();
9800 arrayType = tb.MakeArrayType ();
9801 Assert.IsTrue (arrayType.IsArray, "#C1");
9802 Assert.IsTrue (arrayType.HasElementType, "#C2");
9803 Assert.AreEqual (tb, arrayType.GetElementType (), "#C3");
9804 Assert.IsFalse (tb.HasElementType, "#C4");
9805 Assert.IsTrue (tb.IsCreated (), "#C5");
9808 [Test] // bug #82015
9809 public void MakeArrayType_Incomplete ()
9811 // reference type
9812 TypeBuilder tb = module.DefineType (genTypeName (),
9813 TypeAttributes.Sealed | TypeAttributes.Serializable,
9814 typeof (ContextBoundObject));
9815 Type arrayType = tb.MakeArrayType ();
9816 Assert.IsTrue (arrayType.IsArray, "#A1");
9817 Assert.IsTrue (arrayType.HasElementType, "#A2");
9818 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9819 Assert.IsFalse (tb.HasElementType, "#A4");
9820 Assert.IsFalse (tb.IsCreated (), "#A5");
9822 // value type
9823 tb = module.DefineType (genTypeName (),
9824 TypeAttributes.Sealed | TypeAttributes.Serializable,
9825 typeof (ValueType));
9826 arrayType = tb.MakeArrayType ();
9827 Assert.IsTrue (arrayType.IsArray, "#B1");
9828 Assert.IsTrue (arrayType.HasElementType, "#B2");
9829 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9830 Assert.IsFalse (tb.HasElementType, "#B4");
9831 Assert.IsFalse (tb.IsCreated (), "#B5");
9833 // enum
9834 tb = module.DefineType (genTypeName (),
9835 TypeAttributes.Sealed | TypeAttributes.Serializable,
9836 typeof (Enum));
9837 arrayType = tb.MakeArrayType ();
9838 Assert.IsTrue (arrayType.IsArray, "#C1");
9839 Assert.IsTrue (arrayType.HasElementType, "#C2");
9840 Assert.IsFalse (tb.HasElementType, "#C3");
9841 Assert.IsFalse (tb.IsCreated (), "#C4");
9844 [Test]
9845 public void GetCustomAttributes_InflatedType ()
9847 TypeBuilder tb = module.DefineType (genTypeName ());
9848 tb.DefineGenericParameters (new string[] { "FOO" });
9850 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
9851 new Type [] { typeof (string) });
9853 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
9854 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
9856 tb.SetCustomAttribute (caBuilder);
9857 Type t = tb.CreateType ();
9859 Type inflated = t.MakeGenericType (new Type [] { typeof (int) });
9861 Assert.AreEqual (1, inflated.GetCustomAttributes (false).Length);
9864 [Test]
9865 public void GetField ()
9867 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9868 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
9870 ConstructorBuilder cb = tb.DefineDefaultConstructor (MethodAttributes.Public);
9872 FieldBuilder fb1 = tb.DefineField ("field1", typeParams [0], FieldAttributes.Public);
9874 Type t = tb.MakeGenericType (typeof (int));
9876 // Chect that calling MakeArrayType () does not initialize the class
9877 // (bug #351172)
9878 t.MakeArrayType ();
9880 // Check that the instantiation of a type builder contains live data
9881 TypeBuilder.GetField (t, fb1);
9882 FieldBuilder fb2 = tb.DefineField ("field2", typeParams [0], FieldAttributes.Public);
9883 FieldInfo fi2 = TypeBuilder.GetField (t, fb1);
9885 MethodBuilder mb = tb.DefineMethod ("get_int", MethodAttributes.Public|MethodAttributes.Static, typeof (int), Type.EmptyTypes);
9886 ILGenerator ilgen = mb.GetILGenerator ();
9887 ilgen.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t, cb));
9888 ilgen.Emit (OpCodes.Dup);
9889 ilgen.Emit (OpCodes.Ldc_I4, 42);
9890 ilgen.Emit (OpCodes.Stfld, fi2);
9891 ilgen.Emit (OpCodes.Ldfld, fi2);
9892 ilgen.Emit (OpCodes.Ret);
9894 // Check GetField on a type instantiated with type parameters
9895 Type t3 = tb.MakeGenericType (typeParams [0]);
9896 FieldBuilder fb3 = tb.DefineField ("field3", typeParams [0], FieldAttributes.Public);
9897 FieldInfo fi3 = TypeBuilder.GetField (t3, fb3);
9899 MethodBuilder mb3 = tb.DefineMethod ("get_T", MethodAttributes.Public|MethodAttributes.Static, typeParams [0], Type.EmptyTypes);
9900 ILGenerator ilgen3 = mb3.GetILGenerator ();
9901 ilgen3.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t3, cb));
9902 ilgen3.Emit (OpCodes.Ldfld, fi3);
9903 ilgen3.Emit (OpCodes.Ret);
9905 Type created = tb.CreateType ();
9907 Type inst = created.MakeGenericType (typeof (object));
9909 Assert.AreEqual (42, inst.GetMethod ("get_int").Invoke (null, null));
9911 Assert.AreEqual (null, inst.GetMethod ("get_T").Invoke (null, null));
9914 [Test] //bug #354047
9915 public void CreatedTypeInstantiationOverTypeBuilderArgsIsNotAGenericTypeDefinition ()
9917 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9918 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9919 Type t = tb.CreateType ();
9921 Type inst = tb.MakeGenericType (typeParams [0]);
9922 Assert.IsFalse (inst.IsGenericTypeDefinition, "#1 create type instance is not a generic type definition");
9925 [Test] //bug #354047
9926 public void CreatedTypeAndTypeBuilderOwnTheirGenericArguments ()
9928 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9929 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9930 Type t = tb.CreateType ();
9932 Assert.IsTrue (tb.GetGenericArguments()[0].DeclaringType == tb, "#1 TypeBuilder owns its arguments");
9933 Assert.IsTrue (t.GetGenericArguments()[0].DeclaringType == t, "#1 create type owns its arguments");
9936 [Test] //bug #354047
9937 public void CreatedTypeAndTypeBuilderDontShareGenericArguments ()
9939 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9940 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9941 Type t = tb.CreateType ();
9943 Assert.IsTrue (tb.GetGenericArguments()[0] != t.GetGenericArguments()[0], "#1 TypeBuilder and create type arguments are diferent");
9946 [Test] //bug #399047
9947 public void FieldOnTypeBuilderInstDontInflateWhenEncoded () {
9948 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9950 module = assembly.DefineDynamicModule ("Instance.exe");
9952 TypeBuilder G = module.DefineType ("G", TypeAttributes.Public);
9953 Type T = G.DefineGenericParameters ("T") [0];
9954 ConstructorInfo ctor = G.DefineDefaultConstructor (MethodAttributes.Public);
9955 Type GObj = G.MakeGenericType (new Type [] { T });
9957 FieldBuilder F = G.DefineField ("F", T, FieldAttributes.Public);
9959 TypeBuilder P = module.DefineType ("P", TypeAttributes.Public);
9961 MethodBuilder Test = P.DefineMethod ("Test", MethodAttributes.Public);
9962 Type TATest = Test.DefineGenericParameters ("TA") [0];
9964 Type TestGObj = G.MakeGenericType (new Type [] { TATest });
9966 ILGenerator il = Test.GetILGenerator ();
9968 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (TestGObj, ctor));
9969 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (TestGObj, F));
9970 il.Emit (OpCodes.Pop);
9972 il.Emit (OpCodes.Ret);
9975 MethodBuilder main = P.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static);
9977 ILGenerator il = main.GetILGenerator ();
9978 il.Emit(OpCodes.Newobj, P.DefineDefaultConstructor (MethodAttributes.Public));
9979 il.Emit(OpCodes.Call, Test.MakeGenericMethod (typeof (int)));
9980 il.Emit (OpCodes.Ret);
9983 assembly.SetEntryPoint (main);
9984 G.CreateType ();
9985 P.CreateType ();
9987 assembly.Save ("Instance.exe");
9988 Thread.GetDomain ().ExecuteAssembly(Path.GetTempPath () + Path.DirectorySeparatorChar + "Instance.exe");
9991 [Test]
9992 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers ()
9994 TypeBuilder tb = module.DefineType ("Type1", TypeAttributes.Public);
9995 FieldBuilder fb = tb.DefineInitializedData ("Foo", new byte [] {1,2,3,4}, FieldAttributes.Static|FieldAttributes.Public);
9996 tb.CreateType ();
9998 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME+"2"), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9999 module = assembly.DefineDynamicModule ("Instance.exe");
10001 TypeBuilder tb2 = module.DefineType ("Type2", TypeAttributes.Public);
10002 MethodBuilder mb = tb2.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static, typeof (object), new Type [0]);
10003 ILGenerator il = mb.GetILGenerator ();
10005 il.Emit (OpCodes.Ldc_I4_1);
10006 il.Emit (OpCodes.Newarr, typeof (int));
10007 il.Emit (OpCodes.Dup);
10008 il.Emit (OpCodes.Ldtoken, fb);
10009 il.Emit (OpCodes.Call, typeof (RuntimeHelpers).GetMethod ("InitializeArray"));
10010 il.Emit (OpCodes.Ret);
10012 Type t = tb2.CreateType ();
10013 int[] res = (int[])t.GetMethod ("Test").Invoke (null, new object[0]);
10014 //Console.WriteLine (res[0]);
10016 #endif
10018 public interface IDelegateFactory
10020 Delegate Create (Delegate del);
10023 [Test]
10024 public void CreateType_Ctor_NoBody ()
10026 TypeBuilder tb = module.DefineType (genTypeName ());
10027 tb.DefineConstructor (MethodAttributes.Public,
10028 CallingConventions.Standard,
10029 new Type [] { typeof (string) });
10030 try {
10031 tb.CreateType ();
10032 Assert.Fail ("#1");
10033 } catch (InvalidOperationException ex) {
10034 // Method '.ctor' does not have a method body
10035 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
10036 Assert.IsNull (ex.InnerException, "#3");
10037 Assert.IsNotNull (ex.Message, "#4");
10038 Assert.IsTrue (ex.Message.IndexOf (".ctor") != -1, "#5");
10042 [Test] //bug #361689
10043 public void CreateTypeFailsWithInvalidMethodOverride ()
10045 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
10047 MethodBuilder mc = tb.DefineMethod ("Create", MethodAttributes.Public, typeof (Delegate), new Type[] {typeof (Delegate)});
10048 ILGenerator gen = mc.GetILGenerator ();
10049 gen.Emit (OpCodes.Ldarg_0);
10050 gen.Emit (OpCodes.Ret);
10051 tb.DefineMethodOverride (mc, typeof (IDelegateFactory).GetMethod ("Create"));
10052 try {
10053 tb.CreateType ();
10054 Assert.Fail ("#1 create type did not throw TypeLoadException");
10055 } catch (TypeLoadException) {
10060 [Test] //bug #349194
10061 public void IsAssignableToWorksWithInterfacesOnParent ()
10063 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
10064 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Public, tb);
10066 Assert.IsFalse (typeof (EmptyInterface).IsAssignableFrom (tb));
10067 Type t = tb.CreateType ();
10068 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
10069 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t));
10072 Assert.IsFalse (typeof (EmptyInterface).IsAssignableFrom (tb2));
10073 Type t2 = tb2.CreateType ();
10074 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
10075 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t2));
10078 #if NET_2_0
10080 [Test] //bug #430508
10081 public void MakeGenericTypeRespectBaseType ()
10083 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
10084 EnumBuilder eb = module.DefineEnum (genTypeName (), TypeAttributes.Public, typeof (int));
10086 MethodBuilder mb = tb.DefineMethod ("Test",
10087 MethodAttributes.Public,
10088 typeof (Tuple<,>).MakeGenericType (typeof (int), eb),
10089 new Type [0]);
10090 ILGenerator il = mb.GetILGenerator();
10091 il.Emit (OpCodes.Ldnull);
10092 il.Emit (OpCodes.Ret);
10094 Type e = eb.CreateType ();
10095 Type c = tb.CreateType ();
10097 Assert.AreEqual (c.GetMethod ("Test").ReturnType.GetGenericArguments ()[1], e, "#1");
10100 [Test]
10101 public void GetCustomAttrOnFieldOfInflatedType ()
10103 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
10104 tb.DefineGenericParameters ("T");
10106 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10107 typeof (SimpleTestAttribute).GetConstructors ()[0],
10108 new object [0]);
10110 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
10111 field.SetCustomAttribute (caBuilder);
10113 Type t = tb.CreateType ();
10115 FieldInfo fi = t.GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10116 object[] cattrs = fi.GetCustomAttributes (false);
10117 Assert.AreEqual (1, cattrs.Length);
10119 fi = t.MakeGenericType (typeof (int)).GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10120 cattrs = fi.GetCustomAttributes (false);
10121 Assert.AreEqual (1, cattrs.Length);
10124 [Test]
10125 public void GetCustomAttrOnPropertyOfInflatedType ()
10127 TypeBuilder tb = module.DefineType (genTypeName ());
10128 tb.DefineGenericParameters ("T");
10130 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10131 typeof (SimpleTestAttribute).GetConstructors ()[0],
10132 new object [0]);
10134 PropertyBuilder property = DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
10135 property.SetCustomAttribute (caBuilder);
10137 Type t = tb.CreateType ();
10139 PropertyInfo pi = t.GetProperties ()[0];
10140 object[] cattrs = pi.GetCustomAttributes (false);
10141 Assert.AreEqual (1, cattrs.Length);
10143 pi = t.MakeGenericType (typeof (int)).GetProperties ()[0];
10144 cattrs = pi.GetCustomAttributes (false);
10145 Assert.AreEqual (1, cattrs.Length);
10148 [Test]
10149 public void GetCustomAttrOnEventOfInflatedType ()
10151 TypeBuilder tb = module.DefineType (genTypeName ());
10152 tb.DefineGenericParameters ("T");
10154 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10155 typeof (SimpleTestAttribute).GetConstructors ()[0],
10156 new object [0]);
10158 EventBuilder evt = tb.DefineEvent ("OI", 0, typeof (int));
10159 evt.SetCustomAttribute (caBuilder);
10161 Type t = tb.CreateType ();
10163 EventInfo ei = t.GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10164 object[] cattrs = ei.GetCustomAttributes (false);
10165 Assert.AreEqual (1, cattrs.Length);
10167 ei = t.MakeGenericType (typeof (int)).GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10168 cattrs = ei.GetCustomAttributes (false);
10169 Assert.AreEqual (1, cattrs.Length);
10172 public void TestDoubleInitializationOfMonoGenericClass () //bug #400643
10174 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
10175 tb.DefineGenericParameters ("T");
10177 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10178 typeof (SimpleTestAttribute).GetConstructors ()[0],
10179 new object [0]);
10181 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
10182 field.SetCustomAttribute (caBuilder);
10185 tb.MakeGenericType (typeof (int)).GetMethods ();
10186 tb.MakeGenericType (typeof (double)).GetMethods ();
10188 Type t = tb.CreateType ();
10190 t.MakeGenericType (typeof (int)).GetMethods ();
10191 t.MakeGenericType (typeof (double)).GetMethods ();
10194 [Test]
10195 public void TestGenericFieldAccess () // bug #467415
10197 AssemblyName asmName = new AssemblyName("DemoMethodBuilder1");
10198 AppDomain domain = AppDomain.CurrentDomain;
10199 AssemblyBuilder demoAssembly =
10200 domain.DefineDynamicAssembly(asmName,
10201 AssemblyBuilderAccess.RunAndSave);
10203 // Define the module that contains the code. For an
10204 // assembly with one module, the module name is the
10205 // assembly name plus a file extension.
10206 ModuleBuilder demoModule =
10207 demoAssembly.DefineDynamicModule(asmName.Name,
10208 asmName.Name+".dll");
10210 TypeBuilder demoType =
10211 demoModule.DefineType("DemoType", TypeAttributes.Public);
10213 MethodBuilder factory =
10214 demoType.DefineMethod("Factory",
10215 MethodAttributes.Public | MethodAttributes.Static);
10217 string[] typeParameterNames = {"T"};
10218 GenericTypeParameterBuilder[] typeParameters =
10219 factory.DefineGenericParameters(typeParameterNames);
10221 GenericTypeParameterBuilder T = typeParameters[0];
10223 Type[] parms = {};
10224 factory.SetParameters(parms);
10226 factory.SetReturnType(T);
10228 ILGenerator ilgen = factory.GetILGenerator();
10230 Type G = typeof(Gen<>);
10231 Type GT = G.MakeGenericType (T);
10232 FieldInfo GF = G.GetField("field");
10233 FieldInfo GTF = TypeBuilder.GetField(GT, GF);
10235 ilgen.Emit(OpCodes.Ldsfld, GTF);
10236 ilgen.Emit(OpCodes.Ret);
10238 // Complete the type.
10239 Type dt = demoType.CreateType();
10240 // Save the assembly, so it can be examined with Ildasm.exe.
10241 //demoAssembly.Save(asmName.Name+".dll");
10243 MethodInfo m = dt.GetMethod("Factory");
10244 MethodInfo bound = m.MakeGenericMethod(typeof(int));
10246 // Display a string representing the bound method.
10247 //Console.WriteLine(bound);
10249 object[] parameters = {};
10250 int result = (int)(bound.Invoke(null, parameters));
10252 Assert.AreEqual (0, result, "#1");
10254 #endif
10256 static MethodInfo GetMethodByName (MethodInfo [] methods, string name)
10258 foreach (MethodInfo mi in methods)
10259 if (mi.Name == name)
10260 return mi;
10261 return null;
10264 void CreateMembers (TypeBuilder tb, string suffix, bool defineCtors)
10266 ConstructorBuilder cb;
10267 MethodBuilder mb;
10268 PropertyBuilder pb;
10269 EventBuilder eb;
10270 ILGenerator ilgen;
10272 if (defineCtors) {
10274 // instance constructors
10276 cb = tb.DefineConstructor (MethodAttributes.Private,
10277 CallingConventions.Standard,
10278 new Type [] { typeof (int), typeof (int) });
10279 cb.GetILGenerator ().Emit (OpCodes.Ret);
10281 cb = tb.DefineConstructor (MethodAttributes.Family,
10282 CallingConventions.Standard,
10283 new Type [] { typeof (string) });
10284 cb.GetILGenerator ().Emit (OpCodes.Ret);
10286 cb = tb.DefineConstructor (MethodAttributes.FamANDAssem,
10287 CallingConventions.Standard,
10288 new Type [] { typeof (string), typeof (string) });
10289 cb.GetILGenerator ().Emit (OpCodes.Ret);
10291 cb = tb.DefineConstructor (MethodAttributes.FamORAssem,
10292 CallingConventions.Standard,
10293 new Type [] { typeof (int) });
10294 cb.GetILGenerator ().Emit (OpCodes.Ret);
10296 cb = tb.DefineConstructor (MethodAttributes.Public,
10297 CallingConventions.Standard,
10298 new Type [] { typeof (int), typeof (bool) });
10299 cb.GetILGenerator ().Emit (OpCodes.Ret);
10301 cb = tb.DefineConstructor (MethodAttributes.Assembly,
10302 CallingConventions.Standard,
10303 new Type [] { typeof (string), typeof (int) });
10304 cb.GetILGenerator ().Emit (OpCodes.Ret);
10307 // static constructors
10310 cb = tb.DefineConstructor (MethodAttributes.Private |
10311 MethodAttributes.Static,
10312 CallingConventions.Standard,
10313 Type.EmptyTypes);
10314 cb.GetILGenerator ().Emit (OpCodes.Ret);
10318 // instance methods
10321 mb = tb.DefineMethod ("GetPrivateInstance" + suffix,
10322 MethodAttributes.Private, typeof (void),
10323 Type.EmptyTypes);
10324 mb.GetILGenerator ().Emit (OpCodes.Ret);
10326 mb = tb.DefineMethod ("GetFamilyInstance" + suffix,
10327 MethodAttributes.Family, typeof (void),
10328 Type.EmptyTypes);
10329 mb.GetILGenerator ().Emit (OpCodes.Ret);
10331 mb = tb.DefineMethod ("GetFamANDAssemInstance" + suffix,
10332 MethodAttributes.FamANDAssem, typeof (void),
10333 Type.EmptyTypes);
10334 mb.GetILGenerator ().Emit (OpCodes.Ret);
10336 mb = tb.DefineMethod ("GetFamORAssemInstance" + suffix,
10337 MethodAttributes.FamORAssem, typeof (void),
10338 Type.EmptyTypes);
10339 mb.GetILGenerator ().Emit (OpCodes.Ret);
10341 mb = tb.DefineMethod ("GetPublicInstance" + suffix,
10342 MethodAttributes.Public, typeof (void),
10343 Type.EmptyTypes);
10344 mb.GetILGenerator ().Emit (OpCodes.Ret);
10346 mb = tb.DefineMethod ("GetAssemblyInstance" + suffix,
10347 MethodAttributes.Assembly, typeof (void),
10348 Type.EmptyTypes);
10349 mb.GetILGenerator ().Emit (OpCodes.Ret);
10352 // static methods
10355 mb = tb.DefineMethod ("GetPrivateStatic" + suffix,
10356 MethodAttributes.Private | MethodAttributes.Static,
10357 typeof (void), Type.EmptyTypes);
10358 mb.GetILGenerator ().Emit (OpCodes.Ret);
10360 mb = tb.DefineMethod ("GetFamilyStatic" + suffix,
10361 MethodAttributes.Family | MethodAttributes.Static,
10362 typeof (void), Type.EmptyTypes);
10363 mb.GetILGenerator ().Emit (OpCodes.Ret);
10365 mb = tb.DefineMethod ("GetFamANDAssemStatic" + suffix,
10366 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10367 typeof (void), Type.EmptyTypes);
10368 mb.GetILGenerator ().Emit (OpCodes.Ret);
10370 mb = tb.DefineMethod ("GetFamORAssemStatic" + suffix,
10371 MethodAttributes.FamORAssem | MethodAttributes.Static,
10372 typeof (void), Type.EmptyTypes);
10373 mb.GetILGenerator ().Emit (OpCodes.Ret);
10375 mb = tb.DefineMethod ("GetPublicStatic" + suffix,
10376 MethodAttributes.Public | MethodAttributes.Static,
10377 typeof (void), Type.EmptyTypes);
10378 mb.GetILGenerator ().Emit (OpCodes.Ret);
10380 mb = tb.DefineMethod ("GetAssemblyStatic" + suffix,
10381 MethodAttributes.Assembly | MethodAttributes.Static,
10382 typeof (void), Type.EmptyTypes);
10383 mb.GetILGenerator ().Emit (OpCodes.Ret);
10386 // instance fields
10389 tb.DefineField ("privateInstance" + suffix,
10390 typeof (string), FieldAttributes.Private);
10391 tb.DefineField ("familyInstance" + suffix,
10392 typeof (string), FieldAttributes.Family);
10393 tb.DefineField ("famANDAssemInstance" + suffix,
10394 typeof (string), FieldAttributes.FamANDAssem);
10395 tb.DefineField ("famORAssemInstance" + suffix,
10396 typeof (string), FieldAttributes.FamORAssem);
10397 tb.DefineField ("publicInstance" + suffix,
10398 typeof (string), FieldAttributes.Public);
10399 tb.DefineField ("assemblyInstance" + suffix,
10400 typeof (string), FieldAttributes.Assembly);
10403 // static fields
10406 tb.DefineField ("privateStatic" + suffix,
10407 typeof (string), FieldAttributes.Private |
10408 FieldAttributes.Static);
10409 tb.DefineField ("familyStatic" + suffix,
10410 typeof (string), FieldAttributes.Family |
10411 FieldAttributes.Static);
10412 tb.DefineField ("famANDAssemStatic" + suffix,
10413 typeof (string), FieldAttributes.FamANDAssem |
10414 FieldAttributes.Static);
10415 tb.DefineField ("famORAssemStatic" + suffix,
10416 typeof (string), FieldAttributes.FamORAssem |
10417 FieldAttributes.Static);
10418 tb.DefineField ("publicStatic" + suffix,
10419 typeof (string), FieldAttributes.Public |
10420 FieldAttributes.Static);
10421 tb.DefineField ("assemblyStatic" + suffix,
10422 typeof (string), FieldAttributes.Assembly |
10423 FieldAttributes.Static);
10426 // instance properties
10429 pb = tb.DefineProperty ("PrivateInstance" + suffix,
10430 PropertyAttributes.None, typeof (string),
10431 Type.EmptyTypes);
10432 mb = tb.DefineMethod ("get_PrivateInstance" + suffix,
10433 MethodAttributes.Private, typeof (string),
10434 Type.EmptyTypes);
10435 ilgen = mb.GetILGenerator ();
10436 ilgen.Emit (OpCodes.Ldnull);
10437 ilgen.Emit (OpCodes.Ret);
10438 pb.SetGetMethod (mb);
10440 pb = tb.DefineProperty ("FamilyInstance" + suffix,
10441 PropertyAttributes.None, typeof (string),
10442 Type.EmptyTypes);
10443 mb = tb.DefineMethod ("get_FamilyInstance" + suffix,
10444 MethodAttributes.Family, typeof (string),
10445 Type.EmptyTypes);
10446 ilgen = mb.GetILGenerator ();
10447 ilgen.Emit (OpCodes.Ldnull);
10448 ilgen.Emit (OpCodes.Ret);
10449 pb.SetGetMethod (mb);
10451 pb = tb.DefineProperty ("FamANDAssemInstance" + suffix,
10452 PropertyAttributes.None, typeof (string),
10453 Type.EmptyTypes);
10454 mb = tb.DefineMethod ("get_FamANDAssemInstance" + suffix,
10455 MethodAttributes.FamANDAssem, typeof (string),
10456 Type.EmptyTypes);
10457 ilgen = mb.GetILGenerator ();
10458 ilgen.Emit (OpCodes.Ldnull);
10459 ilgen.Emit (OpCodes.Ret);
10460 pb.SetGetMethod (mb);
10462 pb = tb.DefineProperty ("FamORAssemInstance" + suffix,
10463 PropertyAttributes.None, typeof (string),
10464 Type.EmptyTypes);
10465 mb = tb.DefineMethod ("get_FamORAssemInstance" + suffix,
10466 MethodAttributes.FamORAssem, typeof (string),
10467 Type.EmptyTypes);
10468 ilgen = mb.GetILGenerator ();
10469 ilgen.Emit (OpCodes.Ldnull);
10470 ilgen.Emit (OpCodes.Ret);
10471 pb.SetGetMethod (mb);
10473 pb = tb.DefineProperty ("PublicInstance" + suffix,
10474 PropertyAttributes.None, typeof (string),
10475 Type.EmptyTypes);
10476 mb = tb.DefineMethod ("get_PublicInstance" + suffix,
10477 MethodAttributes.Public, typeof (string),
10478 Type.EmptyTypes);
10479 ilgen = mb.GetILGenerator ();
10480 ilgen.Emit (OpCodes.Ldnull);
10481 ilgen.Emit (OpCodes.Ret);
10482 pb.SetGetMethod (mb);
10484 pb = tb.DefineProperty ("AssemblyInstance" + suffix,
10485 PropertyAttributes.None, typeof (string),
10486 Type.EmptyTypes);
10487 mb = tb.DefineMethod ("get_AssemblyInstance" + suffix,
10488 MethodAttributes.Assembly, typeof (string),
10489 Type.EmptyTypes);
10490 ilgen = mb.GetILGenerator ();
10491 ilgen.Emit (OpCodes.Ldnull);
10492 ilgen.Emit (OpCodes.Ret);
10493 pb.SetGetMethod (mb);
10496 // static properties
10499 pb = tb.DefineProperty ("PrivateStatic" + suffix,
10500 PropertyAttributes.None, typeof (string),
10501 Type.EmptyTypes);
10502 mb = tb.DefineMethod ("get_PrivateStatic" + suffix,
10503 MethodAttributes.Private | MethodAttributes.Static,
10504 typeof (string), Type.EmptyTypes);
10505 ilgen = mb.GetILGenerator ();
10506 ilgen.Emit (OpCodes.Ldnull);
10507 ilgen.Emit (OpCodes.Ret);
10508 pb.SetGetMethod (mb);
10510 pb = tb.DefineProperty ("FamilyStatic" + suffix,
10511 PropertyAttributes.None, typeof (string),
10512 Type.EmptyTypes);
10513 mb = tb.DefineMethod ("get_FamilyStatic" + suffix,
10514 MethodAttributes.Family | MethodAttributes.Static,
10515 typeof (string), Type.EmptyTypes);
10516 ilgen = mb.GetILGenerator ();
10517 ilgen.Emit (OpCodes.Ldnull);
10518 ilgen.Emit (OpCodes.Ret);
10519 pb.SetGetMethod (mb);
10521 pb = tb.DefineProperty ("FamANDAssemStatic" + suffix,
10522 PropertyAttributes.None, typeof (string),
10523 Type.EmptyTypes);
10524 mb = tb.DefineMethod ("get_FamANDAssemStatic" + suffix,
10525 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10526 typeof (string), Type.EmptyTypes);
10527 ilgen = mb.GetILGenerator ();
10528 ilgen.Emit (OpCodes.Ldnull);
10529 ilgen.Emit (OpCodes.Ret);
10530 pb.SetGetMethod (mb);
10532 pb = tb.DefineProperty ("FamORAssemStatic" + suffix,
10533 PropertyAttributes.None, typeof (string),
10534 Type.EmptyTypes);
10535 mb = tb.DefineMethod ("get_FamORAssemStatic" + suffix,
10536 MethodAttributes.FamORAssem | MethodAttributes.Static,
10537 typeof (string), Type.EmptyTypes);
10538 ilgen = mb.GetILGenerator ();
10539 ilgen.Emit (OpCodes.Ldnull);
10540 ilgen.Emit (OpCodes.Ret);
10541 pb.SetGetMethod (mb);
10543 pb = tb.DefineProperty ("PublicStatic" + suffix,
10544 PropertyAttributes.None, typeof (string),
10545 Type.EmptyTypes);
10546 mb = tb.DefineMethod ("get_PublicStatic" + suffix,
10547 MethodAttributes.Public | MethodAttributes.Static,
10548 typeof (string), Type.EmptyTypes);
10549 ilgen = mb.GetILGenerator ();
10550 ilgen.Emit (OpCodes.Ldnull);
10551 ilgen.Emit (OpCodes.Ret);
10552 pb.SetGetMethod (mb);
10554 pb = tb.DefineProperty ("AssemblyStatic" + suffix,
10555 PropertyAttributes.None, typeof (string),
10556 Type.EmptyTypes);
10557 mb = tb.DefineMethod ("get_AssemblyStatic" + suffix,
10558 MethodAttributes.Assembly | MethodAttributes.Static,
10559 typeof (string), Type.EmptyTypes);
10560 ilgen = mb.GetILGenerator ();
10561 ilgen.Emit (OpCodes.Ldnull);
10562 ilgen.Emit (OpCodes.Ret);
10563 pb.SetGetMethod (mb);
10566 // instance events
10569 eb = tb.DefineEvent ("OnPrivateInstance" + suffix,
10570 EventAttributes.None, typeof (EventHandler));
10571 mb = tb.DefineMethod ("add_OnPrivateInstance" + suffix,
10572 MethodAttributes.Private, typeof (void),
10573 Type.EmptyTypes);
10574 mb.GetILGenerator ().Emit (OpCodes.Ret);
10575 eb.SetAddOnMethod (mb);
10577 eb = tb.DefineEvent ("OnFamilyInstance" + suffix,
10578 EventAttributes.None, typeof (EventHandler));
10579 mb = tb.DefineMethod ("add_OnFamilyInstance" + suffix,
10580 MethodAttributes.Family, typeof (void),
10581 Type.EmptyTypes);
10582 mb.GetILGenerator ().Emit (OpCodes.Ret);
10583 eb.SetAddOnMethod (mb);
10585 eb = tb.DefineEvent ("OnFamANDAssemInstance" + suffix,
10586 EventAttributes.None, typeof (EventHandler));
10587 mb = tb.DefineMethod ("add_OnFamANDAssemInstance" + suffix,
10588 MethodAttributes.FamANDAssem, typeof (void),
10589 Type.EmptyTypes);
10590 mb.GetILGenerator ().Emit (OpCodes.Ret);
10591 eb.SetAddOnMethod (mb);
10593 eb = tb.DefineEvent ("OnFamORAssemInstance" + suffix,
10594 EventAttributes.None, typeof (EventHandler));
10595 mb = tb.DefineMethod ("add_OnFamORAssemInstance" + suffix,
10596 MethodAttributes.FamORAssem, typeof (void),
10597 Type.EmptyTypes);
10598 mb.GetILGenerator ().Emit (OpCodes.Ret);
10599 eb.SetAddOnMethod (mb);
10601 eb = tb.DefineEvent ("OnPublicInstance" + suffix,
10602 EventAttributes.None, typeof (EventHandler));
10603 mb = tb.DefineMethod ("add_OnPublicInstance" + suffix,
10604 MethodAttributes.Public, typeof (void),
10605 Type.EmptyTypes);
10606 mb.GetILGenerator ().Emit (OpCodes.Ret);
10607 eb.SetAddOnMethod (mb);
10609 eb = tb.DefineEvent ("OnAssemblyInstance" + suffix,
10610 EventAttributes.None, typeof (EventHandler));
10611 mb = tb.DefineMethod ("add_OnAssemblyInstance" + suffix,
10612 MethodAttributes.Family, typeof (void),
10613 Type.EmptyTypes);
10614 mb.GetILGenerator ().Emit (OpCodes.Ret);
10615 eb.SetAddOnMethod (mb);
10618 // static events
10621 eb = tb.DefineEvent ("OnPrivateStatic" + suffix,
10622 EventAttributes.None, typeof (EventHandler));
10623 mb = tb.DefineMethod ("add_OnPrivateStatic" + suffix,
10624 MethodAttributes.Private | MethodAttributes.Static,
10625 typeof (void), Type.EmptyTypes);
10626 mb.GetILGenerator ().Emit (OpCodes.Ret);
10627 eb.SetAddOnMethod (mb);
10629 eb = tb.DefineEvent ("OnFamilyStatic" + suffix,
10630 EventAttributes.None, typeof (EventHandler));
10631 mb = tb.DefineMethod ("add_OnFamilyStatic" + suffix,
10632 MethodAttributes.Family | MethodAttributes.Static,
10633 typeof (void), Type.EmptyTypes);
10634 mb.GetILGenerator ().Emit (OpCodes.Ret);
10635 eb.SetAddOnMethod (mb);
10637 eb = tb.DefineEvent ("OnFamANDAssemStatic" + suffix,
10638 EventAttributes.None, typeof (EventHandler));
10639 mb = tb.DefineMethod ("add_OnFamANDAssemStatic" + suffix,
10640 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10641 typeof (void), Type.EmptyTypes);
10642 mb.GetILGenerator ().Emit (OpCodes.Ret);
10643 eb.SetAddOnMethod (mb);
10645 eb = tb.DefineEvent ("OnFamORAssemStatic" + suffix,
10646 EventAttributes.None, typeof (EventHandler));
10647 mb = tb.DefineMethod ("add_OnFamORAssemStatic" + suffix,
10648 MethodAttributes.FamORAssem | MethodAttributes.Static,
10649 typeof (void), Type.EmptyTypes);
10650 mb.GetILGenerator ().Emit (OpCodes.Ret);
10651 eb.SetAddOnMethod (mb);
10653 eb = tb.DefineEvent ("OnPublicStatic" + suffix,
10654 EventAttributes.None, typeof (EventHandler));
10655 mb = tb.DefineMethod ("add_OnPublicStatic" + suffix,
10656 MethodAttributes.Public | MethodAttributes.Static,
10657 typeof (void), Type.EmptyTypes);
10658 mb.GetILGenerator ().Emit (OpCodes.Ret);
10659 eb.SetAddOnMethod (mb);
10661 eb = tb.DefineEvent ("OnAssemblyStatic" + suffix,
10662 EventAttributes.None, typeof (EventHandler));
10663 mb = tb.DefineMethod ("add_OnAssemblyStatic" + suffix,
10664 MethodAttributes.Family | MethodAttributes.Static,
10665 typeof (void), Type.EmptyTypes);
10666 mb.GetILGenerator ().Emit (OpCodes.Ret);
10667 eb.SetAddOnMethod (mb);
10670 #if NET_2_0
10671 static TypeBuilder Resolve1_Tb;
10672 static bool Resolve1_Called;
10674 public class Lookup<T>
10676 public static Type t = typeof(T);
10679 Assembly Resolve1 (object sender, ResolveEventArgs args) {
10680 Resolve1_Called = true;
10681 Resolve1_Tb.CreateType ();
10682 return Resolve1_Tb.Assembly;
10685 [Test]
10686 public void TypeResolveGenericInstances () {
10687 // Test that TypeResolve is called for generic instances (#483852)
10688 TypeBuilder tb1 = null;
10690 AppDomain.CurrentDomain.TypeResolve += Resolve1;
10692 tb1 = module.DefineType("Foo");
10693 Resolve1_Tb = tb1;
10694 FieldInfo field = TypeBuilder.GetField(typeof(Lookup<>).MakeGenericType(tb1), typeof(Lookup<>).GetField("t"));
10695 TypeBuilder tb2 = module.DefineType("Bar");
10696 ConstructorBuilder cb = tb2.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
10697 ILGenerator ilgen = cb.GetILGenerator();
10698 ilgen.Emit(OpCodes.Ldsfld, field);
10699 ilgen.Emit(OpCodes.Pop);
10700 ilgen.Emit(OpCodes.Ret);
10701 Activator.CreateInstance(tb2.CreateType());
10703 Assert.IsTrue (Resolve1_Called);
10705 #endif
10707 [Test]
10708 public void CreateConcreteTypeWithAbstractMethod ()
10710 TypeBuilder tb = module.DefineType (genTypeName ());
10711 tb.DefineMethod("method", MethodAttributes.Abstract | MethodAttributes.Public, typeof (void), Type.EmptyTypes);
10712 try {
10713 tb.CreateType ();
10714 Assert.Fail ("#1");
10715 } catch (InvalidOperationException) {}
10718 [Test]
10719 public void ConcreteTypeDontLeakGenericParamFromItSelf ()
10721 var tb = module.DefineType (genTypeName ());
10722 var gps = tb.DefineGenericParameters ("T");
10723 var mb = tb.DefineMethod ("m", MethodAttributes.Public | MethodAttributes.Static);
10724 mb.SetParameters (gps);
10725 mb.GetILGenerator ().Emit (OpCodes.Ret);
10727 var ti = tb.CreateType ();
10728 var mi = ti.GetMethod ("m");
10729 var arg0 = mi.GetParameters () [0].ParameterType;
10731 Assert.AreNotSame (arg0, gps [0], "#1");
10734 [Test]
10735 public void ConcreteTypeDontLeakGenericParamFromMethods ()
10737 var tb = module.DefineType (genTypeName ());
10738 var mb = tb.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Static);
10739 var gps = mb.DefineGenericParameters ("T");
10740 mb.SetParameters (gps);
10741 mb.GetILGenerator ().Emit (OpCodes.Ret);
10743 var ti = tb.CreateType ();
10744 var mi = ti.GetMethod ("m");
10745 var arg0 = mi.GetParameters () [0].ParameterType;
10747 Assert.AreNotSame (arg0, gps [0], "#1");
10749 #if NET_2_0
10750 [Test]
10751 public void DeclaringMethodReturnsNull ()
10753 TypeBuilder tb = module.DefineType (genTypeName ());
10754 Assert.IsNull (tb.DeclaringMethod, null, "#1");
10757 [Test]
10758 public void GenericParameterPositionReturns0 ()
10760 TypeBuilder tb = module.DefineType (genTypeName ());
10761 Assert.AreEqual (0, tb.GenericParameterPosition, "#1");
10764 [Test]
10765 public void GetGenericTypeDefinitionBehavior ()
10767 TypeBuilder tb = module.DefineType (genTypeName ());
10768 try {
10769 tb.GetGenericTypeDefinition ();
10770 Assert.Fail ("#1");
10771 } catch (InvalidOperationException) {}
10773 tb.DefineGenericParameters ("T");
10774 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#2");
10776 tb.CreateType ();
10777 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#3");
10780 [Test]
10781 public void GetElementTypeNotSupported ()
10783 TypeBuilder tb = module.DefineType (genTypeName ());
10784 try {
10785 tb.GetElementType ();
10786 Assert.Fail ("#1");
10787 } catch (NotSupportedException) {}
10790 [Test]
10791 public void GenericParameterAttributesReturnsNone ()
10793 TypeBuilder tb = module.DefineType (genTypeName ());
10794 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#1");
10796 tb.DefineGenericParameters ("T");
10797 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#2");
10799 tb.CreateType ();
10800 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#3");
10803 [Test]
10804 public void GetGenericArgumentsReturnsNullForNonGenericTypeBuilder ()
10806 TypeBuilder tb = module.DefineType (genTypeName ());
10807 Assert.IsNull (tb.GetGenericArguments (), "#1");
10810 public interface IFaceA {}
10811 public interface IFaceB : IFaceA {}
10812 [Test]
10813 public void GetInterfacesAfterCreate ()
10815 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type[] { typeof (IFaceB) });
10817 Type[] ifaces = tb.GetInterfaces ();
10818 Assert.AreEqual (1, ifaces.Length, "#1");
10819 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#2");
10821 tb.CreateType ();
10822 ifaces = tb.GetInterfaces ();
10823 Assert.AreEqual (2, ifaces.Length, "#3");
10824 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#4");
10825 Assert.AreEqual (typeof (IFaceA), ifaces [1], "#5");
10828 public interface MB_Iface
10830 int Test ();
10833 public class MB_Impl : MB_Iface
10835 public virtual int Test () { return 1; }
10837 [Test]
10838 public void MethodOverrideBodyMustBelongToTypeBuilder ()
10840 TypeBuilder tb = module.DefineType (genTypeName ());
10841 MethodInfo md = typeof (MB_Iface).GetMethod("Test");
10842 MethodInfo md2 = typeof (MB_Impl).GetMethod("Test");
10843 try {
10844 tb.DefineMethodOverride (md, md2);
10845 Assert.Fail ("#1");
10846 } catch (ArgumentException) {}
10849 [Test]
10850 public void GetConstructorsThrowWhenIncomplete ()
10852 TypeBuilder tb = module.DefineType (genTypeName ());
10853 try {
10854 tb.GetConstructors (BindingFlags.Instance);
10855 Assert.Fail ("#1");
10856 } catch (NotSupportedException) { }
10858 tb.CreateType ();
10859 Assert.IsNotNull (tb.GetConstructors (BindingFlags.Instance), "#2");
10862 [Test]
10863 public void GetEventsThrowWhenIncomplete ()
10865 TypeBuilder tb = module.DefineType (genTypeName ());
10866 try {
10867 tb.GetEvents (BindingFlags.Instance);
10868 Assert.Fail ("#1");
10869 } catch (NotSupportedException) { }
10871 tb.CreateType ();
10872 Assert.IsNotNull (tb.GetEvents (BindingFlags.Instance), "#2");
10875 [Test]
10876 public void GetNestedTypeCreatedAfterTypeIsCreated ()
10878 TypeBuilder tb = module.DefineType (genTypeName ());
10879 TypeBuilder nested = tb.DefineNestedType ("Bar", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10880 tb.CreateType ();
10881 Assert.IsNull (tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#1");
10882 Type res = nested.CreateType ();
10883 Assert.AreEqual (res, tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#2");
10885 TypeBuilder nested2 = tb.DefineNestedType ("Bar2", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10886 Assert.IsNull (tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#3");
10887 res = nested2.CreateType ();
10888 Assert.AreEqual (res, tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#4");
10892 [Test]
10893 public void IsDefinedThrowWhenIncomplete ()
10895 TypeBuilder tb = module.DefineType (genTypeName ());
10896 try {
10897 tb.IsDefined (typeof (string), true);
10898 Assert.Fail ("#1");
10899 } catch (NotSupportedException) { }
10901 tb.CreateType ();
10902 Assert.IsNotNull (tb.IsDefined (typeof (string), true), "#2");
10904 #endif
10905 #if NET_2_0
10906 #if !WINDOWS
10908 * Tests for passing user types to Ref.Emit. Currently these only test
10909 * whenever the runtime code can handle them without crashing, since we
10910 * don't support user types yet.
10911 * These tests are disabled for windows since the MS runtime trips on them.
10913 [Test]
10914 public void UserTypes () {
10915 TypeDelegator t = new TypeDelegator (typeof (int));
10917 try {
10918 /* Parent */
10919 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, t);
10920 } catch {
10923 try {
10924 /* Interfaces */
10925 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { t });
10926 tb.CreateType ();
10927 } catch {
10930 try {
10931 /* Fields */
10932 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10933 tb.DefineField ("Foo", t, FieldAttributes.Public);
10934 tb.CreateType ();
10935 } catch {
10938 try {
10939 /* Custom modifiers on fields */
10940 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10941 tb.DefineField ("Foo", typeof (int), new Type [] { t }, new Type [] { t }, FieldAttributes.Public);
10942 tb.CreateType ();
10943 } catch {
10946 #if !WINDOWS
10947 try {
10948 /* This is mono only */
10949 UnmanagedMarshal m = UnmanagedMarshal.DefineCustom (t, "foo", "bar", Guid.Empty);
10950 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10951 FieldBuilder fb = tb.DefineField ("Foo", typeof (int), FieldAttributes.Public);
10952 fb.SetMarshal (m);
10953 tb.CreateType ();
10954 } catch {
10956 #endif
10958 try {
10959 /* Properties */
10960 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10961 tb.DefineProperty ("Foo", PropertyAttributes.None, t, null);
10962 tb.CreateType ();
10963 } catch {
10966 try {
10967 /* Custom modifiers on properties */
10968 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10969 // FIXME: These seems to be ignored
10970 tb.DefineProperty ("Foo", PropertyAttributes.None, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10971 tb.CreateType ();
10972 } catch {
10975 try {
10976 /* Method return types */
10977 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10978 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, t, null);
10979 mb.GetILGenerator ().Emit (OpCodes.Ret);
10980 tb.CreateType ();
10981 } catch {
10984 try {
10985 /* Custom modifiers on method return types */
10986 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10987 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10988 mb.GetILGenerator ().Emit (OpCodes.Ret);
10989 tb.CreateType ();
10990 } catch {
10993 try {
10994 /* Method parameters */
10995 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10996 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, typeof (int), new Type [] { t });
10997 mb.GetILGenerator ().Emit (OpCodes.Ret);
10998 tb.CreateType ();
10999 } catch {
11002 try {
11003 /* Custom modifiers on method parameters */
11004 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
11005 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), null, null, new Type [] { typeof (int) }, new Type [][] { new Type [] { t }}, new Type[][] { new Type [] { t }});
11006 mb.GetILGenerator ().Emit (OpCodes.Ret);
11007 tb.CreateType ();
11008 } catch {
11011 try {
11012 /* Ctor parameters */
11013 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
11014 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { t });
11015 mb.GetILGenerator ().Emit (OpCodes.Ret);
11016 tb.CreateType ();
11017 } catch {
11020 try {
11021 /* Custom modifiers on ctor parameters */
11022 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
11023 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { typeof (int) }, new Type [][] { new Type [] { t }}, new Type[][] { new Type [] { t }});
11024 mb.GetILGenerator ().Emit (OpCodes.Ret);
11025 tb.CreateType ();
11026 } catch {
11029 try {
11030 /* SignatureHelper arguments */
11031 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
11032 sighelper.AddArgument (t, false);
11033 byte[] arr = sighelper.GetSignature ();
11034 } catch {
11037 try {
11038 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
11039 sighelper.AddArgument (t, false);
11040 byte[] arr = sighelper.GetSignature ();
11041 } catch {
11044 try {
11045 /* Custom modifiers on SignatureHelper arguments */
11046 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
11047 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
11048 byte[] arr = sighelper.GetSignature ();
11049 } catch {
11052 try {
11053 /* Custom modifiers on SignatureHelper arguments */
11054 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
11055 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
11056 byte[] arr = sighelper.GetSignature ();
11057 } catch {
11060 /* Arguments to ILGenerator methods */
11061 try {
11062 /* Emit () */
11063 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
11064 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
11065 ILGenerator ig = mb.GetILGenerator ();
11066 ig.Emit (OpCodes.Ldnull);
11067 ig.Emit (OpCodes.Castclass, t);
11068 ig.Emit (OpCodes.Pop);
11069 ig.Emit (OpCodes.Ret);
11070 tb.CreateType ();
11071 } catch {
11074 try {
11075 /* DeclareLocal () */
11076 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
11077 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
11078 ILGenerator ig = mb.GetILGenerator ();
11079 ig.DeclareLocal (t);
11080 ig.Emit (OpCodes.Ret);
11081 tb.CreateType ();
11082 } catch {
11085 try {
11086 /* BeginExceptionCatchBlock () */
11087 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
11088 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
11089 ILGenerator ig = mb.GetILGenerator ();
11090 ig.BeginExceptionBlock ();
11091 ig.BeginCatchBlock (t);
11092 ig.Emit (OpCodes.Ret);
11093 tb.CreateType ();
11094 } catch {
11097 try {
11098 /* EmitCalli () */
11099 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
11100 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
11101 ILGenerator ig = mb.GetILGenerator ();
11102 ig.EmitCalli (OpCodes.Call, CallingConventions.Standard, typeof (void), new Type [] { t }, null);
11103 ig.Emit (OpCodes.Ret);
11104 tb.CreateType ();
11105 } catch {
11108 #endif
11109 #endif
11111 //Test for #572660
11112 [Test]
11113 public void CircularArrayType()
11115 var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess.RunAndSave);
11116 var moduleBuilder = assemblyBuilder.DefineDynamicModule("Test", "Test.dll", true);
11117 var typeBuilder = moduleBuilder.DefineType("Foo", TypeAttributes.Public);
11118 var fieldBuilder = typeBuilder.DefineField("Foos", typeBuilder.MakeArrayType(), FieldAttributes.Public);
11120 var fooType = typeBuilder.CreateType();
11121 Assert.AreSame(fooType.MakeArrayType(), fooType.GetField("Foos").FieldType);