2 // TypeBuilderTest.cs - NUnit Test Cases for the TypeBuilder class
4 // Zoltan Varga (vargaz@freemail.hu)
6 // (C) Ximian, Inc. http://www.ximian.com
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
17 using System.Collections;
18 using System.Threading;
19 using System.Reflection;
20 using System.Reflection.Emit;
22 using System.Security;
23 using System.Security.Permissions;
24 using System.Runtime.InteropServices;
25 using NUnit.Framework;
26 using System.Runtime.CompilerServices;
27 using System.Collections.Generic;
29 namespace MonoTests.System.Reflection.Emit
31 public interface EmptyInterface
35 public interface OneMethodInterface
40 public class SimpleTestAttribute : Attribute
43 public class EmptyIfaceImpl : EmptyInterface
48 public static T field = default(T);
52 public class TypeBuilderTest
54 public interface AnInterface
62 public interface Bar : Foo
66 public interface Baz : Bar
70 public interface IMoveable
74 public interface IThrowable : IMoveable
78 public interface ILiquid
82 public interface IWater : ILiquid
90 public interface IDestroyable
94 public class Tuple <A,B> {
99 private AssemblyBuilder assembly;
101 private ModuleBuilder module;
103 static string ASSEMBLY_NAME = "MonoTests.System.Reflection.Emit.TypeBuilderTest";
106 protected void SetUp ()
108 AssemblyName assemblyName = new AssemblyName ();
109 assemblyName.Name = ASSEMBLY_NAME;
112 Thread.GetDomain ().DefineDynamicAssembly (
113 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
115 module = assembly.DefineDynamicModule ("module1");
118 static int typeIndexer = 0;
120 // Return a unique type name
121 private string genTypeName ()
123 return "t" + (typeIndexer++);
126 private string nullName ()
128 return String.Format ("{0}", (char) 0);
132 public void TestAssembly ()
134 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
135 Assert.AreEqual (assembly, tb.Assembly);
139 public void TestAssemblyQualifiedName ()
141 TypeBuilder tb = module.DefineType ("A.B.C.D", TypeAttributes.Public);
142 Assert.AreEqual ("A.B.C.D, " + assembly.GetName ().FullName,
143 tb.AssemblyQualifiedName);
147 public void TestAttributes ()
149 TypeAttributes attrs = TypeAttributes.Public | TypeAttributes.BeforeFieldInit;
150 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
151 Assert.AreEqual (attrs, tb.Attributes);
155 public void TestBaseTypeClass ()
157 TypeAttributes attrs = TypeAttributes.Public;
158 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
159 Assert.AreEqual (typeof (object), tb.BaseType, "#1");
161 TypeBuilder tb2 = module.DefineType (genTypeName (), attrs, tb);
162 Assert.AreEqual (tb, tb2.BaseType, "#2");
166 public void TestBaseTypeInterface ()
168 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
169 Assert.IsNull (tb3.BaseType);
173 public void TestDeclaringType ()
175 TypeAttributes attrs = 0;
176 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
177 Assert.IsNull (tb.DeclaringType, "#1");
179 attrs = TypeAttributes.NestedPublic;
180 TypeBuilder tb2 = tb.DefineNestedType (genTypeName (), attrs);
181 TypeBuilder tb3 = tb2.DefineNestedType (genTypeName (), attrs);
182 Assert.AreEqual (tb3.DeclaringType.DeclaringType, tb, "#2");
186 public void TestFullName ()
188 string name = genTypeName ();
189 TypeAttributes attrs = 0;
190 TypeBuilder tb = module.DefineType (name, attrs);
191 Assert.AreEqual (name, tb.FullName, "#1");
193 string name2 = genTypeName ();
194 attrs = TypeAttributes.NestedPublic;
195 TypeBuilder tb2 = tb.DefineNestedType (name2, attrs);
197 string name3 = genTypeName ();
198 attrs = TypeAttributes.NestedPublic;
199 TypeBuilder tb3 = tb2.DefineNestedType (name3, attrs);
201 Assert.AreEqual (name + "+" + name2 + "+" + name3, tb3.FullName, "#2");
205 public void DefineCtorUsingDefineMethod ()
207 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Class);
208 MethodBuilder mb = tb.DefineMethod(
209 ".ctor", MethodAttributes.Public | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName,
211 ILGenerator ilgen = mb.GetILGenerator();
212 ilgen.Emit(OpCodes.Ldarg_0);
213 ilgen.Emit(OpCodes.Call,
214 typeof(object).GetConstructor(Type.EmptyTypes));
215 ilgen.Emit(OpCodes.Ret);
216 Type t = tb.CreateType();
218 Assert.AreEqual (1, t.GetConstructors ().Length);
222 public void TestGUIDIncomplete ()
224 TypeBuilder tb = module.DefineType (genTypeName ());
228 } catch (NotSupportedException ex) {
229 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
230 Assert.IsNull (ex.InnerException, "#3");
231 Assert.IsNotNull (ex.Message, "#4");
236 [Category ("NotWorking")]
237 public void TestGUIDComplete ()
239 TypeBuilder tb = module.DefineType (genTypeName ());
241 Assert.IsTrue (tb.GUID != Guid.Empty);
245 [Category ("NotWorking")]
246 public void TestFixedGUIDComplete ()
248 TypeBuilder tb = module.DefineType (genTypeName ());
250 Guid guid = Guid.NewGuid ();
252 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
253 new Type [] { typeof (string) });
255 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
256 new object [] { guid.ToString ("D") }, new FieldInfo [0], new object [0]);
258 tb.SetCustomAttribute (caBuilder);
260 Assert.AreEqual (guid, tb.GUID);
264 public void TestHasElementType_Incomplete ()
266 // According to the MSDN docs, this member works, but in reality, it
267 // returns a NotSupportedException
268 TypeBuilder tb = module.DefineType (genTypeName ());
269 Assert.IsFalse (tb.HasElementType);
273 public void TestHasElementType_Complete ()
275 // According to the MSDN docs, this member works, but in reality, it
276 // returns a NotSupportedException
277 TypeBuilder tb = module.DefineType (genTypeName ());
279 Assert.IsFalse (tb.HasElementType);
282 [Test] // bug #324692
283 public void CreateType_Enum_NoInstanceField ()
285 TypeBuilder tb = module.DefineType (genTypeName (),
286 TypeAttributes.Sealed | TypeAttributes.Serializable,
291 Assert.Fail ("#1: must throw TypeLoadException");
292 } catch (TypeLoadException) {
295 Assert.IsTrue (tb.IsCreated (), "#2");
298 [Test] // bug #324692
299 public void TestCreateTypeReturnsNullOnSecondCallForBadType ()
301 TypeBuilder tb = module.DefineType (genTypeName (),
302 TypeAttributes.Sealed | TypeAttributes.Serializable,
308 } catch (TypeLoadException ex) {
309 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A2");
310 Assert.IsNull (ex.InnerException, "#A3");
311 Assert.IsNotNull (ex.Message, "#A4");
314 Assert.IsTrue (tb.IsCreated (), "#B1");
315 Assert.IsNull (tb.CreateType (), "#B2");
316 Assert.IsTrue (tb.IsCreated (), "#B3");
320 public void TestEnumWithEmptyInterfaceBuildsOk ()
322 TypeBuilder tb = module.DefineType (genTypeName (),
323 TypeAttributes.Sealed | TypeAttributes.Serializable,
325 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
326 FieldAttributes.Private | FieldAttributes.RTSpecialName);
328 tb.AddInterfaceImplementation (typeof (EmptyInterface));
332 } catch (TypeLoadException) {
333 Assert.Fail ("#1: must build enum type ok");
336 Assert.IsTrue (tb.IsCreated (), "#2");
340 [Category ("NotWorking")]
341 public void TestEnumWithNonEmptyInterfaceBuildsFails ()
343 TypeBuilder tb = module.DefineType (genTypeName (),
344 TypeAttributes.Sealed | TypeAttributes.Serializable,
346 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
347 FieldAttributes.Private | FieldAttributes.RTSpecialName);
349 tb.AddInterfaceImplementation (typeof (OneMethodInterface));
353 Assert.Fail ("#1: type doesn't have all interface methods");
354 } catch (TypeLoadException) {
357 Assert.IsTrue (tb.IsCreated (), "#2");
361 [Category ("NotWorking")]
362 public void TestTypeDontImplementInterfaceMethodBuildsFails ()
364 TypeBuilder tb = module.DefineType (genTypeName (),
365 TypeAttributes.Sealed | TypeAttributes.Serializable,
368 tb.AddInterfaceImplementation (typeof (OneMethodInterface));
372 Assert.Fail ("#1: type doesn't have all interface methods");
373 } catch (TypeLoadException) {
376 Assert.IsTrue (tb.IsCreated (), "#2");
380 public void TestEnumWithSequentialLayoutBuildsFails ()
382 TypeBuilder tb = module.DefineType (genTypeName (),
383 TypeAttributes.Sealed | TypeAttributes.Serializable |
384 TypeAttributes.SequentialLayout, typeof (Enum));
385 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
386 FieldAttributes.Private | FieldAttributes.RTSpecialName);
390 Assert.Fail ("#1: type doesn't have all interface methods");
391 } catch (TypeLoadException) {
394 Assert.IsTrue (tb.IsCreated (), "#2");
398 public void TestEnumWithExplicitLayoutBuildsFails ()
400 TypeBuilder tb = module.DefineType (genTypeName (),
401 TypeAttributes.Sealed | TypeAttributes.Serializable |
402 TypeAttributes.ExplicitLayout, typeof (Enum));
403 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
404 FieldAttributes.Private | FieldAttributes.RTSpecialName);
408 Assert.Fail ("#1: type doesn't have all interface methods");
409 } catch (TypeLoadException) {
412 Assert.IsTrue (tb.IsCreated (), "#2");
416 public void TestEnumWithMethodsBuildFails ()
418 TypeBuilder tb = module.DefineType ("FooEnum7",
419 TypeAttributes.Sealed | TypeAttributes.Serializable,
421 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
422 FieldAttributes.Private | FieldAttributes.RTSpecialName);
424 MethodBuilder methodBuilder = tb.DefineMethod("mmm",
425 MethodAttributes.Public | MethodAttributes.Virtual,
429 methodBuilder.GetILGenerator().Emit(OpCodes.Ret);
432 Assert.Fail ("#1: enum has method");
433 } catch (TypeLoadException) {
436 Assert.IsTrue (tb.IsCreated (), "#2");
440 public void TestEnumWithBadTypeValueFieldBuildFails ()
448 foreach (Type type in badTypes) {
449 TypeBuilder tb = module.DefineType (genTypeName (),
450 TypeAttributes.Sealed | TypeAttributes.Serializable,
452 tb.DefineField ("value__", type, FieldAttributes.SpecialName |
453 FieldAttributes.Private | FieldAttributes.RTSpecialName);
457 Assert.Fail ("#1: enum using bad type: " + type);
458 } catch (TypeLoadException) {
461 Assert.IsTrue (tb.IsCreated (), "#2");
466 public void TestEnumWithGoodTypeValueFieldBuildOk ()
469 typeof (byte),typeof (sbyte),typeof (bool),
470 typeof (ushort),typeof (short),typeof (char),
471 typeof (uint),typeof (int),
472 typeof (ulong),typeof (long),
473 typeof (UIntPtr),typeof (IntPtr),
476 foreach (Type type in goodTypes) {
477 TypeBuilder tb = module.DefineType (genTypeName (),
478 TypeAttributes.Sealed | TypeAttributes.Serializable,
480 tb.DefineField ("value__", type, FieldAttributes.SpecialName |
481 FieldAttributes.Private | FieldAttributes.RTSpecialName);
485 } catch (TypeLoadException) {
486 Assert.Fail ("#1: enum using good type: " + type);
492 public void TestEnumWithMultipleValueFieldsBuildFals ()
494 TypeBuilder tb = module.DefineType (genTypeName (),
495 TypeAttributes.Sealed | TypeAttributes.Serializable,
497 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
498 FieldAttributes.Private | FieldAttributes.RTSpecialName);
499 tb.DefineField ("value2__", typeof (int), FieldAttributes.SpecialName |
500 FieldAttributes.Private | FieldAttributes.RTSpecialName);
504 Assert.Fail ("#1: invalid enum type");
505 } catch (TypeLoadException) {
508 Assert.IsTrue (tb.IsCreated (), "#2");
512 [Category ("NotWorking")]
513 public void TestEnumWithEmptyInterfaceCanBeCasted ()
515 TypeBuilder tb = module.DefineType (genTypeName (),
516 TypeAttributes.Sealed | TypeAttributes.Serializable,
518 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
519 FieldAttributes.Private | FieldAttributes.RTSpecialName);
520 tb.AddInterfaceImplementation (typeof (EmptyInterface));
524 } catch (TypeLoadException) {
525 Assert.Fail ("#1: must build enum type ok");
529 EmptyInterface obj = (EmptyInterface) Activator.CreateInstance (tb);
530 Assert.IsNotNull (obj, "#2");
531 } catch (TypeLoadException) {
532 Assert.Fail ("#3: must cast enum to interface");
537 public void TestEnumWithValueFieldBuildOk ()
539 TypeBuilder tb = module.DefineType (genTypeName (),
540 TypeAttributes.Sealed | TypeAttributes.Serializable,
542 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
543 FieldAttributes.Private | FieldAttributes.RTSpecialName);
547 } catch (TypeLoadException) {
548 Assert.Fail ("#1: must build enum type ok");
553 public void TestIsAbstract ()
555 TypeBuilder tb = module.DefineType (genTypeName ());
556 Assert.IsFalse (tb.IsAbstract, "#1");
558 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Abstract);
559 Assert.IsTrue (tb2.IsAbstract, "#2");
563 public void TestIsAnsiClass ()
565 TypeBuilder tb = module.DefineType (genTypeName ());
566 Assert.IsTrue (tb.IsAnsiClass, "#1");
568 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.UnicodeClass);
569 Assert.IsFalse (tb2.IsAnsiClass, "#2");
573 public void TestIsArray ()
575 // How can a TypeBuilder be an array ?
576 string name = genTypeName ();
577 TypeBuilder tb = module.DefineType (name);
578 Assert.IsFalse (tb.IsArray);
582 public void TestIsAutoClass ()
584 TypeBuilder tb = module.DefineType (genTypeName ());
585 Assert.IsFalse (tb.IsAutoClass, "#1");
587 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.AutoClass);
588 Assert.IsTrue (tb2.IsAutoClass, "#2");
592 public void TestIsAutoLayout ()
594 TypeBuilder tb = module.DefineType (genTypeName ());
595 Assert.IsTrue (tb.IsAutoLayout, "#1");
597 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.ExplicitLayout);
598 Assert.IsFalse (tb2.IsAutoLayout, "#2");
602 public void TestIsByRef ()
604 // How can a TypeBuilder be ByRef ?
605 TypeBuilder tb = module.DefineType (genTypeName ());
606 Assert.IsFalse (tb.IsByRef);
610 public void TestIsClass ()
612 TypeBuilder tb = module.DefineType (genTypeName ());
613 Assert.IsTrue (tb.IsClass, "#1");
615 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
616 Assert.IsFalse (tb2.IsClass, "#2");
618 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
619 Assert.IsFalse (tb3.IsClass, "#3");
621 TypeBuilder tb4 = module.DefineType (genTypeName (), 0, typeof (Enum));
622 Assert.IsFalse (tb4.IsClass, "#4");
626 public void TestIsCOMObject ()
628 TypeBuilder tb = module.DefineType (genTypeName ());
629 Assert.IsFalse (tb.IsCOMObject, "#1");
631 tb = module.DefineType (genTypeName (), TypeAttributes.Import);
632 Assert.IsTrue (tb.IsCOMObject, "#2");
636 public void TestIsContextful ()
638 TypeBuilder tb = module.DefineType (genTypeName ());
639 Assert.IsFalse (tb.IsContextful, "#1");
641 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (ContextBoundObject));
642 Assert.IsTrue (tb2.IsContextful, "#2");
646 public void TestIsEnum ()
648 TypeBuilder tb = module.DefineType (genTypeName ());
649 Assert.IsFalse (tb.IsEnum, "#1");
651 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (ValueType));
652 Assert.IsFalse (tb2.IsEnum, "#2");
654 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (Enum));
655 Assert.IsTrue (tb3.IsEnum, "#3");
659 public void TestIsExplicitLayout ()
661 TypeBuilder tb = module.DefineType (genTypeName ());
662 Assert.IsFalse (tb.IsExplicitLayout, "#1");
664 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.ExplicitLayout);
665 Assert.IsTrue (tb2.IsExplicitLayout, "#2");
669 public void TestIsImport ()
671 TypeBuilder tb = module.DefineType (genTypeName ());
672 Assert.IsFalse (tb.IsImport, "#1");
674 tb = module.DefineType (genTypeName (), TypeAttributes.Import);
675 Assert.IsTrue (tb.IsImport, "#2");
679 public void TestIsInterface ()
681 TypeBuilder tb = module.DefineType (genTypeName ());
682 Assert.IsFalse (tb.IsInterface, "#1");
684 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
685 Assert.IsTrue (tb2.IsInterface, "#2");
687 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
688 Assert.IsFalse (tb3.IsInterface, "#3");
692 public void TestIsLayoutSequential ()
694 TypeBuilder tb = module.DefineType (genTypeName ());
695 Assert.IsFalse (tb.IsLayoutSequential, "#1");
697 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.SequentialLayout);
698 Assert.IsTrue (tb2.IsLayoutSequential, "#2");
702 public void TestIsMarshalByRef ()
704 TypeBuilder tb = module.DefineType (genTypeName ());
705 Assert.IsFalse (tb.IsMarshalByRef, "#1");
707 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (MarshalByRefObject));
708 Assert.IsTrue (tb2.IsMarshalByRef, "#2");
710 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ContextBoundObject));
711 Assert.IsTrue (tb3.IsMarshalByRef, "#3");
714 // TODO: Visibility properties
717 public void TestIsPointer ()
719 // How can this be true?
720 TypeBuilder tb = module.DefineType (genTypeName ());
721 Assert.IsFalse (tb.IsPointer);
725 public void TestIsPrimitive ()
727 TypeBuilder tb = module.DefineType ("int");
728 Assert.IsFalse (tb.IsPrimitive);
732 public void IsSealed ()
734 TypeBuilder tb = module.DefineType (genTypeName ());
735 Assert.IsFalse (tb.IsSealed, "#1");
737 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
738 Assert.IsTrue (tb2.IsSealed, "#2");
741 static string CreateTempAssembly ()
752 path = Path.Combine (Path.GetTempPath (), "tmp" + num.ToString ("x") + ".dll");
755 f = new FileStream (path, FileMode.CreateNew);
762 return "tmp" + num.ToString ("x") + ".dll";
766 public void IsSerializable ()
768 TypeBuilder tb = module.DefineType (genTypeName ());
769 Assert.IsFalse (tb.IsSerializable, "#1");
771 ConstructorInfo [] ctors = typeof (SerializableAttribute).GetConstructors (BindingFlags.Instance | BindingFlags.Public);
772 Assert.IsTrue (ctors.Length > 0, "#2");
774 tb.SetCustomAttribute (new CustomAttributeBuilder (ctors [0], new object [0]));
775 Type createdType = tb.CreateType ();
777 string an = CreateTempAssembly ();
779 Assert.IsTrue (createdType.IsSerializable, "#3");
780 File.Delete (Path.Combine (Path.GetTempPath (), an));
784 public void TestIsSpecialName ()
786 TypeBuilder tb = module.DefineType (genTypeName ());
787 Assert.IsFalse (tb.IsSpecialName, "#1");
789 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.SpecialName);
790 Assert.IsTrue (tb2.IsSpecialName, "#2");
794 public void TestIsUnicodeClass ()
796 TypeBuilder tb = module.DefineType (genTypeName ());
797 Assert.IsFalse (tb.IsUnicodeClass, "#1");
799 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.UnicodeClass);
800 Assert.IsTrue (tb2.IsUnicodeClass, "#2");
804 public void TestIsValueType ()
806 TypeBuilder tb = module.DefineType (genTypeName ());
807 Assert.IsFalse (tb.IsValueType, "#1");
809 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
810 Assert.IsFalse (tb2.IsValueType, "#2");
812 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
813 Assert.IsTrue (tb3.IsValueType, "#3");
815 TypeBuilder tb4 = module.DefineType (genTypeName (), 0, typeof (Enum));
816 Assert.IsTrue (tb4.IsValueType, "#4");
820 public void TestMemberType ()
822 TypeBuilder tb = module.DefineType (genTypeName ());
823 Assert.AreEqual (MemberTypes.TypeInfo, tb.MemberType);
827 public void TestModule ()
829 TypeBuilder tb = module.DefineType (genTypeName ());
830 Assert.AreEqual (module, tb.Module);
834 public void TestName ()
836 TypeBuilder tb = module.DefineType ("A");
837 Assert.AreEqual ("A", tb.Name, "#1");
839 TypeBuilder tb2 = module.DefineType ("A.B.C.D.E");
840 Assert.AreEqual ("E", tb2.Name, "#2");
842 TypeBuilder tb3 = tb2.DefineNestedType ("A");
843 Assert.AreEqual ("A", tb3.Name, "#3");
845 /* Is .E a valid name ?
846 TypeBuilder tb4 = module.DefineType (".E");
847 Assert.AreEqual ("E", tb4.Name);
852 public void TestNamespace ()
854 TypeBuilder tb = module.DefineType ("A");
855 Assert.AreEqual (string.Empty, tb.Namespace, "#1");
857 TypeBuilder tb2 = module.DefineType ("A.B.C.D.E");
858 Assert.AreEqual ("A.B.C.D", tb2.Namespace, "#2");
860 TypeBuilder tb3 = tb2.DefineNestedType ("A");
861 Assert.AreEqual (string.Empty, tb3.Namespace, "#3");
863 /* Is .E a valid name ?
864 TypeBuilder tb4 = module.DefineType (".E");
865 Assert.AreEqual ("E", tb4.Name);
870 public void TestPackingSize ()
872 TypeBuilder tb = module.DefineType (genTypeName ());
873 Assert.AreEqual (PackingSize.Unspecified, tb.PackingSize, "#1");
875 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (object),
876 PackingSize.Size16, 16);
877 Assert.AreEqual (PackingSize.Size16, tb2.PackingSize, "#2");
881 public void TestReflectedType ()
883 // It is the same as DeclaringType, but why?
884 TypeBuilder tb = module.DefineType (genTypeName ());
885 Assert.IsNull (tb.ReflectedType, "#1");
887 TypeBuilder tb2 = tb.DefineNestedType (genTypeName ());
888 Assert.AreEqual (tb, tb2.ReflectedType, "#2");
892 public void SetParent_Parent_Null ()
894 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class,
897 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
899 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
900 TypeAttributes.Abstract);
902 Assert.IsNull (tb.BaseType, "#B1");
904 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
905 TypeAttributes.Abstract, typeof (ICloneable));
906 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#C1");
908 Assert.IsNull (tb.BaseType, "#C2");
910 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
911 typeof (IDisposable));
915 } catch (InvalidOperationException ex) {
916 // Interface must be declared abstract
917 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
918 Assert.IsNull (ex.InnerException, "#D3");
919 Assert.IsNotNull (ex.Message, "#D4");
924 public void SetParent_Parent_Interface ()
926 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class);
927 tb.SetParent (typeof (ICloneable));
928 Assert.AreEqual (typeof (ICloneable), tb.BaseType);
932 public void TestSetParentIncomplete ()
934 TypeBuilder tb = module.DefineType (genTypeName ());
935 tb.SetParent (typeof (Attribute));
936 Assert.AreEqual (typeof (Attribute), tb.BaseType, "#1");
938 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
939 TypeAttributes.Abstract);
940 tb.SetParent (typeof (IDisposable));
941 Assert.AreEqual (typeof (IDisposable), tb.BaseType, "#2");
943 tb = module.DefineType (genTypeName ());
944 tb.SetParent (typeof (IDisposable));
945 Assert.AreEqual (typeof (IDisposable), tb.BaseType, "#3");
947 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
948 TypeAttributes.Abstract, typeof (IDisposable));
949 tb.SetParent (typeof (ICloneable));
950 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#4");
952 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
953 TypeAttributes.Abstract, typeof (IDisposable));
954 tb.SetParent (typeof (ICloneable));
955 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#5");
959 public void TestSetParentComplete ()
961 TypeBuilder tb = module.DefineType (genTypeName ());
964 tb.SetParent (typeof (Attribute));
966 } catch (InvalidOperationException ex) {
967 // Unable to change after type has been created
968 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
969 Assert.IsNull (ex.InnerException, "#3");
970 Assert.IsNotNull (ex.Message, "#4");
975 public void TestSize ()
978 TypeBuilder tb = module.DefineType (genTypeName ());
979 Assert.AreEqual (0, tb.Size, "#1");
981 Assert.AreEqual (0, tb.Size, "#2");
985 TypeBuilder tb = module.DefineType (genTypeName (), 0, typeof (object),
986 PackingSize.Size16, 32);
987 Assert.AreEqual (32, tb.Size, "#3");
992 public void TestTypeHandle ()
994 TypeBuilder tb = module.DefineType (genTypeName ());
996 RuntimeTypeHandle handle = tb.TypeHandle;
997 Assert.Fail ("#1:" + handle);
998 } catch (NotSupportedException ex) {
999 // The invoked member is not supported in a
1001 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1002 Assert.IsNull (ex.InnerException, "#3");
1003 Assert.IsNotNull (ex.Message, "#4");
1008 public void TestTypeInitializerIncomplete ()
1010 TypeBuilder tb = module.DefineType (genTypeName ());
1012 ConstructorInfo cb = tb.TypeInitializer;
1013 Assert.Fail ("#1:" + (cb != null));
1014 } catch (NotSupportedException ex) {
1015 // The invoked member is not supported in a
1017 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1018 Assert.IsNull (ex.InnerException, "#3");
1019 Assert.IsNotNull (ex.Message, "#4");
1024 public void TestTypeInitializerComplete ()
1026 TypeBuilder tb = module.DefineType (genTypeName ());
1028 ConstructorInfo cb = tb.TypeInitializer;
1032 public void TestTypeToken ()
1034 TypeBuilder tb = module.DefineType (genTypeName ());
1035 TypeToken token = tb.TypeToken;
1039 public void UnderlyingSystemType ()
1044 tb = module.DefineType (genTypeName ());
1045 Assert.AreSame (tb, tb.UnderlyingSystemType, "#A1");
1046 emitted_type = tb.CreateType ();
1047 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#A2");
1049 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1050 Assert.AreSame (tb, tb.UnderlyingSystemType, "#B1");
1051 emitted_type = tb.CreateType ();
1052 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#B2");
1054 tb = module.DefineType (genTypeName (), 0, typeof (ValueType));
1055 Assert.AreSame (tb, tb.UnderlyingSystemType, "#C1");
1056 emitted_type = tb.CreateType ();
1057 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#C2");
1059 tb = module.DefineType (genTypeName (), 0, typeof (Enum));
1061 Type t = tb.UnderlyingSystemType;
1062 Assert.Fail ("#D1:" + t);
1063 } catch (InvalidOperationException ex) {
1064 // Underlying type information on enumeration
1066 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1067 Assert.IsNull (ex.InnerException, "#D3");
1068 Assert.IsNotNull (ex.Message, "#D4");
1070 tb.DefineField ("val", typeof (int), FieldAttributes.Private);
1071 Assert.AreEqual (typeof (int), tb.UnderlyingSystemType, "#D5");
1072 emitted_type = tb.CreateType ();
1073 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#D6");
1075 tb = module.DefineType (genTypeName (), 0, typeof (Enum));
1076 tb.DefineField ("val", typeof (int), FieldAttributes.Static);
1078 Type t = tb.UnderlyingSystemType;
1079 Assert.Fail ("#E1:" + t);
1080 } catch (InvalidOperationException ex) {
1081 // Underlying type information on enumeration
1083 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1084 Assert.IsNull (ex.InnerException, "#E3");
1085 Assert.IsNotNull (ex.Message, "#E4");
1087 tb.DefineField ("foo", typeof (long), FieldAttributes.Private);
1088 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E5");
1089 tb.DefineField ("bar", typeof (short), FieldAttributes.Private);
1090 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E6");
1091 tb.DefineField ("boo", typeof (int), FieldAttributes.Static);
1092 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E7");
1096 public void AddInterfaceImplementation_InterfaceType_Null ()
1098 TypeBuilder tb = module.DefineType (genTypeName ());
1100 tb.AddInterfaceImplementation (null);
1102 } catch (ArgumentNullException ex) {
1103 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1104 Assert.IsNull (ex.InnerException, "#3");
1105 Assert.IsNotNull (ex.Message, "#4");
1106 Assert.AreEqual ("interfaceType", ex.ParamName, "#5");
1111 public void TestAddInterfaceImplementation ()
1113 TypeBuilder tb = module.DefineType (genTypeName ());
1114 tb.AddInterfaceImplementation (typeof (AnInterface));
1115 tb.AddInterfaceImplementation (typeof (AnInterface));
1117 Type t = tb.CreateType ();
1118 Assert.AreEqual (1, tb.GetInterfaces ().Length, "#2");
1120 // Can not be called on a created type
1122 tb.AddInterfaceImplementation (typeof (AnInterface));
1124 } catch (InvalidOperationException) {
1129 public void TestCreateType_Created ()
1131 TypeBuilder tb = module.DefineType (genTypeName ());
1132 Assert.IsFalse (tb.IsCreated (), "#A1");
1134 Type emittedType1 = tb.CreateType ();
1135 Assert.IsTrue (tb.IsCreated (), "#A2");
1136 Assert.IsNotNull (emittedType1, "#A3");
1138 Type emittedType2 = tb.CreateType ();
1139 Assert.IsNotNull (emittedType2, "#B1");
1140 Assert.IsTrue (tb.IsCreated (), "#B2");
1141 Assert.AreSame (emittedType1, emittedType2, "#B3");
1145 public void TestDefineConstructor ()
1147 TypeBuilder tb = module.DefineType (genTypeName ());
1149 ConstructorBuilder cb = tb.DefineConstructor (0, 0, null);
1150 cb.GetILGenerator ().Emit (OpCodes.Ret);
1153 // Can not be called on a created type
1155 tb.DefineConstructor (0, 0, null);
1157 } catch (InvalidOperationException ex) {
1158 // Unable to change after type has been created
1159 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1160 Assert.IsNull (ex.InnerException, "#3");
1161 Assert.IsNotNull (ex.Message, "#4");
1166 public void DefineDefaultConstructor ()
1168 TypeBuilder tb = module.DefineType (genTypeName ());
1169 tb.DefineDefaultConstructor (0);
1172 // Can not be called on a created type, altough the MSDN docs does not mention this
1174 tb.DefineDefaultConstructor (0);
1176 } catch (InvalidOperationException ex) {
1177 // Unable to change after type has been created
1178 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1179 Assert.IsNull (ex.InnerException, "#3");
1180 Assert.IsNotNull (ex.Message, "#4");
1185 [Category ("AndroidNotWorking")] // Fails with System.MethodAccessException : Method `t17:.ctor ()' is inaccessible from method `t18:.ctor ()'
1186 public void DefineDefaultConstructor_Parent_DefaultCtorInaccessible ()
1190 tb = module.DefineType (genTypeName ());
1191 tb.DefineDefaultConstructor (MethodAttributes.Private);
1192 Type parent_type = tb.CreateType ();
1194 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1196 tb.DefineDefaultConstructor (MethodAttributes.Public);
1197 Type emitted_type = tb.CreateType ();
1199 Activator.CreateInstance (emitted_type);
1201 } catch (TargetInvocationException ex) {
1202 Assert.AreEqual (typeof (TargetInvocationException), ex.GetType (), "#2");
1203 Assert.IsNotNull (ex.InnerException, "#3");
1204 Assert.IsNotNull (ex.Message, "#4");
1206 MethodAccessException mae = ex.InnerException as MethodAccessException;
1207 Assert.IsNotNull (mae, "#5");
1208 Assert.AreEqual (typeof (MethodAccessException), mae.GetType (), "#6");
1209 Assert.IsNull (mae.InnerException, "#7");
1210 Assert.IsNotNull (mae.Message, "#8");
1211 Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#9:" + mae.Message);
1212 Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#10:" + mae.Message);
1217 public void DefineDefaultConstructor_Parent_DefaultCtorMissing ()
1221 tb = module.DefineType (genTypeName ());
1222 ConstructorBuilder cb = tb.DefineConstructor (
1223 MethodAttributes.Public,
1224 CallingConventions.Standard,
1225 new Type [] { typeof (string) });
1226 cb.GetILGenerator ().Emit (OpCodes.Ret);
1227 Type parent_type = tb.CreateType ();
1229 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1232 tb.DefineDefaultConstructor (MethodAttributes.Public);
1234 } catch (NotSupportedException ex) {
1235 // Parent does not have a default constructor.
1236 // The default constructor must be explicitly defined
1237 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1238 Assert.IsNull (ex.InnerException, "#3");
1239 Assert.IsNotNull (ex.Message, "#4");
1244 public void DefineEvent_Name_NullChar ()
1246 TypeBuilder tb = module.DefineType (genTypeName ());
1249 tb.DefineEvent ("\0test", EventAttributes.None,
1251 Assert.Fail ("#A1");
1252 } catch (ArgumentException ex) {
1254 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1255 Assert.IsNull (ex.InnerException, "#A3");
1256 Assert.IsNotNull (ex.Message, "#A4");
1257 Assert.AreEqual ("name", ex.ParamName, "#A5");
1260 EventBuilder eb = tb.DefineEvent ("te\0st", EventAttributes.None,
1262 Assert.IsNotNull (eb, "#B1");
1266 public void TestDefineEvent ()
1268 TypeBuilder tb = module.DefineType (genTypeName ());
1270 // Test invalid arguments
1272 tb.DefineEvent (null, 0, typeof (int));
1273 Assert.Fail ("#A1");
1274 } catch (ArgumentNullException ex) {
1275 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1276 Assert.IsNull (ex.InnerException, "#A3");
1277 Assert.IsNotNull (ex.Message, "#A4");
1278 Assert.AreEqual ("name", ex.ParamName, "#A5");
1282 tb.DefineEvent ("FOO", 0, null);
1283 Assert.Fail ("#B1");
1284 } catch (ArgumentNullException ex) {
1285 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1286 Assert.IsNull (ex.InnerException, "#B3");
1287 Assert.IsNotNull (ex.Message, "#B4");
1288 Assert.AreEqual ("type", ex.ParamName, "#B5");
1292 tb.DefineEvent (string.Empty, 0, typeof (int));
1293 Assert.Fail ("#C1");
1294 } catch (ArgumentException ex) {
1295 // Empty name is not legal
1296 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1297 Assert.IsNull (ex.InnerException, "#C3");
1298 Assert.IsNotNull (ex.Message, "#C4");
1299 Assert.AreEqual ("name", ex.ParamName, "#C5");
1304 // Can not be called on a created type
1306 tb.DefineEvent ("BAR", 0, typeof (int));
1307 Assert.Fail ("#D1");
1308 } catch (InvalidOperationException ex) {
1309 // Unable to change after type has been created
1310 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1311 Assert.IsNull (ex.InnerException, "#D3");
1312 Assert.IsNotNull (ex.Message, "#D4");
1316 [Test] // DefineField (String, Type, FieldAttributes)
1317 public void DefineField1 ()
1319 TypeBuilder tb = module.DefineType (genTypeName ());
1321 // Check invalid arguments
1323 tb.DefineField (null, typeof (int), 0);
1324 Assert.Fail ("#A1");
1325 } catch (ArgumentNullException ex) {
1326 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1327 Assert.IsNull (ex.InnerException, "#A3");
1328 Assert.IsNotNull (ex.Message, "#A4");
1329 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1333 tb.DefineField (string.Empty, typeof (int), 0);
1334 Assert.Fail ("#B1");
1335 } catch (ArgumentException ex) {
1336 // Empty name is not legal
1337 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1338 Assert.IsNull (ex.InnerException, "#B3");
1339 Assert.IsNotNull (ex.Message, "#B4");
1340 Assert.AreEqual ("fieldName", ex.ParamName, "#B5");
1344 // Strangely, 'A<NULL>' is accepted...
1345 string name = String.Format ("{0}", (char) 0);
1346 tb.DefineField (name, typeof (int), 0);
1347 Assert.Fail ("#C1");
1348 } catch (ArgumentException ex) {
1350 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1351 Assert.IsNull (ex.InnerException, "#C3");
1352 Assert.IsNotNull (ex.Message, "#C4");
1353 Assert.AreEqual ("fieldName", ex.ParamName, "#C5");
1357 tb.DefineField ("A", typeof (void), 0);
1358 Assert.Fail ("#D1");
1359 } catch (ArgumentException ex) {
1360 // Bad field type in defining field
1361 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1362 Assert.IsNull (ex.InnerException, "#D3");
1363 Assert.IsNotNull (ex.Message, "#D4");
1364 Assert.IsNull (ex.ParamName, "#D5");
1369 // Can not be called on a created type
1371 tb.DefineField ("B", typeof (int), 0);
1372 Assert.Fail ("#E1");
1373 } catch (InvalidOperationException ex) {
1374 // Unable to change after type has been created
1375 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1376 Assert.IsNull (ex.InnerException, "#E3");
1377 Assert.IsNotNull (ex.Message, "#E4");
1381 [Test] // DefineField (String, Type, FieldAttributes)
1382 public void DefineField1_Name_NullChar ()
1384 TypeBuilder tb = module.DefineType (genTypeName ());
1387 tb.DefineField ("\0test", typeof (int),
1388 FieldAttributes.Private);
1389 Assert.Fail ("#A1");
1390 } catch (ArgumentException ex) {
1392 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1393 Assert.IsNull (ex.InnerException, "#A3");
1394 Assert.IsNotNull (ex.Message, "#A4");
1395 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1398 FieldBuilder fb = tb.DefineField ("te\0st", typeof (int),
1399 FieldAttributes.Private);
1400 Assert.IsNotNull (fb, "#B1");
1401 Assert.AreEqual ("te\0st", fb.Name, "#B2");
1404 [Test] // DefineField (String, Type, FieldAttributes)
1405 public void DefineField1_Type_Null ()
1407 TypeBuilder tb = module.DefineType (genTypeName ());
1410 tb.DefineField ("test", (Type) null,
1411 FieldAttributes.Private);
1413 } catch (ArgumentNullException ex) {
1414 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1415 Assert.IsNull (ex.InnerException, "#3");
1416 Assert.IsNotNull (ex.Message, "#4");
1417 Assert.AreEqual ("type", ex.ParamName, "#5");
1421 [Test] // DefineField (String, Type, Type [], Type [], FieldAttributes)
1422 public void DefineField2_Type_Null ()
1424 TypeBuilder tb = module.DefineType (genTypeName ());
1427 tb.DefineField ("test", (Type) null, Type.EmptyTypes,
1428 Type.EmptyTypes, FieldAttributes.Private);
1430 } catch (ArgumentNullException ex) {
1431 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1432 Assert.IsNull (ex.InnerException, "#3");
1433 Assert.IsNotNull (ex.Message, "#4");
1434 Assert.AreEqual ("type", ex.ParamName, "#5");
1439 public void TestDefineInitializedData ()
1441 TypeBuilder tb = module.DefineType (genTypeName ());
1443 // Check invalid arguments
1445 tb.DefineInitializedData (null, new byte [1], 0);
1446 Assert.Fail ("#A1");
1447 } catch (ArgumentNullException ex) {
1448 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1449 Assert.IsNull (ex.InnerException, "#A3");
1450 Assert.IsNotNull (ex.Message, "#A4");
1451 Assert.AreEqual ("name", ex.ParamName, "#A5");
1455 tb.DefineInitializedData ("FOO", null, 0);
1456 Assert.Fail ("#B1");
1457 } catch (ArgumentNullException ex) {
1458 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1459 Assert.IsNull (ex.InnerException, "#B3");
1460 Assert.IsNotNull (ex.Message, "#B4");
1461 Assert.AreEqual ("data", ex.ParamName, "#B5");
1465 tb.DefineInitializedData (string.Empty, new byte [1], 0);
1466 Assert.Fail ("#C1");
1467 } catch (ArgumentException ex) {
1468 // Empty name is not legal
1469 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1470 Assert.IsNull (ex.InnerException, "#C3");
1471 Assert.IsNotNull (ex.Message, "#C4");
1472 Assert.AreEqual ("name", ex.ParamName, "#C5");
1475 // The size of the data is less than or equal to zero ???
1477 tb.DefineInitializedData ("BAR", new byte [0], 0);
1478 Assert.Fail ("#D1");
1479 } catch (ArgumentException ex) {
1480 // Data size must be > 0 and < 0x3f0000
1481 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1482 Assert.IsNull (ex.InnerException, "#D3");
1483 Assert.IsNotNull (ex.Message, "#D4");
1484 Assert.IsNull (ex.ParamName, "#D5");
1488 string name = String.Format ("{0}", (char) 0);
1489 tb.DefineInitializedData (name, new byte [1], 0);
1490 Assert.Fail ("#E1");
1491 } catch (ArgumentException ex) {
1493 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#E2");
1494 Assert.IsNull (ex.InnerException, "#E3");
1495 Assert.IsNotNull (ex.Message, "#E4");
1496 Assert.AreEqual ("fieldName", ex.ParamName, "#E5");
1501 // Can not be called on a created type, altough the MSDN docs does not mention this
1503 tb.DefineInitializedData ("BAR2", new byte [1], 0);
1504 Assert.Fail ("#F1");
1505 } catch (InvalidOperationException ex) {
1506 // Unable to change after type has been created
1507 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
1508 Assert.IsNull (ex.InnerException, "#F3");
1509 Assert.IsNotNull (ex.Message, "#F4");
1514 public void DefineUninitializedDataInvalidArgs ()
1516 TypeBuilder tb = module.DefineType (genTypeName ());
1519 tb.DefineUninitializedData (null, 1, 0);
1520 Assert.Fail ("#A1");
1521 } catch (ArgumentNullException ex) {
1522 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1523 Assert.IsNull (ex.InnerException, "#A3");
1524 Assert.IsNotNull (ex.Message, "#A4");
1525 Assert.AreEqual ("name", ex.ParamName, "#A5");
1529 tb.DefineUninitializedData (string.Empty, 1, 0);
1530 Assert.Fail ("#B1");
1531 } catch (ArgumentException ex) {
1532 // Empty name is not legal
1533 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1534 Assert.IsNull (ex.InnerException, "#B3");
1535 Assert.IsNotNull (ex.Message, "#B4");
1536 Assert.AreEqual ("name", ex.ParamName, "#B5");
1539 // The size of the data is less than or equal to zero ???
1541 tb.DefineUninitializedData ("BAR", 0, 0);
1542 Assert.Fail ("#C1");
1543 } catch (ArgumentException ex) {
1544 // Data size must be > 0 and < 0x3f0000
1545 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1546 Assert.IsNull (ex.InnerException, "#C3");
1547 Assert.IsNotNull (ex.Message, "#C4");
1548 Assert.IsNull (ex.ParamName, "#C5");
1552 string name = String.Format ("{0}", (char) 0);
1553 tb.DefineUninitializedData (name, 1, 0);
1554 Assert.Fail ("#D1");
1555 } catch (ArgumentException ex) {
1557 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1558 Assert.IsNull (ex.InnerException, "#D3");
1559 Assert.IsNotNull (ex.Message, "#D4");
1560 Assert.AreEqual ("fieldName", ex.ParamName, "#D5");
1565 public void DefineUninitializedDataAlreadyCreated ()
1567 TypeBuilder tb = module.DefineType (genTypeName ());
1570 tb.DefineUninitializedData ("BAR2", 1, 0);
1572 } catch (InvalidOperationException ex) {
1573 // Unable to change after type has been created
1574 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1575 Assert.IsNull (ex.InnerException, "#3");
1576 Assert.IsNotNull (ex.Message, "#4");
1581 public void DefineUninitializedData ()
1583 TypeBuilder tb = module.DefineType (genTypeName ());
1585 tb.DefineUninitializedData ("foo", 4, FieldAttributes.Public);
1587 Type t = tb.CreateType ();
1589 object o = Activator.CreateInstance (t);
1591 FieldInfo fi = t.GetField ("foo");
1593 object fieldVal = fi.GetValue (o);
1595 IntPtr ptr = Marshal.AllocHGlobal (4);
1596 Marshal.StructureToPtr (fieldVal, ptr, true);
1597 Marshal.FreeHGlobal (ptr);
1601 public void DefineMethod_Name_NullChar ()
1603 TypeBuilder tb = module.DefineType (genTypeName ());
1605 tb.DefineMethod ("\0test", MethodAttributes.Private,
1606 typeof (string), Type.EmptyTypes);
1607 Assert.Fail ("#A1");
1608 } catch (ArgumentException ex) {
1610 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1611 Assert.IsNull (ex.InnerException, "#A3");
1612 Assert.IsNotNull (ex.Message, "#A4");
1613 Assert.AreEqual ("name", ex.ParamName, "#A5");
1616 MethodBuilder mb = tb.DefineMethod ("te\0st", MethodAttributes.Private,
1617 typeof (string), Type.EmptyTypes);
1618 Assert.IsNotNull (mb, "#B1");
1619 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1623 public void TestDefineMethod ()
1625 TypeBuilder tb = module.DefineType (genTypeName ());
1627 // Check invalid arguments
1629 tb.DefineMethod (null, 0, null, null);
1630 Assert.Fail ("#A1");
1631 } catch (ArgumentNullException ex) {
1632 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1633 Assert.IsNull (ex.InnerException, "#A3");
1634 Assert.IsNotNull (ex.Message, "#A4");
1635 Assert.AreEqual ("name", ex.ParamName, "#A5");
1639 tb.DefineMethod (string.Empty, 0, null, null);
1640 Assert.Fail ("#B1");
1641 } catch (ArgumentException ex) {
1642 // Empty name is not legal
1643 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1644 Assert.IsNull (ex.InnerException, "#B3");
1645 Assert.IsNotNull (ex.Message, "#B4");
1646 Assert.AreEqual ("name", ex.ParamName, "#B5");
1649 // Check non-virtual methods on an interface
1650 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1652 tb2.DefineMethod ("FOO", MethodAttributes.Abstract, null, null);
1653 Assert.Fail ("#C1");
1654 } catch (ArgumentException ex) {
1655 // Interface method must be abstract and virtual
1656 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1657 Assert.IsNull (ex.InnerException, "#C3");
1658 Assert.IsNotNull (ex.Message, "#C4");
1659 Assert.IsNull (ex.ParamName, "#C5");
1662 // Check static methods on an interface
1663 tb2.DefineMethod ("BAR", MethodAttributes.Public | MethodAttributes.Static,
1668 // Can not be called on a created type
1670 tb.DefineMethod ("bar", 0, null, null);
1671 Assert.Fail ("#D1");
1672 } catch (InvalidOperationException ex) {
1673 // Unable to change after type has been created
1674 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1675 Assert.IsNull (ex.InnerException, "#D3");
1676 Assert.IsNotNull (ex.Message, "#D4");
1680 [Test] // bug #327484
1681 [Category ("NotWorking")]
1682 public void TestDefineMethod_Abstract ()
1684 TypeBuilder tb = module.DefineType (genTypeName ());
1685 tb.DefineMethod ("Run", MethodAttributes.Public |
1686 MethodAttributes.Abstract | MethodAttributes.Virtual,
1687 typeof (void), Type.EmptyTypes);
1691 Assert.Fail ("#A1");
1692 } catch (InvalidOperationException ex) {
1693 // Type must be declared abstract if any of its
1694 // methods are abstract
1695 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1696 Assert.IsNull (ex.InnerException, "#A3");
1697 Assert.IsNotNull (ex.Message, "#A4");
1700 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract);
1701 tb.DefineMethod ("Run", MethodAttributes.Public |
1702 MethodAttributes.Abstract, typeof (void),
1707 Assert.Fail ("#B1");
1708 } catch (TypeLoadException ex) {
1709 // Non-virtual abstract method
1710 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B2");
1711 Assert.IsNull (ex.InnerException, "#B3");
1712 Assert.IsNotNull (ex.Message, "#B4");
1715 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract |
1716 TypeAttributes.Public);
1717 tb.DefineMethod ("Run", MethodAttributes.Public |
1718 MethodAttributes.Abstract | MethodAttributes.Virtual,
1719 typeof (void), Type.EmptyTypes);
1720 Type emittedType = tb.CreateType ();
1722 MethodInfo mi1 = emittedType.GetMethod ("Run");
1723 Assert.IsNotNull (mi1, "#C1");
1724 Assert.IsTrue (mi1.IsAbstract, "#C2");
1726 MethodInfo mi2 = tb.GetMethod ("Run");
1727 Assert.IsNotNull (mi2, "#D1");
1728 Assert.IsTrue (mi2.IsAbstract, "#D2");
1731 // TODO: DefineMethodOverride
1734 public void TestDefineNestedType ()
1736 TypeBuilder tb = module.DefineType (genTypeName ());
1738 // Check invalid arguments
1740 tb.DefineNestedType (null);
1741 Assert.Fail ("#A1");
1742 } catch (ArgumentNullException ex) {
1743 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1744 Assert.IsNull (ex.InnerException, "#A3");
1745 Assert.IsNotNull (ex.Message, "#A4");
1746 Assert.AreEqual ("fullname", ex.ParamName, "#A5");
1750 tb.DefineNestedType (string.Empty);
1751 Assert.Fail ("#B1");
1752 } catch (ArgumentException ex) {
1753 // Empty name is not legal
1754 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1755 Assert.IsNull (ex.InnerException, "#B3");
1756 Assert.IsNotNull (ex.Message, "#B4");
1757 Assert.AreEqual ("fullname", ex.ParamName, "#B5");
1761 tb.DefineNestedType (nullName ());
1762 Assert.Fail ("#C1");
1763 } catch (ArgumentException ex) {
1765 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1766 Assert.IsNull (ex.InnerException, "#C3");
1767 Assert.IsNotNull (ex.Message, "#C4");
1768 Assert.AreEqual ("fullname", ex.ParamName, "#C5");
1771 // If I fix the code so this works then mcs breaks -> how can mcs
1772 // works under MS .NET in the first place ???
1775 tb.DefineNestedType ("AA", TypeAttributes.Public, null, null);
1776 Fail ("Nested visibility must be specified.");
1778 catch (ArgumentException) {
1783 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1785 Assert.Fail ("#D1");
1786 } catch (ArgumentNullException ex) {
1787 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#D2");
1788 Assert.IsNull (ex.InnerException, "#D3");
1789 Assert.IsNotNull (ex.Message, "#D4");
1790 Assert.AreEqual ("interfaces", ex.ParamName, "#D5");
1793 // I think this should reject non-interfaces, but it does not
1794 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1795 new Type [1] { typeof (object) });
1797 // Normal invocation
1798 tb.DefineNestedType ("Nest");
1802 // According to the MSDN docs, this cannnot be called after the type
1803 // is created, but it works.
1804 tb.DefineNestedType ("Nest2");
1806 // According to the MSDN docs, a Sealed class can't contain nested
1807 // types, but this is not true
1808 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
1809 tb2.DefineNestedType ("AA");
1811 // According to the MSDN docs, interfaces can only contain interfaces,
1812 // but this is not true
1813 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1815 tb3.DefineNestedType ("AA");
1817 // Check shorter versions
1819 TypeBuilder nested = tb.DefineNestedType ("N1");
1821 Assert.AreEqual ("N1", nested.Name, "#E1");
1822 Assert.AreEqual (typeof (object), nested.BaseType, "#E2");
1823 Assert.AreEqual (TypeAttributes.NestedPrivate, nested.Attributes, "#E3");
1824 Assert.AreEqual (0, nested.GetInterfaces ().Length, "#E4");
1831 public void DefinePInvokeMethod_Name_NullChar ()
1833 TypeBuilder tb = module.DefineType (genTypeName ());
1835 tb.DefinePInvokeMethod ("\0test", "B", "C",
1836 MethodAttributes.Private, CallingConventions.Standard,
1837 typeof (string),Type.EmptyTypes, CallingConvention.Cdecl,
1839 Assert.Fail ("#A1");
1840 } catch (ArgumentException ex) {
1842 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1843 Assert.IsNull (ex.InnerException, "#A3");
1844 Assert.IsNotNull (ex.Message, "#A4");
1845 Assert.AreEqual ("name", ex.ParamName, "#A5");
1848 MethodBuilder mb = tb.DefinePInvokeMethod ("te\0st", "B", "C",
1849 MethodAttributes.Private, CallingConventions.Standard,
1850 typeof (string), Type.EmptyTypes, CallingConvention.Cdecl,
1852 Assert.IsNotNull (mb, "#B1");
1853 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1857 public void TestDefinePInvokeMethod ()
1859 TypeBuilder tb = module.DefineType (genTypeName ());
1861 tb.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1863 // Try invalid parameters
1865 tb.DefinePInvokeMethod (null, "B", "C", 0, 0, null, null, 0, 0);
1866 Assert.Fail ("#A1");
1867 } catch (ArgumentNullException ex) {
1868 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1869 Assert.IsNull (ex.InnerException, "#A3");
1870 Assert.IsNotNull (ex.Message, "#A4");
1871 Assert.AreEqual ("name", ex.ParamName, "#A5");
1875 // Try invalid attributes
1877 tb.DefinePInvokeMethod ("A2", "B", "C", MethodAttributes.Abstract, 0, null, null, 0, 0);
1878 Assert.Fail ("#B1");
1879 } catch (ArgumentException ex) {
1880 // PInvoke methods must be static and native and
1881 // cannot be abstract
1882 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1883 Assert.IsNull (ex.InnerException, "#B3");
1884 Assert.IsNotNull (ex.Message, "#B4");
1885 Assert.IsNull (ex.ParamName, "#B5");
1888 // Try an interface parent
1889 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1892 tb2.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1893 Assert.Fail ("#C1");
1894 } catch (ArgumentException ex) {
1895 // PInvoke methods cannot exist on interfaces
1896 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1897 Assert.IsNull (ex.InnerException, "#B3");
1898 Assert.IsNotNull (ex.Message, "#B4");
1899 Assert.IsNull (ex.ParamName, "#B5");
1904 public void DefineProperty_Name_NullChar ()
1906 TypeBuilder tb = module.DefineType (genTypeName ());
1909 tb.DefineProperty ("\0test", 0, typeof (string), Type.EmptyTypes);
1910 Assert.Fail ("#A1");
1911 } catch (ArgumentException ex) {
1913 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1914 Assert.IsNull (ex.InnerException, "#A3");
1915 Assert.IsNotNull (ex.Message, "#A4");
1916 Assert.AreEqual ("name", ex.ParamName, "#A5");
1919 PropertyBuilder pb = tb.DefineProperty ("te\0st", 0,
1920 typeof (string), Type.EmptyTypes);
1921 Assert.IsNotNull (pb, "#B1");
1922 Assert.AreEqual ("te\0st", pb.Name, "#B2");
1926 public void DefineProperty_ParameterTypes_ItemNull ()
1928 TypeBuilder tb = module.DefineType (genTypeName ());
1931 tb.DefineProperty ("A", 0, typeof (string), new Type [1]);
1933 } catch (ArgumentNullException ex) {
1934 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1935 Assert.IsNull (ex.InnerException, "#3");
1936 Assert.IsNotNull (ex.Message, "#4");
1941 public void DefineProperty_ReturnType_Null ()
1943 TypeBuilder tb = module.DefineType (genTypeName ());
1944 tb.DefineProperty ("A", 0, null, Type.EmptyTypes);
1948 public void GetMethod_WorksWithTypeBuilderParameter () {
1949 TypeBuilder tb = module.DefineType (genTypeName ());
1950 var garg = tb.DefineGenericParameters ("T") [0];
1951 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
1953 var mi = TypeBuilder.GetMethod (tb, mb);
1954 var decl = mi.DeclaringType;
1956 Assert.IsTrue (decl.IsGenericType, "#1");
1957 Assert.IsFalse (decl.IsGenericTypeDefinition, "#2");
1958 Assert.AreEqual (tb, decl.GetGenericTypeDefinition (), "#3");
1959 Assert.AreEqual (garg, decl.GetGenericArguments () [0], "#4");
1963 public void GetConstructor_FailWithTypeBuilderParameter () {
1964 TypeBuilder tb = module.DefineType (genTypeName ());
1965 var garg = tb.DefineGenericParameters ("T") [0];
1966 var cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
1969 TypeBuilder.GetConstructor (tb, cb);
1971 } catch (ArgumentException ex) {
1972 Assert.AreEqual ("type", ex.ParamName, "#2");
1977 public void GetField_FailWithTypeBuilderParameter () {
1978 TypeBuilder tb = module.DefineType (genTypeName ());
1979 var garg = tb.DefineGenericParameters ("T") [0];
1980 var fb = tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
1983 TypeBuilder.GetField (tb, fb);
1985 } catch (ArgumentException ex) {
1986 Assert.AreEqual ("type", ex.ParamName, "#2");
1991 public void GetMethod_RejectMethodFromInflatedTypeBuilder () {
1992 TypeBuilder tb = module.DefineType (genTypeName ());
1993 tb.DefineGenericParameters ("T");
1994 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
1996 Type ginst = tb.MakeGenericType (typeof (int));
1998 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2000 TypeBuilder.GetMethod (ginst, mi);
2002 } catch (ArgumentException ex) {
2003 Assert.AreEqual ("method", ex.ParamName, "#5");
2008 public void GetMethod_WorkWithInstancesOfCreatedTypeBuilder () {
2009 TypeBuilder tb = module.DefineType (genTypeName ());
2010 tb.DefineGenericParameters ("T");
2011 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2012 ILGenerator ig = mb.GetILGenerator ();
2013 ig.Emit (OpCodes.Ret);
2017 MethodInfo mi = TypeBuilder.GetMethod (tb.MakeGenericType (typeof (int)), mb);
2018 Assert.IsNotNull (mi);
2022 [Category ("NotDotNet")]
2023 [Category ("NotWorking")]
2024 public void GetMethod_AcceptMethodFromInflatedTypeBuilder_UnderCompilerContext () {
2025 AssemblyName assemblyName = new AssemblyName ();
2026 assemblyName.Name = ASSEMBLY_NAME;
2029 Thread.GetDomain ().DefineDynamicAssembly (
2030 assemblyName, AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800, Path.GetTempPath ());
2032 module = assembly.DefineDynamicModule ("module1");
2034 TypeBuilder tb = module.DefineType (genTypeName ());
2035 tb.DefineGenericParameters ("T");
2036 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2038 Type ginst = tb.MakeGenericType (typeof (int));
2040 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2043 TypeBuilder.GetMethod (ginst, mi);
2044 } catch (ArgumentException ex) {
2051 // Test that changes made to the method builder after a call to GetMethod ()
2053 public void TestGetMethod ()
2055 TypeBuilder tb = module.DefineType (genTypeName ());
2056 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2058 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2060 ig = cb.GetILGenerator ();
2061 ig.Emit (OpCodes.Ret);
2063 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2065 // Create a method builder but do not emit IL yet
2066 MethodBuilder mb1 = tb.DefineMethod ("create", MethodAttributes.Public|MethodAttributes.Static, fooOfT, Type.EmptyTypes);
2068 Type t = tb.MakeGenericType (typeof (int));
2070 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2072 ig = mb.GetILGenerator ();
2073 ig.Emit (OpCodes.Call, TypeBuilder.GetMethod (t, mb1));
2074 ig.Emit (OpCodes.Ret);
2076 // Finish the method
2077 ig = mb1.GetILGenerator ();
2078 ig.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (fooOfT, cb));
2079 ig.Emit (OpCodes.Ret);
2081 Type t2 = tb.CreateType ();
2083 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2087 public void TestGetConstructor ()
2089 TypeBuilder tb = module.DefineType (genTypeName ());
2090 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2092 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2095 Type t = tb.MakeGenericType (typeof (int));
2097 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2099 ig = mb.GetILGenerator ();
2101 ConstructorInfo ci = TypeBuilder.GetConstructor (t, cb);
2103 ig.Emit (OpCodes.Newobj, ci);
2104 ig.Emit (OpCodes.Ret);
2106 // Finish the ctorbuilder
2107 ig = cb.GetILGenerator ();
2108 ig.Emit(OpCodes.Ldarg_0);
2109 ig.Emit(OpCodes.Call, tb.BaseType.GetConstructor(Type.EmptyTypes));
2110 ig.Emit (OpCodes.Ret);
2112 Type t2 = tb.CreateType ();
2114 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2118 [ExpectedException (typeof (ArgumentException))]
2119 public void Static_GetConstructor_TypeNull ()
2121 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2122 // null is non-generic (from exception message)
2123 TypeBuilder.GetConstructor (null, ci);
2127 [ExpectedException (typeof (ArgumentException))]
2128 public void Static_GetConstructor_TypeGeneric ()
2130 Type t = typeof (List<>).MakeGenericType (typeof (int));
2131 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2132 // type is not 'TypeBuilder' (from exception message)
2133 TypeBuilder.GetConstructor (t, ci);
2137 public void Static_GetConstructor_TypeBuilderGeneric_ConstructorInfoNull ()
2139 TypeBuilder tb = module.DefineType ("XXX");
2140 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2141 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2143 TypeBuilder.GetConstructor (fooOfT, null);
2144 Assert.Fail ("Expected NullReferenceException");
2146 catch (NullReferenceException) {
2151 public void CreateTypeThrowsForMethodsWithBadLabels ()
2153 TypeBuilder tb = module.DefineType (genTypeName ());
2155 MethodBuilder mb = tb.DefineMethod("F", MethodAttributes.Public, typeof(string), null);
2156 ILGenerator il_gen = mb.GetILGenerator ();
2157 il_gen.DefineLabel ();
2158 il_gen.Emit (OpCodes.Leave, new Label ());
2162 } catch (ArgumentException) {}
2166 [Category ("NotWorking")]
2167 public void TestIsDefinedIncomplete ()
2169 TypeBuilder tb = module.DefineType (genTypeName ());
2171 tb.IsDefined (typeof (int), true);
2173 } catch (NotSupportedException ex) {
2174 // The invoked member is not supported in a
2176 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2177 Assert.IsNull (ex.InnerException, "#3");
2178 Assert.IsNotNull (ex.Message, "#4");
2183 public void TestIsDefinedComplete ()
2185 TypeBuilder tb = module.DefineType (genTypeName ());
2187 ConstructorInfo obsoleteCtor = typeof (ObsoleteAttribute).GetConstructor (
2188 new Type [] { typeof (string) });
2190 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (obsoleteCtor,
2191 new object [] { "obsolete message" }, new FieldInfo [0], new object [0]);
2193 tb.SetCustomAttribute (caBuilder);
2195 Assert.IsTrue (tb.IsDefined (typeof (ObsoleteAttribute), false));
2199 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=293659
2200 public void IsDefined_AttributeType_Null ()
2202 TypeBuilder tb = module.DefineType (genTypeName ());
2206 tb.IsDefined ((Type) null, false);
2208 } catch (ArgumentNullException ex) {
2209 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2210 Assert.IsNull (ex.InnerException, "#3");
2211 Assert.IsNotNull (ex.Message, "#4");
2212 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
2216 [Test] // GetConstructor (Type [])
2217 public void GetConstructor1_Incomplete ()
2219 TypeBuilder tb = module.DefineType (genTypeName ());
2220 ConstructorBuilder cb = tb.DefineConstructor (
2221 MethodAttributes.Public,
2222 CallingConventions.Standard,
2224 cb.GetILGenerator ().Emit (OpCodes.Ret);
2227 tb.GetConstructor (Type.EmptyTypes);
2229 } catch (NotSupportedException ex) {
2230 // The invoked member is not supported in a
2232 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2233 Assert.IsNull (ex.InnerException, "#3");
2234 Assert.IsNotNull (ex.Message, "#4");
2238 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2239 public void GetConstructor2_Complete ()
2242 ConstructorInfo ctor;
2244 TypeBuilder redType = module.DefineType (genTypeName (),
2245 TypeAttributes.Public);
2246 CreateMembers (redType, "Red", true);
2248 TypeBuilder greenType = module.DefineType (genTypeName (),
2249 TypeAttributes.Public, redType);
2250 CreateMembers (greenType, "Green", false);
2251 ConstructorBuilder cb = greenType.DefineConstructor (
2252 MethodAttributes.Public,
2253 CallingConventions.Standard,
2255 cb.GetILGenerator ().Emit (OpCodes.Ret);
2257 redType.CreateType ();
2258 greenType.CreateType ();
2260 flags = BindingFlags.Instance | BindingFlags.NonPublic;
2262 ctor = greenType.GetConstructor (flags, null,
2263 new Type [] { typeof (int), typeof (int) },
2264 new ParameterModifier [0]);
2265 Assert.IsNull (ctor, "#A1");
2267 ctor = greenType.GetConstructor (flags, null,
2268 new Type [] { typeof (string) },
2269 new ParameterModifier [0]);
2270 Assert.IsNull (ctor, "#A2");
2272 ctor = greenType.GetConstructor (flags, null,
2273 new Type [] { typeof (string), typeof (string) },
2274 new ParameterModifier [0]);
2275 Assert.IsNull (ctor, "#A3");
2277 ctor = greenType.GetConstructor (flags, null,
2278 new Type [] { typeof (int) },
2279 new ParameterModifier [0]);
2280 Assert.IsNull (ctor, "#A4");
2282 ctor = greenType.GetConstructor (flags, null,
2283 new Type [] { typeof (int), typeof (bool) },
2284 new ParameterModifier [0]);
2285 Assert.IsNull (ctor, "#A5");
2287 ctor = greenType.GetConstructor (flags, null,
2288 new Type [] { typeof (string), typeof (int) },
2289 new ParameterModifier [0]);
2290 Assert.IsNull (ctor, "#A6");
2292 ctor = greenType.GetConstructor (flags, null,
2294 new ParameterModifier [0]);
2295 Assert.IsNull (ctor, "#A7");
2297 ctor = redType.GetConstructor (flags, null,
2298 new Type [] { typeof (int), typeof (int) },
2299 new ParameterModifier [0]);
2300 Assert.IsNotNull (ctor, "#A8a");
2301 Assert.IsTrue (ctor.IsPrivate, "#A8b");
2302 Assert.IsFalse (ctor.IsStatic, "#A8c");
2303 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A8d");
2304 Assert.IsFalse (ctor is ConstructorBuilder, "#A8e");
2306 ctor = redType.GetConstructor (flags, null,
2307 new Type [] { typeof (string) },
2308 new ParameterModifier [0]);
2309 Assert.IsNotNull (ctor, "#A9a");
2310 Assert.IsTrue (ctor.IsFamily, "#A9b");
2311 Assert.IsFalse (ctor.IsStatic, "#A9c");
2312 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A9d");
2313 Assert.IsFalse (ctor is ConstructorBuilder, "#A9e");
2315 ctor = redType.GetConstructor (flags, null,
2316 new Type [] { typeof (string), typeof (string) },
2317 new ParameterModifier [0]);
2318 Assert.IsNotNull (ctor, "#A10a");
2319 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#A10b");
2320 Assert.IsFalse (ctor.IsStatic, "#A10c");
2321 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A10d");
2322 Assert.IsFalse (ctor is ConstructorBuilder, "#A10e");
2324 ctor = redType.GetConstructor (flags, null,
2325 new Type [] { typeof (int) },
2326 new ParameterModifier [0]);
2327 Assert.IsNotNull (ctor, "#A11a");
2328 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#A11b");
2329 Assert.IsFalse (ctor.IsStatic, "#A11c");
2330 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A11d");
2331 Assert.IsFalse (ctor is ConstructorBuilder, "#A11e");
2333 ctor = redType.GetConstructor (flags, null,
2334 new Type [] { typeof (int), typeof (bool) },
2335 new ParameterModifier [0]);
2336 Assert.IsNull (ctor, "#A12");
2338 ctor = redType.GetConstructor (flags, null,
2339 new Type [] { typeof (string), typeof (int) },
2340 new ParameterModifier [0]);
2341 Assert.IsNotNull (ctor, "#A13a");
2342 Assert.IsTrue (ctor.IsAssembly, "#A13b");
2343 Assert.IsFalse (ctor.IsStatic, "#A13c");
2344 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A13d");
2345 Assert.IsFalse (ctor is ConstructorBuilder, "#A13e");
2347 ctor = redType.GetConstructor (flags, null,
2349 new ParameterModifier [0]);
2350 Assert.IsNull (ctor, "#A14");
2352 flags = BindingFlags.Instance | BindingFlags.Public;
2354 ctor = greenType.GetConstructor (flags, null,
2355 new Type [] { typeof (int), typeof (int) },
2356 new ParameterModifier [0]);
2357 Assert.IsNull (ctor, "#B1");
2359 ctor = greenType.GetConstructor (flags, null,
2360 new Type [] { typeof (string) },
2361 new ParameterModifier [0]);
2362 Assert.IsNull (ctor, "#B2");
2364 ctor = greenType.GetConstructor (flags, null,
2365 new Type [] { typeof (string), typeof (string) },
2366 new ParameterModifier [0]);
2367 Assert.IsNull (ctor, "#B3");
2369 ctor = greenType.GetConstructor (flags, null,
2370 new Type [] { typeof (int) },
2371 new ParameterModifier [0]);
2372 Assert.IsNull (ctor, "#B4");
2374 ctor = greenType.GetConstructor (flags, null,
2375 new Type [] { typeof (int), typeof (bool) },
2376 new ParameterModifier [0]);
2377 Assert.IsNull (ctor, "#B5");
2379 ctor = greenType.GetConstructor (flags, null,
2380 new Type [] { typeof (string), typeof (int) },
2381 new ParameterModifier [0]);
2382 Assert.IsNull (ctor, "#B6");
2384 ctor = greenType.GetConstructor (flags, null,
2386 new ParameterModifier [0]);
2387 Assert.IsNotNull (ctor, "#B7a");
2388 Assert.IsTrue (ctor.IsPublic, "#B7b");
2389 Assert.IsFalse (ctor.IsStatic, "#B7c");
2390 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B7d");
2391 Assert.IsFalse (ctor is ConstructorBuilder, "#B7e");
2393 ctor = redType.GetConstructor (flags, null,
2394 new Type [] { typeof (int), typeof (int) },
2395 new ParameterModifier [0]);
2396 Assert.IsNull (ctor, "#B8");
2398 ctor = redType.GetConstructor (flags, null,
2399 new Type [] { typeof (string) },
2400 new ParameterModifier [0]);
2401 Assert.IsNull (ctor, "#B9");
2403 ctor = redType.GetConstructor (flags, null,
2404 new Type [] { typeof (string), typeof (string) },
2405 new ParameterModifier [0]);
2406 Assert.IsNull (ctor, "#B10");
2408 ctor = redType.GetConstructor (flags, null,
2409 new Type [] { typeof (int) },
2410 new ParameterModifier [0]);
2411 Assert.IsNull (ctor, "#B11");
2413 ctor = redType.GetConstructor (flags, null,
2414 new Type [] { typeof (int), typeof (bool) },
2415 new ParameterModifier [0]);
2416 Assert.IsNotNull (ctor, "#B12a");
2417 Assert.IsTrue (ctor.IsPublic, "#B12b");
2418 Assert.IsFalse (ctor.IsStatic, "#B12c");
2419 Assert.AreEqual (2, ctor.GetParameters ().Length, "#B12d");
2420 Assert.IsFalse (ctor is ConstructorBuilder, "#B12e");
2422 ctor = redType.GetConstructor (flags, null,
2423 new Type [] { typeof (string), typeof (int) },
2424 new ParameterModifier [0]);
2425 Assert.IsNull (ctor, "#B13");
2427 ctor = redType.GetConstructor (flags, null,
2429 new ParameterModifier [0]);
2430 Assert.IsNull (ctor, "#B14");
2432 flags = BindingFlags.Static | BindingFlags.Public;
2434 ctor = greenType.GetConstructor (flags, null,
2435 new Type [] { typeof (int), typeof (int) },
2436 new ParameterModifier [0]);
2437 Assert.IsNull (ctor, "#C1");
2439 ctor = greenType.GetConstructor (flags, null,
2440 new Type [] { typeof (string) },
2441 new ParameterModifier [0]);
2442 Assert.IsNull (ctor, "#C2");
2444 ctor = greenType.GetConstructor (flags, null,
2445 new Type [] { typeof (string), typeof (string) },
2446 new ParameterModifier [0]);
2447 Assert.IsNull (ctor, "#C3");
2449 ctor = greenType.GetConstructor (flags, null,
2450 new Type [] { typeof (int) },
2451 new ParameterModifier [0]);
2452 Assert.IsNull (ctor, "#C4");
2454 ctor = greenType.GetConstructor (flags, null,
2455 new Type [] { typeof (int), typeof (bool) },
2456 new ParameterModifier [0]);
2457 Assert.IsNull (ctor, "#C5");
2459 ctor = greenType.GetConstructor (flags, null,
2460 new Type [] { typeof (string), typeof (int) },
2461 new ParameterModifier [0]);
2462 Assert.IsNull (ctor, "#C6");
2464 ctor = greenType.GetConstructor (flags, null,
2466 new ParameterModifier [0]);
2467 Assert.IsNull (ctor, "#C7");
2469 ctor = redType.GetConstructor (flags, null,
2470 new Type [] { typeof (int), typeof (int) },
2471 new ParameterModifier [0]);
2472 Assert.IsNull (ctor, "#C8");
2474 ctor = redType.GetConstructor (flags, null,
2475 new Type [] { typeof (string) },
2476 new ParameterModifier [0]);
2477 Assert.IsNull (ctor, "#C9");
2479 ctor = redType.GetConstructor (flags, null,
2480 new Type [] { typeof (string), typeof (string) },
2481 new ParameterModifier [0]);
2482 Assert.IsNull (ctor, "#C10");
2484 ctor = redType.GetConstructor (flags, null,
2485 new Type [] { typeof (int) },
2486 new ParameterModifier [0]);
2487 Assert.IsNull (ctor, "#C11a");
2489 ctor = redType.GetConstructor (flags, null,
2490 new Type [] { typeof (int), typeof (bool) },
2491 new ParameterModifier [0]);
2492 Assert.IsNull (ctor, "#C12");
2494 ctor = redType.GetConstructor (flags, null,
2495 new Type [] { typeof (string), typeof (int) },
2496 new ParameterModifier [0]);
2497 Assert.IsNull (ctor, "#C13");
2499 ctor = redType.GetConstructor (flags, null,
2501 new ParameterModifier [0]);
2502 Assert.IsNull (ctor, "#C14");
2504 flags = BindingFlags.Static | BindingFlags.NonPublic;
2506 ctor = greenType.GetConstructor (flags, null,
2507 new Type [] { typeof (int), typeof (int) },
2508 new ParameterModifier [0]);
2509 Assert.IsNull (ctor, "#D1");
2511 ctor = greenType.GetConstructor (flags, null,
2512 new Type [] { typeof (string) },
2513 new ParameterModifier [0]);
2514 Assert.IsNull (ctor, "#D2");
2516 ctor = greenType.GetConstructor (flags, null,
2517 new Type [] { typeof (string), typeof (string) },
2518 new ParameterModifier [0]);
2519 Assert.IsNull (ctor, "#D3");
2521 ctor = greenType.GetConstructor (flags, null,
2522 new Type [] { typeof (int) },
2523 new ParameterModifier [0]);
2524 Assert.IsNull (ctor, "#D4");
2526 ctor = greenType.GetConstructor (flags, null,
2527 new Type [] { typeof (int), typeof (bool) },
2528 new ParameterModifier [0]);
2529 Assert.IsNull (ctor, "#D5");
2531 ctor = greenType.GetConstructor (flags, null,
2532 new Type [] { typeof (string), typeof (int) },
2533 new ParameterModifier [0]);
2534 Assert.IsNull (ctor, "#D6");
2536 ctor = greenType.GetConstructor (flags, null,
2538 new ParameterModifier [0]);
2539 Assert.IsNull (ctor, "#D7");
2541 ctor = redType.GetConstructor (flags, null,
2542 new Type [] { typeof (int), typeof (int) },
2543 new ParameterModifier [0]);
2544 Assert.IsNull (ctor, "#D8");
2546 ctor = redType.GetConstructor (flags, null,
2547 new Type [] { typeof (string) },
2548 new ParameterModifier [0]);
2549 Assert.IsNull (ctor, "#D9");
2551 ctor = redType.GetConstructor (flags, null,
2552 new Type [] { typeof (string), typeof (string) },
2553 new ParameterModifier [0]);
2554 Assert.IsNull (ctor, "#D10");
2556 ctor = redType.GetConstructor (flags, null,
2557 new Type [] { typeof (int) },
2558 new ParameterModifier [0]);
2559 Assert.IsNull (ctor, "#D11");
2561 ctor = redType.GetConstructor (flags, null,
2562 new Type [] { typeof (int), typeof (bool) },
2563 new ParameterModifier [0]);
2564 Assert.IsNull (ctor, "#D12");
2566 ctor = redType.GetConstructor (flags, null,
2567 new Type [] { typeof (string), typeof (int) },
2568 new ParameterModifier [0]);
2569 Assert.IsNull (ctor, "#D13");
2571 ctor = redType.GetConstructor (flags, null,
2573 new ParameterModifier [0]);
2574 Assert.IsNotNull (ctor, "#D14a");
2575 Assert.IsTrue (ctor.IsPrivate, "#D14b");
2576 Assert.IsTrue (ctor.IsStatic, "#B14c");
2577 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B14d");
2578 Assert.IsFalse (ctor is ConstructorBuilder, "#B14e");
2580 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2581 BindingFlags.FlattenHierarchy;
2583 ctor = greenType.GetConstructor (flags, null,
2584 new Type [] { typeof (int), typeof (int) },
2585 new ParameterModifier [0]);
2586 Assert.IsNull (ctor, "#E1");
2588 ctor = greenType.GetConstructor (flags, null,
2589 new Type [] { typeof (string) },
2590 new ParameterModifier [0]);
2591 Assert.IsNull (ctor, "#E2");
2593 ctor = greenType.GetConstructor (flags, null,
2594 new Type [] { typeof (string), typeof (string) },
2595 new ParameterModifier [0]);
2596 Assert.IsNull (ctor, "#E3");
2598 ctor = greenType.GetConstructor (flags, null,
2599 new Type [] { typeof (int) },
2600 new ParameterModifier [0]);
2601 Assert.IsNull (ctor, "#E4");
2603 ctor = greenType.GetConstructor (flags, null,
2604 new Type [] { typeof (int), typeof (bool) },
2605 new ParameterModifier [0]);
2606 Assert.IsNull (ctor, "#E5");
2608 ctor = greenType.GetConstructor (flags, null,
2609 new Type [] { typeof (string), typeof (int) },
2610 new ParameterModifier [0]);
2611 Assert.IsNull (ctor, "#E6");
2613 ctor = greenType.GetConstructor (flags, null,
2615 new ParameterModifier [0]);
2616 Assert.IsNull (ctor, "#E7");
2618 ctor = redType.GetConstructor (flags, null,
2619 new Type [] { typeof (int), typeof (int) },
2620 new ParameterModifier [0]);
2621 Assert.IsNotNull (ctor, "#E8a");
2622 Assert.IsTrue (ctor.IsPrivate, "#E8b");
2623 Assert.IsFalse (ctor.IsStatic, "#E8c");
2624 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E8d");
2625 Assert.IsFalse (ctor is ConstructorBuilder, "#E8e");
2627 ctor = redType.GetConstructor (flags, null,
2628 new Type [] { typeof (string) },
2629 new ParameterModifier [0]);
2630 Assert.IsNotNull (ctor, "#E9a");
2631 Assert.IsTrue (ctor.IsFamily, "#E9b");
2632 Assert.IsFalse (ctor.IsStatic, "#E9c");
2633 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E9d");
2634 Assert.IsFalse (ctor is ConstructorBuilder, "#E9e");
2636 ctor = redType.GetConstructor (flags, null,
2637 new Type [] { typeof (string), typeof (string) },
2638 new ParameterModifier [0]);
2639 Assert.IsNotNull (ctor, "#E10a");
2640 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#E10b");
2641 Assert.IsFalse (ctor.IsStatic, "#E10c");
2642 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E10d");
2643 Assert.IsFalse (ctor is ConstructorBuilder, "#E10e");
2645 ctor = redType.GetConstructor (flags, null,
2646 new Type [] { typeof (int) },
2647 new ParameterModifier [0]);
2648 Assert.IsNotNull (ctor, "#E11a");
2649 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#E11b");
2650 Assert.IsFalse (ctor.IsStatic, "#E11c");
2651 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E11d");
2652 Assert.IsFalse (ctor is ConstructorBuilder, "#E11e");
2654 ctor = redType.GetConstructor (flags, null,
2655 new Type [] { typeof (int), typeof (bool) },
2656 new ParameterModifier [0]);
2657 Assert.IsNull (ctor, "#E12");
2659 ctor = redType.GetConstructor (flags, null,
2660 new Type [] { typeof (string), typeof (int) },
2661 new ParameterModifier [0]);
2662 Assert.IsNotNull (ctor, "#E13a");
2663 Assert.IsTrue (ctor.IsAssembly, "#E13b");
2664 Assert.IsFalse (ctor.IsStatic, "#E13c");
2665 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E13d");
2666 Assert.IsFalse (ctor is ConstructorBuilder, "#E13e");
2668 ctor = redType.GetConstructor (flags, null,
2670 new ParameterModifier [0]);
2671 Assert.IsNull (ctor, "#E14");
2673 flags = BindingFlags.Instance | BindingFlags.Public |
2674 BindingFlags.FlattenHierarchy;
2676 ctor = greenType.GetConstructor (flags, null,
2677 new Type [] { typeof (int), typeof (int) },
2678 new ParameterModifier [0]);
2679 Assert.IsNull (ctor, "#F1");
2681 ctor = greenType.GetConstructor (flags, null,
2682 new Type [] { typeof (string) },
2683 new ParameterModifier [0]);
2684 Assert.IsNull (ctor, "#F2");
2686 ctor = greenType.GetConstructor (flags, null,
2687 new Type [] { typeof (string), typeof (string) },
2688 new ParameterModifier [0]);
2689 Assert.IsNull (ctor, "#F3");
2691 ctor = greenType.GetConstructor (flags, null,
2692 new Type [] { typeof (int) },
2693 new ParameterModifier [0]);
2694 Assert.IsNull (ctor, "#F4");
2696 ctor = greenType.GetConstructor (flags, null,
2697 new Type [] { typeof (int), typeof (bool) },
2698 new ParameterModifier [0]);
2699 Assert.IsNull (ctor, "#F5");
2701 ctor = greenType.GetConstructor (flags, null,
2702 new Type [] { typeof (string), typeof (int) },
2703 new ParameterModifier [0]);
2704 Assert.IsNull (ctor, "#F6");
2706 ctor = greenType.GetConstructor (flags, null,
2708 new ParameterModifier [0]);
2709 Assert.IsNotNull (ctor, "#F7a");
2710 Assert.IsTrue (ctor.IsPublic, "#F7b");
2711 Assert.IsFalse (ctor.IsStatic, "#F7c");
2712 Assert.AreEqual (0, ctor.GetParameters ().Length, "#F7d");
2713 Assert.IsFalse (ctor is ConstructorBuilder, "#F7e");
2715 ctor = redType.GetConstructor (flags, null,
2716 new Type [] { typeof (int), typeof (int) },
2717 new ParameterModifier [0]);
2718 Assert.IsNull (ctor, "#F8");
2720 ctor = redType.GetConstructor (flags, null,
2721 new Type [] { typeof (string) },
2722 new ParameterModifier [0]);
2723 Assert.IsNull (ctor, "#F9");
2725 ctor = redType.GetConstructor (flags, null,
2726 new Type [] { typeof (string), typeof (string) },
2727 new ParameterModifier [0]);
2728 Assert.IsNull (ctor, "#F10");
2730 ctor = redType.GetConstructor (flags, null,
2731 new Type [] { typeof (int) },
2732 new ParameterModifier [0]);
2733 Assert.IsNull (ctor, "#F11");
2735 ctor = redType.GetConstructor (flags, null,
2736 new Type [] { typeof (int), typeof (bool) },
2737 new ParameterModifier [0]);
2738 Assert.IsNotNull (ctor, "#F12a");
2739 Assert.IsTrue (ctor.IsPublic, "#F12b");
2740 Assert.IsFalse (ctor.IsStatic, "#F12c");
2741 Assert.AreEqual (2, ctor.GetParameters ().Length, "#F12d");
2742 Assert.IsFalse (ctor is ConstructorBuilder, "#F12e");
2744 ctor = redType.GetConstructor (flags, null,
2745 new Type [] { typeof (string), typeof (int) },
2746 new ParameterModifier [0]);
2747 Assert.IsNull (ctor, "#F13");
2749 ctor = redType.GetConstructor (flags, null,
2751 new ParameterModifier [0]);
2752 Assert.IsNull (ctor, "#F14");
2754 flags = BindingFlags.Static | BindingFlags.Public |
2755 BindingFlags.FlattenHierarchy;
2757 ctor = greenType.GetConstructor (flags, null,
2758 new Type [] { typeof (int), typeof (int) },
2759 new ParameterModifier [0]);
2760 Assert.IsNull (ctor, "#G1");
2762 ctor = greenType.GetConstructor (flags, null,
2763 new Type [] { typeof (string) },
2764 new ParameterModifier [0]);
2765 Assert.IsNull (ctor, "#G2");
2767 ctor = greenType.GetConstructor (flags, null,
2768 new Type [] { typeof (string), typeof (string) },
2769 new ParameterModifier [0]);
2770 Assert.IsNull (ctor, "#G3");
2772 ctor = greenType.GetConstructor (flags, null,
2773 new Type [] { typeof (int) },
2774 new ParameterModifier [0]);
2775 Assert.IsNull (ctor, "#G4");
2777 ctor = greenType.GetConstructor (flags, null,
2778 new Type [] { typeof (int), typeof (bool) },
2779 new ParameterModifier [0]);
2780 Assert.IsNull (ctor, "#G5");
2782 ctor = greenType.GetConstructor (flags, null,
2783 new Type [] { typeof (string), typeof (int) },
2784 new ParameterModifier [0]);
2785 Assert.IsNull (ctor, "#G6");
2787 ctor = greenType.GetConstructor (flags, null,
2789 new ParameterModifier [0]);
2790 Assert.IsNull (ctor, "#G7");
2792 ctor = redType.GetConstructor (flags, null,
2793 new Type [] { typeof (int), typeof (int) },
2794 new ParameterModifier [0]);
2795 Assert.IsNull (ctor, "#G8");
2797 ctor = redType.GetConstructor (flags, null,
2798 new Type [] { typeof (string) },
2799 new ParameterModifier [0]);
2800 Assert.IsNull (ctor, "#G9");
2802 ctor = redType.GetConstructor (flags, null,
2803 new Type [] { typeof (string), typeof (string) },
2804 new ParameterModifier [0]);
2805 Assert.IsNull (ctor, "#G10");
2807 ctor = redType.GetConstructor (flags, null,
2808 new Type [] { typeof (int) },
2809 new ParameterModifier [0]);
2810 Assert.IsNull (ctor, "#G11");
2812 ctor = redType.GetConstructor (flags, null,
2813 new Type [] { typeof (int), typeof (bool) },
2814 new ParameterModifier [0]);
2815 Assert.IsNull (ctor, "#G12");
2817 ctor = redType.GetConstructor (flags, null,
2818 new Type [] { typeof (string), typeof (int) },
2819 new ParameterModifier [0]);
2820 Assert.IsNull (ctor, "#G13");
2822 ctor = redType.GetConstructor (flags, null,
2824 new ParameterModifier [0]);
2825 Assert.IsNull (ctor, "#G14");
2827 flags = BindingFlags.Static | BindingFlags.NonPublic |
2828 BindingFlags.FlattenHierarchy;
2830 ctor = greenType.GetConstructor (flags, null,
2831 new Type [] { typeof (int), typeof (int) },
2832 new ParameterModifier [0]);
2833 Assert.IsNull (ctor, "#H1");
2835 ctor = greenType.GetConstructor (flags, null,
2836 new Type [] { typeof (string) },
2837 new ParameterModifier [0]);
2838 Assert.IsNull (ctor, "#H2");
2840 ctor = greenType.GetConstructor (flags, null,
2841 new Type [] { typeof (string), typeof (string) },
2842 new ParameterModifier [0]);
2843 Assert.IsNull (ctor, "#H3");
2845 ctor = greenType.GetConstructor (flags, null,
2846 new Type [] { typeof (int) },
2847 new ParameterModifier [0]);
2848 Assert.IsNull (ctor, "#H4");
2850 ctor = greenType.GetConstructor (flags, null,
2851 new Type [] { typeof (int), typeof (bool) },
2852 new ParameterModifier [0]);
2853 Assert.IsNull (ctor, "#H5");
2855 ctor = greenType.GetConstructor (flags, null,
2856 new Type [] { typeof (string), typeof (int) },
2857 new ParameterModifier [0]);
2858 Assert.IsNull (ctor, "#H6");
2860 ctor = greenType.GetConstructor (flags, null,
2862 new ParameterModifier [0]);
2863 Assert.IsNull (ctor, "#H7");
2865 ctor = redType.GetConstructor (flags, null,
2866 new Type [] { typeof (int), typeof (int) },
2867 new ParameterModifier [0]);
2868 Assert.IsNull (ctor, "#H8");
2870 ctor = redType.GetConstructor (flags, null,
2871 new Type [] { typeof (string) },
2872 new ParameterModifier [0]);
2873 Assert.IsNull (ctor, "#H9");
2875 ctor = redType.GetConstructor (flags, null,
2876 new Type [] { typeof (string), typeof (string) },
2877 new ParameterModifier [0]);
2878 Assert.IsNull (ctor, "#H10");
2880 ctor = redType.GetConstructor (flags, null,
2881 new Type [] { typeof (int) },
2882 new ParameterModifier [0]);
2883 Assert.IsNull (ctor, "#H11");
2885 ctor = redType.GetConstructor (flags, null,
2886 new Type [] { typeof (int), typeof (bool) },
2887 new ParameterModifier [0]);
2888 Assert.IsNull (ctor, "#H12");
2890 ctor = redType.GetConstructor (flags, null,
2891 new Type [] { typeof (string), typeof (int) },
2892 new ParameterModifier [0]);
2893 Assert.IsNull (ctor, "#H13");
2895 ctor = redType.GetConstructor (flags, null,
2897 new ParameterModifier [0]);
2898 Assert.IsNotNull (ctor, "#H14");
2899 Assert.IsTrue (ctor.IsPrivate, "#H14b");
2900 Assert.IsTrue (ctor.IsStatic, "#H14c");
2901 Assert.AreEqual (0, ctor.GetParameters ().Length, "#H14d");
2902 Assert.IsFalse (ctor is ConstructorBuilder, "#H14e");
2904 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2905 BindingFlags.DeclaredOnly;
2907 ctor = greenType.GetConstructor (flags, null,
2908 new Type [] { typeof (int), typeof (int) },
2909 new ParameterModifier [0]);
2910 Assert.IsNull (ctor, "#I1");
2912 ctor = greenType.GetConstructor (flags, null,
2913 new Type [] { typeof (string) },
2914 new ParameterModifier [0]);
2915 Assert.IsNull (ctor, "#I2");
2917 ctor = greenType.GetConstructor (flags, null,
2918 new Type [] { typeof (string), typeof (string) },
2919 new ParameterModifier [0]);
2920 Assert.IsNull (ctor, "#I3");
2922 ctor = greenType.GetConstructor (flags, null,
2923 new Type [] { typeof (int) },
2924 new ParameterModifier [0]);
2925 Assert.IsNull (ctor, "#I4");
2927 ctor = greenType.GetConstructor (flags, null,
2928 new Type [] { typeof (int), typeof (bool) },
2929 new ParameterModifier [0]);
2930 Assert.IsNull (ctor, "#I5");
2932 ctor = greenType.GetConstructor (flags, null,
2933 new Type [] { typeof (string), typeof (int) },
2934 new ParameterModifier [0]);
2935 Assert.IsNull (ctor, "#I6");
2937 ctor = greenType.GetConstructor (flags, null,
2939 new ParameterModifier [0]);
2940 Assert.IsNull (ctor, "#I7");
2942 ctor = redType.GetConstructor (flags, null,
2943 new Type [] { typeof (int), typeof (int) },
2944 new ParameterModifier [0]);
2945 Assert.IsNotNull (ctor, "#I8a");
2946 Assert.IsTrue (ctor.IsPrivate, "#I8b");
2947 Assert.IsFalse (ctor.IsStatic, "#I8c");
2948 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I8d");
2949 Assert.IsFalse (ctor is ConstructorBuilder, "#I8e");
2951 ctor = redType.GetConstructor (flags, null,
2952 new Type [] { typeof (string) },
2953 new ParameterModifier [0]);
2954 Assert.IsNotNull (ctor, "#I9a");
2955 Assert.IsTrue (ctor.IsFamily, "#I9b");
2956 Assert.IsFalse (ctor.IsStatic, "#I9c");
2957 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I9d");
2958 Assert.IsFalse (ctor is ConstructorBuilder, "#I9e");
2960 ctor = redType.GetConstructor (flags, null,
2961 new Type [] { typeof (string), typeof (string) },
2962 new ParameterModifier [0]);
2963 Assert.IsNotNull (ctor, "#I10a");
2964 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#I10b");
2965 Assert.IsFalse (ctor.IsStatic, "#I10c");
2966 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I10d");
2967 Assert.IsFalse (ctor is ConstructorBuilder, "#I10e");
2969 ctor = redType.GetConstructor (flags, null,
2970 new Type [] { typeof (int) },
2971 new ParameterModifier [0]);
2972 Assert.IsNotNull (ctor, "#I11a");
2973 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#I11b");
2974 Assert.IsFalse (ctor.IsStatic, "#I11c");
2975 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I11d");
2976 Assert.IsFalse (ctor is ConstructorBuilder, "#I11e");
2978 ctor = redType.GetConstructor (flags, null,
2979 new Type [] { typeof (int), typeof (bool) },
2980 new ParameterModifier [0]);
2981 Assert.IsNull (ctor, "#I12");
2983 ctor = redType.GetConstructor (flags, null,
2984 new Type [] { typeof (string), typeof (int) },
2985 new ParameterModifier [0]);
2986 Assert.IsNotNull (ctor, "#I13a");
2987 Assert.IsTrue (ctor.IsAssembly, "#I13b");
2988 Assert.IsFalse (ctor.IsStatic, "#I13c");
2989 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I13d");
2990 Assert.IsFalse (ctor is ConstructorBuilder, "#I13e");
2992 ctor = redType.GetConstructor (flags, null,
2994 new ParameterModifier [0]);
2995 Assert.IsNull (ctor, "#I14");
2997 flags = BindingFlags.Instance | BindingFlags.Public |
2998 BindingFlags.DeclaredOnly;
3000 ctor = greenType.GetConstructor (flags, null,
3001 new Type [] { typeof (int), typeof (int) },
3002 new ParameterModifier [0]);
3003 Assert.IsNull (ctor, "#J1");
3005 ctor = greenType.GetConstructor (flags, null,
3006 new Type [] { typeof (string) },
3007 new ParameterModifier [0]);
3008 Assert.IsNull (ctor, "#J2");
3010 ctor = greenType.GetConstructor (flags, null,
3011 new Type [] { typeof (string), typeof (string) },
3012 new ParameterModifier [0]);
3013 Assert.IsNull (ctor, "#J3");
3015 ctor = greenType.GetConstructor (flags, null,
3016 new Type [] { typeof (int) },
3017 new ParameterModifier [0]);
3018 Assert.IsNull (ctor, "#J4");
3020 ctor = greenType.GetConstructor (flags, null,
3021 new Type [] { typeof (int), typeof (bool) },
3022 new ParameterModifier [0]);
3023 Assert.IsNull (ctor, "#J5");
3025 ctor = greenType.GetConstructor (flags, null,
3026 new Type [] { typeof (string), typeof (int) },
3027 new ParameterModifier [0]);
3028 Assert.IsNull (ctor, "#J6");
3030 ctor = greenType.GetConstructor (flags, null,
3032 new ParameterModifier [0]);
3033 Assert.IsNotNull (ctor, "#J7a");
3034 Assert.IsTrue (ctor.IsPublic, "#J7b");
3035 Assert.IsFalse (ctor.IsStatic, "#J7c");
3036 Assert.AreEqual (0, ctor.GetParameters ().Length, "#J7d");
3037 Assert.IsFalse (ctor is ConstructorBuilder, "#J7e");
3039 ctor = redType.GetConstructor (flags, null,
3040 new Type [] { typeof (int), typeof (int) },
3041 new ParameterModifier [0]);
3042 Assert.IsNull (ctor, "#J8");
3044 ctor = redType.GetConstructor (flags, null,
3045 new Type [] { typeof (string) },
3046 new ParameterModifier [0]);
3047 Assert.IsNull (ctor, "#J9");
3049 ctor = redType.GetConstructor (flags, null,
3050 new Type [] { typeof (string), typeof (string) },
3051 new ParameterModifier [0]);
3052 Assert.IsNull (ctor, "#J10");
3054 ctor = redType.GetConstructor (flags, null,
3055 new Type [] { typeof (int) },
3056 new ParameterModifier [0]);
3057 Assert.IsNull (ctor, "#J11");
3059 ctor = redType.GetConstructor (flags, null,
3060 new Type [] { typeof (int), typeof (bool) },
3061 new ParameterModifier [0]);
3062 Assert.IsNotNull (ctor, "#J12a");
3063 Assert.IsTrue (ctor.IsPublic, "#J12b");
3064 Assert.IsFalse (ctor.IsStatic, "#J12c");
3065 Assert.AreEqual (2, ctor.GetParameters ().Length, "#J12d");
3066 Assert.IsFalse (ctor is ConstructorBuilder, "#J12e");
3068 ctor = redType.GetConstructor (flags, null,
3069 new Type [] { typeof (string), typeof (int) },
3070 new ParameterModifier [0]);
3071 Assert.IsNull (ctor, "#J13");
3073 ctor = redType.GetConstructor (flags, null,
3075 new ParameterModifier [0]);
3076 Assert.IsNull (ctor, "#J14");
3078 flags = BindingFlags.Static | BindingFlags.Public |
3079 BindingFlags.DeclaredOnly;
3081 ctor = greenType.GetConstructor (flags, null,
3082 new Type [] { typeof (int), typeof (int) },
3083 new ParameterModifier [0]);
3084 Assert.IsNull (ctor, "#K1");
3086 ctor = greenType.GetConstructor (flags, null,
3087 new Type [] { typeof (string) },
3088 new ParameterModifier [0]);
3089 Assert.IsNull (ctor, "#K2");
3091 ctor = greenType.GetConstructor (flags, null,
3092 new Type [] { typeof (string), typeof (string) },
3093 new ParameterModifier [0]);
3094 Assert.IsNull (ctor, "#K3");
3096 ctor = greenType.GetConstructor (flags, null,
3097 new Type [] { typeof (int) },
3098 new ParameterModifier [0]);
3099 Assert.IsNull (ctor, "#K4");
3101 ctor = greenType.GetConstructor (flags, null,
3102 new Type [] { typeof (int), typeof (bool) },
3103 new ParameterModifier [0]);
3104 Assert.IsNull (ctor, "#K5");
3106 ctor = greenType.GetConstructor (flags, null,
3107 new Type [] { typeof (string), typeof (int) },
3108 new ParameterModifier [0]);
3109 Assert.IsNull (ctor, "#K6");
3111 ctor = greenType.GetConstructor (flags, null,
3113 new ParameterModifier [0]);
3114 Assert.IsNull (ctor, "#K7");
3116 ctor = redType.GetConstructor (flags, null,
3117 new Type [] { typeof (int), typeof (int) },
3118 new ParameterModifier [0]);
3119 Assert.IsNull (ctor, "#K8");
3121 ctor = redType.GetConstructor (flags, null,
3122 new Type [] { typeof (string) },
3123 new ParameterModifier [0]);
3124 Assert.IsNull (ctor, "#K9");
3126 ctor = redType.GetConstructor (flags, null,
3127 new Type [] { typeof (string), typeof (string) },
3128 new ParameterModifier [0]);
3129 Assert.IsNull (ctor, "#K10");
3131 ctor = redType.GetConstructor (flags, null,
3132 new Type [] { typeof (int) },
3133 new ParameterModifier [0]);
3134 Assert.IsNull (ctor, "#K11");
3136 ctor = redType.GetConstructor (flags, null,
3137 new Type [] { typeof (int), typeof (bool) },
3138 new ParameterModifier [0]);
3139 Assert.IsNull (ctor, "#K12");
3141 ctor = redType.GetConstructor (flags, null,
3142 new Type [] { typeof (string), typeof (int) },
3143 new ParameterModifier [0]);
3144 Assert.IsNull (ctor, "#K13");
3146 ctor = redType.GetConstructor (flags, null,
3148 new ParameterModifier [0]);
3149 Assert.IsNull (ctor, "#K14");
3151 flags = BindingFlags.Static | BindingFlags.NonPublic |
3152 BindingFlags.DeclaredOnly;
3154 ctor = greenType.GetConstructor (flags, null,
3155 new Type [] { typeof (int), typeof (int) },
3156 new ParameterModifier [0]);
3157 Assert.IsNull (ctor, "#L1");
3159 ctor = greenType.GetConstructor (flags, null,
3160 new Type [] { typeof (string) },
3161 new ParameterModifier [0]);
3162 Assert.IsNull (ctor, "#L2");
3164 ctor = greenType.GetConstructor (flags, null,
3165 new Type [] { typeof (string), typeof (string) },
3166 new ParameterModifier [0]);
3167 Assert.IsNull (ctor, "#L3");
3169 ctor = greenType.GetConstructor (flags, null,
3170 new Type [] { typeof (int) },
3171 new ParameterModifier [0]);
3172 Assert.IsNull (ctor, "#L4");
3174 ctor = greenType.GetConstructor (flags, null,
3175 new Type [] { typeof (int), typeof (bool) },
3176 new ParameterModifier [0]);
3177 Assert.IsNull (ctor, "#L5");
3179 ctor = greenType.GetConstructor (flags, null,
3180 new Type [] { typeof (string), typeof (int) },
3181 new ParameterModifier [0]);
3182 Assert.IsNull (ctor, "#L6");
3184 ctor = greenType.GetConstructor (flags, null,
3186 new ParameterModifier [0]);
3187 Assert.IsNull (ctor, "#L7");
3189 ctor = redType.GetConstructor (flags, null,
3190 new Type [] { typeof (int), typeof (int) },
3191 new ParameterModifier [0]);
3192 Assert.IsNull (ctor, "#L8");
3194 ctor = redType.GetConstructor (flags, null,
3195 new Type [] { typeof (string) },
3196 new ParameterModifier [0]);
3197 Assert.IsNull (ctor, "#L9");
3199 ctor = redType.GetConstructor (flags, null,
3200 new Type [] { typeof (string), typeof (string) },
3201 new ParameterModifier [0]);
3202 Assert.IsNull (ctor, "#L10");
3204 ctor = redType.GetConstructor (flags, null,
3205 new Type [] { typeof (int) },
3206 new ParameterModifier [0]);
3207 Assert.IsNull (ctor, "#L11");
3209 ctor = redType.GetConstructor (flags, null,
3210 new Type [] { typeof (int), typeof (bool) },
3211 new ParameterModifier [0]);
3212 Assert.IsNull (ctor, "#L12");
3214 ctor = redType.GetConstructor (flags, null,
3215 new Type [] { typeof (string), typeof (int) },
3216 new ParameterModifier [0]);
3217 Assert.IsNull (ctor, "#L13");
3219 ctor = redType.GetConstructor (flags, null,
3221 new ParameterModifier [0]);
3222 Assert.IsNotNull (ctor, "#L14a");
3223 Assert.IsTrue (ctor.IsPrivate, "#L14b");
3224 Assert.IsTrue (ctor.IsStatic, "#L14c");
3225 Assert.AreEqual (0, ctor.GetParameters ().Length, "#L14d");
3226 Assert.IsFalse (ctor is ConstructorBuilder, "#L14e");
3228 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3229 BindingFlags.Public;
3231 ctor = greenType.GetConstructor (flags, null,
3232 new Type [] { typeof (int), typeof (int) },
3233 new ParameterModifier [0]);
3234 Assert.IsNull (ctor, "#M1");
3236 ctor = greenType.GetConstructor (flags, null,
3237 new Type [] { typeof (string) },
3238 new ParameterModifier [0]);
3239 Assert.IsNull (ctor, "#M2");
3241 ctor = greenType.GetConstructor (flags, null,
3242 new Type [] { typeof (string), typeof (string) },
3243 new ParameterModifier [0]);
3244 Assert.IsNull (ctor, "#M3");
3246 ctor = greenType.GetConstructor (flags, null,
3247 new Type [] { typeof (int) },
3248 new ParameterModifier [0]);
3249 Assert.IsNull (ctor, "#M4");
3251 ctor = greenType.GetConstructor (flags, null,
3252 new Type [] { typeof (int), typeof (bool) },
3253 new ParameterModifier [0]);
3254 Assert.IsNull (ctor, "#M5");
3256 ctor = greenType.GetConstructor (flags, null,
3257 new Type [] { typeof (string), typeof (int) },
3258 new ParameterModifier [0]);
3259 Assert.IsNull (ctor, "#M6");
3261 ctor = greenType.GetConstructor (flags, null,
3263 new ParameterModifier [0]);
3264 Assert.IsNotNull (ctor, "#M7a");
3265 Assert.IsTrue (ctor.IsPublic, "#M7b");
3266 Assert.IsFalse (ctor.IsStatic, "#M7c");
3267 Assert.AreEqual (0, ctor.GetParameters ().Length, "#M7d");
3268 Assert.IsFalse (ctor is ConstructorBuilder, "#M7e");
3270 ctor = redType.GetConstructor (flags, null,
3271 new Type [] { typeof (int), typeof (int) },
3272 new ParameterModifier [0]);
3273 Assert.IsNotNull (ctor, "#M8a");
3274 Assert.IsTrue (ctor.IsPrivate, "#M8b");
3275 Assert.IsFalse (ctor.IsStatic, "#M8c");
3276 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M8d");
3277 Assert.IsFalse (ctor is ConstructorBuilder, "#M8e");
3279 ctor = redType.GetConstructor (flags, null,
3280 new Type [] { typeof (string) },
3281 new ParameterModifier [0]);
3282 Assert.IsNotNull (ctor, "#M9a");
3283 Assert.IsTrue (ctor.IsFamily, "#M9b");
3284 Assert.IsFalse (ctor.IsStatic, "#M9c");
3285 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M9d");
3286 Assert.IsFalse (ctor is ConstructorBuilder, "#M9e");
3288 ctor = redType.GetConstructor (flags, null,
3289 new Type [] { typeof (string), typeof (string) },
3290 new ParameterModifier [0]);
3291 Assert.IsNotNull (ctor, "#M10a");
3292 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#M10b");
3293 Assert.IsFalse (ctor.IsStatic, "#M10c");
3294 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M10d");
3295 Assert.IsFalse (ctor is ConstructorBuilder, "#M10e");
3297 ctor = redType.GetConstructor (flags, null,
3298 new Type [] { typeof (int) },
3299 new ParameterModifier [0]);
3300 Assert.IsNotNull (ctor, "#M11a");
3301 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#M11b");
3302 Assert.IsFalse (ctor.IsStatic, "#M11c");
3303 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M11d");
3304 Assert.IsFalse (ctor is ConstructorBuilder, "#M11e");
3306 ctor = redType.GetConstructor (flags, null,
3307 new Type [] { typeof (int), typeof (bool) },
3308 new ParameterModifier [0]);
3309 Assert.IsNotNull (ctor, "#M12a");
3310 Assert.IsTrue (ctor.IsPublic, "#M12b");
3311 Assert.IsFalse (ctor.IsStatic, "#M12c");
3312 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M12d");
3313 Assert.IsFalse (ctor is ConstructorBuilder, "#M12e");
3315 ctor = redType.GetConstructor (flags, null,
3316 new Type [] { typeof (string), typeof (int) },
3317 new ParameterModifier [0]);
3318 Assert.IsNotNull (ctor, "#M13a");
3319 Assert.IsTrue (ctor.IsAssembly, "#M13b");
3320 Assert.IsFalse (ctor.IsStatic, "#M13c");
3321 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M13d");
3322 Assert.IsFalse (ctor is ConstructorBuilder, "#M13e");
3324 ctor = redType.GetConstructor (flags, null,
3326 new ParameterModifier [0]);
3327 Assert.IsNull (ctor, "#M14");
3329 flags = BindingFlags.Static | BindingFlags.NonPublic |
3330 BindingFlags.Public;
3332 ctor = greenType.GetConstructor (flags, null,
3333 new Type [] { typeof (int), typeof (int) },
3334 new ParameterModifier [0]);
3335 Assert.IsNull (ctor, "#N1");
3337 ctor = greenType.GetConstructor (flags, null,
3338 new Type [] { typeof (string) },
3339 new ParameterModifier [0]);
3340 Assert.IsNull (ctor, "#N2");
3342 ctor = greenType.GetConstructor (flags, null,
3343 new Type [] { typeof (string), typeof (string) },
3344 new ParameterModifier [0]);
3345 Assert.IsNull (ctor, "#N3");
3347 ctor = greenType.GetConstructor (flags, null,
3348 new Type [] { typeof (int) },
3349 new ParameterModifier [0]);
3350 Assert.IsNull (ctor, "#N4");
3352 ctor = greenType.GetConstructor (flags, null,
3353 new Type [] { typeof (int), typeof (bool) },
3354 new ParameterModifier [0]);
3355 Assert.IsNull (ctor, "#N5");
3357 ctor = greenType.GetConstructor (flags, null,
3358 new Type [] { typeof (string), typeof (int) },
3359 new ParameterModifier [0]);
3360 Assert.IsNull (ctor, "#N6");
3362 ctor = greenType.GetConstructor (flags, null,
3364 new ParameterModifier [0]);
3365 Assert.IsNull (ctor, "#N7");
3367 ctor = redType.GetConstructor (flags, null,
3368 new Type [] { typeof (int), typeof (int) },
3369 new ParameterModifier [0]);
3370 Assert.IsNull (ctor, "#N8");
3372 ctor = redType.GetConstructor (flags, null,
3373 new Type [] { typeof (string) },
3374 new ParameterModifier [0]);
3375 Assert.IsNull (ctor, "#N9");
3377 ctor = redType.GetConstructor (flags, null,
3378 new Type [] { typeof (string), typeof (string) },
3379 new ParameterModifier [0]);
3380 Assert.IsNull (ctor, "#N10");
3382 ctor = redType.GetConstructor (flags, null,
3383 new Type [] { typeof (int) },
3384 new ParameterModifier [0]);
3385 Assert.IsNull (ctor, "#N11");
3387 ctor = redType.GetConstructor (flags, null,
3388 new Type [] { typeof (int), typeof (bool) },
3389 new ParameterModifier [0]);
3390 Assert.IsNull (ctor, "#N12");
3392 ctor = redType.GetConstructor (flags, null,
3393 new Type [] { typeof (string), typeof (int) },
3394 new ParameterModifier [0]);
3395 Assert.IsNull (ctor, "#N13");
3397 ctor = redType.GetConstructor (flags, null,
3399 new ParameterModifier [0]);
3400 Assert.IsNotNull (ctor, "#N14a");
3401 Assert.IsTrue (ctor.IsPrivate, "#N14b");
3402 Assert.IsTrue (ctor.IsStatic, "#N14c");
3403 Assert.AreEqual (0, ctor.GetParameters ().Length, "#N14d");
3404 Assert.IsFalse (ctor is ConstructorBuilder, "#N14e");
3407 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
3408 public void GetConstructor2_Incomplete ()
3410 TypeBuilder tb = module.DefineType (genTypeName ());
3411 ConstructorBuilder cb = tb.DefineConstructor (
3412 MethodAttributes.Public,
3413 CallingConventions.Standard,
3415 cb.GetILGenerator ().Emit (OpCodes.Ret);
3418 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3419 null, Type.EmptyTypes, new ParameterModifier [0]);
3421 } catch (NotSupportedException ex) {
3422 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3423 Assert.IsNull (ex.InnerException, "#3");
3424 Assert.IsNotNull (ex.Message, "#4");
3428 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
3429 public void GetConstructor3_Incomplete ()
3431 TypeBuilder tb = module.DefineType (genTypeName ());
3432 ConstructorBuilder cb = tb.DefineConstructor (
3433 MethodAttributes.Public,
3434 CallingConventions.Standard,
3436 cb.GetILGenerator ().Emit (OpCodes.Ret);
3439 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3440 null, CallingConventions.Standard, Type.EmptyTypes,
3441 new ParameterModifier [0]);
3443 } catch (NotSupportedException ex) {
3444 // The invoked member is not supported in a
3446 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3447 Assert.IsNull (ex.InnerException, "#3");
3448 Assert.IsNotNull (ex.Message, "#4");
3452 [Test] // GetConstructors ()
3453 [Category ("NotWorking")] // mcs depends on this
3454 public void GetConstructors1_Incomplete ()
3456 TypeBuilder tb = module.DefineType (genTypeName ());
3457 ConstructorBuilder cb = tb.DefineConstructor (
3458 MethodAttributes.Public,
3459 CallingConventions.Standard,
3461 cb.GetILGenerator ().Emit (OpCodes.Ret);
3464 tb.GetConstructors ();
3466 } catch (NotSupportedException ex) {
3467 // The invoked member is not supported in a
3469 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3470 Assert.IsNull (ex.InnerException, "#3");
3471 Assert.IsNotNull (ex.Message, "#4");
3475 [Test] // GetConstructors (BindingFlags)
3476 public void GetConstructors2_Complete ()
3479 ConstructorInfo [] ctors;
3481 TypeBuilder redType = module.DefineType (genTypeName (),
3482 TypeAttributes.Public);
3483 CreateMembers (redType, "Red", true);
3485 TypeBuilder greenType = module.DefineType (genTypeName (),
3486 TypeAttributes.Public, redType);
3487 CreateMembers (greenType, "Green", false);
3488 ConstructorBuilder cb = greenType.DefineConstructor (
3489 MethodAttributes.Public,
3490 CallingConventions.Standard,
3492 cb.GetILGenerator ().Emit (OpCodes.Ret);
3494 redType.CreateType ();
3495 greenType.CreateType ();
3497 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3499 ctors = greenType.GetConstructors (flags);
3500 Assert.AreEqual (0, ctors.Length, "#A1");
3502 ctors = redType.GetConstructors (flags);
3503 Assert.AreEqual (5, ctors.Length, "#A2");
3504 Assert.IsTrue (ctors [0].IsPrivate, "#A3a");
3505 Assert.IsFalse (ctors [0].IsStatic, "#A3b");
3506 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#A3c");
3507 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#A3d");
3508 Assert.IsTrue (ctors [1].IsFamily, "#A4a");
3509 Assert.IsFalse (ctors [1].IsStatic, "#A4b");
3510 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#A4c");
3511 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#A4d");
3512 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#A5a");
3513 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3514 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#A5c");
3515 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#A5d");
3516 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#A6a");
3517 Assert.IsFalse (ctors [3].IsStatic, "#A6b");
3518 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#A6c");
3519 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#A6d");
3520 Assert.IsTrue (ctors [4].IsAssembly, "#A7a");
3521 Assert.IsFalse (ctors [4].IsStatic, "#A7b");
3522 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#A7c");
3523 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#A7d");
3525 flags = BindingFlags.Instance | BindingFlags.Public;
3527 ctors = greenType.GetConstructors (flags);
3528 Assert.AreEqual (1, ctors.Length, "#B1");
3529 Assert.IsTrue (ctors [0].IsPublic, "#B2a");
3530 Assert.IsFalse (ctors [0].IsStatic, "#B2b");
3531 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#B2c");
3532 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B2d");
3534 ctors = redType.GetConstructors (flags);
3535 Assert.AreEqual (1, ctors.Length, "#B3");
3536 Assert.IsTrue (ctors [0].IsPublic, "#B4a");
3537 Assert.IsFalse (ctors [0].IsStatic, "#B4b");
3538 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#B4c");
3539 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B4d");
3541 flags = BindingFlags.Static | BindingFlags.Public;
3543 ctors = greenType.GetConstructors (flags);
3544 Assert.AreEqual (0, ctors.Length, "#C1");
3546 ctors = redType.GetConstructors (flags);
3547 Assert.AreEqual (0, ctors.Length, "#C2");
3549 flags = BindingFlags.Static | BindingFlags.NonPublic;
3551 ctors = greenType.GetConstructors (flags);
3552 Assert.AreEqual (0, ctors.Length, "#D1");
3554 ctors = redType.GetConstructors (flags);
3555 Assert.AreEqual (1, ctors.Length, "#D2");
3556 Assert.IsTrue (ctors [0].IsPrivate, "#D3a");
3557 Assert.IsTrue (ctors [0].IsStatic, "#D3b");
3558 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#D3c");
3559 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#D3d");
3561 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3562 BindingFlags.FlattenHierarchy;
3564 ctors = greenType.GetConstructors (flags);
3565 Assert.AreEqual (0, ctors.Length, "#E1");
3567 ctors = redType.GetConstructors (flags);
3568 Assert.AreEqual (5, ctors.Length, "#E2");
3569 Assert.IsTrue (ctors [0].IsPrivate, "#E3a");
3570 Assert.IsFalse (ctors [0].IsStatic, "#E3b");
3571 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#E3c");
3572 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#E3d");
3573 Assert.IsTrue (ctors [1].IsFamily, "#E4a");
3574 Assert.IsFalse (ctors [1].IsStatic, "#E4b");
3575 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#E4c");
3576 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#E4d");
3577 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#E5a");
3578 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3579 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#E5c");
3580 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#E5d");
3581 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#E6a");
3582 Assert.IsFalse (ctors [3].IsStatic, "#E6b");
3583 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#E6c");
3584 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#E6d");
3585 Assert.IsTrue (ctors [4].IsAssembly, "#E7a");
3586 Assert.IsFalse (ctors [4].IsStatic, "#E7b");
3587 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#E7c");
3588 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#E7d");
3590 flags = BindingFlags.Instance | BindingFlags.Public |
3591 BindingFlags.FlattenHierarchy;
3593 ctors = greenType.GetConstructors (flags);
3594 Assert.AreEqual (1, ctors.Length, "#F1");
3595 Assert.IsTrue (ctors [0].IsPublic, "#F2a");
3596 Assert.IsFalse (ctors [0].IsStatic, "#F2b");
3597 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#F2c");
3598 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F2d");
3600 ctors = redType.GetConstructors (flags);
3601 Assert.AreEqual (1, ctors.Length, "#F3");
3602 Assert.IsTrue (ctors [0].IsPublic, "#F4a");
3603 Assert.IsFalse (ctors [0].IsStatic, "#F4b");
3604 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#F4c");
3605 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F4d");
3607 flags = BindingFlags.Static | BindingFlags.Public |
3608 BindingFlags.FlattenHierarchy;
3610 ctors = greenType.GetConstructors (flags);
3611 Assert.AreEqual (0, ctors.Length, "#G1");
3613 ctors = redType.GetConstructors (flags);
3614 Assert.AreEqual (0, ctors.Length, "#G2");
3616 flags = BindingFlags.Static | BindingFlags.NonPublic |
3617 BindingFlags.FlattenHierarchy;
3619 ctors = greenType.GetConstructors (flags);
3620 Assert.AreEqual (0, ctors.Length, "#H1");
3622 ctors = redType.GetConstructors (flags);
3623 Assert.AreEqual (1, ctors.Length, "#H2");
3624 Assert.IsTrue (ctors [0].IsPrivate, "#H3a");
3625 Assert.IsTrue (ctors [0].IsStatic, "#H3b");
3626 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#H3c");
3627 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#H3d");
3629 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3630 BindingFlags.DeclaredOnly;
3632 ctors = greenType.GetConstructors (flags);
3633 Assert.AreEqual (0, ctors.Length, "#I1");
3635 ctors = redType.GetConstructors (flags);
3636 Assert.AreEqual (5, ctors.Length, "#I2");
3637 Assert.IsTrue (ctors [0].IsPrivate, "#I3a");
3638 Assert.IsFalse (ctors [0].IsStatic, "#I3b");
3639 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#I3c");
3640 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#I3d");
3641 Assert.IsTrue (ctors [1].IsFamily, "#I4a");
3642 Assert.IsFalse (ctors [1].IsStatic, "#I4b");
3643 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#I4c");
3644 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#I4d");
3645 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#I5a");
3646 Assert.IsFalse (ctors [2].IsStatic, "#I5b");
3647 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#I5c");
3648 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#I5d");
3649 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#I6a");
3650 Assert.IsFalse (ctors [3].IsStatic, "#I6b");
3651 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#I6c");
3652 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#I6d");
3653 Assert.IsTrue (ctors [4].IsAssembly, "#I7a");
3654 Assert.IsFalse (ctors [4].IsStatic, "#I7b");
3655 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#I7c");
3656 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#I7d");
3658 flags = BindingFlags.Instance | BindingFlags.Public |
3659 BindingFlags.DeclaredOnly;
3661 ctors = greenType.GetConstructors (flags);
3662 Assert.AreEqual (1, ctors.Length, "#J1");
3663 Assert.IsTrue (ctors [0].IsPublic, "#J2a");
3664 Assert.IsFalse (ctors [0].IsStatic, "#J2b");
3665 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#J2c");
3666 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J2d");
3668 ctors = redType.GetConstructors (flags);
3669 Assert.AreEqual (1, ctors.Length, "#J3");
3670 Assert.IsTrue (ctors [0].IsPublic, "#J4a");
3671 Assert.IsFalse (ctors [0].IsStatic, "#J4b");
3672 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#J4c");
3673 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J4d");
3675 flags = BindingFlags.Static | BindingFlags.Public |
3676 BindingFlags.DeclaredOnly;
3678 ctors = greenType.GetConstructors (flags);
3679 Assert.AreEqual (0, ctors.Length, "#K1");
3681 ctors = redType.GetConstructors (flags);
3682 Assert.AreEqual (0, ctors.Length, "#K2");
3684 flags = BindingFlags.Static | BindingFlags.NonPublic |
3685 BindingFlags.DeclaredOnly;
3687 ctors = greenType.GetConstructors (flags);
3688 Assert.AreEqual (0, ctors.Length, "#L1");
3690 ctors = redType.GetConstructors (flags);
3691 Assert.AreEqual (1, ctors.Length, "#L2");
3692 Assert.IsTrue (ctors [0].IsPrivate, "#L3a");
3693 Assert.IsTrue (ctors [0].IsStatic, "#L3b");
3694 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#L3c");
3695 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#L3d");
3697 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3698 BindingFlags.Public;
3700 ctors = greenType.GetConstructors (flags);
3701 Assert.AreEqual (1, ctors.Length, "#M1");
3702 Assert.IsTrue (ctors [0].IsPublic, "#M2a");
3703 Assert.IsFalse (ctors [0].IsStatic, "#M2b");
3704 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#M2c");
3705 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M2d");
3707 ctors = redType.GetConstructors (flags);
3708 Assert.AreEqual (6, ctors.Length, "#M3");
3709 Assert.IsTrue (ctors [0].IsPrivate, "#M4a");
3710 Assert.IsFalse (ctors [0].IsStatic, "#M4b");
3711 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#M4c");
3712 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M4d");
3713 Assert.IsTrue (ctors [1].IsFamily, "#M5a");
3714 Assert.IsFalse (ctors [1].IsStatic, "#M5b");
3715 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#M5c");
3716 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#M5d");
3717 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#M6a");
3718 Assert.IsFalse (ctors [2].IsStatic, "#M6b");
3719 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#M6c");
3720 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#M6d");
3721 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#M7a");
3722 Assert.IsFalse (ctors [3].IsStatic, "#M7b");
3723 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#M7c");
3724 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#M7d");
3725 Assert.IsTrue (ctors [4].IsPublic, "#M8a");
3726 Assert.IsFalse (ctors [4].IsStatic, "#M8b");
3727 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#M8c");
3728 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#M8d");
3729 Assert.IsTrue (ctors [5].IsAssembly, "#M9a");
3730 Assert.IsFalse (ctors [5].IsStatic, "#M9b");
3731 Assert.AreEqual (2, ctors [5].GetParameters ().Length, "#M9c");
3732 Assert.IsFalse (ctors [5] is ConstructorBuilder, "#M9d");
3734 flags = BindingFlags.Static | BindingFlags.NonPublic |
3735 BindingFlags.Public;
3737 ctors = greenType.GetConstructors (flags);
3738 Assert.AreEqual (0, ctors.Length, "#N1");
3740 ctors = redType.GetConstructors (flags);
3741 Assert.AreEqual (1, ctors.Length, "#N2");
3742 Assert.IsTrue (ctors [0].IsPrivate, "#N3a");
3743 Assert.IsTrue (ctors [0].IsStatic, "#N3b");
3744 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#N3c");
3745 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#N3d");
3748 [Test] // GetConstructors (BindingFlags)
3749 [Category ("NotWorking")] // mcs depends on this
3750 public void GetConstructors2_Incomplete ()
3752 TypeBuilder tb = module.DefineType (genTypeName ());
3753 ConstructorBuilder cb = tb.DefineConstructor (
3754 MethodAttributes.Public,
3755 CallingConventions.Standard,
3757 cb.GetILGenerator ().Emit (OpCodes.Ret);
3760 tb.GetConstructors (BindingFlags.Public |
3761 BindingFlags.Instance);
3763 } catch (NotSupportedException ex) {
3764 // The invoked member is not supported in a
3766 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3767 Assert.IsNull (ex.InnerException, "#3");
3768 Assert.IsNotNull (ex.Message, "#4");
3773 public void TestGetCustomAttributesIncomplete ()
3775 TypeBuilder tb = module.DefineType (genTypeName ());
3777 tb.GetCustomAttributes (false);
3779 } catch (NotSupportedException ex) {
3780 // The invoked member is not supported in a
3782 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3783 Assert.IsNull (ex.InnerException, "#3");
3784 Assert.IsNotNull (ex.Message, "#4");
3789 public void TestGetCustomAttributesComplete ()
3791 TypeBuilder tb = module.DefineType (genTypeName ());
3793 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3794 new Type [] { typeof (string) });
3796 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3797 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3799 tb.SetCustomAttribute (caBuilder);
3802 Assert.AreEqual (1, tb.GetCustomAttributes (false).Length);
3806 public void TestGetCustomAttributesOfTypeIncomplete ()
3808 TypeBuilder tb = module.DefineType (genTypeName ());
3810 tb.GetCustomAttributes (typeof (ObsoleteAttribute), false);
3812 } catch (NotSupportedException ex) {
3813 // The invoked member is not supported in a
3815 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3816 Assert.IsNull (ex.InnerException, "#3");
3817 Assert.IsNotNull (ex.Message, "#4");
3822 public void TestGetCustomAttributesOfTypeComplete ()
3824 TypeBuilder tb = module.DefineType (genTypeName ());
3826 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3827 new Type [] { typeof (string) });
3829 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3830 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3832 tb.SetCustomAttribute (caBuilder);
3835 Assert.AreEqual (1, tb.GetCustomAttributes (typeof (GuidAttribute), false).Length, "#1");
3836 Assert.AreEqual (0, tb.GetCustomAttributes (typeof (ObsoleteAttribute), false).Length, "#2");
3840 public void TestGetCustomAttributesOfNullTypeComplete ()
3842 TypeBuilder tb = module.DefineType (genTypeName ());
3845 tb.GetCustomAttributes (null, false);
3847 } catch (ArgumentNullException ex) {
3848 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
3849 Assert.IsNull (ex.InnerException, "#3");
3850 Assert.IsNotNull (ex.Message, "#4");
3851 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
3856 [Ignore ("mcs depends on this")]
3857 public void TestGetEventsIncomplete ()
3859 TypeBuilder tb = module.DefineType (genTypeName ());
3863 } catch (NotSupportedException ex) {
3864 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3865 Assert.IsNull (ex.InnerException, "#3");
3866 Assert.IsNotNull (ex.Message, "#4");
3872 public void TestGetEventsComplete ()
3874 TypeBuilder tb = module.DefineType (genTypeName ());
3876 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3877 typeof (void), new Type [] { typeof (Object) });
3878 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
3880 // create public event
3881 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
3882 typeof (ResolveEventHandler));
3883 eventbuilder.SetRaiseMethod (onclickMethod);
3885 Type emittedType = tb.CreateType ();
3887 Assert.AreEqual (1, tb.GetEvents ().Length, "#1");
3888 Assert.AreEqual (tb.GetEvents ().Length, emittedType.GetEvents ().Length, "#2");
3893 [Ignore ("mcs depends on this")]
3894 public void TestGetEventsFlagsIncomplete ()
3896 TypeBuilder tb = module.DefineType (genTypeName ());
3898 tb.GetEvents (BindingFlags.Public);
3900 } catch (NotSupportedException ex) {
3901 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3902 Assert.IsNull (ex.InnerException, "#3");
3903 Assert.IsNotNull (ex.Message, "#4");
3909 public void TestGetEventsFlagsComplete ()
3911 TypeBuilder tb = module.DefineType (genTypeName ());
3913 MethodBuilder onchangeMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3914 typeof (void), new Type [] { typeof (Object) });
3915 onchangeMethod.GetILGenerator ().Emit (OpCodes.Ret);
3917 // create public event
3918 EventBuilder changeEvent = tb.DefineEvent ("Change", EventAttributes.None,
3919 typeof (ResolveEventHandler));
3920 changeEvent.SetRaiseMethod (onchangeMethod);
3922 // create non-public event
3923 EventBuilder redoChangeEvent = tb.DefineEvent ("RedoChange", EventAttributes.None,
3924 typeof (ResolveEventHandler));
3926 Type emittedType = tb.CreateType ();
3928 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3929 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3930 Assert.AreEqual (2, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3931 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length,
3932 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3933 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length,
3934 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3935 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length,
3936 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3940 public void TestGetEventsFlagsComplete_Inheritance ()
3942 EventInfo [] events;
3945 TypeBuilder blueType = module.DefineType (genTypeName (),
3946 TypeAttributes.Public);
3947 CreateMembers (blueType, "Blue", false);
3949 TypeBuilder redType = module.DefineType (genTypeName (),
3950 TypeAttributes.Public, blueType);
3951 CreateMembers (redType, "Red", false);
3953 TypeBuilder greenType = module.DefineType (genTypeName (),
3954 TypeAttributes.Public, redType);
3955 CreateMembers (greenType, "Green", false);
3957 blueType.CreateType ();
3958 redType.CreateType ();
3959 greenType.CreateType ();
3961 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3962 events = greenType.GetEvents (flags);
3964 Assert.AreEqual (13, events.Length, "#A1");
3965 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#A2");
3966 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#A3");
3967 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#A4");
3968 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#A5");
3969 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#A6");
3970 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#A7");
3971 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#A8");
3972 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#A9");
3973 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#A10");
3974 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#A11");
3975 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#A12");
3976 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#A13");
3977 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#A14");
3979 flags = BindingFlags.Instance | BindingFlags.Public;
3980 events = greenType.GetEvents (flags);
3982 Assert.AreEqual (3, events.Length, "#B1");
3983 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#B2");
3984 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#B3");
3985 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#B4");
3987 flags = BindingFlags.Static | BindingFlags.Public;
3988 events = greenType.GetEvents (flags);
3990 Assert.AreEqual (1, events.Length, "#C1");
3991 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#C2");
3993 flags = BindingFlags.Static | BindingFlags.NonPublic;
3994 events = greenType.GetEvents (flags);
3996 Assert.AreEqual (5, events.Length, "#D1");
3997 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#D2");
3998 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#D3");
3999 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#D4");
4000 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#D5");
4001 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#D6");
4003 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4004 BindingFlags.FlattenHierarchy;
4005 events = greenType.GetEvents (flags);
4007 Assert.AreEqual (13, events.Length, "#E1");
4008 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#E2");
4009 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#E3");
4010 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#E4");
4011 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#E5");
4012 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#E6");
4013 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#E7");
4014 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#E8");
4015 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#E9");
4016 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#E10");
4017 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#E11");
4018 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#E12");
4019 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#E13");
4020 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#E14");
4022 flags = BindingFlags.Instance | BindingFlags.Public |
4023 BindingFlags.FlattenHierarchy;
4024 events = greenType.GetEvents (flags);
4026 Assert.AreEqual (3, events.Length, "#F1");
4027 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#F2");
4028 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#F3");
4029 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#F4");
4031 flags = BindingFlags.Static | BindingFlags.Public |
4032 BindingFlags.FlattenHierarchy;
4033 events = greenType.GetEvents (flags);
4035 Assert.AreEqual (3, events.Length, "#G1");
4036 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#G2");
4037 Assert.AreEqual ("OnPublicStaticRed", events [1].Name, "#G3");
4038 Assert.AreEqual ("OnPublicStaticBlue", events [2].Name, "#G4");
4040 flags = BindingFlags.Static | BindingFlags.NonPublic |
4041 BindingFlags.FlattenHierarchy;
4042 events = greenType.GetEvents (flags);
4044 Assert.AreEqual (13, events.Length, "#H1");
4045 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#H2");
4046 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#H3");
4047 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#H4");
4048 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#H5");
4049 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#H6");
4050 Assert.AreEqual ("OnFamilyStaticRed", events [5].Name, "#H7");
4051 Assert.AreEqual ("OnFamANDAssemStaticRed", events [6].Name, "#H8");
4052 Assert.AreEqual ("OnFamORAssemStaticRed", events [7].Name, "#H9");
4053 Assert.AreEqual ("OnAssemblyStaticRed", events [8].Name, "#H10");
4054 Assert.AreEqual ("OnFamilyStaticBlue", events [9].Name, "#H11");
4055 Assert.AreEqual ("OnFamANDAssemStaticBlue", events [10].Name, "#H12");
4056 Assert.AreEqual ("OnFamORAssemStaticBlue", events [11].Name, "#H13");
4057 Assert.AreEqual ("OnAssemblyStaticBlue", events [12].Name, "#H14");
4059 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4060 BindingFlags.DeclaredOnly;
4061 events = greenType.GetEvents (flags);
4063 Assert.AreEqual (5, events.Length, "#I1");
4064 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#I2");
4065 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#I3");
4066 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#I4");
4067 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#I5");
4068 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#I6");
4070 flags = BindingFlags.Instance | BindingFlags.Public |
4071 BindingFlags.DeclaredOnly;
4072 events = greenType.GetEvents (flags);
4074 Assert.AreEqual (1, events.Length, "#J1");
4075 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#J2");
4077 flags = BindingFlags.Static | BindingFlags.Public |
4078 BindingFlags.DeclaredOnly;
4079 events = greenType.GetEvents (flags);
4081 Assert.AreEqual (1, events.Length, "#K1");
4082 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#K2");
4084 flags = BindingFlags.Static | BindingFlags.NonPublic |
4085 BindingFlags.DeclaredOnly;
4086 events = greenType.GetEvents (flags);
4088 Assert.AreEqual (5, events.Length, "#L1");
4089 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#L2");
4090 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#L3");
4091 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#L4");
4092 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#L5");
4093 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#L6");
4095 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4096 BindingFlags.Public;
4097 events = greenType.GetEvents (flags);
4099 Assert.AreEqual (16, events.Length, "#M1");
4100 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#M2");
4101 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#M3");
4102 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#M4");
4103 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#M5");
4104 Assert.AreEqual ("OnPublicInstanceGreen", events [4].Name, "#M6");
4105 Assert.AreEqual ("OnAssemblyInstanceGreen", events [5].Name, "#M7");
4106 Assert.AreEqual ("OnFamilyInstanceRed", events [6].Name, "#M8");
4107 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [7].Name, "#M9");
4108 Assert.AreEqual ("OnFamORAssemInstanceRed", events [8].Name, "#M10");
4109 Assert.AreEqual ("OnPublicInstanceRed", events [9].Name, "#M11");
4110 Assert.AreEqual ("OnAssemblyInstanceRed", events [10].Name, "#M12");
4111 Assert.AreEqual ("OnFamilyInstanceBlue", events [11].Name, "#M13");
4112 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [12].Name, "#M14");
4113 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [13].Name, "#M15");
4114 Assert.AreEqual ("OnPublicInstanceBlue", events [14].Name, "#M16");
4115 Assert.AreEqual ("OnAssemblyInstanceBlue", events [15].Name, "#M17");
4117 flags = BindingFlags.Static | BindingFlags.NonPublic |
4118 BindingFlags.Public;
4119 events = greenType.GetEvents (flags);
4121 Assert.AreEqual (6, events.Length, "#N1");
4122 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#N2");
4123 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#N3");
4124 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#N4");
4125 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#N5");
4126 Assert.AreEqual ("OnPublicStaticGreen", events [4].Name, "#N6");
4127 Assert.AreEqual ("OnAssemblyStaticGreen", events [5].Name, "#N7");
4131 [Ignore ("mcs depends on this")]
4132 public void TestGetEventIncomplete ()
4134 TypeBuilder tb = module.DefineType (genTypeName ());
4136 tb.GetEvent ("FOO");
4138 } catch (NotSupportedException ex) {
4139 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4140 Assert.IsNull (ex.InnerException, "#3");
4141 Assert.IsNotNull (ex.Message, "#4");
4147 public void TestGetEventComplete ()
4149 TypeBuilder tb = module.DefineType (genTypeName ());
4151 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4152 typeof (void), new Type [] { typeof (Object) });
4153 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4155 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4156 typeof (ResolveEventHandler));
4157 eventbuilder.SetRaiseMethod (onclickMethod);
4159 Type emittedType = tb.CreateType ();
4161 Assert.IsNotNull (tb.GetEvent ("Change"));
4162 Assert.AreEqual (tb.GetEvent ("Change"), emittedType.GetEvent ("Change"));
4163 Assert.IsNull (tb.GetEvent ("NotChange"));
4164 Assert.AreEqual (tb.GetEvent ("NotChange"), emittedType.GetEvent ("NotChange"));
4168 [Ignore ("mcs depends on this")]
4169 public void TestGetEventFlagsIncomplete ()
4171 TypeBuilder tb = module.DefineType (genTypeName ());
4173 tb.GetEvent ("FOO", BindingFlags.Public);
4175 } catch (NotSupportedException ex) {
4176 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4177 Assert.IsNull (ex.InnerException, "#3");
4178 Assert.IsNotNull (ex.Message, "#4");
4184 public void TestGetEventFlagsComplete ()
4186 TypeBuilder tb = module.DefineType (genTypeName ());
4188 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4189 typeof (void), new Type [] { typeof (Object) });
4190 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4192 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4193 typeof (ResolveEventHandler));
4194 eventbuilder.SetRaiseMethod (onclickMethod);
4196 Type emittedType = tb.CreateType ();
4198 Assert.IsNotNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4199 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public),
4200 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4201 Assert.IsNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4202 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic),
4203 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4207 public void TestGetEventFlagsComplete_Inheritance ()
4211 TypeBuilder blueType = module.DefineType (genTypeName (),
4212 TypeAttributes.Public);
4213 CreateMembers (blueType, "Blue", false);
4215 TypeBuilder redType = module.DefineType (genTypeName (),
4216 TypeAttributes.Public, blueType);
4217 CreateMembers (redType, "Red", false);
4219 TypeBuilder greenType = module.DefineType (genTypeName (),
4220 TypeAttributes.Public, redType);
4221 CreateMembers (greenType, "Green", false);
4223 blueType.CreateType ();
4224 redType.CreateType ();
4225 greenType.CreateType ();
4227 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4229 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#A1");
4230 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#A2");
4231 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#A3");
4232 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#A4");
4233 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#A5");
4234 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#A6");
4235 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#A7");
4236 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#A8");
4237 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#A9");
4238 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#A10");
4239 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#A11");
4240 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#A12");
4241 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#A13");
4242 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#A14");
4243 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#A15");
4244 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#A16");
4245 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#A17");
4246 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#A18");
4247 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#A19");
4248 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#A20");
4249 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#A21");
4250 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#A22");
4251 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#A23");
4252 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#A24");
4253 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#A25");
4254 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#A26");
4255 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#A27");
4256 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#A28");
4257 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#A29");
4258 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#A30");
4259 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#A31");
4260 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#A32");
4261 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#A33");
4262 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#A34");
4263 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#A35");
4264 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#A36");
4266 flags = BindingFlags.Instance | BindingFlags.Public;
4268 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#B1");
4269 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#B2");
4270 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#B3");
4271 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#B4");
4272 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#B5");
4273 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#B6");
4274 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#B7");
4275 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#B8");
4276 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#B9");
4277 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#B10");
4278 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#B11");
4279 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#B12");
4280 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#B13");
4281 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#B14");
4282 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#B15");
4283 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#B16");
4284 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#B17");
4285 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#B18");
4286 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#B19");
4287 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#B20");
4288 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#B21");
4289 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#B22");
4290 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#B23");
4291 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#B24");
4292 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#B25");
4293 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#B26");
4294 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#B27");
4295 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#B28");
4296 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#B29");
4297 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#B30");
4298 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#B31");
4299 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#B32");
4300 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#B33");
4301 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#B34");
4302 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#B35");
4303 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#B36");
4305 flags = BindingFlags.Static | BindingFlags.Public;
4307 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#C1");
4308 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#C2");
4309 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#C3");
4310 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#C4");
4311 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#C5");
4312 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#C6");
4313 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#C7");
4314 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#C8");
4315 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#C9");
4316 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#C10");
4317 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#C11");
4318 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#C12");
4319 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#C13");
4320 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#C14");
4321 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#C15");
4322 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#C16");
4323 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#C17");
4324 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#C18");
4325 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#C19");
4326 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#C20");
4327 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#C21");
4328 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#C22");
4329 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#C23");
4330 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#C24");
4331 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#C25");
4332 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#C26");
4333 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#C27");
4334 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#C28");
4335 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#C29");
4336 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#C30");
4337 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#C31");
4338 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#C32");
4339 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#C33");
4340 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#C34");
4341 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#C35");
4342 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#C36");
4344 flags = BindingFlags.Static | BindingFlags.NonPublic;
4346 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#D1");
4347 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#D2");
4348 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#D3");
4349 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#D4");
4350 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#D5");
4351 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#D6");
4352 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#D7");
4353 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#D8");
4354 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#D9");
4355 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#D10");
4356 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#D11");
4357 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#D12");
4358 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#D13");
4359 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#D14");
4360 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#D15");
4361 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#D16");
4362 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#D17");
4363 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#D18");
4364 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#D19");
4365 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#D20");
4366 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#D21");
4367 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#D22");
4368 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#D23");
4369 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#D24");
4370 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#D25");
4371 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#D26");
4372 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#D27");
4373 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#D28");
4374 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#D29");
4375 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#D30");
4376 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#D31");
4377 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#D32");
4378 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#D33");
4379 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#D34");
4380 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#D35");
4381 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#D36");
4383 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4384 BindingFlags.FlattenHierarchy;
4386 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#E1");
4387 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#E2");
4388 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#E3");
4389 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#E4");
4390 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#E5");
4391 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#E6");
4392 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#E7");
4393 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#E8");
4394 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#E9");
4395 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#E10");
4396 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#E11");
4397 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#E12");
4398 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#E13");
4399 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#E14");
4400 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#E15");
4401 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#E16");
4402 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#E17");
4403 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#E18");
4404 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#E19");
4405 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#E20");
4406 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#E21");
4407 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#E22");
4408 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#E23");
4409 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#E24");
4410 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#E25");
4411 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#E26");
4412 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#E27");
4413 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#E28");
4414 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#E29");
4415 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#E30");
4416 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#E31");
4417 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#E32");
4418 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#E33");
4419 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#E34");
4420 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#E35");
4421 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#E36");
4423 flags = BindingFlags.Instance | BindingFlags.Public |
4424 BindingFlags.FlattenHierarchy;
4426 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#F1");
4427 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#F2");
4428 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#F3");
4429 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#F4");
4430 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#F5");
4431 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#F6");
4432 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#F7");
4433 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#F8");
4434 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#F9");
4435 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#F10");
4436 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#F11");
4437 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#F12");
4438 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#F13");
4439 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#F14");
4440 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#F15");
4441 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#F16");
4442 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#F17");
4443 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#F18");
4444 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#F19");
4445 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#F20");
4446 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#F21");
4447 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#F22");
4448 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#F23");
4449 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#F24");
4450 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#F25");
4451 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#F26");
4452 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#F27");
4453 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#F28");
4454 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#F29");
4455 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#F30");
4456 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#F31");
4457 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#F32");
4458 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#F33");
4459 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#F34");
4460 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#F35");
4461 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#F36");
4463 flags = BindingFlags.Static | BindingFlags.Public |
4464 BindingFlags.FlattenHierarchy;
4466 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#G1");
4467 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#G2");
4468 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#G3");
4469 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#G4");
4470 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#G5");
4471 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#G6");
4472 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#G7");
4473 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#G8");
4474 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#G9");
4475 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#G10");
4476 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#G11");
4477 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#G12");
4478 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#G13");
4479 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#G14");
4480 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#G15");
4481 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#G16");
4482 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#G17");
4483 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#G18");
4484 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#G19");
4485 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#G20");
4486 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#G21");
4487 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#G22");
4488 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#G23");
4489 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#G24");
4490 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#G25");
4491 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#G26");
4492 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#G27");
4493 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#G28");
4494 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#G29");
4495 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#G30");
4496 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#G31");
4497 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#G32");
4498 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#G33");
4499 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#G34");
4500 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#G35");
4501 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#G36");
4503 flags = BindingFlags.Static | BindingFlags.NonPublic |
4504 BindingFlags.FlattenHierarchy;
4506 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#H1");
4507 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#H2");
4508 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#H3");
4509 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#H4");
4510 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#H5");
4511 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#H6");
4512 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#H7");
4513 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#H8");
4514 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#H9");
4515 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#H10");
4516 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#H11");
4517 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#H12");
4518 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#H13");
4519 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#H14");
4520 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#H15");
4521 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#H16");
4522 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#H17");
4523 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#H18");
4524 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#H19");
4525 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#H20");
4526 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#H21");
4527 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#H22");
4528 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#H23");
4529 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#H24");
4530 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#H25");
4531 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#H26");
4532 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#H27");
4533 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#H28");
4534 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#H29");
4535 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#H30");
4536 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#H31");
4537 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#H32");
4538 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#H33");
4539 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#H34");
4540 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#H35");
4541 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#H36");
4543 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4544 BindingFlags.DeclaredOnly;
4546 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#I1");
4547 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#I2");
4548 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#I3");
4549 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#I4");
4550 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#I5");
4551 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#I6");
4552 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#I7");
4553 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#I8");
4554 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#I9");
4555 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#I10");
4556 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#I11");
4557 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#I12");
4558 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#I13");
4559 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#I14");
4560 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#I15");
4561 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#I16");
4562 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#I17");
4563 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#I18");
4564 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#I19");
4565 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#I20");
4566 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#I21");
4567 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#I22");
4568 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#I23");
4569 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#I24");
4570 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#I25");
4571 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#I26");
4572 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#I27");
4573 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#I28");
4574 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#I29");
4575 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#I30");
4576 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#I31");
4577 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#I32");
4578 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#I33");
4579 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#I34");
4580 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#I35");
4581 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#I36");
4583 flags = BindingFlags.Instance | BindingFlags.Public |
4584 BindingFlags.DeclaredOnly;
4586 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#J1");
4587 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#J2");
4588 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#J3");
4589 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#J4");
4590 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#J5");
4591 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#J6");
4592 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#J7");
4593 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#J8");
4594 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#J9");
4595 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#J10");
4596 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#J11");
4597 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#J12");
4598 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#J13");
4599 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#J14");
4600 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#J15");
4601 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#J16");
4602 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#J17");
4603 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#J18");
4604 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#J19");
4605 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#J20");
4606 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#J21");
4607 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#J22");
4608 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#J23");
4609 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#J24");
4610 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#J25");
4611 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#J26");
4612 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#J27");
4613 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#J28");
4614 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#J29");
4615 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#J30");
4616 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#J31");
4617 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#J32");
4618 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#J33");
4619 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#J34");
4620 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#J35");
4621 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#J36");
4623 flags = BindingFlags.Static | BindingFlags.Public |
4624 BindingFlags.DeclaredOnly;
4626 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#K1");
4627 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#K2");
4628 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#K3");
4629 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#K4");
4630 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#K5");
4631 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#K6");
4632 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#K7");
4633 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#K8");
4634 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#K9");
4635 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#K10");
4636 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#K11");
4637 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#K12");
4638 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#K13");
4639 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#K14");
4640 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#K15");
4641 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#K16");
4642 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#K17");
4643 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#K18");
4644 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#K19");
4645 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#K20");
4646 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#K21");
4647 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#K22");
4648 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#K23");
4649 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#K24");
4650 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#K25");
4651 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#K26");
4652 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#K27");
4653 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#K28");
4654 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#K29");
4655 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#K30");
4656 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#K31");
4657 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#K32");
4658 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#K33");
4659 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#K34");
4660 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#K35");
4661 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#K36");
4663 flags = BindingFlags.Static | BindingFlags.NonPublic |
4664 BindingFlags.DeclaredOnly;
4666 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#L1");
4667 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#L2");
4668 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#L3");
4669 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#L4");
4670 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#L5");
4671 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#L6");
4672 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#L7");
4673 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#L8");
4674 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#L9");
4675 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#L10");
4676 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#L11");
4677 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#L12");
4678 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#L13");
4679 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#L14");
4680 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#L15");
4681 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#L16");
4682 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#L17");
4683 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#L18");
4684 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#L19");
4685 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#L20");
4686 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#L21");
4687 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#L22");
4688 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#L23");
4689 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#L24");
4690 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#L25");
4691 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#L26");
4692 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#L27");
4693 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#L28");
4694 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#L29");
4695 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#L30");
4696 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#L31");
4697 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#L32");
4698 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#L33");
4699 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#L34");
4700 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#L35");
4701 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#L36");
4703 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4704 BindingFlags.Public;
4706 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#M1");
4707 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#M2");
4708 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#M3");
4709 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#M4");
4710 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#M5");
4711 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#M6");
4712 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#M7");
4713 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#M8");
4714 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#M9");
4715 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#M10");
4716 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#M11");
4717 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#M12");
4718 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#M13");
4719 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#M14");
4720 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#M15");
4721 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#M16");
4722 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#M17");
4723 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#M18");
4724 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#M19");
4725 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#M20");
4726 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#M21");
4727 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#M22");
4728 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#M23");
4729 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#M24");
4730 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#M25");
4731 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#M26");
4732 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#M27");
4733 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#M28");
4734 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#M29");
4735 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#M30");
4736 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#M31");
4737 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#M32");
4738 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#M33");
4739 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#M34");
4740 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#M35");
4741 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#M36");
4743 flags = BindingFlags.Static | BindingFlags.NonPublic |
4744 BindingFlags.Public;
4746 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#N1");
4747 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#N2");
4748 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#N3");
4749 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#N4");
4750 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#N5");
4751 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#N6");
4752 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#N7");
4753 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#N8");
4754 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#N9");
4755 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#N10");
4756 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#N11");
4757 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#N12");
4758 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#N13");
4759 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#N14");
4760 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#N15");
4761 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#N16");
4762 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#N17");
4763 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#N18");
4764 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#N19");
4765 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#N20");
4766 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#N21");
4767 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#N22");
4768 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#N23");
4769 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#N24");
4770 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#N25");
4771 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#N26");
4772 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#N27");
4773 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#N28");
4774 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#N29");
4775 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#N30");
4776 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#N31");
4777 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#N32");
4778 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#N33");
4779 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#N34");
4780 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#N35");
4781 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#N36");
4785 [Category ("NotWorking")] // mcs depends on this
4786 public void TestGetFieldsIncomplete_MS ()
4788 TypeBuilder tb = module.DefineType (genTypeName ());
4789 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4793 } catch (NotSupportedException ex) {
4794 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4795 Assert.IsNull (ex.InnerException, "#3");
4796 Assert.IsNotNull (ex.Message, "#4");
4801 [Category ("NotDotNet")] // mcs depends on this
4802 public void TestGetFieldsIncomplete_Mono ()
4804 TypeBuilder tb = module.DefineType (genTypeName ());
4805 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4806 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4807 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4808 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4810 FieldInfo [] fields = tb.GetFields ();
4811 Assert.AreEqual (2, fields.Length, "#A1");
4812 Assert.AreEqual ("Sex", fields [0].Name, "#A2");
4813 Assert.AreEqual ("MALE", fields [1].Name, "#A3");
4815 tb = module.DefineType (genTypeName ());
4816 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4817 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4818 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4819 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4820 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4821 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4823 fields = tb.GetFields ();
4824 Assert.AreEqual (4, fields.Length, "#B1");
4825 Assert.AreEqual ("First", fields [0].Name, "#B2");
4826 Assert.AreEqual ("Second", fields [1].Name, "#B3");
4827 Assert.AreEqual ("Sex", fields [2].Name, "#B4");
4828 Assert.AreEqual ("MALE", fields [3].Name, "#B5");
4832 public void TestGetFieldsComplete ()
4834 TypeBuilder tb = module.DefineType (genTypeName ());
4835 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4837 Type emittedType = tb.CreateType ();
4838 FieldInfo [] dynamicFields = tb.GetFields ();
4839 FieldInfo [] emittedFields = emittedType.GetFields ();
4841 Assert.AreEqual (1, dynamicFields.Length, "#A1");
4842 Assert.AreEqual (dynamicFields.Length, emittedFields.Length, "#A2");
4843 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#A3");
4844 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#A4");
4847 object value = Activator.CreateInstance (emittedType);
4848 emittedFields [0].SetValue (value, 5);
4849 Assert.AreEqual (5, emittedFields [0].GetValue (value), "#B1");
4850 Assert.AreEqual (5, dynamicFields [0].GetValue (value), "#B2");
4851 dynamicFields [0].SetValue (value, 4);
4852 Assert.AreEqual (4, emittedFields [0].GetValue (value), "#B3");
4853 Assert.AreEqual (4, dynamicFields [0].GetValue (value), "#B4");
4856 [Test] // bug #82625 / 325292
4857 public void TestGetFieldsComplete_Generic ()
4859 // FIXME: merge this with TestGetFieldsComplete when
4860 // bug #82625 is fixed
4864 FieldInfo [] dynamicFields;
4865 FieldInfo [] emittedFields;
4867 tb = module.DefineType (genTypeName ());
4868 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4869 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4870 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4871 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4872 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4873 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4875 emittedType = tb.CreateType ();
4876 dynamicFields = tb.GetFields ();
4877 emittedFields = emittedType.GetFields ();
4879 Assert.AreEqual (4, dynamicFields.Length, "#C1");
4880 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#C2");
4881 Assert.IsFalse ((dynamicFields [1]) is FieldBuilder, "#C3");
4882 Assert.IsFalse ((dynamicFields [2]) is FieldBuilder, "#C4");
4883 Assert.IsFalse ((dynamicFields [3]) is FieldBuilder, "#C5");
4884 Assert.AreEqual ("First", dynamicFields [0].Name, "#C6");
4885 Assert.AreEqual ("Second", dynamicFields [1].Name, "#C7");
4886 Assert.AreEqual ("Sex", dynamicFields [2].Name, "#C8");
4887 Assert.AreEqual ("MALE", dynamicFields [3].Name, "#C9");
4889 Assert.AreEqual (4, emittedFields.Length, "#D1");
4890 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#D2");
4891 Assert.IsFalse ((emittedFields [1]) is FieldBuilder, "#D3");
4892 Assert.IsFalse ((emittedFields [2]) is FieldBuilder, "#D4");
4893 Assert.IsFalse ((emittedFields [3]) is FieldBuilder, "#D5");
4894 Assert.AreEqual ("First", emittedFields [0].Name, "#D6");
4895 Assert.AreEqual ("Second", emittedFields [1].Name, "#D7");
4896 Assert.AreEqual ("Sex", emittedFields [2].Name, "#D8");
4897 Assert.AreEqual ("MALE", emittedFields [3].Name, "#D9");
4901 [Category ("NotWorking")] // mcs depends on this
4902 public void TestGetFieldsFlagsIncomplete_MS ()
4904 TypeBuilder tb = module.DefineType (genTypeName ());
4905 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4907 tb.GetFields (BindingFlags.Instance | BindingFlags.Public);
4909 } catch (NotSupportedException ex) {
4910 // The invoked member is not supported in a
4912 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4913 Assert.IsNull (ex.InnerException, "#3");
4914 Assert.IsNotNull (ex.Message, "#4");
4919 [Category ("NotDotNet")] // mcs depends on this
4920 public void TestGetFieldsFlagsIncomplete_Mono ()
4922 FieldInfo [] fields;
4924 TypeBuilder tb = module.DefineType (genTypeName ());
4925 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4926 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4927 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4928 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4930 fields = tb.GetFields (BindingFlags.Public |
4931 BindingFlags.NonPublic | BindingFlags.Instance);
4932 Assert.AreEqual (2, fields.Length, "#A1");
4933 Assert.AreEqual ("name", fields [0].Name, "#A2");
4934 Assert.AreEqual ("Sex", fields [1].Name, "#A3");
4936 fields = tb.GetFields (BindingFlags.Public |
4937 BindingFlags.Instance | BindingFlags.Static);
4938 Assert.AreEqual (2, fields.Length, "#B1");
4939 Assert.AreEqual ("Sex", fields [0].Name, "#B2");
4940 Assert.AreEqual ("MALE", fields [1].Name, "#B3");
4942 fields = tb.GetFields (BindingFlags.Public |
4943 BindingFlags.NonPublic | BindingFlags.Instance |
4944 BindingFlags.Static);
4945 Assert.AreEqual (4, fields.Length, "#C1");
4946 Assert.AreEqual ("name", fields [0].Name, "#C2");
4947 Assert.AreEqual ("Sex", fields [1].Name, "#C3");
4948 Assert.AreEqual ("MALE", fields [2].Name, "#C4");
4949 Assert.AreEqual ("FEMALE", fields [3].Name, "#C5");
4953 public void TestGetFieldsFlagsComplete ()
4955 TypeBuilder tb = module.DefineType (genTypeName ());
4956 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4958 Type emittedType = tb.CreateType ();
4960 Assert.AreEqual (1, tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4961 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length,
4962 emittedType.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4963 Assert.AreEqual (0, tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4964 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length,
4965 emittedType.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4969 public void TestGetFieldsFlagsComplete_Inheritance ()
4971 FieldInfo [] fields;
4974 TypeBuilder blueType = module.DefineType (genTypeName (),
4975 TypeAttributes.Public);
4976 CreateMembers (blueType, "Blue", false);
4978 TypeBuilder redType = module.DefineType (genTypeName (),
4979 TypeAttributes.Public, blueType);
4980 CreateMembers (redType, "Red", false);
4982 TypeBuilder greenType = module.DefineType (genTypeName (),
4983 TypeAttributes.Public, redType);
4984 CreateMembers (greenType, "Green", false);
4986 blueType.CreateType ();
4987 redType.CreateType ();
4988 greenType.CreateType ();
4990 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4991 fields = greenType.GetFields (flags);
4993 Assert.AreEqual (13, fields.Length, "#A1");
4994 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#A2");
4995 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#A3");
4996 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#A4");
4997 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#A5");
4998 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#A6");
4999 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#A7");
5000 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#A8");
5001 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#A9");
5002 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#A10");
5003 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#A11");
5004 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#A12");
5005 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#A13");
5006 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#A14");
5008 flags = BindingFlags.Instance | BindingFlags.Public;
5009 fields = greenType.GetFields (flags);
5011 Assert.AreEqual (3, fields.Length, "#B1");
5012 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#B2");
5013 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#B3");
5014 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#B4");
5016 flags = BindingFlags.Static | BindingFlags.Public;
5017 fields = greenType.GetFields (flags);
5019 Assert.AreEqual (1, fields.Length, "#C1");
5020 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#C2");
5022 flags = BindingFlags.Static | BindingFlags.NonPublic;
5023 fields = greenType.GetFields (flags);
5025 Assert.AreEqual (5, fields.Length, "#D1");
5026 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#D2");
5027 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#D3");
5028 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#D4");
5029 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#D5");
5030 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#D6");
5032 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5033 BindingFlags.FlattenHierarchy;
5034 fields = greenType.GetFields (flags);
5036 Assert.AreEqual (13, fields.Length, "#E1");
5037 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#E2");
5038 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#E3");
5039 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#E4");
5040 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#E5");
5041 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#E6");
5042 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#E7");
5043 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#E8");
5044 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#E9");
5045 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#E10");
5046 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#E11");
5047 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#E12");
5048 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#E13");
5049 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#E14");
5051 flags = BindingFlags.Instance | BindingFlags.Public |
5052 BindingFlags.FlattenHierarchy;
5053 fields = greenType.GetFields (flags);
5055 Assert.AreEqual (3, fields.Length, "#F1");
5056 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#F2");
5057 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#F3");
5058 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#F4");
5060 flags = BindingFlags.Static | BindingFlags.Public |
5061 BindingFlags.FlattenHierarchy;
5062 fields = greenType.GetFields (flags);
5064 Assert.AreEqual (3, fields.Length, "#G1");
5065 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#G2");
5066 Assert.AreEqual ("publicStaticRed", fields [1].Name, "#G3");
5067 Assert.AreEqual ("publicStaticBlue", fields [2].Name, "#G4");
5069 flags = BindingFlags.Static | BindingFlags.NonPublic |
5070 BindingFlags.FlattenHierarchy;
5071 fields = greenType.GetFields (flags);
5073 Assert.AreEqual (13, fields.Length, "#H1");
5074 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#H2");
5075 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#H3");
5076 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#H4");
5077 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#H5");
5078 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#H6");
5079 Assert.AreEqual ("familyStaticRed", fields [5].Name, "#H7");
5080 Assert.AreEqual ("famANDAssemStaticRed", fields [6].Name, "#H8");
5081 Assert.AreEqual ("famORAssemStaticRed", fields [7].Name, "#H9");
5082 Assert.AreEqual ("assemblyStaticRed", fields [8].Name, "#H10");
5083 Assert.AreEqual ("familyStaticBlue", fields [9].Name, "#H11");
5084 Assert.AreEqual ("famANDAssemStaticBlue", fields [10].Name, "#H12");
5085 Assert.AreEqual ("famORAssemStaticBlue", fields [11].Name, "#H13");
5086 Assert.AreEqual ("assemblyStaticBlue", fields [12].Name, "#H14");
5088 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5089 BindingFlags.DeclaredOnly;
5090 fields = greenType.GetFields (flags);
5092 Assert.AreEqual (5, fields.Length, "#I1");
5093 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#I2");
5094 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#I3");
5095 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#I4");
5096 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#I5");
5097 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#I6");
5099 flags = BindingFlags.Instance | BindingFlags.Public |
5100 BindingFlags.DeclaredOnly;
5101 fields = greenType.GetFields (flags);
5103 Assert.AreEqual (1, fields.Length, "#J1");
5104 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#J2");
5106 flags = BindingFlags.Static | BindingFlags.Public |
5107 BindingFlags.DeclaredOnly;
5108 fields = greenType.GetFields (flags);
5110 Assert.AreEqual (1, fields.Length, "#K1");
5111 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#K2");
5113 flags = BindingFlags.Static | BindingFlags.NonPublic |
5114 BindingFlags.DeclaredOnly;
5115 fields = greenType.GetFields (flags);
5117 Assert.AreEqual (5, fields.Length, "#L1");
5118 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#L2");
5119 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#L3");
5120 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#L4");
5121 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#L5");
5122 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#L6");
5124 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5125 BindingFlags.Public;
5126 fields = greenType.GetFields (flags);
5128 Assert.AreEqual (16, fields.Length, "#M1");
5129 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#M2");
5130 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#M3");
5131 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#M4");
5132 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#M5");
5133 Assert.AreEqual ("publicInstanceGreen", fields [4].Name, "#M6");
5134 Assert.AreEqual ("assemblyInstanceGreen", fields [5].Name, "#M7");
5135 Assert.AreEqual ("familyInstanceRed", fields [6].Name, "#M8");
5136 Assert.AreEqual ("famANDAssemInstanceRed", fields [7].Name, "#M9");
5137 Assert.AreEqual ("famORAssemInstanceRed", fields [8].Name, "#M10");
5138 Assert.AreEqual ("publicInstanceRed", fields [9].Name, "#M11");
5139 Assert.AreEqual ("assemblyInstanceRed", fields [10].Name, "#M12");
5140 Assert.AreEqual ("familyInstanceBlue", fields [11].Name, "#M13");
5141 Assert.AreEqual ("famANDAssemInstanceBlue", fields [12].Name, "#M14");
5142 Assert.AreEqual ("famORAssemInstanceBlue", fields [13].Name, "#M15");
5143 Assert.AreEqual ("publicInstanceBlue", fields [14].Name, "#M16");
5144 Assert.AreEqual ("assemblyInstanceBlue", fields [15].Name, "#M17");
5146 flags = BindingFlags.Static | BindingFlags.NonPublic |
5147 BindingFlags.Public;
5148 fields = greenType.GetFields (flags);
5150 Assert.AreEqual (6, fields.Length, "#N1");
5151 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#N2");
5152 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#N3");
5153 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#N4");
5154 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#N5");
5155 Assert.AreEqual ("publicStaticGreen", fields [4].Name, "#N6");
5156 Assert.AreEqual ("assemblyStaticGreen", fields [5].Name, "#N7");
5160 [Category ("NotWorking")] // mcs depends on this
5161 public void TestGetFieldIncomplete_MS ()
5163 TypeBuilder tb = module.DefineType (genTypeName ());
5164 tb.DefineField ("test", typeof (int), FieldAttributes.Public);
5166 tb.GetField ("test");
5168 } catch (NotSupportedException ex) {
5169 // The invoked member is not supported in a
5171 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5172 Assert.IsNull (ex.InnerException, "#3");
5173 Assert.IsNotNull (ex.Message, "#4");
5178 [Category ("NotDotNet")] // mcs depends on this
5179 public void TestGetFieldIncomplete_Mono ()
5181 TypeBuilder tb = module.DefineType (genTypeName ());
5182 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5183 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5185 FieldInfo field = tb.GetField ("TestField");
5186 Assert.IsNotNull (field, "#A1");
5187 Assert.AreEqual ("TestField", field.Name, "#A2");
5188 Assert.IsTrue (field is FieldBuilder, "#A3");
5190 Assert.IsNull (tb.GetField ("OtherField"), "#B1");
5191 Assert.IsNull (tb.GetField ("TestOtherField"), "#B2");
5195 public void TestGetFieldComplete ()
5197 TypeBuilder tb = module.DefineType (genTypeName ());
5198 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5200 Type emittedType = tb.CreateType ();
5202 FieldInfo dynamicField = tb.GetField ("TestField");
5203 FieldInfo emittedField = emittedType.GetField ("TestField");
5204 Assert.IsNotNull (dynamicField, "#A1");
5205 Assert.AreEqual (dynamicField.Name, emittedField.Name, "#A2");
5206 Assert.IsNull (tb.GetField ("TestOtherField"), "#A3");
5207 Assert.IsFalse (emittedField is FieldBuilder, "#A4");
5208 Assert.IsFalse (dynamicField is FieldBuilder, "#A5");
5211 object value = Activator.CreateInstance (emittedType);
5212 emittedField.SetValue (value, 5);
5213 Assert.AreEqual (5, emittedField.GetValue (value), "#B1");
5214 Assert.AreEqual (5, dynamicField.GetValue (value), "#B2");
5215 dynamicField.SetValue (value, 4);
5216 Assert.AreEqual (4, emittedField.GetValue (value), "#B3");
5217 Assert.AreEqual (4, dynamicField.GetValue (value), "#B4");
5220 [Test] // bug #81640
5221 public void TestGetFieldComplete_Type ()
5223 TypeBuilder tb = module.DefineType (genTypeName ());
5224 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5225 Type emittedType = tb.CreateType ();
5226 FieldInfo dynamicField = tb.GetField ("TestField");
5227 Assert.IsFalse (dynamicField is FieldBuilder, "#1");
5229 object value = Activator.CreateInstance (emittedType);
5230 Assert.AreEqual (0, dynamicField.GetValue (value), "#2");
5234 [Category ("NotWorking")] // mcs depends on this
5235 public void TestGetFieldFlagsIncomplete_MS ()
5237 TypeBuilder tb = module.DefineType (genTypeName ());
5238 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5239 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5241 tb.GetField ("test", BindingFlags.Public);
5243 } catch (NotSupportedException ex) {
5244 // The invoked member is not supported in a
5246 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5247 Assert.IsNull (ex.InnerException, "#3");
5248 Assert.IsNotNull (ex.Message, "#4");
5253 [Category ("NotDotNet")] // mcs depends on this
5254 public void TestGetFieldFlagsIncomplete_Mono ()
5256 TypeBuilder tb = module.DefineType (genTypeName ());
5257 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5258 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5260 FieldInfo field = tb.GetField ("TestField", BindingFlags.Public
5261 | BindingFlags.Instance);
5262 Assert.IsNotNull (field, "#A1");
5263 Assert.AreEqual ("TestField", field.Name, "#A2");
5264 Assert.IsTrue (field is FieldBuilder, "#A3");
5266 field = tb.GetField ("OtherField", BindingFlags.NonPublic |
5267 BindingFlags.Instance);
5268 Assert.IsNotNull (field, "#B1");
5269 Assert.AreEqual ("OtherField", field.Name, "#B2");
5270 Assert.IsTrue (field is FieldBuilder, "#B3");
5272 Assert.IsNull (tb.GetField ("TestField", BindingFlags.NonPublic |
5273 BindingFlags.Instance), "#C1");
5274 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Public |
5275 BindingFlags.Static), "#C2");
5276 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5277 BindingFlags.Instance), "#C3");
5278 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5279 BindingFlags.Static), "#C4");
5280 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.NonPublic |
5281 BindingFlags.Instance), "#C5");
5282 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.Public |
5283 BindingFlags.Instance), "#C6");
5287 public void TestGetFieldFlagsComplete ()
5289 TypeBuilder tb = module.DefineType (genTypeName ());
5290 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5292 Type emittedType = tb.CreateType ();
5294 Assert.IsNotNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public));
5295 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name,
5296 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name);
5297 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5298 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic),
5299 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5303 public void TestGetFieldFlagsComplete_Inheritance ()
5307 TypeBuilder blueType = module.DefineType (genTypeName (),
5308 TypeAttributes.Public);
5309 CreateMembers (blueType, "Blue", false);
5311 TypeBuilder redType = module.DefineType (genTypeName (),
5312 TypeAttributes.Public, blueType);
5313 CreateMembers (redType, "Red", false);
5315 TypeBuilder greenType = module.DefineType (genTypeName (),
5316 TypeAttributes.Public, redType);
5317 CreateMembers (greenType, "Green", false);
5319 blueType.CreateType ();
5320 redType.CreateType ();
5321 greenType.CreateType ();
5323 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5325 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#A1");
5326 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#A2");
5327 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#A3");
5328 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#A4");
5329 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#A5");
5330 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#A6");
5331 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#A7");
5332 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#A8");
5333 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#A9");
5334 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#A10");
5335 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#A11");
5336 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#A12");
5337 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#A13");
5338 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#A14");
5339 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#A15");
5340 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#A16");
5341 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#A17");
5342 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#A18");
5343 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#A19");
5344 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#A20");
5345 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#A21");
5346 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#A22");
5347 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#A23");
5348 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#A24");
5349 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#A25");
5350 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#A26");
5351 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#A27");
5352 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#A28");
5353 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#A29");
5354 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#A30");
5355 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#A31");
5356 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#A32");
5357 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#A33");
5358 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#A34");
5359 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#A35");
5360 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#A36");
5362 flags = BindingFlags.Instance | BindingFlags.Public;
5364 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#B1");
5365 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#B2");
5366 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#B3");
5367 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#B4");
5368 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#B5");
5369 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#B6");
5370 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#B7");
5371 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#B8");
5372 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#B9");
5373 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#B10");
5374 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#B11");
5375 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#B12");
5376 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#B13");
5377 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#B14");
5378 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#B15");
5379 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#B16");
5380 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#B17");
5381 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#B18");
5382 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#B19");
5383 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#B20");
5384 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#B21");
5385 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#B22");
5386 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#B23");
5387 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#B24");
5388 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#B25");
5389 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#B26");
5390 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#B27");
5391 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#B28");
5392 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#B29");
5393 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#B30");
5394 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#B31");
5395 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#B32");
5396 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#B33");
5397 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#B34");
5398 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#B35");
5399 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#B36");
5401 flags = BindingFlags.Static | BindingFlags.Public;
5403 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#C1");
5404 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#C2");
5405 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#C3");
5406 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#C4");
5407 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#C5");
5408 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#C6");
5409 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#C7");
5410 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#C8");
5411 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#C9");
5412 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#C10");
5413 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#C11");
5414 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#C12");
5415 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#C13");
5416 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#C14");
5417 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#C15");
5418 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#C16");
5419 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#C17");
5420 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#C18");
5421 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#C19");
5422 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#C20");
5423 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#C21");
5424 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#C22");
5425 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#C23");
5426 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#C24");
5427 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#C25");
5428 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#C26");
5429 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#C27");
5430 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#C28");
5431 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#C29");
5432 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#C30");
5433 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#C31");
5434 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#C32");
5435 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#C33");
5436 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#C34");
5437 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#C35");
5438 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#C36");
5440 flags = BindingFlags.Static | BindingFlags.NonPublic;
5442 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#D1");
5443 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#D2");
5444 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#D3");
5445 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#D4");
5446 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#D5");
5447 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#D6");
5448 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#D7");
5449 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#D8");
5450 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#D9");
5451 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#D10");
5452 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#D11");
5453 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#D12");
5454 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#D13");
5455 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#D14");
5456 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#D15");
5457 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#D16");
5458 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#D17");
5459 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#D18");
5460 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#D19");
5461 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#D20");
5462 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#D21");
5463 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#D22");
5464 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#D23");
5465 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#D24");
5466 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#D25");
5467 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#D26");
5468 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#D27");
5469 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#D28");
5470 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#D29");
5471 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#D30");
5472 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#D31");
5473 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#D32");
5474 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#D33");
5475 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#D34");
5476 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#D35");
5477 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#D36");
5479 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5480 BindingFlags.FlattenHierarchy;
5482 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#E1");
5483 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#E2");
5484 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#E3");
5485 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#E4");
5486 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#E5");
5487 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#E6");
5488 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#E7");
5489 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#E8");
5490 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#E9");
5491 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#E10");
5492 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#E11");
5493 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#E12");
5494 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#E13");
5495 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#E14");
5496 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#E15");
5497 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#E16");
5498 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#E17");
5499 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#E18");
5500 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#E19");
5501 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#E20");
5502 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#E21");
5503 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#E22");
5504 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#E23");
5505 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#E24");
5506 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#E25");
5507 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#E26");
5508 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#E27");
5509 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#E28");
5510 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#E29");
5511 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#E30");
5512 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#E31");
5513 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#E32");
5514 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#E33");
5515 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#E34");
5516 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#E35");
5517 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#E36");
5519 flags = BindingFlags.Instance | BindingFlags.Public |
5520 BindingFlags.FlattenHierarchy;
5522 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#F1");
5523 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#F2");
5524 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#F3");
5525 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#F4");
5526 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#F5");
5527 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#F6");
5528 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#F7");
5529 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#F8");
5530 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#F9");
5531 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#F10");
5532 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#F11");
5533 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#F12");
5534 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#F13");
5535 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#F14");
5536 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#F15");
5537 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#F16");
5538 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#F17");
5539 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#F18");
5540 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#F19");
5541 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#F20");
5542 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#F21");
5543 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#F22");
5544 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#F23");
5545 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#F24");
5546 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#F25");
5547 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#F26");
5548 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#F27");
5549 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#F28");
5550 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#F29");
5551 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#F30");
5552 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#F31");
5553 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#F32");
5554 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#F33");
5555 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#F34");
5556 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#F35");
5557 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#F36");
5559 flags = BindingFlags.Static | BindingFlags.Public |
5560 BindingFlags.FlattenHierarchy;
5562 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#G1");
5563 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#G2");
5564 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#G3");
5565 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#G4");
5566 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#G5");
5567 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#G6");
5568 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#G7");
5569 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#G8");
5570 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#G9");
5571 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#G10");
5572 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#G11");
5573 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#G12");
5574 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#G13");
5575 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#G14");
5576 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#G15");
5577 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#G16");
5578 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#G17");
5579 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#G18");
5580 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#G19");
5581 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#G20");
5582 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#G21");
5583 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#G22");
5584 Assert.IsNotNull (greenType.GetField ("publicStaticBlue", flags), "#G23");
5585 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#G24");
5586 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#G25");
5587 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#G26");
5588 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#G27");
5589 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#G28");
5590 Assert.IsNotNull (greenType.GetField ("publicStaticRed", flags), "#G29");
5591 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#G30");
5592 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#G31");
5593 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#G32");
5594 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#G33");
5595 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#G34");
5596 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#G35");
5597 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#G36");
5599 flags = BindingFlags.Static | BindingFlags.NonPublic |
5600 BindingFlags.FlattenHierarchy;
5602 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#H1");
5603 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#H2");
5604 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#H3");
5605 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#H4");
5606 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#H5");
5607 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#H6");
5608 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#H7");
5609 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#H8");
5610 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#H9");
5611 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#H10");
5612 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#H11");
5613 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#H12");
5614 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#H13");
5615 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#H14");
5616 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#H15");
5617 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#H16");
5618 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#H17");
5619 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#H18");
5620 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#H19");
5621 Assert.IsNotNull (greenType.GetField ("familyStaticBlue", flags), "#H20");
5622 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#H21");
5623 Assert.IsNotNull (greenType.GetField ("famORAssemStaticBlue", flags), "#H22");
5624 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#H23");
5625 Assert.IsNotNull (greenType.GetField ("assemblyStaticBlue", flags), "#H24");
5626 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#H25");
5627 Assert.IsNotNull (greenType.GetField ("familyStaticRed", flags), "#H26");
5628 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticRed", flags), "#H27");
5629 Assert.IsNotNull (greenType.GetField ("famORAssemStaticRed", flags), "#H28");
5630 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#H29");
5631 Assert.IsNotNull (greenType.GetField ("assemblyStaticRed", flags), "#H30");
5632 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#H31");
5633 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#H32");
5634 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#H33");
5635 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#H34");
5636 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#H35");
5637 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#H36");
5639 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5640 BindingFlags.DeclaredOnly;
5642 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#I1");
5643 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#I2");
5644 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#I3");
5645 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#I4");
5646 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#I5");
5647 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#I6");
5648 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#I7");
5649 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#I8");
5650 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#I9");
5651 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#I10");
5652 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#I11");
5653 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#I12");
5654 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#I13");
5655 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#I14");
5656 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#I15");
5657 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#I16");
5658 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#I17");
5659 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#I18");
5660 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#I19");
5661 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#I20");
5662 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#I21");
5663 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#I22");
5664 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#I23");
5665 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#I24");
5666 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#I25");
5667 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#I26");
5668 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#I27");
5669 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#I28");
5670 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#I29");
5671 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#I30");
5672 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#I31");
5673 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#I32");
5674 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#I33");
5675 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#I34");
5676 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#I35");
5677 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#I36");
5679 flags = BindingFlags.Instance | BindingFlags.Public |
5680 BindingFlags.DeclaredOnly;
5682 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#J1");
5683 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#J2");
5684 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#J3");
5685 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#J4");
5686 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#J5");
5687 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#J6");
5688 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#J7");
5689 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#J8");
5690 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#J9");
5691 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#J10");
5692 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#J11");
5693 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#J12");
5694 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#J13");
5695 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#J14");
5696 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#J15");
5697 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#J16");
5698 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#J17");
5699 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#J18");
5700 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#J19");
5701 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#J20");
5702 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#J21");
5703 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#J22");
5704 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#J23");
5705 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#J24");
5706 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#J25");
5707 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#J26");
5708 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#J27");
5709 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#J28");
5710 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#J29");
5711 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#J30");
5712 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#J31");
5713 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#J32");
5714 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#J33");
5715 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#J34");
5716 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#J35");
5717 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#J36");
5719 flags = BindingFlags.Static | BindingFlags.Public |
5720 BindingFlags.DeclaredOnly;
5722 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#K1");
5723 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#K2");
5724 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#K3");
5725 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#K4");
5726 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#K5");
5727 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#K6");
5728 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#K7");
5729 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#K8");
5730 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#K9");
5731 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#K10");
5732 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#K11");
5733 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#K12");
5734 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#K13");
5735 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#K14");
5736 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#K15");
5737 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#K16");
5738 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#K17");
5739 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#K18");
5740 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#K19");
5741 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#K20");
5742 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#K21");
5743 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#K22");
5744 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#K23");
5745 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#K24");
5746 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#K25");
5747 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#K26");
5748 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#K27");
5749 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#K28");
5750 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#K29");
5751 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#K30");
5752 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#K31");
5753 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#K32");
5754 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#K33");
5755 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#K34");
5756 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#K35");
5757 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#K36");
5759 flags = BindingFlags.Static | BindingFlags.NonPublic |
5760 BindingFlags.DeclaredOnly;
5762 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#L1");
5763 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#L2");
5764 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#L3");
5765 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#L4");
5766 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#L5");
5767 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#L6");
5768 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#L7");
5769 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#L8");
5770 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#L9");
5771 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#L10");
5772 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#L11");
5773 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#L12");
5774 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#L13");
5775 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#L14");
5776 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#L15");
5777 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#L16");
5778 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#L17");
5779 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#L18");
5780 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#L19");
5781 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#L20");
5782 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#L21");
5783 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#L22");
5784 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#L23");
5785 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#L24");
5786 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#L25");
5787 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#L26");
5788 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#L27");
5789 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#L28");
5790 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#L29");
5791 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#L30");
5792 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#L31");
5793 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#L32");
5794 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#L33");
5795 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#L34");
5796 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#L35");
5797 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#L36");
5799 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5800 BindingFlags.Public;
5802 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#M1");
5803 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#M2");
5804 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#M3");
5805 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#M4");
5806 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#M5");
5807 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#M6");
5808 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#M7");
5809 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#M8");
5810 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#M9");
5811 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#M10");
5812 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#M11");
5813 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#M12");
5814 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#M13");
5815 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#M14");
5816 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#M15");
5817 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#M16");
5818 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#M17");
5819 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#M18");
5820 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#M19");
5821 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#M20");
5822 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#M21");
5823 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#M22");
5824 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#M23");
5825 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#M24");
5826 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#M25");
5827 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#M26");
5828 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#M27");
5829 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#M28");
5830 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#M29");
5831 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#M30");
5832 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#M31");
5833 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#M32");
5834 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#M33");
5835 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#M34");
5836 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#M35");
5837 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#M36");
5839 flags = BindingFlags.Static | BindingFlags.NonPublic |
5840 BindingFlags.Public;
5842 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#N1");
5843 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#N2");
5844 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#N3");
5845 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#N4");
5846 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#N5");
5847 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#N6");
5848 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#N7");
5849 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#N8");
5850 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#N9");
5851 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#N10");
5852 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#N11");
5853 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#N12");
5854 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#N13");
5855 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#N14");
5856 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#N15");
5857 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#N16");
5858 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#N17");
5859 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#N18");
5860 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#N19");
5861 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#N20");
5862 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#N21");
5863 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#N22");
5864 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#N23");
5865 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#N24");
5866 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#N25");
5867 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#N26");
5868 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#N27");
5869 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#N28");
5870 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#N29");
5871 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#N30");
5872 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#N31");
5873 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#N32");
5874 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#N33");
5875 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#N34");
5876 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#N35");
5877 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#N36");
5881 [Category ("NotDotNet")] // mcs depends on this
5882 public void TestGetPropertiesIncomplete_Mono ()
5884 TypeBuilder tb = module.DefineType (genTypeName ());
5885 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5886 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5887 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5889 PropertyInfo [] properties = tb.GetProperties ();
5890 Assert.AreEqual (2, properties.Length, "#1");
5891 Assert.AreEqual ("Name", properties [0].Name, "#2");
5892 Assert.AreEqual ("FirstName", properties [1].Name, "#3");
5896 [Category ("NotWorking")] // mcs depends on this
5897 public void TestGetPropertiesIncomplete_MS ()
5899 TypeBuilder tb = module.DefineType (genTypeName ());
5900 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5901 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5902 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5905 tb.GetProperties ();
5907 } catch (NotSupportedException ex) {
5908 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5909 Assert.IsNull (ex.InnerException, "#3");
5910 Assert.IsNotNull (ex.Message, "#4");
5915 public void TestGetPropertiesComplete ()
5917 TypeBuilder tb = module.DefineType (genTypeName ());
5918 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
5920 Type emittedType = tb.CreateType ();
5922 Assert.AreEqual (1, tb.GetProperties ().Length);
5923 Assert.AreEqual (tb.GetProperties ().Length, emittedType.GetProperties ().Length);
5927 [Category ("NotDotNet")] // mcs depends on this
5928 public void TestGetPropertiesFlagsIncomplete_Mono ()
5930 PropertyInfo [] properties;
5932 TypeBuilder tb = module.DefineType (genTypeName ());
5933 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5934 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5935 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5937 properties = tb.GetProperties (BindingFlags.Public |
5938 BindingFlags.NonPublic | BindingFlags.Instance);
5939 Assert.AreEqual (3, properties.Length, "#A1");
5940 Assert.AreEqual ("Name", properties [0].Name, "#A2");
5941 Assert.AreEqual ("Income", properties [1].Name, "#A3");
5942 Assert.AreEqual ("FirstName", properties [2].Name, "#A4");
5944 properties = tb.GetProperties (BindingFlags.Public |
5945 BindingFlags.Instance);
5946 Assert.AreEqual (2, properties.Length, "#B1");
5947 Assert.AreEqual ("Name", properties [0].Name, "#B2");
5948 Assert.AreEqual ("FirstName", properties [1].Name, "#B3");
5950 properties = tb.GetProperties (BindingFlags.NonPublic |
5951 BindingFlags.Instance);
5952 Assert.AreEqual (1, properties.Length, "#C1");
5953 Assert.AreEqual ("Income", properties [0].Name, "#C2");
5957 [Category ("NotWorking")] // mcs depends on this
5958 public void TestGetPropertiesFlagsIncomplete_MS ()
5960 TypeBuilder tb = module.DefineType (genTypeName ());
5961 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5962 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5963 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5966 tb.GetProperties (BindingFlags.Public);
5968 } catch (NotSupportedException ex) {
5969 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5970 Assert.IsNull (ex.InnerException, "#3");
5971 Assert.IsNotNull (ex.Message, "#4");
5976 public void TestGetPropertiesFlagsComplete ()
5978 TypeBuilder tb = module.DefineType (genTypeName ());
5979 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
5981 Type emittedType = tb.CreateType ();
5983 Assert.AreEqual (1, tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
5984 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length,
5985 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
5986 Assert.AreEqual (0, tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
5987 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length,
5988 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
5992 public void TestGetPropertiesFlagsComplete_Inheritance ()
5994 PropertyInfo [] props;
5997 TypeBuilder blueType = module.DefineType (genTypeName (),
5998 TypeAttributes.Public);
5999 CreateMembers (blueType, "Blue", false);
6001 TypeBuilder redType = module.DefineType (genTypeName (),
6002 TypeAttributes.Public, blueType);
6003 CreateMembers (redType, "Red", false);
6005 TypeBuilder greenType = module.DefineType (genTypeName (),
6006 TypeAttributes.Public, redType);
6007 CreateMembers (greenType, "Green", false);
6009 blueType.CreateType ();
6010 redType.CreateType ();
6011 greenType.CreateType ();
6013 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6014 props = greenType.GetProperties (flags);
6016 Assert.AreEqual (13, props.Length, "#A1");
6017 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#A2");
6018 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#A3");
6019 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#A4");
6020 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#A5");
6021 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#A6");
6022 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#A7");
6023 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#A8");
6024 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#A9");
6025 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#A10");
6026 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#A11");
6027 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#A12");
6028 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#A13");
6029 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#A15");
6031 flags = BindingFlags.Instance | BindingFlags.Public;
6032 props = greenType.GetProperties (flags);
6034 Assert.AreEqual (3, props.Length, "#B1");
6035 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#B2");
6036 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#B3");
6037 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#B4");
6039 flags = BindingFlags.Static | BindingFlags.Public;
6040 props = greenType.GetProperties (flags);
6042 Assert.AreEqual (1, props.Length, "#C1");
6043 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#C2");
6045 flags = BindingFlags.Static | BindingFlags.NonPublic;
6046 props = greenType.GetProperties (flags);
6048 Assert.AreEqual (5, props.Length, "#D1");
6049 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#D2");
6050 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#D3");
6051 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#D4");
6052 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#D5");
6053 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#D6");
6055 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6056 BindingFlags.FlattenHierarchy;
6057 props = greenType.GetProperties (flags);
6059 Assert.AreEqual (13, props.Length, "#E1");
6060 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#E2");
6061 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#E3");
6062 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#E4");
6063 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#E5");
6064 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#E6");
6065 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#E7");
6066 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#E8");
6067 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#E9");
6068 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#E10");
6069 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#E11");
6070 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#E12");
6071 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#E13");
6072 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#E14");
6074 flags = BindingFlags.Instance | BindingFlags.Public |
6075 BindingFlags.FlattenHierarchy;
6076 props = greenType.GetProperties (flags);
6078 Assert.AreEqual (3, props.Length, "#F1");
6079 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#F2");
6080 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#F3");
6081 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#F4");
6083 flags = BindingFlags.Static | BindingFlags.Public |
6084 BindingFlags.FlattenHierarchy;
6085 props = greenType.GetProperties (flags);
6087 Assert.AreEqual (3, props.Length, "#G1");
6088 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#G2");
6089 Assert.AreEqual ("PublicStaticRed", props [1].Name, "#G3");
6090 Assert.AreEqual ("PublicStaticBlue", props [2].Name, "#G4");
6092 flags = BindingFlags.Static | BindingFlags.NonPublic |
6093 BindingFlags.FlattenHierarchy;
6094 props = greenType.GetProperties (flags);
6096 Assert.AreEqual (13, props.Length, "#H1");
6097 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#H2");
6098 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#H3");
6099 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#H4");
6100 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#H5");
6101 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#H6");
6102 Assert.AreEqual ("FamilyStaticRed", props [5].Name, "#H7");
6103 Assert.AreEqual ("FamANDAssemStaticRed", props [6].Name, "#H8");
6104 Assert.AreEqual ("FamORAssemStaticRed", props [7].Name, "#H9");
6105 Assert.AreEqual ("AssemblyStaticRed", props [8].Name, "#H10");
6106 Assert.AreEqual ("FamilyStaticBlue", props [9].Name, "#H11");
6107 Assert.AreEqual ("FamANDAssemStaticBlue", props [10].Name, "#H12");
6108 Assert.AreEqual ("FamORAssemStaticBlue", props [11].Name, "#H13");
6109 Assert.AreEqual ("AssemblyStaticBlue", props [12].Name, "#H14");
6111 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6112 BindingFlags.DeclaredOnly;
6113 props = greenType.GetProperties (flags);
6115 Assert.AreEqual (5, props.Length, "#I1");
6116 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#I2");
6117 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#I3");
6118 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#I4");
6119 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#I5");
6120 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#I6");
6122 flags = BindingFlags.Instance | BindingFlags.Public |
6123 BindingFlags.DeclaredOnly;
6124 props = greenType.GetProperties (flags);
6126 Assert.AreEqual (1, props.Length, "#J1");
6127 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#J2");
6129 flags = BindingFlags.Static | BindingFlags.Public |
6130 BindingFlags.DeclaredOnly;
6131 props = greenType.GetProperties (flags);
6133 Assert.AreEqual (1, props.Length, "#K1");
6134 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#K2");
6136 flags = BindingFlags.Static | BindingFlags.NonPublic |
6137 BindingFlags.DeclaredOnly;
6138 props = greenType.GetProperties (flags);
6140 Assert.AreEqual (5, props.Length, "#L1");
6141 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#L2");
6142 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#L3");
6143 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#L4");
6144 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#L5");
6145 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#L6");
6147 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6148 BindingFlags.Public;
6149 props = greenType.GetProperties (flags);
6151 Assert.AreEqual (16, props.Length, "#M1");
6152 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#M2");
6153 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#M3");
6154 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#M4");
6155 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#M5");
6156 Assert.AreEqual ("PublicInstanceGreen", props [4].Name, "#M6");
6157 Assert.AreEqual ("AssemblyInstanceGreen", props [5].Name, "#M7");
6158 Assert.AreEqual ("FamilyInstanceRed", props [6].Name, "#M8");
6159 Assert.AreEqual ("FamANDAssemInstanceRed", props [7].Name, "#M9");
6160 Assert.AreEqual ("FamORAssemInstanceRed", props [8].Name, "#M10");
6161 Assert.AreEqual ("PublicInstanceRed", props [9].Name, "#M11");
6162 Assert.AreEqual ("AssemblyInstanceRed", props [10].Name, "#M12");
6163 Assert.AreEqual ("FamilyInstanceBlue", props [11].Name, "#M13");
6164 Assert.AreEqual ("FamANDAssemInstanceBlue", props [12].Name, "#M14");
6165 Assert.AreEqual ("FamORAssemInstanceBlue", props [13].Name, "#M15");
6166 Assert.AreEqual ("PublicInstanceBlue", props [14].Name, "#M16");
6167 Assert.AreEqual ("AssemblyInstanceBlue", props [15].Name, "#M17");
6169 flags = BindingFlags.Static | BindingFlags.NonPublic |
6170 BindingFlags.Public;
6171 props = greenType.GetProperties (flags);
6173 Assert.AreEqual (6, props.Length, "#N1");
6174 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#N2");
6175 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#N3");
6176 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#N4");
6177 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#N5");
6178 Assert.AreEqual ("PublicStaticGreen", props [4].Name, "#N6");
6179 Assert.AreEqual ("AssemblyStaticGreen", props [5].Name, "#N7");
6183 public void TestGetPropertyIncomplete ()
6185 TypeBuilder tb = module.DefineType (genTypeName ());
6187 tb.GetProperty ("test");
6189 } catch (NotSupportedException ex) {
6190 // The invoked member is not supported in a
6192 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6193 Assert.IsNull (ex.InnerException, "#3");
6194 Assert.IsNotNull (ex.Message, "#4");
6199 public void TestGetPropertyComplete ()
6201 TypeBuilder tb = module.DefineType (genTypeName ());
6202 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6204 Type emittedType = tb.CreateType ();
6206 Assert.IsNotNull (emittedType.GetProperty ("CustomerName"));
6207 Assert.IsNull (emittedType.GetProperty ("OtherCustomerName"));
6210 tb.GetProperty ("CustomerName");
6212 } catch (NotSupportedException ex) {
6213 // The invoked member is not supported in a
6215 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6216 Assert.IsNull (ex.InnerException, "#3");
6217 Assert.IsNotNull (ex.Message, "#4");
6222 public void TestGetPropertyFlagsIncomplete ()
6224 TypeBuilder tb = module.DefineType (genTypeName ());
6226 tb.GetProperty ("test", BindingFlags.Public);
6228 } catch (NotSupportedException ex) {
6229 // The invoked member is not supported in a
6231 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6232 Assert.IsNull (ex.InnerException, "#3");
6233 Assert.IsNotNull (ex.Message, "#4");
6238 public void TestGetPropertyFlagsComplete ()
6240 TypeBuilder tb = module.DefineType (genTypeName ());
6241 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6243 Type emittedType = tb.CreateType ();
6245 Assert.IsNotNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6246 BindingFlags.Public));
6247 Assert.IsNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6248 BindingFlags.NonPublic));
6251 tb.GetProperty ("CustomerName", BindingFlags.Instance | BindingFlags.Public);
6253 } catch (NotSupportedException ex) {
6254 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6255 Assert.IsNull (ex.InnerException, "#3");
6256 Assert.IsNotNull (ex.Message, "#4");
6261 public void TestGetMethodFlagsComplete ()
6265 TypeBuilder blueType = module.DefineType (genTypeName (),
6266 TypeAttributes.Public);
6267 CreateMembers (blueType, "Blue", false);
6269 TypeBuilder redType = module.DefineType (genTypeName (),
6270 TypeAttributes.Public, blueType);
6271 CreateMembers (redType, "Red", false);
6273 TypeBuilder greenType = module.DefineType (genTypeName (),
6274 TypeAttributes.Public, redType);
6275 CreateMembers (greenType, "Green", false);
6277 blueType.CreateType ();
6278 redType.CreateType ();
6279 greenType.CreateType ();
6281 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6283 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#A1");
6284 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#A2");
6285 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#A3");
6286 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#A4");
6287 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#A5");
6288 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#A6");
6289 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#A7");
6290 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#A8");
6291 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#A9");
6292 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#A10");
6293 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#A11");
6294 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#A12");
6295 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#A13");
6296 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#A14");
6297 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#A15");
6298 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#A16");
6299 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#A17");
6300 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#A18");
6301 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#A19");
6302 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#A20");
6303 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#A21");
6304 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#A22");
6305 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#A23");
6306 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#A24");
6307 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#A25");
6308 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#A26");
6309 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#A27");
6310 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#A28");
6311 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#A29");
6312 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#A30");
6313 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#A31");
6314 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#A32");
6315 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#A33");
6316 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#A34");
6317 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#A35");
6318 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#A36");
6320 flags = BindingFlags.Instance | BindingFlags.Public;
6322 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#B1");
6323 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#B2");
6324 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#B3");
6325 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#B4");
6326 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#B5");
6327 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#B6");
6328 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#B7");
6329 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#B8");
6330 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#B9");
6331 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#B10");
6332 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#B11");
6333 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#B12");
6334 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#B13");
6335 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#B14");
6336 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#B15");
6337 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#B16");
6338 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#B17");
6339 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#B18");
6340 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#B19");
6341 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#B20");
6342 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#B21");
6343 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#B22");
6344 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#B23");
6345 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#B24");
6346 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#B25");
6347 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#B26");
6348 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#B27");
6349 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#B28");
6350 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#B29");
6351 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#B30");
6352 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#B31");
6353 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#B32");
6354 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#B33");
6355 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#B34");
6356 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#B35");
6357 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#B36");
6359 flags = BindingFlags.Static | BindingFlags.Public;
6361 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#C1");
6362 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#C2");
6363 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#C3");
6364 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#C4");
6365 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#C5");
6366 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#C6");
6367 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#C7");
6368 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#C8");
6369 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#C9");
6370 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#C10");
6371 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#C11");
6372 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#C12");
6373 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#C13");
6374 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#C14");
6375 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#C15");
6376 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#C16");
6377 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#C17");
6378 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#C18");
6379 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#C19");
6380 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#C20");
6381 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#C21");
6382 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#C22");
6383 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#C23");
6384 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#C24");
6385 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#C25");
6386 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#C26");
6387 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#C27");
6388 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#C28");
6389 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#C29");
6390 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#C30");
6391 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#C31");
6392 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#C32");
6393 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#C33");
6394 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#C34");
6395 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#C35");
6396 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#C36");
6398 flags = BindingFlags.Static | BindingFlags.NonPublic;
6400 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#D1");
6401 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#D2");
6402 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#D3");
6403 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#D4");
6404 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#D5");
6405 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#D6");
6406 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#D7");
6407 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#D8");
6408 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#D9");
6409 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#D10");
6410 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#D11");
6411 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#D12");
6412 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#D13");
6413 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#D14");
6414 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#D15");
6415 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#D16");
6416 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#D17");
6417 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#D18");
6418 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#D19");
6419 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#D20");
6420 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#D21");
6421 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#D22");
6422 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#D23");
6423 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#D24");
6424 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#D25");
6425 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#D26");
6426 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#D27");
6427 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#D28");
6428 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#D29");
6429 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#D30");
6430 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#D31");
6431 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#D32");
6432 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#D33");
6433 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#D34");
6434 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#D35");
6435 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#D36");
6437 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6438 BindingFlags.FlattenHierarchy;
6440 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#E1");
6441 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#E2");
6442 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#E3");
6443 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#E4");
6444 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#E5");
6445 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#E6");
6446 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#E7");
6447 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#E8");
6448 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#E9");
6449 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#E10");
6450 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#E11");
6451 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#E12");
6452 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#E13");
6453 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#E14");
6454 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#E15");
6455 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#E16");
6456 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#E17");
6457 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#E18");
6458 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#E19");
6459 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#E20");
6460 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#E21");
6461 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#E22");
6462 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#E23");
6463 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#E24");
6464 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#E25");
6465 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#E26");
6466 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#E27");
6467 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#E28");
6468 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#E29");
6469 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#E30");
6470 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#E31");
6471 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#E32");
6472 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#E33");
6473 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#E34");
6474 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#E35");
6475 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#E36");
6477 flags = BindingFlags.Instance | BindingFlags.Public |
6478 BindingFlags.FlattenHierarchy;
6480 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#F1");
6481 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#F2");
6482 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#F3");
6483 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#F4");
6484 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#F5");
6485 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#F6");
6486 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#F7");
6487 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#F8");
6488 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#F9");
6489 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#F10");
6490 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#F11");
6491 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#F12");
6492 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#F13");
6493 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#F14");
6494 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#F15");
6495 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#F16");
6496 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#F17");
6497 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#F18");
6498 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#F19");
6499 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#F20");
6500 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#F21");
6501 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#F22");
6502 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#F23");
6503 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#F24");
6504 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#F25");
6505 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#F26");
6506 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#F27");
6507 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#F28");
6508 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#F29");
6509 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#F30");
6510 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#F31");
6511 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#F32");
6512 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#F33");
6513 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#F34");
6514 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#F35");
6515 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#F36");
6517 flags = BindingFlags.Static | BindingFlags.Public |
6518 BindingFlags.FlattenHierarchy;
6520 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#G1");
6521 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#G2");
6522 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#G3");
6523 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#G4");
6524 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#G5");
6525 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#G6");
6526 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#G7");
6527 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#G8");
6528 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#G9");
6529 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#G10");
6530 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#G11");
6531 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#G12");
6532 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#G13");
6533 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#G14");
6534 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#G15");
6535 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#G16");
6536 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#G17");
6537 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#G18");
6538 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#G19");
6539 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#G20");
6540 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#G21");
6541 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#G22");
6542 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#G23");
6543 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#G24");
6544 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#G25");
6545 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#G26");
6546 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#G27");
6547 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#G28");
6548 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#G29");
6549 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#G30");
6550 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#G31");
6551 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#G32");
6552 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#G33");
6553 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#G34");
6554 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#G35");
6555 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#G36");
6557 flags = BindingFlags.Static | BindingFlags.NonPublic |
6558 BindingFlags.FlattenHierarchy;
6560 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#H1");
6561 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#H2");
6562 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#H3");
6563 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#H4");
6564 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#H5");
6565 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#H6");
6566 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#H7");
6567 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#H8");
6568 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#H9");
6569 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#H10");
6570 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#H11");
6571 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#H12");
6572 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#H13");
6573 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#H14");
6574 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#H15");
6575 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#H16");
6576 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#H17");
6577 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#H18");
6578 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#H19");
6579 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#H20");
6580 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#H21");
6581 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#H22");
6582 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#H23");
6583 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#H24");
6584 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#H25");
6585 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#H26");
6586 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#H27");
6587 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#H28");
6588 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#H29");
6589 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#H30");
6590 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#H31");
6591 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#H32");
6592 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#H33");
6593 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#H34");
6594 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#H35");
6595 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#H36");
6597 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6598 BindingFlags.DeclaredOnly;
6600 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#I1");
6601 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#I2");
6602 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#I3");
6603 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#I4");
6604 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#I5");
6605 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#I6");
6606 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#I7");
6607 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#I8");
6608 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#I9");
6609 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#I10");
6610 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#I11");
6611 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#I12");
6612 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#I13");
6613 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#I14");
6614 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#I15");
6615 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#I16");
6616 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#I17");
6617 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#I18");
6618 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#I19");
6619 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#I20");
6620 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#I21");
6621 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#I22");
6622 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#I23");
6623 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#I24");
6624 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#I25");
6625 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#I26");
6626 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#I27");
6627 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#I28");
6628 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#I29");
6629 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#I30");
6630 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#I31");
6631 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#I32");
6632 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#I33");
6633 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#I34");
6634 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#I35");
6635 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#I36");
6637 flags = BindingFlags.Instance | BindingFlags.Public |
6638 BindingFlags.DeclaredOnly;
6640 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#J1");
6641 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#J2");
6642 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#J3");
6643 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#J4");
6644 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#J5");
6645 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#J6");
6646 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#J7");
6647 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#J8");
6648 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#J9");
6649 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#J10");
6650 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#J11");
6651 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#J12");
6652 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#J13");
6653 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#J14");
6654 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#J15");
6655 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#J16");
6656 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#J17");
6657 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#J18");
6658 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#J19");
6659 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#J20");
6660 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#J21");
6661 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#J22");
6662 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#J23");
6663 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#J24");
6664 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#J25");
6665 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#J26");
6666 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#J27");
6667 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#J28");
6668 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#J29");
6669 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#J30");
6670 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#J31");
6671 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#J32");
6672 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#J33");
6673 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#J34");
6674 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#J35");
6675 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#J36");
6677 flags = BindingFlags.Static | BindingFlags.Public |
6678 BindingFlags.DeclaredOnly;
6680 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#K1");
6681 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#K2");
6682 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#K3");
6683 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#K4");
6684 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#K5");
6685 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#K6");
6686 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#K7");
6687 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#K8");
6688 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#K9");
6689 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#K10");
6690 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#K11");
6691 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#K12");
6692 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#K13");
6693 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#K14");
6694 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#K15");
6695 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#K16");
6696 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#K17");
6697 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#K18");
6698 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#K19");
6699 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#K20");
6700 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#K21");
6701 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#K22");
6702 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#K23");
6703 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#K24");
6704 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#K25");
6705 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#K26");
6706 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#K27");
6707 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#K28");
6708 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#K29");
6709 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#K30");
6710 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#K31");
6711 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#K32");
6712 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#K33");
6713 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#K34");
6714 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#K35");
6715 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#K36");
6717 flags = BindingFlags.Static | BindingFlags.NonPublic |
6718 BindingFlags.DeclaredOnly;
6720 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#L1");
6721 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#L2");
6722 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#L3");
6723 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#L4");
6724 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#L5");
6725 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#L6");
6726 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#L7");
6727 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#L8");
6728 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#L9");
6729 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#L10");
6730 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#L11");
6731 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#L12");
6732 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#L13");
6733 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#L14");
6734 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#L15");
6735 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#L16");
6736 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#L17");
6737 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#L18");
6738 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#L19");
6739 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#L20");
6740 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#L21");
6741 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#L22");
6742 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#L23");
6743 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#L24");
6744 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#L25");
6745 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#L26");
6746 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#L27");
6747 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#L28");
6748 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#L29");
6749 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#L30");
6750 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#L31");
6751 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#L32");
6752 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#L33");
6753 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#L34");
6754 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#L35");
6755 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#L36");
6757 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6758 BindingFlags.Public;
6760 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#M1");
6761 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#M2");
6762 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#M3");
6763 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#M4");
6764 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#M5");
6765 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#M6");
6766 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#M7");
6767 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#M8");
6768 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#M9");
6769 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#M10");
6770 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#M11");
6771 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#M12");
6772 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#M13");
6773 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#M14");
6774 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#M15");
6775 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#M16");
6776 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#M17");
6777 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#M18");
6778 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#M19");
6779 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#M20");
6780 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#M21");
6781 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#M22");
6782 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#M23");
6783 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#M24");
6784 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#M25");
6785 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#M26");
6786 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#M27");
6787 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#M28");
6788 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#M29");
6789 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#M30");
6790 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#M31");
6791 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#M32");
6792 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#M33");
6793 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#M34");
6794 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#M35");
6795 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#M36");
6797 flags = BindingFlags.Static | BindingFlags.NonPublic |
6798 BindingFlags.Public;
6800 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#N1");
6801 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#N2");
6802 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#N3");
6803 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#N4");
6804 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#N5");
6805 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#N6");
6806 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#N7");
6807 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#N8");
6808 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#N9");
6809 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#N10");
6810 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#N11");
6811 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#N12");
6812 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#N13");
6813 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#N14");
6814 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#N15");
6815 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#N16");
6816 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#N17");
6817 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#N18");
6818 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#N19");
6819 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#N20");
6820 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#N21");
6821 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#N22");
6822 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#N23");
6823 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#N24");
6824 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#N25");
6825 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#N26");
6826 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#N27");
6827 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#N28");
6828 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#N29");
6829 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#N30");
6830 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#N31");
6831 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#N32");
6832 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#N33");
6833 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#N34");
6834 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#N35");
6835 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#N36");
6839 [Category ("NotDotNet")] // mcs depends on this
6840 public void TestGetMethodsIncomplete_Mono ()
6845 TypeBuilder tb = module.DefineType (genTypeName (),
6846 TypeAttributes.Abstract);
6847 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6848 typeof (void), Type.EmptyTypes);
6849 ilgen = mb.GetILGenerator ();
6850 ilgen.Emit (OpCodes.Ret);
6852 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6853 typeof (void), Type.EmptyTypes);
6854 ilgen = mb.GetILGenerator ();
6855 ilgen.Emit (OpCodes.Ret);
6857 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6858 MethodAttributes.Static,
6859 typeof (void), Type.EmptyTypes);
6860 ilgen = mb.GetILGenerator ();
6861 ilgen.Emit (OpCodes.Ret);
6863 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6864 MethodAttributes.Abstract | MethodAttributes.Virtual,
6865 typeof (void), Type.EmptyTypes);
6867 MethodInfo [] methods = tb.GetMethods ();
6868 Assert.AreEqual (7, methods.Length, "#A");
6870 Assert.AreEqual ("Equals", methods [0].Name, "#B1");
6871 Assert.IsFalse (methods [0].IsStatic, "#B2");
6872 Assert.IsFalse (methods [0].IsAbstract, "#B3");
6874 Assert.AreEqual ("GetHashCode", methods [1].Name, "#C1");
6875 Assert.IsFalse (methods [1].IsStatic, "#C2");
6876 Assert.IsFalse (methods [1].IsAbstract, "#C3");
6878 Assert.AreEqual ("GetType", methods [2].Name, "#D1");
6879 Assert.IsFalse (methods [2].IsStatic, "#D2");
6880 Assert.IsFalse (methods [2].IsAbstract, "#D3");
6882 Assert.AreEqual ("ToString", methods [3].Name, "#E1");
6883 Assert.IsFalse (methods [3].IsStatic, "#E2");
6884 Assert.IsFalse (methods [3].IsAbstract, "#E3");
6886 Assert.AreEqual ("Hello", methods [4].Name, "#F1");
6887 Assert.IsFalse (methods [4].IsStatic, "#F2");
6888 Assert.IsFalse (methods [4].IsAbstract, "#F3");
6890 Assert.AreEqual ("Execute", methods [5].Name, "#G1");
6891 Assert.IsTrue (methods [5].IsStatic, "#G2");
6892 Assert.IsFalse (methods [5].IsAbstract, "#G3");
6894 Assert.AreEqual ("Init", methods [6].Name, "#H1");
6895 Assert.IsFalse (methods [6].IsStatic, "#H2");
6896 Assert.IsTrue (methods [6].IsAbstract, "#H3");
6900 [Category ("NotWorking")] // mcs depends on this
6901 public void TestGetMethodsIncomplete_MS ()
6906 TypeBuilder tb = module.DefineType (genTypeName (),
6907 TypeAttributes.Abstract);
6908 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6909 typeof (void), Type.EmptyTypes);
6910 ilgen = mb.GetILGenerator ();
6911 ilgen.Emit (OpCodes.Ret);
6913 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6914 typeof (void), Type.EmptyTypes);
6915 ilgen = mb.GetILGenerator ();
6916 ilgen.Emit (OpCodes.Ret);
6918 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6919 MethodAttributes.Static,
6920 typeof (void), Type.EmptyTypes);
6921 ilgen = mb.GetILGenerator ();
6922 ilgen.Emit (OpCodes.Ret);
6924 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6925 MethodAttributes.Abstract | MethodAttributes.Virtual,
6926 typeof (void), Type.EmptyTypes);
6931 } catch (NotSupportedException ex) {
6932 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6933 Assert.IsNull (ex.InnerException, "#3");
6934 Assert.IsNotNull (ex.Message, "#4");
6939 public void TestGetMethodsComplete ()
6945 TypeBuilder tb = module.DefineType (genTypeName (),
6946 TypeAttributes.Abstract);
6947 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6948 typeof (string), Type.EmptyTypes);
6949 ilgen = mb.GetILGenerator ();
6950 ilgen.Emit (OpCodes.Ldstr, "Hi! ");
6951 ilgen.Emit (OpCodes.Ldarg_1);
6952 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
6953 new Type [] { typeof (string), typeof (string) });
6954 ilgen.Emit (OpCodes.Call, infoMethod);
6955 ilgen.Emit (OpCodes.Ret);
6957 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6958 typeof (void), Type.EmptyTypes);
6959 ilgen = mb.GetILGenerator ();
6960 ilgen.Emit (OpCodes.Ret);
6962 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6963 MethodAttributes.Static,
6964 typeof (void), Type.EmptyTypes);
6965 ilgen = mb.GetILGenerator ();
6966 ilgen.Emit (OpCodes.Ret);
6968 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6969 MethodAttributes.Abstract | MethodAttributes.Virtual,
6970 typeof (void), Type.EmptyTypes);
6972 Type emittedType = tb.CreateType ();
6974 MethodInfo [] methods = emittedType.GetMethods ();
6975 Assert.AreEqual (7, methods.Length, "#A1");
6976 Assert.AreEqual (7, tb.GetMethods ().Length, "#A2");
6978 mi = GetMethodByName (methods, "Hello");
6979 Assert.IsNotNull (mi, "#B1");
6980 Assert.IsFalse (mi.IsStatic, "#B2");
6981 Assert.IsFalse (mi.IsAbstract, "#B3");
6983 mi = GetMethodByName (methods, "Execute");
6984 Assert.IsNotNull (mi, "#C1");
6985 Assert.IsTrue (mi.IsStatic, "#C2");
6986 Assert.IsFalse (mi.IsAbstract, "#C3");
6988 mi = GetMethodByName (methods, "Init");
6989 Assert.IsNotNull (mi, "#D1");
6990 Assert.IsFalse (mi.IsStatic, "#D2");
6991 Assert.IsTrue (mi.IsAbstract, "#D3");
6993 mi = GetMethodByName (methods, "GetType");
6994 Assert.IsNotNull (mi, "#E1");
6995 Assert.IsFalse (methods [3].IsStatic, "#E2");
6996 Assert.IsFalse (methods [3].IsAbstract, "#E3");
6998 mi = GetMethodByName (methods, "ToString");
6999 Assert.IsNotNull (mi, "#F1");
7000 Assert.IsFalse (mi.IsStatic, "#F2");
7001 Assert.IsFalse (mi.IsAbstract, "#F3");
7003 mi = GetMethodByName (methods, "Equals");
7004 Assert.IsNotNull (mi, "#G1");
7005 Assert.IsFalse (mi.IsStatic, "#G2");
7006 Assert.IsFalse (mi.IsAbstract, "#G3");
7008 mi = GetMethodByName (methods, "GetHashCode");
7009 Assert.IsNotNull (mi, "#H1");
7010 Assert.IsFalse (mi.IsStatic, "#H2");
7011 Assert.IsFalse (mi.IsAbstract, "#H3");
7015 [Category ("NotDotNet")] // mcs depends on this
7016 public void TestGetMethodsFlagsIncomplete_Inheritance ()
7018 MethodInfo [] methods;
7021 TypeBuilder blueType = module.DefineType (genTypeName (),
7022 TypeAttributes.Public);
7023 CreateMembers (blueType, "Blue", false);
7025 TypeBuilder redType = module.DefineType (genTypeName (),
7026 TypeAttributes.Public, blueType);
7027 CreateMembers (redType, "Red", false);
7029 TypeBuilder greenType = module.DefineType (genTypeName (),
7030 TypeAttributes.Public, redType);
7031 CreateMembers (greenType, "Green", false);
7033 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7034 methods = greenType.GetMethods (flags);
7036 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7037 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7038 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7039 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7040 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7041 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7042 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7043 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7044 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7045 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7046 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7047 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7048 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7049 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7050 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7051 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7052 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7053 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7054 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7055 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7056 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7057 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7058 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7059 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7060 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7061 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7062 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7063 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7064 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7065 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7066 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7067 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7068 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7069 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7070 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7071 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7073 flags = BindingFlags.Instance | BindingFlags.Public;
7074 methods = greenType.GetMethods (flags);
7076 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7077 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7078 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7079 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7080 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7081 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7082 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7083 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7084 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7085 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7086 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7087 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7088 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7089 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7090 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7091 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7092 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7093 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7094 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7095 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7096 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7097 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7098 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7099 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7100 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7101 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7102 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7103 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7104 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7105 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7106 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7107 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7108 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7109 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7110 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7111 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7113 flags = BindingFlags.Static | BindingFlags.Public;
7114 methods = greenType.GetMethods (flags);
7116 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7117 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7118 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7119 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7120 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7121 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7122 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7123 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7124 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7125 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7126 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7127 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7128 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7129 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7130 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7131 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7132 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7133 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7134 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7135 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7136 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7137 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7138 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7139 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7140 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7141 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7142 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7143 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7144 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7145 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7146 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7147 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7148 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7149 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7150 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7151 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7153 flags = BindingFlags.Static | BindingFlags.NonPublic;
7154 methods = greenType.GetMethods (flags);
7156 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7157 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7158 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7159 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7160 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7161 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7162 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7163 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7164 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7165 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7166 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7167 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7168 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7169 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7170 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7171 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7172 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7173 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7174 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7175 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7176 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7177 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7178 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7179 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7180 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7181 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7182 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7183 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7184 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7185 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7186 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7187 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7188 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7189 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7190 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7191 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7193 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7194 BindingFlags.FlattenHierarchy;
7195 methods = greenType.GetMethods (flags);
7197 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7198 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7199 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7200 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7201 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7202 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7203 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7204 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7205 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7206 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7207 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7208 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7209 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7210 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7211 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7212 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7213 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7214 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7215 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7216 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7217 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7218 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7219 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7220 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7221 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7222 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7223 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7224 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7225 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7226 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7227 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7228 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7229 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7230 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7231 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7232 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7234 flags = BindingFlags.Instance | BindingFlags.Public |
7235 BindingFlags.FlattenHierarchy;
7236 methods = greenType.GetMethods (flags);
7238 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7239 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7240 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7241 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7242 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7243 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7244 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7245 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7246 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7247 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7248 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7249 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7250 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7251 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7252 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7253 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7254 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
7255 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
7256 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
7257 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
7258 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
7259 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
7260 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
7261 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
7262 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
7263 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
7264 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
7265 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
7266 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
7267 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
7268 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
7269 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
7270 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
7271 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
7272 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
7273 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
7275 flags = BindingFlags.Static | BindingFlags.Public |
7276 BindingFlags.FlattenHierarchy;
7277 methods = greenType.GetMethods (flags);
7279 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
7280 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
7281 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
7282 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
7283 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
7284 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
7285 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
7286 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
7287 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
7288 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
7289 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
7290 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
7291 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
7292 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
7293 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
7294 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
7295 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
7296 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
7297 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
7298 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
7299 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
7300 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
7301 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
7302 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
7303 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
7304 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
7305 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
7306 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
7307 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
7308 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
7309 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
7310 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
7311 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
7312 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
7313 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
7314 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
7316 flags = BindingFlags.Static | BindingFlags.NonPublic |
7317 BindingFlags.FlattenHierarchy;
7318 methods = greenType.GetMethods (flags);
7320 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
7321 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
7322 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
7323 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
7324 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
7325 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
7326 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
7327 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
7328 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
7329 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
7330 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
7331 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
7332 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
7333 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
7334 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
7335 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
7336 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
7337 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
7338 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
7339 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
7340 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
7341 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
7342 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
7343 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
7344 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
7345 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
7346 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
7347 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
7348 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
7349 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
7350 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
7351 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
7352 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
7353 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
7354 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
7355 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
7357 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7358 BindingFlags.DeclaredOnly;
7359 methods = greenType.GetMethods (flags);
7361 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
7362 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
7363 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
7364 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
7365 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
7366 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
7367 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
7368 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
7369 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
7370 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
7371 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
7372 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
7373 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
7374 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
7375 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
7376 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
7377 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
7378 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
7379 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
7380 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
7381 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
7382 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
7383 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
7384 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
7385 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
7386 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
7387 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
7388 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
7389 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
7390 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
7391 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
7392 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
7393 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
7394 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
7395 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
7396 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
7398 flags = BindingFlags.Instance | BindingFlags.Public |
7399 BindingFlags.DeclaredOnly;
7400 methods = greenType.GetMethods (flags);
7402 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
7403 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
7404 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
7405 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
7406 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
7407 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
7408 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
7409 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
7410 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
7411 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
7412 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
7413 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
7414 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
7415 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
7416 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
7417 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
7418 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
7419 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
7420 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
7421 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
7422 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
7423 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
7424 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
7425 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
7426 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
7427 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
7428 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
7429 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
7430 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
7431 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
7432 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
7433 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
7434 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
7435 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
7436 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
7437 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
7439 flags = BindingFlags.Static | BindingFlags.Public |
7440 BindingFlags.DeclaredOnly;
7441 methods = greenType.GetMethods (flags);
7443 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
7444 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
7445 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
7446 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
7447 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
7448 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
7449 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
7450 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
7451 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
7452 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
7453 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
7454 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
7455 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
7456 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
7457 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
7458 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
7459 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
7460 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
7461 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
7462 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
7463 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
7464 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
7465 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
7466 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
7467 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
7468 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
7469 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
7470 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
7471 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
7472 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
7473 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
7474 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
7475 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
7476 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
7477 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
7478 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
7480 flags = BindingFlags.Static | BindingFlags.NonPublic |
7481 BindingFlags.DeclaredOnly;
7482 methods = greenType.GetMethods (flags);
7484 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
7485 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
7486 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
7487 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
7488 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
7489 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
7490 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
7491 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
7492 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
7493 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
7494 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
7495 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
7496 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
7497 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
7498 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
7499 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
7500 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
7501 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
7502 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
7503 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
7504 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
7505 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
7506 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
7507 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
7508 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
7509 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
7510 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
7511 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
7512 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
7513 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
7514 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
7515 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
7516 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
7517 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
7518 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
7519 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
7521 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7522 BindingFlags.Public;
7523 methods = greenType.GetMethods (flags);
7525 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
7526 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
7527 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
7528 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
7529 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
7530 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
7531 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
7532 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
7533 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
7534 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
7535 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
7536 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
7537 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
7538 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
7539 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
7540 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
7541 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
7542 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
7543 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
7544 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
7545 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
7546 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
7547 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
7548 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
7549 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
7550 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
7551 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
7552 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
7553 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
7554 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
7555 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
7556 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
7557 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
7558 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
7559 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
7560 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
7562 flags = BindingFlags.Static | BindingFlags.NonPublic |
7563 BindingFlags.Public;
7564 methods = greenType.GetMethods (flags);
7566 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
7567 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
7568 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
7569 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
7570 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
7571 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
7572 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
7573 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
7574 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
7575 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
7576 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
7577 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
7578 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
7579 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
7580 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
7581 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
7582 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
7583 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
7584 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
7585 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
7586 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
7587 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
7588 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
7589 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
7590 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
7591 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
7592 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
7593 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
7594 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
7595 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
7596 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
7597 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
7598 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
7599 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
7600 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
7601 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
7605 [Category ("NotDotNet")] // mcs depends on this
7606 public void TestGetMethodsFlagsIncomplete_Mono ()
7610 MethodInfo [] methods;
7612 TypeBuilder tb = module.DefineType (genTypeName (),
7613 TypeAttributes.Abstract);
7614 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7615 typeof (void), Type.EmptyTypes);
7616 ilgen = mb.GetILGenerator ();
7617 ilgen.Emit (OpCodes.Ret);
7619 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7620 typeof (void), Type.EmptyTypes);
7621 ilgen = mb.GetILGenerator ();
7622 ilgen.Emit (OpCodes.Ret);
7624 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7625 MethodAttributes.Static,
7626 typeof (void), Type.EmptyTypes);
7627 ilgen = mb.GetILGenerator ();
7628 ilgen.Emit (OpCodes.Ret);
7630 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7631 MethodAttributes.Abstract | MethodAttributes.Virtual,
7632 typeof (void), Type.EmptyTypes);
7634 methods = tb.GetMethods (BindingFlags.Public |
7635 BindingFlags.Instance);
7636 Assert.AreEqual (6, methods.Length, "#A1");
7637 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#A2");
7638 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#A3");
7639 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#A4");
7640 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#A5");
7641 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#A6");
7643 methods = tb.GetMethods (BindingFlags.Public |
7644 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7645 Assert.AreEqual (2, methods.Length, "#B1");
7646 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#B2");
7647 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#B3");
7649 methods = tb.GetMethods (BindingFlags.Public |
7650 BindingFlags.Instance | BindingFlags.Static);
7651 Assert.AreEqual (7, methods.Length, "#C1");
7652 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#C2");
7653 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#C3");
7654 Assert.IsNotNull (GetMethodByName (methods, "Execute"), "#C4");
7655 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#C5");
7656 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#C6");
7657 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#C7");
7659 methods = tb.GetMethods (BindingFlags.NonPublic |
7660 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7661 Assert.AreEqual (1, methods.Length, "#D1");
7662 Assert.IsNotNull (GetMethodByName (methods, "Run"), "#D2");
7667 [Category ("NotWorking")] // mcs depends on this
7668 public void TestGetMethodsFlagsIncomplete_MS ()
7673 TypeBuilder tb = module.DefineType (genTypeName (),
7674 TypeAttributes.Abstract);
7675 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7676 typeof (void), Type.EmptyTypes);
7677 ilgen = mb.GetILGenerator ();
7678 ilgen.Emit (OpCodes.Ret);
7680 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7681 typeof (void), Type.EmptyTypes);
7682 ilgen = mb.GetILGenerator ();
7683 ilgen.Emit (OpCodes.Ret);
7685 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7686 MethodAttributes.Static,
7687 typeof (void), Type.EmptyTypes);
7688 ilgen = mb.GetILGenerator ();
7689 ilgen.Emit (OpCodes.Ret);
7691 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7692 MethodAttributes.Abstract | MethodAttributes.Virtual,
7693 typeof (void), Type.EmptyTypes);
7696 tb.GetMethods (BindingFlags.Public | BindingFlags.Instance);
7698 } catch (NotSupportedException ex) {
7699 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
7700 Assert.IsNull (ex.InnerException, "#3");
7701 Assert.IsNotNull (ex.Message, "#4");
7706 public void TestGetMethodsFlagsComplete ()
7708 TypeBuilder tb = module.DefineType (genTypeName ());
7709 MethodBuilder helloMethod = tb.DefineMethod ("HelloMethod",
7710 MethodAttributes.Public, typeof (string), Type.EmptyTypes);
7711 ILGenerator helloMethodIL = helloMethod.GetILGenerator ();
7712 helloMethodIL.Emit (OpCodes.Ldstr, "Hi! ");
7713 helloMethodIL.Emit (OpCodes.Ldarg_1);
7714 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
7715 new Type [] { typeof (string), typeof (string) });
7716 helloMethodIL.Emit (OpCodes.Call, infoMethod);
7717 helloMethodIL.Emit (OpCodes.Ret);
7719 Type emittedType = tb.CreateType ();
7721 Assert.AreEqual (1, tb.GetMethods (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Length, "#1");
7722 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length,
7723 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length, "#2");
7724 Assert.AreEqual (0, tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).Length, "#3");
7725 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length,
7726 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length, "#4");
7730 public void TestGetMethodsFlagsComplete_Inheritance ()
7732 MethodInfo [] methods;
7735 TypeBuilder blueType = module.DefineType (genTypeName (),
7736 TypeAttributes.Public);
7737 CreateMembers (blueType, "Blue", false);
7739 TypeBuilder redType = module.DefineType (genTypeName (),
7740 TypeAttributes.Public, blueType);
7741 CreateMembers (redType, "Red", false);
7743 TypeBuilder greenType = module.DefineType (genTypeName (),
7744 TypeAttributes.Public, redType);
7745 CreateMembers (greenType, "Green", false);
7747 blueType.CreateType ();
7748 redType.CreateType ();
7749 greenType.CreateType ();
7751 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7752 methods = greenType.GetMethods (flags);
7754 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7755 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7756 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7757 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7758 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7759 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7760 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7761 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7762 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7763 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7764 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7765 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7766 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7767 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7768 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7769 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7770 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7771 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7772 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7773 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7774 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7775 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7776 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7777 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7778 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7779 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7780 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7781 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7782 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7783 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7784 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7785 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7786 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7787 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7788 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7789 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7791 flags = BindingFlags.Instance | BindingFlags.Public;
7792 methods = greenType.GetMethods (flags);
7794 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7795 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7796 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7797 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7798 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7799 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7800 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7801 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7802 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7803 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7804 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7805 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7806 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7807 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7808 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7809 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7810 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7811 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7812 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7813 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7814 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7815 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7816 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7817 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7818 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7819 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7820 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7821 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7822 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7823 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7824 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7825 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7826 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7827 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7828 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7829 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7831 flags = BindingFlags.Static | BindingFlags.Public;
7832 methods = greenType.GetMethods (flags);
7834 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7835 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7836 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7837 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7838 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7839 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7840 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7841 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7842 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7843 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7844 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7845 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7846 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7847 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7848 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7849 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7850 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7851 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7852 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7853 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7854 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7855 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7856 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7857 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7858 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7859 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7860 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7861 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7862 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7863 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7864 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7865 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7866 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7867 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7868 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7869 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7871 flags = BindingFlags.Static | BindingFlags.NonPublic;
7872 methods = greenType.GetMethods (flags);
7874 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7875 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7876 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7877 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7878 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7879 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7880 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7881 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7882 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7883 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7884 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7885 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7886 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7887 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7888 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7889 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7890 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7891 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7892 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7893 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7894 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7895 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7896 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7897 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7898 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7899 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7900 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7901 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7902 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7903 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7904 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7905 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7906 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7907 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7908 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7909 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7911 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7912 BindingFlags.FlattenHierarchy;
7913 methods = greenType.GetMethods (flags);
7915 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7916 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7917 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7918 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7919 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7920 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7921 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7922 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7923 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7924 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7925 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7926 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7927 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7928 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7929 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7930 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7931 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7932 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7933 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7934 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7935 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7936 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7937 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7938 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7939 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7940 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7941 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7942 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7943 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7944 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7945 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7946 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7947 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7948 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7949 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7950 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7952 flags = BindingFlags.Instance | BindingFlags.Public |
7953 BindingFlags.FlattenHierarchy;
7954 methods = greenType.GetMethods (flags);
7956 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7957 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7958 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7959 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7960 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7961 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7962 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7963 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7964 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7965 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7966 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7967 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7968 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7969 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7970 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7971 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7972 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
7973 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
7974 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
7975 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
7976 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
7977 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
7978 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
7979 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
7980 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
7981 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
7982 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
7983 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
7984 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
7985 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
7986 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
7987 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
7988 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
7989 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
7990 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
7991 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
7993 flags = BindingFlags.Static | BindingFlags.Public |
7994 BindingFlags.FlattenHierarchy;
7995 methods = greenType.GetMethods (flags);
7997 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
7998 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
7999 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
8000 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
8001 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
8002 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
8003 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
8004 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
8005 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
8006 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
8007 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
8008 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
8009 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
8010 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
8011 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
8012 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
8013 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
8014 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
8015 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
8016 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
8017 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
8018 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
8019 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
8020 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
8021 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
8022 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
8023 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
8024 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
8025 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
8026 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
8027 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
8028 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
8029 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
8030 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
8031 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
8032 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
8034 flags = BindingFlags.Static | BindingFlags.NonPublic |
8035 BindingFlags.FlattenHierarchy;
8036 methods = greenType.GetMethods (flags);
8038 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
8039 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
8040 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
8041 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
8042 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
8043 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
8044 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
8045 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
8046 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
8047 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
8048 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
8049 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
8050 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
8051 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
8052 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
8053 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
8054 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
8055 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
8056 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
8057 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
8058 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
8059 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
8060 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
8061 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
8062 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
8063 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
8064 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
8065 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
8066 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
8067 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
8068 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
8069 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
8070 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
8071 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
8072 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
8073 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
8075 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8076 BindingFlags.DeclaredOnly;
8077 methods = greenType.GetMethods (flags);
8079 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
8080 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
8081 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
8082 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
8083 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
8084 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
8085 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
8086 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
8087 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
8088 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
8089 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
8090 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
8091 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
8092 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
8093 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
8094 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
8095 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
8096 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
8097 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
8098 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
8099 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
8100 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
8101 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
8102 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
8103 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
8104 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
8105 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
8106 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
8107 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
8108 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
8109 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
8110 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
8111 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
8112 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
8113 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
8114 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
8116 flags = BindingFlags.Instance | BindingFlags.Public |
8117 BindingFlags.DeclaredOnly;
8118 methods = greenType.GetMethods (flags);
8120 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
8121 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
8122 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
8123 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
8124 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
8125 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
8126 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
8127 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
8128 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
8129 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
8130 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
8131 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
8132 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
8133 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
8134 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
8135 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
8136 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
8137 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
8138 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
8139 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
8140 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
8141 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
8142 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
8143 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
8144 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
8145 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
8146 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
8147 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
8148 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
8149 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
8150 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
8151 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
8152 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
8153 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
8154 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
8155 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
8157 flags = BindingFlags.Static | BindingFlags.Public |
8158 BindingFlags.DeclaredOnly;
8159 methods = greenType.GetMethods (flags);
8161 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
8162 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
8163 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
8164 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
8165 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
8166 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
8167 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
8168 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
8169 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
8170 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
8171 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
8172 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
8173 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
8174 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
8175 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
8176 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
8177 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
8178 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
8179 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
8180 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
8181 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
8182 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
8183 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
8184 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
8185 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
8186 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
8187 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
8188 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
8189 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
8190 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
8191 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
8192 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
8193 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
8194 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
8195 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
8196 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
8198 flags = BindingFlags.Static | BindingFlags.NonPublic |
8199 BindingFlags.DeclaredOnly;
8200 methods = greenType.GetMethods (flags);
8202 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
8203 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
8204 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
8205 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
8206 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
8207 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
8208 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
8209 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
8210 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
8211 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
8212 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
8213 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
8214 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
8215 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
8216 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
8217 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
8218 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
8219 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
8220 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
8221 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
8222 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
8223 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
8224 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
8225 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
8226 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
8227 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
8228 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
8229 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
8230 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
8231 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
8232 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
8233 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
8234 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
8235 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
8236 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
8237 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
8239 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8240 BindingFlags.Public;
8241 methods = greenType.GetMethods (flags);
8243 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
8244 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
8245 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
8246 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
8247 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
8248 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
8249 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
8250 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
8251 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
8252 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
8253 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
8254 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
8255 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
8256 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
8257 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
8258 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
8259 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
8260 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
8261 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
8262 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
8263 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
8264 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
8265 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
8266 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
8267 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
8268 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
8269 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
8270 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
8271 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
8272 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
8273 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
8274 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
8275 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
8276 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
8277 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
8278 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
8280 flags = BindingFlags.Static | BindingFlags.NonPublic |
8281 BindingFlags.Public;
8282 methods = greenType.GetMethods (flags);
8284 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
8285 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
8286 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
8287 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
8288 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
8289 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
8290 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
8291 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
8292 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
8293 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
8294 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
8295 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
8296 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
8297 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
8298 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
8299 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
8300 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
8301 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
8302 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
8303 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
8304 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
8305 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
8306 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
8307 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
8308 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
8309 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
8310 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
8311 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
8312 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
8313 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
8314 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
8315 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
8316 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
8317 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
8318 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
8319 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
8323 public void TestGetMemberIncomplete ()
8325 TypeBuilder tb = module.DefineType (genTypeName ());
8327 tb.GetMember ("FOO", MemberTypes.All, BindingFlags.Public);
8329 } catch (NotSupportedException ex) {
8330 // The invoked member is not supported in a
8332 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8333 Assert.IsNull (ex.InnerException, "#3");
8334 Assert.IsNotNull (ex.Message, "#4");
8339 public void TestGetMemberComplete ()
8341 TypeBuilder tb = module.DefineType (genTypeName ());
8342 tb.DefineField ("FOO", typeof (int), FieldAttributes.Private);
8344 Type emittedType = tb.CreateType ();
8346 Assert.AreEqual (1, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.NonPublic).Length);
8347 Assert.AreEqual (0, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.Public).Length);
8351 public void TestGetMembersIncomplete ()
8353 TypeBuilder tb = module.DefineType (genTypeName ());
8357 } catch (NotSupportedException ex) {
8358 // The invoked member is not supported in a
8360 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8361 Assert.IsNull (ex.InnerException, "#3");
8362 Assert.IsNotNull (ex.Message, "#4");
8367 public void TestGetMembersComplete ()
8369 TypeBuilder tb = module.DefineType (genTypeName ());
8370 Type emittedType = tb.CreateType ();
8372 Assert.AreEqual (tb.GetMembers ().Length, emittedType.GetMembers ().Length);
8376 public void TestGetMembersFlagsIncomplete ()
8378 TypeBuilder tb = module.DefineType (genTypeName ());
8380 tb.GetMembers (BindingFlags.Public);
8382 } catch (NotSupportedException ex) {
8383 // The invoked member is not supported in a
8385 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8386 Assert.IsNull (ex.InnerException, "#3");
8387 Assert.IsNotNull (ex.Message, "#4");
8392 public void TestGetMembersFlagsComplete ()
8394 TypeBuilder tb = module.DefineType (genTypeName ());
8395 tb.DefineField ("FOO", typeof (int), FieldAttributes.Public);
8397 Type emittedType = tb.CreateType ();
8399 Assert.IsTrue (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length != 0);
8400 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length,
8401 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length);
8402 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length,
8403 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length);
8407 public void TestGetInterfaceIncomplete ()
8409 TypeBuilder tb = module.DefineType (genTypeName ());
8411 tb.GetInterface ("FOO", true);
8413 } catch (NotSupportedException ex) {
8414 // The invoked member is not supported in a
8416 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8417 Assert.IsNull (ex.InnerException, "#3");
8418 Assert.IsNotNull (ex.Message, "#4");
8423 public void TestGetInterfaces ()
8425 TypeBuilder tb = module.DefineType (genTypeName ());
8426 Type [] interfaces = tb.GetInterfaces ();
8427 Assert.AreEqual (0, interfaces.Length);
8429 TypeBuilder tbInterface = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
8430 Type emittedInterface = tbInterface.CreateType ();
8432 tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { emittedInterface });
8433 interfaces = tb.GetInterfaces ();
8434 Assert.AreEqual (1, interfaces.Length);
8438 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8439 public void TestAddDeclarativeSecurityAlreadyCreated ()
8441 TypeBuilder tb = module.DefineType (genTypeName ());
8444 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8446 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8448 } catch (InvalidOperationException ex) {
8449 // Unable to change after type has been created
8450 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8451 Assert.IsNull (ex.InnerException, "#3");
8452 Assert.IsNotNull (ex.Message, "#4");
8457 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8458 public void TestAddDeclarativeSecurityNullPermissionSet ()
8460 TypeBuilder tb = module.DefineType (genTypeName ());
8462 tb.AddDeclarativeSecurity (SecurityAction.Demand, null);
8464 } catch (ArgumentNullException ex) {
8465 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
8466 Assert.IsNull (ex.InnerException, "#3");
8467 Assert.IsNotNull (ex.Message, "#4");
8468 Assert.AreEqual ("pset", ex.ParamName, "#5");
8474 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8475 public void TestAddDeclarativeSecurityInvalidAction ()
8477 TypeBuilder tb = module.DefineType (genTypeName ());
8479 SecurityAction [] actions = new SecurityAction [] {
8480 SecurityAction.RequestMinimum,
8481 SecurityAction.RequestOptional,
8482 SecurityAction.RequestRefuse };
8483 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8485 foreach (SecurityAction action in actions) {
8487 tb.AddDeclarativeSecurity (action, set);
8489 } catch (ArgumentOutOfRangeException) {
8495 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8496 public void TestAddDeclarativeSecurityDuplicateAction ()
8498 TypeBuilder tb = module.DefineType (genTypeName ());
8500 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8501 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8503 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8505 } catch (InvalidOperationException ex) {
8506 // Multiple permission sets specified with the
8507 // same SecurityAction
8508 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8509 Assert.IsNull (ex.InnerException, "#3");
8510 Assert.IsNotNull (ex.Message, "#4");
8515 public void TestEnums ()
8517 TypeAttributes typeAttrs = TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed;
8518 TypeBuilder enumToCreate = module.DefineType (genTypeName (), typeAttrs,
8520 enumToCreate.SetCustomAttribute (new CustomAttributeBuilder (typeof (FlagsAttribute).GetConstructors () [0], Type.EmptyTypes));
8521 // add value__ field, see DefineEnum method of ModuleBuilder
8522 enumToCreate.DefineField ("value__", typeof (Int32),
8523 FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
8526 FieldBuilder fb = enumToCreate.DefineField ("A", enumToCreate,
8527 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8528 fb.SetConstant ((Int32) 0);
8530 fb = enumToCreate.DefineField ("B", enumToCreate,
8531 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8532 fb.SetConstant ((Int32) 1);
8534 fb = enumToCreate.DefineField ("C", enumToCreate,
8535 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8536 fb.SetConstant ((Int32) 2);
8538 Type enumType = enumToCreate.CreateType ();
8540 object enumVal = Enum.ToObject (enumType, (Int32) 3);
8542 Assert.AreEqual ("B, C", enumVal.ToString ());
8543 Assert.AreEqual (3, (Int32) enumVal);
8547 public void DefineEnum ()
8549 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8550 TypeAttributes.Public);
8551 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8552 TypeAttributes.Public, typeof (int));
8553 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8554 enumBuilder.CreateType ();
8555 typeBuilder.CreateType ();
8559 [Category ("NotWorking")]
8560 public void DefineEnumThrowIfTypeBuilderCalledBeforeEnumBuilder ()
8562 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8563 TypeAttributes.Public);
8564 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8565 TypeAttributes.Public, typeof (int));
8566 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8568 typeBuilder.CreateType ();
8570 } catch (TypeLoadException) {
8571 // Could not load type '...' from assembly
8572 // 'MonoTests.System.Reflection.Emit.TypeBuilderTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
8574 Assert.IsTrue (typeBuilder.IsCreated (), "#2");
8575 Assert.IsNull (typeBuilder.CreateType (), "#3");
8579 public void SetCustomAttribute_SuppressUnmanagedCodeSecurity ()
8581 TypeBuilder tb = module.DefineType (genTypeName ());
8582 ConstructorInfo attrCtor = typeof (SuppressUnmanagedCodeSecurityAttribute).
8583 GetConstructor (Type.EmptyTypes);
8584 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
8585 attrCtor, new object [0]);
8586 Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#1");
8587 tb.SetCustomAttribute (caBuilder);
8588 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#2");
8589 Type emittedType = tb.CreateType ();
8590 Assert.AreEqual (TypeAttributes.HasSecurity, emittedType.Attributes & TypeAttributes.HasSecurity, "#3");
8591 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#4");
8592 object [] emittedAttrs = emittedType.GetCustomAttributes (typeof (SuppressUnmanagedCodeSecurityAttribute), true);
8593 Assert.AreEqual (1, emittedAttrs.Length, "#5");
8596 private PropertyBuilder DefineStringProperty (TypeBuilder tb, string propertyName, string fieldName, MethodAttributes methodAttribs)
8598 // define the field holding the property value
8599 FieldBuilder fieldBuilder = tb.DefineField (fieldName,
8600 typeof (string), FieldAttributes.Private);
8602 PropertyBuilder propertyBuilder = tb.DefineProperty (
8603 propertyName, PropertyAttributes.HasDefault, typeof (string),
8604 new Type [] { typeof (string) });
8606 // First, we'll define the behavior of the "get" property for CustomerName as a method.
8607 MethodBuilder getMethodBuilder = tb.DefineMethod ("Get" + propertyName,
8612 ILGenerator getIL = getMethodBuilder.GetILGenerator ();
8614 getIL.Emit (OpCodes.Ldarg_0);
8615 getIL.Emit (OpCodes.Ldfld, fieldBuilder);
8616 getIL.Emit (OpCodes.Ret);
8618 // Now, we'll define the behavior of the "set" property for CustomerName.
8619 MethodBuilder setMethodBuilder = tb.DefineMethod ("Set" + propertyName,
8622 new Type [] { typeof (string) });
8624 ILGenerator setIL = setMethodBuilder.GetILGenerator ();
8626 setIL.Emit (OpCodes.Ldarg_0);
8627 setIL.Emit (OpCodes.Ldarg_1);
8628 setIL.Emit (OpCodes.Stfld, fieldBuilder);
8629 setIL.Emit (OpCodes.Ret);
8631 // Last, we must map the two methods created above to our PropertyBuilder to
8632 // their corresponding behaviors, "get" and "set" respectively.
8633 propertyBuilder.SetGetMethod (getMethodBuilder);
8634 propertyBuilder.SetSetMethod (setMethodBuilder);
8635 return propertyBuilder;
8638 static int handler_called = 0;
8641 public void TestTypeResolve ()
8643 string typeName = genTypeName ();
8645 ResolveEventHandler handler = new ResolveEventHandler (TypeResolve);
8646 AppDomain.CurrentDomain.TypeResolve += handler;
8648 Type t = Type.GetType (typeName);
8649 Assert.AreEqual (typeName, t.Name);
8650 Assert.AreEqual (1, handler_called);
8651 AppDomain.CurrentDomain.TypeResolve -= handler;
8654 Assembly TypeResolve (object sender, ResolveEventArgs args)
8656 TypeBuilder tb = module.DefineType (args.Name, TypeAttributes.Public);
8663 public void IsAssignableFrom_Created ()
8665 TypeBuilder tb = module.DefineType (genTypeName (),
8666 TypeAttributes.Public, typeof (MemoryStream),
8667 new Type [] { typeof (IThrowable), typeof (Bar) });
8668 tb.AddInterfaceImplementation (typeof (IDestroyable));
8669 Type emitted_type = tb.CreateType ();
8671 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8672 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8673 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8674 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8675 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb), "#A5");
8676 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#A6");
8677 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#A7");
8678 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#A8");
8679 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#A9");
8680 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#A10");
8681 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#A11");
8682 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#A12");
8683 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A13");
8684 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A14");
8685 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A15");
8686 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A16");
8687 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A17");
8688 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A18");
8690 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#B1");
8691 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#B2");
8692 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#B3");
8693 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#B4");
8694 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#B5");
8695 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#B6");
8696 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#B7");
8697 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#B8");
8698 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#B9");
8699 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#B10");
8701 Assert.IsTrue (tb.IsAssignableFrom (tb), "#C1");
8702 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#C2");
8703 Assert.IsTrue (tb.IsAssignableFrom (emitted_type), "#C3");
8704 Assert.IsTrue (emitted_type.IsAssignableFrom (tb), "#C4");
8705 Assert.IsFalse (emitted_type.IsAssignableFrom ((Type) null), "#C5");
8707 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type), "#D1");
8708 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IThrowable)), "#D2");
8709 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type), "#D3");
8710 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IMoveable)), "#D4");
8711 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type), "#D5");
8712 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Foo)), "#D6");
8713 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type), "#D7");
8714 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Bar)), "#D8");
8715 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type), "#D9");
8716 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Baz)), "#D10");
8717 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type), "#D11");
8718 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDestroyable)), "#D12");
8719 Assert.IsFalse (typeof (IAir).IsAssignableFrom (emitted_type), "#D13");
8720 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IAir)), "#D14");
8721 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type), "#D15");
8722 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IWater)), "#D16");
8723 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type), "#D17");
8724 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (ILiquid)), "#D18");
8726 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type), "#E1");
8727 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (MemoryStream)), "#E2");
8728 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type), "#E3");
8729 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Stream)), "#E4");
8730 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type), "#E5");
8731 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (FileStream)), "#E6");
8732 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type), "#E7");
8733 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (object)), "#E8");
8734 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type), "#E9");
8735 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDisposable)), "#E10");
8737 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8738 tb.FullName + "[]")), "#F1");
8739 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8740 tb.FullName + "[]")), "#F2");
8741 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8742 tb.FullName + "[]")), "#F3");
8744 TypeBuilder tb2 = module.DefineType (genTypeName (),
8745 TypeAttributes.Public, tb,
8746 new Type [] { typeof (IAir) });
8747 Type emitted_type2 = tb2.CreateType ();
8749 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#G1");
8750 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#G2");
8751 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#G3");
8752 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#G4");
8753 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#G5");
8754 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#G6");
8755 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#G7");
8756 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#G8");
8757 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#G9");
8758 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#G10");
8759 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#G11");
8760 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDestroyable)), "#G12");
8761 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#G13");
8762 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#G14");
8763 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#G15");
8764 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#G16");
8765 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#G17");
8766 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#G18");
8768 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#H1");
8769 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#H2");
8770 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#H3");
8771 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#H4");
8772 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#H5");
8773 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#H6");
8774 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#H7");
8775 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#H8");
8776 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#H9");
8777 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#H10");
8779 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#I1");
8780 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#I2");
8781 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type2), "#I3");
8782 Assert.IsFalse (tb2.IsAssignableFrom (emitted_type), "#I4");
8783 Assert.IsFalse (tb2.IsAssignableFrom ((Type) null), "#I5");
8784 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type2), "#I6");
8785 Assert.IsFalse (emitted_type2.IsAssignableFrom (emitted_type), "#I7");
8786 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb2), "#I8");
8787 Assert.IsFalse (emitted_type2.IsAssignableFrom (tb), "#I9");
8788 Assert.IsFalse (emitted_type2.IsAssignableFrom ((Type) null), "#I10");
8789 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#I11");
8790 Assert.IsTrue (tb.IsAssignableFrom (emitted_type2), "#I12");
8791 Assert.IsTrue (emitted_type.IsAssignableFrom (tb2), "#I13");
8792 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type2), "#I14");
8794 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type2), "#J1");
8795 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IThrowable)), "#J2");
8796 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type2), "#J3");
8797 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IMoveable)), "#J4");
8798 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type2), "#J5");
8799 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Foo)), "#J6");
8800 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type2), "#J7");
8801 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Bar)), "#J8");
8802 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type2), "#J9");
8803 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Baz)), "#J10");
8804 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#J11");
8805 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDestroyable)), "#J12");
8806 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type2), "#J13");
8807 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IAir)), "#J14");
8808 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type2), "#J15");
8809 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IWater)), "#J16");
8810 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type2), "#J17");
8811 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (ILiquid)), "#J18");
8813 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type2), "#K1");
8814 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (MemoryStream)), "#K2");
8815 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type2), "#K3");
8816 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Stream)), "#K4");
8817 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type2), "#K5");
8818 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (FileStream)), "#K6");
8819 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type2), "#K7");
8820 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (object)), "#K8");
8821 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type2), "#K9");
8822 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDisposable)), "#K10");
8824 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8825 tb2.FullName + "[]")), "#L1");
8826 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8827 tb2.FullName + "[]")), "#L2");
8828 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8829 tb2.FullName + "[]")), "#L3");
8831 TypeBuilder tb3 = module.DefineType (genTypeName (),
8832 TypeAttributes.Public, tb2,
8833 new Type [] { typeof (IWater) });
8834 Type emitted_type3 = tb3.CreateType ();
8836 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#M1");
8837 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#M2");
8838 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#M3");
8839 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#M4");
8840 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#M5");
8841 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#M6");
8842 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#M7");
8843 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#M8");
8844 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#M9");
8845 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#M10");
8846 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb3), "#M11");
8847 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDestroyable)), "#M12");
8848 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#M13");
8849 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#M14");
8850 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#M15");
8851 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#M16");
8852 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (tb3), "#M17");
8853 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#M18");
8855 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#N1");
8856 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#N2");
8857 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#N3");
8858 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#N4");
8859 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#N5");
8860 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#N6");
8861 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#N7");
8862 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#N8");
8863 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#N9");
8864 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#N10");
8866 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#O1");
8867 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#O2");
8868 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#O3");
8869 Assert.IsTrue (tb3.IsAssignableFrom (emitted_type3), "#O4");
8870 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type2), "#O5");
8871 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type), "#O6");
8872 Assert.IsFalse (tb3.IsAssignableFrom ((Type) null), "#O7");
8873 Assert.IsTrue (emitted_type3.IsAssignableFrom (emitted_type3), "#O8");
8874 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type2), "#O9");
8875 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type), "#O10");
8876 Assert.IsTrue (emitted_type3.IsAssignableFrom (tb3), "#O11");
8877 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb2), "#O12");
8878 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb), "#O13");
8879 Assert.IsFalse (emitted_type3.IsAssignableFrom ((Type) null), "#O14");
8880 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#O15");
8881 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type3), "#O16");
8882 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type3), "#O17");
8883 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb3), "#O18");
8884 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#O19");
8885 Assert.IsTrue (tb.IsAssignableFrom (emitted_type3), "#O20");
8886 Assert.IsTrue (emitted_type.IsAssignableFrom (tb3), "#021");
8887 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type3), "#O22");
8889 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type3), "#P1");
8890 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IThrowable)), "#P2");
8891 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type3), "#P3");
8892 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IMoveable)), "#P4");
8893 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type3), "#P5");
8894 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Foo)), "#P6");
8895 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type3), "#P7");
8896 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Bar)), "#P8");
8897 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type3), "#P9");
8898 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Baz)), "#P10");
8899 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type3), "#P11");
8900 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDestroyable)), "#P12");
8901 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type3), "#P13");
8902 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IAir)), "#P14");
8903 Assert.IsTrue (typeof (IWater).IsAssignableFrom (emitted_type3), "#P15");
8904 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IWater)), "#P16");
8905 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (emitted_type3), "#P17");
8906 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (ILiquid)), "#P18");
8908 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type3), "#Q1");
8909 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (MemoryStream)), "#Q2");
8910 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type3), "#Q3");
8911 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Stream)), "#Q4");
8912 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type3), "#Q5");
8913 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (FileStream)), "#Q6");
8914 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type3), "#Q7");
8915 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (object)), "#Q8");
8916 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type3), "#Q9");
8917 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDisposable)), "#Q10");
8919 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8920 tb3.FullName + "[]")), "#R1");
8921 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8922 tb3.FullName + "[]")), "#R2");
8923 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8924 tb3.FullName + "[]")), "#R3");
8926 TypeBuilder tb4 = module.DefineType (genTypeName (),
8927 TypeAttributes.Public, null,
8928 new Type [] { typeof (IWater) });
8929 tb4.DefineGenericParameters ("T");
8931 Type inst = tb4.MakeGenericType (typeof (int));
8932 Type emitted_type4 = tb4.CreateType ();
8933 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (inst));
8934 // This returns True if CreateType () is called _before_ MakeGenericType...
8935 //Assert.IsFalse (typeof (IWater).IsAssignableFrom (inst));
8939 public void IsAssignableFrom_NotCreated ()
8941 TypeBuilder tb = module.DefineType (genTypeName (),
8942 TypeAttributes.Public, typeof (MemoryStream),
8944 typeof (IThrowable), typeof (Bar),
8945 typeof (IComparable)
8948 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8949 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8950 //Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8951 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8952 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb), "#A5");
8953 Assert.IsFalse (tb.IsAssignableFrom (typeof (IComparable)), "#A6");
8954 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A7");
8955 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A8");
8956 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A9");
8957 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A10");
8958 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A11");
8959 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A12");
8961 //Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb), "#B1");
8962 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#B2");
8963 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#B3");
8964 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#B4");
8965 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#B5");
8966 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#B6");
8968 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#C1");
8969 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#C2");
8970 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#C3");
8971 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#C4");
8972 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#C5");
8973 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#C6");
8974 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#C7");
8975 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#C8");
8976 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#C9");
8977 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#C10");
8979 Assert.IsTrue (tb.IsAssignableFrom (tb), "#D1");
8980 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#D2");
8982 TypeBuilder tb2 = module.DefineType (genTypeName (),
8983 TypeAttributes.Public, tb,
8984 new Type[] { typeof (IAir) });
8986 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#E1");
8987 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#E2");
8988 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#E3");
8989 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#E4");
8990 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb2), "#E5");
8991 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IComparable)), "#E6");
8992 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#E7");
8993 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#E8");
8994 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#E9");
8995 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#E10");
8996 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#E11");
8997 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#E12");
8999 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#F1");
9000 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#F2");
9001 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#F3");
9002 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#F4");
9003 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#F5");
9004 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#F6");
9006 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#G1");
9007 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#G2");
9008 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#G3");
9009 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#G4");
9010 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#G5");
9011 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#G6");
9012 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#G7");
9013 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#G8");
9014 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#G9");
9015 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#G10");
9017 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#H1");
9018 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#H2");
9019 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#H3");
9021 TypeBuilder tb3 = module.DefineType (genTypeName (),
9022 TypeAttributes.Public, tb2,
9023 new Type[] { typeof (IWater) });
9025 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#I1");
9026 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#I2");
9027 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#I3");
9028 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#I4");
9029 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb3), "#I5");
9030 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IComparable)), "#I6");
9031 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#I7");
9032 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#I8");
9033 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#I9");
9034 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#I10");
9035 //Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb3), "#I11");
9036 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#I12");
9038 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#J1");
9039 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#J2");
9040 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#J3");
9041 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#J4");
9042 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#J5");
9043 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#J6");
9045 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#K1");
9046 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#K2");
9047 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#K3");
9048 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#K4");
9049 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#K5");
9050 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#K6");
9051 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#K7");
9052 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#K8");
9053 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#K9");
9054 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#K10");
9056 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#L1");
9057 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#L2");
9058 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#L3");
9059 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#L4");
9060 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#L5");
9064 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9065 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_Mono ()
9067 TypeBuilder tb = module.DefineType (genTypeName (),
9068 TypeAttributes.Public, typeof (FormatException),
9069 new Type [] { typeof (IThrowable) });
9070 tb.AddInterfaceImplementation (typeof (IDestroyable));
9072 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9073 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9075 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9076 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9080 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9081 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_MS ()
9083 TypeBuilder tb = module.DefineType (genTypeName (),
9084 TypeAttributes.Public, typeof (FormatException),
9085 new Type [] { typeof (IThrowable) });
9086 tb.AddInterfaceImplementation (typeof (IDestroyable));
9088 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9089 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9091 Assert.IsFalse (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9092 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9097 [Category ("NotDotNet")]
9098 public void IsAssignableFrom_NotCreated_Array ()
9100 TypeBuilder tb = module.DefineType (genTypeName (),
9101 TypeAttributes.Public, typeof (FormatException),
9103 typeof (IThrowable), typeof (Bar),
9104 typeof (IComparable)
9107 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9108 tb.FullName + "[]")), "#1");
9109 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9110 tb.FullName + "[]")), "#2");
9111 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9112 tb.FullName + "[]")), "#3");
9116 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9117 public void IsAssignableFrom_NotCreated_BaseInterface_Mono ()
9119 TypeBuilder tb = module.DefineType (genTypeName (),
9120 TypeAttributes.Public, typeof (FormatException),
9122 typeof (IThrowable), typeof (Bar),
9123 typeof (IComparable)
9126 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9127 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9131 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9132 public void IsAssignableFrom_NotCreated_BaseInterface_MS ()
9134 TypeBuilder tb = module.DefineType (genTypeName (),
9135 TypeAttributes.Public, typeof (FormatException),
9137 typeof (IThrowable), typeof (Bar),
9138 typeof (IComparable)
9141 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9142 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9146 public void CreateType_EmptyMethodBody ()
9148 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9150 tb.DefineMethod ("foo", MethodAttributes.Public, typeof (void), new Type [] { });
9154 } catch (InvalidOperationException ex) {
9155 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9156 Assert.IsNull (ex.InnerException, "#3");
9157 Assert.IsNotNull (ex.Message, "#4");
9162 public void CreateType_EmptyCtorBody ()
9164 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9166 tb.DefineConstructor (0, CallingConventions.Standard, null);
9170 } catch (InvalidOperationException ex) {
9171 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9172 Assert.IsNull (ex.InnerException, "#3");
9173 Assert.IsNotNull (ex.Message, "#4");
9178 [Category ("NotWorking")]
9179 public void CreateType_Interface_ParentInvalid ()
9183 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9184 typeof (Exception));
9185 Assert.AreEqual (typeof (Exception), tb.BaseType, "#A1");
9188 Assert.Fail ("#A2");
9189 } catch (TypeLoadException ex) {
9190 // Could not load interface 't5' from assembly '...'
9191 // because it must extend from Object
9192 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A3");
9193 Assert.IsNull (ex.InnerException, "#A4");
9194 Assert.IsNotNull (ex.Message, "#A5");
9195 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#A6");
9196 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#A7");
9199 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9201 Assert.AreEqual (typeof (object), tb.BaseType, "#B1");
9204 Assert.Fail ("#B2");
9205 } catch (TypeLoadException ex) {
9206 // Failure has occurred while loading a type
9207 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B3");
9208 Assert.IsNull (ex.InnerException, "#B4");
9209 Assert.IsNotNull (ex.Message, "#B5");
9212 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9213 typeof (EmptyInterface));
9214 Assert.AreEqual (typeof (EmptyInterface), tb.BaseType, "#C1");
9217 Assert.Fail ("#C2");
9218 } catch (TypeLoadException ex) {
9219 // Could not load interface 't5' from assembly '...'
9220 // because the parent type is an interface
9221 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#C3");
9222 Assert.IsNull (ex.InnerException, "#C4");
9223 Assert.IsNotNull (ex.Message, "#C5");
9224 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#C6");
9225 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#C7");
9230 public void CreateType_Parent_DefaultCtorMissing ()
9234 tb = module.DefineType (genTypeName ());
9235 ConstructorBuilder cb = tb.DefineConstructor (
9236 MethodAttributes.Public,
9237 CallingConventions.Standard,
9238 new Type [] { typeof (string) });
9239 cb.GetILGenerator ().Emit (OpCodes.Ret);
9240 Type parent_type = tb.CreateType ();
9242 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
9247 } catch (NotSupportedException ex) {
9248 // Parent does not have a default constructor.
9249 // The default constructor must be explicitly defined
9250 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
9251 Assert.IsNull (ex.InnerException, "#3");
9252 Assert.IsNotNull (ex.Message, "#4");
9257 public void CreateType_Parent_Null ()
9262 tb = module.DefineType (genTypeName (), TypeAttributes.Public, null);
9263 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
9264 emitted_type = tb.CreateType ();
9265 Assert.AreEqual (typeof (object), emitted_type.BaseType, "#A2");
9267 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract, null);
9268 Assert.IsNull (tb.BaseType, "#B1");
9269 emitted_type = tb.CreateType ();
9270 Assert.IsNull (emitted_type.BaseType, "#B2");
9274 [Category ("NotWorking")]
9275 public void DefineGenericParameters_AlreadyDefined ()
9277 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9278 tb.DefineGenericParameters ("K");
9280 tb.DefineGenericParameters ("V");
9282 } catch (InvalidOperationException ex) {
9283 // Operation is not valid due to the current
9284 // state of the object
9285 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9286 Assert.IsNull (ex.InnerException, "#3");
9287 Assert.IsNotNull (ex.Message, "#4");
9292 public void DefineGenericParameters_Names_Empty ()
9294 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9297 tb.DefineGenericParameters (new string [0]);
9299 } catch (ArgumentException ex) {
9300 // Value does not fall within the expected range
9301 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9302 Assert.IsNull (ex.InnerException, "#3");
9303 Assert.IsNotNull (ex.Message, "#4");
9304 Assert.IsNull (ex.ParamName, "#5");
9309 public void DefineGenericParameters_Names_Null ()
9311 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9314 tb.DefineGenericParameters ((string []) null);
9315 Assert.Fail ("#A1");
9316 } catch (ArgumentNullException ex) {
9317 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9318 Assert.IsNull (ex.InnerException, "#A3");
9319 Assert.IsNotNull (ex.Message, "#A4");
9320 Assert.AreEqual ("names", ex.ParamName, "#A5");
9324 tb.DefineGenericParameters ("K", null, "V");
9325 Assert.Fail ("#B1");
9326 } catch (ArgumentNullException ex) {
9327 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9328 Assert.IsNull (ex.InnerException, "#B3");
9329 Assert.IsNotNull (ex.Message, "#B4");
9330 Assert.AreEqual ("names", ex.ParamName, "#B5");
9335 public void GenericType ()
9337 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9338 tb.DefineGenericParameters ("T");
9340 Assert.IsTrue (tb.IsGenericType, "#A1");
9341 Assert.IsTrue (tb.IsGenericTypeDefinition, "#A2");
9342 Assert.IsTrue (tb.ContainsGenericParameters, "#A3");
9343 Assert.IsFalse (tb.IsGenericParameter, "#A4");
9345 Type[] args = tb.GetGenericArguments ();
9346 Assert.IsFalse (args [0].IsGenericType, "#B1");
9347 Assert.IsFalse (args [0].IsGenericTypeDefinition, "#B2");
9348 Assert.IsTrue (args [0].ContainsGenericParameters, "#B3");
9349 Assert.IsTrue (args [0].IsGenericParameter, "#B4");
9353 public void MakeGenericType ()
9358 tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9359 tb.DefineGenericParameters ("T");
9361 generic_type = tb.MakeGenericType (typeof (int));
9362 Assert.IsTrue (generic_type.IsGenericType, "#A1");
9363 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A2");
9364 Assert.IsFalse (generic_type.ContainsGenericParameters, "#A3");
9365 Assert.IsFalse (generic_type.IsGenericParameter, "#A4");
9367 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9368 Assert.IsTrue (generic_type.IsGenericType, "#B1");
9369 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B2");
9370 Assert.IsTrue (generic_type.ContainsGenericParameters, "#B3");
9371 Assert.IsFalse (generic_type.IsGenericParameter, "#B4");
9373 tb = module.DefineType (genTypeName (), TypeAttributes.Interface
9374 | TypeAttributes.Abstract | TypeAttributes.Public);
9375 tb.DefineGenericParameters ("T");
9377 generic_type = tb.MakeGenericType (typeof (int));
9378 Assert.IsTrue (generic_type.IsGenericType, "#C1");
9379 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#C2");
9380 Assert.IsFalse (generic_type.ContainsGenericParameters, "#C3");
9381 Assert.IsFalse (generic_type.IsGenericParameter, "#C4");
9383 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9384 Assert.IsTrue (generic_type.IsGenericType, "#D1");
9385 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#D2");
9386 Assert.IsTrue (generic_type.ContainsGenericParameters, "#D3");
9387 Assert.IsFalse (generic_type.IsGenericParameter, "#D4");
9391 public void MakeGenericType_NoGenericTypeDefinition ()
9393 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9395 tb.MakeGenericType (typeof (int));
9397 } catch (InvalidOperationException ex) {
9398 // Operation is not valid due to the current
9399 // state of the object
9400 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9401 Assert.IsNull (ex.InnerException, "#3");
9402 Assert.IsNotNull (ex.Message, "#4");
9407 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9408 public void MakeGenericType_TypeArguments_Null_Mono ()
9410 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9411 tb.DefineGenericParameters ("K", "V");
9414 tb.MakeGenericType ((Type []) null);
9415 Assert.Fail ("#A1");
9416 } catch (ArgumentNullException ex) {
9417 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9418 Assert.IsNull (ex.InnerException, "#A3");
9419 Assert.IsNotNull (ex.Message, "#A4");
9420 Assert.AreEqual ("typeArguments", ex.ParamName, "#A5");
9424 tb.MakeGenericType (typeof (string), (Type) null);
9425 Assert.Fail ("#B1");
9426 } catch (ArgumentNullException ex) {
9427 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9428 Assert.IsNull (ex.InnerException, "#B3");
9429 Assert.IsNotNull (ex.Message, "#B4");
9430 Assert.AreEqual ("typeArguments", ex.ParamName, "#B5");
9435 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9436 public void MakeGenericType_TypeArguments_Null_MS ()
9441 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9442 tb.DefineGenericParameters ("K", "V");
9444 generic_type = tb.MakeGenericType ((Type []) null);
9445 Assert.IsNotNull (generic_type, "#A1");
9446 Assert.IsTrue (generic_type.IsGenericType, "#A2");
9447 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A3");
9448 type_args = generic_type.GetGenericArguments ();
9449 Assert.IsNull (type_args, "#A4");
9451 generic_type = tb.MakeGenericType (typeof (string), (Type) null);
9452 Assert.IsNotNull (generic_type, "#B1");
9453 Assert.IsTrue (generic_type.IsGenericType, "#B2");
9454 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B3");
9455 type_args = generic_type.GetGenericArguments ();
9456 Assert.IsNotNull (type_args, "#B4");
9457 Assert.AreEqual (2, type_args.Length, "#B5");
9458 Assert.AreEqual (typeof (string), type_args [0], "#B6");
9459 Assert.IsNull (type_args [1], "#B7");
9463 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9464 public void MakeGenericType_TypeArguments_Mismatch_Mono ()
9466 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9467 tb.DefineGenericParameters ("K", "V");
9469 tb.MakeGenericType (typeof (int));
9471 } catch (ArgumentException ex) {
9472 // The type or method has 2 generic prarameter(s)
9473 // but 1 generic argument(s) were provided. A
9474 // generic argument must be provided for each
9475 // generic parameter
9476 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9477 Assert.IsNull (ex.InnerException, "#3");
9478 Assert.IsNotNull (ex.Message, "#4");
9479 Assert.AreEqual ("typeArguments", ex.ParamName, "#5");
9484 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9485 public void MakeGenericType_TypeArguments_Mismatch_MS ()
9487 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9488 tb.DefineGenericParameters ("K", "V");
9490 Type generic_type = tb.MakeGenericType (typeof (int));
9491 Assert.IsTrue (generic_type.IsGenericType, "#1");
9492 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#2");
9493 Type [] type_args = generic_type.GetGenericArguments ();
9494 Assert.IsNotNull (type_args, "#3");
9495 Assert.AreEqual (1, type_args.Length, "#4");
9496 Assert.AreEqual (typeof (int), type_args [0], "#5");
9500 public void MakeArrayType_Complete ()
9503 TypeBuilder tb = module.DefineType (genTypeName (),
9504 TypeAttributes.Sealed | TypeAttributes.Serializable,
9505 typeof (ContextBoundObject));
9506 Type emittedType = tb.CreateType ();
9507 Type arrayType = tb.MakeArrayType ();
9508 Assert.IsTrue (arrayType.IsArray, "#A1");
9509 Assert.IsTrue (arrayType.HasElementType, "#A2");
9510 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9511 Assert.IsFalse (tb.HasElementType, "#A4");
9512 Assert.IsTrue (tb.IsCreated (), "#A5");
9515 tb = module.DefineType (genTypeName (),
9516 TypeAttributes.Sealed | TypeAttributes.Serializable,
9517 typeof (ValueType));
9518 emittedType = tb.CreateType ();
9519 arrayType = tb.MakeArrayType ();
9520 Assert.IsTrue (arrayType.IsArray, "#B1");
9521 Assert.IsTrue (arrayType.HasElementType, "#B2");
9522 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9523 Assert.IsFalse (tb.HasElementType, "#B4");
9524 Assert.IsTrue (tb.IsCreated (), "#B5");
9526 tb = module.DefineType (genTypeName (),
9527 TypeAttributes.Sealed | TypeAttributes.Serializable,
9529 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
9530 FieldAttributes.Private | FieldAttributes.RTSpecialName);
9531 emittedType = tb.CreateType ();
9532 arrayType = tb.MakeArrayType ();
9533 Assert.IsTrue (arrayType.IsArray, "#C1");
9534 Assert.IsTrue (arrayType.HasElementType, "#C2");
9535 Assert.AreEqual (tb, arrayType.GetElementType (), "#C3");
9536 Assert.IsFalse (tb.HasElementType, "#C4");
9537 Assert.IsTrue (tb.IsCreated (), "#C5");
9540 [Test] // bug #82015
9541 public void MakeArrayType_Incomplete ()
9544 TypeBuilder tb = module.DefineType (genTypeName (),
9545 TypeAttributes.Sealed | TypeAttributes.Serializable,
9546 typeof (ContextBoundObject));
9547 Type arrayType = tb.MakeArrayType ();
9548 Assert.IsTrue (arrayType.IsArray, "#A1");
9549 Assert.IsTrue (arrayType.HasElementType, "#A2");
9550 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9551 Assert.IsFalse (tb.HasElementType, "#A4");
9552 Assert.IsFalse (tb.IsCreated (), "#A5");
9555 tb = module.DefineType (genTypeName (),
9556 TypeAttributes.Sealed | TypeAttributes.Serializable,
9557 typeof (ValueType));
9558 arrayType = tb.MakeArrayType ();
9559 Assert.IsTrue (arrayType.IsArray, "#B1");
9560 Assert.IsTrue (arrayType.HasElementType, "#B2");
9561 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9562 Assert.IsFalse (tb.HasElementType, "#B4");
9563 Assert.IsFalse (tb.IsCreated (), "#B5");
9566 tb = module.DefineType (genTypeName (),
9567 TypeAttributes.Sealed | TypeAttributes.Serializable,
9569 arrayType = tb.MakeArrayType ();
9570 Assert.IsTrue (arrayType.IsArray, "#C1");
9571 Assert.IsTrue (arrayType.HasElementType, "#C2");
9572 Assert.IsFalse (tb.HasElementType, "#C3");
9573 Assert.IsFalse (tb.IsCreated (), "#C4");
9577 public void GetCustomAttributes_InflatedType ()
9579 TypeBuilder tb = module.DefineType (genTypeName ());
9580 tb.DefineGenericParameters (new string[] { "FOO" });
9582 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
9583 new Type [] { typeof (string) });
9585 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
9586 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
9588 tb.SetCustomAttribute (caBuilder);
9589 Type t = tb.CreateType ();
9591 Type inflated = t.MakeGenericType (new Type [] { typeof (int) });
9593 Assert.AreEqual (1, inflated.GetCustomAttributes (false).Length);
9597 public void GetField ()
9599 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9600 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
9602 ConstructorBuilder cb = tb.DefineDefaultConstructor (MethodAttributes.Public);
9604 FieldBuilder fb1 = tb.DefineField ("field1", typeParams [0], FieldAttributes.Public);
9606 Type t = tb.MakeGenericType (typeof (int));
9608 // Chect that calling MakeArrayType () does not initialize the class
9612 // Check that the instantiation of a type builder contains live data
9613 TypeBuilder.GetField (t, fb1);
9614 FieldBuilder fb2 = tb.DefineField ("field2", typeParams [0], FieldAttributes.Public);
9615 FieldInfo fi2 = TypeBuilder.GetField (t, fb1);
9617 MethodBuilder mb = tb.DefineMethod ("get_int", MethodAttributes.Public|MethodAttributes.Static, typeof (int), Type.EmptyTypes);
9618 ILGenerator ilgen = mb.GetILGenerator ();
9619 ilgen.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t, cb));
9620 ilgen.Emit (OpCodes.Dup);
9621 ilgen.Emit (OpCodes.Ldc_I4, 42);
9622 ilgen.Emit (OpCodes.Stfld, fi2);
9623 ilgen.Emit (OpCodes.Ldfld, fi2);
9624 ilgen.Emit (OpCodes.Ret);
9626 // Check GetField on a type instantiated with type parameters
9627 Type t3 = tb.MakeGenericType (typeParams [0]);
9628 FieldBuilder fb3 = tb.DefineField ("field3", typeParams [0], FieldAttributes.Public);
9629 FieldInfo fi3 = TypeBuilder.GetField (t3, fb3);
9631 MethodBuilder mb3 = tb.DefineMethod ("get_T", MethodAttributes.Public|MethodAttributes.Static, typeParams [0], Type.EmptyTypes);
9632 ILGenerator ilgen3 = mb3.GetILGenerator ();
9633 ilgen3.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t3, cb));
9634 ilgen3.Emit (OpCodes.Ldfld, fi3);
9635 ilgen3.Emit (OpCodes.Ret);
9637 Type created = tb.CreateType ();
9639 Type inst = created.MakeGenericType (typeof (object));
9641 Assert.AreEqual (42, inst.GetMethod ("get_int").Invoke (null, null));
9643 Assert.AreEqual (null, inst.GetMethod ("get_T").Invoke (null, null));
9646 [Test] //bug #354047
9647 public void CreatedTypeInstantiationOverTypeBuilderArgsIsNotAGenericTypeDefinition ()
9649 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9650 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9651 Type t = tb.CreateType ();
9653 Type inst = tb.MakeGenericType (typeParams [0]);
9654 Assert.IsFalse (inst.IsGenericTypeDefinition, "#1 create type instance is not a generic type definition");
9657 [Test] //bug #354047
9658 public void CreatedTypeAndTypeBuilderOwnTheirGenericArguments ()
9660 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9661 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9662 Type t = tb.CreateType ();
9664 Assert.IsTrue (tb.GetGenericArguments()[0].DeclaringType == tb, "#1 TypeBuilder owns its arguments");
9665 Assert.IsTrue (t.GetGenericArguments()[0].DeclaringType == t, "#1 create type owns its arguments");
9668 [Test] //bug #354047
9669 public void CreatedTypeAndTypeBuilderDontShareGenericArguments ()
9671 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9672 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9673 Type t = tb.CreateType ();
9675 Assert.IsTrue (tb.GetGenericArguments()[0] != t.GetGenericArguments()[0], "#1 TypeBuilder and create type arguments are diferent");
9678 [Test] //bug #399047
9679 public void FieldOnTypeBuilderInstDontInflateWhenEncoded () {
9680 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9682 module = assembly.DefineDynamicModule ("Instance.exe");
9684 TypeBuilder G = module.DefineType ("G", TypeAttributes.Public);
9685 Type T = G.DefineGenericParameters ("T") [0];
9686 ConstructorInfo ctor = G.DefineDefaultConstructor (MethodAttributes.Public);
9687 Type GObj = G.MakeGenericType (new Type [] { T });
9689 FieldBuilder F = G.DefineField ("F", T, FieldAttributes.Public);
9691 TypeBuilder P = module.DefineType ("P", TypeAttributes.Public);
9693 MethodBuilder Test = P.DefineMethod ("Test", MethodAttributes.Public);
9694 Type TATest = Test.DefineGenericParameters ("TA") [0];
9696 Type TestGObj = G.MakeGenericType (new Type [] { TATest });
9698 ILGenerator il = Test.GetILGenerator ();
9700 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (TestGObj, ctor));
9701 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (TestGObj, F));
9702 il.Emit (OpCodes.Pop);
9704 il.Emit (OpCodes.Ret);
9707 MethodBuilder main = P.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static);
9709 ILGenerator il = main.GetILGenerator ();
9710 il.Emit(OpCodes.Newobj, P.DefineDefaultConstructor (MethodAttributes.Public));
9711 il.Emit(OpCodes.Call, Test.MakeGenericMethod (typeof (int)));
9712 il.Emit (OpCodes.Ret);
9715 assembly.SetEntryPoint (main);
9719 assembly.Save ("Instance.exe");
9720 Thread.GetDomain ().ExecuteAssembly(Path.GetTempPath () + Path.DirectorySeparatorChar + "Instance.exe");
9724 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers ()
9726 TypeBuilder tb = module.DefineType ("Type1", TypeAttributes.Public);
9727 FieldBuilder fb = tb.DefineInitializedData ("Foo", new byte [] {1,2,3,4}, FieldAttributes.Static|FieldAttributes.Public);
9730 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME+"2"), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9731 module = assembly.DefineDynamicModule ("Instance.exe");
9733 TypeBuilder tb2 = module.DefineType ("Type2", TypeAttributes.Public);
9734 MethodBuilder mb = tb2.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static, typeof (object), new Type [0]);
9735 ILGenerator il = mb.GetILGenerator ();
9737 il.Emit (OpCodes.Ldc_I4_1);
9738 il.Emit (OpCodes.Newarr, typeof (int));
9739 il.Emit (OpCodes.Dup);
9740 il.Emit (OpCodes.Ldtoken, fb);
9741 il.Emit (OpCodes.Call, typeof (RuntimeHelpers).GetMethod ("InitializeArray"));
9742 il.Emit (OpCodes.Ret);
9744 Type t = tb2.CreateType ();
9745 int[] res = (int[])t.GetMethod ("Test").Invoke (null, new object[0]);
9746 //Console.WriteLine (res[0]);
9749 public interface IDelegateFactory
9751 Delegate Create (Delegate del);
9755 public void CreateType_Ctor_NoBody ()
9757 TypeBuilder tb = module.DefineType (genTypeName ());
9758 tb.DefineConstructor (MethodAttributes.Public,
9759 CallingConventions.Standard,
9760 new Type [] { typeof (string) });
9764 } catch (InvalidOperationException ex) {
9765 // Method '.ctor' does not have a method body
9766 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9767 Assert.IsNull (ex.InnerException, "#3");
9768 Assert.IsNotNull (ex.Message, "#4");
9769 Assert.IsTrue (ex.Message.IndexOf (".ctor") != -1, "#5");
9773 [Test] //bug #361689
9774 public void CreateTypeFailsWithInvalidMethodOverride ()
9776 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9778 MethodBuilder mc = tb.DefineMethod ("Create", MethodAttributes.Public, typeof (Delegate), new Type[] {typeof (Delegate)});
9779 ILGenerator gen = mc.GetILGenerator ();
9780 gen.Emit (OpCodes.Ldarg_0);
9781 gen.Emit (OpCodes.Ret);
9782 tb.DefineMethodOverride (mc, typeof (IDelegateFactory).GetMethod ("Create"));
9785 Assert.Fail ("#1 create type did not throw TypeLoadException");
9786 } catch (TypeLoadException) {
9791 [Test] //bug #349194
9792 public void IsAssignableToWorksWithInterfacesOnParent ()
9794 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9795 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Public, tb);
9797 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
9798 Type t = tb.CreateType ();
9799 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
9800 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t));
9803 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
9804 Type t2 = tb2.CreateType ();
9805 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
9806 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t2));
9810 [Test] //bug #430508
9811 public void MakeGenericTypeRespectBaseType ()
9813 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9814 EnumBuilder eb = module.DefineEnum (genTypeName (), TypeAttributes.Public, typeof (int));
9816 MethodBuilder mb = tb.DefineMethod ("Test",
9817 MethodAttributes.Public,
9818 typeof (Tuple<,>).MakeGenericType (typeof (int), eb),
9820 ILGenerator il = mb.GetILGenerator();
9821 il.Emit (OpCodes.Ldnull);
9822 il.Emit (OpCodes.Ret);
9824 Type e = eb.CreateType ();
9825 Type c = tb.CreateType ();
9827 Assert.AreEqual (c.GetMethod ("Test").ReturnType.GetGenericArguments ()[1], e, "#1");
9831 public void GetCustomAttrOnFieldOfInflatedType ()
9833 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9834 tb.DefineGenericParameters ("T");
9836 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9837 typeof (SimpleTestAttribute).GetConstructors ()[0],
9840 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
9841 field.SetCustomAttribute (caBuilder);
9843 Type t = tb.CreateType ();
9845 FieldInfo fi = t.GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9846 object[] cattrs = fi.GetCustomAttributes (false);
9847 Assert.AreEqual (1, cattrs.Length);
9849 fi = t.MakeGenericType (typeof (int)).GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9850 cattrs = fi.GetCustomAttributes (false);
9851 Assert.AreEqual (1, cattrs.Length);
9855 public void GetCustomAttrOnPropertyOfInflatedType ()
9857 TypeBuilder tb = module.DefineType (genTypeName ());
9858 tb.DefineGenericParameters ("T");
9860 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9861 typeof (SimpleTestAttribute).GetConstructors ()[0],
9864 PropertyBuilder property = DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
9865 property.SetCustomAttribute (caBuilder);
9867 Type t = tb.CreateType ();
9869 PropertyInfo pi = t.GetProperties ()[0];
9870 object[] cattrs = pi.GetCustomAttributes (false);
9871 Assert.AreEqual (1, cattrs.Length);
9873 pi = t.MakeGenericType (typeof (int)).GetProperties ()[0];
9874 cattrs = pi.GetCustomAttributes (false);
9875 Assert.AreEqual (1, cattrs.Length);
9879 public void GetCustomAttrOnEventOfInflatedType ()
9881 TypeBuilder tb = module.DefineType (genTypeName ());
9882 tb.DefineGenericParameters ("T");
9884 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9885 typeof (SimpleTestAttribute).GetConstructors ()[0],
9888 EventBuilder evt = tb.DefineEvent ("OI", 0, typeof (int));
9889 evt.SetCustomAttribute (caBuilder);
9891 Type t = tb.CreateType ();
9893 EventInfo ei = t.GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9894 object[] cattrs = ei.GetCustomAttributes (false);
9895 Assert.AreEqual (1, cattrs.Length);
9897 ei = t.MakeGenericType (typeof (int)).GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9898 cattrs = ei.GetCustomAttributes (false);
9899 Assert.AreEqual (1, cattrs.Length);
9902 public void TestDoubleInitializationOfMonoGenericClass () //bug #400643
9904 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9905 tb.DefineGenericParameters ("T");
9907 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9908 typeof (SimpleTestAttribute).GetConstructors ()[0],
9911 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
9912 field.SetCustomAttribute (caBuilder);
9915 tb.MakeGenericType (typeof (int)).GetMethods ();
9916 tb.MakeGenericType (typeof (double)).GetMethods ();
9918 Type t = tb.CreateType ();
9920 t.MakeGenericType (typeof (int)).GetMethods ();
9921 t.MakeGenericType (typeof (double)).GetMethods ();
9925 public void TestGenericFieldAccess () // bug #467415
9927 AssemblyName asmName = new AssemblyName("DemoMethodBuilder1");
9928 AppDomain domain = AppDomain.CurrentDomain;
9929 AssemblyBuilder demoAssembly =
9930 domain.DefineDynamicAssembly(asmName,
9931 AssemblyBuilderAccess.RunAndSave);
9933 // Define the module that contains the code. For an
9934 // assembly with one module, the module name is the
9935 // assembly name plus a file extension.
9936 ModuleBuilder demoModule =
9937 demoAssembly.DefineDynamicModule(asmName.Name,
9938 asmName.Name+".dll");
9940 TypeBuilder demoType =
9941 demoModule.DefineType("DemoType", TypeAttributes.Public);
9943 MethodBuilder factory =
9944 demoType.DefineMethod("Factory",
9945 MethodAttributes.Public | MethodAttributes.Static);
9947 string[] typeParameterNames = {"T"};
9948 GenericTypeParameterBuilder[] typeParameters =
9949 factory.DefineGenericParameters(typeParameterNames);
9951 GenericTypeParameterBuilder T = typeParameters[0];
9954 factory.SetParameters(parms);
9956 factory.SetReturnType(T);
9958 ILGenerator ilgen = factory.GetILGenerator();
9960 Type G = typeof(Gen<>);
9961 Type GT = G.MakeGenericType (T);
9962 FieldInfo GF = G.GetField("field");
9963 FieldInfo GTF = TypeBuilder.GetField(GT, GF);
9965 ilgen.Emit(OpCodes.Ldsfld, GTF);
9966 ilgen.Emit(OpCodes.Ret);
9968 // Complete the type.
9969 Type dt = demoType.CreateType();
9970 // Save the assembly, so it can be examined with Ildasm.exe.
9971 //demoAssembly.Save(asmName.Name+".dll");
9973 MethodInfo m = dt.GetMethod("Factory");
9974 MethodInfo bound = m.MakeGenericMethod(typeof(int));
9976 // Display a string representing the bound method.
9977 //Console.WriteLine(bound);
9979 object[] parameters = {};
9980 int result = (int)(bound.Invoke(null, parameters));
9982 Assert.AreEqual (0, result, "#1");
9985 static MethodInfo GetMethodByName (MethodInfo [] methods, string name)
9987 foreach (MethodInfo mi in methods)
9988 if (mi.Name == name)
9993 void CreateMembers (TypeBuilder tb, string suffix, bool defineCtors)
9995 ConstructorBuilder cb;
10003 // instance constructors
10005 cb = tb.DefineConstructor (MethodAttributes.Private,
10006 CallingConventions.Standard,
10007 new Type [] { typeof (int), typeof (int) });
10008 cb.GetILGenerator ().Emit (OpCodes.Ret);
10010 cb = tb.DefineConstructor (MethodAttributes.Family,
10011 CallingConventions.Standard,
10012 new Type [] { typeof (string) });
10013 cb.GetILGenerator ().Emit (OpCodes.Ret);
10015 cb = tb.DefineConstructor (MethodAttributes.FamANDAssem,
10016 CallingConventions.Standard,
10017 new Type [] { typeof (string), typeof (string) });
10018 cb.GetILGenerator ().Emit (OpCodes.Ret);
10020 cb = tb.DefineConstructor (MethodAttributes.FamORAssem,
10021 CallingConventions.Standard,
10022 new Type [] { typeof (int) });
10023 cb.GetILGenerator ().Emit (OpCodes.Ret);
10025 cb = tb.DefineConstructor (MethodAttributes.Public,
10026 CallingConventions.Standard,
10027 new Type [] { typeof (int), typeof (bool) });
10028 cb.GetILGenerator ().Emit (OpCodes.Ret);
10030 cb = tb.DefineConstructor (MethodAttributes.Assembly,
10031 CallingConventions.Standard,
10032 new Type [] { typeof (string), typeof (int) });
10033 cb.GetILGenerator ().Emit (OpCodes.Ret);
10036 // static constructors
10039 cb = tb.DefineConstructor (MethodAttributes.Private |
10040 MethodAttributes.Static,
10041 CallingConventions.Standard,
10043 cb.GetILGenerator ().Emit (OpCodes.Ret);
10047 // instance methods
10050 mb = tb.DefineMethod ("GetPrivateInstance" + suffix,
10051 MethodAttributes.Private, typeof (void),
10053 mb.GetILGenerator ().Emit (OpCodes.Ret);
10055 mb = tb.DefineMethod ("GetFamilyInstance" + suffix,
10056 MethodAttributes.Family, typeof (void),
10058 mb.GetILGenerator ().Emit (OpCodes.Ret);
10060 mb = tb.DefineMethod ("GetFamANDAssemInstance" + suffix,
10061 MethodAttributes.FamANDAssem, typeof (void),
10063 mb.GetILGenerator ().Emit (OpCodes.Ret);
10065 mb = tb.DefineMethod ("GetFamORAssemInstance" + suffix,
10066 MethodAttributes.FamORAssem, typeof (void),
10068 mb.GetILGenerator ().Emit (OpCodes.Ret);
10070 mb = tb.DefineMethod ("GetPublicInstance" + suffix,
10071 MethodAttributes.Public, typeof (void),
10073 mb.GetILGenerator ().Emit (OpCodes.Ret);
10075 mb = tb.DefineMethod ("GetAssemblyInstance" + suffix,
10076 MethodAttributes.Assembly, typeof (void),
10078 mb.GetILGenerator ().Emit (OpCodes.Ret);
10084 mb = tb.DefineMethod ("GetPrivateStatic" + suffix,
10085 MethodAttributes.Private | MethodAttributes.Static,
10086 typeof (void), Type.EmptyTypes);
10087 mb.GetILGenerator ().Emit (OpCodes.Ret);
10089 mb = tb.DefineMethod ("GetFamilyStatic" + suffix,
10090 MethodAttributes.Family | MethodAttributes.Static,
10091 typeof (void), Type.EmptyTypes);
10092 mb.GetILGenerator ().Emit (OpCodes.Ret);
10094 mb = tb.DefineMethod ("GetFamANDAssemStatic" + suffix,
10095 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10096 typeof (void), Type.EmptyTypes);
10097 mb.GetILGenerator ().Emit (OpCodes.Ret);
10099 mb = tb.DefineMethod ("GetFamORAssemStatic" + suffix,
10100 MethodAttributes.FamORAssem | MethodAttributes.Static,
10101 typeof (void), Type.EmptyTypes);
10102 mb.GetILGenerator ().Emit (OpCodes.Ret);
10104 mb = tb.DefineMethod ("GetPublicStatic" + suffix,
10105 MethodAttributes.Public | MethodAttributes.Static,
10106 typeof (void), Type.EmptyTypes);
10107 mb.GetILGenerator ().Emit (OpCodes.Ret);
10109 mb = tb.DefineMethod ("GetAssemblyStatic" + suffix,
10110 MethodAttributes.Assembly | MethodAttributes.Static,
10111 typeof (void), Type.EmptyTypes);
10112 mb.GetILGenerator ().Emit (OpCodes.Ret);
10118 tb.DefineField ("privateInstance" + suffix,
10119 typeof (string), FieldAttributes.Private);
10120 tb.DefineField ("familyInstance" + suffix,
10121 typeof (string), FieldAttributes.Family);
10122 tb.DefineField ("famANDAssemInstance" + suffix,
10123 typeof (string), FieldAttributes.FamANDAssem);
10124 tb.DefineField ("famORAssemInstance" + suffix,
10125 typeof (string), FieldAttributes.FamORAssem);
10126 tb.DefineField ("publicInstance" + suffix,
10127 typeof (string), FieldAttributes.Public);
10128 tb.DefineField ("assemblyInstance" + suffix,
10129 typeof (string), FieldAttributes.Assembly);
10135 tb.DefineField ("privateStatic" + suffix,
10136 typeof (string), FieldAttributes.Private |
10137 FieldAttributes.Static);
10138 tb.DefineField ("familyStatic" + suffix,
10139 typeof (string), FieldAttributes.Family |
10140 FieldAttributes.Static);
10141 tb.DefineField ("famANDAssemStatic" + suffix,
10142 typeof (string), FieldAttributes.FamANDAssem |
10143 FieldAttributes.Static);
10144 tb.DefineField ("famORAssemStatic" + suffix,
10145 typeof (string), FieldAttributes.FamORAssem |
10146 FieldAttributes.Static);
10147 tb.DefineField ("publicStatic" + suffix,
10148 typeof (string), FieldAttributes.Public |
10149 FieldAttributes.Static);
10150 tb.DefineField ("assemblyStatic" + suffix,
10151 typeof (string), FieldAttributes.Assembly |
10152 FieldAttributes.Static);
10155 // instance properties
10158 pb = tb.DefineProperty ("PrivateInstance" + suffix,
10159 PropertyAttributes.None, typeof (string),
10161 mb = tb.DefineMethod ("get_PrivateInstance" + suffix,
10162 MethodAttributes.Private, typeof (string),
10164 ilgen = mb.GetILGenerator ();
10165 ilgen.Emit (OpCodes.Ldnull);
10166 ilgen.Emit (OpCodes.Ret);
10167 pb.SetGetMethod (mb);
10169 pb = tb.DefineProperty ("FamilyInstance" + suffix,
10170 PropertyAttributes.None, typeof (string),
10172 mb = tb.DefineMethod ("get_FamilyInstance" + suffix,
10173 MethodAttributes.Family, typeof (string),
10175 ilgen = mb.GetILGenerator ();
10176 ilgen.Emit (OpCodes.Ldnull);
10177 ilgen.Emit (OpCodes.Ret);
10178 pb.SetGetMethod (mb);
10180 pb = tb.DefineProperty ("FamANDAssemInstance" + suffix,
10181 PropertyAttributes.None, typeof (string),
10183 mb = tb.DefineMethod ("get_FamANDAssemInstance" + suffix,
10184 MethodAttributes.FamANDAssem, typeof (string),
10186 ilgen = mb.GetILGenerator ();
10187 ilgen.Emit (OpCodes.Ldnull);
10188 ilgen.Emit (OpCodes.Ret);
10189 pb.SetGetMethod (mb);
10191 pb = tb.DefineProperty ("FamORAssemInstance" + suffix,
10192 PropertyAttributes.None, typeof (string),
10194 mb = tb.DefineMethod ("get_FamORAssemInstance" + suffix,
10195 MethodAttributes.FamORAssem, typeof (string),
10197 ilgen = mb.GetILGenerator ();
10198 ilgen.Emit (OpCodes.Ldnull);
10199 ilgen.Emit (OpCodes.Ret);
10200 pb.SetGetMethod (mb);
10202 pb = tb.DefineProperty ("PublicInstance" + suffix,
10203 PropertyAttributes.None, typeof (string),
10205 mb = tb.DefineMethod ("get_PublicInstance" + suffix,
10206 MethodAttributes.Public, typeof (string),
10208 ilgen = mb.GetILGenerator ();
10209 ilgen.Emit (OpCodes.Ldnull);
10210 ilgen.Emit (OpCodes.Ret);
10211 pb.SetGetMethod (mb);
10213 pb = tb.DefineProperty ("AssemblyInstance" + suffix,
10214 PropertyAttributes.None, typeof (string),
10216 mb = tb.DefineMethod ("get_AssemblyInstance" + suffix,
10217 MethodAttributes.Assembly, typeof (string),
10219 ilgen = mb.GetILGenerator ();
10220 ilgen.Emit (OpCodes.Ldnull);
10221 ilgen.Emit (OpCodes.Ret);
10222 pb.SetGetMethod (mb);
10225 // static properties
10228 pb = tb.DefineProperty ("PrivateStatic" + suffix,
10229 PropertyAttributes.None, typeof (string),
10231 mb = tb.DefineMethod ("get_PrivateStatic" + suffix,
10232 MethodAttributes.Private | MethodAttributes.Static,
10233 typeof (string), Type.EmptyTypes);
10234 ilgen = mb.GetILGenerator ();
10235 ilgen.Emit (OpCodes.Ldnull);
10236 ilgen.Emit (OpCodes.Ret);
10237 pb.SetGetMethod (mb);
10239 pb = tb.DefineProperty ("FamilyStatic" + suffix,
10240 PropertyAttributes.None, typeof (string),
10242 mb = tb.DefineMethod ("get_FamilyStatic" + suffix,
10243 MethodAttributes.Family | MethodAttributes.Static,
10244 typeof (string), Type.EmptyTypes);
10245 ilgen = mb.GetILGenerator ();
10246 ilgen.Emit (OpCodes.Ldnull);
10247 ilgen.Emit (OpCodes.Ret);
10248 pb.SetGetMethod (mb);
10250 pb = tb.DefineProperty ("FamANDAssemStatic" + suffix,
10251 PropertyAttributes.None, typeof (string),
10253 mb = tb.DefineMethod ("get_FamANDAssemStatic" + suffix,
10254 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10255 typeof (string), Type.EmptyTypes);
10256 ilgen = mb.GetILGenerator ();
10257 ilgen.Emit (OpCodes.Ldnull);
10258 ilgen.Emit (OpCodes.Ret);
10259 pb.SetGetMethod (mb);
10261 pb = tb.DefineProperty ("FamORAssemStatic" + suffix,
10262 PropertyAttributes.None, typeof (string),
10264 mb = tb.DefineMethod ("get_FamORAssemStatic" + suffix,
10265 MethodAttributes.FamORAssem | MethodAttributes.Static,
10266 typeof (string), Type.EmptyTypes);
10267 ilgen = mb.GetILGenerator ();
10268 ilgen.Emit (OpCodes.Ldnull);
10269 ilgen.Emit (OpCodes.Ret);
10270 pb.SetGetMethod (mb);
10272 pb = tb.DefineProperty ("PublicStatic" + suffix,
10273 PropertyAttributes.None, typeof (string),
10275 mb = tb.DefineMethod ("get_PublicStatic" + suffix,
10276 MethodAttributes.Public | MethodAttributes.Static,
10277 typeof (string), Type.EmptyTypes);
10278 ilgen = mb.GetILGenerator ();
10279 ilgen.Emit (OpCodes.Ldnull);
10280 ilgen.Emit (OpCodes.Ret);
10281 pb.SetGetMethod (mb);
10283 pb = tb.DefineProperty ("AssemblyStatic" + suffix,
10284 PropertyAttributes.None, typeof (string),
10286 mb = tb.DefineMethod ("get_AssemblyStatic" + suffix,
10287 MethodAttributes.Assembly | MethodAttributes.Static,
10288 typeof (string), Type.EmptyTypes);
10289 ilgen = mb.GetILGenerator ();
10290 ilgen.Emit (OpCodes.Ldnull);
10291 ilgen.Emit (OpCodes.Ret);
10292 pb.SetGetMethod (mb);
10298 eb = tb.DefineEvent ("OnPrivateInstance" + suffix,
10299 EventAttributes.None, typeof (EventHandler));
10300 mb = tb.DefineMethod ("add_OnPrivateInstance" + suffix,
10301 MethodAttributes.Private, typeof (void),
10303 mb.GetILGenerator ().Emit (OpCodes.Ret);
10304 eb.SetAddOnMethod (mb);
10306 eb = tb.DefineEvent ("OnFamilyInstance" + suffix,
10307 EventAttributes.None, typeof (EventHandler));
10308 mb = tb.DefineMethod ("add_OnFamilyInstance" + suffix,
10309 MethodAttributes.Family, typeof (void),
10311 mb.GetILGenerator ().Emit (OpCodes.Ret);
10312 eb.SetAddOnMethod (mb);
10314 eb = tb.DefineEvent ("OnFamANDAssemInstance" + suffix,
10315 EventAttributes.None, typeof (EventHandler));
10316 mb = tb.DefineMethod ("add_OnFamANDAssemInstance" + suffix,
10317 MethodAttributes.FamANDAssem, typeof (void),
10319 mb.GetILGenerator ().Emit (OpCodes.Ret);
10320 eb.SetAddOnMethod (mb);
10322 eb = tb.DefineEvent ("OnFamORAssemInstance" + suffix,
10323 EventAttributes.None, typeof (EventHandler));
10324 mb = tb.DefineMethod ("add_OnFamORAssemInstance" + suffix,
10325 MethodAttributes.FamORAssem, typeof (void),
10327 mb.GetILGenerator ().Emit (OpCodes.Ret);
10328 eb.SetAddOnMethod (mb);
10330 eb = tb.DefineEvent ("OnPublicInstance" + suffix,
10331 EventAttributes.None, typeof (EventHandler));
10332 mb = tb.DefineMethod ("add_OnPublicInstance" + suffix,
10333 MethodAttributes.Public, typeof (void),
10335 mb.GetILGenerator ().Emit (OpCodes.Ret);
10336 eb.SetAddOnMethod (mb);
10338 eb = tb.DefineEvent ("OnAssemblyInstance" + suffix,
10339 EventAttributes.None, typeof (EventHandler));
10340 mb = tb.DefineMethod ("add_OnAssemblyInstance" + suffix,
10341 MethodAttributes.Family, typeof (void),
10343 mb.GetILGenerator ().Emit (OpCodes.Ret);
10344 eb.SetAddOnMethod (mb);
10350 eb = tb.DefineEvent ("OnPrivateStatic" + suffix,
10351 EventAttributes.None, typeof (EventHandler));
10352 mb = tb.DefineMethod ("add_OnPrivateStatic" + suffix,
10353 MethodAttributes.Private | MethodAttributes.Static,
10354 typeof (void), Type.EmptyTypes);
10355 mb.GetILGenerator ().Emit (OpCodes.Ret);
10356 eb.SetAddOnMethod (mb);
10358 eb = tb.DefineEvent ("OnFamilyStatic" + suffix,
10359 EventAttributes.None, typeof (EventHandler));
10360 mb = tb.DefineMethod ("add_OnFamilyStatic" + suffix,
10361 MethodAttributes.Family | MethodAttributes.Static,
10362 typeof (void), Type.EmptyTypes);
10363 mb.GetILGenerator ().Emit (OpCodes.Ret);
10364 eb.SetAddOnMethod (mb);
10366 eb = tb.DefineEvent ("OnFamANDAssemStatic" + suffix,
10367 EventAttributes.None, typeof (EventHandler));
10368 mb = tb.DefineMethod ("add_OnFamANDAssemStatic" + suffix,
10369 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10370 typeof (void), Type.EmptyTypes);
10371 mb.GetILGenerator ().Emit (OpCodes.Ret);
10372 eb.SetAddOnMethod (mb);
10374 eb = tb.DefineEvent ("OnFamORAssemStatic" + suffix,
10375 EventAttributes.None, typeof (EventHandler));
10376 mb = tb.DefineMethod ("add_OnFamORAssemStatic" + suffix,
10377 MethodAttributes.FamORAssem | MethodAttributes.Static,
10378 typeof (void), Type.EmptyTypes);
10379 mb.GetILGenerator ().Emit (OpCodes.Ret);
10380 eb.SetAddOnMethod (mb);
10382 eb = tb.DefineEvent ("OnPublicStatic" + suffix,
10383 EventAttributes.None, typeof (EventHandler));
10384 mb = tb.DefineMethod ("add_OnPublicStatic" + suffix,
10385 MethodAttributes.Public | MethodAttributes.Static,
10386 typeof (void), Type.EmptyTypes);
10387 mb.GetILGenerator ().Emit (OpCodes.Ret);
10388 eb.SetAddOnMethod (mb);
10390 eb = tb.DefineEvent ("OnAssemblyStatic" + suffix,
10391 EventAttributes.None, typeof (EventHandler));
10392 mb = tb.DefineMethod ("add_OnAssemblyStatic" + suffix,
10393 MethodAttributes.Family | MethodAttributes.Static,
10394 typeof (void), Type.EmptyTypes);
10395 mb.GetILGenerator ().Emit (OpCodes.Ret);
10396 eb.SetAddOnMethod (mb);
10399 static TypeBuilder Resolve1_Tb;
10400 static bool Resolve1_Called;
10402 public class Lookup<T>
10404 public static Type t = typeof(T);
10407 Assembly Resolve1 (object sender, ResolveEventArgs args) {
10408 Resolve1_Called = true;
10409 Resolve1_Tb.CreateType ();
10410 return Resolve1_Tb.Assembly;
10414 public void TypeResolveGenericInstances () {
10415 // Test that TypeResolve is called for generic instances (#483852)
10416 TypeBuilder tb1 = null;
10418 AppDomain.CurrentDomain.TypeResolve += Resolve1;
10420 tb1 = module.DefineType("Foo");
10422 FieldInfo field = TypeBuilder.GetField(typeof(Lookup<>).MakeGenericType(tb1), typeof(Lookup<>).GetField("t"));
10423 TypeBuilder tb2 = module.DefineType("Bar");
10424 ConstructorBuilder cb = tb2.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
10425 ILGenerator ilgen = cb.GetILGenerator();
10427 ilgen.Emit(OpCodes.Ldarg_0);
10428 ilgen.Emit(OpCodes.Call, tb2.BaseType.GetConstructor(Type.EmptyTypes));
10430 ilgen.Emit(OpCodes.Ldsfld, field);
10431 ilgen.Emit(OpCodes.Pop);
10432 ilgen.Emit(OpCodes.Ret);
10433 Activator.CreateInstance(tb2.CreateType());
10435 Assert.IsTrue (Resolve1_Called);
10439 public void CreateConcreteTypeWithAbstractMethod ()
10441 TypeBuilder tb = module.DefineType (genTypeName ());
10442 tb.DefineMethod("method", MethodAttributes.Abstract | MethodAttributes.Public, typeof (void), Type.EmptyTypes);
10445 Assert.Fail ("#1");
10446 } catch (InvalidOperationException) {}
10450 public void ConcreteTypeDontLeakGenericParamFromItSelf ()
10452 var tb = module.DefineType (genTypeName ());
10453 var gps = tb.DefineGenericParameters ("T");
10454 var mb = tb.DefineMethod ("m", MethodAttributes.Public | MethodAttributes.Static);
10455 mb.SetParameters (gps);
10456 mb.GetILGenerator ().Emit (OpCodes.Ret);
10458 var ti = tb.CreateType ();
10459 var mi = ti.GetMethod ("m");
10460 var arg0 = mi.GetParameters () [0].ParameterType;
10462 Assert.AreNotSame (arg0, gps [0], "#1");
10466 public void ConcreteTypeDontLeakGenericParamFromMethods ()
10468 var tb = module.DefineType (genTypeName ());
10469 var mb = tb.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Static);
10470 var gps = mb.DefineGenericParameters ("T");
10471 mb.SetParameters (gps);
10472 mb.GetILGenerator ().Emit (OpCodes.Ret);
10474 var ti = tb.CreateType ();
10475 var mi = ti.GetMethod ("m");
10476 var arg0 = mi.GetParameters () [0].ParameterType;
10478 Assert.AreNotSame (arg0, gps [0], "#1");
10482 public void DeclaringMethodReturnsNull ()
10484 TypeBuilder tb = module.DefineType (genTypeName ());
10485 Assert.IsNull (tb.DeclaringMethod, null, "#1");
10489 public void GenericParameterPositionReturns0 ()
10491 TypeBuilder tb = module.DefineType (genTypeName ());
10492 Assert.AreEqual (0, tb.GenericParameterPosition, "#1");
10496 public void GetGenericTypeDefinitionBehavior ()
10498 TypeBuilder tb = module.DefineType (genTypeName ());
10500 tb.GetGenericTypeDefinition ();
10501 Assert.Fail ("#1");
10502 } catch (InvalidOperationException) {}
10504 tb.DefineGenericParameters ("T");
10505 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#2");
10508 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#3");
10512 public void GetElementTypeNotSupported ()
10514 TypeBuilder tb = module.DefineType (genTypeName ());
10516 tb.GetElementType ();
10517 Assert.Fail ("#1");
10518 } catch (NotSupportedException) {}
10522 public void GenericParameterAttributesReturnsNone ()
10524 TypeBuilder tb = module.DefineType (genTypeName ());
10525 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#1");
10527 tb.DefineGenericParameters ("T");
10528 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#2");
10531 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#3");
10535 public void GetGenericArgumentsReturnsNullForNonGenericTypeBuilder ()
10537 TypeBuilder tb = module.DefineType (genTypeName ());
10538 Assert.IsNull (tb.GetGenericArguments (), "#1");
10541 public interface IFaceA {}
10542 public interface IFaceB : IFaceA {}
10544 public void GetInterfacesAfterCreate ()
10546 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type[] { typeof (IFaceB) });
10548 Type[] ifaces = tb.GetInterfaces ();
10549 Assert.AreEqual (1, ifaces.Length, "#1");
10550 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#2");
10553 ifaces = tb.GetInterfaces ();
10554 Assert.AreEqual (2, ifaces.Length, "#3");
10555 //Interfaces can come in any particular order
10556 if (ifaces [0] == typeof (IFaceB)) {
10557 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#4");
10558 Assert.AreEqual (typeof (IFaceA), ifaces [1], "#5");
10560 Assert.AreEqual (typeof (IFaceB), ifaces [1], "#4");
10561 Assert.AreEqual (typeof (IFaceA), ifaces [0], "#5");
10565 public interface MB_Iface
10570 public class MB_Impl : MB_Iface
10572 public virtual int Test () { return 1; }
10575 public void MethodOverrideBodyMustBelongToTypeBuilder ()
10577 TypeBuilder tb = module.DefineType (genTypeName ());
10578 MethodInfo md = typeof (MB_Iface).GetMethod("Test");
10579 MethodInfo md2 = typeof (MB_Impl).GetMethod("Test");
10581 tb.DefineMethodOverride (md, md2);
10582 Assert.Fail ("#1");
10583 } catch (ArgumentException) {}
10587 public void GetConstructorsThrowWhenIncomplete ()
10589 TypeBuilder tb = module.DefineType (genTypeName ());
10591 tb.GetConstructors (BindingFlags.Instance);
10592 Assert.Fail ("#1");
10593 } catch (NotSupportedException) { }
10596 Assert.IsNotNull (tb.GetConstructors (BindingFlags.Instance), "#2");
10600 public void GetEventsThrowWhenIncomplete ()
10602 TypeBuilder tb = module.DefineType (genTypeName ());
10604 tb.GetEvents (BindingFlags.Instance);
10605 Assert.Fail ("#1");
10606 } catch (NotSupportedException) { }
10609 Assert.IsNotNull (tb.GetEvents (BindingFlags.Instance), "#2");
10613 public void GetNestedTypeCreatedAfterTypeIsCreated ()
10615 TypeBuilder tb = module.DefineType (genTypeName ());
10616 TypeBuilder nested = tb.DefineNestedType ("Bar", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10618 Assert.IsNull (tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#1");
10619 Type res = nested.CreateType ();
10620 Assert.AreEqual (res, tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#2");
10622 TypeBuilder nested2 = tb.DefineNestedType ("Bar2", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10623 Assert.IsNull (tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#3");
10624 res = nested2.CreateType ();
10625 Assert.AreEqual (res, tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#4");
10630 public void IsDefinedThrowWhenIncomplete ()
10632 TypeBuilder tb = module.DefineType (genTypeName ());
10634 tb.IsDefined (typeof (string), true);
10635 Assert.Fail ("#1");
10636 } catch (NotSupportedException) { }
10639 Assert.IsNotNull (tb.IsDefined (typeof (string), true), "#2");
10642 [Test] //Bug #594728
10643 public void IsSubclassOfWorksIfSetParentIsCalledOnParent ()
10645 var tb_a = module.DefineType ("A", TypeAttributes.Public);
10646 var tb_b = module.DefineType ("B", TypeAttributes.Public);
10648 tb_b.SetParent (tb_a);
10649 tb_a.SetParent (typeof (Attribute));
10651 Assert.IsTrue (tb_b.IsSubclassOf (tb_a), "#1");
10652 Assert.IsTrue (tb_b.IsSubclassOf (typeof (Attribute)), "#2");
10653 Assert.IsFalse (tb_a.IsSubclassOf (tb_b), "#3");
10656 var a = tb_a.CreateType ();
10657 var b = tb_b.CreateType ();
10659 Assert.IsTrue (b.IsSubclassOf (a), "#4");
10660 Assert.IsTrue (b.IsSubclassOf (typeof (Attribute)), "#5");
10661 Assert.IsFalse (a.IsSubclassOf (b), "#6");
10665 public void DefinedDefaultConstructorWorksWithGenericBaseType ()
10667 AssemblyName assemblyName = new AssemblyName ("a");
10668 AssemblyBuilder ass = AppDomain.CurrentDomain.DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.RunAndSave);
10669 var mb = ass.DefineDynamicModule ("a.dll");
10671 var tb = mb.DefineType ("Base");
10672 tb.DefineGenericParameters ("F");
10674 var inst = tb.MakeGenericType (typeof (int));
10675 var tb2 = mb.DefineType ("Child", TypeAttributes.Public, inst);
10678 var res = tb2.CreateType ();
10680 Assert.IsNotNull (res, "#1");
10681 Assert.AreEqual (1, res.GetConstructors ().Length, "#2");
10685 * Tests for passing user types to Ref.Emit. Currently these only test
10686 * whenever the runtime code can handle them without crashing, since we
10687 * don't support user types yet.
10688 * These tests are disabled for windows since the MS runtime trips on them.
10691 [Category ("NotDotNet")] //Proper UT handling is a mono extension to SRE bugginess
10692 public void UserTypes () {
10693 TypeDelegator t = new TypeDelegator (typeof (int));
10697 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, t);
10703 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { t });
10710 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10711 tb.DefineField ("Foo", t, FieldAttributes.Public);
10717 /* Custom modifiers on fields */
10718 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10719 tb.DefineField ("Foo", typeof (int), new Type [] { t }, new Type [] { t }, FieldAttributes.Public);
10723 /* this is mono only
10725 UnmanagedMarshal m = UnmanagedMarshal.DefineCustom (t, "foo", "bar", Guid.Empty);
10726 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10727 FieldBuilder fb = tb.DefineField ("Foo", typeof (int), FieldAttributes.Public);
10735 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10736 tb.DefineProperty ("Foo", PropertyAttributes.None, t, null);
10742 /* Custom modifiers on properties */
10743 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10744 // FIXME: These seems to be ignored
10745 tb.DefineProperty ("Foo", PropertyAttributes.None, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10751 /* Method return types */
10752 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10753 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, t, null);
10754 mb.GetILGenerator ().Emit (OpCodes.Ret);
10760 /* Custom modifiers on method return types */
10761 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10762 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10763 mb.GetILGenerator ().Emit (OpCodes.Ret);
10769 /* Method parameters */
10770 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10771 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, typeof (int), new Type [] { t });
10772 mb.GetILGenerator ().Emit (OpCodes.Ret);
10778 /* Custom modifiers on method parameters */
10779 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10780 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 }});
10781 mb.GetILGenerator ().Emit (OpCodes.Ret);
10787 /* Ctor parameters */
10788 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10789 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { t });
10790 mb.GetILGenerator ().Emit (OpCodes.Ret);
10796 /* Custom modifiers on ctor parameters */
10797 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10798 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { typeof (int) }, new Type [][] { new Type [] { t }}, new Type[][] { new Type [] { t }});
10799 mb.GetILGenerator ().Emit (OpCodes.Ret);
10805 /* SignatureHelper arguments */
10806 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10807 sighelper.AddArgument (t, false);
10808 byte[] arr = sighelper.GetSignature ();
10813 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10814 sighelper.AddArgument (t, false);
10815 byte[] arr = sighelper.GetSignature ();
10820 /* Custom modifiers on SignatureHelper arguments */
10821 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10822 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10823 byte[] arr = sighelper.GetSignature ();
10828 /* Custom modifiers on SignatureHelper arguments */
10829 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10830 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10831 byte[] arr = sighelper.GetSignature ();
10835 /* Arguments to ILGenerator methods */
10838 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10839 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10840 ILGenerator ig = mb.GetILGenerator ();
10841 ig.Emit (OpCodes.Ldnull);
10842 ig.Emit (OpCodes.Castclass, t);
10843 ig.Emit (OpCodes.Pop);
10844 ig.Emit (OpCodes.Ret);
10850 /* DeclareLocal () */
10851 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10852 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10853 ILGenerator ig = mb.GetILGenerator ();
10854 ig.DeclareLocal (t);
10855 ig.Emit (OpCodes.Ret);
10861 /* BeginExceptionCatchBlock () */
10862 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10863 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10864 ILGenerator ig = mb.GetILGenerator ();
10865 ig.BeginExceptionBlock ();
10866 ig.BeginCatchBlock (t);
10867 ig.Emit (OpCodes.Ret);
10874 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10875 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10876 ILGenerator ig = mb.GetILGenerator ();
10877 ig.EmitCalli (OpCodes.Call, CallingConventions.Standard, typeof (void), new Type [] { t }, null);
10878 ig.Emit (OpCodes.Ret);
10886 public void CircularArrayType()
10888 var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess.RunAndSave);
10889 var moduleBuilder = assemblyBuilder.DefineDynamicModule("Test", "Test.dll", true);
10890 var typeBuilder = moduleBuilder.DefineType("Foo", TypeAttributes.Public);
10891 var fieldBuilder = typeBuilder.DefineField("Foos", typeBuilder.MakeArrayType(), FieldAttributes.Public);
10893 var fooType = typeBuilder.CreateType();
10894 Assert.AreSame(fooType.MakeArrayType(), fooType.GetField("Foos").FieldType);
10898 [Test] //Test for #422113
10899 [ExpectedException (typeof (TypeLoadException))]
10900 public void CreateInstanceOfIncompleteType ()
10902 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class, null, new Type[] { typeof (IComparable) });
10903 Type proxyType = tb.CreateType();
10904 Activator.CreateInstance(proxyType);
10907 [Test] //Test for #640780
10908 public void StaticMethodNotUsedInIfaceVtable ()
10910 TypeBuilder tb1 = module.DefineType("Interface", TypeAttributes.Interface | TypeAttributes.Abstract);
10911 tb1.DefineTypeInitializer().GetILGenerator().Emit(OpCodes.Ret);
10912 tb1.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Abstract);
10915 TypeBuilder tb2 = module.DefineType("Class", TypeAttributes.Sealed);
10916 tb2.AddInterfaceImplementation(tb1);
10917 tb2.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Virtual)
10918 .GetILGenerator().Emit(OpCodes.Ret);
10919 tb2.DefineDefaultConstructor(MethodAttributes.Public);
10921 Activator.CreateInstance(tb2.CreateType());
10924 [Test] //Test for #648391
10925 public void GetConstructorCheckCtorDeclaringType ()
10927 TypeBuilder myType = module.DefineType ("Sample", TypeAttributes.Public);
10928 string[] typeParamNames = { "TFirst" };
10929 GenericTypeParameterBuilder[] typeParams = myType.DefineGenericParameters (typeParamNames);
10930 var ctor = myType.DefineDefaultConstructor (MethodAttributes.Public);
10931 var ctori = TypeBuilder.GetConstructor (myType.MakeGenericType (typeof (int)), ctor);
10933 TypeBuilder.GetConstructor (myType.MakeGenericType (typeof (bool)), ctori);
10934 Assert.Fail ("#1");
10935 } catch (ArgumentException) {
10940 [Test] //Test for #649237
10941 public void GetFieldCheckFieldDeclaringType () {
10942 TypeBuilder myType = module.DefineType ("Sample", TypeAttributes.Public);
10943 myType.DefineGenericParameters ( "TFirst");
10944 TypeBuilder otherType = module.DefineType ("Sample2", TypeAttributes.Public);
10945 otherType.DefineGenericParameters ( "TFirst");
10947 var field = myType.DefineField ("field", typeof (object), FieldAttributes.Public);
10950 TypeBuilder.GetField (otherType.MakeGenericType (typeof (int)), field);
10951 Assert.Fail ("#1");
10952 } catch (ArgumentException) {
10958 public void TypeWithFieldRVAWorksUnderSgen () {
10959 AssemblyName an = new AssemblyName("MAIN");
10960 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(an,
10961 AssemblyBuilderAccess.Run, ".");
10962 ModuleBuilder mob = ab.DefineDynamicModule("MAIN");
10963 TypeBuilder tb = mob.DefineType("MAIN", TypeAttributes.Public |
10964 TypeAttributes.Sealed | TypeAttributes.Abstract |
10965 TypeAttributes.Class | TypeAttributes.BeforeFieldInit);
10967 byte[] source = new byte[] { 42 };
10968 FieldBuilder fb = tb.DefineInitializedData("A0", source, 0);
10970 MethodBuilder mb = tb.DefineMethod("EVAL", MethodAttributes.Static |
10971 MethodAttributes.Public, typeof(byte[]), new Type[] { });
10972 ILGenerator il = mb.GetILGenerator();
10974 il.Emit(OpCodes.Ldc_I4_1);
10975 il.Emit(OpCodes.Newarr, typeof(byte));
10976 il.Emit(OpCodes.Dup);
10977 il.Emit(OpCodes.Ldtoken, fb);
10978 il.Emit(OpCodes.Call, typeof(RuntimeHelpers).GetMethod("InitializeArray"));
10979 il.Emit(OpCodes.Ret);
10981 Type t = tb.CreateType();
10985 byte[] res = (byte[]) t.InvokeMember("EVAL", BindingFlags.Public |
10986 BindingFlags.Static | BindingFlags.InvokeMethod, null, null,
10989 Assert.AreEqual (42, res[0]);
10994 public void Ldfld_Regress_9531 () {
10995 Build<Example<int>> ();
10999 var base_class = typeof(T);
11001 var builder = module.DefineType(genTypeName (),
11002 TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
11005 var field = builder.BaseType.GetField("Field", BindingFlags.Instance | BindingFlags.Public);
11007 var cb = builder.DefineConstructor(
11008 MethodAttributes.Public | MethodAttributes.SpecialName,
11009 CallingConventions.HasThis,
11010 new[] { typeof(string) });
11012 var il = cb.GetILGenerator();
11016 throw new InvalidOperationException("wtf");
11019 il.Emit(OpCodes.Ldarg_0);
11020 il.Emit(OpCodes.Ldarg_1);
11021 il.Emit(OpCodes.Stfld, field);
11022 il.Emit(OpCodes.Ret);
11024 builder.CreateType();
11027 public class Example<T> {
11028 public string Field;
11033 public void Ldfld_Encoding_10122 () {
11034 Build2<Example<int>> ();
11037 void Build2<T> () {
11038 var base_class = typeof(T);
11040 string AssemblyName = genTypeName ();
11041 string AssemblyFileName = AssemblyName + ".dll";
11043 var assemblyBuilderAccess = AssemblyBuilderAccess.Save;
11044 var assemblyName = new AssemblyName(AssemblyName);
11045 var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, assemblyBuilderAccess);
11046 var moduleBuilder = assemblyBuilder.DefineDynamicModule(AssemblyName, AssemblyFileName);
11049 var builder = moduleBuilder.DefineType("Wrapped",
11050 TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
11053 var field = builder.BaseType.GetField("Field", BindingFlags.Instance | BindingFlags.Public);
11055 var cb = builder.DefineConstructor(
11056 MethodAttributes.Public | MethodAttributes.SpecialName,
11057 CallingConventions.HasThis,
11058 new[] { typeof(string) });
11060 var il = cb.GetILGenerator();
11064 throw new InvalidOperationException("wtf");
11067 il.Emit(OpCodes.Ldarg_0);
11068 il.Emit(OpCodes.Ldarg_1);
11069 il.Emit(OpCodes.Stfld, field);
11070 il.Emit(OpCodes.Ret);
11072 builder.CreateType();
11074 assemblyBuilder.Save (AssemblyFileName);
11076 var fromDisk = Assembly.Load (AssemblyName);
11077 Console.WriteLine (fromDisk);
11078 var t = fromDisk.GetType ("Wrapped");
11079 Activator.CreateInstance (t, new object[] { "string"});
11082 public interface IFace16096 {
11087 public void MemberRef_Caching_16096 () {
11088 var outer_class = module.DefineType(
11090 TypeAttributes.Class | TypeAttributes.Public,
11093 var builder = outer_class.DefineNestedType(
11095 TypeAttributes.Class | TypeAttributes.Public,
11098 builder.AddInterfaceImplementation (typeof (IFace16096));
11100 var ctor = builder.DefineDefaultConstructor (MethodAttributes.Public);
11101 var field = builder.DefineField ("Field", typeof (object), FieldAttributes.Public);
11102 var g_args = builder.DefineGenericParameters("b","a");
11103 var method = builder.DefineMethod ("Bar", MethodAttributes.Public | MethodAttributes.Virtual, typeof (object), new Type [0]);
11105 var il = method.GetILGenerator();
11106 il.Emit (OpCodes.Ldarg_0);
11107 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (builder.MakeGenericType (g_args), field));
11108 il.Emit (OpCodes.Pop);
11109 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (builder.MakeGenericType (g_args), ctor));
11110 il.Emit (OpCodes.Ret);
11112 var type = builder.CreateType ();
11114 /*Build a gshared instance. */
11115 var ginst = type.MakeGenericType (typeof (List<char>), typeof (object));
11116 var ins = (IFace16096)Activator.CreateInstance (ginst);
11118 /* This will trigger the runtime to cache the MEMBER_REF to the .ctor as it won't have a context. */
11119 var ins2 = ins.Bar ();
11120 Assert.IsNotNull (ins2);
11122 /* Build an unsharable version. */
11123 var ginst2 = type.MakeGenericType (typeof (List<char>), typeof (char));
11124 var ins3 = (IFace16096)Activator.CreateInstance (ginst2);
11126 /* This will trigger the runtime to use the cached version, which is wrong as it's an open type. */
11127 var ins4 = ins3.Bar ();
11128 Assert.IsNotNull (ins4);
11133 [ExpectedException (typeof (TypeLoadException))]
11134 public void PrivateIface ()
11136 TypeBuilder tb = module.DefineType ("Sample", TypeAttributes.Public, typeof (object), new[] { typeof (IFoo) });