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 public void DefineDefaultConstructor_Parent_DefaultCtorInaccessible ()
1189 tb = module.DefineType (genTypeName ());
1190 tb.DefineDefaultConstructor (MethodAttributes.Private);
1191 Type parent_type = tb.CreateType ();
1193 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1195 tb.DefineDefaultConstructor (MethodAttributes.Public);
1196 Type emitted_type = tb.CreateType ();
1198 Activator.CreateInstance (emitted_type);
1200 } catch (TargetInvocationException ex) {
1201 Assert.AreEqual (typeof (TargetInvocationException), ex.GetType (), "#2");
1202 Assert.IsNotNull (ex.InnerException, "#3");
1203 Assert.IsNotNull (ex.Message, "#4");
1205 MethodAccessException mae = ex.InnerException as MethodAccessException;
1206 Assert.IsNotNull (mae, "#5");
1207 Assert.AreEqual (typeof (MethodAccessException), mae.GetType (), "#6");
1208 Assert.IsNull (mae.InnerException, "#7");
1209 Assert.IsNotNull (mae.Message, "#8");
1210 Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#9:" + mae.Message);
1211 Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#10:" + mae.Message);
1216 public void DefineDefaultConstructor_Parent_DefaultCtorMissing ()
1220 tb = module.DefineType (genTypeName ());
1221 ConstructorBuilder cb = tb.DefineConstructor (
1222 MethodAttributes.Public,
1223 CallingConventions.Standard,
1224 new Type [] { typeof (string) });
1225 cb.GetILGenerator ().Emit (OpCodes.Ret);
1226 Type parent_type = tb.CreateType ();
1228 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1231 tb.DefineDefaultConstructor (MethodAttributes.Public);
1233 } catch (NotSupportedException ex) {
1234 // Parent does not have a default constructor.
1235 // The default constructor must be explicitly defined
1236 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1237 Assert.IsNull (ex.InnerException, "#3");
1238 Assert.IsNotNull (ex.Message, "#4");
1243 public void DefineEvent_Name_NullChar ()
1245 TypeBuilder tb = module.DefineType (genTypeName ());
1248 tb.DefineEvent ("\0test", EventAttributes.None,
1250 Assert.Fail ("#A1");
1251 } catch (ArgumentException ex) {
1253 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1254 Assert.IsNull (ex.InnerException, "#A3");
1255 Assert.IsNotNull (ex.Message, "#A4");
1256 Assert.AreEqual ("name", ex.ParamName, "#A5");
1259 EventBuilder eb = tb.DefineEvent ("te\0st", EventAttributes.None,
1261 Assert.IsNotNull (eb, "#B1");
1265 public void TestDefineEvent ()
1267 TypeBuilder tb = module.DefineType (genTypeName ());
1269 // Test invalid arguments
1271 tb.DefineEvent (null, 0, typeof (int));
1272 Assert.Fail ("#A1");
1273 } catch (ArgumentNullException ex) {
1274 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1275 Assert.IsNull (ex.InnerException, "#A3");
1276 Assert.IsNotNull (ex.Message, "#A4");
1277 Assert.AreEqual ("name", ex.ParamName, "#A5");
1281 tb.DefineEvent ("FOO", 0, null);
1282 Assert.Fail ("#B1");
1283 } catch (ArgumentNullException ex) {
1284 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1285 Assert.IsNull (ex.InnerException, "#B3");
1286 Assert.IsNotNull (ex.Message, "#B4");
1287 Assert.AreEqual ("type", ex.ParamName, "#B5");
1291 tb.DefineEvent (string.Empty, 0, typeof (int));
1292 Assert.Fail ("#C1");
1293 } catch (ArgumentException ex) {
1294 // Empty name is not legal
1295 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1296 Assert.IsNull (ex.InnerException, "#C3");
1297 Assert.IsNotNull (ex.Message, "#C4");
1298 Assert.AreEqual ("name", ex.ParamName, "#C5");
1303 // Can not be called on a created type
1305 tb.DefineEvent ("BAR", 0, typeof (int));
1306 Assert.Fail ("#D1");
1307 } catch (InvalidOperationException ex) {
1308 // Unable to change after type has been created
1309 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1310 Assert.IsNull (ex.InnerException, "#D3");
1311 Assert.IsNotNull (ex.Message, "#D4");
1315 [Test] // DefineField (String, Type, FieldAttributes)
1316 public void DefineField1 ()
1318 TypeBuilder tb = module.DefineType (genTypeName ());
1320 // Check invalid arguments
1322 tb.DefineField (null, typeof (int), 0);
1323 Assert.Fail ("#A1");
1324 } catch (ArgumentNullException ex) {
1325 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1326 Assert.IsNull (ex.InnerException, "#A3");
1327 Assert.IsNotNull (ex.Message, "#A4");
1328 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1332 tb.DefineField (string.Empty, typeof (int), 0);
1333 Assert.Fail ("#B1");
1334 } catch (ArgumentException ex) {
1335 // Empty name is not legal
1336 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1337 Assert.IsNull (ex.InnerException, "#B3");
1338 Assert.IsNotNull (ex.Message, "#B4");
1339 Assert.AreEqual ("fieldName", ex.ParamName, "#B5");
1343 // Strangely, 'A<NULL>' is accepted...
1344 string name = String.Format ("{0}", (char) 0);
1345 tb.DefineField (name, typeof (int), 0);
1346 Assert.Fail ("#C1");
1347 } catch (ArgumentException ex) {
1349 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1350 Assert.IsNull (ex.InnerException, "#C3");
1351 Assert.IsNotNull (ex.Message, "#C4");
1352 Assert.AreEqual ("fieldName", ex.ParamName, "#C5");
1356 tb.DefineField ("A", typeof (void), 0);
1357 Assert.Fail ("#D1");
1358 } catch (ArgumentException ex) {
1359 // Bad field type in defining field
1360 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1361 Assert.IsNull (ex.InnerException, "#D3");
1362 Assert.IsNotNull (ex.Message, "#D4");
1363 Assert.IsNull (ex.ParamName, "#D5");
1368 // Can not be called on a created type
1370 tb.DefineField ("B", typeof (int), 0);
1371 Assert.Fail ("#E1");
1372 } catch (InvalidOperationException ex) {
1373 // Unable to change after type has been created
1374 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1375 Assert.IsNull (ex.InnerException, "#E3");
1376 Assert.IsNotNull (ex.Message, "#E4");
1380 [Test] // DefineField (String, Type, FieldAttributes)
1381 public void DefineField1_Name_NullChar ()
1383 TypeBuilder tb = module.DefineType (genTypeName ());
1386 tb.DefineField ("\0test", typeof (int),
1387 FieldAttributes.Private);
1388 Assert.Fail ("#A1");
1389 } catch (ArgumentException ex) {
1391 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1392 Assert.IsNull (ex.InnerException, "#A3");
1393 Assert.IsNotNull (ex.Message, "#A4");
1394 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1397 FieldBuilder fb = tb.DefineField ("te\0st", typeof (int),
1398 FieldAttributes.Private);
1399 Assert.IsNotNull (fb, "#B1");
1400 Assert.AreEqual ("te\0st", fb.Name, "#B2");
1403 [Test] // DefineField (String, Type, FieldAttributes)
1404 public void DefineField1_Type_Null ()
1406 TypeBuilder tb = module.DefineType (genTypeName ());
1409 tb.DefineField ("test", (Type) null,
1410 FieldAttributes.Private);
1412 } catch (ArgumentNullException ex) {
1413 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1414 Assert.IsNull (ex.InnerException, "#3");
1415 Assert.IsNotNull (ex.Message, "#4");
1416 Assert.AreEqual ("type", ex.ParamName, "#5");
1420 [Test] // DefineField (String, Type, Type [], Type [], FieldAttributes)
1421 public void DefineField2_Type_Null ()
1423 TypeBuilder tb = module.DefineType (genTypeName ());
1426 tb.DefineField ("test", (Type) null, Type.EmptyTypes,
1427 Type.EmptyTypes, FieldAttributes.Private);
1429 } catch (ArgumentNullException ex) {
1430 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1431 Assert.IsNull (ex.InnerException, "#3");
1432 Assert.IsNotNull (ex.Message, "#4");
1433 Assert.AreEqual ("type", ex.ParamName, "#5");
1438 public void TestDefineInitializedData ()
1440 TypeBuilder tb = module.DefineType (genTypeName ());
1442 // Check invalid arguments
1444 tb.DefineInitializedData (null, new byte [1], 0);
1445 Assert.Fail ("#A1");
1446 } catch (ArgumentNullException ex) {
1447 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1448 Assert.IsNull (ex.InnerException, "#A3");
1449 Assert.IsNotNull (ex.Message, "#A4");
1450 Assert.AreEqual ("name", ex.ParamName, "#A5");
1454 tb.DefineInitializedData ("FOO", null, 0);
1455 Assert.Fail ("#B1");
1456 } catch (ArgumentNullException ex) {
1457 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1458 Assert.IsNull (ex.InnerException, "#B3");
1459 Assert.IsNotNull (ex.Message, "#B4");
1460 Assert.AreEqual ("data", ex.ParamName, "#B5");
1464 tb.DefineInitializedData (string.Empty, new byte [1], 0);
1465 Assert.Fail ("#C1");
1466 } catch (ArgumentException ex) {
1467 // Empty name is not legal
1468 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1469 Assert.IsNull (ex.InnerException, "#C3");
1470 Assert.IsNotNull (ex.Message, "#C4");
1471 Assert.AreEqual ("name", ex.ParamName, "#C5");
1474 // The size of the data is less than or equal to zero ???
1476 tb.DefineInitializedData ("BAR", new byte [0], 0);
1477 Assert.Fail ("#D1");
1478 } catch (ArgumentException ex) {
1479 // Data size must be > 0 and < 0x3f0000
1480 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1481 Assert.IsNull (ex.InnerException, "#D3");
1482 Assert.IsNotNull (ex.Message, "#D4");
1483 Assert.IsNull (ex.ParamName, "#D5");
1487 string name = String.Format ("{0}", (char) 0);
1488 tb.DefineInitializedData (name, new byte [1], 0);
1489 Assert.Fail ("#E1");
1490 } catch (ArgumentException ex) {
1492 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#E2");
1493 Assert.IsNull (ex.InnerException, "#E3");
1494 Assert.IsNotNull (ex.Message, "#E4");
1495 Assert.AreEqual ("fieldName", ex.ParamName, "#E5");
1500 // Can not be called on a created type, altough the MSDN docs does not mention this
1502 tb.DefineInitializedData ("BAR2", new byte [1], 0);
1503 Assert.Fail ("#F1");
1504 } catch (InvalidOperationException ex) {
1505 // Unable to change after type has been created
1506 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
1507 Assert.IsNull (ex.InnerException, "#F3");
1508 Assert.IsNotNull (ex.Message, "#F4");
1513 public void DefineUninitializedDataInvalidArgs ()
1515 TypeBuilder tb = module.DefineType (genTypeName ());
1518 tb.DefineUninitializedData (null, 1, 0);
1519 Assert.Fail ("#A1");
1520 } catch (ArgumentNullException ex) {
1521 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1522 Assert.IsNull (ex.InnerException, "#A3");
1523 Assert.IsNotNull (ex.Message, "#A4");
1524 Assert.AreEqual ("name", ex.ParamName, "#A5");
1528 tb.DefineUninitializedData (string.Empty, 1, 0);
1529 Assert.Fail ("#B1");
1530 } catch (ArgumentException ex) {
1531 // Empty name is not legal
1532 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1533 Assert.IsNull (ex.InnerException, "#B3");
1534 Assert.IsNotNull (ex.Message, "#B4");
1535 Assert.AreEqual ("name", ex.ParamName, "#B5");
1538 // The size of the data is less than or equal to zero ???
1540 tb.DefineUninitializedData ("BAR", 0, 0);
1541 Assert.Fail ("#C1");
1542 } catch (ArgumentException ex) {
1543 // Data size must be > 0 and < 0x3f0000
1544 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1545 Assert.IsNull (ex.InnerException, "#C3");
1546 Assert.IsNotNull (ex.Message, "#C4");
1547 Assert.IsNull (ex.ParamName, "#C5");
1551 string name = String.Format ("{0}", (char) 0);
1552 tb.DefineUninitializedData (name, 1, 0);
1553 Assert.Fail ("#D1");
1554 } catch (ArgumentException ex) {
1556 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1557 Assert.IsNull (ex.InnerException, "#D3");
1558 Assert.IsNotNull (ex.Message, "#D4");
1559 Assert.AreEqual ("fieldName", ex.ParamName, "#D5");
1564 public void DefineUninitializedDataAlreadyCreated ()
1566 TypeBuilder tb = module.DefineType (genTypeName ());
1569 tb.DefineUninitializedData ("BAR2", 1, 0);
1571 } catch (InvalidOperationException ex) {
1572 // Unable to change after type has been created
1573 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1574 Assert.IsNull (ex.InnerException, "#3");
1575 Assert.IsNotNull (ex.Message, "#4");
1580 public void DefineUninitializedData ()
1582 TypeBuilder tb = module.DefineType (genTypeName ());
1584 tb.DefineUninitializedData ("foo", 4, FieldAttributes.Public);
1586 Type t = tb.CreateType ();
1588 object o = Activator.CreateInstance (t);
1590 FieldInfo fi = t.GetField ("foo");
1592 object fieldVal = fi.GetValue (o);
1594 IntPtr ptr = Marshal.AllocHGlobal (4);
1595 Marshal.StructureToPtr (fieldVal, ptr, true);
1596 Marshal.FreeHGlobal (ptr);
1600 public void DefineMethod_Name_NullChar ()
1602 TypeBuilder tb = module.DefineType (genTypeName ());
1604 tb.DefineMethod ("\0test", MethodAttributes.Private,
1605 typeof (string), Type.EmptyTypes);
1606 Assert.Fail ("#A1");
1607 } catch (ArgumentException ex) {
1609 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1610 Assert.IsNull (ex.InnerException, "#A3");
1611 Assert.IsNotNull (ex.Message, "#A4");
1612 Assert.AreEqual ("name", ex.ParamName, "#A5");
1615 MethodBuilder mb = tb.DefineMethod ("te\0st", MethodAttributes.Private,
1616 typeof (string), Type.EmptyTypes);
1617 Assert.IsNotNull (mb, "#B1");
1618 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1622 public void TestDefineMethod ()
1624 TypeBuilder tb = module.DefineType (genTypeName ());
1626 // Check invalid arguments
1628 tb.DefineMethod (null, 0, null, null);
1629 Assert.Fail ("#A1");
1630 } catch (ArgumentNullException ex) {
1631 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1632 Assert.IsNull (ex.InnerException, "#A3");
1633 Assert.IsNotNull (ex.Message, "#A4");
1634 Assert.AreEqual ("name", ex.ParamName, "#A5");
1638 tb.DefineMethod (string.Empty, 0, null, null);
1639 Assert.Fail ("#B1");
1640 } catch (ArgumentException ex) {
1641 // Empty name is not legal
1642 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1643 Assert.IsNull (ex.InnerException, "#B3");
1644 Assert.IsNotNull (ex.Message, "#B4");
1645 Assert.AreEqual ("name", ex.ParamName, "#B5");
1648 // Check non-virtual methods on an interface
1649 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1651 tb2.DefineMethod ("FOO", MethodAttributes.Abstract, null, null);
1652 Assert.Fail ("#C1");
1653 } catch (ArgumentException ex) {
1654 // Interface method must be abstract and virtual
1655 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1656 Assert.IsNull (ex.InnerException, "#C3");
1657 Assert.IsNotNull (ex.Message, "#C4");
1658 Assert.IsNull (ex.ParamName, "#C5");
1661 // Check static methods on an interface
1662 tb2.DefineMethod ("BAR", MethodAttributes.Public | MethodAttributes.Static,
1667 // Can not be called on a created type
1669 tb.DefineMethod ("bar", 0, null, null);
1670 Assert.Fail ("#D1");
1671 } catch (InvalidOperationException ex) {
1672 // Unable to change after type has been created
1673 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1674 Assert.IsNull (ex.InnerException, "#D3");
1675 Assert.IsNotNull (ex.Message, "#D4");
1679 [Test] // bug #327484
1680 [Category ("NotWorking")]
1681 public void TestDefineMethod_Abstract ()
1683 TypeBuilder tb = module.DefineType (genTypeName ());
1684 tb.DefineMethod ("Run", MethodAttributes.Public |
1685 MethodAttributes.Abstract | MethodAttributes.Virtual,
1686 typeof (void), Type.EmptyTypes);
1690 Assert.Fail ("#A1");
1691 } catch (InvalidOperationException ex) {
1692 // Type must be declared abstract if any of its
1693 // methods are abstract
1694 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1695 Assert.IsNull (ex.InnerException, "#A3");
1696 Assert.IsNotNull (ex.Message, "#A4");
1699 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract);
1700 tb.DefineMethod ("Run", MethodAttributes.Public |
1701 MethodAttributes.Abstract, typeof (void),
1706 Assert.Fail ("#B1");
1707 } catch (TypeLoadException ex) {
1708 // Non-virtual abstract method
1709 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B2");
1710 Assert.IsNull (ex.InnerException, "#B3");
1711 Assert.IsNotNull (ex.Message, "#B4");
1714 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract |
1715 TypeAttributes.Public);
1716 tb.DefineMethod ("Run", MethodAttributes.Public |
1717 MethodAttributes.Abstract | MethodAttributes.Virtual,
1718 typeof (void), Type.EmptyTypes);
1719 Type emittedType = tb.CreateType ();
1721 MethodInfo mi1 = emittedType.GetMethod ("Run");
1722 Assert.IsNotNull (mi1, "#C1");
1723 Assert.IsTrue (mi1.IsAbstract, "#C2");
1725 MethodInfo mi2 = tb.GetMethod ("Run");
1726 Assert.IsNotNull (mi2, "#D1");
1727 Assert.IsTrue (mi2.IsAbstract, "#D2");
1730 // TODO: DefineMethodOverride
1733 public void TestDefineNestedType ()
1735 TypeBuilder tb = module.DefineType (genTypeName ());
1737 // Check invalid arguments
1739 tb.DefineNestedType (null);
1740 Assert.Fail ("#A1");
1741 } catch (ArgumentNullException ex) {
1742 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1743 Assert.IsNull (ex.InnerException, "#A3");
1744 Assert.IsNotNull (ex.Message, "#A4");
1745 Assert.AreEqual ("fullname", ex.ParamName, "#A5");
1749 tb.DefineNestedType (string.Empty);
1750 Assert.Fail ("#B1");
1751 } catch (ArgumentException ex) {
1752 // Empty name is not legal
1753 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1754 Assert.IsNull (ex.InnerException, "#B3");
1755 Assert.IsNotNull (ex.Message, "#B4");
1756 Assert.AreEqual ("fullname", ex.ParamName, "#B5");
1760 tb.DefineNestedType (nullName ());
1761 Assert.Fail ("#C1");
1762 } catch (ArgumentException ex) {
1764 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1765 Assert.IsNull (ex.InnerException, "#C3");
1766 Assert.IsNotNull (ex.Message, "#C4");
1767 Assert.AreEqual ("fullname", ex.ParamName, "#C5");
1770 // If I fix the code so this works then mcs breaks -> how can mcs
1771 // works under MS .NET in the first place ???
1774 tb.DefineNestedType ("AA", TypeAttributes.Public, null, null);
1775 Fail ("Nested visibility must be specified.");
1777 catch (ArgumentException) {
1782 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1784 Assert.Fail ("#D1");
1785 } catch (ArgumentNullException ex) {
1786 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#D2");
1787 Assert.IsNull (ex.InnerException, "#D3");
1788 Assert.IsNotNull (ex.Message, "#D4");
1789 Assert.AreEqual ("interfaces", ex.ParamName, "#D5");
1792 // I think this should reject non-interfaces, but it does not
1793 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1794 new Type [1] { typeof (object) });
1796 // Normal invocation
1797 tb.DefineNestedType ("Nest");
1801 // According to the MSDN docs, this cannnot be called after the type
1802 // is created, but it works.
1803 tb.DefineNestedType ("Nest2");
1805 // According to the MSDN docs, a Sealed class can't contain nested
1806 // types, but this is not true
1807 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
1808 tb2.DefineNestedType ("AA");
1810 // According to the MSDN docs, interfaces can only contain interfaces,
1811 // but this is not true
1812 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1814 tb3.DefineNestedType ("AA");
1816 // Check shorter versions
1818 TypeBuilder nested = tb.DefineNestedType ("N1");
1820 Assert.AreEqual ("N1", nested.Name, "#E1");
1821 Assert.AreEqual (typeof (object), nested.BaseType, "#E2");
1822 Assert.AreEqual (TypeAttributes.NestedPrivate, nested.Attributes, "#E3");
1823 Assert.AreEqual (0, nested.GetInterfaces ().Length, "#E4");
1830 public void DefinePInvokeMethod_Name_NullChar ()
1832 TypeBuilder tb = module.DefineType (genTypeName ());
1834 tb.DefinePInvokeMethod ("\0test", "B", "C",
1835 MethodAttributes.Private, CallingConventions.Standard,
1836 typeof (string),Type.EmptyTypes, CallingConvention.Cdecl,
1838 Assert.Fail ("#A1");
1839 } catch (ArgumentException ex) {
1841 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1842 Assert.IsNull (ex.InnerException, "#A3");
1843 Assert.IsNotNull (ex.Message, "#A4");
1844 Assert.AreEqual ("name", ex.ParamName, "#A5");
1847 MethodBuilder mb = tb.DefinePInvokeMethod ("te\0st", "B", "C",
1848 MethodAttributes.Private, CallingConventions.Standard,
1849 typeof (string), Type.EmptyTypes, CallingConvention.Cdecl,
1851 Assert.IsNotNull (mb, "#B1");
1852 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1856 public void TestDefinePInvokeMethod ()
1858 TypeBuilder tb = module.DefineType (genTypeName ());
1860 tb.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1862 // Try invalid parameters
1864 tb.DefinePInvokeMethod (null, "B", "C", 0, 0, null, null, 0, 0);
1865 Assert.Fail ("#A1");
1866 } catch (ArgumentNullException ex) {
1867 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1868 Assert.IsNull (ex.InnerException, "#A3");
1869 Assert.IsNotNull (ex.Message, "#A4");
1870 Assert.AreEqual ("name", ex.ParamName, "#A5");
1874 // Try invalid attributes
1876 tb.DefinePInvokeMethod ("A2", "B", "C", MethodAttributes.Abstract, 0, null, null, 0, 0);
1877 Assert.Fail ("#B1");
1878 } catch (ArgumentException ex) {
1879 // PInvoke methods must be static and native and
1880 // cannot be abstract
1881 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1882 Assert.IsNull (ex.InnerException, "#B3");
1883 Assert.IsNotNull (ex.Message, "#B4");
1884 Assert.IsNull (ex.ParamName, "#B5");
1887 // Try an interface parent
1888 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1891 tb2.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1892 Assert.Fail ("#C1");
1893 } catch (ArgumentException ex) {
1894 // PInvoke methods cannot exist on interfaces
1895 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1896 Assert.IsNull (ex.InnerException, "#B3");
1897 Assert.IsNotNull (ex.Message, "#B4");
1898 Assert.IsNull (ex.ParamName, "#B5");
1903 public void DefineProperty_Name_NullChar ()
1905 TypeBuilder tb = module.DefineType (genTypeName ());
1908 tb.DefineProperty ("\0test", 0, typeof (string), Type.EmptyTypes);
1909 Assert.Fail ("#A1");
1910 } catch (ArgumentException ex) {
1912 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1913 Assert.IsNull (ex.InnerException, "#A3");
1914 Assert.IsNotNull (ex.Message, "#A4");
1915 Assert.AreEqual ("name", ex.ParamName, "#A5");
1918 PropertyBuilder pb = tb.DefineProperty ("te\0st", 0,
1919 typeof (string), Type.EmptyTypes);
1920 Assert.IsNotNull (pb, "#B1");
1921 Assert.AreEqual ("te\0st", pb.Name, "#B2");
1925 public void DefineProperty_ParameterTypes_ItemNull ()
1927 TypeBuilder tb = module.DefineType (genTypeName ());
1930 tb.DefineProperty ("A", 0, typeof (string), new Type [1]);
1932 } catch (ArgumentNullException ex) {
1933 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1934 Assert.IsNull (ex.InnerException, "#3");
1935 Assert.IsNotNull (ex.Message, "#4");
1940 public void DefineProperty_ReturnType_Null ()
1942 TypeBuilder tb = module.DefineType (genTypeName ());
1943 tb.DefineProperty ("A", 0, null, Type.EmptyTypes);
1947 public void GetMethod_WorksWithTypeBuilderParameter () {
1948 TypeBuilder tb = module.DefineType (genTypeName ());
1949 var garg = tb.DefineGenericParameters ("T") [0];
1950 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
1952 var mi = TypeBuilder.GetMethod (tb, mb);
1953 var decl = mi.DeclaringType;
1955 Assert.IsTrue (decl.IsGenericType, "#1");
1956 Assert.IsFalse (decl.IsGenericTypeDefinition, "#2");
1957 Assert.AreEqual (tb, decl.GetGenericTypeDefinition (), "#3");
1958 Assert.AreEqual (garg, decl.GetGenericArguments () [0], "#4");
1962 public void GetConstructor_FailWithTypeBuilderParameter () {
1963 TypeBuilder tb = module.DefineType (genTypeName ());
1964 var garg = tb.DefineGenericParameters ("T") [0];
1965 var cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
1968 TypeBuilder.GetConstructor (tb, cb);
1970 } catch (ArgumentException ex) {
1971 Assert.AreEqual ("type", ex.ParamName, "#2");
1976 public void GetField_FailWithTypeBuilderParameter () {
1977 TypeBuilder tb = module.DefineType (genTypeName ());
1978 var garg = tb.DefineGenericParameters ("T") [0];
1979 var fb = tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
1982 TypeBuilder.GetField (tb, fb);
1984 } catch (ArgumentException ex) {
1985 Assert.AreEqual ("type", ex.ParamName, "#2");
1990 public void GetMethod_RejectMethodFromInflatedTypeBuilder () {
1991 TypeBuilder tb = module.DefineType (genTypeName ());
1992 tb.DefineGenericParameters ("T");
1993 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
1995 Type ginst = tb.MakeGenericType (typeof (int));
1997 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
1999 TypeBuilder.GetMethod (ginst, mi);
2001 } catch (ArgumentException ex) {
2002 Assert.AreEqual ("method", ex.ParamName, "#5");
2007 public void GetMethod_WorkWithInstancesOfCreatedTypeBuilder () {
2008 TypeBuilder tb = module.DefineType (genTypeName ());
2009 tb.DefineGenericParameters ("T");
2010 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2011 ILGenerator ig = mb.GetILGenerator ();
2012 ig.Emit (OpCodes.Ret);
2016 MethodInfo mi = TypeBuilder.GetMethod (tb.MakeGenericType (typeof (int)), mb);
2017 Assert.IsNotNull (mi);
2021 [Category ("NotDotNet")]
2022 [Category ("NotWorking")]
2023 public void GetMethod_AcceptMethodFromInflatedTypeBuilder_UnderCompilerContext () {
2024 AssemblyName assemblyName = new AssemblyName ();
2025 assemblyName.Name = ASSEMBLY_NAME;
2028 Thread.GetDomain ().DefineDynamicAssembly (
2029 assemblyName, AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800, Path.GetTempPath ());
2031 module = assembly.DefineDynamicModule ("module1");
2033 TypeBuilder tb = module.DefineType (genTypeName ());
2034 tb.DefineGenericParameters ("T");
2035 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2037 Type ginst = tb.MakeGenericType (typeof (int));
2039 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2042 TypeBuilder.GetMethod (ginst, mi);
2043 } catch (ArgumentException ex) {
2050 // Test that changes made to the method builder after a call to GetMethod ()
2052 public void TestGetMethod ()
2054 TypeBuilder tb = module.DefineType (genTypeName ());
2055 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2057 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2059 ig = cb.GetILGenerator ();
2060 ig.Emit (OpCodes.Ret);
2062 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2064 // Create a method builder but do not emit IL yet
2065 MethodBuilder mb1 = tb.DefineMethod ("create", MethodAttributes.Public|MethodAttributes.Static, fooOfT, Type.EmptyTypes);
2067 Type t = tb.MakeGenericType (typeof (int));
2069 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2071 ig = mb.GetILGenerator ();
2072 ig.Emit (OpCodes.Call, TypeBuilder.GetMethod (t, mb1));
2073 ig.Emit (OpCodes.Ret);
2075 // Finish the method
2076 ig = mb1.GetILGenerator ();
2077 ig.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (fooOfT, cb));
2078 ig.Emit (OpCodes.Ret);
2080 Type t2 = tb.CreateType ();
2082 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2086 public void TestGetConstructor ()
2088 TypeBuilder tb = module.DefineType (genTypeName ());
2089 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2091 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2094 Type t = tb.MakeGenericType (typeof (int));
2096 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2098 ig = mb.GetILGenerator ();
2100 ConstructorInfo ci = TypeBuilder.GetConstructor (t, cb);
2102 ig.Emit (OpCodes.Newobj, ci);
2103 ig.Emit (OpCodes.Ret);
2105 // Finish the ctorbuilder
2106 ig = cb.GetILGenerator ();
2107 ig.Emit(OpCodes.Ldarg_0);
2108 ig.Emit(OpCodes.Call, tb.BaseType.GetConstructor(Type.EmptyTypes));
2109 ig.Emit (OpCodes.Ret);
2111 Type t2 = tb.CreateType ();
2113 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2117 [ExpectedException (typeof (ArgumentException))]
2118 public void Static_GetConstructor_TypeNull ()
2120 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2121 // null is non-generic (from exception message)
2122 TypeBuilder.GetConstructor (null, ci);
2126 [ExpectedException (typeof (ArgumentException))]
2127 public void Static_GetConstructor_TypeGeneric ()
2129 Type t = typeof (List<>).MakeGenericType (typeof (int));
2130 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2131 // type is not 'TypeBuilder' (from exception message)
2132 TypeBuilder.GetConstructor (t, ci);
2136 public void Static_GetConstructor_TypeBuilderGeneric_ConstructorInfoNull ()
2138 TypeBuilder tb = module.DefineType ("XXX");
2139 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2140 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2142 TypeBuilder.GetConstructor (fooOfT, null);
2143 Assert.Fail ("Expected NullReferenceException");
2145 catch (NullReferenceException) {
2150 public void CreateTypeThrowsForMethodsWithBadLabels ()
2152 TypeBuilder tb = module.DefineType (genTypeName ());
2154 MethodBuilder mb = tb.DefineMethod("F", MethodAttributes.Public, typeof(string), null);
2155 ILGenerator il_gen = mb.GetILGenerator ();
2156 il_gen.DefineLabel ();
2157 il_gen.Emit (OpCodes.Leave, new Label ());
2161 } catch (ArgumentException) {}
2165 [Category ("NotWorking")]
2166 public void TestIsDefinedIncomplete ()
2168 TypeBuilder tb = module.DefineType (genTypeName ());
2170 tb.IsDefined (typeof (int), true);
2172 } catch (NotSupportedException ex) {
2173 // The invoked member is not supported in a
2175 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2176 Assert.IsNull (ex.InnerException, "#3");
2177 Assert.IsNotNull (ex.Message, "#4");
2182 public void TestIsDefinedComplete ()
2184 TypeBuilder tb = module.DefineType (genTypeName ());
2186 ConstructorInfo obsoleteCtor = typeof (ObsoleteAttribute).GetConstructor (
2187 new Type [] { typeof (string) });
2189 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (obsoleteCtor,
2190 new object [] { "obsolete message" }, new FieldInfo [0], new object [0]);
2192 tb.SetCustomAttribute (caBuilder);
2194 Assert.IsTrue (tb.IsDefined (typeof (ObsoleteAttribute), false));
2198 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=293659
2199 public void IsDefined_AttributeType_Null ()
2201 TypeBuilder tb = module.DefineType (genTypeName ());
2205 tb.IsDefined ((Type) null, false);
2207 } catch (ArgumentNullException ex) {
2208 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2209 Assert.IsNull (ex.InnerException, "#3");
2210 Assert.IsNotNull (ex.Message, "#4");
2211 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
2215 [Test] // GetConstructor (Type [])
2216 public void GetConstructor1_Incomplete ()
2218 TypeBuilder tb = module.DefineType (genTypeName ());
2219 ConstructorBuilder cb = tb.DefineConstructor (
2220 MethodAttributes.Public,
2221 CallingConventions.Standard,
2223 cb.GetILGenerator ().Emit (OpCodes.Ret);
2226 tb.GetConstructor (Type.EmptyTypes);
2228 } catch (NotSupportedException ex) {
2229 // The invoked member is not supported in a
2231 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2232 Assert.IsNull (ex.InnerException, "#3");
2233 Assert.IsNotNull (ex.Message, "#4");
2237 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2238 public void GetConstructor2_Complete ()
2241 ConstructorInfo ctor;
2243 TypeBuilder redType = module.DefineType (genTypeName (),
2244 TypeAttributes.Public);
2245 CreateMembers (redType, "Red", true);
2247 TypeBuilder greenType = module.DefineType (genTypeName (),
2248 TypeAttributes.Public, redType);
2249 CreateMembers (greenType, "Green", false);
2250 ConstructorBuilder cb = greenType.DefineConstructor (
2251 MethodAttributes.Public,
2252 CallingConventions.Standard,
2254 cb.GetILGenerator ().Emit (OpCodes.Ret);
2256 redType.CreateType ();
2257 greenType.CreateType ();
2259 flags = BindingFlags.Instance | BindingFlags.NonPublic;
2261 ctor = greenType.GetConstructor (flags, null,
2262 new Type [] { typeof (int), typeof (int) },
2263 new ParameterModifier [0]);
2264 Assert.IsNull (ctor, "#A1");
2266 ctor = greenType.GetConstructor (flags, null,
2267 new Type [] { typeof (string) },
2268 new ParameterModifier [0]);
2269 Assert.IsNull (ctor, "#A2");
2271 ctor = greenType.GetConstructor (flags, null,
2272 new Type [] { typeof (string), typeof (string) },
2273 new ParameterModifier [0]);
2274 Assert.IsNull (ctor, "#A3");
2276 ctor = greenType.GetConstructor (flags, null,
2277 new Type [] { typeof (int) },
2278 new ParameterModifier [0]);
2279 Assert.IsNull (ctor, "#A4");
2281 ctor = greenType.GetConstructor (flags, null,
2282 new Type [] { typeof (int), typeof (bool) },
2283 new ParameterModifier [0]);
2284 Assert.IsNull (ctor, "#A5");
2286 ctor = greenType.GetConstructor (flags, null,
2287 new Type [] { typeof (string), typeof (int) },
2288 new ParameterModifier [0]);
2289 Assert.IsNull (ctor, "#A6");
2291 ctor = greenType.GetConstructor (flags, null,
2293 new ParameterModifier [0]);
2294 Assert.IsNull (ctor, "#A7");
2296 ctor = redType.GetConstructor (flags, null,
2297 new Type [] { typeof (int), typeof (int) },
2298 new ParameterModifier [0]);
2299 Assert.IsNotNull (ctor, "#A8a");
2300 Assert.IsTrue (ctor.IsPrivate, "#A8b");
2301 Assert.IsFalse (ctor.IsStatic, "#A8c");
2302 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A8d");
2303 Assert.IsFalse (ctor is ConstructorBuilder, "#A8e");
2305 ctor = redType.GetConstructor (flags, null,
2306 new Type [] { typeof (string) },
2307 new ParameterModifier [0]);
2308 Assert.IsNotNull (ctor, "#A9a");
2309 Assert.IsTrue (ctor.IsFamily, "#A9b");
2310 Assert.IsFalse (ctor.IsStatic, "#A9c");
2311 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A9d");
2312 Assert.IsFalse (ctor is ConstructorBuilder, "#A9e");
2314 ctor = redType.GetConstructor (flags, null,
2315 new Type [] { typeof (string), typeof (string) },
2316 new ParameterModifier [0]);
2317 Assert.IsNotNull (ctor, "#A10a");
2318 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#A10b");
2319 Assert.IsFalse (ctor.IsStatic, "#A10c");
2320 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A10d");
2321 Assert.IsFalse (ctor is ConstructorBuilder, "#A10e");
2323 ctor = redType.GetConstructor (flags, null,
2324 new Type [] { typeof (int) },
2325 new ParameterModifier [0]);
2326 Assert.IsNotNull (ctor, "#A11a");
2327 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#A11b");
2328 Assert.IsFalse (ctor.IsStatic, "#A11c");
2329 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A11d");
2330 Assert.IsFalse (ctor is ConstructorBuilder, "#A11e");
2332 ctor = redType.GetConstructor (flags, null,
2333 new Type [] { typeof (int), typeof (bool) },
2334 new ParameterModifier [0]);
2335 Assert.IsNull (ctor, "#A12");
2337 ctor = redType.GetConstructor (flags, null,
2338 new Type [] { typeof (string), typeof (int) },
2339 new ParameterModifier [0]);
2340 Assert.IsNotNull (ctor, "#A13a");
2341 Assert.IsTrue (ctor.IsAssembly, "#A13b");
2342 Assert.IsFalse (ctor.IsStatic, "#A13c");
2343 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A13d");
2344 Assert.IsFalse (ctor is ConstructorBuilder, "#A13e");
2346 ctor = redType.GetConstructor (flags, null,
2348 new ParameterModifier [0]);
2349 Assert.IsNull (ctor, "#A14");
2351 flags = BindingFlags.Instance | BindingFlags.Public;
2353 ctor = greenType.GetConstructor (flags, null,
2354 new Type [] { typeof (int), typeof (int) },
2355 new ParameterModifier [0]);
2356 Assert.IsNull (ctor, "#B1");
2358 ctor = greenType.GetConstructor (flags, null,
2359 new Type [] { typeof (string) },
2360 new ParameterModifier [0]);
2361 Assert.IsNull (ctor, "#B2");
2363 ctor = greenType.GetConstructor (flags, null,
2364 new Type [] { typeof (string), typeof (string) },
2365 new ParameterModifier [0]);
2366 Assert.IsNull (ctor, "#B3");
2368 ctor = greenType.GetConstructor (flags, null,
2369 new Type [] { typeof (int) },
2370 new ParameterModifier [0]);
2371 Assert.IsNull (ctor, "#B4");
2373 ctor = greenType.GetConstructor (flags, null,
2374 new Type [] { typeof (int), typeof (bool) },
2375 new ParameterModifier [0]);
2376 Assert.IsNull (ctor, "#B5");
2378 ctor = greenType.GetConstructor (flags, null,
2379 new Type [] { typeof (string), typeof (int) },
2380 new ParameterModifier [0]);
2381 Assert.IsNull (ctor, "#B6");
2383 ctor = greenType.GetConstructor (flags, null,
2385 new ParameterModifier [0]);
2386 Assert.IsNotNull (ctor, "#B7a");
2387 Assert.IsTrue (ctor.IsPublic, "#B7b");
2388 Assert.IsFalse (ctor.IsStatic, "#B7c");
2389 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B7d");
2390 Assert.IsFalse (ctor is ConstructorBuilder, "#B7e");
2392 ctor = redType.GetConstructor (flags, null,
2393 new Type [] { typeof (int), typeof (int) },
2394 new ParameterModifier [0]);
2395 Assert.IsNull (ctor, "#B8");
2397 ctor = redType.GetConstructor (flags, null,
2398 new Type [] { typeof (string) },
2399 new ParameterModifier [0]);
2400 Assert.IsNull (ctor, "#B9");
2402 ctor = redType.GetConstructor (flags, null,
2403 new Type [] { typeof (string), typeof (string) },
2404 new ParameterModifier [0]);
2405 Assert.IsNull (ctor, "#B10");
2407 ctor = redType.GetConstructor (flags, null,
2408 new Type [] { typeof (int) },
2409 new ParameterModifier [0]);
2410 Assert.IsNull (ctor, "#B11");
2412 ctor = redType.GetConstructor (flags, null,
2413 new Type [] { typeof (int), typeof (bool) },
2414 new ParameterModifier [0]);
2415 Assert.IsNotNull (ctor, "#B12a");
2416 Assert.IsTrue (ctor.IsPublic, "#B12b");
2417 Assert.IsFalse (ctor.IsStatic, "#B12c");
2418 Assert.AreEqual (2, ctor.GetParameters ().Length, "#B12d");
2419 Assert.IsFalse (ctor is ConstructorBuilder, "#B12e");
2421 ctor = redType.GetConstructor (flags, null,
2422 new Type [] { typeof (string), typeof (int) },
2423 new ParameterModifier [0]);
2424 Assert.IsNull (ctor, "#B13");
2426 ctor = redType.GetConstructor (flags, null,
2428 new ParameterModifier [0]);
2429 Assert.IsNull (ctor, "#B14");
2431 flags = BindingFlags.Static | BindingFlags.Public;
2433 ctor = greenType.GetConstructor (flags, null,
2434 new Type [] { typeof (int), typeof (int) },
2435 new ParameterModifier [0]);
2436 Assert.IsNull (ctor, "#C1");
2438 ctor = greenType.GetConstructor (flags, null,
2439 new Type [] { typeof (string) },
2440 new ParameterModifier [0]);
2441 Assert.IsNull (ctor, "#C2");
2443 ctor = greenType.GetConstructor (flags, null,
2444 new Type [] { typeof (string), typeof (string) },
2445 new ParameterModifier [0]);
2446 Assert.IsNull (ctor, "#C3");
2448 ctor = greenType.GetConstructor (flags, null,
2449 new Type [] { typeof (int) },
2450 new ParameterModifier [0]);
2451 Assert.IsNull (ctor, "#C4");
2453 ctor = greenType.GetConstructor (flags, null,
2454 new Type [] { typeof (int), typeof (bool) },
2455 new ParameterModifier [0]);
2456 Assert.IsNull (ctor, "#C5");
2458 ctor = greenType.GetConstructor (flags, null,
2459 new Type [] { typeof (string), typeof (int) },
2460 new ParameterModifier [0]);
2461 Assert.IsNull (ctor, "#C6");
2463 ctor = greenType.GetConstructor (flags, null,
2465 new ParameterModifier [0]);
2466 Assert.IsNull (ctor, "#C7");
2468 ctor = redType.GetConstructor (flags, null,
2469 new Type [] { typeof (int), typeof (int) },
2470 new ParameterModifier [0]);
2471 Assert.IsNull (ctor, "#C8");
2473 ctor = redType.GetConstructor (flags, null,
2474 new Type [] { typeof (string) },
2475 new ParameterModifier [0]);
2476 Assert.IsNull (ctor, "#C9");
2478 ctor = redType.GetConstructor (flags, null,
2479 new Type [] { typeof (string), typeof (string) },
2480 new ParameterModifier [0]);
2481 Assert.IsNull (ctor, "#C10");
2483 ctor = redType.GetConstructor (flags, null,
2484 new Type [] { typeof (int) },
2485 new ParameterModifier [0]);
2486 Assert.IsNull (ctor, "#C11a");
2488 ctor = redType.GetConstructor (flags, null,
2489 new Type [] { typeof (int), typeof (bool) },
2490 new ParameterModifier [0]);
2491 Assert.IsNull (ctor, "#C12");
2493 ctor = redType.GetConstructor (flags, null,
2494 new Type [] { typeof (string), typeof (int) },
2495 new ParameterModifier [0]);
2496 Assert.IsNull (ctor, "#C13");
2498 ctor = redType.GetConstructor (flags, null,
2500 new ParameterModifier [0]);
2501 Assert.IsNull (ctor, "#C14");
2503 flags = BindingFlags.Static | BindingFlags.NonPublic;
2505 ctor = greenType.GetConstructor (flags, null,
2506 new Type [] { typeof (int), typeof (int) },
2507 new ParameterModifier [0]);
2508 Assert.IsNull (ctor, "#D1");
2510 ctor = greenType.GetConstructor (flags, null,
2511 new Type [] { typeof (string) },
2512 new ParameterModifier [0]);
2513 Assert.IsNull (ctor, "#D2");
2515 ctor = greenType.GetConstructor (flags, null,
2516 new Type [] { typeof (string), typeof (string) },
2517 new ParameterModifier [0]);
2518 Assert.IsNull (ctor, "#D3");
2520 ctor = greenType.GetConstructor (flags, null,
2521 new Type [] { typeof (int) },
2522 new ParameterModifier [0]);
2523 Assert.IsNull (ctor, "#D4");
2525 ctor = greenType.GetConstructor (flags, null,
2526 new Type [] { typeof (int), typeof (bool) },
2527 new ParameterModifier [0]);
2528 Assert.IsNull (ctor, "#D5");
2530 ctor = greenType.GetConstructor (flags, null,
2531 new Type [] { typeof (string), typeof (int) },
2532 new ParameterModifier [0]);
2533 Assert.IsNull (ctor, "#D6");
2535 ctor = greenType.GetConstructor (flags, null,
2537 new ParameterModifier [0]);
2538 Assert.IsNull (ctor, "#D7");
2540 ctor = redType.GetConstructor (flags, null,
2541 new Type [] { typeof (int), typeof (int) },
2542 new ParameterModifier [0]);
2543 Assert.IsNull (ctor, "#D8");
2545 ctor = redType.GetConstructor (flags, null,
2546 new Type [] { typeof (string) },
2547 new ParameterModifier [0]);
2548 Assert.IsNull (ctor, "#D9");
2550 ctor = redType.GetConstructor (flags, null,
2551 new Type [] { typeof (string), typeof (string) },
2552 new ParameterModifier [0]);
2553 Assert.IsNull (ctor, "#D10");
2555 ctor = redType.GetConstructor (flags, null,
2556 new Type [] { typeof (int) },
2557 new ParameterModifier [0]);
2558 Assert.IsNull (ctor, "#D11");
2560 ctor = redType.GetConstructor (flags, null,
2561 new Type [] { typeof (int), typeof (bool) },
2562 new ParameterModifier [0]);
2563 Assert.IsNull (ctor, "#D12");
2565 ctor = redType.GetConstructor (flags, null,
2566 new Type [] { typeof (string), typeof (int) },
2567 new ParameterModifier [0]);
2568 Assert.IsNull (ctor, "#D13");
2570 ctor = redType.GetConstructor (flags, null,
2572 new ParameterModifier [0]);
2573 Assert.IsNotNull (ctor, "#D14a");
2574 Assert.IsTrue (ctor.IsPrivate, "#D14b");
2575 Assert.IsTrue (ctor.IsStatic, "#B14c");
2576 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B14d");
2577 Assert.IsFalse (ctor is ConstructorBuilder, "#B14e");
2579 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2580 BindingFlags.FlattenHierarchy;
2582 ctor = greenType.GetConstructor (flags, null,
2583 new Type [] { typeof (int), typeof (int) },
2584 new ParameterModifier [0]);
2585 Assert.IsNull (ctor, "#E1");
2587 ctor = greenType.GetConstructor (flags, null,
2588 new Type [] { typeof (string) },
2589 new ParameterModifier [0]);
2590 Assert.IsNull (ctor, "#E2");
2592 ctor = greenType.GetConstructor (flags, null,
2593 new Type [] { typeof (string), typeof (string) },
2594 new ParameterModifier [0]);
2595 Assert.IsNull (ctor, "#E3");
2597 ctor = greenType.GetConstructor (flags, null,
2598 new Type [] { typeof (int) },
2599 new ParameterModifier [0]);
2600 Assert.IsNull (ctor, "#E4");
2602 ctor = greenType.GetConstructor (flags, null,
2603 new Type [] { typeof (int), typeof (bool) },
2604 new ParameterModifier [0]);
2605 Assert.IsNull (ctor, "#E5");
2607 ctor = greenType.GetConstructor (flags, null,
2608 new Type [] { typeof (string), typeof (int) },
2609 new ParameterModifier [0]);
2610 Assert.IsNull (ctor, "#E6");
2612 ctor = greenType.GetConstructor (flags, null,
2614 new ParameterModifier [0]);
2615 Assert.IsNull (ctor, "#E7");
2617 ctor = redType.GetConstructor (flags, null,
2618 new Type [] { typeof (int), typeof (int) },
2619 new ParameterModifier [0]);
2620 Assert.IsNotNull (ctor, "#E8a");
2621 Assert.IsTrue (ctor.IsPrivate, "#E8b");
2622 Assert.IsFalse (ctor.IsStatic, "#E8c");
2623 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E8d");
2624 Assert.IsFalse (ctor is ConstructorBuilder, "#E8e");
2626 ctor = redType.GetConstructor (flags, null,
2627 new Type [] { typeof (string) },
2628 new ParameterModifier [0]);
2629 Assert.IsNotNull (ctor, "#E9a");
2630 Assert.IsTrue (ctor.IsFamily, "#E9b");
2631 Assert.IsFalse (ctor.IsStatic, "#E9c");
2632 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E9d");
2633 Assert.IsFalse (ctor is ConstructorBuilder, "#E9e");
2635 ctor = redType.GetConstructor (flags, null,
2636 new Type [] { typeof (string), typeof (string) },
2637 new ParameterModifier [0]);
2638 Assert.IsNotNull (ctor, "#E10a");
2639 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#E10b");
2640 Assert.IsFalse (ctor.IsStatic, "#E10c");
2641 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E10d");
2642 Assert.IsFalse (ctor is ConstructorBuilder, "#E10e");
2644 ctor = redType.GetConstructor (flags, null,
2645 new Type [] { typeof (int) },
2646 new ParameterModifier [0]);
2647 Assert.IsNotNull (ctor, "#E11a");
2648 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#E11b");
2649 Assert.IsFalse (ctor.IsStatic, "#E11c");
2650 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E11d");
2651 Assert.IsFalse (ctor is ConstructorBuilder, "#E11e");
2653 ctor = redType.GetConstructor (flags, null,
2654 new Type [] { typeof (int), typeof (bool) },
2655 new ParameterModifier [0]);
2656 Assert.IsNull (ctor, "#E12");
2658 ctor = redType.GetConstructor (flags, null,
2659 new Type [] { typeof (string), typeof (int) },
2660 new ParameterModifier [0]);
2661 Assert.IsNotNull (ctor, "#E13a");
2662 Assert.IsTrue (ctor.IsAssembly, "#E13b");
2663 Assert.IsFalse (ctor.IsStatic, "#E13c");
2664 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E13d");
2665 Assert.IsFalse (ctor is ConstructorBuilder, "#E13e");
2667 ctor = redType.GetConstructor (flags, null,
2669 new ParameterModifier [0]);
2670 Assert.IsNull (ctor, "#E14");
2672 flags = BindingFlags.Instance | BindingFlags.Public |
2673 BindingFlags.FlattenHierarchy;
2675 ctor = greenType.GetConstructor (flags, null,
2676 new Type [] { typeof (int), typeof (int) },
2677 new ParameterModifier [0]);
2678 Assert.IsNull (ctor, "#F1");
2680 ctor = greenType.GetConstructor (flags, null,
2681 new Type [] { typeof (string) },
2682 new ParameterModifier [0]);
2683 Assert.IsNull (ctor, "#F2");
2685 ctor = greenType.GetConstructor (flags, null,
2686 new Type [] { typeof (string), typeof (string) },
2687 new ParameterModifier [0]);
2688 Assert.IsNull (ctor, "#F3");
2690 ctor = greenType.GetConstructor (flags, null,
2691 new Type [] { typeof (int) },
2692 new ParameterModifier [0]);
2693 Assert.IsNull (ctor, "#F4");
2695 ctor = greenType.GetConstructor (flags, null,
2696 new Type [] { typeof (int), typeof (bool) },
2697 new ParameterModifier [0]);
2698 Assert.IsNull (ctor, "#F5");
2700 ctor = greenType.GetConstructor (flags, null,
2701 new Type [] { typeof (string), typeof (int) },
2702 new ParameterModifier [0]);
2703 Assert.IsNull (ctor, "#F6");
2705 ctor = greenType.GetConstructor (flags, null,
2707 new ParameterModifier [0]);
2708 Assert.IsNotNull (ctor, "#F7a");
2709 Assert.IsTrue (ctor.IsPublic, "#F7b");
2710 Assert.IsFalse (ctor.IsStatic, "#F7c");
2711 Assert.AreEqual (0, ctor.GetParameters ().Length, "#F7d");
2712 Assert.IsFalse (ctor is ConstructorBuilder, "#F7e");
2714 ctor = redType.GetConstructor (flags, null,
2715 new Type [] { typeof (int), typeof (int) },
2716 new ParameterModifier [0]);
2717 Assert.IsNull (ctor, "#F8");
2719 ctor = redType.GetConstructor (flags, null,
2720 new Type [] { typeof (string) },
2721 new ParameterModifier [0]);
2722 Assert.IsNull (ctor, "#F9");
2724 ctor = redType.GetConstructor (flags, null,
2725 new Type [] { typeof (string), typeof (string) },
2726 new ParameterModifier [0]);
2727 Assert.IsNull (ctor, "#F10");
2729 ctor = redType.GetConstructor (flags, null,
2730 new Type [] { typeof (int) },
2731 new ParameterModifier [0]);
2732 Assert.IsNull (ctor, "#F11");
2734 ctor = redType.GetConstructor (flags, null,
2735 new Type [] { typeof (int), typeof (bool) },
2736 new ParameterModifier [0]);
2737 Assert.IsNotNull (ctor, "#F12a");
2738 Assert.IsTrue (ctor.IsPublic, "#F12b");
2739 Assert.IsFalse (ctor.IsStatic, "#F12c");
2740 Assert.AreEqual (2, ctor.GetParameters ().Length, "#F12d");
2741 Assert.IsFalse (ctor is ConstructorBuilder, "#F12e");
2743 ctor = redType.GetConstructor (flags, null,
2744 new Type [] { typeof (string), typeof (int) },
2745 new ParameterModifier [0]);
2746 Assert.IsNull (ctor, "#F13");
2748 ctor = redType.GetConstructor (flags, null,
2750 new ParameterModifier [0]);
2751 Assert.IsNull (ctor, "#F14");
2753 flags = BindingFlags.Static | BindingFlags.Public |
2754 BindingFlags.FlattenHierarchy;
2756 ctor = greenType.GetConstructor (flags, null,
2757 new Type [] { typeof (int), typeof (int) },
2758 new ParameterModifier [0]);
2759 Assert.IsNull (ctor, "#G1");
2761 ctor = greenType.GetConstructor (flags, null,
2762 new Type [] { typeof (string) },
2763 new ParameterModifier [0]);
2764 Assert.IsNull (ctor, "#G2");
2766 ctor = greenType.GetConstructor (flags, null,
2767 new Type [] { typeof (string), typeof (string) },
2768 new ParameterModifier [0]);
2769 Assert.IsNull (ctor, "#G3");
2771 ctor = greenType.GetConstructor (flags, null,
2772 new Type [] { typeof (int) },
2773 new ParameterModifier [0]);
2774 Assert.IsNull (ctor, "#G4");
2776 ctor = greenType.GetConstructor (flags, null,
2777 new Type [] { typeof (int), typeof (bool) },
2778 new ParameterModifier [0]);
2779 Assert.IsNull (ctor, "#G5");
2781 ctor = greenType.GetConstructor (flags, null,
2782 new Type [] { typeof (string), typeof (int) },
2783 new ParameterModifier [0]);
2784 Assert.IsNull (ctor, "#G6");
2786 ctor = greenType.GetConstructor (flags, null,
2788 new ParameterModifier [0]);
2789 Assert.IsNull (ctor, "#G7");
2791 ctor = redType.GetConstructor (flags, null,
2792 new Type [] { typeof (int), typeof (int) },
2793 new ParameterModifier [0]);
2794 Assert.IsNull (ctor, "#G8");
2796 ctor = redType.GetConstructor (flags, null,
2797 new Type [] { typeof (string) },
2798 new ParameterModifier [0]);
2799 Assert.IsNull (ctor, "#G9");
2801 ctor = redType.GetConstructor (flags, null,
2802 new Type [] { typeof (string), typeof (string) },
2803 new ParameterModifier [0]);
2804 Assert.IsNull (ctor, "#G10");
2806 ctor = redType.GetConstructor (flags, null,
2807 new Type [] { typeof (int) },
2808 new ParameterModifier [0]);
2809 Assert.IsNull (ctor, "#G11");
2811 ctor = redType.GetConstructor (flags, null,
2812 new Type [] { typeof (int), typeof (bool) },
2813 new ParameterModifier [0]);
2814 Assert.IsNull (ctor, "#G12");
2816 ctor = redType.GetConstructor (flags, null,
2817 new Type [] { typeof (string), typeof (int) },
2818 new ParameterModifier [0]);
2819 Assert.IsNull (ctor, "#G13");
2821 ctor = redType.GetConstructor (flags, null,
2823 new ParameterModifier [0]);
2824 Assert.IsNull (ctor, "#G14");
2826 flags = BindingFlags.Static | BindingFlags.NonPublic |
2827 BindingFlags.FlattenHierarchy;
2829 ctor = greenType.GetConstructor (flags, null,
2830 new Type [] { typeof (int), typeof (int) },
2831 new ParameterModifier [0]);
2832 Assert.IsNull (ctor, "#H1");
2834 ctor = greenType.GetConstructor (flags, null,
2835 new Type [] { typeof (string) },
2836 new ParameterModifier [0]);
2837 Assert.IsNull (ctor, "#H2");
2839 ctor = greenType.GetConstructor (flags, null,
2840 new Type [] { typeof (string), typeof (string) },
2841 new ParameterModifier [0]);
2842 Assert.IsNull (ctor, "#H3");
2844 ctor = greenType.GetConstructor (flags, null,
2845 new Type [] { typeof (int) },
2846 new ParameterModifier [0]);
2847 Assert.IsNull (ctor, "#H4");
2849 ctor = greenType.GetConstructor (flags, null,
2850 new Type [] { typeof (int), typeof (bool) },
2851 new ParameterModifier [0]);
2852 Assert.IsNull (ctor, "#H5");
2854 ctor = greenType.GetConstructor (flags, null,
2855 new Type [] { typeof (string), typeof (int) },
2856 new ParameterModifier [0]);
2857 Assert.IsNull (ctor, "#H6");
2859 ctor = greenType.GetConstructor (flags, null,
2861 new ParameterModifier [0]);
2862 Assert.IsNull (ctor, "#H7");
2864 ctor = redType.GetConstructor (flags, null,
2865 new Type [] { typeof (int), typeof (int) },
2866 new ParameterModifier [0]);
2867 Assert.IsNull (ctor, "#H8");
2869 ctor = redType.GetConstructor (flags, null,
2870 new Type [] { typeof (string) },
2871 new ParameterModifier [0]);
2872 Assert.IsNull (ctor, "#H9");
2874 ctor = redType.GetConstructor (flags, null,
2875 new Type [] { typeof (string), typeof (string) },
2876 new ParameterModifier [0]);
2877 Assert.IsNull (ctor, "#H10");
2879 ctor = redType.GetConstructor (flags, null,
2880 new Type [] { typeof (int) },
2881 new ParameterModifier [0]);
2882 Assert.IsNull (ctor, "#H11");
2884 ctor = redType.GetConstructor (flags, null,
2885 new Type [] { typeof (int), typeof (bool) },
2886 new ParameterModifier [0]);
2887 Assert.IsNull (ctor, "#H12");
2889 ctor = redType.GetConstructor (flags, null,
2890 new Type [] { typeof (string), typeof (int) },
2891 new ParameterModifier [0]);
2892 Assert.IsNull (ctor, "#H13");
2894 ctor = redType.GetConstructor (flags, null,
2896 new ParameterModifier [0]);
2897 Assert.IsNotNull (ctor, "#H14");
2898 Assert.IsTrue (ctor.IsPrivate, "#H14b");
2899 Assert.IsTrue (ctor.IsStatic, "#H14c");
2900 Assert.AreEqual (0, ctor.GetParameters ().Length, "#H14d");
2901 Assert.IsFalse (ctor is ConstructorBuilder, "#H14e");
2903 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2904 BindingFlags.DeclaredOnly;
2906 ctor = greenType.GetConstructor (flags, null,
2907 new Type [] { typeof (int), typeof (int) },
2908 new ParameterModifier [0]);
2909 Assert.IsNull (ctor, "#I1");
2911 ctor = greenType.GetConstructor (flags, null,
2912 new Type [] { typeof (string) },
2913 new ParameterModifier [0]);
2914 Assert.IsNull (ctor, "#I2");
2916 ctor = greenType.GetConstructor (flags, null,
2917 new Type [] { typeof (string), typeof (string) },
2918 new ParameterModifier [0]);
2919 Assert.IsNull (ctor, "#I3");
2921 ctor = greenType.GetConstructor (flags, null,
2922 new Type [] { typeof (int) },
2923 new ParameterModifier [0]);
2924 Assert.IsNull (ctor, "#I4");
2926 ctor = greenType.GetConstructor (flags, null,
2927 new Type [] { typeof (int), typeof (bool) },
2928 new ParameterModifier [0]);
2929 Assert.IsNull (ctor, "#I5");
2931 ctor = greenType.GetConstructor (flags, null,
2932 new Type [] { typeof (string), typeof (int) },
2933 new ParameterModifier [0]);
2934 Assert.IsNull (ctor, "#I6");
2936 ctor = greenType.GetConstructor (flags, null,
2938 new ParameterModifier [0]);
2939 Assert.IsNull (ctor, "#I7");
2941 ctor = redType.GetConstructor (flags, null,
2942 new Type [] { typeof (int), typeof (int) },
2943 new ParameterModifier [0]);
2944 Assert.IsNotNull (ctor, "#I8a");
2945 Assert.IsTrue (ctor.IsPrivate, "#I8b");
2946 Assert.IsFalse (ctor.IsStatic, "#I8c");
2947 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I8d");
2948 Assert.IsFalse (ctor is ConstructorBuilder, "#I8e");
2950 ctor = redType.GetConstructor (flags, null,
2951 new Type [] { typeof (string) },
2952 new ParameterModifier [0]);
2953 Assert.IsNotNull (ctor, "#I9a");
2954 Assert.IsTrue (ctor.IsFamily, "#I9b");
2955 Assert.IsFalse (ctor.IsStatic, "#I9c");
2956 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I9d");
2957 Assert.IsFalse (ctor is ConstructorBuilder, "#I9e");
2959 ctor = redType.GetConstructor (flags, null,
2960 new Type [] { typeof (string), typeof (string) },
2961 new ParameterModifier [0]);
2962 Assert.IsNotNull (ctor, "#I10a");
2963 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#I10b");
2964 Assert.IsFalse (ctor.IsStatic, "#I10c");
2965 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I10d");
2966 Assert.IsFalse (ctor is ConstructorBuilder, "#I10e");
2968 ctor = redType.GetConstructor (flags, null,
2969 new Type [] { typeof (int) },
2970 new ParameterModifier [0]);
2971 Assert.IsNotNull (ctor, "#I11a");
2972 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#I11b");
2973 Assert.IsFalse (ctor.IsStatic, "#I11c");
2974 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I11d");
2975 Assert.IsFalse (ctor is ConstructorBuilder, "#I11e");
2977 ctor = redType.GetConstructor (flags, null,
2978 new Type [] { typeof (int), typeof (bool) },
2979 new ParameterModifier [0]);
2980 Assert.IsNull (ctor, "#I12");
2982 ctor = redType.GetConstructor (flags, null,
2983 new Type [] { typeof (string), typeof (int) },
2984 new ParameterModifier [0]);
2985 Assert.IsNotNull (ctor, "#I13a");
2986 Assert.IsTrue (ctor.IsAssembly, "#I13b");
2987 Assert.IsFalse (ctor.IsStatic, "#I13c");
2988 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I13d");
2989 Assert.IsFalse (ctor is ConstructorBuilder, "#I13e");
2991 ctor = redType.GetConstructor (flags, null,
2993 new ParameterModifier [0]);
2994 Assert.IsNull (ctor, "#I14");
2996 flags = BindingFlags.Instance | BindingFlags.Public |
2997 BindingFlags.DeclaredOnly;
2999 ctor = greenType.GetConstructor (flags, null,
3000 new Type [] { typeof (int), typeof (int) },
3001 new ParameterModifier [0]);
3002 Assert.IsNull (ctor, "#J1");
3004 ctor = greenType.GetConstructor (flags, null,
3005 new Type [] { typeof (string) },
3006 new ParameterModifier [0]);
3007 Assert.IsNull (ctor, "#J2");
3009 ctor = greenType.GetConstructor (flags, null,
3010 new Type [] { typeof (string), typeof (string) },
3011 new ParameterModifier [0]);
3012 Assert.IsNull (ctor, "#J3");
3014 ctor = greenType.GetConstructor (flags, null,
3015 new Type [] { typeof (int) },
3016 new ParameterModifier [0]);
3017 Assert.IsNull (ctor, "#J4");
3019 ctor = greenType.GetConstructor (flags, null,
3020 new Type [] { typeof (int), typeof (bool) },
3021 new ParameterModifier [0]);
3022 Assert.IsNull (ctor, "#J5");
3024 ctor = greenType.GetConstructor (flags, null,
3025 new Type [] { typeof (string), typeof (int) },
3026 new ParameterModifier [0]);
3027 Assert.IsNull (ctor, "#J6");
3029 ctor = greenType.GetConstructor (flags, null,
3031 new ParameterModifier [0]);
3032 Assert.IsNotNull (ctor, "#J7a");
3033 Assert.IsTrue (ctor.IsPublic, "#J7b");
3034 Assert.IsFalse (ctor.IsStatic, "#J7c");
3035 Assert.AreEqual (0, ctor.GetParameters ().Length, "#J7d");
3036 Assert.IsFalse (ctor is ConstructorBuilder, "#J7e");
3038 ctor = redType.GetConstructor (flags, null,
3039 new Type [] { typeof (int), typeof (int) },
3040 new ParameterModifier [0]);
3041 Assert.IsNull (ctor, "#J8");
3043 ctor = redType.GetConstructor (flags, null,
3044 new Type [] { typeof (string) },
3045 new ParameterModifier [0]);
3046 Assert.IsNull (ctor, "#J9");
3048 ctor = redType.GetConstructor (flags, null,
3049 new Type [] { typeof (string), typeof (string) },
3050 new ParameterModifier [0]);
3051 Assert.IsNull (ctor, "#J10");
3053 ctor = redType.GetConstructor (flags, null,
3054 new Type [] { typeof (int) },
3055 new ParameterModifier [0]);
3056 Assert.IsNull (ctor, "#J11");
3058 ctor = redType.GetConstructor (flags, null,
3059 new Type [] { typeof (int), typeof (bool) },
3060 new ParameterModifier [0]);
3061 Assert.IsNotNull (ctor, "#J12a");
3062 Assert.IsTrue (ctor.IsPublic, "#J12b");
3063 Assert.IsFalse (ctor.IsStatic, "#J12c");
3064 Assert.AreEqual (2, ctor.GetParameters ().Length, "#J12d");
3065 Assert.IsFalse (ctor is ConstructorBuilder, "#J12e");
3067 ctor = redType.GetConstructor (flags, null,
3068 new Type [] { typeof (string), typeof (int) },
3069 new ParameterModifier [0]);
3070 Assert.IsNull (ctor, "#J13");
3072 ctor = redType.GetConstructor (flags, null,
3074 new ParameterModifier [0]);
3075 Assert.IsNull (ctor, "#J14");
3077 flags = BindingFlags.Static | BindingFlags.Public |
3078 BindingFlags.DeclaredOnly;
3080 ctor = greenType.GetConstructor (flags, null,
3081 new Type [] { typeof (int), typeof (int) },
3082 new ParameterModifier [0]);
3083 Assert.IsNull (ctor, "#K1");
3085 ctor = greenType.GetConstructor (flags, null,
3086 new Type [] { typeof (string) },
3087 new ParameterModifier [0]);
3088 Assert.IsNull (ctor, "#K2");
3090 ctor = greenType.GetConstructor (flags, null,
3091 new Type [] { typeof (string), typeof (string) },
3092 new ParameterModifier [0]);
3093 Assert.IsNull (ctor, "#K3");
3095 ctor = greenType.GetConstructor (flags, null,
3096 new Type [] { typeof (int) },
3097 new ParameterModifier [0]);
3098 Assert.IsNull (ctor, "#K4");
3100 ctor = greenType.GetConstructor (flags, null,
3101 new Type [] { typeof (int), typeof (bool) },
3102 new ParameterModifier [0]);
3103 Assert.IsNull (ctor, "#K5");
3105 ctor = greenType.GetConstructor (flags, null,
3106 new Type [] { typeof (string), typeof (int) },
3107 new ParameterModifier [0]);
3108 Assert.IsNull (ctor, "#K6");
3110 ctor = greenType.GetConstructor (flags, null,
3112 new ParameterModifier [0]);
3113 Assert.IsNull (ctor, "#K7");
3115 ctor = redType.GetConstructor (flags, null,
3116 new Type [] { typeof (int), typeof (int) },
3117 new ParameterModifier [0]);
3118 Assert.IsNull (ctor, "#K8");
3120 ctor = redType.GetConstructor (flags, null,
3121 new Type [] { typeof (string) },
3122 new ParameterModifier [0]);
3123 Assert.IsNull (ctor, "#K9");
3125 ctor = redType.GetConstructor (flags, null,
3126 new Type [] { typeof (string), typeof (string) },
3127 new ParameterModifier [0]);
3128 Assert.IsNull (ctor, "#K10");
3130 ctor = redType.GetConstructor (flags, null,
3131 new Type [] { typeof (int) },
3132 new ParameterModifier [0]);
3133 Assert.IsNull (ctor, "#K11");
3135 ctor = redType.GetConstructor (flags, null,
3136 new Type [] { typeof (int), typeof (bool) },
3137 new ParameterModifier [0]);
3138 Assert.IsNull (ctor, "#K12");
3140 ctor = redType.GetConstructor (flags, null,
3141 new Type [] { typeof (string), typeof (int) },
3142 new ParameterModifier [0]);
3143 Assert.IsNull (ctor, "#K13");
3145 ctor = redType.GetConstructor (flags, null,
3147 new ParameterModifier [0]);
3148 Assert.IsNull (ctor, "#K14");
3150 flags = BindingFlags.Static | BindingFlags.NonPublic |
3151 BindingFlags.DeclaredOnly;
3153 ctor = greenType.GetConstructor (flags, null,
3154 new Type [] { typeof (int), typeof (int) },
3155 new ParameterModifier [0]);
3156 Assert.IsNull (ctor, "#L1");
3158 ctor = greenType.GetConstructor (flags, null,
3159 new Type [] { typeof (string) },
3160 new ParameterModifier [0]);
3161 Assert.IsNull (ctor, "#L2");
3163 ctor = greenType.GetConstructor (flags, null,
3164 new Type [] { typeof (string), typeof (string) },
3165 new ParameterModifier [0]);
3166 Assert.IsNull (ctor, "#L3");
3168 ctor = greenType.GetConstructor (flags, null,
3169 new Type [] { typeof (int) },
3170 new ParameterModifier [0]);
3171 Assert.IsNull (ctor, "#L4");
3173 ctor = greenType.GetConstructor (flags, null,
3174 new Type [] { typeof (int), typeof (bool) },
3175 new ParameterModifier [0]);
3176 Assert.IsNull (ctor, "#L5");
3178 ctor = greenType.GetConstructor (flags, null,
3179 new Type [] { typeof (string), typeof (int) },
3180 new ParameterModifier [0]);
3181 Assert.IsNull (ctor, "#L6");
3183 ctor = greenType.GetConstructor (flags, null,
3185 new ParameterModifier [0]);
3186 Assert.IsNull (ctor, "#L7");
3188 ctor = redType.GetConstructor (flags, null,
3189 new Type [] { typeof (int), typeof (int) },
3190 new ParameterModifier [0]);
3191 Assert.IsNull (ctor, "#L8");
3193 ctor = redType.GetConstructor (flags, null,
3194 new Type [] { typeof (string) },
3195 new ParameterModifier [0]);
3196 Assert.IsNull (ctor, "#L9");
3198 ctor = redType.GetConstructor (flags, null,
3199 new Type [] { typeof (string), typeof (string) },
3200 new ParameterModifier [0]);
3201 Assert.IsNull (ctor, "#L10");
3203 ctor = redType.GetConstructor (flags, null,
3204 new Type [] { typeof (int) },
3205 new ParameterModifier [0]);
3206 Assert.IsNull (ctor, "#L11");
3208 ctor = redType.GetConstructor (flags, null,
3209 new Type [] { typeof (int), typeof (bool) },
3210 new ParameterModifier [0]);
3211 Assert.IsNull (ctor, "#L12");
3213 ctor = redType.GetConstructor (flags, null,
3214 new Type [] { typeof (string), typeof (int) },
3215 new ParameterModifier [0]);
3216 Assert.IsNull (ctor, "#L13");
3218 ctor = redType.GetConstructor (flags, null,
3220 new ParameterModifier [0]);
3221 Assert.IsNotNull (ctor, "#L14a");
3222 Assert.IsTrue (ctor.IsPrivate, "#L14b");
3223 Assert.IsTrue (ctor.IsStatic, "#L14c");
3224 Assert.AreEqual (0, ctor.GetParameters ().Length, "#L14d");
3225 Assert.IsFalse (ctor is ConstructorBuilder, "#L14e");
3227 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3228 BindingFlags.Public;
3230 ctor = greenType.GetConstructor (flags, null,
3231 new Type [] { typeof (int), typeof (int) },
3232 new ParameterModifier [0]);
3233 Assert.IsNull (ctor, "#M1");
3235 ctor = greenType.GetConstructor (flags, null,
3236 new Type [] { typeof (string) },
3237 new ParameterModifier [0]);
3238 Assert.IsNull (ctor, "#M2");
3240 ctor = greenType.GetConstructor (flags, null,
3241 new Type [] { typeof (string), typeof (string) },
3242 new ParameterModifier [0]);
3243 Assert.IsNull (ctor, "#M3");
3245 ctor = greenType.GetConstructor (flags, null,
3246 new Type [] { typeof (int) },
3247 new ParameterModifier [0]);
3248 Assert.IsNull (ctor, "#M4");
3250 ctor = greenType.GetConstructor (flags, null,
3251 new Type [] { typeof (int), typeof (bool) },
3252 new ParameterModifier [0]);
3253 Assert.IsNull (ctor, "#M5");
3255 ctor = greenType.GetConstructor (flags, null,
3256 new Type [] { typeof (string), typeof (int) },
3257 new ParameterModifier [0]);
3258 Assert.IsNull (ctor, "#M6");
3260 ctor = greenType.GetConstructor (flags, null,
3262 new ParameterModifier [0]);
3263 Assert.IsNotNull (ctor, "#M7a");
3264 Assert.IsTrue (ctor.IsPublic, "#M7b");
3265 Assert.IsFalse (ctor.IsStatic, "#M7c");
3266 Assert.AreEqual (0, ctor.GetParameters ().Length, "#M7d");
3267 Assert.IsFalse (ctor is ConstructorBuilder, "#M7e");
3269 ctor = redType.GetConstructor (flags, null,
3270 new Type [] { typeof (int), typeof (int) },
3271 new ParameterModifier [0]);
3272 Assert.IsNotNull (ctor, "#M8a");
3273 Assert.IsTrue (ctor.IsPrivate, "#M8b");
3274 Assert.IsFalse (ctor.IsStatic, "#M8c");
3275 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M8d");
3276 Assert.IsFalse (ctor is ConstructorBuilder, "#M8e");
3278 ctor = redType.GetConstructor (flags, null,
3279 new Type [] { typeof (string) },
3280 new ParameterModifier [0]);
3281 Assert.IsNotNull (ctor, "#M9a");
3282 Assert.IsTrue (ctor.IsFamily, "#M9b");
3283 Assert.IsFalse (ctor.IsStatic, "#M9c");
3284 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M9d");
3285 Assert.IsFalse (ctor is ConstructorBuilder, "#M9e");
3287 ctor = redType.GetConstructor (flags, null,
3288 new Type [] { typeof (string), typeof (string) },
3289 new ParameterModifier [0]);
3290 Assert.IsNotNull (ctor, "#M10a");
3291 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#M10b");
3292 Assert.IsFalse (ctor.IsStatic, "#M10c");
3293 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M10d");
3294 Assert.IsFalse (ctor is ConstructorBuilder, "#M10e");
3296 ctor = redType.GetConstructor (flags, null,
3297 new Type [] { typeof (int) },
3298 new ParameterModifier [0]);
3299 Assert.IsNotNull (ctor, "#M11a");
3300 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#M11b");
3301 Assert.IsFalse (ctor.IsStatic, "#M11c");
3302 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M11d");
3303 Assert.IsFalse (ctor is ConstructorBuilder, "#M11e");
3305 ctor = redType.GetConstructor (flags, null,
3306 new Type [] { typeof (int), typeof (bool) },
3307 new ParameterModifier [0]);
3308 Assert.IsNotNull (ctor, "#M12a");
3309 Assert.IsTrue (ctor.IsPublic, "#M12b");
3310 Assert.IsFalse (ctor.IsStatic, "#M12c");
3311 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M12d");
3312 Assert.IsFalse (ctor is ConstructorBuilder, "#M12e");
3314 ctor = redType.GetConstructor (flags, null,
3315 new Type [] { typeof (string), typeof (int) },
3316 new ParameterModifier [0]);
3317 Assert.IsNotNull (ctor, "#M13a");
3318 Assert.IsTrue (ctor.IsAssembly, "#M13b");
3319 Assert.IsFalse (ctor.IsStatic, "#M13c");
3320 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M13d");
3321 Assert.IsFalse (ctor is ConstructorBuilder, "#M13e");
3323 ctor = redType.GetConstructor (flags, null,
3325 new ParameterModifier [0]);
3326 Assert.IsNull (ctor, "#M14");
3328 flags = BindingFlags.Static | BindingFlags.NonPublic |
3329 BindingFlags.Public;
3331 ctor = greenType.GetConstructor (flags, null,
3332 new Type [] { typeof (int), typeof (int) },
3333 new ParameterModifier [0]);
3334 Assert.IsNull (ctor, "#N1");
3336 ctor = greenType.GetConstructor (flags, null,
3337 new Type [] { typeof (string) },
3338 new ParameterModifier [0]);
3339 Assert.IsNull (ctor, "#N2");
3341 ctor = greenType.GetConstructor (flags, null,
3342 new Type [] { typeof (string), typeof (string) },
3343 new ParameterModifier [0]);
3344 Assert.IsNull (ctor, "#N3");
3346 ctor = greenType.GetConstructor (flags, null,
3347 new Type [] { typeof (int) },
3348 new ParameterModifier [0]);
3349 Assert.IsNull (ctor, "#N4");
3351 ctor = greenType.GetConstructor (flags, null,
3352 new Type [] { typeof (int), typeof (bool) },
3353 new ParameterModifier [0]);
3354 Assert.IsNull (ctor, "#N5");
3356 ctor = greenType.GetConstructor (flags, null,
3357 new Type [] { typeof (string), typeof (int) },
3358 new ParameterModifier [0]);
3359 Assert.IsNull (ctor, "#N6");
3361 ctor = greenType.GetConstructor (flags, null,
3363 new ParameterModifier [0]);
3364 Assert.IsNull (ctor, "#N7");
3366 ctor = redType.GetConstructor (flags, null,
3367 new Type [] { typeof (int), typeof (int) },
3368 new ParameterModifier [0]);
3369 Assert.IsNull (ctor, "#N8");
3371 ctor = redType.GetConstructor (flags, null,
3372 new Type [] { typeof (string) },
3373 new ParameterModifier [0]);
3374 Assert.IsNull (ctor, "#N9");
3376 ctor = redType.GetConstructor (flags, null,
3377 new Type [] { typeof (string), typeof (string) },
3378 new ParameterModifier [0]);
3379 Assert.IsNull (ctor, "#N10");
3381 ctor = redType.GetConstructor (flags, null,
3382 new Type [] { typeof (int) },
3383 new ParameterModifier [0]);
3384 Assert.IsNull (ctor, "#N11");
3386 ctor = redType.GetConstructor (flags, null,
3387 new Type [] { typeof (int), typeof (bool) },
3388 new ParameterModifier [0]);
3389 Assert.IsNull (ctor, "#N12");
3391 ctor = redType.GetConstructor (flags, null,
3392 new Type [] { typeof (string), typeof (int) },
3393 new ParameterModifier [0]);
3394 Assert.IsNull (ctor, "#N13");
3396 ctor = redType.GetConstructor (flags, null,
3398 new ParameterModifier [0]);
3399 Assert.IsNotNull (ctor, "#N14a");
3400 Assert.IsTrue (ctor.IsPrivate, "#N14b");
3401 Assert.IsTrue (ctor.IsStatic, "#N14c");
3402 Assert.AreEqual (0, ctor.GetParameters ().Length, "#N14d");
3403 Assert.IsFalse (ctor is ConstructorBuilder, "#N14e");
3406 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
3407 public void GetConstructor2_Incomplete ()
3409 TypeBuilder tb = module.DefineType (genTypeName ());
3410 ConstructorBuilder cb = tb.DefineConstructor (
3411 MethodAttributes.Public,
3412 CallingConventions.Standard,
3414 cb.GetILGenerator ().Emit (OpCodes.Ret);
3417 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3418 null, Type.EmptyTypes, new ParameterModifier [0]);
3420 } catch (NotSupportedException ex) {
3421 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3422 Assert.IsNull (ex.InnerException, "#3");
3423 Assert.IsNotNull (ex.Message, "#4");
3427 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
3428 public void GetConstructor3_Incomplete ()
3430 TypeBuilder tb = module.DefineType (genTypeName ());
3431 ConstructorBuilder cb = tb.DefineConstructor (
3432 MethodAttributes.Public,
3433 CallingConventions.Standard,
3435 cb.GetILGenerator ().Emit (OpCodes.Ret);
3438 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3439 null, CallingConventions.Standard, Type.EmptyTypes,
3440 new ParameterModifier [0]);
3442 } catch (NotSupportedException ex) {
3443 // The invoked member is not supported in a
3445 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3446 Assert.IsNull (ex.InnerException, "#3");
3447 Assert.IsNotNull (ex.Message, "#4");
3451 [Test] // GetConstructors ()
3452 [Category ("NotWorking")] // mcs depends on this
3453 public void GetConstructors1_Incomplete ()
3455 TypeBuilder tb = module.DefineType (genTypeName ());
3456 ConstructorBuilder cb = tb.DefineConstructor (
3457 MethodAttributes.Public,
3458 CallingConventions.Standard,
3460 cb.GetILGenerator ().Emit (OpCodes.Ret);
3463 tb.GetConstructors ();
3465 } catch (NotSupportedException ex) {
3466 // The invoked member is not supported in a
3468 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3469 Assert.IsNull (ex.InnerException, "#3");
3470 Assert.IsNotNull (ex.Message, "#4");
3474 [Test] // GetConstructors (BindingFlags)
3475 public void GetConstructors2_Complete ()
3478 ConstructorInfo [] ctors;
3480 TypeBuilder redType = module.DefineType (genTypeName (),
3481 TypeAttributes.Public);
3482 CreateMembers (redType, "Red", true);
3484 TypeBuilder greenType = module.DefineType (genTypeName (),
3485 TypeAttributes.Public, redType);
3486 CreateMembers (greenType, "Green", false);
3487 ConstructorBuilder cb = greenType.DefineConstructor (
3488 MethodAttributes.Public,
3489 CallingConventions.Standard,
3491 cb.GetILGenerator ().Emit (OpCodes.Ret);
3493 redType.CreateType ();
3494 greenType.CreateType ();
3496 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3498 ctors = greenType.GetConstructors (flags);
3499 Assert.AreEqual (0, ctors.Length, "#A1");
3501 ctors = redType.GetConstructors (flags);
3502 Assert.AreEqual (5, ctors.Length, "#A2");
3503 Assert.IsTrue (ctors [0].IsPrivate, "#A3a");
3504 Assert.IsFalse (ctors [0].IsStatic, "#A3b");
3505 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#A3c");
3506 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#A3d");
3507 Assert.IsTrue (ctors [1].IsFamily, "#A4a");
3508 Assert.IsFalse (ctors [1].IsStatic, "#A4b");
3509 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#A4c");
3510 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#A4d");
3511 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#A5a");
3512 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3513 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#A5c");
3514 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#A5d");
3515 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#A6a");
3516 Assert.IsFalse (ctors [3].IsStatic, "#A6b");
3517 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#A6c");
3518 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#A6d");
3519 Assert.IsTrue (ctors [4].IsAssembly, "#A7a");
3520 Assert.IsFalse (ctors [4].IsStatic, "#A7b");
3521 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#A7c");
3522 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#A7d");
3524 flags = BindingFlags.Instance | BindingFlags.Public;
3526 ctors = greenType.GetConstructors (flags);
3527 Assert.AreEqual (1, ctors.Length, "#B1");
3528 Assert.IsTrue (ctors [0].IsPublic, "#B2a");
3529 Assert.IsFalse (ctors [0].IsStatic, "#B2b");
3530 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#B2c");
3531 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B2d");
3533 ctors = redType.GetConstructors (flags);
3534 Assert.AreEqual (1, ctors.Length, "#B3");
3535 Assert.IsTrue (ctors [0].IsPublic, "#B4a");
3536 Assert.IsFalse (ctors [0].IsStatic, "#B4b");
3537 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#B4c");
3538 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B4d");
3540 flags = BindingFlags.Static | BindingFlags.Public;
3542 ctors = greenType.GetConstructors (flags);
3543 Assert.AreEqual (0, ctors.Length, "#C1");
3545 ctors = redType.GetConstructors (flags);
3546 Assert.AreEqual (0, ctors.Length, "#C2");
3548 flags = BindingFlags.Static | BindingFlags.NonPublic;
3550 ctors = greenType.GetConstructors (flags);
3551 Assert.AreEqual (0, ctors.Length, "#D1");
3553 ctors = redType.GetConstructors (flags);
3554 Assert.AreEqual (1, ctors.Length, "#D2");
3555 Assert.IsTrue (ctors [0].IsPrivate, "#D3a");
3556 Assert.IsTrue (ctors [0].IsStatic, "#D3b");
3557 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#D3c");
3558 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#D3d");
3560 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3561 BindingFlags.FlattenHierarchy;
3563 ctors = greenType.GetConstructors (flags);
3564 Assert.AreEqual (0, ctors.Length, "#E1");
3566 ctors = redType.GetConstructors (flags);
3567 Assert.AreEqual (5, ctors.Length, "#E2");
3568 Assert.IsTrue (ctors [0].IsPrivate, "#E3a");
3569 Assert.IsFalse (ctors [0].IsStatic, "#E3b");
3570 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#E3c");
3571 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#E3d");
3572 Assert.IsTrue (ctors [1].IsFamily, "#E4a");
3573 Assert.IsFalse (ctors [1].IsStatic, "#E4b");
3574 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#E4c");
3575 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#E4d");
3576 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#E5a");
3577 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3578 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#E5c");
3579 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#E5d");
3580 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#E6a");
3581 Assert.IsFalse (ctors [3].IsStatic, "#E6b");
3582 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#E6c");
3583 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#E6d");
3584 Assert.IsTrue (ctors [4].IsAssembly, "#E7a");
3585 Assert.IsFalse (ctors [4].IsStatic, "#E7b");
3586 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#E7c");
3587 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#E7d");
3589 flags = BindingFlags.Instance | BindingFlags.Public |
3590 BindingFlags.FlattenHierarchy;
3592 ctors = greenType.GetConstructors (flags);
3593 Assert.AreEqual (1, ctors.Length, "#F1");
3594 Assert.IsTrue (ctors [0].IsPublic, "#F2a");
3595 Assert.IsFalse (ctors [0].IsStatic, "#F2b");
3596 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#F2c");
3597 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F2d");
3599 ctors = redType.GetConstructors (flags);
3600 Assert.AreEqual (1, ctors.Length, "#F3");
3601 Assert.IsTrue (ctors [0].IsPublic, "#F4a");
3602 Assert.IsFalse (ctors [0].IsStatic, "#F4b");
3603 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#F4c");
3604 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F4d");
3606 flags = BindingFlags.Static | BindingFlags.Public |
3607 BindingFlags.FlattenHierarchy;
3609 ctors = greenType.GetConstructors (flags);
3610 Assert.AreEqual (0, ctors.Length, "#G1");
3612 ctors = redType.GetConstructors (flags);
3613 Assert.AreEqual (0, ctors.Length, "#G2");
3615 flags = BindingFlags.Static | BindingFlags.NonPublic |
3616 BindingFlags.FlattenHierarchy;
3618 ctors = greenType.GetConstructors (flags);
3619 Assert.AreEqual (0, ctors.Length, "#H1");
3621 ctors = redType.GetConstructors (flags);
3622 Assert.AreEqual (1, ctors.Length, "#H2");
3623 Assert.IsTrue (ctors [0].IsPrivate, "#H3a");
3624 Assert.IsTrue (ctors [0].IsStatic, "#H3b");
3625 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#H3c");
3626 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#H3d");
3628 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3629 BindingFlags.DeclaredOnly;
3631 ctors = greenType.GetConstructors (flags);
3632 Assert.AreEqual (0, ctors.Length, "#I1");
3634 ctors = redType.GetConstructors (flags);
3635 Assert.AreEqual (5, ctors.Length, "#I2");
3636 Assert.IsTrue (ctors [0].IsPrivate, "#I3a");
3637 Assert.IsFalse (ctors [0].IsStatic, "#I3b");
3638 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#I3c");
3639 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#I3d");
3640 Assert.IsTrue (ctors [1].IsFamily, "#I4a");
3641 Assert.IsFalse (ctors [1].IsStatic, "#I4b");
3642 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#I4c");
3643 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#I4d");
3644 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#I5a");
3645 Assert.IsFalse (ctors [2].IsStatic, "#I5b");
3646 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#I5c");
3647 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#I5d");
3648 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#I6a");
3649 Assert.IsFalse (ctors [3].IsStatic, "#I6b");
3650 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#I6c");
3651 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#I6d");
3652 Assert.IsTrue (ctors [4].IsAssembly, "#I7a");
3653 Assert.IsFalse (ctors [4].IsStatic, "#I7b");
3654 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#I7c");
3655 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#I7d");
3657 flags = BindingFlags.Instance | BindingFlags.Public |
3658 BindingFlags.DeclaredOnly;
3660 ctors = greenType.GetConstructors (flags);
3661 Assert.AreEqual (1, ctors.Length, "#J1");
3662 Assert.IsTrue (ctors [0].IsPublic, "#J2a");
3663 Assert.IsFalse (ctors [0].IsStatic, "#J2b");
3664 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#J2c");
3665 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J2d");
3667 ctors = redType.GetConstructors (flags);
3668 Assert.AreEqual (1, ctors.Length, "#J3");
3669 Assert.IsTrue (ctors [0].IsPublic, "#J4a");
3670 Assert.IsFalse (ctors [0].IsStatic, "#J4b");
3671 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#J4c");
3672 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J4d");
3674 flags = BindingFlags.Static | BindingFlags.Public |
3675 BindingFlags.DeclaredOnly;
3677 ctors = greenType.GetConstructors (flags);
3678 Assert.AreEqual (0, ctors.Length, "#K1");
3680 ctors = redType.GetConstructors (flags);
3681 Assert.AreEqual (0, ctors.Length, "#K2");
3683 flags = BindingFlags.Static | BindingFlags.NonPublic |
3684 BindingFlags.DeclaredOnly;
3686 ctors = greenType.GetConstructors (flags);
3687 Assert.AreEqual (0, ctors.Length, "#L1");
3689 ctors = redType.GetConstructors (flags);
3690 Assert.AreEqual (1, ctors.Length, "#L2");
3691 Assert.IsTrue (ctors [0].IsPrivate, "#L3a");
3692 Assert.IsTrue (ctors [0].IsStatic, "#L3b");
3693 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#L3c");
3694 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#L3d");
3696 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3697 BindingFlags.Public;
3699 ctors = greenType.GetConstructors (flags);
3700 Assert.AreEqual (1, ctors.Length, "#M1");
3701 Assert.IsTrue (ctors [0].IsPublic, "#M2a");
3702 Assert.IsFalse (ctors [0].IsStatic, "#M2b");
3703 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#M2c");
3704 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M2d");
3706 ctors = redType.GetConstructors (flags);
3707 Assert.AreEqual (6, ctors.Length, "#M3");
3708 Assert.IsTrue (ctors [0].IsPrivate, "#M4a");
3709 Assert.IsFalse (ctors [0].IsStatic, "#M4b");
3710 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#M4c");
3711 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M4d");
3712 Assert.IsTrue (ctors [1].IsFamily, "#M5a");
3713 Assert.IsFalse (ctors [1].IsStatic, "#M5b");
3714 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#M5c");
3715 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#M5d");
3716 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#M6a");
3717 Assert.IsFalse (ctors [2].IsStatic, "#M6b");
3718 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#M6c");
3719 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#M6d");
3720 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#M7a");
3721 Assert.IsFalse (ctors [3].IsStatic, "#M7b");
3722 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#M7c");
3723 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#M7d");
3724 Assert.IsTrue (ctors [4].IsPublic, "#M8a");
3725 Assert.IsFalse (ctors [4].IsStatic, "#M8b");
3726 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#M8c");
3727 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#M8d");
3728 Assert.IsTrue (ctors [5].IsAssembly, "#M9a");
3729 Assert.IsFalse (ctors [5].IsStatic, "#M9b");
3730 Assert.AreEqual (2, ctors [5].GetParameters ().Length, "#M9c");
3731 Assert.IsFalse (ctors [5] is ConstructorBuilder, "#M9d");
3733 flags = BindingFlags.Static | BindingFlags.NonPublic |
3734 BindingFlags.Public;
3736 ctors = greenType.GetConstructors (flags);
3737 Assert.AreEqual (0, ctors.Length, "#N1");
3739 ctors = redType.GetConstructors (flags);
3740 Assert.AreEqual (1, ctors.Length, "#N2");
3741 Assert.IsTrue (ctors [0].IsPrivate, "#N3a");
3742 Assert.IsTrue (ctors [0].IsStatic, "#N3b");
3743 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#N3c");
3744 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#N3d");
3747 [Test] // GetConstructors (BindingFlags)
3748 [Category ("NotWorking")] // mcs depends on this
3749 public void GetConstructors2_Incomplete ()
3751 TypeBuilder tb = module.DefineType (genTypeName ());
3752 ConstructorBuilder cb = tb.DefineConstructor (
3753 MethodAttributes.Public,
3754 CallingConventions.Standard,
3756 cb.GetILGenerator ().Emit (OpCodes.Ret);
3759 tb.GetConstructors (BindingFlags.Public |
3760 BindingFlags.Instance);
3762 } catch (NotSupportedException ex) {
3763 // The invoked member is not supported in a
3765 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3766 Assert.IsNull (ex.InnerException, "#3");
3767 Assert.IsNotNull (ex.Message, "#4");
3772 public void TestGetCustomAttributesIncomplete ()
3774 TypeBuilder tb = module.DefineType (genTypeName ());
3776 tb.GetCustomAttributes (false);
3778 } catch (NotSupportedException ex) {
3779 // The invoked member is not supported in a
3781 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3782 Assert.IsNull (ex.InnerException, "#3");
3783 Assert.IsNotNull (ex.Message, "#4");
3788 public void TestGetCustomAttributesComplete ()
3790 TypeBuilder tb = module.DefineType (genTypeName ());
3792 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3793 new Type [] { typeof (string) });
3795 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3796 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3798 tb.SetCustomAttribute (caBuilder);
3801 Assert.AreEqual (1, tb.GetCustomAttributes (false).Length);
3805 public void TestGetCustomAttributesOfTypeIncomplete ()
3807 TypeBuilder tb = module.DefineType (genTypeName ());
3809 tb.GetCustomAttributes (typeof (ObsoleteAttribute), false);
3811 } catch (NotSupportedException ex) {
3812 // The invoked member is not supported in a
3814 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3815 Assert.IsNull (ex.InnerException, "#3");
3816 Assert.IsNotNull (ex.Message, "#4");
3821 public void TestGetCustomAttributesOfTypeComplete ()
3823 TypeBuilder tb = module.DefineType (genTypeName ());
3825 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3826 new Type [] { typeof (string) });
3828 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3829 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3831 tb.SetCustomAttribute (caBuilder);
3834 Assert.AreEqual (1, tb.GetCustomAttributes (typeof (GuidAttribute), false).Length, "#1");
3835 Assert.AreEqual (0, tb.GetCustomAttributes (typeof (ObsoleteAttribute), false).Length, "#2");
3839 public void TestGetCustomAttributesOfNullTypeComplete ()
3841 TypeBuilder tb = module.DefineType (genTypeName ());
3844 tb.GetCustomAttributes (null, false);
3846 } catch (ArgumentNullException ex) {
3847 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
3848 Assert.IsNull (ex.InnerException, "#3");
3849 Assert.IsNotNull (ex.Message, "#4");
3850 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
3855 [Ignore ("mcs depends on this")]
3856 public void TestGetEventsIncomplete ()
3858 TypeBuilder tb = module.DefineType (genTypeName ());
3862 } catch (NotSupportedException ex) {
3863 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3864 Assert.IsNull (ex.InnerException, "#3");
3865 Assert.IsNotNull (ex.Message, "#4");
3871 public void TestGetEventsComplete ()
3873 TypeBuilder tb = module.DefineType (genTypeName ());
3875 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3876 typeof (void), new Type [] { typeof (Object) });
3877 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
3879 // create public event
3880 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
3881 typeof (ResolveEventHandler));
3882 eventbuilder.SetRaiseMethod (onclickMethod);
3884 Type emittedType = tb.CreateType ();
3886 Assert.AreEqual (1, tb.GetEvents ().Length, "#1");
3887 Assert.AreEqual (tb.GetEvents ().Length, emittedType.GetEvents ().Length, "#2");
3892 [Ignore ("mcs depends on this")]
3893 public void TestGetEventsFlagsIncomplete ()
3895 TypeBuilder tb = module.DefineType (genTypeName ());
3897 tb.GetEvents (BindingFlags.Public);
3899 } catch (NotSupportedException ex) {
3900 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3901 Assert.IsNull (ex.InnerException, "#3");
3902 Assert.IsNotNull (ex.Message, "#4");
3908 public void TestGetEventsFlagsComplete ()
3910 TypeBuilder tb = module.DefineType (genTypeName ());
3912 MethodBuilder onchangeMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3913 typeof (void), new Type [] { typeof (Object) });
3914 onchangeMethod.GetILGenerator ().Emit (OpCodes.Ret);
3916 // create public event
3917 EventBuilder changeEvent = tb.DefineEvent ("Change", EventAttributes.None,
3918 typeof (ResolveEventHandler));
3919 changeEvent.SetRaiseMethod (onchangeMethod);
3921 // create non-public event
3922 EventBuilder redoChangeEvent = tb.DefineEvent ("RedoChange", EventAttributes.None,
3923 typeof (ResolveEventHandler));
3925 Type emittedType = tb.CreateType ();
3927 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3928 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3929 Assert.AreEqual (2, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3930 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length,
3931 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3932 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length,
3933 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3934 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length,
3935 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3939 public void TestGetEventsFlagsComplete_Inheritance ()
3941 EventInfo [] events;
3944 TypeBuilder blueType = module.DefineType (genTypeName (),
3945 TypeAttributes.Public);
3946 CreateMembers (blueType, "Blue", false);
3948 TypeBuilder redType = module.DefineType (genTypeName (),
3949 TypeAttributes.Public, blueType);
3950 CreateMembers (redType, "Red", false);
3952 TypeBuilder greenType = module.DefineType (genTypeName (),
3953 TypeAttributes.Public, redType);
3954 CreateMembers (greenType, "Green", false);
3956 blueType.CreateType ();
3957 redType.CreateType ();
3958 greenType.CreateType ();
3960 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3961 events = greenType.GetEvents (flags);
3963 Assert.AreEqual (13, events.Length, "#A1");
3964 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#A2");
3965 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#A3");
3966 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#A4");
3967 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#A5");
3968 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#A6");
3969 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#A7");
3970 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#A8");
3971 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#A9");
3972 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#A10");
3973 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#A11");
3974 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#A12");
3975 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#A13");
3976 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#A14");
3978 flags = BindingFlags.Instance | BindingFlags.Public;
3979 events = greenType.GetEvents (flags);
3981 Assert.AreEqual (3, events.Length, "#B1");
3982 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#B2");
3983 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#B3");
3984 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#B4");
3986 flags = BindingFlags.Static | BindingFlags.Public;
3987 events = greenType.GetEvents (flags);
3989 Assert.AreEqual (1, events.Length, "#C1");
3990 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#C2");
3992 flags = BindingFlags.Static | BindingFlags.NonPublic;
3993 events = greenType.GetEvents (flags);
3995 Assert.AreEqual (5, events.Length, "#D1");
3996 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#D2");
3997 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#D3");
3998 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#D4");
3999 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#D5");
4000 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#D6");
4002 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4003 BindingFlags.FlattenHierarchy;
4004 events = greenType.GetEvents (flags);
4006 Assert.AreEqual (13, events.Length, "#E1");
4007 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#E2");
4008 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#E3");
4009 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#E4");
4010 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#E5");
4011 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#E6");
4012 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#E7");
4013 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#E8");
4014 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#E9");
4015 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#E10");
4016 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#E11");
4017 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#E12");
4018 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#E13");
4019 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#E14");
4021 flags = BindingFlags.Instance | BindingFlags.Public |
4022 BindingFlags.FlattenHierarchy;
4023 events = greenType.GetEvents (flags);
4025 Assert.AreEqual (3, events.Length, "#F1");
4026 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#F2");
4027 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#F3");
4028 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#F4");
4030 flags = BindingFlags.Static | BindingFlags.Public |
4031 BindingFlags.FlattenHierarchy;
4032 events = greenType.GetEvents (flags);
4034 Assert.AreEqual (3, events.Length, "#G1");
4035 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#G2");
4036 Assert.AreEqual ("OnPublicStaticRed", events [1].Name, "#G3");
4037 Assert.AreEqual ("OnPublicStaticBlue", events [2].Name, "#G4");
4039 flags = BindingFlags.Static | BindingFlags.NonPublic |
4040 BindingFlags.FlattenHierarchy;
4041 events = greenType.GetEvents (flags);
4043 Assert.AreEqual (13, events.Length, "#H1");
4044 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#H2");
4045 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#H3");
4046 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#H4");
4047 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#H5");
4048 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#H6");
4049 Assert.AreEqual ("OnFamilyStaticRed", events [5].Name, "#H7");
4050 Assert.AreEqual ("OnFamANDAssemStaticRed", events [6].Name, "#H8");
4051 Assert.AreEqual ("OnFamORAssemStaticRed", events [7].Name, "#H9");
4052 Assert.AreEqual ("OnAssemblyStaticRed", events [8].Name, "#H10");
4053 Assert.AreEqual ("OnFamilyStaticBlue", events [9].Name, "#H11");
4054 Assert.AreEqual ("OnFamANDAssemStaticBlue", events [10].Name, "#H12");
4055 Assert.AreEqual ("OnFamORAssemStaticBlue", events [11].Name, "#H13");
4056 Assert.AreEqual ("OnAssemblyStaticBlue", events [12].Name, "#H14");
4058 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4059 BindingFlags.DeclaredOnly;
4060 events = greenType.GetEvents (flags);
4062 Assert.AreEqual (5, events.Length, "#I1");
4063 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#I2");
4064 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#I3");
4065 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#I4");
4066 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#I5");
4067 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#I6");
4069 flags = BindingFlags.Instance | BindingFlags.Public |
4070 BindingFlags.DeclaredOnly;
4071 events = greenType.GetEvents (flags);
4073 Assert.AreEqual (1, events.Length, "#J1");
4074 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#J2");
4076 flags = BindingFlags.Static | BindingFlags.Public |
4077 BindingFlags.DeclaredOnly;
4078 events = greenType.GetEvents (flags);
4080 Assert.AreEqual (1, events.Length, "#K1");
4081 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#K2");
4083 flags = BindingFlags.Static | BindingFlags.NonPublic |
4084 BindingFlags.DeclaredOnly;
4085 events = greenType.GetEvents (flags);
4087 Assert.AreEqual (5, events.Length, "#L1");
4088 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#L2");
4089 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#L3");
4090 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#L4");
4091 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#L5");
4092 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#L6");
4094 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4095 BindingFlags.Public;
4096 events = greenType.GetEvents (flags);
4098 Assert.AreEqual (16, events.Length, "#M1");
4099 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#M2");
4100 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#M3");
4101 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#M4");
4102 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#M5");
4103 Assert.AreEqual ("OnPublicInstanceGreen", events [4].Name, "#M6");
4104 Assert.AreEqual ("OnAssemblyInstanceGreen", events [5].Name, "#M7");
4105 Assert.AreEqual ("OnFamilyInstanceRed", events [6].Name, "#M8");
4106 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [7].Name, "#M9");
4107 Assert.AreEqual ("OnFamORAssemInstanceRed", events [8].Name, "#M10");
4108 Assert.AreEqual ("OnPublicInstanceRed", events [9].Name, "#M11");
4109 Assert.AreEqual ("OnAssemblyInstanceRed", events [10].Name, "#M12");
4110 Assert.AreEqual ("OnFamilyInstanceBlue", events [11].Name, "#M13");
4111 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [12].Name, "#M14");
4112 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [13].Name, "#M15");
4113 Assert.AreEqual ("OnPublicInstanceBlue", events [14].Name, "#M16");
4114 Assert.AreEqual ("OnAssemblyInstanceBlue", events [15].Name, "#M17");
4116 flags = BindingFlags.Static | BindingFlags.NonPublic |
4117 BindingFlags.Public;
4118 events = greenType.GetEvents (flags);
4120 Assert.AreEqual (6, events.Length, "#N1");
4121 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#N2");
4122 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#N3");
4123 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#N4");
4124 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#N5");
4125 Assert.AreEqual ("OnPublicStaticGreen", events [4].Name, "#N6");
4126 Assert.AreEqual ("OnAssemblyStaticGreen", events [5].Name, "#N7");
4130 [Ignore ("mcs depends on this")]
4131 public void TestGetEventIncomplete ()
4133 TypeBuilder tb = module.DefineType (genTypeName ());
4135 tb.GetEvent ("FOO");
4137 } catch (NotSupportedException ex) {
4138 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4139 Assert.IsNull (ex.InnerException, "#3");
4140 Assert.IsNotNull (ex.Message, "#4");
4146 public void TestGetEventComplete ()
4148 TypeBuilder tb = module.DefineType (genTypeName ());
4150 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4151 typeof (void), new Type [] { typeof (Object) });
4152 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4154 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4155 typeof (ResolveEventHandler));
4156 eventbuilder.SetRaiseMethod (onclickMethod);
4158 Type emittedType = tb.CreateType ();
4160 Assert.IsNotNull (tb.GetEvent ("Change"));
4161 Assert.AreEqual (tb.GetEvent ("Change"), emittedType.GetEvent ("Change"));
4162 Assert.IsNull (tb.GetEvent ("NotChange"));
4163 Assert.AreEqual (tb.GetEvent ("NotChange"), emittedType.GetEvent ("NotChange"));
4167 [Ignore ("mcs depends on this")]
4168 public void TestGetEventFlagsIncomplete ()
4170 TypeBuilder tb = module.DefineType (genTypeName ());
4172 tb.GetEvent ("FOO", BindingFlags.Public);
4174 } catch (NotSupportedException ex) {
4175 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4176 Assert.IsNull (ex.InnerException, "#3");
4177 Assert.IsNotNull (ex.Message, "#4");
4183 public void TestGetEventFlagsComplete ()
4185 TypeBuilder tb = module.DefineType (genTypeName ());
4187 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4188 typeof (void), new Type [] { typeof (Object) });
4189 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4191 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4192 typeof (ResolveEventHandler));
4193 eventbuilder.SetRaiseMethod (onclickMethod);
4195 Type emittedType = tb.CreateType ();
4197 Assert.IsNotNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4198 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public),
4199 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4200 Assert.IsNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4201 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic),
4202 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4206 public void TestGetEventFlagsComplete_Inheritance ()
4210 TypeBuilder blueType = module.DefineType (genTypeName (),
4211 TypeAttributes.Public);
4212 CreateMembers (blueType, "Blue", false);
4214 TypeBuilder redType = module.DefineType (genTypeName (),
4215 TypeAttributes.Public, blueType);
4216 CreateMembers (redType, "Red", false);
4218 TypeBuilder greenType = module.DefineType (genTypeName (),
4219 TypeAttributes.Public, redType);
4220 CreateMembers (greenType, "Green", false);
4222 blueType.CreateType ();
4223 redType.CreateType ();
4224 greenType.CreateType ();
4226 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4228 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#A1");
4229 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#A2");
4230 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#A3");
4231 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#A4");
4232 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#A5");
4233 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#A6");
4234 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#A7");
4235 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#A8");
4236 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#A9");
4237 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#A10");
4238 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#A11");
4239 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#A12");
4240 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#A13");
4241 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#A14");
4242 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#A15");
4243 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#A16");
4244 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#A17");
4245 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#A18");
4246 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#A19");
4247 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#A20");
4248 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#A21");
4249 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#A22");
4250 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#A23");
4251 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#A24");
4252 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#A25");
4253 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#A26");
4254 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#A27");
4255 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#A28");
4256 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#A29");
4257 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#A30");
4258 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#A31");
4259 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#A32");
4260 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#A33");
4261 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#A34");
4262 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#A35");
4263 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#A36");
4265 flags = BindingFlags.Instance | BindingFlags.Public;
4267 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#B1");
4268 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#B2");
4269 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#B3");
4270 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#B4");
4271 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#B5");
4272 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#B6");
4273 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#B7");
4274 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#B8");
4275 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#B9");
4276 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#B10");
4277 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#B11");
4278 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#B12");
4279 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#B13");
4280 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#B14");
4281 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#B15");
4282 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#B16");
4283 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#B17");
4284 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#B18");
4285 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#B19");
4286 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#B20");
4287 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#B21");
4288 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#B22");
4289 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#B23");
4290 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#B24");
4291 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#B25");
4292 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#B26");
4293 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#B27");
4294 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#B28");
4295 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#B29");
4296 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#B30");
4297 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#B31");
4298 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#B32");
4299 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#B33");
4300 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#B34");
4301 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#B35");
4302 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#B36");
4304 flags = BindingFlags.Static | BindingFlags.Public;
4306 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#C1");
4307 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#C2");
4308 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#C3");
4309 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#C4");
4310 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#C5");
4311 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#C6");
4312 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#C7");
4313 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#C8");
4314 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#C9");
4315 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#C10");
4316 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#C11");
4317 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#C12");
4318 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#C13");
4319 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#C14");
4320 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#C15");
4321 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#C16");
4322 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#C17");
4323 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#C18");
4324 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#C19");
4325 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#C20");
4326 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#C21");
4327 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#C22");
4328 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#C23");
4329 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#C24");
4330 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#C25");
4331 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#C26");
4332 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#C27");
4333 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#C28");
4334 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#C29");
4335 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#C30");
4336 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#C31");
4337 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#C32");
4338 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#C33");
4339 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#C34");
4340 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#C35");
4341 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#C36");
4343 flags = BindingFlags.Static | BindingFlags.NonPublic;
4345 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#D1");
4346 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#D2");
4347 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#D3");
4348 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#D4");
4349 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#D5");
4350 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#D6");
4351 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#D7");
4352 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#D8");
4353 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#D9");
4354 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#D10");
4355 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#D11");
4356 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#D12");
4357 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#D13");
4358 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#D14");
4359 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#D15");
4360 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#D16");
4361 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#D17");
4362 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#D18");
4363 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#D19");
4364 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#D20");
4365 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#D21");
4366 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#D22");
4367 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#D23");
4368 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#D24");
4369 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#D25");
4370 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#D26");
4371 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#D27");
4372 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#D28");
4373 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#D29");
4374 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#D30");
4375 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#D31");
4376 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#D32");
4377 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#D33");
4378 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#D34");
4379 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#D35");
4380 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#D36");
4382 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4383 BindingFlags.FlattenHierarchy;
4385 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#E1");
4386 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#E2");
4387 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#E3");
4388 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#E4");
4389 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#E5");
4390 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#E6");
4391 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#E7");
4392 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#E8");
4393 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#E9");
4394 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#E10");
4395 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#E11");
4396 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#E12");
4397 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#E13");
4398 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#E14");
4399 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#E15");
4400 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#E16");
4401 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#E17");
4402 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#E18");
4403 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#E19");
4404 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#E20");
4405 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#E21");
4406 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#E22");
4407 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#E23");
4408 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#E24");
4409 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#E25");
4410 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#E26");
4411 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#E27");
4412 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#E28");
4413 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#E29");
4414 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#E30");
4415 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#E31");
4416 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#E32");
4417 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#E33");
4418 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#E34");
4419 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#E35");
4420 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#E36");
4422 flags = BindingFlags.Instance | BindingFlags.Public |
4423 BindingFlags.FlattenHierarchy;
4425 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#F1");
4426 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#F2");
4427 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#F3");
4428 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#F4");
4429 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#F5");
4430 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#F6");
4431 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#F7");
4432 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#F8");
4433 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#F9");
4434 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#F10");
4435 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#F11");
4436 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#F12");
4437 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#F13");
4438 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#F14");
4439 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#F15");
4440 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#F16");
4441 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#F17");
4442 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#F18");
4443 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#F19");
4444 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#F20");
4445 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#F21");
4446 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#F22");
4447 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#F23");
4448 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#F24");
4449 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#F25");
4450 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#F26");
4451 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#F27");
4452 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#F28");
4453 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#F29");
4454 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#F30");
4455 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#F31");
4456 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#F32");
4457 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#F33");
4458 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#F34");
4459 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#F35");
4460 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#F36");
4462 flags = BindingFlags.Static | BindingFlags.Public |
4463 BindingFlags.FlattenHierarchy;
4465 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#G1");
4466 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#G2");
4467 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#G3");
4468 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#G4");
4469 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#G5");
4470 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#G6");
4471 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#G7");
4472 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#G8");
4473 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#G9");
4474 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#G10");
4475 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#G11");
4476 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#G12");
4477 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#G13");
4478 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#G14");
4479 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#G15");
4480 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#G16");
4481 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#G17");
4482 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#G18");
4483 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#G19");
4484 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#G20");
4485 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#G21");
4486 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#G22");
4487 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#G23");
4488 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#G24");
4489 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#G25");
4490 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#G26");
4491 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#G27");
4492 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#G28");
4493 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#G29");
4494 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#G30");
4495 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#G31");
4496 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#G32");
4497 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#G33");
4498 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#G34");
4499 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#G35");
4500 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#G36");
4502 flags = BindingFlags.Static | BindingFlags.NonPublic |
4503 BindingFlags.FlattenHierarchy;
4505 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#H1");
4506 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#H2");
4507 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#H3");
4508 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#H4");
4509 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#H5");
4510 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#H6");
4511 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#H7");
4512 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#H8");
4513 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#H9");
4514 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#H10");
4515 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#H11");
4516 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#H12");
4517 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#H13");
4518 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#H14");
4519 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#H15");
4520 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#H16");
4521 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#H17");
4522 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#H18");
4523 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#H19");
4524 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#H20");
4525 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#H21");
4526 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#H22");
4527 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#H23");
4528 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#H24");
4529 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#H25");
4530 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#H26");
4531 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#H27");
4532 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#H28");
4533 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#H29");
4534 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#H30");
4535 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#H31");
4536 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#H32");
4537 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#H33");
4538 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#H34");
4539 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#H35");
4540 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#H36");
4542 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4543 BindingFlags.DeclaredOnly;
4545 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#I1");
4546 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#I2");
4547 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#I3");
4548 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#I4");
4549 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#I5");
4550 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#I6");
4551 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#I7");
4552 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#I8");
4553 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#I9");
4554 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#I10");
4555 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#I11");
4556 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#I12");
4557 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#I13");
4558 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#I14");
4559 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#I15");
4560 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#I16");
4561 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#I17");
4562 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#I18");
4563 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#I19");
4564 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#I20");
4565 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#I21");
4566 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#I22");
4567 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#I23");
4568 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#I24");
4569 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#I25");
4570 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#I26");
4571 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#I27");
4572 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#I28");
4573 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#I29");
4574 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#I30");
4575 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#I31");
4576 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#I32");
4577 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#I33");
4578 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#I34");
4579 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#I35");
4580 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#I36");
4582 flags = BindingFlags.Instance | BindingFlags.Public |
4583 BindingFlags.DeclaredOnly;
4585 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#J1");
4586 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#J2");
4587 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#J3");
4588 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#J4");
4589 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#J5");
4590 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#J6");
4591 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#J7");
4592 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#J8");
4593 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#J9");
4594 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#J10");
4595 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#J11");
4596 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#J12");
4597 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#J13");
4598 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#J14");
4599 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#J15");
4600 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#J16");
4601 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#J17");
4602 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#J18");
4603 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#J19");
4604 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#J20");
4605 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#J21");
4606 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#J22");
4607 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#J23");
4608 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#J24");
4609 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#J25");
4610 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#J26");
4611 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#J27");
4612 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#J28");
4613 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#J29");
4614 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#J30");
4615 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#J31");
4616 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#J32");
4617 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#J33");
4618 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#J34");
4619 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#J35");
4620 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#J36");
4622 flags = BindingFlags.Static | BindingFlags.Public |
4623 BindingFlags.DeclaredOnly;
4625 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#K1");
4626 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#K2");
4627 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#K3");
4628 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#K4");
4629 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#K5");
4630 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#K6");
4631 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#K7");
4632 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#K8");
4633 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#K9");
4634 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#K10");
4635 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#K11");
4636 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#K12");
4637 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#K13");
4638 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#K14");
4639 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#K15");
4640 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#K16");
4641 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#K17");
4642 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#K18");
4643 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#K19");
4644 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#K20");
4645 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#K21");
4646 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#K22");
4647 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#K23");
4648 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#K24");
4649 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#K25");
4650 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#K26");
4651 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#K27");
4652 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#K28");
4653 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#K29");
4654 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#K30");
4655 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#K31");
4656 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#K32");
4657 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#K33");
4658 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#K34");
4659 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#K35");
4660 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#K36");
4662 flags = BindingFlags.Static | BindingFlags.NonPublic |
4663 BindingFlags.DeclaredOnly;
4665 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#L1");
4666 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#L2");
4667 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#L3");
4668 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#L4");
4669 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#L5");
4670 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#L6");
4671 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#L7");
4672 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#L8");
4673 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#L9");
4674 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#L10");
4675 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#L11");
4676 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#L12");
4677 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#L13");
4678 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#L14");
4679 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#L15");
4680 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#L16");
4681 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#L17");
4682 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#L18");
4683 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#L19");
4684 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#L20");
4685 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#L21");
4686 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#L22");
4687 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#L23");
4688 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#L24");
4689 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#L25");
4690 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#L26");
4691 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#L27");
4692 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#L28");
4693 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#L29");
4694 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#L30");
4695 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#L31");
4696 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#L32");
4697 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#L33");
4698 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#L34");
4699 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#L35");
4700 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#L36");
4702 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4703 BindingFlags.Public;
4705 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#M1");
4706 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#M2");
4707 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#M3");
4708 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#M4");
4709 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#M5");
4710 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#M6");
4711 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#M7");
4712 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#M8");
4713 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#M9");
4714 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#M10");
4715 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#M11");
4716 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#M12");
4717 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#M13");
4718 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#M14");
4719 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#M15");
4720 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#M16");
4721 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#M17");
4722 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#M18");
4723 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#M19");
4724 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#M20");
4725 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#M21");
4726 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#M22");
4727 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#M23");
4728 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#M24");
4729 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#M25");
4730 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#M26");
4731 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#M27");
4732 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#M28");
4733 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#M29");
4734 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#M30");
4735 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#M31");
4736 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#M32");
4737 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#M33");
4738 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#M34");
4739 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#M35");
4740 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#M36");
4742 flags = BindingFlags.Static | BindingFlags.NonPublic |
4743 BindingFlags.Public;
4745 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#N1");
4746 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#N2");
4747 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#N3");
4748 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#N4");
4749 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#N5");
4750 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#N6");
4751 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#N7");
4752 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#N8");
4753 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#N9");
4754 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#N10");
4755 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#N11");
4756 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#N12");
4757 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#N13");
4758 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#N14");
4759 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#N15");
4760 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#N16");
4761 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#N17");
4762 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#N18");
4763 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#N19");
4764 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#N20");
4765 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#N21");
4766 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#N22");
4767 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#N23");
4768 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#N24");
4769 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#N25");
4770 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#N26");
4771 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#N27");
4772 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#N28");
4773 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#N29");
4774 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#N30");
4775 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#N31");
4776 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#N32");
4777 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#N33");
4778 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#N34");
4779 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#N35");
4780 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#N36");
4784 [Category ("NotWorking")] // mcs depends on this
4785 public void TestGetFieldsIncomplete_MS ()
4787 TypeBuilder tb = module.DefineType (genTypeName ());
4788 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4792 } catch (NotSupportedException ex) {
4793 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4794 Assert.IsNull (ex.InnerException, "#3");
4795 Assert.IsNotNull (ex.Message, "#4");
4800 [Category ("NotDotNet")] // mcs depends on this
4801 public void TestGetFieldsIncomplete_Mono ()
4803 TypeBuilder tb = module.DefineType (genTypeName ());
4804 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4805 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4806 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4807 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4809 FieldInfo [] fields = tb.GetFields ();
4810 Assert.AreEqual (2, fields.Length, "#A1");
4811 Assert.AreEqual ("Sex", fields [0].Name, "#A2");
4812 Assert.AreEqual ("MALE", fields [1].Name, "#A3");
4814 tb = module.DefineType (genTypeName ());
4815 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4816 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4817 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4818 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4819 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4820 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4822 fields = tb.GetFields ();
4823 Assert.AreEqual (4, fields.Length, "#B1");
4824 Assert.AreEqual ("First", fields [0].Name, "#B2");
4825 Assert.AreEqual ("Second", fields [1].Name, "#B3");
4826 Assert.AreEqual ("Sex", fields [2].Name, "#B4");
4827 Assert.AreEqual ("MALE", fields [3].Name, "#B5");
4831 public void TestGetFieldsComplete ()
4833 TypeBuilder tb = module.DefineType (genTypeName ());
4834 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4836 Type emittedType = tb.CreateType ();
4837 FieldInfo [] dynamicFields = tb.GetFields ();
4838 FieldInfo [] emittedFields = emittedType.GetFields ();
4840 Assert.AreEqual (1, dynamicFields.Length, "#A1");
4841 Assert.AreEqual (dynamicFields.Length, emittedFields.Length, "#A2");
4842 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#A3");
4843 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#A4");
4846 object value = Activator.CreateInstance (emittedType);
4847 emittedFields [0].SetValue (value, 5);
4848 Assert.AreEqual (5, emittedFields [0].GetValue (value), "#B1");
4849 Assert.AreEqual (5, dynamicFields [0].GetValue (value), "#B2");
4850 dynamicFields [0].SetValue (value, 4);
4851 Assert.AreEqual (4, emittedFields [0].GetValue (value), "#B3");
4852 Assert.AreEqual (4, dynamicFields [0].GetValue (value), "#B4");
4855 [Test] // bug #82625 / 325292
4856 public void TestGetFieldsComplete_Generic ()
4858 // FIXME: merge this with TestGetFieldsComplete when
4859 // bug #82625 is fixed
4863 FieldInfo [] dynamicFields;
4864 FieldInfo [] emittedFields;
4866 tb = module.DefineType (genTypeName ());
4867 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4868 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4869 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4870 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4871 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4872 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4874 emittedType = tb.CreateType ();
4875 dynamicFields = tb.GetFields ();
4876 emittedFields = emittedType.GetFields ();
4878 Assert.AreEqual (4, dynamicFields.Length, "#C1");
4879 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#C2");
4880 Assert.IsFalse ((dynamicFields [1]) is FieldBuilder, "#C3");
4881 Assert.IsFalse ((dynamicFields [2]) is FieldBuilder, "#C4");
4882 Assert.IsFalse ((dynamicFields [3]) is FieldBuilder, "#C5");
4883 Assert.AreEqual ("First", dynamicFields [0].Name, "#C6");
4884 Assert.AreEqual ("Second", dynamicFields [1].Name, "#C7");
4885 Assert.AreEqual ("Sex", dynamicFields [2].Name, "#C8");
4886 Assert.AreEqual ("MALE", dynamicFields [3].Name, "#C9");
4888 Assert.AreEqual (4, emittedFields.Length, "#D1");
4889 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#D2");
4890 Assert.IsFalse ((emittedFields [1]) is FieldBuilder, "#D3");
4891 Assert.IsFalse ((emittedFields [2]) is FieldBuilder, "#D4");
4892 Assert.IsFalse ((emittedFields [3]) is FieldBuilder, "#D5");
4893 Assert.AreEqual ("First", emittedFields [0].Name, "#D6");
4894 Assert.AreEqual ("Second", emittedFields [1].Name, "#D7");
4895 Assert.AreEqual ("Sex", emittedFields [2].Name, "#D8");
4896 Assert.AreEqual ("MALE", emittedFields [3].Name, "#D9");
4900 [Category ("NotWorking")] // mcs depends on this
4901 public void TestGetFieldsFlagsIncomplete_MS ()
4903 TypeBuilder tb = module.DefineType (genTypeName ());
4904 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4906 tb.GetFields (BindingFlags.Instance | BindingFlags.Public);
4908 } catch (NotSupportedException ex) {
4909 // The invoked member is not supported in a
4911 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4912 Assert.IsNull (ex.InnerException, "#3");
4913 Assert.IsNotNull (ex.Message, "#4");
4918 [Category ("NotDotNet")] // mcs depends on this
4919 public void TestGetFieldsFlagsIncomplete_Mono ()
4921 FieldInfo [] fields;
4923 TypeBuilder tb = module.DefineType (genTypeName ());
4924 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4925 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4926 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4927 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4929 fields = tb.GetFields (BindingFlags.Public |
4930 BindingFlags.NonPublic | BindingFlags.Instance);
4931 Assert.AreEqual (2, fields.Length, "#A1");
4932 Assert.AreEqual ("name", fields [0].Name, "#A2");
4933 Assert.AreEqual ("Sex", fields [1].Name, "#A3");
4935 fields = tb.GetFields (BindingFlags.Public |
4936 BindingFlags.Instance | BindingFlags.Static);
4937 Assert.AreEqual (2, fields.Length, "#B1");
4938 Assert.AreEqual ("Sex", fields [0].Name, "#B2");
4939 Assert.AreEqual ("MALE", fields [1].Name, "#B3");
4941 fields = tb.GetFields (BindingFlags.Public |
4942 BindingFlags.NonPublic | BindingFlags.Instance |
4943 BindingFlags.Static);
4944 Assert.AreEqual (4, fields.Length, "#C1");
4945 Assert.AreEqual ("name", fields [0].Name, "#C2");
4946 Assert.AreEqual ("Sex", fields [1].Name, "#C3");
4947 Assert.AreEqual ("MALE", fields [2].Name, "#C4");
4948 Assert.AreEqual ("FEMALE", fields [3].Name, "#C5");
4952 public void TestGetFieldsFlagsComplete ()
4954 TypeBuilder tb = module.DefineType (genTypeName ());
4955 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4957 Type emittedType = tb.CreateType ();
4959 Assert.AreEqual (1, tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4960 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length,
4961 emittedType.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4962 Assert.AreEqual (0, tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4963 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length,
4964 emittedType.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4968 public void TestGetFieldsFlagsComplete_Inheritance ()
4970 FieldInfo [] fields;
4973 TypeBuilder blueType = module.DefineType (genTypeName (),
4974 TypeAttributes.Public);
4975 CreateMembers (blueType, "Blue", false);
4977 TypeBuilder redType = module.DefineType (genTypeName (),
4978 TypeAttributes.Public, blueType);
4979 CreateMembers (redType, "Red", false);
4981 TypeBuilder greenType = module.DefineType (genTypeName (),
4982 TypeAttributes.Public, redType);
4983 CreateMembers (greenType, "Green", false);
4985 blueType.CreateType ();
4986 redType.CreateType ();
4987 greenType.CreateType ();
4989 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4990 fields = greenType.GetFields (flags);
4992 Assert.AreEqual (13, fields.Length, "#A1");
4993 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#A2");
4994 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#A3");
4995 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#A4");
4996 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#A5");
4997 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#A6");
4998 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#A7");
4999 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#A8");
5000 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#A9");
5001 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#A10");
5002 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#A11");
5003 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#A12");
5004 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#A13");
5005 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#A14");
5007 flags = BindingFlags.Instance | BindingFlags.Public;
5008 fields = greenType.GetFields (flags);
5010 Assert.AreEqual (3, fields.Length, "#B1");
5011 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#B2");
5012 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#B3");
5013 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#B4");
5015 flags = BindingFlags.Static | BindingFlags.Public;
5016 fields = greenType.GetFields (flags);
5018 Assert.AreEqual (1, fields.Length, "#C1");
5019 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#C2");
5021 flags = BindingFlags.Static | BindingFlags.NonPublic;
5022 fields = greenType.GetFields (flags);
5024 Assert.AreEqual (5, fields.Length, "#D1");
5025 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#D2");
5026 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#D3");
5027 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#D4");
5028 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#D5");
5029 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#D6");
5031 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5032 BindingFlags.FlattenHierarchy;
5033 fields = greenType.GetFields (flags);
5035 Assert.AreEqual (13, fields.Length, "#E1");
5036 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#E2");
5037 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#E3");
5038 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#E4");
5039 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#E5");
5040 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#E6");
5041 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#E7");
5042 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#E8");
5043 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#E9");
5044 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#E10");
5045 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#E11");
5046 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#E12");
5047 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#E13");
5048 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#E14");
5050 flags = BindingFlags.Instance | BindingFlags.Public |
5051 BindingFlags.FlattenHierarchy;
5052 fields = greenType.GetFields (flags);
5054 Assert.AreEqual (3, fields.Length, "#F1");
5055 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#F2");
5056 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#F3");
5057 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#F4");
5059 flags = BindingFlags.Static | BindingFlags.Public |
5060 BindingFlags.FlattenHierarchy;
5061 fields = greenType.GetFields (flags);
5063 Assert.AreEqual (3, fields.Length, "#G1");
5064 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#G2");
5065 Assert.AreEqual ("publicStaticRed", fields [1].Name, "#G3");
5066 Assert.AreEqual ("publicStaticBlue", fields [2].Name, "#G4");
5068 flags = BindingFlags.Static | BindingFlags.NonPublic |
5069 BindingFlags.FlattenHierarchy;
5070 fields = greenType.GetFields (flags);
5072 Assert.AreEqual (13, fields.Length, "#H1");
5073 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#H2");
5074 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#H3");
5075 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#H4");
5076 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#H5");
5077 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#H6");
5078 Assert.AreEqual ("familyStaticRed", fields [5].Name, "#H7");
5079 Assert.AreEqual ("famANDAssemStaticRed", fields [6].Name, "#H8");
5080 Assert.AreEqual ("famORAssemStaticRed", fields [7].Name, "#H9");
5081 Assert.AreEqual ("assemblyStaticRed", fields [8].Name, "#H10");
5082 Assert.AreEqual ("familyStaticBlue", fields [9].Name, "#H11");
5083 Assert.AreEqual ("famANDAssemStaticBlue", fields [10].Name, "#H12");
5084 Assert.AreEqual ("famORAssemStaticBlue", fields [11].Name, "#H13");
5085 Assert.AreEqual ("assemblyStaticBlue", fields [12].Name, "#H14");
5087 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5088 BindingFlags.DeclaredOnly;
5089 fields = greenType.GetFields (flags);
5091 Assert.AreEqual (5, fields.Length, "#I1");
5092 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#I2");
5093 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#I3");
5094 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#I4");
5095 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#I5");
5096 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#I6");
5098 flags = BindingFlags.Instance | BindingFlags.Public |
5099 BindingFlags.DeclaredOnly;
5100 fields = greenType.GetFields (flags);
5102 Assert.AreEqual (1, fields.Length, "#J1");
5103 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#J2");
5105 flags = BindingFlags.Static | BindingFlags.Public |
5106 BindingFlags.DeclaredOnly;
5107 fields = greenType.GetFields (flags);
5109 Assert.AreEqual (1, fields.Length, "#K1");
5110 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#K2");
5112 flags = BindingFlags.Static | BindingFlags.NonPublic |
5113 BindingFlags.DeclaredOnly;
5114 fields = greenType.GetFields (flags);
5116 Assert.AreEqual (5, fields.Length, "#L1");
5117 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#L2");
5118 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#L3");
5119 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#L4");
5120 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#L5");
5121 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#L6");
5123 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5124 BindingFlags.Public;
5125 fields = greenType.GetFields (flags);
5127 Assert.AreEqual (16, fields.Length, "#M1");
5128 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#M2");
5129 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#M3");
5130 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#M4");
5131 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#M5");
5132 Assert.AreEqual ("publicInstanceGreen", fields [4].Name, "#M6");
5133 Assert.AreEqual ("assemblyInstanceGreen", fields [5].Name, "#M7");
5134 Assert.AreEqual ("familyInstanceRed", fields [6].Name, "#M8");
5135 Assert.AreEqual ("famANDAssemInstanceRed", fields [7].Name, "#M9");
5136 Assert.AreEqual ("famORAssemInstanceRed", fields [8].Name, "#M10");
5137 Assert.AreEqual ("publicInstanceRed", fields [9].Name, "#M11");
5138 Assert.AreEqual ("assemblyInstanceRed", fields [10].Name, "#M12");
5139 Assert.AreEqual ("familyInstanceBlue", fields [11].Name, "#M13");
5140 Assert.AreEqual ("famANDAssemInstanceBlue", fields [12].Name, "#M14");
5141 Assert.AreEqual ("famORAssemInstanceBlue", fields [13].Name, "#M15");
5142 Assert.AreEqual ("publicInstanceBlue", fields [14].Name, "#M16");
5143 Assert.AreEqual ("assemblyInstanceBlue", fields [15].Name, "#M17");
5145 flags = BindingFlags.Static | BindingFlags.NonPublic |
5146 BindingFlags.Public;
5147 fields = greenType.GetFields (flags);
5149 Assert.AreEqual (6, fields.Length, "#N1");
5150 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#N2");
5151 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#N3");
5152 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#N4");
5153 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#N5");
5154 Assert.AreEqual ("publicStaticGreen", fields [4].Name, "#N6");
5155 Assert.AreEqual ("assemblyStaticGreen", fields [5].Name, "#N7");
5159 [Category ("NotWorking")] // mcs depends on this
5160 public void TestGetFieldIncomplete_MS ()
5162 TypeBuilder tb = module.DefineType (genTypeName ());
5163 tb.DefineField ("test", typeof (int), FieldAttributes.Public);
5165 tb.GetField ("test");
5167 } catch (NotSupportedException ex) {
5168 // The invoked member is not supported in a
5170 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5171 Assert.IsNull (ex.InnerException, "#3");
5172 Assert.IsNotNull (ex.Message, "#4");
5177 [Category ("NotDotNet")] // mcs depends on this
5178 public void TestGetFieldIncomplete_Mono ()
5180 TypeBuilder tb = module.DefineType (genTypeName ());
5181 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5182 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5184 FieldInfo field = tb.GetField ("TestField");
5185 Assert.IsNotNull (field, "#A1");
5186 Assert.AreEqual ("TestField", field.Name, "#A2");
5187 Assert.IsTrue (field is FieldBuilder, "#A3");
5189 Assert.IsNull (tb.GetField ("OtherField"), "#B1");
5190 Assert.IsNull (tb.GetField ("TestOtherField"), "#B2");
5194 public void TestGetFieldComplete ()
5196 TypeBuilder tb = module.DefineType (genTypeName ());
5197 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5199 Type emittedType = tb.CreateType ();
5201 FieldInfo dynamicField = tb.GetField ("TestField");
5202 FieldInfo emittedField = emittedType.GetField ("TestField");
5203 Assert.IsNotNull (dynamicField, "#A1");
5204 Assert.AreEqual (dynamicField.Name, emittedField.Name, "#A2");
5205 Assert.IsNull (tb.GetField ("TestOtherField"), "#A3");
5206 Assert.IsFalse (emittedField is FieldBuilder, "#A4");
5207 Assert.IsFalse (dynamicField is FieldBuilder, "#A5");
5210 object value = Activator.CreateInstance (emittedType);
5211 emittedField.SetValue (value, 5);
5212 Assert.AreEqual (5, emittedField.GetValue (value), "#B1");
5213 Assert.AreEqual (5, dynamicField.GetValue (value), "#B2");
5214 dynamicField.SetValue (value, 4);
5215 Assert.AreEqual (4, emittedField.GetValue (value), "#B3");
5216 Assert.AreEqual (4, dynamicField.GetValue (value), "#B4");
5219 [Test] // bug #81640
5220 public void TestGetFieldComplete_Type ()
5222 TypeBuilder tb = module.DefineType (genTypeName ());
5223 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5224 Type emittedType = tb.CreateType ();
5225 FieldInfo dynamicField = tb.GetField ("TestField");
5226 Assert.IsFalse (dynamicField is FieldBuilder, "#1");
5228 object value = Activator.CreateInstance (emittedType);
5229 Assert.AreEqual (0, dynamicField.GetValue (value), "#2");
5233 [Category ("NotWorking")] // mcs depends on this
5234 public void TestGetFieldFlagsIncomplete_MS ()
5236 TypeBuilder tb = module.DefineType (genTypeName ());
5237 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5238 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5240 tb.GetField ("test", BindingFlags.Public);
5242 } catch (NotSupportedException ex) {
5243 // The invoked member is not supported in a
5245 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5246 Assert.IsNull (ex.InnerException, "#3");
5247 Assert.IsNotNull (ex.Message, "#4");
5252 [Category ("NotDotNet")] // mcs depends on this
5253 public void TestGetFieldFlagsIncomplete_Mono ()
5255 TypeBuilder tb = module.DefineType (genTypeName ());
5256 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5257 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5259 FieldInfo field = tb.GetField ("TestField", BindingFlags.Public
5260 | BindingFlags.Instance);
5261 Assert.IsNotNull (field, "#A1");
5262 Assert.AreEqual ("TestField", field.Name, "#A2");
5263 Assert.IsTrue (field is FieldBuilder, "#A3");
5265 field = tb.GetField ("OtherField", BindingFlags.NonPublic |
5266 BindingFlags.Instance);
5267 Assert.IsNotNull (field, "#B1");
5268 Assert.AreEqual ("OtherField", field.Name, "#B2");
5269 Assert.IsTrue (field is FieldBuilder, "#B3");
5271 Assert.IsNull (tb.GetField ("TestField", BindingFlags.NonPublic |
5272 BindingFlags.Instance), "#C1");
5273 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Public |
5274 BindingFlags.Static), "#C2");
5275 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5276 BindingFlags.Instance), "#C3");
5277 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5278 BindingFlags.Static), "#C4");
5279 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.NonPublic |
5280 BindingFlags.Instance), "#C5");
5281 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.Public |
5282 BindingFlags.Instance), "#C6");
5286 public void TestGetFieldFlagsComplete ()
5288 TypeBuilder tb = module.DefineType (genTypeName ());
5289 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5291 Type emittedType = tb.CreateType ();
5293 Assert.IsNotNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public));
5294 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name,
5295 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name);
5296 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5297 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic),
5298 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5302 public void TestGetFieldFlagsComplete_Inheritance ()
5306 TypeBuilder blueType = module.DefineType (genTypeName (),
5307 TypeAttributes.Public);
5308 CreateMembers (blueType, "Blue", false);
5310 TypeBuilder redType = module.DefineType (genTypeName (),
5311 TypeAttributes.Public, blueType);
5312 CreateMembers (redType, "Red", false);
5314 TypeBuilder greenType = module.DefineType (genTypeName (),
5315 TypeAttributes.Public, redType);
5316 CreateMembers (greenType, "Green", false);
5318 blueType.CreateType ();
5319 redType.CreateType ();
5320 greenType.CreateType ();
5322 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5324 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#A1");
5325 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#A2");
5326 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#A3");
5327 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#A4");
5328 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#A5");
5329 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#A6");
5330 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#A7");
5331 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#A8");
5332 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#A9");
5333 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#A10");
5334 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#A11");
5335 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#A12");
5336 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#A13");
5337 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#A14");
5338 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#A15");
5339 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#A16");
5340 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#A17");
5341 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#A18");
5342 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#A19");
5343 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#A20");
5344 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#A21");
5345 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#A22");
5346 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#A23");
5347 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#A24");
5348 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#A25");
5349 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#A26");
5350 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#A27");
5351 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#A28");
5352 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#A29");
5353 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#A30");
5354 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#A31");
5355 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#A32");
5356 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#A33");
5357 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#A34");
5358 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#A35");
5359 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#A36");
5361 flags = BindingFlags.Instance | BindingFlags.Public;
5363 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#B1");
5364 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#B2");
5365 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#B3");
5366 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#B4");
5367 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#B5");
5368 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#B6");
5369 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#B7");
5370 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#B8");
5371 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#B9");
5372 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#B10");
5373 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#B11");
5374 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#B12");
5375 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#B13");
5376 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#B14");
5377 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#B15");
5378 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#B16");
5379 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#B17");
5380 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#B18");
5381 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#B19");
5382 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#B20");
5383 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#B21");
5384 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#B22");
5385 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#B23");
5386 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#B24");
5387 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#B25");
5388 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#B26");
5389 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#B27");
5390 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#B28");
5391 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#B29");
5392 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#B30");
5393 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#B31");
5394 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#B32");
5395 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#B33");
5396 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#B34");
5397 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#B35");
5398 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#B36");
5400 flags = BindingFlags.Static | BindingFlags.Public;
5402 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#C1");
5403 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#C2");
5404 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#C3");
5405 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#C4");
5406 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#C5");
5407 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#C6");
5408 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#C7");
5409 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#C8");
5410 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#C9");
5411 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#C10");
5412 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#C11");
5413 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#C12");
5414 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#C13");
5415 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#C14");
5416 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#C15");
5417 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#C16");
5418 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#C17");
5419 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#C18");
5420 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#C19");
5421 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#C20");
5422 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#C21");
5423 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#C22");
5424 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#C23");
5425 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#C24");
5426 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#C25");
5427 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#C26");
5428 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#C27");
5429 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#C28");
5430 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#C29");
5431 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#C30");
5432 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#C31");
5433 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#C32");
5434 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#C33");
5435 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#C34");
5436 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#C35");
5437 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#C36");
5439 flags = BindingFlags.Static | BindingFlags.NonPublic;
5441 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#D1");
5442 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#D2");
5443 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#D3");
5444 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#D4");
5445 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#D5");
5446 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#D6");
5447 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#D7");
5448 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#D8");
5449 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#D9");
5450 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#D10");
5451 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#D11");
5452 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#D12");
5453 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#D13");
5454 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#D14");
5455 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#D15");
5456 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#D16");
5457 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#D17");
5458 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#D18");
5459 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#D19");
5460 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#D20");
5461 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#D21");
5462 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#D22");
5463 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#D23");
5464 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#D24");
5465 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#D25");
5466 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#D26");
5467 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#D27");
5468 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#D28");
5469 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#D29");
5470 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#D30");
5471 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#D31");
5472 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#D32");
5473 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#D33");
5474 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#D34");
5475 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#D35");
5476 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#D36");
5478 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5479 BindingFlags.FlattenHierarchy;
5481 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#E1");
5482 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#E2");
5483 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#E3");
5484 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#E4");
5485 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#E5");
5486 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#E6");
5487 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#E7");
5488 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#E8");
5489 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#E9");
5490 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#E10");
5491 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#E11");
5492 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#E12");
5493 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#E13");
5494 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#E14");
5495 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#E15");
5496 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#E16");
5497 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#E17");
5498 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#E18");
5499 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#E19");
5500 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#E20");
5501 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#E21");
5502 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#E22");
5503 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#E23");
5504 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#E24");
5505 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#E25");
5506 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#E26");
5507 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#E27");
5508 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#E28");
5509 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#E29");
5510 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#E30");
5511 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#E31");
5512 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#E32");
5513 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#E33");
5514 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#E34");
5515 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#E35");
5516 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#E36");
5518 flags = BindingFlags.Instance | BindingFlags.Public |
5519 BindingFlags.FlattenHierarchy;
5521 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#F1");
5522 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#F2");
5523 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#F3");
5524 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#F4");
5525 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#F5");
5526 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#F6");
5527 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#F7");
5528 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#F8");
5529 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#F9");
5530 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#F10");
5531 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#F11");
5532 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#F12");
5533 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#F13");
5534 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#F14");
5535 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#F15");
5536 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#F16");
5537 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#F17");
5538 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#F18");
5539 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#F19");
5540 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#F20");
5541 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#F21");
5542 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#F22");
5543 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#F23");
5544 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#F24");
5545 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#F25");
5546 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#F26");
5547 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#F27");
5548 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#F28");
5549 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#F29");
5550 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#F30");
5551 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#F31");
5552 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#F32");
5553 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#F33");
5554 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#F34");
5555 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#F35");
5556 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#F36");
5558 flags = BindingFlags.Static | BindingFlags.Public |
5559 BindingFlags.FlattenHierarchy;
5561 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#G1");
5562 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#G2");
5563 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#G3");
5564 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#G4");
5565 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#G5");
5566 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#G6");
5567 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#G7");
5568 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#G8");
5569 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#G9");
5570 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#G10");
5571 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#G11");
5572 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#G12");
5573 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#G13");
5574 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#G14");
5575 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#G15");
5576 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#G16");
5577 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#G17");
5578 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#G18");
5579 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#G19");
5580 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#G20");
5581 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#G21");
5582 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#G22");
5583 Assert.IsNotNull (greenType.GetField ("publicStaticBlue", flags), "#G23");
5584 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#G24");
5585 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#G25");
5586 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#G26");
5587 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#G27");
5588 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#G28");
5589 Assert.IsNotNull (greenType.GetField ("publicStaticRed", flags), "#G29");
5590 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#G30");
5591 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#G31");
5592 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#G32");
5593 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#G33");
5594 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#G34");
5595 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#G35");
5596 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#G36");
5598 flags = BindingFlags.Static | BindingFlags.NonPublic |
5599 BindingFlags.FlattenHierarchy;
5601 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#H1");
5602 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#H2");
5603 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#H3");
5604 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#H4");
5605 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#H5");
5606 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#H6");
5607 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#H7");
5608 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#H8");
5609 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#H9");
5610 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#H10");
5611 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#H11");
5612 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#H12");
5613 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#H13");
5614 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#H14");
5615 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#H15");
5616 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#H16");
5617 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#H17");
5618 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#H18");
5619 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#H19");
5620 Assert.IsNotNull (greenType.GetField ("familyStaticBlue", flags), "#H20");
5621 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#H21");
5622 Assert.IsNotNull (greenType.GetField ("famORAssemStaticBlue", flags), "#H22");
5623 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#H23");
5624 Assert.IsNotNull (greenType.GetField ("assemblyStaticBlue", flags), "#H24");
5625 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#H25");
5626 Assert.IsNotNull (greenType.GetField ("familyStaticRed", flags), "#H26");
5627 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticRed", flags), "#H27");
5628 Assert.IsNotNull (greenType.GetField ("famORAssemStaticRed", flags), "#H28");
5629 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#H29");
5630 Assert.IsNotNull (greenType.GetField ("assemblyStaticRed", flags), "#H30");
5631 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#H31");
5632 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#H32");
5633 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#H33");
5634 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#H34");
5635 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#H35");
5636 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#H36");
5638 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5639 BindingFlags.DeclaredOnly;
5641 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#I1");
5642 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#I2");
5643 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#I3");
5644 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#I4");
5645 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#I5");
5646 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#I6");
5647 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#I7");
5648 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#I8");
5649 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#I9");
5650 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#I10");
5651 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#I11");
5652 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#I12");
5653 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#I13");
5654 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#I14");
5655 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#I15");
5656 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#I16");
5657 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#I17");
5658 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#I18");
5659 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#I19");
5660 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#I20");
5661 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#I21");
5662 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#I22");
5663 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#I23");
5664 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#I24");
5665 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#I25");
5666 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#I26");
5667 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#I27");
5668 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#I28");
5669 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#I29");
5670 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#I30");
5671 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#I31");
5672 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#I32");
5673 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#I33");
5674 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#I34");
5675 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#I35");
5676 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#I36");
5678 flags = BindingFlags.Instance | BindingFlags.Public |
5679 BindingFlags.DeclaredOnly;
5681 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#J1");
5682 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#J2");
5683 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#J3");
5684 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#J4");
5685 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#J5");
5686 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#J6");
5687 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#J7");
5688 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#J8");
5689 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#J9");
5690 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#J10");
5691 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#J11");
5692 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#J12");
5693 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#J13");
5694 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#J14");
5695 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#J15");
5696 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#J16");
5697 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#J17");
5698 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#J18");
5699 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#J19");
5700 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#J20");
5701 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#J21");
5702 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#J22");
5703 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#J23");
5704 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#J24");
5705 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#J25");
5706 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#J26");
5707 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#J27");
5708 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#J28");
5709 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#J29");
5710 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#J30");
5711 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#J31");
5712 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#J32");
5713 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#J33");
5714 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#J34");
5715 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#J35");
5716 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#J36");
5718 flags = BindingFlags.Static | BindingFlags.Public |
5719 BindingFlags.DeclaredOnly;
5721 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#K1");
5722 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#K2");
5723 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#K3");
5724 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#K4");
5725 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#K5");
5726 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#K6");
5727 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#K7");
5728 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#K8");
5729 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#K9");
5730 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#K10");
5731 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#K11");
5732 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#K12");
5733 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#K13");
5734 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#K14");
5735 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#K15");
5736 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#K16");
5737 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#K17");
5738 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#K18");
5739 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#K19");
5740 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#K20");
5741 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#K21");
5742 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#K22");
5743 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#K23");
5744 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#K24");
5745 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#K25");
5746 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#K26");
5747 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#K27");
5748 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#K28");
5749 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#K29");
5750 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#K30");
5751 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#K31");
5752 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#K32");
5753 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#K33");
5754 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#K34");
5755 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#K35");
5756 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#K36");
5758 flags = BindingFlags.Static | BindingFlags.NonPublic |
5759 BindingFlags.DeclaredOnly;
5761 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#L1");
5762 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#L2");
5763 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#L3");
5764 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#L4");
5765 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#L5");
5766 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#L6");
5767 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#L7");
5768 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#L8");
5769 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#L9");
5770 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#L10");
5771 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#L11");
5772 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#L12");
5773 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#L13");
5774 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#L14");
5775 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#L15");
5776 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#L16");
5777 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#L17");
5778 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#L18");
5779 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#L19");
5780 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#L20");
5781 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#L21");
5782 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#L22");
5783 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#L23");
5784 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#L24");
5785 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#L25");
5786 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#L26");
5787 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#L27");
5788 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#L28");
5789 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#L29");
5790 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#L30");
5791 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#L31");
5792 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#L32");
5793 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#L33");
5794 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#L34");
5795 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#L35");
5796 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#L36");
5798 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5799 BindingFlags.Public;
5801 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#M1");
5802 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#M2");
5803 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#M3");
5804 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#M4");
5805 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#M5");
5806 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#M6");
5807 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#M7");
5808 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#M8");
5809 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#M9");
5810 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#M10");
5811 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#M11");
5812 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#M12");
5813 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#M13");
5814 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#M14");
5815 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#M15");
5816 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#M16");
5817 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#M17");
5818 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#M18");
5819 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#M19");
5820 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#M20");
5821 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#M21");
5822 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#M22");
5823 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#M23");
5824 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#M24");
5825 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#M25");
5826 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#M26");
5827 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#M27");
5828 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#M28");
5829 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#M29");
5830 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#M30");
5831 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#M31");
5832 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#M32");
5833 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#M33");
5834 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#M34");
5835 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#M35");
5836 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#M36");
5838 flags = BindingFlags.Static | BindingFlags.NonPublic |
5839 BindingFlags.Public;
5841 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#N1");
5842 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#N2");
5843 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#N3");
5844 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#N4");
5845 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#N5");
5846 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#N6");
5847 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#N7");
5848 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#N8");
5849 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#N9");
5850 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#N10");
5851 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#N11");
5852 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#N12");
5853 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#N13");
5854 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#N14");
5855 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#N15");
5856 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#N16");
5857 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#N17");
5858 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#N18");
5859 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#N19");
5860 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#N20");
5861 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#N21");
5862 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#N22");
5863 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#N23");
5864 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#N24");
5865 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#N25");
5866 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#N26");
5867 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#N27");
5868 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#N28");
5869 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#N29");
5870 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#N30");
5871 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#N31");
5872 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#N32");
5873 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#N33");
5874 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#N34");
5875 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#N35");
5876 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#N36");
5880 [Category ("NotDotNet")] // mcs depends on this
5881 public void TestGetPropertiesIncomplete_Mono ()
5883 TypeBuilder tb = module.DefineType (genTypeName ());
5884 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5885 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5886 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5888 PropertyInfo [] properties = tb.GetProperties ();
5889 Assert.AreEqual (2, properties.Length, "#1");
5890 Assert.AreEqual ("Name", properties [0].Name, "#2");
5891 Assert.AreEqual ("FirstName", properties [1].Name, "#3");
5895 [Category ("NotWorking")] // mcs depends on this
5896 public void TestGetPropertiesIncomplete_MS ()
5898 TypeBuilder tb = module.DefineType (genTypeName ());
5899 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5900 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5901 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5904 tb.GetProperties ();
5906 } catch (NotSupportedException ex) {
5907 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5908 Assert.IsNull (ex.InnerException, "#3");
5909 Assert.IsNotNull (ex.Message, "#4");
5914 public void TestGetPropertiesComplete ()
5916 TypeBuilder tb = module.DefineType (genTypeName ());
5917 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
5919 Type emittedType = tb.CreateType ();
5921 Assert.AreEqual (1, tb.GetProperties ().Length);
5922 Assert.AreEqual (tb.GetProperties ().Length, emittedType.GetProperties ().Length);
5926 [Category ("NotDotNet")] // mcs depends on this
5927 public void TestGetPropertiesFlagsIncomplete_Mono ()
5929 PropertyInfo [] properties;
5931 TypeBuilder tb = module.DefineType (genTypeName ());
5932 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5933 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5934 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5936 properties = tb.GetProperties (BindingFlags.Public |
5937 BindingFlags.NonPublic | BindingFlags.Instance);
5938 Assert.AreEqual (3, properties.Length, "#A1");
5939 Assert.AreEqual ("Name", properties [0].Name, "#A2");
5940 Assert.AreEqual ("Income", properties [1].Name, "#A3");
5941 Assert.AreEqual ("FirstName", properties [2].Name, "#A4");
5943 properties = tb.GetProperties (BindingFlags.Public |
5944 BindingFlags.Instance);
5945 Assert.AreEqual (2, properties.Length, "#B1");
5946 Assert.AreEqual ("Name", properties [0].Name, "#B2");
5947 Assert.AreEqual ("FirstName", properties [1].Name, "#B3");
5949 properties = tb.GetProperties (BindingFlags.NonPublic |
5950 BindingFlags.Instance);
5951 Assert.AreEqual (1, properties.Length, "#C1");
5952 Assert.AreEqual ("Income", properties [0].Name, "#C2");
5956 [Category ("NotWorking")] // mcs depends on this
5957 public void TestGetPropertiesFlagsIncomplete_MS ()
5959 TypeBuilder tb = module.DefineType (genTypeName ());
5960 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5961 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5962 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5965 tb.GetProperties (BindingFlags.Public);
5967 } catch (NotSupportedException ex) {
5968 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5969 Assert.IsNull (ex.InnerException, "#3");
5970 Assert.IsNotNull (ex.Message, "#4");
5975 public void TestGetPropertiesFlagsComplete ()
5977 TypeBuilder tb = module.DefineType (genTypeName ());
5978 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
5980 Type emittedType = tb.CreateType ();
5982 Assert.AreEqual (1, tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
5983 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length,
5984 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
5985 Assert.AreEqual (0, tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
5986 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length,
5987 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
5991 public void TestGetPropertiesFlagsComplete_Inheritance ()
5993 PropertyInfo [] props;
5996 TypeBuilder blueType = module.DefineType (genTypeName (),
5997 TypeAttributes.Public);
5998 CreateMembers (blueType, "Blue", false);
6000 TypeBuilder redType = module.DefineType (genTypeName (),
6001 TypeAttributes.Public, blueType);
6002 CreateMembers (redType, "Red", false);
6004 TypeBuilder greenType = module.DefineType (genTypeName (),
6005 TypeAttributes.Public, redType);
6006 CreateMembers (greenType, "Green", false);
6008 blueType.CreateType ();
6009 redType.CreateType ();
6010 greenType.CreateType ();
6012 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6013 props = greenType.GetProperties (flags);
6015 Assert.AreEqual (13, props.Length, "#A1");
6016 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#A2");
6017 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#A3");
6018 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#A4");
6019 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#A5");
6020 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#A6");
6021 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#A7");
6022 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#A8");
6023 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#A9");
6024 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#A10");
6025 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#A11");
6026 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#A12");
6027 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#A13");
6028 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#A15");
6030 flags = BindingFlags.Instance | BindingFlags.Public;
6031 props = greenType.GetProperties (flags);
6033 Assert.AreEqual (3, props.Length, "#B1");
6034 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#B2");
6035 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#B3");
6036 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#B4");
6038 flags = BindingFlags.Static | BindingFlags.Public;
6039 props = greenType.GetProperties (flags);
6041 Assert.AreEqual (1, props.Length, "#C1");
6042 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#C2");
6044 flags = BindingFlags.Static | BindingFlags.NonPublic;
6045 props = greenType.GetProperties (flags);
6047 Assert.AreEqual (5, props.Length, "#D1");
6048 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#D2");
6049 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#D3");
6050 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#D4");
6051 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#D5");
6052 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#D6");
6054 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6055 BindingFlags.FlattenHierarchy;
6056 props = greenType.GetProperties (flags);
6058 Assert.AreEqual (13, props.Length, "#E1");
6059 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#E2");
6060 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#E3");
6061 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#E4");
6062 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#E5");
6063 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#E6");
6064 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#E7");
6065 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#E8");
6066 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#E9");
6067 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#E10");
6068 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#E11");
6069 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#E12");
6070 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#E13");
6071 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#E14");
6073 flags = BindingFlags.Instance | BindingFlags.Public |
6074 BindingFlags.FlattenHierarchy;
6075 props = greenType.GetProperties (flags);
6077 Assert.AreEqual (3, props.Length, "#F1");
6078 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#F2");
6079 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#F3");
6080 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#F4");
6082 flags = BindingFlags.Static | BindingFlags.Public |
6083 BindingFlags.FlattenHierarchy;
6084 props = greenType.GetProperties (flags);
6086 Assert.AreEqual (3, props.Length, "#G1");
6087 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#G2");
6088 Assert.AreEqual ("PublicStaticRed", props [1].Name, "#G3");
6089 Assert.AreEqual ("PublicStaticBlue", props [2].Name, "#G4");
6091 flags = BindingFlags.Static | BindingFlags.NonPublic |
6092 BindingFlags.FlattenHierarchy;
6093 props = greenType.GetProperties (flags);
6095 Assert.AreEqual (13, props.Length, "#H1");
6096 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#H2");
6097 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#H3");
6098 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#H4");
6099 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#H5");
6100 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#H6");
6101 Assert.AreEqual ("FamilyStaticRed", props [5].Name, "#H7");
6102 Assert.AreEqual ("FamANDAssemStaticRed", props [6].Name, "#H8");
6103 Assert.AreEqual ("FamORAssemStaticRed", props [7].Name, "#H9");
6104 Assert.AreEqual ("AssemblyStaticRed", props [8].Name, "#H10");
6105 Assert.AreEqual ("FamilyStaticBlue", props [9].Name, "#H11");
6106 Assert.AreEqual ("FamANDAssemStaticBlue", props [10].Name, "#H12");
6107 Assert.AreEqual ("FamORAssemStaticBlue", props [11].Name, "#H13");
6108 Assert.AreEqual ("AssemblyStaticBlue", props [12].Name, "#H14");
6110 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6111 BindingFlags.DeclaredOnly;
6112 props = greenType.GetProperties (flags);
6114 Assert.AreEqual (5, props.Length, "#I1");
6115 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#I2");
6116 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#I3");
6117 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#I4");
6118 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#I5");
6119 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#I6");
6121 flags = BindingFlags.Instance | BindingFlags.Public |
6122 BindingFlags.DeclaredOnly;
6123 props = greenType.GetProperties (flags);
6125 Assert.AreEqual (1, props.Length, "#J1");
6126 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#J2");
6128 flags = BindingFlags.Static | BindingFlags.Public |
6129 BindingFlags.DeclaredOnly;
6130 props = greenType.GetProperties (flags);
6132 Assert.AreEqual (1, props.Length, "#K1");
6133 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#K2");
6135 flags = BindingFlags.Static | BindingFlags.NonPublic |
6136 BindingFlags.DeclaredOnly;
6137 props = greenType.GetProperties (flags);
6139 Assert.AreEqual (5, props.Length, "#L1");
6140 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#L2");
6141 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#L3");
6142 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#L4");
6143 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#L5");
6144 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#L6");
6146 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6147 BindingFlags.Public;
6148 props = greenType.GetProperties (flags);
6150 Assert.AreEqual (16, props.Length, "#M1");
6151 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#M2");
6152 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#M3");
6153 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#M4");
6154 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#M5");
6155 Assert.AreEqual ("PublicInstanceGreen", props [4].Name, "#M6");
6156 Assert.AreEqual ("AssemblyInstanceGreen", props [5].Name, "#M7");
6157 Assert.AreEqual ("FamilyInstanceRed", props [6].Name, "#M8");
6158 Assert.AreEqual ("FamANDAssemInstanceRed", props [7].Name, "#M9");
6159 Assert.AreEqual ("FamORAssemInstanceRed", props [8].Name, "#M10");
6160 Assert.AreEqual ("PublicInstanceRed", props [9].Name, "#M11");
6161 Assert.AreEqual ("AssemblyInstanceRed", props [10].Name, "#M12");
6162 Assert.AreEqual ("FamilyInstanceBlue", props [11].Name, "#M13");
6163 Assert.AreEqual ("FamANDAssemInstanceBlue", props [12].Name, "#M14");
6164 Assert.AreEqual ("FamORAssemInstanceBlue", props [13].Name, "#M15");
6165 Assert.AreEqual ("PublicInstanceBlue", props [14].Name, "#M16");
6166 Assert.AreEqual ("AssemblyInstanceBlue", props [15].Name, "#M17");
6168 flags = BindingFlags.Static | BindingFlags.NonPublic |
6169 BindingFlags.Public;
6170 props = greenType.GetProperties (flags);
6172 Assert.AreEqual (6, props.Length, "#N1");
6173 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#N2");
6174 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#N3");
6175 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#N4");
6176 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#N5");
6177 Assert.AreEqual ("PublicStaticGreen", props [4].Name, "#N6");
6178 Assert.AreEqual ("AssemblyStaticGreen", props [5].Name, "#N7");
6182 public void TestGetPropertyIncomplete ()
6184 TypeBuilder tb = module.DefineType (genTypeName ());
6186 tb.GetProperty ("test");
6188 } catch (NotSupportedException ex) {
6189 // The invoked member is not supported in a
6191 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6192 Assert.IsNull (ex.InnerException, "#3");
6193 Assert.IsNotNull (ex.Message, "#4");
6198 public void TestGetPropertyComplete ()
6200 TypeBuilder tb = module.DefineType (genTypeName ());
6201 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6203 Type emittedType = tb.CreateType ();
6205 Assert.IsNotNull (emittedType.GetProperty ("CustomerName"));
6206 Assert.IsNull (emittedType.GetProperty ("OtherCustomerName"));
6209 tb.GetProperty ("CustomerName");
6211 } catch (NotSupportedException ex) {
6212 // The invoked member is not supported in a
6214 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6215 Assert.IsNull (ex.InnerException, "#3");
6216 Assert.IsNotNull (ex.Message, "#4");
6221 public void TestGetPropertyFlagsIncomplete ()
6223 TypeBuilder tb = module.DefineType (genTypeName ());
6225 tb.GetProperty ("test", BindingFlags.Public);
6227 } catch (NotSupportedException ex) {
6228 // The invoked member is not supported in a
6230 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6231 Assert.IsNull (ex.InnerException, "#3");
6232 Assert.IsNotNull (ex.Message, "#4");
6237 public void TestGetPropertyFlagsComplete ()
6239 TypeBuilder tb = module.DefineType (genTypeName ());
6240 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6242 Type emittedType = tb.CreateType ();
6244 Assert.IsNotNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6245 BindingFlags.Public));
6246 Assert.IsNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6247 BindingFlags.NonPublic));
6250 tb.GetProperty ("CustomerName", BindingFlags.Instance | BindingFlags.Public);
6252 } catch (NotSupportedException ex) {
6253 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6254 Assert.IsNull (ex.InnerException, "#3");
6255 Assert.IsNotNull (ex.Message, "#4");
6260 public void TestGetMethodFlagsComplete ()
6264 TypeBuilder blueType = module.DefineType (genTypeName (),
6265 TypeAttributes.Public);
6266 CreateMembers (blueType, "Blue", false);
6268 TypeBuilder redType = module.DefineType (genTypeName (),
6269 TypeAttributes.Public, blueType);
6270 CreateMembers (redType, "Red", false);
6272 TypeBuilder greenType = module.DefineType (genTypeName (),
6273 TypeAttributes.Public, redType);
6274 CreateMembers (greenType, "Green", false);
6276 blueType.CreateType ();
6277 redType.CreateType ();
6278 greenType.CreateType ();
6280 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6282 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#A1");
6283 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#A2");
6284 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#A3");
6285 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#A4");
6286 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#A5");
6287 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#A6");
6288 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#A7");
6289 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#A8");
6290 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#A9");
6291 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#A10");
6292 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#A11");
6293 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#A12");
6294 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#A13");
6295 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#A14");
6296 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#A15");
6297 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#A16");
6298 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#A17");
6299 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#A18");
6300 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#A19");
6301 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#A20");
6302 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#A21");
6303 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#A22");
6304 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#A23");
6305 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#A24");
6306 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#A25");
6307 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#A26");
6308 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#A27");
6309 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#A28");
6310 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#A29");
6311 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#A30");
6312 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#A31");
6313 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#A32");
6314 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#A33");
6315 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#A34");
6316 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#A35");
6317 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#A36");
6319 flags = BindingFlags.Instance | BindingFlags.Public;
6321 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#B1");
6322 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#B2");
6323 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#B3");
6324 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#B4");
6325 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#B5");
6326 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#B6");
6327 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#B7");
6328 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#B8");
6329 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#B9");
6330 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#B10");
6331 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#B11");
6332 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#B12");
6333 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#B13");
6334 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#B14");
6335 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#B15");
6336 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#B16");
6337 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#B17");
6338 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#B18");
6339 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#B19");
6340 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#B20");
6341 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#B21");
6342 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#B22");
6343 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#B23");
6344 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#B24");
6345 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#B25");
6346 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#B26");
6347 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#B27");
6348 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#B28");
6349 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#B29");
6350 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#B30");
6351 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#B31");
6352 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#B32");
6353 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#B33");
6354 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#B34");
6355 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#B35");
6356 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#B36");
6358 flags = BindingFlags.Static | BindingFlags.Public;
6360 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#C1");
6361 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#C2");
6362 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#C3");
6363 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#C4");
6364 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#C5");
6365 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#C6");
6366 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#C7");
6367 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#C8");
6368 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#C9");
6369 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#C10");
6370 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#C11");
6371 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#C12");
6372 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#C13");
6373 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#C14");
6374 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#C15");
6375 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#C16");
6376 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#C17");
6377 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#C18");
6378 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#C19");
6379 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#C20");
6380 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#C21");
6381 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#C22");
6382 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#C23");
6383 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#C24");
6384 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#C25");
6385 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#C26");
6386 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#C27");
6387 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#C28");
6388 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#C29");
6389 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#C30");
6390 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#C31");
6391 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#C32");
6392 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#C33");
6393 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#C34");
6394 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#C35");
6395 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#C36");
6397 flags = BindingFlags.Static | BindingFlags.NonPublic;
6399 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#D1");
6400 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#D2");
6401 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#D3");
6402 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#D4");
6403 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#D5");
6404 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#D6");
6405 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#D7");
6406 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#D8");
6407 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#D9");
6408 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#D10");
6409 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#D11");
6410 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#D12");
6411 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#D13");
6412 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#D14");
6413 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#D15");
6414 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#D16");
6415 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#D17");
6416 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#D18");
6417 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#D19");
6418 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#D20");
6419 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#D21");
6420 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#D22");
6421 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#D23");
6422 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#D24");
6423 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#D25");
6424 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#D26");
6425 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#D27");
6426 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#D28");
6427 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#D29");
6428 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#D30");
6429 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#D31");
6430 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#D32");
6431 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#D33");
6432 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#D34");
6433 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#D35");
6434 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#D36");
6436 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6437 BindingFlags.FlattenHierarchy;
6439 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#E1");
6440 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#E2");
6441 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#E3");
6442 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#E4");
6443 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#E5");
6444 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#E6");
6445 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#E7");
6446 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#E8");
6447 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#E9");
6448 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#E10");
6449 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#E11");
6450 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#E12");
6451 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#E13");
6452 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#E14");
6453 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#E15");
6454 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#E16");
6455 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#E17");
6456 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#E18");
6457 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#E19");
6458 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#E20");
6459 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#E21");
6460 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#E22");
6461 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#E23");
6462 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#E24");
6463 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#E25");
6464 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#E26");
6465 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#E27");
6466 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#E28");
6467 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#E29");
6468 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#E30");
6469 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#E31");
6470 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#E32");
6471 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#E33");
6472 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#E34");
6473 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#E35");
6474 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#E36");
6476 flags = BindingFlags.Instance | BindingFlags.Public |
6477 BindingFlags.FlattenHierarchy;
6479 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#F1");
6480 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#F2");
6481 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#F3");
6482 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#F4");
6483 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#F5");
6484 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#F6");
6485 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#F7");
6486 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#F8");
6487 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#F9");
6488 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#F10");
6489 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#F11");
6490 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#F12");
6491 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#F13");
6492 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#F14");
6493 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#F15");
6494 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#F16");
6495 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#F17");
6496 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#F18");
6497 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#F19");
6498 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#F20");
6499 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#F21");
6500 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#F22");
6501 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#F23");
6502 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#F24");
6503 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#F25");
6504 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#F26");
6505 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#F27");
6506 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#F28");
6507 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#F29");
6508 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#F30");
6509 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#F31");
6510 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#F32");
6511 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#F33");
6512 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#F34");
6513 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#F35");
6514 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#F36");
6516 flags = BindingFlags.Static | BindingFlags.Public |
6517 BindingFlags.FlattenHierarchy;
6519 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#G1");
6520 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#G2");
6521 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#G3");
6522 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#G4");
6523 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#G5");
6524 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#G6");
6525 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#G7");
6526 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#G8");
6527 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#G9");
6528 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#G10");
6529 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#G11");
6530 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#G12");
6531 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#G13");
6532 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#G14");
6533 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#G15");
6534 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#G16");
6535 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#G17");
6536 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#G18");
6537 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#G19");
6538 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#G20");
6539 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#G21");
6540 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#G22");
6541 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#G23");
6542 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#G24");
6543 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#G25");
6544 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#G26");
6545 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#G27");
6546 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#G28");
6547 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#G29");
6548 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#G30");
6549 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#G31");
6550 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#G32");
6551 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#G33");
6552 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#G34");
6553 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#G35");
6554 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#G36");
6556 flags = BindingFlags.Static | BindingFlags.NonPublic |
6557 BindingFlags.FlattenHierarchy;
6559 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#H1");
6560 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#H2");
6561 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#H3");
6562 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#H4");
6563 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#H5");
6564 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#H6");
6565 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#H7");
6566 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#H8");
6567 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#H9");
6568 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#H10");
6569 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#H11");
6570 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#H12");
6571 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#H13");
6572 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#H14");
6573 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#H15");
6574 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#H16");
6575 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#H17");
6576 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#H18");
6577 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#H19");
6578 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#H20");
6579 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#H21");
6580 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#H22");
6581 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#H23");
6582 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#H24");
6583 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#H25");
6584 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#H26");
6585 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#H27");
6586 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#H28");
6587 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#H29");
6588 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#H30");
6589 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#H31");
6590 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#H32");
6591 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#H33");
6592 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#H34");
6593 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#H35");
6594 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#H36");
6596 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6597 BindingFlags.DeclaredOnly;
6599 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#I1");
6600 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#I2");
6601 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#I3");
6602 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#I4");
6603 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#I5");
6604 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#I6");
6605 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#I7");
6606 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#I8");
6607 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#I9");
6608 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#I10");
6609 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#I11");
6610 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#I12");
6611 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#I13");
6612 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#I14");
6613 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#I15");
6614 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#I16");
6615 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#I17");
6616 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#I18");
6617 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#I19");
6618 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#I20");
6619 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#I21");
6620 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#I22");
6621 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#I23");
6622 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#I24");
6623 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#I25");
6624 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#I26");
6625 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#I27");
6626 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#I28");
6627 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#I29");
6628 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#I30");
6629 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#I31");
6630 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#I32");
6631 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#I33");
6632 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#I34");
6633 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#I35");
6634 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#I36");
6636 flags = BindingFlags.Instance | BindingFlags.Public |
6637 BindingFlags.DeclaredOnly;
6639 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#J1");
6640 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#J2");
6641 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#J3");
6642 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#J4");
6643 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#J5");
6644 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#J6");
6645 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#J7");
6646 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#J8");
6647 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#J9");
6648 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#J10");
6649 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#J11");
6650 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#J12");
6651 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#J13");
6652 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#J14");
6653 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#J15");
6654 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#J16");
6655 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#J17");
6656 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#J18");
6657 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#J19");
6658 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#J20");
6659 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#J21");
6660 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#J22");
6661 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#J23");
6662 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#J24");
6663 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#J25");
6664 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#J26");
6665 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#J27");
6666 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#J28");
6667 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#J29");
6668 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#J30");
6669 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#J31");
6670 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#J32");
6671 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#J33");
6672 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#J34");
6673 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#J35");
6674 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#J36");
6676 flags = BindingFlags.Static | BindingFlags.Public |
6677 BindingFlags.DeclaredOnly;
6679 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#K1");
6680 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#K2");
6681 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#K3");
6682 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#K4");
6683 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#K5");
6684 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#K6");
6685 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#K7");
6686 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#K8");
6687 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#K9");
6688 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#K10");
6689 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#K11");
6690 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#K12");
6691 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#K13");
6692 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#K14");
6693 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#K15");
6694 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#K16");
6695 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#K17");
6696 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#K18");
6697 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#K19");
6698 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#K20");
6699 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#K21");
6700 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#K22");
6701 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#K23");
6702 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#K24");
6703 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#K25");
6704 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#K26");
6705 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#K27");
6706 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#K28");
6707 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#K29");
6708 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#K30");
6709 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#K31");
6710 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#K32");
6711 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#K33");
6712 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#K34");
6713 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#K35");
6714 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#K36");
6716 flags = BindingFlags.Static | BindingFlags.NonPublic |
6717 BindingFlags.DeclaredOnly;
6719 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#L1");
6720 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#L2");
6721 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#L3");
6722 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#L4");
6723 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#L5");
6724 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#L6");
6725 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#L7");
6726 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#L8");
6727 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#L9");
6728 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#L10");
6729 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#L11");
6730 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#L12");
6731 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#L13");
6732 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#L14");
6733 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#L15");
6734 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#L16");
6735 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#L17");
6736 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#L18");
6737 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#L19");
6738 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#L20");
6739 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#L21");
6740 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#L22");
6741 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#L23");
6742 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#L24");
6743 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#L25");
6744 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#L26");
6745 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#L27");
6746 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#L28");
6747 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#L29");
6748 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#L30");
6749 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#L31");
6750 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#L32");
6751 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#L33");
6752 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#L34");
6753 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#L35");
6754 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#L36");
6756 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6757 BindingFlags.Public;
6759 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#M1");
6760 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#M2");
6761 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#M3");
6762 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#M4");
6763 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#M5");
6764 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#M6");
6765 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#M7");
6766 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#M8");
6767 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#M9");
6768 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#M10");
6769 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#M11");
6770 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#M12");
6771 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#M13");
6772 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#M14");
6773 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#M15");
6774 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#M16");
6775 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#M17");
6776 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#M18");
6777 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#M19");
6778 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#M20");
6779 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#M21");
6780 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#M22");
6781 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#M23");
6782 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#M24");
6783 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#M25");
6784 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#M26");
6785 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#M27");
6786 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#M28");
6787 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#M29");
6788 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#M30");
6789 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#M31");
6790 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#M32");
6791 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#M33");
6792 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#M34");
6793 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#M35");
6794 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#M36");
6796 flags = BindingFlags.Static | BindingFlags.NonPublic |
6797 BindingFlags.Public;
6799 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#N1");
6800 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#N2");
6801 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#N3");
6802 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#N4");
6803 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#N5");
6804 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#N6");
6805 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#N7");
6806 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#N8");
6807 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#N9");
6808 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#N10");
6809 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#N11");
6810 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#N12");
6811 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#N13");
6812 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#N14");
6813 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#N15");
6814 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#N16");
6815 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#N17");
6816 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#N18");
6817 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#N19");
6818 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#N20");
6819 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#N21");
6820 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#N22");
6821 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#N23");
6822 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#N24");
6823 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#N25");
6824 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#N26");
6825 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#N27");
6826 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#N28");
6827 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#N29");
6828 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#N30");
6829 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#N31");
6830 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#N32");
6831 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#N33");
6832 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#N34");
6833 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#N35");
6834 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#N36");
6838 [Category ("NotDotNet")] // mcs depends on this
6839 public void TestGetMethodsIncomplete_Mono ()
6844 TypeBuilder tb = module.DefineType (genTypeName (),
6845 TypeAttributes.Abstract);
6846 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6847 typeof (void), Type.EmptyTypes);
6848 ilgen = mb.GetILGenerator ();
6849 ilgen.Emit (OpCodes.Ret);
6851 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6852 typeof (void), Type.EmptyTypes);
6853 ilgen = mb.GetILGenerator ();
6854 ilgen.Emit (OpCodes.Ret);
6856 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6857 MethodAttributes.Static,
6858 typeof (void), Type.EmptyTypes);
6859 ilgen = mb.GetILGenerator ();
6860 ilgen.Emit (OpCodes.Ret);
6862 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6863 MethodAttributes.Abstract | MethodAttributes.Virtual,
6864 typeof (void), Type.EmptyTypes);
6866 MethodInfo [] methods = tb.GetMethods ();
6867 Assert.AreEqual (7, methods.Length, "#A");
6869 Assert.AreEqual ("Equals", methods [0].Name, "#B1");
6870 Assert.IsFalse (methods [0].IsStatic, "#B2");
6871 Assert.IsFalse (methods [0].IsAbstract, "#B3");
6873 Assert.AreEqual ("GetHashCode", methods [1].Name, "#C1");
6874 Assert.IsFalse (methods [1].IsStatic, "#C2");
6875 Assert.IsFalse (methods [1].IsAbstract, "#C3");
6877 Assert.AreEqual ("GetType", methods [2].Name, "#D1");
6878 Assert.IsFalse (methods [2].IsStatic, "#D2");
6879 Assert.IsFalse (methods [2].IsAbstract, "#D3");
6881 Assert.AreEqual ("ToString", methods [3].Name, "#E1");
6882 Assert.IsFalse (methods [3].IsStatic, "#E2");
6883 Assert.IsFalse (methods [3].IsAbstract, "#E3");
6885 Assert.AreEqual ("Hello", methods [4].Name, "#F1");
6886 Assert.IsFalse (methods [4].IsStatic, "#F2");
6887 Assert.IsFalse (methods [4].IsAbstract, "#F3");
6889 Assert.AreEqual ("Execute", methods [5].Name, "#G1");
6890 Assert.IsTrue (methods [5].IsStatic, "#G2");
6891 Assert.IsFalse (methods [5].IsAbstract, "#G3");
6893 Assert.AreEqual ("Init", methods [6].Name, "#H1");
6894 Assert.IsFalse (methods [6].IsStatic, "#H2");
6895 Assert.IsTrue (methods [6].IsAbstract, "#H3");
6899 [Category ("NotWorking")] // mcs depends on this
6900 public void TestGetMethodsIncomplete_MS ()
6905 TypeBuilder tb = module.DefineType (genTypeName (),
6906 TypeAttributes.Abstract);
6907 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6908 typeof (void), Type.EmptyTypes);
6909 ilgen = mb.GetILGenerator ();
6910 ilgen.Emit (OpCodes.Ret);
6912 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6913 typeof (void), Type.EmptyTypes);
6914 ilgen = mb.GetILGenerator ();
6915 ilgen.Emit (OpCodes.Ret);
6917 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6918 MethodAttributes.Static,
6919 typeof (void), Type.EmptyTypes);
6920 ilgen = mb.GetILGenerator ();
6921 ilgen.Emit (OpCodes.Ret);
6923 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6924 MethodAttributes.Abstract | MethodAttributes.Virtual,
6925 typeof (void), Type.EmptyTypes);
6930 } catch (NotSupportedException ex) {
6931 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6932 Assert.IsNull (ex.InnerException, "#3");
6933 Assert.IsNotNull (ex.Message, "#4");
6938 public void TestGetMethodsComplete ()
6944 TypeBuilder tb = module.DefineType (genTypeName (),
6945 TypeAttributes.Abstract);
6946 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6947 typeof (string), Type.EmptyTypes);
6948 ilgen = mb.GetILGenerator ();
6949 ilgen.Emit (OpCodes.Ldstr, "Hi! ");
6950 ilgen.Emit (OpCodes.Ldarg_1);
6951 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
6952 new Type [] { typeof (string), typeof (string) });
6953 ilgen.Emit (OpCodes.Call, infoMethod);
6954 ilgen.Emit (OpCodes.Ret);
6956 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6957 typeof (void), Type.EmptyTypes);
6958 ilgen = mb.GetILGenerator ();
6959 ilgen.Emit (OpCodes.Ret);
6961 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6962 MethodAttributes.Static,
6963 typeof (void), Type.EmptyTypes);
6964 ilgen = mb.GetILGenerator ();
6965 ilgen.Emit (OpCodes.Ret);
6967 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6968 MethodAttributes.Abstract | MethodAttributes.Virtual,
6969 typeof (void), Type.EmptyTypes);
6971 Type emittedType = tb.CreateType ();
6973 MethodInfo [] methods = emittedType.GetMethods ();
6974 Assert.AreEqual (7, methods.Length, "#A1");
6975 Assert.AreEqual (7, tb.GetMethods ().Length, "#A2");
6977 mi = GetMethodByName (methods, "Hello");
6978 Assert.IsNotNull (mi, "#B1");
6979 Assert.IsFalse (mi.IsStatic, "#B2");
6980 Assert.IsFalse (mi.IsAbstract, "#B3");
6982 mi = GetMethodByName (methods, "Execute");
6983 Assert.IsNotNull (mi, "#C1");
6984 Assert.IsTrue (mi.IsStatic, "#C2");
6985 Assert.IsFalse (mi.IsAbstract, "#C3");
6987 mi = GetMethodByName (methods, "Init");
6988 Assert.IsNotNull (mi, "#D1");
6989 Assert.IsFalse (mi.IsStatic, "#D2");
6990 Assert.IsTrue (mi.IsAbstract, "#D3");
6992 mi = GetMethodByName (methods, "GetType");
6993 Assert.IsNotNull (mi, "#E1");
6994 Assert.IsFalse (methods [3].IsStatic, "#E2");
6995 Assert.IsFalse (methods [3].IsAbstract, "#E3");
6997 mi = GetMethodByName (methods, "ToString");
6998 Assert.IsNotNull (mi, "#F1");
6999 Assert.IsFalse (mi.IsStatic, "#F2");
7000 Assert.IsFalse (mi.IsAbstract, "#F3");
7002 mi = GetMethodByName (methods, "Equals");
7003 Assert.IsNotNull (mi, "#G1");
7004 Assert.IsFalse (mi.IsStatic, "#G2");
7005 Assert.IsFalse (mi.IsAbstract, "#G3");
7007 mi = GetMethodByName (methods, "GetHashCode");
7008 Assert.IsNotNull (mi, "#H1");
7009 Assert.IsFalse (mi.IsStatic, "#H2");
7010 Assert.IsFalse (mi.IsAbstract, "#H3");
7014 [Category ("NotDotNet")] // mcs depends on this
7015 public void TestGetMethodsFlagsIncomplete_Inheritance ()
7017 MethodInfo [] methods;
7020 TypeBuilder blueType = module.DefineType (genTypeName (),
7021 TypeAttributes.Public);
7022 CreateMembers (blueType, "Blue", false);
7024 TypeBuilder redType = module.DefineType (genTypeName (),
7025 TypeAttributes.Public, blueType);
7026 CreateMembers (redType, "Red", false);
7028 TypeBuilder greenType = module.DefineType (genTypeName (),
7029 TypeAttributes.Public, redType);
7030 CreateMembers (greenType, "Green", false);
7032 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7033 methods = greenType.GetMethods (flags);
7035 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7036 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7037 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7038 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7039 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7040 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7041 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7042 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7043 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7044 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7045 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7046 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7047 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7048 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7049 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7050 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7051 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7052 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7053 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7054 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7055 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7056 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7057 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7058 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7059 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7060 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7061 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7062 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7063 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7064 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7065 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7066 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7067 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7068 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7069 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7070 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7072 flags = BindingFlags.Instance | BindingFlags.Public;
7073 methods = greenType.GetMethods (flags);
7075 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7076 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7077 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7078 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7079 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7080 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7081 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7082 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7083 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7084 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7085 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7086 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7087 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7088 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7089 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7090 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7091 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7092 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7093 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7094 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7095 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7096 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7097 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7098 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7099 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7100 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7101 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7102 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7103 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7104 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7105 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7106 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7107 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7108 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7109 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7110 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7112 flags = BindingFlags.Static | BindingFlags.Public;
7113 methods = greenType.GetMethods (flags);
7115 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7116 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7117 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7118 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7119 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7120 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7121 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7122 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7123 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7124 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7125 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7126 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7127 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7128 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7129 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7130 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7131 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7132 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7133 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7134 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7135 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7136 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7137 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7138 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7139 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7140 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7141 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7142 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7143 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7144 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7145 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7146 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7147 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7148 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7149 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7150 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7152 flags = BindingFlags.Static | BindingFlags.NonPublic;
7153 methods = greenType.GetMethods (flags);
7155 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7156 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7157 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7158 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7159 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7160 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7161 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7162 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7163 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7164 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7165 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7166 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7167 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7168 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7169 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7170 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7171 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7172 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7173 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7174 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7175 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7176 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7177 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7178 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7179 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7180 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7181 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7182 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7183 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7184 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7185 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7186 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7187 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7188 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7189 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7190 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7192 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7193 BindingFlags.FlattenHierarchy;
7194 methods = greenType.GetMethods (flags);
7196 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7197 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7198 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7199 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7200 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7201 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7202 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7203 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7204 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7205 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7206 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7207 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7208 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7209 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7210 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7211 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7212 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7213 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7214 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7215 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7216 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7217 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7218 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7219 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7220 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7221 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7222 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7223 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7224 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7225 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7226 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7227 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7228 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7229 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7230 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7231 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7233 flags = BindingFlags.Instance | BindingFlags.Public |
7234 BindingFlags.FlattenHierarchy;
7235 methods = greenType.GetMethods (flags);
7237 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7238 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7239 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7240 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7241 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7242 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7243 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7244 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7245 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7246 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7247 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7248 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7249 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7250 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7251 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7252 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7253 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
7254 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
7255 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
7256 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
7257 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
7258 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
7259 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
7260 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
7261 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
7262 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
7263 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
7264 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
7265 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
7266 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
7267 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
7268 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
7269 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
7270 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
7271 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
7272 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
7274 flags = BindingFlags.Static | BindingFlags.Public |
7275 BindingFlags.FlattenHierarchy;
7276 methods = greenType.GetMethods (flags);
7278 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
7279 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
7280 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
7281 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
7282 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
7283 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
7284 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
7285 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
7286 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
7287 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
7288 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
7289 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
7290 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
7291 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
7292 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
7293 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
7294 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
7295 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
7296 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
7297 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
7298 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
7299 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
7300 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
7301 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
7302 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
7303 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
7304 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
7305 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
7306 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
7307 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
7308 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
7309 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
7310 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
7311 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
7312 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
7313 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
7315 flags = BindingFlags.Static | BindingFlags.NonPublic |
7316 BindingFlags.FlattenHierarchy;
7317 methods = greenType.GetMethods (flags);
7319 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
7320 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
7321 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
7322 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
7323 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
7324 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
7325 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
7326 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
7327 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
7328 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
7329 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
7330 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
7331 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
7332 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
7333 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
7334 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
7335 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
7336 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
7337 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
7338 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
7339 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
7340 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
7341 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
7342 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
7343 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
7344 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
7345 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
7346 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
7347 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
7348 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
7349 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
7350 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
7351 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
7352 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
7353 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
7354 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
7356 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7357 BindingFlags.DeclaredOnly;
7358 methods = greenType.GetMethods (flags);
7360 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
7361 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
7362 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
7363 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
7364 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
7365 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
7366 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
7367 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
7368 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
7369 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
7370 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
7371 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
7372 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
7373 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
7374 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
7375 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
7376 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
7377 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
7378 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
7379 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
7380 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
7381 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
7382 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
7383 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
7384 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
7385 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
7386 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
7387 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
7388 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
7389 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
7390 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
7391 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
7392 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
7393 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
7394 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
7395 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
7397 flags = BindingFlags.Instance | BindingFlags.Public |
7398 BindingFlags.DeclaredOnly;
7399 methods = greenType.GetMethods (flags);
7401 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
7402 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
7403 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
7404 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
7405 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
7406 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
7407 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
7408 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
7409 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
7410 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
7411 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
7412 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
7413 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
7414 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
7415 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
7416 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
7417 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
7418 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
7419 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
7420 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
7421 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
7422 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
7423 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
7424 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
7425 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
7426 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
7427 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
7428 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
7429 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
7430 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
7431 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
7432 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
7433 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
7434 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
7435 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
7436 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
7438 flags = BindingFlags.Static | BindingFlags.Public |
7439 BindingFlags.DeclaredOnly;
7440 methods = greenType.GetMethods (flags);
7442 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
7443 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
7444 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
7445 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
7446 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
7447 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
7448 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
7449 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
7450 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
7451 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
7452 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
7453 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
7454 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
7455 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
7456 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
7457 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
7458 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
7459 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
7460 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
7461 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
7462 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
7463 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
7464 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
7465 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
7466 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
7467 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
7468 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
7469 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
7470 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
7471 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
7472 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
7473 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
7474 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
7475 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
7476 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
7477 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
7479 flags = BindingFlags.Static | BindingFlags.NonPublic |
7480 BindingFlags.DeclaredOnly;
7481 methods = greenType.GetMethods (flags);
7483 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
7484 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
7485 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
7486 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
7487 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
7488 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
7489 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
7490 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
7491 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
7492 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
7493 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
7494 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
7495 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
7496 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
7497 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
7498 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
7499 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
7500 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
7501 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
7502 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
7503 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
7504 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
7505 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
7506 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
7507 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
7508 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
7509 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
7510 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
7511 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
7512 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
7513 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
7514 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
7515 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
7516 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
7517 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
7518 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
7520 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7521 BindingFlags.Public;
7522 methods = greenType.GetMethods (flags);
7524 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
7525 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
7526 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
7527 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
7528 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
7529 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
7530 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
7531 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
7532 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
7533 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
7534 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
7535 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
7536 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
7537 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
7538 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
7539 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
7540 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
7541 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
7542 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
7543 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
7544 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
7545 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
7546 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
7547 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
7548 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
7549 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
7550 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
7551 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
7552 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
7553 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
7554 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
7555 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
7556 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
7557 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
7558 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
7559 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
7561 flags = BindingFlags.Static | BindingFlags.NonPublic |
7562 BindingFlags.Public;
7563 methods = greenType.GetMethods (flags);
7565 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
7566 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
7567 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
7568 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
7569 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
7570 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
7571 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
7572 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
7573 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
7574 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
7575 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
7576 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
7577 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
7578 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
7579 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
7580 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
7581 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
7582 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
7583 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
7584 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
7585 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
7586 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
7587 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
7588 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
7589 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
7590 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
7591 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
7592 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
7593 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
7594 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
7595 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
7596 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
7597 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
7598 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
7599 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
7600 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
7604 [Category ("NotDotNet")] // mcs depends on this
7605 public void TestGetMethodsFlagsIncomplete_Mono ()
7609 MethodInfo [] methods;
7611 TypeBuilder tb = module.DefineType (genTypeName (),
7612 TypeAttributes.Abstract);
7613 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7614 typeof (void), Type.EmptyTypes);
7615 ilgen = mb.GetILGenerator ();
7616 ilgen.Emit (OpCodes.Ret);
7618 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7619 typeof (void), Type.EmptyTypes);
7620 ilgen = mb.GetILGenerator ();
7621 ilgen.Emit (OpCodes.Ret);
7623 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7624 MethodAttributes.Static,
7625 typeof (void), Type.EmptyTypes);
7626 ilgen = mb.GetILGenerator ();
7627 ilgen.Emit (OpCodes.Ret);
7629 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7630 MethodAttributes.Abstract | MethodAttributes.Virtual,
7631 typeof (void), Type.EmptyTypes);
7633 methods = tb.GetMethods (BindingFlags.Public |
7634 BindingFlags.Instance);
7635 Assert.AreEqual (6, methods.Length, "#A1");
7636 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#A2");
7637 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#A3");
7638 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#A4");
7639 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#A5");
7640 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#A6");
7642 methods = tb.GetMethods (BindingFlags.Public |
7643 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7644 Assert.AreEqual (2, methods.Length, "#B1");
7645 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#B2");
7646 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#B3");
7648 methods = tb.GetMethods (BindingFlags.Public |
7649 BindingFlags.Instance | BindingFlags.Static);
7650 Assert.AreEqual (7, methods.Length, "#C1");
7651 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#C2");
7652 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#C3");
7653 Assert.IsNotNull (GetMethodByName (methods, "Execute"), "#C4");
7654 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#C5");
7655 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#C6");
7656 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#C7");
7658 methods = tb.GetMethods (BindingFlags.NonPublic |
7659 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7660 Assert.AreEqual (1, methods.Length, "#D1");
7661 Assert.IsNotNull (GetMethodByName (methods, "Run"), "#D2");
7666 [Category ("NotWorking")] // mcs depends on this
7667 public void TestGetMethodsFlagsIncomplete_MS ()
7672 TypeBuilder tb = module.DefineType (genTypeName (),
7673 TypeAttributes.Abstract);
7674 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7675 typeof (void), Type.EmptyTypes);
7676 ilgen = mb.GetILGenerator ();
7677 ilgen.Emit (OpCodes.Ret);
7679 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7680 typeof (void), Type.EmptyTypes);
7681 ilgen = mb.GetILGenerator ();
7682 ilgen.Emit (OpCodes.Ret);
7684 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7685 MethodAttributes.Static,
7686 typeof (void), Type.EmptyTypes);
7687 ilgen = mb.GetILGenerator ();
7688 ilgen.Emit (OpCodes.Ret);
7690 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7691 MethodAttributes.Abstract | MethodAttributes.Virtual,
7692 typeof (void), Type.EmptyTypes);
7695 tb.GetMethods (BindingFlags.Public | BindingFlags.Instance);
7697 } catch (NotSupportedException ex) {
7698 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
7699 Assert.IsNull (ex.InnerException, "#3");
7700 Assert.IsNotNull (ex.Message, "#4");
7705 public void TestGetMethodsFlagsComplete ()
7707 TypeBuilder tb = module.DefineType (genTypeName ());
7708 MethodBuilder helloMethod = tb.DefineMethod ("HelloMethod",
7709 MethodAttributes.Public, typeof (string), Type.EmptyTypes);
7710 ILGenerator helloMethodIL = helloMethod.GetILGenerator ();
7711 helloMethodIL.Emit (OpCodes.Ldstr, "Hi! ");
7712 helloMethodIL.Emit (OpCodes.Ldarg_1);
7713 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
7714 new Type [] { typeof (string), typeof (string) });
7715 helloMethodIL.Emit (OpCodes.Call, infoMethod);
7716 helloMethodIL.Emit (OpCodes.Ret);
7718 Type emittedType = tb.CreateType ();
7720 Assert.AreEqual (1, tb.GetMethods (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Length, "#1");
7721 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length,
7722 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length, "#2");
7723 Assert.AreEqual (0, tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).Length, "#3");
7724 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length,
7725 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length, "#4");
7729 public void TestGetMethodsFlagsComplete_Inheritance ()
7731 MethodInfo [] methods;
7734 TypeBuilder blueType = module.DefineType (genTypeName (),
7735 TypeAttributes.Public);
7736 CreateMembers (blueType, "Blue", false);
7738 TypeBuilder redType = module.DefineType (genTypeName (),
7739 TypeAttributes.Public, blueType);
7740 CreateMembers (redType, "Red", false);
7742 TypeBuilder greenType = module.DefineType (genTypeName (),
7743 TypeAttributes.Public, redType);
7744 CreateMembers (greenType, "Green", false);
7746 blueType.CreateType ();
7747 redType.CreateType ();
7748 greenType.CreateType ();
7750 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7751 methods = greenType.GetMethods (flags);
7753 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7754 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7755 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7756 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7757 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7758 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7759 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7760 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7761 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7762 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7763 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7764 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7765 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7766 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7767 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7768 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7769 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7770 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7771 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7772 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7773 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7774 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7775 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7776 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7777 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7778 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7779 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7780 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7781 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7782 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7783 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7784 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7785 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7786 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7787 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7788 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7790 flags = BindingFlags.Instance | BindingFlags.Public;
7791 methods = greenType.GetMethods (flags);
7793 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7794 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7795 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7796 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7797 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7798 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7799 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7800 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7801 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7802 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7803 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7804 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7805 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7806 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7807 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7808 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7809 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7810 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7811 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7812 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7813 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7814 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7815 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7816 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7817 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7818 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7819 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7820 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7821 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7822 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7823 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7824 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7825 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7826 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7827 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7828 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7830 flags = BindingFlags.Static | BindingFlags.Public;
7831 methods = greenType.GetMethods (flags);
7833 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7834 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7835 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7836 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7837 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7838 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7839 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7840 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7841 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7842 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7843 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7844 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7845 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7846 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7847 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7848 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7849 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7850 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7851 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7852 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7853 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7854 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7855 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7856 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7857 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7858 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7859 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7860 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7861 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7862 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7863 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7864 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7865 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7866 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7867 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7868 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7870 flags = BindingFlags.Static | BindingFlags.NonPublic;
7871 methods = greenType.GetMethods (flags);
7873 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7874 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7875 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7876 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7877 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7878 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7879 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7880 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7881 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7882 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7883 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7884 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7885 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7886 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7887 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7888 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7889 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7890 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7891 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7892 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7893 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7894 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7895 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7896 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7897 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7898 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7899 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7900 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7901 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7902 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7903 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7904 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7905 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7906 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7907 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7908 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7910 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7911 BindingFlags.FlattenHierarchy;
7912 methods = greenType.GetMethods (flags);
7914 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7915 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7916 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7917 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7918 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7919 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7920 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7921 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7922 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7923 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7924 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7925 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7926 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7927 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7928 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7929 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7930 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7931 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7932 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7933 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7934 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7935 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7936 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7937 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7938 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7939 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7940 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7941 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7942 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7943 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7944 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7945 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7946 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7947 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7948 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7949 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7951 flags = BindingFlags.Instance | BindingFlags.Public |
7952 BindingFlags.FlattenHierarchy;
7953 methods = greenType.GetMethods (flags);
7955 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7956 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7957 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7958 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7959 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7960 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7961 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7962 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7963 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7964 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7965 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7966 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7967 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7968 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7969 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7970 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7971 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
7972 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
7973 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
7974 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
7975 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
7976 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
7977 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
7978 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
7979 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
7980 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
7981 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
7982 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
7983 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
7984 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
7985 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
7986 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
7987 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
7988 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
7989 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
7990 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
7992 flags = BindingFlags.Static | BindingFlags.Public |
7993 BindingFlags.FlattenHierarchy;
7994 methods = greenType.GetMethods (flags);
7996 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
7997 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
7998 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
7999 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
8000 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
8001 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
8002 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
8003 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
8004 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
8005 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
8006 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
8007 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
8008 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
8009 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
8010 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
8011 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
8012 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
8013 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
8014 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
8015 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
8016 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
8017 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
8018 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
8019 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
8020 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
8021 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
8022 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
8023 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
8024 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
8025 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
8026 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
8027 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
8028 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
8029 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
8030 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
8031 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
8033 flags = BindingFlags.Static | BindingFlags.NonPublic |
8034 BindingFlags.FlattenHierarchy;
8035 methods = greenType.GetMethods (flags);
8037 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
8038 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
8039 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
8040 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
8041 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
8042 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
8043 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
8044 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
8045 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
8046 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
8047 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
8048 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
8049 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
8050 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
8051 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
8052 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
8053 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
8054 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
8055 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
8056 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
8057 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
8058 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
8059 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
8060 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
8061 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
8062 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
8063 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
8064 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
8065 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
8066 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
8067 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
8068 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
8069 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
8070 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
8071 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
8072 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
8074 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8075 BindingFlags.DeclaredOnly;
8076 methods = greenType.GetMethods (flags);
8078 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
8079 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
8080 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
8081 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
8082 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
8083 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
8084 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
8085 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
8086 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
8087 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
8088 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
8089 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
8090 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
8091 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
8092 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
8093 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
8094 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
8095 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
8096 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
8097 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
8098 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
8099 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
8100 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
8101 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
8102 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
8103 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
8104 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
8105 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
8106 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
8107 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
8108 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
8109 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
8110 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
8111 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
8112 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
8113 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
8115 flags = BindingFlags.Instance | BindingFlags.Public |
8116 BindingFlags.DeclaredOnly;
8117 methods = greenType.GetMethods (flags);
8119 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
8120 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
8121 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
8122 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
8123 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
8124 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
8125 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
8126 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
8127 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
8128 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
8129 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
8130 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
8131 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
8132 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
8133 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
8134 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
8135 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
8136 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
8137 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
8138 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
8139 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
8140 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
8141 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
8142 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
8143 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
8144 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
8145 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
8146 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
8147 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
8148 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
8149 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
8150 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
8151 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
8152 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
8153 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
8154 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
8156 flags = BindingFlags.Static | BindingFlags.Public |
8157 BindingFlags.DeclaredOnly;
8158 methods = greenType.GetMethods (flags);
8160 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
8161 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
8162 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
8163 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
8164 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
8165 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
8166 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
8167 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
8168 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
8169 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
8170 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
8171 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
8172 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
8173 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
8174 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
8175 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
8176 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
8177 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
8178 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
8179 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
8180 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
8181 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
8182 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
8183 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
8184 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
8185 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
8186 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
8187 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
8188 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
8189 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
8190 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
8191 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
8192 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
8193 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
8194 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
8195 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
8197 flags = BindingFlags.Static | BindingFlags.NonPublic |
8198 BindingFlags.DeclaredOnly;
8199 methods = greenType.GetMethods (flags);
8201 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
8202 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
8203 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
8204 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
8205 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
8206 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
8207 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
8208 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
8209 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
8210 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
8211 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
8212 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
8213 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
8214 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
8215 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
8216 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
8217 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
8218 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
8219 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
8220 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
8221 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
8222 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
8223 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
8224 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
8225 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
8226 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
8227 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
8228 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
8229 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
8230 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
8231 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
8232 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
8233 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
8234 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
8235 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
8236 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
8238 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8239 BindingFlags.Public;
8240 methods = greenType.GetMethods (flags);
8242 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
8243 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
8244 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
8245 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
8246 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
8247 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
8248 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
8249 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
8250 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
8251 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
8252 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
8253 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
8254 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
8255 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
8256 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
8257 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
8258 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
8259 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
8260 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
8261 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
8262 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
8263 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
8264 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
8265 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
8266 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
8267 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
8268 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
8269 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
8270 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
8271 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
8272 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
8273 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
8274 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
8275 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
8276 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
8277 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
8279 flags = BindingFlags.Static | BindingFlags.NonPublic |
8280 BindingFlags.Public;
8281 methods = greenType.GetMethods (flags);
8283 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
8284 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
8285 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
8286 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
8287 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
8288 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
8289 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
8290 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
8291 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
8292 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
8293 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
8294 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
8295 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
8296 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
8297 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
8298 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
8299 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
8300 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
8301 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
8302 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
8303 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
8304 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
8305 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
8306 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
8307 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
8308 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
8309 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
8310 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
8311 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
8312 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
8313 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
8314 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
8315 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
8316 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
8317 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
8318 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
8322 public void TestGetMemberIncomplete ()
8324 TypeBuilder tb = module.DefineType (genTypeName ());
8326 tb.GetMember ("FOO", MemberTypes.All, BindingFlags.Public);
8328 } catch (NotSupportedException ex) {
8329 // The invoked member is not supported in a
8331 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8332 Assert.IsNull (ex.InnerException, "#3");
8333 Assert.IsNotNull (ex.Message, "#4");
8338 public void TestGetMemberComplete ()
8340 TypeBuilder tb = module.DefineType (genTypeName ());
8341 tb.DefineField ("FOO", typeof (int), FieldAttributes.Private);
8343 Type emittedType = tb.CreateType ();
8345 Assert.AreEqual (1, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.NonPublic).Length);
8346 Assert.AreEqual (0, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.Public).Length);
8350 public void TestGetMembersIncomplete ()
8352 TypeBuilder tb = module.DefineType (genTypeName ());
8356 } catch (NotSupportedException ex) {
8357 // The invoked member is not supported in a
8359 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8360 Assert.IsNull (ex.InnerException, "#3");
8361 Assert.IsNotNull (ex.Message, "#4");
8366 public void TestGetMembersComplete ()
8368 TypeBuilder tb = module.DefineType (genTypeName ());
8369 Type emittedType = tb.CreateType ();
8371 Assert.AreEqual (tb.GetMembers ().Length, emittedType.GetMembers ().Length);
8375 public void TestGetMembersFlagsIncomplete ()
8377 TypeBuilder tb = module.DefineType (genTypeName ());
8379 tb.GetMembers (BindingFlags.Public);
8381 } catch (NotSupportedException ex) {
8382 // The invoked member is not supported in a
8384 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8385 Assert.IsNull (ex.InnerException, "#3");
8386 Assert.IsNotNull (ex.Message, "#4");
8391 public void TestGetMembersFlagsComplete ()
8393 TypeBuilder tb = module.DefineType (genTypeName ());
8394 tb.DefineField ("FOO", typeof (int), FieldAttributes.Public);
8396 Type emittedType = tb.CreateType ();
8398 Assert.IsTrue (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length != 0);
8399 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length,
8400 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length);
8401 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length,
8402 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length);
8406 public void TestGetInterfaceIncomplete ()
8408 TypeBuilder tb = module.DefineType (genTypeName ());
8410 tb.GetInterface ("FOO", true);
8412 } catch (NotSupportedException ex) {
8413 // The invoked member is not supported in a
8415 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8416 Assert.IsNull (ex.InnerException, "#3");
8417 Assert.IsNotNull (ex.Message, "#4");
8422 public void TestGetInterfaces ()
8424 TypeBuilder tb = module.DefineType (genTypeName ());
8425 Type [] interfaces = tb.GetInterfaces ();
8426 Assert.AreEqual (0, interfaces.Length);
8428 TypeBuilder tbInterface = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
8429 Type emittedInterface = tbInterface.CreateType ();
8431 tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { emittedInterface });
8432 interfaces = tb.GetInterfaces ();
8433 Assert.AreEqual (1, interfaces.Length);
8437 public void TestAddDeclarativeSecurityAlreadyCreated ()
8439 TypeBuilder tb = module.DefineType (genTypeName ());
8442 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8444 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8446 } catch (InvalidOperationException ex) {
8447 // Unable to change after type has been created
8448 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8449 Assert.IsNull (ex.InnerException, "#3");
8450 Assert.IsNotNull (ex.Message, "#4");
8455 public void TestAddDeclarativeSecurityNullPermissionSet ()
8457 TypeBuilder tb = module.DefineType (genTypeName ());
8459 tb.AddDeclarativeSecurity (SecurityAction.Demand, null);
8461 } catch (ArgumentNullException ex) {
8462 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
8463 Assert.IsNull (ex.InnerException, "#3");
8464 Assert.IsNotNull (ex.Message, "#4");
8465 Assert.AreEqual ("pset", ex.ParamName, "#5");
8471 public void TestAddDeclarativeSecurityInvalidAction ()
8473 TypeBuilder tb = module.DefineType (genTypeName ());
8475 SecurityAction [] actions = new SecurityAction [] {
8476 SecurityAction.RequestMinimum,
8477 SecurityAction.RequestOptional,
8478 SecurityAction.RequestRefuse };
8479 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8481 foreach (SecurityAction action in actions) {
8483 tb.AddDeclarativeSecurity (action, set);
8485 } catch (ArgumentOutOfRangeException) {
8491 public void TestAddDeclarativeSecurityDuplicateAction ()
8493 TypeBuilder tb = module.DefineType (genTypeName ());
8495 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8496 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8498 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8500 } catch (InvalidOperationException ex) {
8501 // Multiple permission sets specified with the
8502 // same SecurityAction
8503 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8504 Assert.IsNull (ex.InnerException, "#3");
8505 Assert.IsNotNull (ex.Message, "#4");
8510 public void TestEnums ()
8512 TypeAttributes typeAttrs = TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed;
8513 TypeBuilder enumToCreate = module.DefineType (genTypeName (), typeAttrs,
8515 enumToCreate.SetCustomAttribute (new CustomAttributeBuilder (typeof (FlagsAttribute).GetConstructors () [0], Type.EmptyTypes));
8516 // add value__ field, see DefineEnum method of ModuleBuilder
8517 enumToCreate.DefineField ("value__", typeof (Int32),
8518 FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
8521 FieldBuilder fb = enumToCreate.DefineField ("A", enumToCreate,
8522 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8523 fb.SetConstant ((Int32) 0);
8525 fb = enumToCreate.DefineField ("B", enumToCreate,
8526 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8527 fb.SetConstant ((Int32) 1);
8529 fb = enumToCreate.DefineField ("C", enumToCreate,
8530 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8531 fb.SetConstant ((Int32) 2);
8533 Type enumType = enumToCreate.CreateType ();
8535 object enumVal = Enum.ToObject (enumType, (Int32) 3);
8537 Assert.AreEqual ("B, C", enumVal.ToString ());
8538 Assert.AreEqual (3, (Int32) enumVal);
8542 public void DefineEnum ()
8544 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8545 TypeAttributes.Public);
8546 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8547 TypeAttributes.Public, typeof (int));
8548 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8549 enumBuilder.CreateType ();
8550 typeBuilder.CreateType ();
8554 [Category ("NotWorking")]
8555 public void DefineEnumThrowIfTypeBuilderCalledBeforeEnumBuilder ()
8557 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8558 TypeAttributes.Public);
8559 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8560 TypeAttributes.Public, typeof (int));
8561 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8563 typeBuilder.CreateType ();
8565 } catch (TypeLoadException) {
8566 // Could not load type '...' from assembly
8567 // 'MonoTests.System.Reflection.Emit.TypeBuilderTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
8569 Assert.IsTrue (typeBuilder.IsCreated (), "#2");
8570 Assert.IsNull (typeBuilder.CreateType (), "#3");
8574 public void SetCustomAttribute_SuppressUnmanagedCodeSecurity ()
8576 TypeBuilder tb = module.DefineType (genTypeName ());
8577 ConstructorInfo attrCtor = typeof (SuppressUnmanagedCodeSecurityAttribute).
8578 GetConstructor (Type.EmptyTypes);
8579 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
8580 attrCtor, new object [0]);
8581 Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#1");
8582 tb.SetCustomAttribute (caBuilder);
8583 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#2");
8584 Type emittedType = tb.CreateType ();
8585 Assert.AreEqual (TypeAttributes.HasSecurity, emittedType.Attributes & TypeAttributes.HasSecurity, "#3");
8586 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#4");
8587 object [] emittedAttrs = emittedType.GetCustomAttributes (typeof (SuppressUnmanagedCodeSecurityAttribute), true);
8588 Assert.AreEqual (1, emittedAttrs.Length, "#5");
8591 private PropertyBuilder DefineStringProperty (TypeBuilder tb, string propertyName, string fieldName, MethodAttributes methodAttribs)
8593 // define the field holding the property value
8594 FieldBuilder fieldBuilder = tb.DefineField (fieldName,
8595 typeof (string), FieldAttributes.Private);
8597 PropertyBuilder propertyBuilder = tb.DefineProperty (
8598 propertyName, PropertyAttributes.HasDefault, typeof (string),
8599 new Type [] { typeof (string) });
8601 // First, we'll define the behavior of the "get" property for CustomerName as a method.
8602 MethodBuilder getMethodBuilder = tb.DefineMethod ("Get" + propertyName,
8607 ILGenerator getIL = getMethodBuilder.GetILGenerator ();
8609 getIL.Emit (OpCodes.Ldarg_0);
8610 getIL.Emit (OpCodes.Ldfld, fieldBuilder);
8611 getIL.Emit (OpCodes.Ret);
8613 // Now, we'll define the behavior of the "set" property for CustomerName.
8614 MethodBuilder setMethodBuilder = tb.DefineMethod ("Set" + propertyName,
8617 new Type [] { typeof (string) });
8619 ILGenerator setIL = setMethodBuilder.GetILGenerator ();
8621 setIL.Emit (OpCodes.Ldarg_0);
8622 setIL.Emit (OpCodes.Ldarg_1);
8623 setIL.Emit (OpCodes.Stfld, fieldBuilder);
8624 setIL.Emit (OpCodes.Ret);
8626 // Last, we must map the two methods created above to our PropertyBuilder to
8627 // their corresponding behaviors, "get" and "set" respectively.
8628 propertyBuilder.SetGetMethod (getMethodBuilder);
8629 propertyBuilder.SetSetMethod (setMethodBuilder);
8630 return propertyBuilder;
8633 static int handler_called = 0;
8636 public void TestTypeResolve ()
8638 string typeName = genTypeName ();
8640 ResolveEventHandler handler = new ResolveEventHandler (TypeResolve);
8641 AppDomain.CurrentDomain.TypeResolve += handler;
8643 Type t = Type.GetType (typeName);
8644 Assert.AreEqual (typeName, t.Name);
8645 Assert.AreEqual (1, handler_called);
8646 AppDomain.CurrentDomain.TypeResolve -= handler;
8649 Assembly TypeResolve (object sender, ResolveEventArgs args)
8651 TypeBuilder tb = module.DefineType (args.Name, TypeAttributes.Public);
8658 public void IsAssignableFrom_Created ()
8660 TypeBuilder tb = module.DefineType (genTypeName (),
8661 TypeAttributes.Public, typeof (MemoryStream),
8662 new Type [] { typeof (IThrowable), typeof (Bar) });
8663 tb.AddInterfaceImplementation (typeof (IDestroyable));
8664 Type emitted_type = tb.CreateType ();
8666 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8667 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8668 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8669 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8670 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb), "#A5");
8671 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#A6");
8672 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#A7");
8673 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#A8");
8674 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#A9");
8675 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#A10");
8676 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#A11");
8677 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#A12");
8678 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A13");
8679 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A14");
8680 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A15");
8681 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A16");
8682 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A17");
8683 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A18");
8685 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#B1");
8686 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#B2");
8687 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#B3");
8688 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#B4");
8689 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#B5");
8690 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#B6");
8691 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#B7");
8692 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#B8");
8693 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#B9");
8694 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#B10");
8696 Assert.IsTrue (tb.IsAssignableFrom (tb), "#C1");
8697 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#C2");
8698 Assert.IsTrue (tb.IsAssignableFrom (emitted_type), "#C3");
8699 Assert.IsTrue (emitted_type.IsAssignableFrom (tb), "#C4");
8700 Assert.IsFalse (emitted_type.IsAssignableFrom ((Type) null), "#C5");
8702 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type), "#D1");
8703 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IThrowable)), "#D2");
8704 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type), "#D3");
8705 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IMoveable)), "#D4");
8706 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type), "#D5");
8707 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Foo)), "#D6");
8708 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type), "#D7");
8709 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Bar)), "#D8");
8710 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type), "#D9");
8711 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Baz)), "#D10");
8712 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type), "#D11");
8713 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDestroyable)), "#D12");
8714 Assert.IsFalse (typeof (IAir).IsAssignableFrom (emitted_type), "#D13");
8715 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IAir)), "#D14");
8716 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type), "#D15");
8717 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IWater)), "#D16");
8718 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type), "#D17");
8719 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (ILiquid)), "#D18");
8721 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type), "#E1");
8722 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (MemoryStream)), "#E2");
8723 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type), "#E3");
8724 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Stream)), "#E4");
8725 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type), "#E5");
8726 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (FileStream)), "#E6");
8727 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type), "#E7");
8728 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (object)), "#E8");
8729 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type), "#E9");
8730 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDisposable)), "#E10");
8732 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8733 tb.FullName + "[]")), "#F1");
8734 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8735 tb.FullName + "[]")), "#F2");
8736 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8737 tb.FullName + "[]")), "#F3");
8739 TypeBuilder tb2 = module.DefineType (genTypeName (),
8740 TypeAttributes.Public, tb,
8741 new Type [] { typeof (IAir) });
8742 Type emitted_type2 = tb2.CreateType ();
8744 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#G1");
8745 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#G2");
8746 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#G3");
8747 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#G4");
8748 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#G5");
8749 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#G6");
8750 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#G7");
8751 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#G8");
8752 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#G9");
8753 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#G10");
8754 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#G11");
8755 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDestroyable)), "#G12");
8756 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#G13");
8757 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#G14");
8758 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#G15");
8759 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#G16");
8760 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#G17");
8761 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#G18");
8763 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#H1");
8764 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#H2");
8765 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#H3");
8766 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#H4");
8767 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#H5");
8768 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#H6");
8769 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#H7");
8770 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#H8");
8771 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#H9");
8772 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#H10");
8774 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#I1");
8775 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#I2");
8776 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type2), "#I3");
8777 Assert.IsFalse (tb2.IsAssignableFrom (emitted_type), "#I4");
8778 Assert.IsFalse (tb2.IsAssignableFrom ((Type) null), "#I5");
8779 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type2), "#I6");
8780 Assert.IsFalse (emitted_type2.IsAssignableFrom (emitted_type), "#I7");
8781 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb2), "#I8");
8782 Assert.IsFalse (emitted_type2.IsAssignableFrom (tb), "#I9");
8783 Assert.IsFalse (emitted_type2.IsAssignableFrom ((Type) null), "#I10");
8784 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#I11");
8785 Assert.IsTrue (tb.IsAssignableFrom (emitted_type2), "#I12");
8786 Assert.IsTrue (emitted_type.IsAssignableFrom (tb2), "#I13");
8787 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type2), "#I14");
8789 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type2), "#J1");
8790 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IThrowable)), "#J2");
8791 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type2), "#J3");
8792 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IMoveable)), "#J4");
8793 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type2), "#J5");
8794 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Foo)), "#J6");
8795 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type2), "#J7");
8796 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Bar)), "#J8");
8797 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type2), "#J9");
8798 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Baz)), "#J10");
8799 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#J11");
8800 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDestroyable)), "#J12");
8801 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type2), "#J13");
8802 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IAir)), "#J14");
8803 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type2), "#J15");
8804 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IWater)), "#J16");
8805 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type2), "#J17");
8806 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (ILiquid)), "#J18");
8808 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type2), "#K1");
8809 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (MemoryStream)), "#K2");
8810 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type2), "#K3");
8811 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Stream)), "#K4");
8812 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type2), "#K5");
8813 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (FileStream)), "#K6");
8814 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type2), "#K7");
8815 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (object)), "#K8");
8816 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type2), "#K9");
8817 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDisposable)), "#K10");
8819 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8820 tb2.FullName + "[]")), "#L1");
8821 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8822 tb2.FullName + "[]")), "#L2");
8823 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8824 tb2.FullName + "[]")), "#L3");
8826 TypeBuilder tb3 = module.DefineType (genTypeName (),
8827 TypeAttributes.Public, tb2,
8828 new Type [] { typeof (IWater) });
8829 Type emitted_type3 = tb3.CreateType ();
8831 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#M1");
8832 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#M2");
8833 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#M3");
8834 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#M4");
8835 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#M5");
8836 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#M6");
8837 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#M7");
8838 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#M8");
8839 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#M9");
8840 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#M10");
8841 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb3), "#M11");
8842 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDestroyable)), "#M12");
8843 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#M13");
8844 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#M14");
8845 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#M15");
8846 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#M16");
8847 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (tb3), "#M17");
8848 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#M18");
8850 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#N1");
8851 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#N2");
8852 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#N3");
8853 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#N4");
8854 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#N5");
8855 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#N6");
8856 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#N7");
8857 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#N8");
8858 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#N9");
8859 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#N10");
8861 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#O1");
8862 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#O2");
8863 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#O3");
8864 Assert.IsTrue (tb3.IsAssignableFrom (emitted_type3), "#O4");
8865 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type2), "#O5");
8866 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type), "#O6");
8867 Assert.IsFalse (tb3.IsAssignableFrom ((Type) null), "#O7");
8868 Assert.IsTrue (emitted_type3.IsAssignableFrom (emitted_type3), "#O8");
8869 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type2), "#O9");
8870 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type), "#O10");
8871 Assert.IsTrue (emitted_type3.IsAssignableFrom (tb3), "#O11");
8872 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb2), "#O12");
8873 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb), "#O13");
8874 Assert.IsFalse (emitted_type3.IsAssignableFrom ((Type) null), "#O14");
8875 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#O15");
8876 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type3), "#O16");
8877 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type3), "#O17");
8878 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb3), "#O18");
8879 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#O19");
8880 Assert.IsTrue (tb.IsAssignableFrom (emitted_type3), "#O20");
8881 Assert.IsTrue (emitted_type.IsAssignableFrom (tb3), "#021");
8882 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type3), "#O22");
8884 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type3), "#P1");
8885 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IThrowable)), "#P2");
8886 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type3), "#P3");
8887 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IMoveable)), "#P4");
8888 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type3), "#P5");
8889 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Foo)), "#P6");
8890 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type3), "#P7");
8891 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Bar)), "#P8");
8892 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type3), "#P9");
8893 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Baz)), "#P10");
8894 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type3), "#P11");
8895 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDestroyable)), "#P12");
8896 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type3), "#P13");
8897 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IAir)), "#P14");
8898 Assert.IsTrue (typeof (IWater).IsAssignableFrom (emitted_type3), "#P15");
8899 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IWater)), "#P16");
8900 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (emitted_type3), "#P17");
8901 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (ILiquid)), "#P18");
8903 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type3), "#Q1");
8904 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (MemoryStream)), "#Q2");
8905 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type3), "#Q3");
8906 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Stream)), "#Q4");
8907 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type3), "#Q5");
8908 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (FileStream)), "#Q6");
8909 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type3), "#Q7");
8910 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (object)), "#Q8");
8911 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type3), "#Q9");
8912 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDisposable)), "#Q10");
8914 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8915 tb3.FullName + "[]")), "#R1");
8916 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8917 tb3.FullName + "[]")), "#R2");
8918 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8919 tb3.FullName + "[]")), "#R3");
8921 TypeBuilder tb4 = module.DefineType (genTypeName (),
8922 TypeAttributes.Public, null,
8923 new Type [] { typeof (IWater) });
8924 tb4.DefineGenericParameters ("T");
8926 Type inst = tb4.MakeGenericType (typeof (int));
8927 Type emitted_type4 = tb4.CreateType ();
8928 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (inst));
8929 // This returns True if CreateType () is called _before_ MakeGenericType...
8930 //Assert.IsFalse (typeof (IWater).IsAssignableFrom (inst));
8934 public void IsAssignableFrom_NotCreated ()
8936 TypeBuilder tb = module.DefineType (genTypeName (),
8937 TypeAttributes.Public, typeof (MemoryStream),
8939 typeof (IThrowable), typeof (Bar),
8940 typeof (IComparable)
8943 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8944 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8945 //Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8946 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8947 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb), "#A5");
8948 Assert.IsFalse (tb.IsAssignableFrom (typeof (IComparable)), "#A6");
8949 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A7");
8950 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A8");
8951 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A9");
8952 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A10");
8953 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A11");
8954 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A12");
8956 //Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb), "#B1");
8957 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#B2");
8958 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#B3");
8959 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#B4");
8960 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#B5");
8961 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#B6");
8963 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#C1");
8964 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#C2");
8965 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#C3");
8966 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#C4");
8967 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#C5");
8968 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#C6");
8969 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#C7");
8970 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#C8");
8971 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#C9");
8972 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#C10");
8974 Assert.IsTrue (tb.IsAssignableFrom (tb), "#D1");
8975 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#D2");
8977 TypeBuilder tb2 = module.DefineType (genTypeName (),
8978 TypeAttributes.Public, tb,
8979 new Type[] { typeof (IAir) });
8981 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#E1");
8982 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#E2");
8983 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#E3");
8984 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#E4");
8985 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb2), "#E5");
8986 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IComparable)), "#E6");
8987 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#E7");
8988 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#E8");
8989 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#E9");
8990 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#E10");
8991 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#E11");
8992 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#E12");
8994 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#F1");
8995 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#F2");
8996 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#F3");
8997 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#F4");
8998 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#F5");
8999 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#F6");
9001 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#G1");
9002 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#G2");
9003 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#G3");
9004 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#G4");
9005 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#G5");
9006 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#G6");
9007 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#G7");
9008 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#G8");
9009 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#G9");
9010 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#G10");
9012 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#H1");
9013 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#H2");
9014 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#H3");
9016 TypeBuilder tb3 = module.DefineType (genTypeName (),
9017 TypeAttributes.Public, tb2,
9018 new Type[] { typeof (IWater) });
9020 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#I1");
9021 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#I2");
9022 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#I3");
9023 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#I4");
9024 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb3), "#I5");
9025 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IComparable)), "#I6");
9026 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#I7");
9027 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#I8");
9028 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#I9");
9029 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#I10");
9030 //Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb3), "#I11");
9031 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#I12");
9033 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#J1");
9034 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#J2");
9035 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#J3");
9036 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#J4");
9037 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#J5");
9038 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#J6");
9040 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#K1");
9041 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#K2");
9042 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#K3");
9043 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#K4");
9044 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#K5");
9045 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#K6");
9046 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#K7");
9047 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#K8");
9048 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#K9");
9049 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#K10");
9051 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#L1");
9052 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#L2");
9053 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#L3");
9054 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#L4");
9055 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#L5");
9059 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9060 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_Mono ()
9062 TypeBuilder tb = module.DefineType (genTypeName (),
9063 TypeAttributes.Public, typeof (FormatException),
9064 new Type [] { typeof (IThrowable) });
9065 tb.AddInterfaceImplementation (typeof (IDestroyable));
9067 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9068 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9070 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9071 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9075 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9076 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_MS ()
9078 TypeBuilder tb = module.DefineType (genTypeName (),
9079 TypeAttributes.Public, typeof (FormatException),
9080 new Type [] { typeof (IThrowable) });
9081 tb.AddInterfaceImplementation (typeof (IDestroyable));
9083 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9084 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9086 Assert.IsFalse (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9087 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9092 [Category ("NotDotNet")]
9093 public void IsAssignableFrom_NotCreated_Array ()
9095 TypeBuilder tb = module.DefineType (genTypeName (),
9096 TypeAttributes.Public, typeof (FormatException),
9098 typeof (IThrowable), typeof (Bar),
9099 typeof (IComparable)
9102 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9103 tb.FullName + "[]")), "#1");
9104 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9105 tb.FullName + "[]")), "#2");
9106 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9107 tb.FullName + "[]")), "#3");
9111 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9112 public void IsAssignableFrom_NotCreated_BaseInterface_Mono ()
9114 TypeBuilder tb = module.DefineType (genTypeName (),
9115 TypeAttributes.Public, typeof (FormatException),
9117 typeof (IThrowable), typeof (Bar),
9118 typeof (IComparable)
9121 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9122 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9126 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9127 public void IsAssignableFrom_NotCreated_BaseInterface_MS ()
9129 TypeBuilder tb = module.DefineType (genTypeName (),
9130 TypeAttributes.Public, typeof (FormatException),
9132 typeof (IThrowable), typeof (Bar),
9133 typeof (IComparable)
9136 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9137 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9141 public void CreateType_EmptyMethodBody ()
9143 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9145 tb.DefineMethod ("foo", MethodAttributes.Public, typeof (void), new Type [] { });
9149 } catch (InvalidOperationException ex) {
9150 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9151 Assert.IsNull (ex.InnerException, "#3");
9152 Assert.IsNotNull (ex.Message, "#4");
9157 public void CreateType_EmptyCtorBody ()
9159 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9161 tb.DefineConstructor (0, CallingConventions.Standard, null);
9165 } catch (InvalidOperationException ex) {
9166 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9167 Assert.IsNull (ex.InnerException, "#3");
9168 Assert.IsNotNull (ex.Message, "#4");
9173 [Category ("NotWorking")]
9174 public void CreateType_Interface_ParentInvalid ()
9178 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9179 typeof (Exception));
9180 Assert.AreEqual (typeof (Exception), tb.BaseType, "#A1");
9183 Assert.Fail ("#A2");
9184 } catch (TypeLoadException ex) {
9185 // Could not load interface 't5' from assembly '...'
9186 // because it must extend from Object
9187 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A3");
9188 Assert.IsNull (ex.InnerException, "#A4");
9189 Assert.IsNotNull (ex.Message, "#A5");
9190 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#A6");
9191 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#A7");
9194 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9196 Assert.AreEqual (typeof (object), tb.BaseType, "#B1");
9199 Assert.Fail ("#B2");
9200 } catch (TypeLoadException ex) {
9201 // Failure has occurred while loading a type
9202 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B3");
9203 Assert.IsNull (ex.InnerException, "#B4");
9204 Assert.IsNotNull (ex.Message, "#B5");
9207 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9208 typeof (EmptyInterface));
9209 Assert.AreEqual (typeof (EmptyInterface), tb.BaseType, "#C1");
9212 Assert.Fail ("#C2");
9213 } catch (TypeLoadException ex) {
9214 // Could not load interface 't5' from assembly '...'
9215 // because the parent type is an interface
9216 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#C3");
9217 Assert.IsNull (ex.InnerException, "#C4");
9218 Assert.IsNotNull (ex.Message, "#C5");
9219 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#C6");
9220 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#C7");
9225 public void CreateType_Parent_DefaultCtorMissing ()
9229 tb = module.DefineType (genTypeName ());
9230 ConstructorBuilder cb = tb.DefineConstructor (
9231 MethodAttributes.Public,
9232 CallingConventions.Standard,
9233 new Type [] { typeof (string) });
9234 cb.GetILGenerator ().Emit (OpCodes.Ret);
9235 Type parent_type = tb.CreateType ();
9237 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
9242 } catch (NotSupportedException ex) {
9243 // Parent does not have a default constructor.
9244 // The default constructor must be explicitly defined
9245 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
9246 Assert.IsNull (ex.InnerException, "#3");
9247 Assert.IsNotNull (ex.Message, "#4");
9252 public void CreateType_Parent_Null ()
9257 tb = module.DefineType (genTypeName (), TypeAttributes.Public, null);
9258 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
9259 emitted_type = tb.CreateType ();
9260 Assert.AreEqual (typeof (object), emitted_type.BaseType, "#A2");
9262 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract, null);
9263 Assert.IsNull (tb.BaseType, "#B1");
9264 emitted_type = tb.CreateType ();
9265 Assert.IsNull (emitted_type.BaseType, "#B2");
9269 [Category ("NotWorking")]
9270 public void DefineGenericParameters_AlreadyDefined ()
9272 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9273 tb.DefineGenericParameters ("K");
9275 tb.DefineGenericParameters ("V");
9277 } catch (InvalidOperationException ex) {
9278 // Operation is not valid due to the current
9279 // state of the object
9280 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9281 Assert.IsNull (ex.InnerException, "#3");
9282 Assert.IsNotNull (ex.Message, "#4");
9287 public void DefineGenericParameters_Names_Empty ()
9289 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9292 tb.DefineGenericParameters (new string [0]);
9294 } catch (ArgumentException ex) {
9295 // Value does not fall within the expected range
9296 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9297 Assert.IsNull (ex.InnerException, "#3");
9298 Assert.IsNotNull (ex.Message, "#4");
9299 Assert.IsNull (ex.ParamName, "#5");
9304 public void DefineGenericParameters_Names_Null ()
9306 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9309 tb.DefineGenericParameters ((string []) null);
9310 Assert.Fail ("#A1");
9311 } catch (ArgumentNullException ex) {
9312 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9313 Assert.IsNull (ex.InnerException, "#A3");
9314 Assert.IsNotNull (ex.Message, "#A4");
9315 Assert.AreEqual ("names", ex.ParamName, "#A5");
9319 tb.DefineGenericParameters ("K", null, "V");
9320 Assert.Fail ("#B1");
9321 } catch (ArgumentNullException ex) {
9322 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9323 Assert.IsNull (ex.InnerException, "#B3");
9324 Assert.IsNotNull (ex.Message, "#B4");
9325 Assert.AreEqual ("names", ex.ParamName, "#B5");
9330 public void GenericType ()
9332 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9333 tb.DefineGenericParameters ("T");
9335 Assert.IsTrue (tb.IsGenericType, "#A1");
9336 Assert.IsTrue (tb.IsGenericTypeDefinition, "#A2");
9337 Assert.IsTrue (tb.ContainsGenericParameters, "#A3");
9338 Assert.IsFalse (tb.IsGenericParameter, "#A4");
9340 Type[] args = tb.GetGenericArguments ();
9341 Assert.IsFalse (args [0].IsGenericType, "#B1");
9342 Assert.IsFalse (args [0].IsGenericTypeDefinition, "#B2");
9343 Assert.IsTrue (args [0].ContainsGenericParameters, "#B3");
9344 Assert.IsTrue (args [0].IsGenericParameter, "#B4");
9348 public void MakeGenericType ()
9353 tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9354 tb.DefineGenericParameters ("T");
9356 generic_type = tb.MakeGenericType (typeof (int));
9357 Assert.IsTrue (generic_type.IsGenericType, "#A1");
9358 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A2");
9359 Assert.IsFalse (generic_type.ContainsGenericParameters, "#A3");
9360 Assert.IsFalse (generic_type.IsGenericParameter, "#A4");
9362 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9363 Assert.IsTrue (generic_type.IsGenericType, "#B1");
9364 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B2");
9365 Assert.IsTrue (generic_type.ContainsGenericParameters, "#B3");
9366 Assert.IsFalse (generic_type.IsGenericParameter, "#B4");
9368 tb = module.DefineType (genTypeName (), TypeAttributes.Interface
9369 | TypeAttributes.Abstract | TypeAttributes.Public);
9370 tb.DefineGenericParameters ("T");
9372 generic_type = tb.MakeGenericType (typeof (int));
9373 Assert.IsTrue (generic_type.IsGenericType, "#C1");
9374 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#C2");
9375 Assert.IsFalse (generic_type.ContainsGenericParameters, "#C3");
9376 Assert.IsFalse (generic_type.IsGenericParameter, "#C4");
9378 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9379 Assert.IsTrue (generic_type.IsGenericType, "#D1");
9380 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#D2");
9381 Assert.IsTrue (generic_type.ContainsGenericParameters, "#D3");
9382 Assert.IsFalse (generic_type.IsGenericParameter, "#D4");
9386 public void MakeGenericType_NoGenericTypeDefinition ()
9388 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9390 tb.MakeGenericType (typeof (int));
9392 } catch (InvalidOperationException ex) {
9393 // Operation is not valid due to the current
9394 // state of the object
9395 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9396 Assert.IsNull (ex.InnerException, "#3");
9397 Assert.IsNotNull (ex.Message, "#4");
9402 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9403 public void MakeGenericType_TypeArguments_Null_Mono ()
9405 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9406 tb.DefineGenericParameters ("K", "V");
9409 tb.MakeGenericType ((Type []) null);
9410 Assert.Fail ("#A1");
9411 } catch (ArgumentNullException ex) {
9412 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9413 Assert.IsNull (ex.InnerException, "#A3");
9414 Assert.IsNotNull (ex.Message, "#A4");
9415 Assert.AreEqual ("typeArguments", ex.ParamName, "#A5");
9419 tb.MakeGenericType (typeof (string), (Type) null);
9420 Assert.Fail ("#B1");
9421 } catch (ArgumentNullException ex) {
9422 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9423 Assert.IsNull (ex.InnerException, "#B3");
9424 Assert.IsNotNull (ex.Message, "#B4");
9425 Assert.AreEqual ("typeArguments", ex.ParamName, "#B5");
9430 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9431 public void MakeGenericType_TypeArguments_Null_MS ()
9436 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9437 tb.DefineGenericParameters ("K", "V");
9439 generic_type = tb.MakeGenericType ((Type []) null);
9440 Assert.IsNotNull (generic_type, "#A1");
9441 Assert.IsTrue (generic_type.IsGenericType, "#A2");
9442 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A3");
9443 type_args = generic_type.GetGenericArguments ();
9444 Assert.IsNull (type_args, "#A4");
9446 generic_type = tb.MakeGenericType (typeof (string), (Type) null);
9447 Assert.IsNotNull (generic_type, "#B1");
9448 Assert.IsTrue (generic_type.IsGenericType, "#B2");
9449 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B3");
9450 type_args = generic_type.GetGenericArguments ();
9451 Assert.IsNotNull (type_args, "#B4");
9452 Assert.AreEqual (2, type_args.Length, "#B5");
9453 Assert.AreEqual (typeof (string), type_args [0], "#B6");
9454 Assert.IsNull (type_args [1], "#B7");
9458 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9459 public void MakeGenericType_TypeArguments_Mismatch_Mono ()
9461 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9462 tb.DefineGenericParameters ("K", "V");
9464 tb.MakeGenericType (typeof (int));
9466 } catch (ArgumentException ex) {
9467 // The type or method has 2 generic prarameter(s)
9468 // but 1 generic argument(s) were provided. A
9469 // generic argument must be provided for each
9470 // generic parameter
9471 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9472 Assert.IsNull (ex.InnerException, "#3");
9473 Assert.IsNotNull (ex.Message, "#4");
9474 Assert.AreEqual ("typeArguments", ex.ParamName, "#5");
9479 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9480 public void MakeGenericType_TypeArguments_Mismatch_MS ()
9482 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9483 tb.DefineGenericParameters ("K", "V");
9485 Type generic_type = tb.MakeGenericType (typeof (int));
9486 Assert.IsTrue (generic_type.IsGenericType, "#1");
9487 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#2");
9488 Type [] type_args = generic_type.GetGenericArguments ();
9489 Assert.IsNotNull (type_args, "#3");
9490 Assert.AreEqual (1, type_args.Length, "#4");
9491 Assert.AreEqual (typeof (int), type_args [0], "#5");
9495 public void MakeArrayType_Complete ()
9498 TypeBuilder tb = module.DefineType (genTypeName (),
9499 TypeAttributes.Sealed | TypeAttributes.Serializable,
9500 typeof (ContextBoundObject));
9501 Type emittedType = tb.CreateType ();
9502 Type arrayType = tb.MakeArrayType ();
9503 Assert.IsTrue (arrayType.IsArray, "#A1");
9504 Assert.IsTrue (arrayType.HasElementType, "#A2");
9505 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9506 Assert.IsFalse (tb.HasElementType, "#A4");
9507 Assert.IsTrue (tb.IsCreated (), "#A5");
9510 tb = module.DefineType (genTypeName (),
9511 TypeAttributes.Sealed | TypeAttributes.Serializable,
9512 typeof (ValueType));
9513 emittedType = tb.CreateType ();
9514 arrayType = tb.MakeArrayType ();
9515 Assert.IsTrue (arrayType.IsArray, "#B1");
9516 Assert.IsTrue (arrayType.HasElementType, "#B2");
9517 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9518 Assert.IsFalse (tb.HasElementType, "#B4");
9519 Assert.IsTrue (tb.IsCreated (), "#B5");
9521 tb = module.DefineType (genTypeName (),
9522 TypeAttributes.Sealed | TypeAttributes.Serializable,
9524 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
9525 FieldAttributes.Private | FieldAttributes.RTSpecialName);
9526 emittedType = tb.CreateType ();
9527 arrayType = tb.MakeArrayType ();
9528 Assert.IsTrue (arrayType.IsArray, "#C1");
9529 Assert.IsTrue (arrayType.HasElementType, "#C2");
9530 Assert.AreEqual (tb, arrayType.GetElementType (), "#C3");
9531 Assert.IsFalse (tb.HasElementType, "#C4");
9532 Assert.IsTrue (tb.IsCreated (), "#C5");
9535 [Test] // bug #82015
9536 public void MakeArrayType_Incomplete ()
9539 TypeBuilder tb = module.DefineType (genTypeName (),
9540 TypeAttributes.Sealed | TypeAttributes.Serializable,
9541 typeof (ContextBoundObject));
9542 Type arrayType = tb.MakeArrayType ();
9543 Assert.IsTrue (arrayType.IsArray, "#A1");
9544 Assert.IsTrue (arrayType.HasElementType, "#A2");
9545 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9546 Assert.IsFalse (tb.HasElementType, "#A4");
9547 Assert.IsFalse (tb.IsCreated (), "#A5");
9550 tb = module.DefineType (genTypeName (),
9551 TypeAttributes.Sealed | TypeAttributes.Serializable,
9552 typeof (ValueType));
9553 arrayType = tb.MakeArrayType ();
9554 Assert.IsTrue (arrayType.IsArray, "#B1");
9555 Assert.IsTrue (arrayType.HasElementType, "#B2");
9556 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9557 Assert.IsFalse (tb.HasElementType, "#B4");
9558 Assert.IsFalse (tb.IsCreated (), "#B5");
9561 tb = module.DefineType (genTypeName (),
9562 TypeAttributes.Sealed | TypeAttributes.Serializable,
9564 arrayType = tb.MakeArrayType ();
9565 Assert.IsTrue (arrayType.IsArray, "#C1");
9566 Assert.IsTrue (arrayType.HasElementType, "#C2");
9567 Assert.IsFalse (tb.HasElementType, "#C3");
9568 Assert.IsFalse (tb.IsCreated (), "#C4");
9572 public void GetCustomAttributes_InflatedType ()
9574 TypeBuilder tb = module.DefineType (genTypeName ());
9575 tb.DefineGenericParameters (new string[] { "FOO" });
9577 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
9578 new Type [] { typeof (string) });
9580 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
9581 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
9583 tb.SetCustomAttribute (caBuilder);
9584 Type t = tb.CreateType ();
9586 Type inflated = t.MakeGenericType (new Type [] { typeof (int) });
9588 Assert.AreEqual (1, inflated.GetCustomAttributes (false).Length);
9592 public void GetField ()
9594 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9595 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
9597 ConstructorBuilder cb = tb.DefineDefaultConstructor (MethodAttributes.Public);
9599 FieldBuilder fb1 = tb.DefineField ("field1", typeParams [0], FieldAttributes.Public);
9601 Type t = tb.MakeGenericType (typeof (int));
9603 // Chect that calling MakeArrayType () does not initialize the class
9607 // Check that the instantiation of a type builder contains live data
9608 TypeBuilder.GetField (t, fb1);
9609 FieldBuilder fb2 = tb.DefineField ("field2", typeParams [0], FieldAttributes.Public);
9610 FieldInfo fi2 = TypeBuilder.GetField (t, fb1);
9612 MethodBuilder mb = tb.DefineMethod ("get_int", MethodAttributes.Public|MethodAttributes.Static, typeof (int), Type.EmptyTypes);
9613 ILGenerator ilgen = mb.GetILGenerator ();
9614 ilgen.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t, cb));
9615 ilgen.Emit (OpCodes.Dup);
9616 ilgen.Emit (OpCodes.Ldc_I4, 42);
9617 ilgen.Emit (OpCodes.Stfld, fi2);
9618 ilgen.Emit (OpCodes.Ldfld, fi2);
9619 ilgen.Emit (OpCodes.Ret);
9621 // Check GetField on a type instantiated with type parameters
9622 Type t3 = tb.MakeGenericType (typeParams [0]);
9623 FieldBuilder fb3 = tb.DefineField ("field3", typeParams [0], FieldAttributes.Public);
9624 FieldInfo fi3 = TypeBuilder.GetField (t3, fb3);
9626 MethodBuilder mb3 = tb.DefineMethod ("get_T", MethodAttributes.Public|MethodAttributes.Static, typeParams [0], Type.EmptyTypes);
9627 ILGenerator ilgen3 = mb3.GetILGenerator ();
9628 ilgen3.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t3, cb));
9629 ilgen3.Emit (OpCodes.Ldfld, fi3);
9630 ilgen3.Emit (OpCodes.Ret);
9632 Type created = tb.CreateType ();
9634 Type inst = created.MakeGenericType (typeof (object));
9636 Assert.AreEqual (42, inst.GetMethod ("get_int").Invoke (null, null));
9638 Assert.AreEqual (null, inst.GetMethod ("get_T").Invoke (null, null));
9641 [Test] //bug #354047
9642 public void CreatedTypeInstantiationOverTypeBuilderArgsIsNotAGenericTypeDefinition ()
9644 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9645 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9646 Type t = tb.CreateType ();
9648 Type inst = tb.MakeGenericType (typeParams [0]);
9649 Assert.IsFalse (inst.IsGenericTypeDefinition, "#1 create type instance is not a generic type definition");
9652 [Test] //bug #354047
9653 public void CreatedTypeAndTypeBuilderOwnTheirGenericArguments ()
9655 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9656 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9657 Type t = tb.CreateType ();
9659 Assert.IsTrue (tb.GetGenericArguments()[0].DeclaringType == tb, "#1 TypeBuilder owns its arguments");
9660 Assert.IsTrue (t.GetGenericArguments()[0].DeclaringType == t, "#1 create type owns its arguments");
9663 [Test] //bug #354047
9664 public void CreatedTypeAndTypeBuilderDontShareGenericArguments ()
9666 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9667 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9668 Type t = tb.CreateType ();
9670 Assert.IsTrue (tb.GetGenericArguments()[0] != t.GetGenericArguments()[0], "#1 TypeBuilder and create type arguments are diferent");
9673 [Test] //bug #399047
9674 public void FieldOnTypeBuilderInstDontInflateWhenEncoded () {
9675 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9677 module = assembly.DefineDynamicModule ("Instance.exe");
9679 TypeBuilder G = module.DefineType ("G", TypeAttributes.Public);
9680 Type T = G.DefineGenericParameters ("T") [0];
9681 ConstructorInfo ctor = G.DefineDefaultConstructor (MethodAttributes.Public);
9682 Type GObj = G.MakeGenericType (new Type [] { T });
9684 FieldBuilder F = G.DefineField ("F", T, FieldAttributes.Public);
9686 TypeBuilder P = module.DefineType ("P", TypeAttributes.Public);
9688 MethodBuilder Test = P.DefineMethod ("Test", MethodAttributes.Public);
9689 Type TATest = Test.DefineGenericParameters ("TA") [0];
9691 Type TestGObj = G.MakeGenericType (new Type [] { TATest });
9693 ILGenerator il = Test.GetILGenerator ();
9695 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (TestGObj, ctor));
9696 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (TestGObj, F));
9697 il.Emit (OpCodes.Pop);
9699 il.Emit (OpCodes.Ret);
9702 MethodBuilder main = P.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static);
9704 ILGenerator il = main.GetILGenerator ();
9705 il.Emit(OpCodes.Newobj, P.DefineDefaultConstructor (MethodAttributes.Public));
9706 il.Emit(OpCodes.Call, Test.MakeGenericMethod (typeof (int)));
9707 il.Emit (OpCodes.Ret);
9710 assembly.SetEntryPoint (main);
9714 assembly.Save ("Instance.exe");
9715 Thread.GetDomain ().ExecuteAssembly(Path.GetTempPath () + Path.DirectorySeparatorChar + "Instance.exe");
9719 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers ()
9721 TypeBuilder tb = module.DefineType ("Type1", TypeAttributes.Public);
9722 FieldBuilder fb = tb.DefineInitializedData ("Foo", new byte [] {1,2,3,4}, FieldAttributes.Static|FieldAttributes.Public);
9725 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME+"2"), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9726 module = assembly.DefineDynamicModule ("Instance.exe");
9728 TypeBuilder tb2 = module.DefineType ("Type2", TypeAttributes.Public);
9729 MethodBuilder mb = tb2.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static, typeof (object), new Type [0]);
9730 ILGenerator il = mb.GetILGenerator ();
9732 il.Emit (OpCodes.Ldc_I4_1);
9733 il.Emit (OpCodes.Newarr, typeof (int));
9734 il.Emit (OpCodes.Dup);
9735 il.Emit (OpCodes.Ldtoken, fb);
9736 il.Emit (OpCodes.Call, typeof (RuntimeHelpers).GetMethod ("InitializeArray"));
9737 il.Emit (OpCodes.Ret);
9739 Type t = tb2.CreateType ();
9740 int[] res = (int[])t.GetMethod ("Test").Invoke (null, new object[0]);
9741 //Console.WriteLine (res[0]);
9744 public interface IDelegateFactory
9746 Delegate Create (Delegate del);
9750 public void CreateType_Ctor_NoBody ()
9752 TypeBuilder tb = module.DefineType (genTypeName ());
9753 tb.DefineConstructor (MethodAttributes.Public,
9754 CallingConventions.Standard,
9755 new Type [] { typeof (string) });
9759 } catch (InvalidOperationException ex) {
9760 // Method '.ctor' does not have a method body
9761 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9762 Assert.IsNull (ex.InnerException, "#3");
9763 Assert.IsNotNull (ex.Message, "#4");
9764 Assert.IsTrue (ex.Message.IndexOf (".ctor") != -1, "#5");
9768 [Test] //bug #361689
9769 public void CreateTypeFailsWithInvalidMethodOverride ()
9771 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9773 MethodBuilder mc = tb.DefineMethod ("Create", MethodAttributes.Public, typeof (Delegate), new Type[] {typeof (Delegate)});
9774 ILGenerator gen = mc.GetILGenerator ();
9775 gen.Emit (OpCodes.Ldarg_0);
9776 gen.Emit (OpCodes.Ret);
9777 tb.DefineMethodOverride (mc, typeof (IDelegateFactory).GetMethod ("Create"));
9780 Assert.Fail ("#1 create type did not throw TypeLoadException");
9781 } catch (TypeLoadException) {
9786 [Test] //bug #349194
9787 public void IsAssignableToWorksWithInterfacesOnParent ()
9789 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9790 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Public, tb);
9792 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
9793 Type t = tb.CreateType ();
9794 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
9795 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t));
9798 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
9799 Type t2 = tb2.CreateType ();
9800 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
9801 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t2));
9805 [Test] //bug #430508
9806 public void MakeGenericTypeRespectBaseType ()
9808 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9809 EnumBuilder eb = module.DefineEnum (genTypeName (), TypeAttributes.Public, typeof (int));
9811 MethodBuilder mb = tb.DefineMethod ("Test",
9812 MethodAttributes.Public,
9813 typeof (Tuple<,>).MakeGenericType (typeof (int), eb),
9815 ILGenerator il = mb.GetILGenerator();
9816 il.Emit (OpCodes.Ldnull);
9817 il.Emit (OpCodes.Ret);
9819 Type e = eb.CreateType ();
9820 Type c = tb.CreateType ();
9822 Assert.AreEqual (c.GetMethod ("Test").ReturnType.GetGenericArguments ()[1], e, "#1");
9826 public void GetCustomAttrOnFieldOfInflatedType ()
9828 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9829 tb.DefineGenericParameters ("T");
9831 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9832 typeof (SimpleTestAttribute).GetConstructors ()[0],
9835 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
9836 field.SetCustomAttribute (caBuilder);
9838 Type t = tb.CreateType ();
9840 FieldInfo fi = t.GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9841 object[] cattrs = fi.GetCustomAttributes (false);
9842 Assert.AreEqual (1, cattrs.Length);
9844 fi = t.MakeGenericType (typeof (int)).GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9845 cattrs = fi.GetCustomAttributes (false);
9846 Assert.AreEqual (1, cattrs.Length);
9850 public void GetCustomAttrOnPropertyOfInflatedType ()
9852 TypeBuilder tb = module.DefineType (genTypeName ());
9853 tb.DefineGenericParameters ("T");
9855 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9856 typeof (SimpleTestAttribute).GetConstructors ()[0],
9859 PropertyBuilder property = DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
9860 property.SetCustomAttribute (caBuilder);
9862 Type t = tb.CreateType ();
9864 PropertyInfo pi = t.GetProperties ()[0];
9865 object[] cattrs = pi.GetCustomAttributes (false);
9866 Assert.AreEqual (1, cattrs.Length);
9868 pi = t.MakeGenericType (typeof (int)).GetProperties ()[0];
9869 cattrs = pi.GetCustomAttributes (false);
9870 Assert.AreEqual (1, cattrs.Length);
9874 public void GetCustomAttrOnEventOfInflatedType ()
9876 TypeBuilder tb = module.DefineType (genTypeName ());
9877 tb.DefineGenericParameters ("T");
9879 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9880 typeof (SimpleTestAttribute).GetConstructors ()[0],
9883 EventBuilder evt = tb.DefineEvent ("OI", 0, typeof (int));
9884 evt.SetCustomAttribute (caBuilder);
9886 Type t = tb.CreateType ();
9888 EventInfo ei = t.GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9889 object[] cattrs = ei.GetCustomAttributes (false);
9890 Assert.AreEqual (1, cattrs.Length);
9892 ei = t.MakeGenericType (typeof (int)).GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9893 cattrs = ei.GetCustomAttributes (false);
9894 Assert.AreEqual (1, cattrs.Length);
9897 public void TestDoubleInitializationOfMonoGenericClass () //bug #400643
9899 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9900 tb.DefineGenericParameters ("T");
9902 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9903 typeof (SimpleTestAttribute).GetConstructors ()[0],
9906 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
9907 field.SetCustomAttribute (caBuilder);
9910 tb.MakeGenericType (typeof (int)).GetMethods ();
9911 tb.MakeGenericType (typeof (double)).GetMethods ();
9913 Type t = tb.CreateType ();
9915 t.MakeGenericType (typeof (int)).GetMethods ();
9916 t.MakeGenericType (typeof (double)).GetMethods ();
9920 public void TestGenericFieldAccess () // bug #467415
9922 AssemblyName asmName = new AssemblyName("DemoMethodBuilder1");
9923 AppDomain domain = AppDomain.CurrentDomain;
9924 AssemblyBuilder demoAssembly =
9925 domain.DefineDynamicAssembly(asmName,
9926 AssemblyBuilderAccess.RunAndSave);
9928 // Define the module that contains the code. For an
9929 // assembly with one module, the module name is the
9930 // assembly name plus a file extension.
9931 ModuleBuilder demoModule =
9932 demoAssembly.DefineDynamicModule(asmName.Name,
9933 asmName.Name+".dll");
9935 TypeBuilder demoType =
9936 demoModule.DefineType("DemoType", TypeAttributes.Public);
9938 MethodBuilder factory =
9939 demoType.DefineMethod("Factory",
9940 MethodAttributes.Public | MethodAttributes.Static);
9942 string[] typeParameterNames = {"T"};
9943 GenericTypeParameterBuilder[] typeParameters =
9944 factory.DefineGenericParameters(typeParameterNames);
9946 GenericTypeParameterBuilder T = typeParameters[0];
9949 factory.SetParameters(parms);
9951 factory.SetReturnType(T);
9953 ILGenerator ilgen = factory.GetILGenerator();
9955 Type G = typeof(Gen<>);
9956 Type GT = G.MakeGenericType (T);
9957 FieldInfo GF = G.GetField("field");
9958 FieldInfo GTF = TypeBuilder.GetField(GT, GF);
9960 ilgen.Emit(OpCodes.Ldsfld, GTF);
9961 ilgen.Emit(OpCodes.Ret);
9963 // Complete the type.
9964 Type dt = demoType.CreateType();
9965 // Save the assembly, so it can be examined with Ildasm.exe.
9966 //demoAssembly.Save(asmName.Name+".dll");
9968 MethodInfo m = dt.GetMethod("Factory");
9969 MethodInfo bound = m.MakeGenericMethod(typeof(int));
9971 // Display a string representing the bound method.
9972 //Console.WriteLine(bound);
9974 object[] parameters = {};
9975 int result = (int)(bound.Invoke(null, parameters));
9977 Assert.AreEqual (0, result, "#1");
9980 static MethodInfo GetMethodByName (MethodInfo [] methods, string name)
9982 foreach (MethodInfo mi in methods)
9983 if (mi.Name == name)
9988 void CreateMembers (TypeBuilder tb, string suffix, bool defineCtors)
9990 ConstructorBuilder cb;
9998 // instance constructors
10000 cb = tb.DefineConstructor (MethodAttributes.Private,
10001 CallingConventions.Standard,
10002 new Type [] { typeof (int), typeof (int) });
10003 cb.GetILGenerator ().Emit (OpCodes.Ret);
10005 cb = tb.DefineConstructor (MethodAttributes.Family,
10006 CallingConventions.Standard,
10007 new Type [] { typeof (string) });
10008 cb.GetILGenerator ().Emit (OpCodes.Ret);
10010 cb = tb.DefineConstructor (MethodAttributes.FamANDAssem,
10011 CallingConventions.Standard,
10012 new Type [] { typeof (string), typeof (string) });
10013 cb.GetILGenerator ().Emit (OpCodes.Ret);
10015 cb = tb.DefineConstructor (MethodAttributes.FamORAssem,
10016 CallingConventions.Standard,
10017 new Type [] { typeof (int) });
10018 cb.GetILGenerator ().Emit (OpCodes.Ret);
10020 cb = tb.DefineConstructor (MethodAttributes.Public,
10021 CallingConventions.Standard,
10022 new Type [] { typeof (int), typeof (bool) });
10023 cb.GetILGenerator ().Emit (OpCodes.Ret);
10025 cb = tb.DefineConstructor (MethodAttributes.Assembly,
10026 CallingConventions.Standard,
10027 new Type [] { typeof (string), typeof (int) });
10028 cb.GetILGenerator ().Emit (OpCodes.Ret);
10031 // static constructors
10034 cb = tb.DefineConstructor (MethodAttributes.Private |
10035 MethodAttributes.Static,
10036 CallingConventions.Standard,
10038 cb.GetILGenerator ().Emit (OpCodes.Ret);
10042 // instance methods
10045 mb = tb.DefineMethod ("GetPrivateInstance" + suffix,
10046 MethodAttributes.Private, typeof (void),
10048 mb.GetILGenerator ().Emit (OpCodes.Ret);
10050 mb = tb.DefineMethod ("GetFamilyInstance" + suffix,
10051 MethodAttributes.Family, typeof (void),
10053 mb.GetILGenerator ().Emit (OpCodes.Ret);
10055 mb = tb.DefineMethod ("GetFamANDAssemInstance" + suffix,
10056 MethodAttributes.FamANDAssem, typeof (void),
10058 mb.GetILGenerator ().Emit (OpCodes.Ret);
10060 mb = tb.DefineMethod ("GetFamORAssemInstance" + suffix,
10061 MethodAttributes.FamORAssem, typeof (void),
10063 mb.GetILGenerator ().Emit (OpCodes.Ret);
10065 mb = tb.DefineMethod ("GetPublicInstance" + suffix,
10066 MethodAttributes.Public, typeof (void),
10068 mb.GetILGenerator ().Emit (OpCodes.Ret);
10070 mb = tb.DefineMethod ("GetAssemblyInstance" + suffix,
10071 MethodAttributes.Assembly, typeof (void),
10073 mb.GetILGenerator ().Emit (OpCodes.Ret);
10079 mb = tb.DefineMethod ("GetPrivateStatic" + suffix,
10080 MethodAttributes.Private | MethodAttributes.Static,
10081 typeof (void), Type.EmptyTypes);
10082 mb.GetILGenerator ().Emit (OpCodes.Ret);
10084 mb = tb.DefineMethod ("GetFamilyStatic" + suffix,
10085 MethodAttributes.Family | MethodAttributes.Static,
10086 typeof (void), Type.EmptyTypes);
10087 mb.GetILGenerator ().Emit (OpCodes.Ret);
10089 mb = tb.DefineMethod ("GetFamANDAssemStatic" + suffix,
10090 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10091 typeof (void), Type.EmptyTypes);
10092 mb.GetILGenerator ().Emit (OpCodes.Ret);
10094 mb = tb.DefineMethod ("GetFamORAssemStatic" + suffix,
10095 MethodAttributes.FamORAssem | MethodAttributes.Static,
10096 typeof (void), Type.EmptyTypes);
10097 mb.GetILGenerator ().Emit (OpCodes.Ret);
10099 mb = tb.DefineMethod ("GetPublicStatic" + suffix,
10100 MethodAttributes.Public | MethodAttributes.Static,
10101 typeof (void), Type.EmptyTypes);
10102 mb.GetILGenerator ().Emit (OpCodes.Ret);
10104 mb = tb.DefineMethod ("GetAssemblyStatic" + suffix,
10105 MethodAttributes.Assembly | MethodAttributes.Static,
10106 typeof (void), Type.EmptyTypes);
10107 mb.GetILGenerator ().Emit (OpCodes.Ret);
10113 tb.DefineField ("privateInstance" + suffix,
10114 typeof (string), FieldAttributes.Private);
10115 tb.DefineField ("familyInstance" + suffix,
10116 typeof (string), FieldAttributes.Family);
10117 tb.DefineField ("famANDAssemInstance" + suffix,
10118 typeof (string), FieldAttributes.FamANDAssem);
10119 tb.DefineField ("famORAssemInstance" + suffix,
10120 typeof (string), FieldAttributes.FamORAssem);
10121 tb.DefineField ("publicInstance" + suffix,
10122 typeof (string), FieldAttributes.Public);
10123 tb.DefineField ("assemblyInstance" + suffix,
10124 typeof (string), FieldAttributes.Assembly);
10130 tb.DefineField ("privateStatic" + suffix,
10131 typeof (string), FieldAttributes.Private |
10132 FieldAttributes.Static);
10133 tb.DefineField ("familyStatic" + suffix,
10134 typeof (string), FieldAttributes.Family |
10135 FieldAttributes.Static);
10136 tb.DefineField ("famANDAssemStatic" + suffix,
10137 typeof (string), FieldAttributes.FamANDAssem |
10138 FieldAttributes.Static);
10139 tb.DefineField ("famORAssemStatic" + suffix,
10140 typeof (string), FieldAttributes.FamORAssem |
10141 FieldAttributes.Static);
10142 tb.DefineField ("publicStatic" + suffix,
10143 typeof (string), FieldAttributes.Public |
10144 FieldAttributes.Static);
10145 tb.DefineField ("assemblyStatic" + suffix,
10146 typeof (string), FieldAttributes.Assembly |
10147 FieldAttributes.Static);
10150 // instance properties
10153 pb = tb.DefineProperty ("PrivateInstance" + suffix,
10154 PropertyAttributes.None, typeof (string),
10156 mb = tb.DefineMethod ("get_PrivateInstance" + suffix,
10157 MethodAttributes.Private, typeof (string),
10159 ilgen = mb.GetILGenerator ();
10160 ilgen.Emit (OpCodes.Ldnull);
10161 ilgen.Emit (OpCodes.Ret);
10162 pb.SetGetMethod (mb);
10164 pb = tb.DefineProperty ("FamilyInstance" + suffix,
10165 PropertyAttributes.None, typeof (string),
10167 mb = tb.DefineMethod ("get_FamilyInstance" + suffix,
10168 MethodAttributes.Family, typeof (string),
10170 ilgen = mb.GetILGenerator ();
10171 ilgen.Emit (OpCodes.Ldnull);
10172 ilgen.Emit (OpCodes.Ret);
10173 pb.SetGetMethod (mb);
10175 pb = tb.DefineProperty ("FamANDAssemInstance" + suffix,
10176 PropertyAttributes.None, typeof (string),
10178 mb = tb.DefineMethod ("get_FamANDAssemInstance" + suffix,
10179 MethodAttributes.FamANDAssem, typeof (string),
10181 ilgen = mb.GetILGenerator ();
10182 ilgen.Emit (OpCodes.Ldnull);
10183 ilgen.Emit (OpCodes.Ret);
10184 pb.SetGetMethod (mb);
10186 pb = tb.DefineProperty ("FamORAssemInstance" + suffix,
10187 PropertyAttributes.None, typeof (string),
10189 mb = tb.DefineMethod ("get_FamORAssemInstance" + suffix,
10190 MethodAttributes.FamORAssem, typeof (string),
10192 ilgen = mb.GetILGenerator ();
10193 ilgen.Emit (OpCodes.Ldnull);
10194 ilgen.Emit (OpCodes.Ret);
10195 pb.SetGetMethod (mb);
10197 pb = tb.DefineProperty ("PublicInstance" + suffix,
10198 PropertyAttributes.None, typeof (string),
10200 mb = tb.DefineMethod ("get_PublicInstance" + suffix,
10201 MethodAttributes.Public, typeof (string),
10203 ilgen = mb.GetILGenerator ();
10204 ilgen.Emit (OpCodes.Ldnull);
10205 ilgen.Emit (OpCodes.Ret);
10206 pb.SetGetMethod (mb);
10208 pb = tb.DefineProperty ("AssemblyInstance" + suffix,
10209 PropertyAttributes.None, typeof (string),
10211 mb = tb.DefineMethod ("get_AssemblyInstance" + suffix,
10212 MethodAttributes.Assembly, typeof (string),
10214 ilgen = mb.GetILGenerator ();
10215 ilgen.Emit (OpCodes.Ldnull);
10216 ilgen.Emit (OpCodes.Ret);
10217 pb.SetGetMethod (mb);
10220 // static properties
10223 pb = tb.DefineProperty ("PrivateStatic" + suffix,
10224 PropertyAttributes.None, typeof (string),
10226 mb = tb.DefineMethod ("get_PrivateStatic" + suffix,
10227 MethodAttributes.Private | MethodAttributes.Static,
10228 typeof (string), Type.EmptyTypes);
10229 ilgen = mb.GetILGenerator ();
10230 ilgen.Emit (OpCodes.Ldnull);
10231 ilgen.Emit (OpCodes.Ret);
10232 pb.SetGetMethod (mb);
10234 pb = tb.DefineProperty ("FamilyStatic" + suffix,
10235 PropertyAttributes.None, typeof (string),
10237 mb = tb.DefineMethod ("get_FamilyStatic" + suffix,
10238 MethodAttributes.Family | MethodAttributes.Static,
10239 typeof (string), Type.EmptyTypes);
10240 ilgen = mb.GetILGenerator ();
10241 ilgen.Emit (OpCodes.Ldnull);
10242 ilgen.Emit (OpCodes.Ret);
10243 pb.SetGetMethod (mb);
10245 pb = tb.DefineProperty ("FamANDAssemStatic" + suffix,
10246 PropertyAttributes.None, typeof (string),
10248 mb = tb.DefineMethod ("get_FamANDAssemStatic" + suffix,
10249 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10250 typeof (string), Type.EmptyTypes);
10251 ilgen = mb.GetILGenerator ();
10252 ilgen.Emit (OpCodes.Ldnull);
10253 ilgen.Emit (OpCodes.Ret);
10254 pb.SetGetMethod (mb);
10256 pb = tb.DefineProperty ("FamORAssemStatic" + suffix,
10257 PropertyAttributes.None, typeof (string),
10259 mb = tb.DefineMethod ("get_FamORAssemStatic" + suffix,
10260 MethodAttributes.FamORAssem | MethodAttributes.Static,
10261 typeof (string), Type.EmptyTypes);
10262 ilgen = mb.GetILGenerator ();
10263 ilgen.Emit (OpCodes.Ldnull);
10264 ilgen.Emit (OpCodes.Ret);
10265 pb.SetGetMethod (mb);
10267 pb = tb.DefineProperty ("PublicStatic" + suffix,
10268 PropertyAttributes.None, typeof (string),
10270 mb = tb.DefineMethod ("get_PublicStatic" + suffix,
10271 MethodAttributes.Public | MethodAttributes.Static,
10272 typeof (string), Type.EmptyTypes);
10273 ilgen = mb.GetILGenerator ();
10274 ilgen.Emit (OpCodes.Ldnull);
10275 ilgen.Emit (OpCodes.Ret);
10276 pb.SetGetMethod (mb);
10278 pb = tb.DefineProperty ("AssemblyStatic" + suffix,
10279 PropertyAttributes.None, typeof (string),
10281 mb = tb.DefineMethod ("get_AssemblyStatic" + suffix,
10282 MethodAttributes.Assembly | MethodAttributes.Static,
10283 typeof (string), Type.EmptyTypes);
10284 ilgen = mb.GetILGenerator ();
10285 ilgen.Emit (OpCodes.Ldnull);
10286 ilgen.Emit (OpCodes.Ret);
10287 pb.SetGetMethod (mb);
10293 eb = tb.DefineEvent ("OnPrivateInstance" + suffix,
10294 EventAttributes.None, typeof (EventHandler));
10295 mb = tb.DefineMethod ("add_OnPrivateInstance" + suffix,
10296 MethodAttributes.Private, typeof (void),
10298 mb.GetILGenerator ().Emit (OpCodes.Ret);
10299 eb.SetAddOnMethod (mb);
10301 eb = tb.DefineEvent ("OnFamilyInstance" + suffix,
10302 EventAttributes.None, typeof (EventHandler));
10303 mb = tb.DefineMethod ("add_OnFamilyInstance" + suffix,
10304 MethodAttributes.Family, typeof (void),
10306 mb.GetILGenerator ().Emit (OpCodes.Ret);
10307 eb.SetAddOnMethod (mb);
10309 eb = tb.DefineEvent ("OnFamANDAssemInstance" + suffix,
10310 EventAttributes.None, typeof (EventHandler));
10311 mb = tb.DefineMethod ("add_OnFamANDAssemInstance" + suffix,
10312 MethodAttributes.FamANDAssem, typeof (void),
10314 mb.GetILGenerator ().Emit (OpCodes.Ret);
10315 eb.SetAddOnMethod (mb);
10317 eb = tb.DefineEvent ("OnFamORAssemInstance" + suffix,
10318 EventAttributes.None, typeof (EventHandler));
10319 mb = tb.DefineMethod ("add_OnFamORAssemInstance" + suffix,
10320 MethodAttributes.FamORAssem, typeof (void),
10322 mb.GetILGenerator ().Emit (OpCodes.Ret);
10323 eb.SetAddOnMethod (mb);
10325 eb = tb.DefineEvent ("OnPublicInstance" + suffix,
10326 EventAttributes.None, typeof (EventHandler));
10327 mb = tb.DefineMethod ("add_OnPublicInstance" + suffix,
10328 MethodAttributes.Public, typeof (void),
10330 mb.GetILGenerator ().Emit (OpCodes.Ret);
10331 eb.SetAddOnMethod (mb);
10333 eb = tb.DefineEvent ("OnAssemblyInstance" + suffix,
10334 EventAttributes.None, typeof (EventHandler));
10335 mb = tb.DefineMethod ("add_OnAssemblyInstance" + suffix,
10336 MethodAttributes.Family, typeof (void),
10338 mb.GetILGenerator ().Emit (OpCodes.Ret);
10339 eb.SetAddOnMethod (mb);
10345 eb = tb.DefineEvent ("OnPrivateStatic" + suffix,
10346 EventAttributes.None, typeof (EventHandler));
10347 mb = tb.DefineMethod ("add_OnPrivateStatic" + suffix,
10348 MethodAttributes.Private | MethodAttributes.Static,
10349 typeof (void), Type.EmptyTypes);
10350 mb.GetILGenerator ().Emit (OpCodes.Ret);
10351 eb.SetAddOnMethod (mb);
10353 eb = tb.DefineEvent ("OnFamilyStatic" + suffix,
10354 EventAttributes.None, typeof (EventHandler));
10355 mb = tb.DefineMethod ("add_OnFamilyStatic" + suffix,
10356 MethodAttributes.Family | MethodAttributes.Static,
10357 typeof (void), Type.EmptyTypes);
10358 mb.GetILGenerator ().Emit (OpCodes.Ret);
10359 eb.SetAddOnMethod (mb);
10361 eb = tb.DefineEvent ("OnFamANDAssemStatic" + suffix,
10362 EventAttributes.None, typeof (EventHandler));
10363 mb = tb.DefineMethod ("add_OnFamANDAssemStatic" + suffix,
10364 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10365 typeof (void), Type.EmptyTypes);
10366 mb.GetILGenerator ().Emit (OpCodes.Ret);
10367 eb.SetAddOnMethod (mb);
10369 eb = tb.DefineEvent ("OnFamORAssemStatic" + suffix,
10370 EventAttributes.None, typeof (EventHandler));
10371 mb = tb.DefineMethod ("add_OnFamORAssemStatic" + suffix,
10372 MethodAttributes.FamORAssem | MethodAttributes.Static,
10373 typeof (void), Type.EmptyTypes);
10374 mb.GetILGenerator ().Emit (OpCodes.Ret);
10375 eb.SetAddOnMethod (mb);
10377 eb = tb.DefineEvent ("OnPublicStatic" + suffix,
10378 EventAttributes.None, typeof (EventHandler));
10379 mb = tb.DefineMethod ("add_OnPublicStatic" + suffix,
10380 MethodAttributes.Public | MethodAttributes.Static,
10381 typeof (void), Type.EmptyTypes);
10382 mb.GetILGenerator ().Emit (OpCodes.Ret);
10383 eb.SetAddOnMethod (mb);
10385 eb = tb.DefineEvent ("OnAssemblyStatic" + suffix,
10386 EventAttributes.None, typeof (EventHandler));
10387 mb = tb.DefineMethod ("add_OnAssemblyStatic" + suffix,
10388 MethodAttributes.Family | MethodAttributes.Static,
10389 typeof (void), Type.EmptyTypes);
10390 mb.GetILGenerator ().Emit (OpCodes.Ret);
10391 eb.SetAddOnMethod (mb);
10394 static TypeBuilder Resolve1_Tb;
10395 static bool Resolve1_Called;
10397 public class Lookup<T>
10399 public static Type t = typeof(T);
10402 Assembly Resolve1 (object sender, ResolveEventArgs args) {
10403 Resolve1_Called = true;
10404 Resolve1_Tb.CreateType ();
10405 return Resolve1_Tb.Assembly;
10409 public void TypeResolveGenericInstances () {
10410 // Test that TypeResolve is called for generic instances (#483852)
10411 TypeBuilder tb1 = null;
10413 AppDomain.CurrentDomain.TypeResolve += Resolve1;
10415 tb1 = module.DefineType("Foo");
10417 FieldInfo field = TypeBuilder.GetField(typeof(Lookup<>).MakeGenericType(tb1), typeof(Lookup<>).GetField("t"));
10418 TypeBuilder tb2 = module.DefineType("Bar");
10419 ConstructorBuilder cb = tb2.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
10420 ILGenerator ilgen = cb.GetILGenerator();
10422 ilgen.Emit(OpCodes.Ldarg_0);
10423 ilgen.Emit(OpCodes.Call, tb2.BaseType.GetConstructor(Type.EmptyTypes));
10425 ilgen.Emit(OpCodes.Ldsfld, field);
10426 ilgen.Emit(OpCodes.Pop);
10427 ilgen.Emit(OpCodes.Ret);
10428 Activator.CreateInstance(tb2.CreateType());
10430 Assert.IsTrue (Resolve1_Called);
10434 public void CreateConcreteTypeWithAbstractMethod ()
10436 TypeBuilder tb = module.DefineType (genTypeName ());
10437 tb.DefineMethod("method", MethodAttributes.Abstract | MethodAttributes.Public, typeof (void), Type.EmptyTypes);
10440 Assert.Fail ("#1");
10441 } catch (InvalidOperationException) {}
10445 public void ConcreteTypeDontLeakGenericParamFromItSelf ()
10447 var tb = module.DefineType (genTypeName ());
10448 var gps = tb.DefineGenericParameters ("T");
10449 var mb = tb.DefineMethod ("m", MethodAttributes.Public | MethodAttributes.Static);
10450 mb.SetParameters (gps);
10451 mb.GetILGenerator ().Emit (OpCodes.Ret);
10453 var ti = tb.CreateType ();
10454 var mi = ti.GetMethod ("m");
10455 var arg0 = mi.GetParameters () [0].ParameterType;
10457 Assert.AreNotSame (arg0, gps [0], "#1");
10461 public void ConcreteTypeDontLeakGenericParamFromMethods ()
10463 var tb = module.DefineType (genTypeName ());
10464 var mb = tb.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Static);
10465 var gps = mb.DefineGenericParameters ("T");
10466 mb.SetParameters (gps);
10467 mb.GetILGenerator ().Emit (OpCodes.Ret);
10469 var ti = tb.CreateType ();
10470 var mi = ti.GetMethod ("m");
10471 var arg0 = mi.GetParameters () [0].ParameterType;
10473 Assert.AreNotSame (arg0, gps [0], "#1");
10477 public void DeclaringMethodReturnsNull ()
10479 TypeBuilder tb = module.DefineType (genTypeName ());
10480 Assert.IsNull (tb.DeclaringMethod, null, "#1");
10484 public void GenericParameterPositionReturns0 ()
10486 TypeBuilder tb = module.DefineType (genTypeName ());
10487 Assert.AreEqual (0, tb.GenericParameterPosition, "#1");
10491 public void GetGenericTypeDefinitionBehavior ()
10493 TypeBuilder tb = module.DefineType (genTypeName ());
10495 tb.GetGenericTypeDefinition ();
10496 Assert.Fail ("#1");
10497 } catch (InvalidOperationException) {}
10499 tb.DefineGenericParameters ("T");
10500 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#2");
10503 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#3");
10507 public void GetElementTypeNotSupported ()
10509 TypeBuilder tb = module.DefineType (genTypeName ());
10511 tb.GetElementType ();
10512 Assert.Fail ("#1");
10513 } catch (NotSupportedException) {}
10517 public void GenericParameterAttributesReturnsNone ()
10519 TypeBuilder tb = module.DefineType (genTypeName ());
10520 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#1");
10522 tb.DefineGenericParameters ("T");
10523 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#2");
10526 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#3");
10530 public void GetGenericArgumentsReturnsNullForNonGenericTypeBuilder ()
10532 TypeBuilder tb = module.DefineType (genTypeName ());
10533 Assert.IsNull (tb.GetGenericArguments (), "#1");
10536 public interface IFaceA {}
10537 public interface IFaceB : IFaceA {}
10539 public void GetInterfacesAfterCreate ()
10541 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type[] { typeof (IFaceB) });
10543 Type[] ifaces = tb.GetInterfaces ();
10544 Assert.AreEqual (1, ifaces.Length, "#1");
10545 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#2");
10548 ifaces = tb.GetInterfaces ();
10549 Assert.AreEqual (2, ifaces.Length, "#3");
10550 //Interfaces can come in any particular order
10551 if (ifaces [0] == typeof (IFaceB)) {
10552 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#4");
10553 Assert.AreEqual (typeof (IFaceA), ifaces [1], "#5");
10555 Assert.AreEqual (typeof (IFaceB), ifaces [1], "#4");
10556 Assert.AreEqual (typeof (IFaceA), ifaces [0], "#5");
10560 public interface MB_Iface
10565 public class MB_Impl : MB_Iface
10567 public virtual int Test () { return 1; }
10570 public void MethodOverrideBodyMustBelongToTypeBuilder ()
10572 TypeBuilder tb = module.DefineType (genTypeName ());
10573 MethodInfo md = typeof (MB_Iface).GetMethod("Test");
10574 MethodInfo md2 = typeof (MB_Impl).GetMethod("Test");
10576 tb.DefineMethodOverride (md, md2);
10577 Assert.Fail ("#1");
10578 } catch (ArgumentException) {}
10582 public void GetConstructorsThrowWhenIncomplete ()
10584 TypeBuilder tb = module.DefineType (genTypeName ());
10586 tb.GetConstructors (BindingFlags.Instance);
10587 Assert.Fail ("#1");
10588 } catch (NotSupportedException) { }
10591 Assert.IsNotNull (tb.GetConstructors (BindingFlags.Instance), "#2");
10595 public void GetEventsThrowWhenIncomplete ()
10597 TypeBuilder tb = module.DefineType (genTypeName ());
10599 tb.GetEvents (BindingFlags.Instance);
10600 Assert.Fail ("#1");
10601 } catch (NotSupportedException) { }
10604 Assert.IsNotNull (tb.GetEvents (BindingFlags.Instance), "#2");
10608 public void GetNestedTypeCreatedAfterTypeIsCreated ()
10610 TypeBuilder tb = module.DefineType (genTypeName ());
10611 TypeBuilder nested = tb.DefineNestedType ("Bar", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10613 Assert.IsNull (tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#1");
10614 Type res = nested.CreateType ();
10615 Assert.AreEqual (res, tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#2");
10617 TypeBuilder nested2 = tb.DefineNestedType ("Bar2", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10618 Assert.IsNull (tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#3");
10619 res = nested2.CreateType ();
10620 Assert.AreEqual (res, tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#4");
10625 public void IsDefinedThrowWhenIncomplete ()
10627 TypeBuilder tb = module.DefineType (genTypeName ());
10629 tb.IsDefined (typeof (string), true);
10630 Assert.Fail ("#1");
10631 } catch (NotSupportedException) { }
10634 Assert.IsNotNull (tb.IsDefined (typeof (string), true), "#2");
10637 [Test] //Bug #594728
10638 public void IsSubclassOfWorksIfSetParentIsCalledOnParent ()
10640 var tb_a = module.DefineType ("A", TypeAttributes.Public);
10641 var tb_b = module.DefineType ("B", TypeAttributes.Public);
10643 tb_b.SetParent (tb_a);
10644 tb_a.SetParent (typeof (Attribute));
10646 Assert.IsTrue (tb_b.IsSubclassOf (tb_a), "#1");
10647 Assert.IsTrue (tb_b.IsSubclassOf (typeof (Attribute)), "#2");
10648 Assert.IsFalse (tb_a.IsSubclassOf (tb_b), "#3");
10651 var a = tb_a.CreateType ();
10652 var b = tb_b.CreateType ();
10654 Assert.IsTrue (b.IsSubclassOf (a), "#4");
10655 Assert.IsTrue (b.IsSubclassOf (typeof (Attribute)), "#5");
10656 Assert.IsFalse (a.IsSubclassOf (b), "#6");
10660 public void DefinedDefaultConstructorWorksWithGenericBaseType ()
10662 AssemblyName assemblyName = new AssemblyName ("a");
10663 AssemblyBuilder ass = AppDomain.CurrentDomain.DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.RunAndSave);
10664 var mb = ass.DefineDynamicModule ("a.dll");
10666 var tb = mb.DefineType ("Base");
10667 tb.DefineGenericParameters ("F");
10669 var inst = tb.MakeGenericType (typeof (int));
10670 var tb2 = mb.DefineType ("Child", TypeAttributes.Public, inst);
10673 var res = tb2.CreateType ();
10675 Assert.IsNotNull (res, "#1");
10676 Assert.AreEqual (1, res.GetConstructors ().Length, "#2");
10680 * Tests for passing user types to Ref.Emit. Currently these only test
10681 * whenever the runtime code can handle them without crashing, since we
10682 * don't support user types yet.
10683 * These tests are disabled for windows since the MS runtime trips on them.
10686 [Category ("NotDotNet")] //Proper UT handling is a mono extension to SRE bugginess
10687 public void UserTypes () {
10688 TypeDelegator t = new TypeDelegator (typeof (int));
10692 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, t);
10698 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { t });
10705 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10706 tb.DefineField ("Foo", t, FieldAttributes.Public);
10712 /* Custom modifiers on fields */
10713 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10714 tb.DefineField ("Foo", typeof (int), new Type [] { t }, new Type [] { t }, FieldAttributes.Public);
10718 /* this is mono only
10720 UnmanagedMarshal m = UnmanagedMarshal.DefineCustom (t, "foo", "bar", Guid.Empty);
10721 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10722 FieldBuilder fb = tb.DefineField ("Foo", typeof (int), FieldAttributes.Public);
10730 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10731 tb.DefineProperty ("Foo", PropertyAttributes.None, t, null);
10737 /* Custom modifiers on properties */
10738 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10739 // FIXME: These seems to be ignored
10740 tb.DefineProperty ("Foo", PropertyAttributes.None, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10746 /* Method return types */
10747 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10748 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, t, null);
10749 mb.GetILGenerator ().Emit (OpCodes.Ret);
10755 /* Custom modifiers on method return types */
10756 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10757 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10758 mb.GetILGenerator ().Emit (OpCodes.Ret);
10764 /* Method parameters */
10765 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10766 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, typeof (int), new Type [] { t });
10767 mb.GetILGenerator ().Emit (OpCodes.Ret);
10773 /* Custom modifiers on method parameters */
10774 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10775 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 }});
10776 mb.GetILGenerator ().Emit (OpCodes.Ret);
10782 /* Ctor parameters */
10783 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10784 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { t });
10785 mb.GetILGenerator ().Emit (OpCodes.Ret);
10791 /* Custom modifiers on ctor parameters */
10792 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10793 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { typeof (int) }, new Type [][] { new Type [] { t }}, new Type[][] { new Type [] { t }});
10794 mb.GetILGenerator ().Emit (OpCodes.Ret);
10800 /* SignatureHelper arguments */
10801 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10802 sighelper.AddArgument (t, false);
10803 byte[] arr = sighelper.GetSignature ();
10808 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10809 sighelper.AddArgument (t, false);
10810 byte[] arr = sighelper.GetSignature ();
10815 /* Custom modifiers on SignatureHelper arguments */
10816 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10817 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10818 byte[] arr = sighelper.GetSignature ();
10823 /* Custom modifiers on SignatureHelper arguments */
10824 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10825 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10826 byte[] arr = sighelper.GetSignature ();
10830 /* Arguments to ILGenerator methods */
10833 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10834 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10835 ILGenerator ig = mb.GetILGenerator ();
10836 ig.Emit (OpCodes.Ldnull);
10837 ig.Emit (OpCodes.Castclass, t);
10838 ig.Emit (OpCodes.Pop);
10839 ig.Emit (OpCodes.Ret);
10845 /* DeclareLocal () */
10846 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10847 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10848 ILGenerator ig = mb.GetILGenerator ();
10849 ig.DeclareLocal (t);
10850 ig.Emit (OpCodes.Ret);
10856 /* BeginExceptionCatchBlock () */
10857 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10858 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10859 ILGenerator ig = mb.GetILGenerator ();
10860 ig.BeginExceptionBlock ();
10861 ig.BeginCatchBlock (t);
10862 ig.Emit (OpCodes.Ret);
10869 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10870 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10871 ILGenerator ig = mb.GetILGenerator ();
10872 ig.EmitCalli (OpCodes.Call, CallingConventions.Standard, typeof (void), new Type [] { t }, null);
10873 ig.Emit (OpCodes.Ret);
10881 public void CircularArrayType()
10883 var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess.RunAndSave);
10884 var moduleBuilder = assemblyBuilder.DefineDynamicModule("Test", "Test.dll", true);
10885 var typeBuilder = moduleBuilder.DefineType("Foo", TypeAttributes.Public);
10886 var fieldBuilder = typeBuilder.DefineField("Foos", typeBuilder.MakeArrayType(), FieldAttributes.Public);
10888 var fooType = typeBuilder.CreateType();
10889 Assert.AreSame(fooType.MakeArrayType(), fooType.GetField("Foos").FieldType);
10893 [Test] //Test for #422113
10894 [ExpectedException (typeof (TypeLoadException))]
10895 public void CreateInstanceOfIncompleteType ()
10897 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class, null, new Type[] { typeof (IComparable) });
10898 Type proxyType = tb.CreateType();
10899 Activator.CreateInstance(proxyType);
10902 [Test] //Test for #640780
10903 public void StaticMethodNotUsedInIfaceVtable ()
10905 TypeBuilder tb1 = module.DefineType("Interface", TypeAttributes.Interface | TypeAttributes.Abstract);
10906 tb1.DefineTypeInitializer().GetILGenerator().Emit(OpCodes.Ret);
10907 tb1.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Abstract);
10910 TypeBuilder tb2 = module.DefineType("Class", TypeAttributes.Sealed);
10911 tb2.AddInterfaceImplementation(tb1);
10912 tb2.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Virtual)
10913 .GetILGenerator().Emit(OpCodes.Ret);
10914 tb2.DefineDefaultConstructor(MethodAttributes.Public);
10916 Activator.CreateInstance(tb2.CreateType());
10919 [Test] //Test for #648391
10920 public void GetConstructorCheckCtorDeclaringType ()
10922 TypeBuilder myType = module.DefineType ("Sample", TypeAttributes.Public);
10923 string[] typeParamNames = { "TFirst" };
10924 GenericTypeParameterBuilder[] typeParams = myType.DefineGenericParameters (typeParamNames);
10925 var ctor = myType.DefineDefaultConstructor (MethodAttributes.Public);
10926 var ctori = TypeBuilder.GetConstructor (myType.MakeGenericType (typeof (int)), ctor);
10928 TypeBuilder.GetConstructor (myType.MakeGenericType (typeof (bool)), ctori);
10929 Assert.Fail ("#1");
10930 } catch (ArgumentException) {
10935 [Test] //Test for #649237
10936 public void GetFieldCheckFieldDeclaringType () {
10937 TypeBuilder myType = module.DefineType ("Sample", TypeAttributes.Public);
10938 myType.DefineGenericParameters ( "TFirst");
10939 TypeBuilder otherType = module.DefineType ("Sample2", TypeAttributes.Public);
10940 otherType.DefineGenericParameters ( "TFirst");
10942 var field = myType.DefineField ("field", typeof (object), FieldAttributes.Public);
10945 TypeBuilder.GetField (otherType.MakeGenericType (typeof (int)), field);
10946 Assert.Fail ("#1");
10947 } catch (ArgumentException) {
10953 public void TypeWithFieldRVAWorksUnderSgen () {
10954 AssemblyName an = new AssemblyName("MAIN");
10955 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(an,
10956 AssemblyBuilderAccess.Run, ".");
10957 ModuleBuilder mob = ab.DefineDynamicModule("MAIN");
10958 TypeBuilder tb = mob.DefineType("MAIN", TypeAttributes.Public |
10959 TypeAttributes.Sealed | TypeAttributes.Abstract |
10960 TypeAttributes.Class | TypeAttributes.BeforeFieldInit);
10962 byte[] source = new byte[] { 42 };
10963 FieldBuilder fb = tb.DefineInitializedData("A0", source, 0);
10965 MethodBuilder mb = tb.DefineMethod("EVAL", MethodAttributes.Static |
10966 MethodAttributes.Public, typeof(byte[]), new Type[] { });
10967 ILGenerator il = mb.GetILGenerator();
10969 il.Emit(OpCodes.Ldc_I4_1);
10970 il.Emit(OpCodes.Newarr, typeof(byte));
10971 il.Emit(OpCodes.Dup);
10972 il.Emit(OpCodes.Ldtoken, fb);
10973 il.Emit(OpCodes.Call, typeof(RuntimeHelpers).GetMethod("InitializeArray"));
10974 il.Emit(OpCodes.Ret);
10976 Type t = tb.CreateType();
10980 byte[] res = (byte[]) t.InvokeMember("EVAL", BindingFlags.Public |
10981 BindingFlags.Static | BindingFlags.InvokeMethod, null, null,
10984 Assert.AreEqual (42, res[0]);
10989 public void Ldfld_Regress_9531 () {
10990 Build<Example<int>> ();
10994 var base_class = typeof(T);
10996 var builder = module.DefineType(genTypeName (),
10997 TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
11000 var field = builder.BaseType.GetField("Field", BindingFlags.Instance | BindingFlags.Public);
11002 var cb = builder.DefineConstructor(
11003 MethodAttributes.Public | MethodAttributes.SpecialName,
11004 CallingConventions.HasThis,
11005 new[] { typeof(string) });
11007 var il = cb.GetILGenerator();
11011 throw new InvalidOperationException("wtf");
11014 il.Emit(OpCodes.Ldarg_0);
11015 il.Emit(OpCodes.Ldarg_1);
11016 il.Emit(OpCodes.Stfld, field);
11017 il.Emit(OpCodes.Ret);
11019 builder.CreateType();
11022 public class Example<T> {
11023 public string Field;
11028 public void Ldfld_Encoding_10122 () {
11029 Build2<Example<int>> ();
11032 void Build2<T> () {
11033 var base_class = typeof(T);
11035 string AssemblyName = genTypeName ();
11036 string AssemblyFileName = AssemblyName + ".dll";
11038 var assemblyBuilderAccess = AssemblyBuilderAccess.Save;
11039 var assemblyName = new AssemblyName(AssemblyName);
11040 var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, assemblyBuilderAccess);
11041 var moduleBuilder = assemblyBuilder.DefineDynamicModule(AssemblyName, AssemblyFileName);
11044 var builder = moduleBuilder.DefineType("Wrapped",
11045 TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
11048 var field = builder.BaseType.GetField("Field", BindingFlags.Instance | BindingFlags.Public);
11050 var cb = builder.DefineConstructor(
11051 MethodAttributes.Public | MethodAttributes.SpecialName,
11052 CallingConventions.HasThis,
11053 new[] { typeof(string) });
11055 var il = cb.GetILGenerator();
11059 throw new InvalidOperationException("wtf");
11062 il.Emit(OpCodes.Ldarg_0);
11063 il.Emit(OpCodes.Ldarg_1);
11064 il.Emit(OpCodes.Stfld, field);
11065 il.Emit(OpCodes.Ret);
11067 builder.CreateType();
11069 assemblyBuilder.Save (AssemblyFileName);
11071 var fromDisk = Assembly.Load (AssemblyName);
11072 Console.WriteLine (fromDisk);
11073 var t = fromDisk.GetType ("Wrapped");
11074 Activator.CreateInstance (t, new object[] { "string"});
11077 public interface IFace16096 {
11082 public void MemberRef_Caching_16096 () {
11083 var outer_class = module.DefineType(
11085 TypeAttributes.Class | TypeAttributes.Public,
11088 var builder = outer_class.DefineNestedType(
11090 TypeAttributes.Class | TypeAttributes.Public,
11093 builder.AddInterfaceImplementation (typeof (IFace16096));
11095 var ctor = builder.DefineDefaultConstructor (MethodAttributes.Public);
11096 var field = builder.DefineField ("Field", typeof (object), FieldAttributes.Public);
11097 var g_args = builder.DefineGenericParameters("b","a");
11098 var method = builder.DefineMethod ("Bar", MethodAttributes.Public | MethodAttributes.Virtual, typeof (object), new Type [0]);
11100 var il = method.GetILGenerator();
11101 il.Emit (OpCodes.Ldarg_0);
11102 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (builder.MakeGenericType (g_args), field));
11103 il.Emit (OpCodes.Pop);
11104 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (builder.MakeGenericType (g_args), ctor));
11105 il.Emit (OpCodes.Ret);
11107 var type = builder.CreateType ();
11109 /*Build a gshared instance. */
11110 var ginst = type.MakeGenericType (typeof (List<char>), typeof (object));
11111 var ins = (IFace16096)Activator.CreateInstance (ginst);
11113 /* This will trigger the runtime to cache the MEMBER_REF to the .ctor as it won't have a context. */
11114 var ins2 = ins.Bar ();
11115 Assert.IsNotNull (ins2);
11117 /* Build an unsharable version. */
11118 var ginst2 = type.MakeGenericType (typeof (List<char>), typeof (char));
11119 var ins3 = (IFace16096)Activator.CreateInstance (ginst2);
11121 /* This will trigger the runtime to use the cached version, which is wrong as it's an open type. */
11122 var ins4 = ins3.Bar ();
11123 Assert.IsNotNull (ins4);
11128 [ExpectedException (typeof (TypeLoadException))]
11129 public void PrivateIface ()
11131 TypeBuilder tb = module.DefineType ("Sample", TypeAttributes.Public, typeof (object), new[] { typeof (IFoo) });