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 (ASSEMBLY_NAME, ASSEMBLY_NAME + ".dll");
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);
1201 /* MOBILE special case MethodAccessException on reflection invokes and don't wrap them. */
1203 } catch (MethodAccessException mae) {
1204 Assert.IsNull (mae.InnerException, "#2");
1205 Assert.IsNotNull (mae.Message, "#3");
1206 Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#4:" + mae.Message);
1207 Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#4:" + mae.Message);
1210 } catch (TargetInvocationException ex) {
1211 Assert.AreEqual (typeof (TargetInvocationException), ex.GetType (), "#2");
1212 Assert.IsNotNull (ex.InnerException, "#3");
1213 Assert.IsNotNull (ex.Message, "#4");
1215 MethodAccessException mae = ex.InnerException as MethodAccessException;
1216 Assert.IsNotNull (mae, "#5");
1217 Assert.AreEqual (typeof (MethodAccessException), mae.GetType (), "#6");
1218 Assert.IsNull (mae.InnerException, "#7");
1219 Assert.IsNotNull (mae.Message, "#8");
1220 Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#9:" + mae.Message);
1221 Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#10:" + mae.Message);
1227 public void DefineDefaultConstructor_Parent_DefaultCtorMissing ()
1231 tb = module.DefineType (genTypeName ());
1232 ConstructorBuilder cb = tb.DefineConstructor (
1233 MethodAttributes.Public,
1234 CallingConventions.Standard,
1235 new Type [] { typeof (string) });
1236 cb.GetILGenerator ().Emit (OpCodes.Ret);
1237 Type parent_type = tb.CreateType ();
1239 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1242 tb.DefineDefaultConstructor (MethodAttributes.Public);
1244 } catch (NotSupportedException ex) {
1245 // Parent does not have a default constructor.
1246 // The default constructor must be explicitly defined
1247 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1248 Assert.IsNull (ex.InnerException, "#3");
1249 Assert.IsNotNull (ex.Message, "#4");
1254 public void DefineEvent_Name_NullChar ()
1256 TypeBuilder tb = module.DefineType (genTypeName ());
1259 tb.DefineEvent ("\0test", EventAttributes.None,
1261 Assert.Fail ("#A1");
1262 } catch (ArgumentException ex) {
1264 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1265 Assert.IsNull (ex.InnerException, "#A3");
1266 Assert.IsNotNull (ex.Message, "#A4");
1267 Assert.AreEqual ("name", ex.ParamName, "#A5");
1270 EventBuilder eb = tb.DefineEvent ("te\0st", EventAttributes.None,
1272 Assert.IsNotNull (eb, "#B1");
1276 public void TestDefineEvent ()
1278 TypeBuilder tb = module.DefineType (genTypeName ());
1280 // Test invalid arguments
1282 tb.DefineEvent (null, 0, typeof (int));
1283 Assert.Fail ("#A1");
1284 } catch (ArgumentNullException ex) {
1285 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1286 Assert.IsNull (ex.InnerException, "#A3");
1287 Assert.IsNotNull (ex.Message, "#A4");
1288 Assert.AreEqual ("name", ex.ParamName, "#A5");
1292 tb.DefineEvent ("FOO", 0, null);
1293 Assert.Fail ("#B1");
1294 } catch (ArgumentNullException ex) {
1295 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1296 Assert.IsNull (ex.InnerException, "#B3");
1297 Assert.IsNotNull (ex.Message, "#B4");
1298 Assert.AreEqual ("type", ex.ParamName, "#B5");
1302 tb.DefineEvent (string.Empty, 0, typeof (int));
1303 Assert.Fail ("#C1");
1304 } catch (ArgumentException ex) {
1305 // Empty name is not legal
1306 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1307 Assert.IsNull (ex.InnerException, "#C3");
1308 Assert.IsNotNull (ex.Message, "#C4");
1309 Assert.AreEqual ("name", ex.ParamName, "#C5");
1314 // Can not be called on a created type
1316 tb.DefineEvent ("BAR", 0, typeof (int));
1317 Assert.Fail ("#D1");
1318 } catch (InvalidOperationException ex) {
1319 // Unable to change after type has been created
1320 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1321 Assert.IsNull (ex.InnerException, "#D3");
1322 Assert.IsNotNull (ex.Message, "#D4");
1326 [Test] // DefineField (String, Type, FieldAttributes)
1327 public void DefineField1 ()
1329 TypeBuilder tb = module.DefineType (genTypeName ());
1331 // Check invalid arguments
1333 tb.DefineField (null, typeof (int), 0);
1334 Assert.Fail ("#A1");
1335 } catch (ArgumentNullException ex) {
1336 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1337 Assert.IsNull (ex.InnerException, "#A3");
1338 Assert.IsNotNull (ex.Message, "#A4");
1339 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1343 tb.DefineField (string.Empty, typeof (int), 0);
1344 Assert.Fail ("#B1");
1345 } catch (ArgumentException ex) {
1346 // Empty name is not legal
1347 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1348 Assert.IsNull (ex.InnerException, "#B3");
1349 Assert.IsNotNull (ex.Message, "#B4");
1350 Assert.AreEqual ("fieldName", ex.ParamName, "#B5");
1354 // Strangely, 'A<NULL>' is accepted...
1355 string name = String.Format ("{0}", (char) 0);
1356 tb.DefineField (name, typeof (int), 0);
1357 Assert.Fail ("#C1");
1358 } catch (ArgumentException ex) {
1360 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1361 Assert.IsNull (ex.InnerException, "#C3");
1362 Assert.IsNotNull (ex.Message, "#C4");
1363 Assert.AreEqual ("fieldName", ex.ParamName, "#C5");
1367 tb.DefineField ("A", typeof (void), 0);
1368 Assert.Fail ("#D1");
1369 } catch (ArgumentException ex) {
1370 // Bad field type in defining field
1371 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1372 Assert.IsNull (ex.InnerException, "#D3");
1373 Assert.IsNotNull (ex.Message, "#D4");
1374 Assert.IsNull (ex.ParamName, "#D5");
1379 // Can not be called on a created type
1381 tb.DefineField ("B", typeof (int), 0);
1382 Assert.Fail ("#E1");
1383 } catch (InvalidOperationException ex) {
1384 // Unable to change after type has been created
1385 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1386 Assert.IsNull (ex.InnerException, "#E3");
1387 Assert.IsNotNull (ex.Message, "#E4");
1391 [Test] // DefineField (String, Type, FieldAttributes)
1392 public void DefineField1_Name_NullChar ()
1394 TypeBuilder tb = module.DefineType (genTypeName ());
1397 tb.DefineField ("\0test", typeof (int),
1398 FieldAttributes.Private);
1399 Assert.Fail ("#A1");
1400 } catch (ArgumentException ex) {
1402 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1403 Assert.IsNull (ex.InnerException, "#A3");
1404 Assert.IsNotNull (ex.Message, "#A4");
1405 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1408 FieldBuilder fb = tb.DefineField ("te\0st", typeof (int),
1409 FieldAttributes.Private);
1410 Assert.IsNotNull (fb, "#B1");
1411 Assert.AreEqual ("te\0st", fb.Name, "#B2");
1414 [Test] // DefineField (String, Type, FieldAttributes)
1415 public void DefineField1_Type_Null ()
1417 TypeBuilder tb = module.DefineType (genTypeName ());
1420 tb.DefineField ("test", (Type) null,
1421 FieldAttributes.Private);
1423 } catch (ArgumentNullException ex) {
1424 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1425 Assert.IsNull (ex.InnerException, "#3");
1426 Assert.IsNotNull (ex.Message, "#4");
1427 Assert.AreEqual ("type", ex.ParamName, "#5");
1431 [Test] // DefineField (String, Type, Type [], Type [], FieldAttributes)
1432 public void DefineField2_Type_Null ()
1434 TypeBuilder tb = module.DefineType (genTypeName ());
1437 tb.DefineField ("test", (Type) null, Type.EmptyTypes,
1438 Type.EmptyTypes, FieldAttributes.Private);
1440 } catch (ArgumentNullException ex) {
1441 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1442 Assert.IsNull (ex.InnerException, "#3");
1443 Assert.IsNotNull (ex.Message, "#4");
1444 Assert.AreEqual ("type", ex.ParamName, "#5");
1449 public void TestDefineInitializedData ()
1451 TypeBuilder tb = module.DefineType (genTypeName ());
1453 // Check invalid arguments
1455 tb.DefineInitializedData (null, new byte [1], 0);
1456 Assert.Fail ("#A1");
1457 } catch (ArgumentNullException ex) {
1458 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1459 Assert.IsNull (ex.InnerException, "#A3");
1460 Assert.IsNotNull (ex.Message, "#A4");
1461 Assert.AreEqual ("name", ex.ParamName, "#A5");
1465 tb.DefineInitializedData ("FOO", null, 0);
1466 Assert.Fail ("#B1");
1467 } catch (ArgumentNullException ex) {
1468 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1469 Assert.IsNull (ex.InnerException, "#B3");
1470 Assert.IsNotNull (ex.Message, "#B4");
1471 Assert.AreEqual ("data", ex.ParamName, "#B5");
1475 tb.DefineInitializedData (string.Empty, new byte [1], 0);
1476 Assert.Fail ("#C1");
1477 } catch (ArgumentException ex) {
1478 // Empty name is not legal
1479 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1480 Assert.IsNull (ex.InnerException, "#C3");
1481 Assert.IsNotNull (ex.Message, "#C4");
1482 Assert.AreEqual ("name", ex.ParamName, "#C5");
1485 // The size of the data is less than or equal to zero ???
1487 tb.DefineInitializedData ("BAR", new byte [0], 0);
1488 Assert.Fail ("#D1");
1489 } catch (ArgumentException ex) {
1490 // Data size must be > 0 and < 0x3f0000
1491 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1492 Assert.IsNull (ex.InnerException, "#D3");
1493 Assert.IsNotNull (ex.Message, "#D4");
1494 Assert.IsNull (ex.ParamName, "#D5");
1498 string name = String.Format ("{0}", (char) 0);
1499 tb.DefineInitializedData (name, new byte [1], 0);
1500 Assert.Fail ("#E1");
1501 } catch (ArgumentException ex) {
1503 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#E2");
1504 Assert.IsNull (ex.InnerException, "#E3");
1505 Assert.IsNotNull (ex.Message, "#E4");
1506 Assert.AreEqual ("fieldName", ex.ParamName, "#E5");
1511 // Can not be called on a created type, altough the MSDN docs does not mention this
1513 tb.DefineInitializedData ("BAR2", new byte [1], 0);
1514 Assert.Fail ("#F1");
1515 } catch (InvalidOperationException ex) {
1516 // Unable to change after type has been created
1517 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
1518 Assert.IsNull (ex.InnerException, "#F3");
1519 Assert.IsNotNull (ex.Message, "#F4");
1524 public void DefineUninitializedDataInvalidArgs ()
1526 TypeBuilder tb = module.DefineType (genTypeName ());
1529 tb.DefineUninitializedData (null, 1, 0);
1530 Assert.Fail ("#A1");
1531 } catch (ArgumentNullException ex) {
1532 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1533 Assert.IsNull (ex.InnerException, "#A3");
1534 Assert.IsNotNull (ex.Message, "#A4");
1535 Assert.AreEqual ("name", ex.ParamName, "#A5");
1539 tb.DefineUninitializedData (string.Empty, 1, 0);
1540 Assert.Fail ("#B1");
1541 } catch (ArgumentException ex) {
1542 // Empty name is not legal
1543 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1544 Assert.IsNull (ex.InnerException, "#B3");
1545 Assert.IsNotNull (ex.Message, "#B4");
1546 Assert.AreEqual ("name", ex.ParamName, "#B5");
1549 // The size of the data is less than or equal to zero ???
1551 tb.DefineUninitializedData ("BAR", 0, 0);
1552 Assert.Fail ("#C1");
1553 } catch (ArgumentException ex) {
1554 // Data size must be > 0 and < 0x3f0000
1555 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1556 Assert.IsNull (ex.InnerException, "#C3");
1557 Assert.IsNotNull (ex.Message, "#C4");
1558 Assert.IsNull (ex.ParamName, "#C5");
1562 string name = String.Format ("{0}", (char) 0);
1563 tb.DefineUninitializedData (name, 1, 0);
1564 Assert.Fail ("#D1");
1565 } catch (ArgumentException ex) {
1567 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1568 Assert.IsNull (ex.InnerException, "#D3");
1569 Assert.IsNotNull (ex.Message, "#D4");
1570 Assert.AreEqual ("fieldName", ex.ParamName, "#D5");
1575 public void DefineUninitializedDataAlreadyCreated ()
1577 TypeBuilder tb = module.DefineType (genTypeName ());
1580 tb.DefineUninitializedData ("BAR2", 1, 0);
1582 } catch (InvalidOperationException ex) {
1583 // Unable to change after type has been created
1584 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1585 Assert.IsNull (ex.InnerException, "#3");
1586 Assert.IsNotNull (ex.Message, "#4");
1591 public void DefineUninitializedData ()
1593 TypeBuilder tb = module.DefineType (genTypeName ());
1595 tb.DefineUninitializedData ("foo", 4, FieldAttributes.Public);
1597 Type t = tb.CreateType ();
1599 object o = Activator.CreateInstance (t);
1601 FieldInfo fi = t.GetField ("foo");
1603 object fieldVal = fi.GetValue (o);
1605 IntPtr ptr = Marshal.AllocHGlobal (4);
1606 Marshal.StructureToPtr (fieldVal, ptr, true);
1607 Marshal.FreeHGlobal (ptr);
1611 public void DefineMethod_Name_NullChar ()
1613 TypeBuilder tb = module.DefineType (genTypeName ());
1615 tb.DefineMethod ("\0test", MethodAttributes.Private,
1616 typeof (string), Type.EmptyTypes);
1617 Assert.Fail ("#A1");
1618 } catch (ArgumentException ex) {
1620 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1621 Assert.IsNull (ex.InnerException, "#A3");
1622 Assert.IsNotNull (ex.Message, "#A4");
1623 Assert.AreEqual ("name", ex.ParamName, "#A5");
1626 MethodBuilder mb = tb.DefineMethod ("te\0st", MethodAttributes.Private,
1627 typeof (string), Type.EmptyTypes);
1628 Assert.IsNotNull (mb, "#B1");
1629 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1633 public void TestDefineMethod ()
1635 TypeBuilder tb = module.DefineType (genTypeName ());
1637 // Check invalid arguments
1639 tb.DefineMethod (null, 0, null, null);
1640 Assert.Fail ("#A1");
1641 } catch (ArgumentNullException ex) {
1642 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1643 Assert.IsNull (ex.InnerException, "#A3");
1644 Assert.IsNotNull (ex.Message, "#A4");
1645 Assert.AreEqual ("name", ex.ParamName, "#A5");
1649 tb.DefineMethod (string.Empty, 0, null, null);
1650 Assert.Fail ("#B1");
1651 } catch (ArgumentException ex) {
1652 // Empty name is not legal
1653 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1654 Assert.IsNull (ex.InnerException, "#B3");
1655 Assert.IsNotNull (ex.Message, "#B4");
1656 Assert.AreEqual ("name", ex.ParamName, "#B5");
1659 // Check non-virtual methods on an interface
1660 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1662 tb2.DefineMethod ("FOO", MethodAttributes.Abstract, null, null);
1663 Assert.Fail ("#C1");
1664 } catch (ArgumentException ex) {
1665 // Interface method must be abstract and virtual
1666 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1667 Assert.IsNull (ex.InnerException, "#C3");
1668 Assert.IsNotNull (ex.Message, "#C4");
1669 Assert.IsNull (ex.ParamName, "#C5");
1672 // Check static methods on an interface
1673 tb2.DefineMethod ("BAR", MethodAttributes.Public | MethodAttributes.Static,
1678 // Can not be called on a created type
1680 tb.DefineMethod ("bar", 0, null, null);
1681 Assert.Fail ("#D1");
1682 } catch (InvalidOperationException ex) {
1683 // Unable to change after type has been created
1684 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1685 Assert.IsNull (ex.InnerException, "#D3");
1686 Assert.IsNotNull (ex.Message, "#D4");
1690 [Test] // bug #327484
1691 [Category ("NotWorking")]
1692 public void TestDefineMethod_Abstract ()
1694 TypeBuilder tb = module.DefineType (genTypeName ());
1695 tb.DefineMethod ("Run", MethodAttributes.Public |
1696 MethodAttributes.Abstract | MethodAttributes.Virtual,
1697 typeof (void), Type.EmptyTypes);
1701 Assert.Fail ("#A1");
1702 } catch (InvalidOperationException ex) {
1703 // Type must be declared abstract if any of its
1704 // methods are abstract
1705 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1706 Assert.IsNull (ex.InnerException, "#A3");
1707 Assert.IsNotNull (ex.Message, "#A4");
1710 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract);
1711 tb.DefineMethod ("Run", MethodAttributes.Public |
1712 MethodAttributes.Abstract, typeof (void),
1717 Assert.Fail ("#B1");
1718 } catch (TypeLoadException ex) {
1719 // Non-virtual abstract method
1720 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B2");
1721 Assert.IsNull (ex.InnerException, "#B3");
1722 Assert.IsNotNull (ex.Message, "#B4");
1725 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract |
1726 TypeAttributes.Public);
1727 tb.DefineMethod ("Run", MethodAttributes.Public |
1728 MethodAttributes.Abstract | MethodAttributes.Virtual,
1729 typeof (void), Type.EmptyTypes);
1730 Type emittedType = tb.CreateType ();
1732 MethodInfo mi1 = emittedType.GetMethod ("Run");
1733 Assert.IsNotNull (mi1, "#C1");
1734 Assert.IsTrue (mi1.IsAbstract, "#C2");
1736 MethodInfo mi2 = tb.GetMethod ("Run");
1737 Assert.IsNotNull (mi2, "#D1");
1738 Assert.IsTrue (mi2.IsAbstract, "#D2");
1741 // TODO: DefineMethodOverride
1744 public void TestDefineNestedType ()
1746 TypeBuilder tb = module.DefineType (genTypeName ());
1748 // Check invalid arguments
1750 tb.DefineNestedType (null);
1751 Assert.Fail ("#A1");
1752 } catch (ArgumentNullException ex) {
1753 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1754 Assert.IsNull (ex.InnerException, "#A3");
1755 Assert.IsNotNull (ex.Message, "#A4");
1756 Assert.AreEqual ("fullname", ex.ParamName, "#A5");
1760 tb.DefineNestedType (string.Empty);
1761 Assert.Fail ("#B1");
1762 } catch (ArgumentException ex) {
1763 // Empty name is not legal
1764 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1765 Assert.IsNull (ex.InnerException, "#B3");
1766 Assert.IsNotNull (ex.Message, "#B4");
1767 Assert.AreEqual ("fullname", ex.ParamName, "#B5");
1771 tb.DefineNestedType (nullName ());
1772 Assert.Fail ("#C1");
1773 } catch (ArgumentException ex) {
1775 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1776 Assert.IsNull (ex.InnerException, "#C3");
1777 Assert.IsNotNull (ex.Message, "#C4");
1778 Assert.AreEqual ("fullname", ex.ParamName, "#C5");
1781 // If I fix the code so this works then mcs breaks -> how can mcs
1782 // works under MS .NET in the first place ???
1785 tb.DefineNestedType ("AA", TypeAttributes.Public, null, null);
1786 Fail ("Nested visibility must be specified.");
1788 catch (ArgumentException) {
1793 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1795 Assert.Fail ("#D1");
1796 } catch (ArgumentNullException ex) {
1797 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#D2");
1798 Assert.IsNull (ex.InnerException, "#D3");
1799 Assert.IsNotNull (ex.Message, "#D4");
1800 Assert.AreEqual ("interfaces", ex.ParamName, "#D5");
1803 // I think this should reject non-interfaces, but it does not
1804 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1805 new Type [1] { typeof (object) });
1807 // Normal invocation
1808 tb.DefineNestedType ("Nest");
1812 // According to the MSDN docs, this cannnot be called after the type
1813 // is created, but it works.
1814 tb.DefineNestedType ("Nest2");
1816 // According to the MSDN docs, a Sealed class can't contain nested
1817 // types, but this is not true
1818 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
1819 tb2.DefineNestedType ("AA");
1821 // According to the MSDN docs, interfaces can only contain interfaces,
1822 // but this is not true
1823 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1825 tb3.DefineNestedType ("AA");
1827 // Check shorter versions
1829 TypeBuilder nested = tb.DefineNestedType ("N1");
1831 Assert.AreEqual ("N1", nested.Name, "#E1");
1832 Assert.AreEqual (typeof (object), nested.BaseType, "#E2");
1833 Assert.AreEqual (TypeAttributes.NestedPrivate, nested.Attributes, "#E3");
1834 Assert.AreEqual (0, nested.GetInterfaces ().Length, "#E4");
1841 public void NestedTypeSave () {
1842 var tb = module.DefineType (genTypeName ());
1844 var tbuilder = tb.DefineNestedType ("Test.CodeGen", TypeAttributes.Public | TypeAttributes.Class);
1845 var entryp = tbuilder.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, typeof (void), null);
1846 var ilg = entryp.GetILGenerator (128);
1847 ilg.Emit (OpCodes.Ldtoken, tb);
1848 ilg.Emit (OpCodes.Pop);
1849 ilg.Emit (OpCodes.Ret);
1851 tbuilder.CreateType ();
1854 assembly.Save (ASSEMBLY_NAME + ".dll");
1858 public void DefinePInvokeMethod_Name_NullChar ()
1860 TypeBuilder tb = module.DefineType (genTypeName ());
1862 tb.DefinePInvokeMethod ("\0test", "B", "C",
1863 MethodAttributes.Private, CallingConventions.Standard,
1864 typeof (string),Type.EmptyTypes, CallingConvention.Cdecl,
1866 Assert.Fail ("#A1");
1867 } catch (ArgumentException ex) {
1869 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1870 Assert.IsNull (ex.InnerException, "#A3");
1871 Assert.IsNotNull (ex.Message, "#A4");
1872 Assert.AreEqual ("name", ex.ParamName, "#A5");
1875 MethodBuilder mb = tb.DefinePInvokeMethod ("te\0st", "B", "C",
1876 MethodAttributes.Private, CallingConventions.Standard,
1877 typeof (string), Type.EmptyTypes, CallingConvention.Cdecl,
1879 Assert.IsNotNull (mb, "#B1");
1880 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1884 public void TestDefinePInvokeMethod ()
1886 TypeBuilder tb = module.DefineType (genTypeName ());
1888 tb.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1890 // Try invalid parameters
1892 tb.DefinePInvokeMethod (null, "B", "C", 0, 0, null, null, 0, 0);
1893 Assert.Fail ("#A1");
1894 } catch (ArgumentNullException ex) {
1895 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1896 Assert.IsNull (ex.InnerException, "#A3");
1897 Assert.IsNotNull (ex.Message, "#A4");
1898 Assert.AreEqual ("name", ex.ParamName, "#A5");
1902 // Try invalid attributes
1904 tb.DefinePInvokeMethod ("A2", "B", "C", MethodAttributes.Abstract, 0, null, null, 0, 0);
1905 Assert.Fail ("#B1");
1906 } catch (ArgumentException ex) {
1907 // PInvoke methods must be static and native and
1908 // cannot be abstract
1909 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1910 Assert.IsNull (ex.InnerException, "#B3");
1911 Assert.IsNotNull (ex.Message, "#B4");
1912 Assert.IsNull (ex.ParamName, "#B5");
1915 // Try an interface parent
1916 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1919 tb2.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1920 Assert.Fail ("#C1");
1921 } catch (ArgumentException ex) {
1922 // PInvoke methods cannot exist on interfaces
1923 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1924 Assert.IsNull (ex.InnerException, "#B3");
1925 Assert.IsNotNull (ex.Message, "#B4");
1926 Assert.IsNull (ex.ParamName, "#B5");
1931 public void DefineProperty_Name_NullChar ()
1933 TypeBuilder tb = module.DefineType (genTypeName ());
1936 tb.DefineProperty ("\0test", 0, typeof (string), Type.EmptyTypes);
1937 Assert.Fail ("#A1");
1938 } catch (ArgumentException ex) {
1940 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1941 Assert.IsNull (ex.InnerException, "#A3");
1942 Assert.IsNotNull (ex.Message, "#A4");
1943 Assert.AreEqual ("name", ex.ParamName, "#A5");
1946 PropertyBuilder pb = tb.DefineProperty ("te\0st", 0,
1947 typeof (string), Type.EmptyTypes);
1948 Assert.IsNotNull (pb, "#B1");
1949 Assert.AreEqual ("te\0st", pb.Name, "#B2");
1953 public void DefineProperty_ParameterTypes_ItemNull ()
1955 TypeBuilder tb = module.DefineType (genTypeName ());
1958 tb.DefineProperty ("A", 0, typeof (string), new Type [1]);
1960 } catch (ArgumentNullException ex) {
1961 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1962 Assert.IsNull (ex.InnerException, "#3");
1963 Assert.IsNotNull (ex.Message, "#4");
1968 public void DefineProperty_ReturnType_Null ()
1970 TypeBuilder tb = module.DefineType (genTypeName ());
1971 tb.DefineProperty ("A", 0, null, Type.EmptyTypes);
1975 public void GetMethod_WorksWithTypeBuilderParameter () {
1976 TypeBuilder tb = module.DefineType (genTypeName ());
1977 var garg = tb.DefineGenericParameters ("T") [0];
1978 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
1980 var mi = TypeBuilder.GetMethod (tb, mb);
1981 var decl = mi.DeclaringType;
1983 Assert.IsTrue (decl.IsGenericType, "#1");
1984 Assert.IsFalse (decl.IsGenericTypeDefinition, "#2");
1985 Assert.AreEqual (tb, decl.GetGenericTypeDefinition (), "#3");
1986 Assert.AreEqual (garg, decl.GetGenericArguments () [0], "#4");
1990 public void GetConstructor_FailWithTypeBuilderParameter () {
1991 TypeBuilder tb = module.DefineType (genTypeName ());
1992 var garg = tb.DefineGenericParameters ("T") [0];
1993 var cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
1996 TypeBuilder.GetConstructor (tb, cb);
1998 } catch (ArgumentException ex) {
1999 Assert.AreEqual ("type", ex.ParamName, "#2");
2004 public void GetField_FailWithTypeBuilderParameter () {
2005 TypeBuilder tb = module.DefineType (genTypeName ());
2006 var garg = tb.DefineGenericParameters ("T") [0];
2007 var fb = tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
2010 TypeBuilder.GetField (tb, fb);
2012 } catch (ArgumentException ex) {
2013 Assert.AreEqual ("type", ex.ParamName, "#2");
2018 public void GetMethod_RejectMethodFromInflatedTypeBuilder () {
2019 TypeBuilder tb = module.DefineType (genTypeName ());
2020 tb.DefineGenericParameters ("T");
2021 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2023 Type ginst = tb.MakeGenericType (typeof (int));
2025 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2027 TypeBuilder.GetMethod (ginst, mi);
2029 } catch (ArgumentException ex) {
2030 Assert.AreEqual ("method", ex.ParamName, "#5");
2035 public void GetMethod_WorkWithInstancesOfCreatedTypeBuilder () {
2036 TypeBuilder tb = module.DefineType (genTypeName ());
2037 tb.DefineGenericParameters ("T");
2038 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2039 ILGenerator ig = mb.GetILGenerator ();
2040 ig.Emit (OpCodes.Ret);
2044 MethodInfo mi = TypeBuilder.GetMethod (tb.MakeGenericType (typeof (int)), mb);
2045 Assert.IsNotNull (mi);
2049 [Category ("NotDotNet")]
2050 [Category ("NotWorking")]
2051 public void GetMethod_AcceptMethodFromInflatedTypeBuilder_UnderCompilerContext () {
2052 AssemblyName assemblyName = new AssemblyName ();
2053 assemblyName.Name = ASSEMBLY_NAME;
2056 Thread.GetDomain ().DefineDynamicAssembly (
2057 assemblyName, AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800, Path.GetTempPath ());
2059 module = assembly.DefineDynamicModule ("module1");
2061 TypeBuilder tb = module.DefineType (genTypeName ());
2062 tb.DefineGenericParameters ("T");
2063 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2065 Type ginst = tb.MakeGenericType (typeof (int));
2067 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2070 TypeBuilder.GetMethod (ginst, mi);
2071 } catch (ArgumentException ex) {
2078 // Test that changes made to the method builder after a call to GetMethod ()
2080 public void TestGetMethod ()
2082 TypeBuilder tb = module.DefineType (genTypeName ());
2083 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2085 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2087 ig = cb.GetILGenerator ();
2088 ig.Emit (OpCodes.Ret);
2090 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2092 // Create a method builder but do not emit IL yet
2093 MethodBuilder mb1 = tb.DefineMethod ("create", MethodAttributes.Public|MethodAttributes.Static, fooOfT, Type.EmptyTypes);
2095 Type t = tb.MakeGenericType (typeof (int));
2097 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2099 ig = mb.GetILGenerator ();
2100 ig.Emit (OpCodes.Call, TypeBuilder.GetMethod (t, mb1));
2101 ig.Emit (OpCodes.Ret);
2103 // Finish the method
2104 ig = mb1.GetILGenerator ();
2105 ig.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (fooOfT, cb));
2106 ig.Emit (OpCodes.Ret);
2108 Type t2 = tb.CreateType ();
2110 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2114 public void TestGetConstructor ()
2116 TypeBuilder tb = module.DefineType (genTypeName ());
2117 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2119 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2122 Type t = tb.MakeGenericType (typeof (int));
2124 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2126 ig = mb.GetILGenerator ();
2128 ConstructorInfo ci = TypeBuilder.GetConstructor (t, cb);
2130 ig.Emit (OpCodes.Newobj, ci);
2131 ig.Emit (OpCodes.Ret);
2133 // Finish the ctorbuilder
2134 ig = cb.GetILGenerator ();
2135 ig.Emit(OpCodes.Ldarg_0);
2136 ig.Emit(OpCodes.Call, tb.BaseType.GetConstructor(Type.EmptyTypes));
2137 ig.Emit (OpCodes.Ret);
2139 Type t2 = tb.CreateType ();
2141 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2145 [ExpectedException (typeof (ArgumentException))]
2146 public void Static_GetConstructor_TypeNull ()
2148 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2149 // null is non-generic (from exception message)
2150 TypeBuilder.GetConstructor (null, ci);
2154 [ExpectedException (typeof (ArgumentException))]
2155 public void Static_GetConstructor_TypeGeneric ()
2157 Type t = typeof (List<>).MakeGenericType (typeof (int));
2158 ConstructorInfo ci = typeof (object).GetConstructor (Type.EmptyTypes);
2159 // type is not 'TypeBuilder' (from exception message)
2160 TypeBuilder.GetConstructor (t, ci);
2164 public void Static_GetConstructor_TypeBuilderGeneric_ConstructorInfoNull ()
2166 TypeBuilder tb = module.DefineType ("XXX");
2167 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2168 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2170 TypeBuilder.GetConstructor (fooOfT, null);
2171 Assert.Fail ("Expected NullReferenceException");
2173 catch (NullReferenceException) {
2178 public void CreateTypeThrowsForMethodsWithBadLabels ()
2180 TypeBuilder tb = module.DefineType (genTypeName ());
2182 MethodBuilder mb = tb.DefineMethod("F", MethodAttributes.Public, typeof(string), null);
2183 ILGenerator il_gen = mb.GetILGenerator ();
2184 il_gen.DefineLabel ();
2185 il_gen.Emit (OpCodes.Leave, new Label ());
2189 } catch (ArgumentException) {}
2193 [Category ("NotWorking")]
2194 public void TestIsDefinedIncomplete ()
2196 TypeBuilder tb = module.DefineType (genTypeName ());
2198 tb.IsDefined (typeof (int), true);
2200 } catch (NotSupportedException ex) {
2201 // The invoked member is not supported in a
2203 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2204 Assert.IsNull (ex.InnerException, "#3");
2205 Assert.IsNotNull (ex.Message, "#4");
2210 public void TestIsDefinedComplete ()
2212 TypeBuilder tb = module.DefineType (genTypeName ());
2214 ConstructorInfo obsoleteCtor = typeof (ObsoleteAttribute).GetConstructor (
2215 new Type [] { typeof (string) });
2217 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (obsoleteCtor,
2218 new object [] { "obsolete message" }, new FieldInfo [0], new object [0]);
2220 tb.SetCustomAttribute (caBuilder);
2222 Assert.IsTrue (tb.IsDefined (typeof (ObsoleteAttribute), false));
2226 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=293659
2227 public void IsDefined_AttributeType_Null ()
2229 TypeBuilder tb = module.DefineType (genTypeName ());
2233 tb.IsDefined ((Type) null, false);
2235 } catch (ArgumentNullException ex) {
2236 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2237 Assert.IsNull (ex.InnerException, "#3");
2238 Assert.IsNotNull (ex.Message, "#4");
2239 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
2243 [Test] // GetConstructor (Type [])
2244 public void GetConstructor1_Incomplete ()
2246 TypeBuilder tb = module.DefineType (genTypeName ());
2247 ConstructorBuilder cb = tb.DefineConstructor (
2248 MethodAttributes.Public,
2249 CallingConventions.Standard,
2251 cb.GetILGenerator ().Emit (OpCodes.Ret);
2254 tb.GetConstructor (Type.EmptyTypes);
2256 } catch (NotSupportedException ex) {
2257 // The invoked member is not supported in a
2259 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2260 Assert.IsNull (ex.InnerException, "#3");
2261 Assert.IsNotNull (ex.Message, "#4");
2265 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2266 public void GetConstructor2_Complete ()
2269 ConstructorInfo ctor;
2271 TypeBuilder redType = module.DefineType (genTypeName (),
2272 TypeAttributes.Public);
2273 CreateMembers (redType, "Red", true);
2275 TypeBuilder greenType = module.DefineType (genTypeName (),
2276 TypeAttributes.Public, redType);
2277 CreateMembers (greenType, "Green", false);
2278 ConstructorBuilder cb = greenType.DefineConstructor (
2279 MethodAttributes.Public,
2280 CallingConventions.Standard,
2282 cb.GetILGenerator ().Emit (OpCodes.Ret);
2284 redType.CreateType ();
2285 greenType.CreateType ();
2287 flags = BindingFlags.Instance | BindingFlags.NonPublic;
2289 ctor = greenType.GetConstructor (flags, null,
2290 new Type [] { typeof (int), typeof (int) },
2291 new ParameterModifier [0]);
2292 Assert.IsNull (ctor, "#A1");
2294 ctor = greenType.GetConstructor (flags, null,
2295 new Type [] { typeof (string) },
2296 new ParameterModifier [0]);
2297 Assert.IsNull (ctor, "#A2");
2299 ctor = greenType.GetConstructor (flags, null,
2300 new Type [] { typeof (string), typeof (string) },
2301 new ParameterModifier [0]);
2302 Assert.IsNull (ctor, "#A3");
2304 ctor = greenType.GetConstructor (flags, null,
2305 new Type [] { typeof (int) },
2306 new ParameterModifier [0]);
2307 Assert.IsNull (ctor, "#A4");
2309 ctor = greenType.GetConstructor (flags, null,
2310 new Type [] { typeof (int), typeof (bool) },
2311 new ParameterModifier [0]);
2312 Assert.IsNull (ctor, "#A5");
2314 ctor = greenType.GetConstructor (flags, null,
2315 new Type [] { typeof (string), typeof (int) },
2316 new ParameterModifier [0]);
2317 Assert.IsNull (ctor, "#A6");
2319 ctor = greenType.GetConstructor (flags, null,
2321 new ParameterModifier [0]);
2322 Assert.IsNull (ctor, "#A7");
2324 ctor = redType.GetConstructor (flags, null,
2325 new Type [] { typeof (int), typeof (int) },
2326 new ParameterModifier [0]);
2327 Assert.IsNotNull (ctor, "#A8a");
2328 Assert.IsTrue (ctor.IsPrivate, "#A8b");
2329 Assert.IsFalse (ctor.IsStatic, "#A8c");
2330 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A8d");
2331 Assert.IsFalse (ctor is ConstructorBuilder, "#A8e");
2333 ctor = redType.GetConstructor (flags, null,
2334 new Type [] { typeof (string) },
2335 new ParameterModifier [0]);
2336 Assert.IsNotNull (ctor, "#A9a");
2337 Assert.IsTrue (ctor.IsFamily, "#A9b");
2338 Assert.IsFalse (ctor.IsStatic, "#A9c");
2339 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A9d");
2340 Assert.IsFalse (ctor is ConstructorBuilder, "#A9e");
2342 ctor = redType.GetConstructor (flags, null,
2343 new Type [] { typeof (string), typeof (string) },
2344 new ParameterModifier [0]);
2345 Assert.IsNotNull (ctor, "#A10a");
2346 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#A10b");
2347 Assert.IsFalse (ctor.IsStatic, "#A10c");
2348 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A10d");
2349 Assert.IsFalse (ctor is ConstructorBuilder, "#A10e");
2351 ctor = redType.GetConstructor (flags, null,
2352 new Type [] { typeof (int) },
2353 new ParameterModifier [0]);
2354 Assert.IsNotNull (ctor, "#A11a");
2355 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#A11b");
2356 Assert.IsFalse (ctor.IsStatic, "#A11c");
2357 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A11d");
2358 Assert.IsFalse (ctor is ConstructorBuilder, "#A11e");
2360 ctor = redType.GetConstructor (flags, null,
2361 new Type [] { typeof (int), typeof (bool) },
2362 new ParameterModifier [0]);
2363 Assert.IsNull (ctor, "#A12");
2365 ctor = redType.GetConstructor (flags, null,
2366 new Type [] { typeof (string), typeof (int) },
2367 new ParameterModifier [0]);
2368 Assert.IsNotNull (ctor, "#A13a");
2369 Assert.IsTrue (ctor.IsAssembly, "#A13b");
2370 Assert.IsFalse (ctor.IsStatic, "#A13c");
2371 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A13d");
2372 Assert.IsFalse (ctor is ConstructorBuilder, "#A13e");
2374 ctor = redType.GetConstructor (flags, null,
2376 new ParameterModifier [0]);
2377 Assert.IsNull (ctor, "#A14");
2379 flags = BindingFlags.Instance | BindingFlags.Public;
2381 ctor = greenType.GetConstructor (flags, null,
2382 new Type [] { typeof (int), typeof (int) },
2383 new ParameterModifier [0]);
2384 Assert.IsNull (ctor, "#B1");
2386 ctor = greenType.GetConstructor (flags, null,
2387 new Type [] { typeof (string) },
2388 new ParameterModifier [0]);
2389 Assert.IsNull (ctor, "#B2");
2391 ctor = greenType.GetConstructor (flags, null,
2392 new Type [] { typeof (string), typeof (string) },
2393 new ParameterModifier [0]);
2394 Assert.IsNull (ctor, "#B3");
2396 ctor = greenType.GetConstructor (flags, null,
2397 new Type [] { typeof (int) },
2398 new ParameterModifier [0]);
2399 Assert.IsNull (ctor, "#B4");
2401 ctor = greenType.GetConstructor (flags, null,
2402 new Type [] { typeof (int), typeof (bool) },
2403 new ParameterModifier [0]);
2404 Assert.IsNull (ctor, "#B5");
2406 ctor = greenType.GetConstructor (flags, null,
2407 new Type [] { typeof (string), typeof (int) },
2408 new ParameterModifier [0]);
2409 Assert.IsNull (ctor, "#B6");
2411 ctor = greenType.GetConstructor (flags, null,
2413 new ParameterModifier [0]);
2414 Assert.IsNotNull (ctor, "#B7a");
2415 Assert.IsTrue (ctor.IsPublic, "#B7b");
2416 Assert.IsFalse (ctor.IsStatic, "#B7c");
2417 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B7d");
2418 Assert.IsFalse (ctor is ConstructorBuilder, "#B7e");
2420 ctor = redType.GetConstructor (flags, null,
2421 new Type [] { typeof (int), typeof (int) },
2422 new ParameterModifier [0]);
2423 Assert.IsNull (ctor, "#B8");
2425 ctor = redType.GetConstructor (flags, null,
2426 new Type [] { typeof (string) },
2427 new ParameterModifier [0]);
2428 Assert.IsNull (ctor, "#B9");
2430 ctor = redType.GetConstructor (flags, null,
2431 new Type [] { typeof (string), typeof (string) },
2432 new ParameterModifier [0]);
2433 Assert.IsNull (ctor, "#B10");
2435 ctor = redType.GetConstructor (flags, null,
2436 new Type [] { typeof (int) },
2437 new ParameterModifier [0]);
2438 Assert.IsNull (ctor, "#B11");
2440 ctor = redType.GetConstructor (flags, null,
2441 new Type [] { typeof (int), typeof (bool) },
2442 new ParameterModifier [0]);
2443 Assert.IsNotNull (ctor, "#B12a");
2444 Assert.IsTrue (ctor.IsPublic, "#B12b");
2445 Assert.IsFalse (ctor.IsStatic, "#B12c");
2446 Assert.AreEqual (2, ctor.GetParameters ().Length, "#B12d");
2447 Assert.IsFalse (ctor is ConstructorBuilder, "#B12e");
2449 ctor = redType.GetConstructor (flags, null,
2450 new Type [] { typeof (string), typeof (int) },
2451 new ParameterModifier [0]);
2452 Assert.IsNull (ctor, "#B13");
2454 ctor = redType.GetConstructor (flags, null,
2456 new ParameterModifier [0]);
2457 Assert.IsNull (ctor, "#B14");
2459 flags = BindingFlags.Static | BindingFlags.Public;
2461 ctor = greenType.GetConstructor (flags, null,
2462 new Type [] { typeof (int), typeof (int) },
2463 new ParameterModifier [0]);
2464 Assert.IsNull (ctor, "#C1");
2466 ctor = greenType.GetConstructor (flags, null,
2467 new Type [] { typeof (string) },
2468 new ParameterModifier [0]);
2469 Assert.IsNull (ctor, "#C2");
2471 ctor = greenType.GetConstructor (flags, null,
2472 new Type [] { typeof (string), typeof (string) },
2473 new ParameterModifier [0]);
2474 Assert.IsNull (ctor, "#C3");
2476 ctor = greenType.GetConstructor (flags, null,
2477 new Type [] { typeof (int) },
2478 new ParameterModifier [0]);
2479 Assert.IsNull (ctor, "#C4");
2481 ctor = greenType.GetConstructor (flags, null,
2482 new Type [] { typeof (int), typeof (bool) },
2483 new ParameterModifier [0]);
2484 Assert.IsNull (ctor, "#C5");
2486 ctor = greenType.GetConstructor (flags, null,
2487 new Type [] { typeof (string), typeof (int) },
2488 new ParameterModifier [0]);
2489 Assert.IsNull (ctor, "#C6");
2491 ctor = greenType.GetConstructor (flags, null,
2493 new ParameterModifier [0]);
2494 Assert.IsNull (ctor, "#C7");
2496 ctor = redType.GetConstructor (flags, null,
2497 new Type [] { typeof (int), typeof (int) },
2498 new ParameterModifier [0]);
2499 Assert.IsNull (ctor, "#C8");
2501 ctor = redType.GetConstructor (flags, null,
2502 new Type [] { typeof (string) },
2503 new ParameterModifier [0]);
2504 Assert.IsNull (ctor, "#C9");
2506 ctor = redType.GetConstructor (flags, null,
2507 new Type [] { typeof (string), typeof (string) },
2508 new ParameterModifier [0]);
2509 Assert.IsNull (ctor, "#C10");
2511 ctor = redType.GetConstructor (flags, null,
2512 new Type [] { typeof (int) },
2513 new ParameterModifier [0]);
2514 Assert.IsNull (ctor, "#C11a");
2516 ctor = redType.GetConstructor (flags, null,
2517 new Type [] { typeof (int), typeof (bool) },
2518 new ParameterModifier [0]);
2519 Assert.IsNull (ctor, "#C12");
2521 ctor = redType.GetConstructor (flags, null,
2522 new Type [] { typeof (string), typeof (int) },
2523 new ParameterModifier [0]);
2524 Assert.IsNull (ctor, "#C13");
2526 ctor = redType.GetConstructor (flags, null,
2528 new ParameterModifier [0]);
2529 Assert.IsNull (ctor, "#C14");
2531 flags = BindingFlags.Static | BindingFlags.NonPublic;
2533 ctor = greenType.GetConstructor (flags, null,
2534 new Type [] { typeof (int), typeof (int) },
2535 new ParameterModifier [0]);
2536 Assert.IsNull (ctor, "#D1");
2538 ctor = greenType.GetConstructor (flags, null,
2539 new Type [] { typeof (string) },
2540 new ParameterModifier [0]);
2541 Assert.IsNull (ctor, "#D2");
2543 ctor = greenType.GetConstructor (flags, null,
2544 new Type [] { typeof (string), typeof (string) },
2545 new ParameterModifier [0]);
2546 Assert.IsNull (ctor, "#D3");
2548 ctor = greenType.GetConstructor (flags, null,
2549 new Type [] { typeof (int) },
2550 new ParameterModifier [0]);
2551 Assert.IsNull (ctor, "#D4");
2553 ctor = greenType.GetConstructor (flags, null,
2554 new Type [] { typeof (int), typeof (bool) },
2555 new ParameterModifier [0]);
2556 Assert.IsNull (ctor, "#D5");
2558 ctor = greenType.GetConstructor (flags, null,
2559 new Type [] { typeof (string), typeof (int) },
2560 new ParameterModifier [0]);
2561 Assert.IsNull (ctor, "#D6");
2563 ctor = greenType.GetConstructor (flags, null,
2565 new ParameterModifier [0]);
2566 Assert.IsNull (ctor, "#D7");
2568 ctor = redType.GetConstructor (flags, null,
2569 new Type [] { typeof (int), typeof (int) },
2570 new ParameterModifier [0]);
2571 Assert.IsNull (ctor, "#D8");
2573 ctor = redType.GetConstructor (flags, null,
2574 new Type [] { typeof (string) },
2575 new ParameterModifier [0]);
2576 Assert.IsNull (ctor, "#D9");
2578 ctor = redType.GetConstructor (flags, null,
2579 new Type [] { typeof (string), typeof (string) },
2580 new ParameterModifier [0]);
2581 Assert.IsNull (ctor, "#D10");
2583 ctor = redType.GetConstructor (flags, null,
2584 new Type [] { typeof (int) },
2585 new ParameterModifier [0]);
2586 Assert.IsNull (ctor, "#D11");
2588 ctor = redType.GetConstructor (flags, null,
2589 new Type [] { typeof (int), typeof (bool) },
2590 new ParameterModifier [0]);
2591 Assert.IsNull (ctor, "#D12");
2593 ctor = redType.GetConstructor (flags, null,
2594 new Type [] { typeof (string), typeof (int) },
2595 new ParameterModifier [0]);
2596 Assert.IsNull (ctor, "#D13");
2598 ctor = redType.GetConstructor (flags, null,
2600 new ParameterModifier [0]);
2601 Assert.IsNotNull (ctor, "#D14a");
2602 Assert.IsTrue (ctor.IsPrivate, "#D14b");
2603 Assert.IsTrue (ctor.IsStatic, "#B14c");
2604 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B14d");
2605 Assert.IsFalse (ctor is ConstructorBuilder, "#B14e");
2607 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2608 BindingFlags.FlattenHierarchy;
2610 ctor = greenType.GetConstructor (flags, null,
2611 new Type [] { typeof (int), typeof (int) },
2612 new ParameterModifier [0]);
2613 Assert.IsNull (ctor, "#E1");
2615 ctor = greenType.GetConstructor (flags, null,
2616 new Type [] { typeof (string) },
2617 new ParameterModifier [0]);
2618 Assert.IsNull (ctor, "#E2");
2620 ctor = greenType.GetConstructor (flags, null,
2621 new Type [] { typeof (string), typeof (string) },
2622 new ParameterModifier [0]);
2623 Assert.IsNull (ctor, "#E3");
2625 ctor = greenType.GetConstructor (flags, null,
2626 new Type [] { typeof (int) },
2627 new ParameterModifier [0]);
2628 Assert.IsNull (ctor, "#E4");
2630 ctor = greenType.GetConstructor (flags, null,
2631 new Type [] { typeof (int), typeof (bool) },
2632 new ParameterModifier [0]);
2633 Assert.IsNull (ctor, "#E5");
2635 ctor = greenType.GetConstructor (flags, null,
2636 new Type [] { typeof (string), typeof (int) },
2637 new ParameterModifier [0]);
2638 Assert.IsNull (ctor, "#E6");
2640 ctor = greenType.GetConstructor (flags, null,
2642 new ParameterModifier [0]);
2643 Assert.IsNull (ctor, "#E7");
2645 ctor = redType.GetConstructor (flags, null,
2646 new Type [] { typeof (int), typeof (int) },
2647 new ParameterModifier [0]);
2648 Assert.IsNotNull (ctor, "#E8a");
2649 Assert.IsTrue (ctor.IsPrivate, "#E8b");
2650 Assert.IsFalse (ctor.IsStatic, "#E8c");
2651 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E8d");
2652 Assert.IsFalse (ctor is ConstructorBuilder, "#E8e");
2654 ctor = redType.GetConstructor (flags, null,
2655 new Type [] { typeof (string) },
2656 new ParameterModifier [0]);
2657 Assert.IsNotNull (ctor, "#E9a");
2658 Assert.IsTrue (ctor.IsFamily, "#E9b");
2659 Assert.IsFalse (ctor.IsStatic, "#E9c");
2660 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E9d");
2661 Assert.IsFalse (ctor is ConstructorBuilder, "#E9e");
2663 ctor = redType.GetConstructor (flags, null,
2664 new Type [] { typeof (string), typeof (string) },
2665 new ParameterModifier [0]);
2666 Assert.IsNotNull (ctor, "#E10a");
2667 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#E10b");
2668 Assert.IsFalse (ctor.IsStatic, "#E10c");
2669 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E10d");
2670 Assert.IsFalse (ctor is ConstructorBuilder, "#E10e");
2672 ctor = redType.GetConstructor (flags, null,
2673 new Type [] { typeof (int) },
2674 new ParameterModifier [0]);
2675 Assert.IsNotNull (ctor, "#E11a");
2676 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#E11b");
2677 Assert.IsFalse (ctor.IsStatic, "#E11c");
2678 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E11d");
2679 Assert.IsFalse (ctor is ConstructorBuilder, "#E11e");
2681 ctor = redType.GetConstructor (flags, null,
2682 new Type [] { typeof (int), typeof (bool) },
2683 new ParameterModifier [0]);
2684 Assert.IsNull (ctor, "#E12");
2686 ctor = redType.GetConstructor (flags, null,
2687 new Type [] { typeof (string), typeof (int) },
2688 new ParameterModifier [0]);
2689 Assert.IsNotNull (ctor, "#E13a");
2690 Assert.IsTrue (ctor.IsAssembly, "#E13b");
2691 Assert.IsFalse (ctor.IsStatic, "#E13c");
2692 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E13d");
2693 Assert.IsFalse (ctor is ConstructorBuilder, "#E13e");
2695 ctor = redType.GetConstructor (flags, null,
2697 new ParameterModifier [0]);
2698 Assert.IsNull (ctor, "#E14");
2700 flags = BindingFlags.Instance | BindingFlags.Public |
2701 BindingFlags.FlattenHierarchy;
2703 ctor = greenType.GetConstructor (flags, null,
2704 new Type [] { typeof (int), typeof (int) },
2705 new ParameterModifier [0]);
2706 Assert.IsNull (ctor, "#F1");
2708 ctor = greenType.GetConstructor (flags, null,
2709 new Type [] { typeof (string) },
2710 new ParameterModifier [0]);
2711 Assert.IsNull (ctor, "#F2");
2713 ctor = greenType.GetConstructor (flags, null,
2714 new Type [] { typeof (string), typeof (string) },
2715 new ParameterModifier [0]);
2716 Assert.IsNull (ctor, "#F3");
2718 ctor = greenType.GetConstructor (flags, null,
2719 new Type [] { typeof (int) },
2720 new ParameterModifier [0]);
2721 Assert.IsNull (ctor, "#F4");
2723 ctor = greenType.GetConstructor (flags, null,
2724 new Type [] { typeof (int), typeof (bool) },
2725 new ParameterModifier [0]);
2726 Assert.IsNull (ctor, "#F5");
2728 ctor = greenType.GetConstructor (flags, null,
2729 new Type [] { typeof (string), typeof (int) },
2730 new ParameterModifier [0]);
2731 Assert.IsNull (ctor, "#F6");
2733 ctor = greenType.GetConstructor (flags, null,
2735 new ParameterModifier [0]);
2736 Assert.IsNotNull (ctor, "#F7a");
2737 Assert.IsTrue (ctor.IsPublic, "#F7b");
2738 Assert.IsFalse (ctor.IsStatic, "#F7c");
2739 Assert.AreEqual (0, ctor.GetParameters ().Length, "#F7d");
2740 Assert.IsFalse (ctor is ConstructorBuilder, "#F7e");
2742 ctor = redType.GetConstructor (flags, null,
2743 new Type [] { typeof (int), typeof (int) },
2744 new ParameterModifier [0]);
2745 Assert.IsNull (ctor, "#F8");
2747 ctor = redType.GetConstructor (flags, null,
2748 new Type [] { typeof (string) },
2749 new ParameterModifier [0]);
2750 Assert.IsNull (ctor, "#F9");
2752 ctor = redType.GetConstructor (flags, null,
2753 new Type [] { typeof (string), typeof (string) },
2754 new ParameterModifier [0]);
2755 Assert.IsNull (ctor, "#F10");
2757 ctor = redType.GetConstructor (flags, null,
2758 new Type [] { typeof (int) },
2759 new ParameterModifier [0]);
2760 Assert.IsNull (ctor, "#F11");
2762 ctor = redType.GetConstructor (flags, null,
2763 new Type [] { typeof (int), typeof (bool) },
2764 new ParameterModifier [0]);
2765 Assert.IsNotNull (ctor, "#F12a");
2766 Assert.IsTrue (ctor.IsPublic, "#F12b");
2767 Assert.IsFalse (ctor.IsStatic, "#F12c");
2768 Assert.AreEqual (2, ctor.GetParameters ().Length, "#F12d");
2769 Assert.IsFalse (ctor is ConstructorBuilder, "#F12e");
2771 ctor = redType.GetConstructor (flags, null,
2772 new Type [] { typeof (string), typeof (int) },
2773 new ParameterModifier [0]);
2774 Assert.IsNull (ctor, "#F13");
2776 ctor = redType.GetConstructor (flags, null,
2778 new ParameterModifier [0]);
2779 Assert.IsNull (ctor, "#F14");
2781 flags = BindingFlags.Static | BindingFlags.Public |
2782 BindingFlags.FlattenHierarchy;
2784 ctor = greenType.GetConstructor (flags, null,
2785 new Type [] { typeof (int), typeof (int) },
2786 new ParameterModifier [0]);
2787 Assert.IsNull (ctor, "#G1");
2789 ctor = greenType.GetConstructor (flags, null,
2790 new Type [] { typeof (string) },
2791 new ParameterModifier [0]);
2792 Assert.IsNull (ctor, "#G2");
2794 ctor = greenType.GetConstructor (flags, null,
2795 new Type [] { typeof (string), typeof (string) },
2796 new ParameterModifier [0]);
2797 Assert.IsNull (ctor, "#G3");
2799 ctor = greenType.GetConstructor (flags, null,
2800 new Type [] { typeof (int) },
2801 new ParameterModifier [0]);
2802 Assert.IsNull (ctor, "#G4");
2804 ctor = greenType.GetConstructor (flags, null,
2805 new Type [] { typeof (int), typeof (bool) },
2806 new ParameterModifier [0]);
2807 Assert.IsNull (ctor, "#G5");
2809 ctor = greenType.GetConstructor (flags, null,
2810 new Type [] { typeof (string), typeof (int) },
2811 new ParameterModifier [0]);
2812 Assert.IsNull (ctor, "#G6");
2814 ctor = greenType.GetConstructor (flags, null,
2816 new ParameterModifier [0]);
2817 Assert.IsNull (ctor, "#G7");
2819 ctor = redType.GetConstructor (flags, null,
2820 new Type [] { typeof (int), typeof (int) },
2821 new ParameterModifier [0]);
2822 Assert.IsNull (ctor, "#G8");
2824 ctor = redType.GetConstructor (flags, null,
2825 new Type [] { typeof (string) },
2826 new ParameterModifier [0]);
2827 Assert.IsNull (ctor, "#G9");
2829 ctor = redType.GetConstructor (flags, null,
2830 new Type [] { typeof (string), typeof (string) },
2831 new ParameterModifier [0]);
2832 Assert.IsNull (ctor, "#G10");
2834 ctor = redType.GetConstructor (flags, null,
2835 new Type [] { typeof (int) },
2836 new ParameterModifier [0]);
2837 Assert.IsNull (ctor, "#G11");
2839 ctor = redType.GetConstructor (flags, null,
2840 new Type [] { typeof (int), typeof (bool) },
2841 new ParameterModifier [0]);
2842 Assert.IsNull (ctor, "#G12");
2844 ctor = redType.GetConstructor (flags, null,
2845 new Type [] { typeof (string), typeof (int) },
2846 new ParameterModifier [0]);
2847 Assert.IsNull (ctor, "#G13");
2849 ctor = redType.GetConstructor (flags, null,
2851 new ParameterModifier [0]);
2852 Assert.IsNull (ctor, "#G14");
2854 flags = BindingFlags.Static | BindingFlags.NonPublic |
2855 BindingFlags.FlattenHierarchy;
2857 ctor = greenType.GetConstructor (flags, null,
2858 new Type [] { typeof (int), typeof (int) },
2859 new ParameterModifier [0]);
2860 Assert.IsNull (ctor, "#H1");
2862 ctor = greenType.GetConstructor (flags, null,
2863 new Type [] { typeof (string) },
2864 new ParameterModifier [0]);
2865 Assert.IsNull (ctor, "#H2");
2867 ctor = greenType.GetConstructor (flags, null,
2868 new Type [] { typeof (string), typeof (string) },
2869 new ParameterModifier [0]);
2870 Assert.IsNull (ctor, "#H3");
2872 ctor = greenType.GetConstructor (flags, null,
2873 new Type [] { typeof (int) },
2874 new ParameterModifier [0]);
2875 Assert.IsNull (ctor, "#H4");
2877 ctor = greenType.GetConstructor (flags, null,
2878 new Type [] { typeof (int), typeof (bool) },
2879 new ParameterModifier [0]);
2880 Assert.IsNull (ctor, "#H5");
2882 ctor = greenType.GetConstructor (flags, null,
2883 new Type [] { typeof (string), typeof (int) },
2884 new ParameterModifier [0]);
2885 Assert.IsNull (ctor, "#H6");
2887 ctor = greenType.GetConstructor (flags, null,
2889 new ParameterModifier [0]);
2890 Assert.IsNull (ctor, "#H7");
2892 ctor = redType.GetConstructor (flags, null,
2893 new Type [] { typeof (int), typeof (int) },
2894 new ParameterModifier [0]);
2895 Assert.IsNull (ctor, "#H8");
2897 ctor = redType.GetConstructor (flags, null,
2898 new Type [] { typeof (string) },
2899 new ParameterModifier [0]);
2900 Assert.IsNull (ctor, "#H9");
2902 ctor = redType.GetConstructor (flags, null,
2903 new Type [] { typeof (string), typeof (string) },
2904 new ParameterModifier [0]);
2905 Assert.IsNull (ctor, "#H10");
2907 ctor = redType.GetConstructor (flags, null,
2908 new Type [] { typeof (int) },
2909 new ParameterModifier [0]);
2910 Assert.IsNull (ctor, "#H11");
2912 ctor = redType.GetConstructor (flags, null,
2913 new Type [] { typeof (int), typeof (bool) },
2914 new ParameterModifier [0]);
2915 Assert.IsNull (ctor, "#H12");
2917 ctor = redType.GetConstructor (flags, null,
2918 new Type [] { typeof (string), typeof (int) },
2919 new ParameterModifier [0]);
2920 Assert.IsNull (ctor, "#H13");
2922 ctor = redType.GetConstructor (flags, null,
2924 new ParameterModifier [0]);
2925 Assert.IsNotNull (ctor, "#H14");
2926 Assert.IsTrue (ctor.IsPrivate, "#H14b");
2927 Assert.IsTrue (ctor.IsStatic, "#H14c");
2928 Assert.AreEqual (0, ctor.GetParameters ().Length, "#H14d");
2929 Assert.IsFalse (ctor is ConstructorBuilder, "#H14e");
2931 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2932 BindingFlags.DeclaredOnly;
2934 ctor = greenType.GetConstructor (flags, null,
2935 new Type [] { typeof (int), typeof (int) },
2936 new ParameterModifier [0]);
2937 Assert.IsNull (ctor, "#I1");
2939 ctor = greenType.GetConstructor (flags, null,
2940 new Type [] { typeof (string) },
2941 new ParameterModifier [0]);
2942 Assert.IsNull (ctor, "#I2");
2944 ctor = greenType.GetConstructor (flags, null,
2945 new Type [] { typeof (string), typeof (string) },
2946 new ParameterModifier [0]);
2947 Assert.IsNull (ctor, "#I3");
2949 ctor = greenType.GetConstructor (flags, null,
2950 new Type [] { typeof (int) },
2951 new ParameterModifier [0]);
2952 Assert.IsNull (ctor, "#I4");
2954 ctor = greenType.GetConstructor (flags, null,
2955 new Type [] { typeof (int), typeof (bool) },
2956 new ParameterModifier [0]);
2957 Assert.IsNull (ctor, "#I5");
2959 ctor = greenType.GetConstructor (flags, null,
2960 new Type [] { typeof (string), typeof (int) },
2961 new ParameterModifier [0]);
2962 Assert.IsNull (ctor, "#I6");
2964 ctor = greenType.GetConstructor (flags, null,
2966 new ParameterModifier [0]);
2967 Assert.IsNull (ctor, "#I7");
2969 ctor = redType.GetConstructor (flags, null,
2970 new Type [] { typeof (int), typeof (int) },
2971 new ParameterModifier [0]);
2972 Assert.IsNotNull (ctor, "#I8a");
2973 Assert.IsTrue (ctor.IsPrivate, "#I8b");
2974 Assert.IsFalse (ctor.IsStatic, "#I8c");
2975 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I8d");
2976 Assert.IsFalse (ctor is ConstructorBuilder, "#I8e");
2978 ctor = redType.GetConstructor (flags, null,
2979 new Type [] { typeof (string) },
2980 new ParameterModifier [0]);
2981 Assert.IsNotNull (ctor, "#I9a");
2982 Assert.IsTrue (ctor.IsFamily, "#I9b");
2983 Assert.IsFalse (ctor.IsStatic, "#I9c");
2984 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I9d");
2985 Assert.IsFalse (ctor is ConstructorBuilder, "#I9e");
2987 ctor = redType.GetConstructor (flags, null,
2988 new Type [] { typeof (string), typeof (string) },
2989 new ParameterModifier [0]);
2990 Assert.IsNotNull (ctor, "#I10a");
2991 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#I10b");
2992 Assert.IsFalse (ctor.IsStatic, "#I10c");
2993 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I10d");
2994 Assert.IsFalse (ctor is ConstructorBuilder, "#I10e");
2996 ctor = redType.GetConstructor (flags, null,
2997 new Type [] { typeof (int) },
2998 new ParameterModifier [0]);
2999 Assert.IsNotNull (ctor, "#I11a");
3000 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#I11b");
3001 Assert.IsFalse (ctor.IsStatic, "#I11c");
3002 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I11d");
3003 Assert.IsFalse (ctor is ConstructorBuilder, "#I11e");
3005 ctor = redType.GetConstructor (flags, null,
3006 new Type [] { typeof (int), typeof (bool) },
3007 new ParameterModifier [0]);
3008 Assert.IsNull (ctor, "#I12");
3010 ctor = redType.GetConstructor (flags, null,
3011 new Type [] { typeof (string), typeof (int) },
3012 new ParameterModifier [0]);
3013 Assert.IsNotNull (ctor, "#I13a");
3014 Assert.IsTrue (ctor.IsAssembly, "#I13b");
3015 Assert.IsFalse (ctor.IsStatic, "#I13c");
3016 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I13d");
3017 Assert.IsFalse (ctor is ConstructorBuilder, "#I13e");
3019 ctor = redType.GetConstructor (flags, null,
3021 new ParameterModifier [0]);
3022 Assert.IsNull (ctor, "#I14");
3024 flags = BindingFlags.Instance | BindingFlags.Public |
3025 BindingFlags.DeclaredOnly;
3027 ctor = greenType.GetConstructor (flags, null,
3028 new Type [] { typeof (int), typeof (int) },
3029 new ParameterModifier [0]);
3030 Assert.IsNull (ctor, "#J1");
3032 ctor = greenType.GetConstructor (flags, null,
3033 new Type [] { typeof (string) },
3034 new ParameterModifier [0]);
3035 Assert.IsNull (ctor, "#J2");
3037 ctor = greenType.GetConstructor (flags, null,
3038 new Type [] { typeof (string), typeof (string) },
3039 new ParameterModifier [0]);
3040 Assert.IsNull (ctor, "#J3");
3042 ctor = greenType.GetConstructor (flags, null,
3043 new Type [] { typeof (int) },
3044 new ParameterModifier [0]);
3045 Assert.IsNull (ctor, "#J4");
3047 ctor = greenType.GetConstructor (flags, null,
3048 new Type [] { typeof (int), typeof (bool) },
3049 new ParameterModifier [0]);
3050 Assert.IsNull (ctor, "#J5");
3052 ctor = greenType.GetConstructor (flags, null,
3053 new Type [] { typeof (string), typeof (int) },
3054 new ParameterModifier [0]);
3055 Assert.IsNull (ctor, "#J6");
3057 ctor = greenType.GetConstructor (flags, null,
3059 new ParameterModifier [0]);
3060 Assert.IsNotNull (ctor, "#J7a");
3061 Assert.IsTrue (ctor.IsPublic, "#J7b");
3062 Assert.IsFalse (ctor.IsStatic, "#J7c");
3063 Assert.AreEqual (0, ctor.GetParameters ().Length, "#J7d");
3064 Assert.IsFalse (ctor is ConstructorBuilder, "#J7e");
3066 ctor = redType.GetConstructor (flags, null,
3067 new Type [] { typeof (int), typeof (int) },
3068 new ParameterModifier [0]);
3069 Assert.IsNull (ctor, "#J8");
3071 ctor = redType.GetConstructor (flags, null,
3072 new Type [] { typeof (string) },
3073 new ParameterModifier [0]);
3074 Assert.IsNull (ctor, "#J9");
3076 ctor = redType.GetConstructor (flags, null,
3077 new Type [] { typeof (string), typeof (string) },
3078 new ParameterModifier [0]);
3079 Assert.IsNull (ctor, "#J10");
3081 ctor = redType.GetConstructor (flags, null,
3082 new Type [] { typeof (int) },
3083 new ParameterModifier [0]);
3084 Assert.IsNull (ctor, "#J11");
3086 ctor = redType.GetConstructor (flags, null,
3087 new Type [] { typeof (int), typeof (bool) },
3088 new ParameterModifier [0]);
3089 Assert.IsNotNull (ctor, "#J12a");
3090 Assert.IsTrue (ctor.IsPublic, "#J12b");
3091 Assert.IsFalse (ctor.IsStatic, "#J12c");
3092 Assert.AreEqual (2, ctor.GetParameters ().Length, "#J12d");
3093 Assert.IsFalse (ctor is ConstructorBuilder, "#J12e");
3095 ctor = redType.GetConstructor (flags, null,
3096 new Type [] { typeof (string), typeof (int) },
3097 new ParameterModifier [0]);
3098 Assert.IsNull (ctor, "#J13");
3100 ctor = redType.GetConstructor (flags, null,
3102 new ParameterModifier [0]);
3103 Assert.IsNull (ctor, "#J14");
3105 flags = BindingFlags.Static | BindingFlags.Public |
3106 BindingFlags.DeclaredOnly;
3108 ctor = greenType.GetConstructor (flags, null,
3109 new Type [] { typeof (int), typeof (int) },
3110 new ParameterModifier [0]);
3111 Assert.IsNull (ctor, "#K1");
3113 ctor = greenType.GetConstructor (flags, null,
3114 new Type [] { typeof (string) },
3115 new ParameterModifier [0]);
3116 Assert.IsNull (ctor, "#K2");
3118 ctor = greenType.GetConstructor (flags, null,
3119 new Type [] { typeof (string), typeof (string) },
3120 new ParameterModifier [0]);
3121 Assert.IsNull (ctor, "#K3");
3123 ctor = greenType.GetConstructor (flags, null,
3124 new Type [] { typeof (int) },
3125 new ParameterModifier [0]);
3126 Assert.IsNull (ctor, "#K4");
3128 ctor = greenType.GetConstructor (flags, null,
3129 new Type [] { typeof (int), typeof (bool) },
3130 new ParameterModifier [0]);
3131 Assert.IsNull (ctor, "#K5");
3133 ctor = greenType.GetConstructor (flags, null,
3134 new Type [] { typeof (string), typeof (int) },
3135 new ParameterModifier [0]);
3136 Assert.IsNull (ctor, "#K6");
3138 ctor = greenType.GetConstructor (flags, null,
3140 new ParameterModifier [0]);
3141 Assert.IsNull (ctor, "#K7");
3143 ctor = redType.GetConstructor (flags, null,
3144 new Type [] { typeof (int), typeof (int) },
3145 new ParameterModifier [0]);
3146 Assert.IsNull (ctor, "#K8");
3148 ctor = redType.GetConstructor (flags, null,
3149 new Type [] { typeof (string) },
3150 new ParameterModifier [0]);
3151 Assert.IsNull (ctor, "#K9");
3153 ctor = redType.GetConstructor (flags, null,
3154 new Type [] { typeof (string), typeof (string) },
3155 new ParameterModifier [0]);
3156 Assert.IsNull (ctor, "#K10");
3158 ctor = redType.GetConstructor (flags, null,
3159 new Type [] { typeof (int) },
3160 new ParameterModifier [0]);
3161 Assert.IsNull (ctor, "#K11");
3163 ctor = redType.GetConstructor (flags, null,
3164 new Type [] { typeof (int), typeof (bool) },
3165 new ParameterModifier [0]);
3166 Assert.IsNull (ctor, "#K12");
3168 ctor = redType.GetConstructor (flags, null,
3169 new Type [] { typeof (string), typeof (int) },
3170 new ParameterModifier [0]);
3171 Assert.IsNull (ctor, "#K13");
3173 ctor = redType.GetConstructor (flags, null,
3175 new ParameterModifier [0]);
3176 Assert.IsNull (ctor, "#K14");
3178 flags = BindingFlags.Static | BindingFlags.NonPublic |
3179 BindingFlags.DeclaredOnly;
3181 ctor = greenType.GetConstructor (flags, null,
3182 new Type [] { typeof (int), typeof (int) },
3183 new ParameterModifier [0]);
3184 Assert.IsNull (ctor, "#L1");
3186 ctor = greenType.GetConstructor (flags, null,
3187 new Type [] { typeof (string) },
3188 new ParameterModifier [0]);
3189 Assert.IsNull (ctor, "#L2");
3191 ctor = greenType.GetConstructor (flags, null,
3192 new Type [] { typeof (string), typeof (string) },
3193 new ParameterModifier [0]);
3194 Assert.IsNull (ctor, "#L3");
3196 ctor = greenType.GetConstructor (flags, null,
3197 new Type [] { typeof (int) },
3198 new ParameterModifier [0]);
3199 Assert.IsNull (ctor, "#L4");
3201 ctor = greenType.GetConstructor (flags, null,
3202 new Type [] { typeof (int), typeof (bool) },
3203 new ParameterModifier [0]);
3204 Assert.IsNull (ctor, "#L5");
3206 ctor = greenType.GetConstructor (flags, null,
3207 new Type [] { typeof (string), typeof (int) },
3208 new ParameterModifier [0]);
3209 Assert.IsNull (ctor, "#L6");
3211 ctor = greenType.GetConstructor (flags, null,
3213 new ParameterModifier [0]);
3214 Assert.IsNull (ctor, "#L7");
3216 ctor = redType.GetConstructor (flags, null,
3217 new Type [] { typeof (int), typeof (int) },
3218 new ParameterModifier [0]);
3219 Assert.IsNull (ctor, "#L8");
3221 ctor = redType.GetConstructor (flags, null,
3222 new Type [] { typeof (string) },
3223 new ParameterModifier [0]);
3224 Assert.IsNull (ctor, "#L9");
3226 ctor = redType.GetConstructor (flags, null,
3227 new Type [] { typeof (string), typeof (string) },
3228 new ParameterModifier [0]);
3229 Assert.IsNull (ctor, "#L10");
3231 ctor = redType.GetConstructor (flags, null,
3232 new Type [] { typeof (int) },
3233 new ParameterModifier [0]);
3234 Assert.IsNull (ctor, "#L11");
3236 ctor = redType.GetConstructor (flags, null,
3237 new Type [] { typeof (int), typeof (bool) },
3238 new ParameterModifier [0]);
3239 Assert.IsNull (ctor, "#L12");
3241 ctor = redType.GetConstructor (flags, null,
3242 new Type [] { typeof (string), typeof (int) },
3243 new ParameterModifier [0]);
3244 Assert.IsNull (ctor, "#L13");
3246 ctor = redType.GetConstructor (flags, null,
3248 new ParameterModifier [0]);
3249 Assert.IsNotNull (ctor, "#L14a");
3250 Assert.IsTrue (ctor.IsPrivate, "#L14b");
3251 Assert.IsTrue (ctor.IsStatic, "#L14c");
3252 Assert.AreEqual (0, ctor.GetParameters ().Length, "#L14d");
3253 Assert.IsFalse (ctor is ConstructorBuilder, "#L14e");
3255 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3256 BindingFlags.Public;
3258 ctor = greenType.GetConstructor (flags, null,
3259 new Type [] { typeof (int), typeof (int) },
3260 new ParameterModifier [0]);
3261 Assert.IsNull (ctor, "#M1");
3263 ctor = greenType.GetConstructor (flags, null,
3264 new Type [] { typeof (string) },
3265 new ParameterModifier [0]);
3266 Assert.IsNull (ctor, "#M2");
3268 ctor = greenType.GetConstructor (flags, null,
3269 new Type [] { typeof (string), typeof (string) },
3270 new ParameterModifier [0]);
3271 Assert.IsNull (ctor, "#M3");
3273 ctor = greenType.GetConstructor (flags, null,
3274 new Type [] { typeof (int) },
3275 new ParameterModifier [0]);
3276 Assert.IsNull (ctor, "#M4");
3278 ctor = greenType.GetConstructor (flags, null,
3279 new Type [] { typeof (int), typeof (bool) },
3280 new ParameterModifier [0]);
3281 Assert.IsNull (ctor, "#M5");
3283 ctor = greenType.GetConstructor (flags, null,
3284 new Type [] { typeof (string), typeof (int) },
3285 new ParameterModifier [0]);
3286 Assert.IsNull (ctor, "#M6");
3288 ctor = greenType.GetConstructor (flags, null,
3290 new ParameterModifier [0]);
3291 Assert.IsNotNull (ctor, "#M7a");
3292 Assert.IsTrue (ctor.IsPublic, "#M7b");
3293 Assert.IsFalse (ctor.IsStatic, "#M7c");
3294 Assert.AreEqual (0, ctor.GetParameters ().Length, "#M7d");
3295 Assert.IsFalse (ctor is ConstructorBuilder, "#M7e");
3297 ctor = redType.GetConstructor (flags, null,
3298 new Type [] { typeof (int), typeof (int) },
3299 new ParameterModifier [0]);
3300 Assert.IsNotNull (ctor, "#M8a");
3301 Assert.IsTrue (ctor.IsPrivate, "#M8b");
3302 Assert.IsFalse (ctor.IsStatic, "#M8c");
3303 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M8d");
3304 Assert.IsFalse (ctor is ConstructorBuilder, "#M8e");
3306 ctor = redType.GetConstructor (flags, null,
3307 new Type [] { typeof (string) },
3308 new ParameterModifier [0]);
3309 Assert.IsNotNull (ctor, "#M9a");
3310 Assert.IsTrue (ctor.IsFamily, "#M9b");
3311 Assert.IsFalse (ctor.IsStatic, "#M9c");
3312 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M9d");
3313 Assert.IsFalse (ctor is ConstructorBuilder, "#M9e");
3315 ctor = redType.GetConstructor (flags, null,
3316 new Type [] { typeof (string), typeof (string) },
3317 new ParameterModifier [0]);
3318 Assert.IsNotNull (ctor, "#M10a");
3319 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#M10b");
3320 Assert.IsFalse (ctor.IsStatic, "#M10c");
3321 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M10d");
3322 Assert.IsFalse (ctor is ConstructorBuilder, "#M10e");
3324 ctor = redType.GetConstructor (flags, null,
3325 new Type [] { typeof (int) },
3326 new ParameterModifier [0]);
3327 Assert.IsNotNull (ctor, "#M11a");
3328 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#M11b");
3329 Assert.IsFalse (ctor.IsStatic, "#M11c");
3330 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M11d");
3331 Assert.IsFalse (ctor is ConstructorBuilder, "#M11e");
3333 ctor = redType.GetConstructor (flags, null,
3334 new Type [] { typeof (int), typeof (bool) },
3335 new ParameterModifier [0]);
3336 Assert.IsNotNull (ctor, "#M12a");
3337 Assert.IsTrue (ctor.IsPublic, "#M12b");
3338 Assert.IsFalse (ctor.IsStatic, "#M12c");
3339 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M12d");
3340 Assert.IsFalse (ctor is ConstructorBuilder, "#M12e");
3342 ctor = redType.GetConstructor (flags, null,
3343 new Type [] { typeof (string), typeof (int) },
3344 new ParameterModifier [0]);
3345 Assert.IsNotNull (ctor, "#M13a");
3346 Assert.IsTrue (ctor.IsAssembly, "#M13b");
3347 Assert.IsFalse (ctor.IsStatic, "#M13c");
3348 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M13d");
3349 Assert.IsFalse (ctor is ConstructorBuilder, "#M13e");
3351 ctor = redType.GetConstructor (flags, null,
3353 new ParameterModifier [0]);
3354 Assert.IsNull (ctor, "#M14");
3356 flags = BindingFlags.Static | BindingFlags.NonPublic |
3357 BindingFlags.Public;
3359 ctor = greenType.GetConstructor (flags, null,
3360 new Type [] { typeof (int), typeof (int) },
3361 new ParameterModifier [0]);
3362 Assert.IsNull (ctor, "#N1");
3364 ctor = greenType.GetConstructor (flags, null,
3365 new Type [] { typeof (string) },
3366 new ParameterModifier [0]);
3367 Assert.IsNull (ctor, "#N2");
3369 ctor = greenType.GetConstructor (flags, null,
3370 new Type [] { typeof (string), typeof (string) },
3371 new ParameterModifier [0]);
3372 Assert.IsNull (ctor, "#N3");
3374 ctor = greenType.GetConstructor (flags, null,
3375 new Type [] { typeof (int) },
3376 new ParameterModifier [0]);
3377 Assert.IsNull (ctor, "#N4");
3379 ctor = greenType.GetConstructor (flags, null,
3380 new Type [] { typeof (int), typeof (bool) },
3381 new ParameterModifier [0]);
3382 Assert.IsNull (ctor, "#N5");
3384 ctor = greenType.GetConstructor (flags, null,
3385 new Type [] { typeof (string), typeof (int) },
3386 new ParameterModifier [0]);
3387 Assert.IsNull (ctor, "#N6");
3389 ctor = greenType.GetConstructor (flags, null,
3391 new ParameterModifier [0]);
3392 Assert.IsNull (ctor, "#N7");
3394 ctor = redType.GetConstructor (flags, null,
3395 new Type [] { typeof (int), typeof (int) },
3396 new ParameterModifier [0]);
3397 Assert.IsNull (ctor, "#N8");
3399 ctor = redType.GetConstructor (flags, null,
3400 new Type [] { typeof (string) },
3401 new ParameterModifier [0]);
3402 Assert.IsNull (ctor, "#N9");
3404 ctor = redType.GetConstructor (flags, null,
3405 new Type [] { typeof (string), typeof (string) },
3406 new ParameterModifier [0]);
3407 Assert.IsNull (ctor, "#N10");
3409 ctor = redType.GetConstructor (flags, null,
3410 new Type [] { typeof (int) },
3411 new ParameterModifier [0]);
3412 Assert.IsNull (ctor, "#N11");
3414 ctor = redType.GetConstructor (flags, null,
3415 new Type [] { typeof (int), typeof (bool) },
3416 new ParameterModifier [0]);
3417 Assert.IsNull (ctor, "#N12");
3419 ctor = redType.GetConstructor (flags, null,
3420 new Type [] { typeof (string), typeof (int) },
3421 new ParameterModifier [0]);
3422 Assert.IsNull (ctor, "#N13");
3424 ctor = redType.GetConstructor (flags, null,
3426 new ParameterModifier [0]);
3427 Assert.IsNotNull (ctor, "#N14a");
3428 Assert.IsTrue (ctor.IsPrivate, "#N14b");
3429 Assert.IsTrue (ctor.IsStatic, "#N14c");
3430 Assert.AreEqual (0, ctor.GetParameters ().Length, "#N14d");
3431 Assert.IsFalse (ctor is ConstructorBuilder, "#N14e");
3434 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
3435 public void GetConstructor2_Incomplete ()
3437 TypeBuilder tb = module.DefineType (genTypeName ());
3438 ConstructorBuilder cb = tb.DefineConstructor (
3439 MethodAttributes.Public,
3440 CallingConventions.Standard,
3442 cb.GetILGenerator ().Emit (OpCodes.Ret);
3445 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3446 null, Type.EmptyTypes, new ParameterModifier [0]);
3448 } catch (NotSupportedException ex) {
3449 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3450 Assert.IsNull (ex.InnerException, "#3");
3451 Assert.IsNotNull (ex.Message, "#4");
3455 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
3456 public void GetConstructor3_Incomplete ()
3458 TypeBuilder tb = module.DefineType (genTypeName ());
3459 ConstructorBuilder cb = tb.DefineConstructor (
3460 MethodAttributes.Public,
3461 CallingConventions.Standard,
3463 cb.GetILGenerator ().Emit (OpCodes.Ret);
3466 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3467 null, CallingConventions.Standard, Type.EmptyTypes,
3468 new ParameterModifier [0]);
3470 } catch (NotSupportedException ex) {
3471 // The invoked member is not supported in a
3473 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3474 Assert.IsNull (ex.InnerException, "#3");
3475 Assert.IsNotNull (ex.Message, "#4");
3479 [Test] // GetConstructors ()
3480 [Category ("NotWorking")] // mcs depends on this
3481 public void GetConstructors1_Incomplete ()
3483 TypeBuilder tb = module.DefineType (genTypeName ());
3484 ConstructorBuilder cb = tb.DefineConstructor (
3485 MethodAttributes.Public,
3486 CallingConventions.Standard,
3488 cb.GetILGenerator ().Emit (OpCodes.Ret);
3491 tb.GetConstructors ();
3493 } catch (NotSupportedException ex) {
3494 // The invoked member is not supported in a
3496 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3497 Assert.IsNull (ex.InnerException, "#3");
3498 Assert.IsNotNull (ex.Message, "#4");
3502 [Test] // GetConstructors (BindingFlags)
3503 public void GetConstructors2_Complete ()
3506 ConstructorInfo [] ctors;
3508 TypeBuilder redType = module.DefineType (genTypeName (),
3509 TypeAttributes.Public);
3510 CreateMembers (redType, "Red", true);
3512 TypeBuilder greenType = module.DefineType (genTypeName (),
3513 TypeAttributes.Public, redType);
3514 CreateMembers (greenType, "Green", false);
3515 ConstructorBuilder cb = greenType.DefineConstructor (
3516 MethodAttributes.Public,
3517 CallingConventions.Standard,
3519 cb.GetILGenerator ().Emit (OpCodes.Ret);
3521 redType.CreateType ();
3522 greenType.CreateType ();
3524 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3526 ctors = greenType.GetConstructors (flags);
3527 Assert.AreEqual (0, ctors.Length, "#A1");
3529 ctors = redType.GetConstructors (flags);
3530 Assert.AreEqual (5, ctors.Length, "#A2");
3531 Assert.IsTrue (ctors [0].IsPrivate, "#A3a");
3532 Assert.IsFalse (ctors [0].IsStatic, "#A3b");
3533 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#A3c");
3534 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#A3d");
3535 Assert.IsTrue (ctors [1].IsFamily, "#A4a");
3536 Assert.IsFalse (ctors [1].IsStatic, "#A4b");
3537 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#A4c");
3538 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#A4d");
3539 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#A5a");
3540 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3541 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#A5c");
3542 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#A5d");
3543 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#A6a");
3544 Assert.IsFalse (ctors [3].IsStatic, "#A6b");
3545 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#A6c");
3546 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#A6d");
3547 Assert.IsTrue (ctors [4].IsAssembly, "#A7a");
3548 Assert.IsFalse (ctors [4].IsStatic, "#A7b");
3549 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#A7c");
3550 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#A7d");
3552 flags = BindingFlags.Instance | BindingFlags.Public;
3554 ctors = greenType.GetConstructors (flags);
3555 Assert.AreEqual (1, ctors.Length, "#B1");
3556 Assert.IsTrue (ctors [0].IsPublic, "#B2a");
3557 Assert.IsFalse (ctors [0].IsStatic, "#B2b");
3558 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#B2c");
3559 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B2d");
3561 ctors = redType.GetConstructors (flags);
3562 Assert.AreEqual (1, ctors.Length, "#B3");
3563 Assert.IsTrue (ctors [0].IsPublic, "#B4a");
3564 Assert.IsFalse (ctors [0].IsStatic, "#B4b");
3565 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#B4c");
3566 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B4d");
3568 flags = BindingFlags.Static | BindingFlags.Public;
3570 ctors = greenType.GetConstructors (flags);
3571 Assert.AreEqual (0, ctors.Length, "#C1");
3573 ctors = redType.GetConstructors (flags);
3574 Assert.AreEqual (0, ctors.Length, "#C2");
3576 flags = BindingFlags.Static | BindingFlags.NonPublic;
3578 ctors = greenType.GetConstructors (flags);
3579 Assert.AreEqual (0, ctors.Length, "#D1");
3581 ctors = redType.GetConstructors (flags);
3582 Assert.AreEqual (1, ctors.Length, "#D2");
3583 Assert.IsTrue (ctors [0].IsPrivate, "#D3a");
3584 Assert.IsTrue (ctors [0].IsStatic, "#D3b");
3585 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#D3c");
3586 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#D3d");
3588 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3589 BindingFlags.FlattenHierarchy;
3591 ctors = greenType.GetConstructors (flags);
3592 Assert.AreEqual (0, ctors.Length, "#E1");
3594 ctors = redType.GetConstructors (flags);
3595 Assert.AreEqual (5, ctors.Length, "#E2");
3596 Assert.IsTrue (ctors [0].IsPrivate, "#E3a");
3597 Assert.IsFalse (ctors [0].IsStatic, "#E3b");
3598 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#E3c");
3599 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#E3d");
3600 Assert.IsTrue (ctors [1].IsFamily, "#E4a");
3601 Assert.IsFalse (ctors [1].IsStatic, "#E4b");
3602 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#E4c");
3603 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#E4d");
3604 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#E5a");
3605 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3606 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#E5c");
3607 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#E5d");
3608 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#E6a");
3609 Assert.IsFalse (ctors [3].IsStatic, "#E6b");
3610 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#E6c");
3611 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#E6d");
3612 Assert.IsTrue (ctors [4].IsAssembly, "#E7a");
3613 Assert.IsFalse (ctors [4].IsStatic, "#E7b");
3614 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#E7c");
3615 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#E7d");
3617 flags = BindingFlags.Instance | BindingFlags.Public |
3618 BindingFlags.FlattenHierarchy;
3620 ctors = greenType.GetConstructors (flags);
3621 Assert.AreEqual (1, ctors.Length, "#F1");
3622 Assert.IsTrue (ctors [0].IsPublic, "#F2a");
3623 Assert.IsFalse (ctors [0].IsStatic, "#F2b");
3624 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#F2c");
3625 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F2d");
3627 ctors = redType.GetConstructors (flags);
3628 Assert.AreEqual (1, ctors.Length, "#F3");
3629 Assert.IsTrue (ctors [0].IsPublic, "#F4a");
3630 Assert.IsFalse (ctors [0].IsStatic, "#F4b");
3631 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#F4c");
3632 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F4d");
3634 flags = BindingFlags.Static | BindingFlags.Public |
3635 BindingFlags.FlattenHierarchy;
3637 ctors = greenType.GetConstructors (flags);
3638 Assert.AreEqual (0, ctors.Length, "#G1");
3640 ctors = redType.GetConstructors (flags);
3641 Assert.AreEqual (0, ctors.Length, "#G2");
3643 flags = BindingFlags.Static | BindingFlags.NonPublic |
3644 BindingFlags.FlattenHierarchy;
3646 ctors = greenType.GetConstructors (flags);
3647 Assert.AreEqual (0, ctors.Length, "#H1");
3649 ctors = redType.GetConstructors (flags);
3650 Assert.AreEqual (1, ctors.Length, "#H2");
3651 Assert.IsTrue (ctors [0].IsPrivate, "#H3a");
3652 Assert.IsTrue (ctors [0].IsStatic, "#H3b");
3653 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#H3c");
3654 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#H3d");
3656 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3657 BindingFlags.DeclaredOnly;
3659 ctors = greenType.GetConstructors (flags);
3660 Assert.AreEqual (0, ctors.Length, "#I1");
3662 ctors = redType.GetConstructors (flags);
3663 Assert.AreEqual (5, ctors.Length, "#I2");
3664 Assert.IsTrue (ctors [0].IsPrivate, "#I3a");
3665 Assert.IsFalse (ctors [0].IsStatic, "#I3b");
3666 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#I3c");
3667 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#I3d");
3668 Assert.IsTrue (ctors [1].IsFamily, "#I4a");
3669 Assert.IsFalse (ctors [1].IsStatic, "#I4b");
3670 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#I4c");
3671 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#I4d");
3672 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#I5a");
3673 Assert.IsFalse (ctors [2].IsStatic, "#I5b");
3674 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#I5c");
3675 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#I5d");
3676 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#I6a");
3677 Assert.IsFalse (ctors [3].IsStatic, "#I6b");
3678 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#I6c");
3679 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#I6d");
3680 Assert.IsTrue (ctors [4].IsAssembly, "#I7a");
3681 Assert.IsFalse (ctors [4].IsStatic, "#I7b");
3682 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#I7c");
3683 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#I7d");
3685 flags = BindingFlags.Instance | BindingFlags.Public |
3686 BindingFlags.DeclaredOnly;
3688 ctors = greenType.GetConstructors (flags);
3689 Assert.AreEqual (1, ctors.Length, "#J1");
3690 Assert.IsTrue (ctors [0].IsPublic, "#J2a");
3691 Assert.IsFalse (ctors [0].IsStatic, "#J2b");
3692 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#J2c");
3693 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J2d");
3695 ctors = redType.GetConstructors (flags);
3696 Assert.AreEqual (1, ctors.Length, "#J3");
3697 Assert.IsTrue (ctors [0].IsPublic, "#J4a");
3698 Assert.IsFalse (ctors [0].IsStatic, "#J4b");
3699 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#J4c");
3700 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J4d");
3702 flags = BindingFlags.Static | BindingFlags.Public |
3703 BindingFlags.DeclaredOnly;
3705 ctors = greenType.GetConstructors (flags);
3706 Assert.AreEqual (0, ctors.Length, "#K1");
3708 ctors = redType.GetConstructors (flags);
3709 Assert.AreEqual (0, ctors.Length, "#K2");
3711 flags = BindingFlags.Static | BindingFlags.NonPublic |
3712 BindingFlags.DeclaredOnly;
3714 ctors = greenType.GetConstructors (flags);
3715 Assert.AreEqual (0, ctors.Length, "#L1");
3717 ctors = redType.GetConstructors (flags);
3718 Assert.AreEqual (1, ctors.Length, "#L2");
3719 Assert.IsTrue (ctors [0].IsPrivate, "#L3a");
3720 Assert.IsTrue (ctors [0].IsStatic, "#L3b");
3721 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#L3c");
3722 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#L3d");
3724 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3725 BindingFlags.Public;
3727 ctors = greenType.GetConstructors (flags);
3728 Assert.AreEqual (1, ctors.Length, "#M1");
3729 Assert.IsTrue (ctors [0].IsPublic, "#M2a");
3730 Assert.IsFalse (ctors [0].IsStatic, "#M2b");
3731 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#M2c");
3732 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M2d");
3734 ctors = redType.GetConstructors (flags);
3735 Assert.AreEqual (6, ctors.Length, "#M3");
3736 Assert.IsTrue (ctors [0].IsPrivate, "#M4a");
3737 Assert.IsFalse (ctors [0].IsStatic, "#M4b");
3738 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#M4c");
3739 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M4d");
3740 Assert.IsTrue (ctors [1].IsFamily, "#M5a");
3741 Assert.IsFalse (ctors [1].IsStatic, "#M5b");
3742 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#M5c");
3743 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#M5d");
3744 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#M6a");
3745 Assert.IsFalse (ctors [2].IsStatic, "#M6b");
3746 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#M6c");
3747 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#M6d");
3748 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#M7a");
3749 Assert.IsFalse (ctors [3].IsStatic, "#M7b");
3750 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#M7c");
3751 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#M7d");
3752 Assert.IsTrue (ctors [4].IsPublic, "#M8a");
3753 Assert.IsFalse (ctors [4].IsStatic, "#M8b");
3754 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#M8c");
3755 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#M8d");
3756 Assert.IsTrue (ctors [5].IsAssembly, "#M9a");
3757 Assert.IsFalse (ctors [5].IsStatic, "#M9b");
3758 Assert.AreEqual (2, ctors [5].GetParameters ().Length, "#M9c");
3759 Assert.IsFalse (ctors [5] is ConstructorBuilder, "#M9d");
3761 flags = BindingFlags.Static | BindingFlags.NonPublic |
3762 BindingFlags.Public;
3764 ctors = greenType.GetConstructors (flags);
3765 Assert.AreEqual (0, ctors.Length, "#N1");
3767 ctors = redType.GetConstructors (flags);
3768 Assert.AreEqual (1, ctors.Length, "#N2");
3769 Assert.IsTrue (ctors [0].IsPrivate, "#N3a");
3770 Assert.IsTrue (ctors [0].IsStatic, "#N3b");
3771 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#N3c");
3772 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#N3d");
3775 [Test] // GetConstructors (BindingFlags)
3776 [Category ("NotWorking")] // mcs depends on this
3777 public void GetConstructors2_Incomplete ()
3779 TypeBuilder tb = module.DefineType (genTypeName ());
3780 ConstructorBuilder cb = tb.DefineConstructor (
3781 MethodAttributes.Public,
3782 CallingConventions.Standard,
3784 cb.GetILGenerator ().Emit (OpCodes.Ret);
3787 tb.GetConstructors (BindingFlags.Public |
3788 BindingFlags.Instance);
3790 } catch (NotSupportedException ex) {
3791 // The invoked member is not supported in a
3793 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3794 Assert.IsNull (ex.InnerException, "#3");
3795 Assert.IsNotNull (ex.Message, "#4");
3800 public void TestGetCustomAttributesIncomplete ()
3802 TypeBuilder tb = module.DefineType (genTypeName ());
3804 tb.GetCustomAttributes (false);
3806 } catch (NotSupportedException ex) {
3807 // The invoked member is not supported in a
3809 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3810 Assert.IsNull (ex.InnerException, "#3");
3811 Assert.IsNotNull (ex.Message, "#4");
3816 public void TestGetCustomAttributesComplete ()
3818 TypeBuilder tb = module.DefineType (genTypeName ());
3820 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3821 new Type [] { typeof (string) });
3823 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3824 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3826 tb.SetCustomAttribute (caBuilder);
3829 Assert.AreEqual (1, tb.GetCustomAttributes (false).Length);
3833 public void TestGetCustomAttributesOfTypeIncomplete ()
3835 TypeBuilder tb = module.DefineType (genTypeName ());
3837 tb.GetCustomAttributes (typeof (ObsoleteAttribute), false);
3839 } catch (NotSupportedException ex) {
3840 // The invoked member is not supported in a
3842 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3843 Assert.IsNull (ex.InnerException, "#3");
3844 Assert.IsNotNull (ex.Message, "#4");
3849 public void TestGetCustomAttributesOfTypeComplete ()
3851 TypeBuilder tb = module.DefineType (genTypeName ());
3853 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3854 new Type [] { typeof (string) });
3856 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3857 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3859 tb.SetCustomAttribute (caBuilder);
3862 Assert.AreEqual (1, tb.GetCustomAttributes (typeof (GuidAttribute), false).Length, "#1");
3863 Assert.AreEqual (0, tb.GetCustomAttributes (typeof (ObsoleteAttribute), false).Length, "#2");
3867 public void TestGetCustomAttributesOfNullTypeComplete ()
3869 TypeBuilder tb = module.DefineType (genTypeName ());
3872 tb.GetCustomAttributes (null, false);
3874 } catch (ArgumentNullException ex) {
3875 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
3876 Assert.IsNull (ex.InnerException, "#3");
3877 Assert.IsNotNull (ex.Message, "#4");
3878 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
3883 [Ignore ("mcs depends on this")]
3884 public void TestGetEventsIncomplete ()
3886 TypeBuilder tb = module.DefineType (genTypeName ());
3890 } catch (NotSupportedException ex) {
3891 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3892 Assert.IsNull (ex.InnerException, "#3");
3893 Assert.IsNotNull (ex.Message, "#4");
3899 public void TestGetEventsComplete ()
3901 TypeBuilder tb = module.DefineType (genTypeName ());
3903 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3904 typeof (void), new Type [] { typeof (Object) });
3905 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
3907 // create public event
3908 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
3909 typeof (ResolveEventHandler));
3910 eventbuilder.SetRaiseMethod (onclickMethod);
3912 Type emittedType = tb.CreateType ();
3914 Assert.AreEqual (1, tb.GetEvents ().Length, "#1");
3915 Assert.AreEqual (tb.GetEvents ().Length, emittedType.GetEvents ().Length, "#2");
3920 [Ignore ("mcs depends on this")]
3921 public void TestGetEventsFlagsIncomplete ()
3923 TypeBuilder tb = module.DefineType (genTypeName ());
3925 tb.GetEvents (BindingFlags.Public);
3927 } catch (NotSupportedException ex) {
3928 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3929 Assert.IsNull (ex.InnerException, "#3");
3930 Assert.IsNotNull (ex.Message, "#4");
3936 public void TestGetEventsFlagsComplete ()
3938 TypeBuilder tb = module.DefineType (genTypeName ());
3940 MethodBuilder onchangeMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3941 typeof (void), new Type [] { typeof (Object) });
3942 onchangeMethod.GetILGenerator ().Emit (OpCodes.Ret);
3944 // create public event
3945 EventBuilder changeEvent = tb.DefineEvent ("Change", EventAttributes.None,
3946 typeof (ResolveEventHandler));
3947 changeEvent.SetRaiseMethod (onchangeMethod);
3949 // create non-public event
3950 EventBuilder redoChangeEvent = tb.DefineEvent ("RedoChange", EventAttributes.None,
3951 typeof (ResolveEventHandler));
3953 Type emittedType = tb.CreateType ();
3955 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3956 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3957 Assert.AreEqual (2, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3958 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length,
3959 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3960 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length,
3961 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3962 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length,
3963 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3967 public void TestGetEventsFlagsComplete_Inheritance ()
3969 EventInfo [] events;
3972 TypeBuilder blueType = module.DefineType (genTypeName (),
3973 TypeAttributes.Public);
3974 CreateMembers (blueType, "Blue", false);
3976 TypeBuilder redType = module.DefineType (genTypeName (),
3977 TypeAttributes.Public, blueType);
3978 CreateMembers (redType, "Red", false);
3980 TypeBuilder greenType = module.DefineType (genTypeName (),
3981 TypeAttributes.Public, redType);
3982 CreateMembers (greenType, "Green", false);
3984 blueType.CreateType ();
3985 redType.CreateType ();
3986 greenType.CreateType ();
3988 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3989 events = greenType.GetEvents (flags);
3991 Assert.AreEqual (13, events.Length, "#A1");
3992 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#A2");
3993 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#A3");
3994 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#A4");
3995 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#A5");
3996 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#A6");
3997 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#A7");
3998 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#A8");
3999 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#A9");
4000 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#A10");
4001 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#A11");
4002 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#A12");
4003 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#A13");
4004 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#A14");
4006 flags = BindingFlags.Instance | BindingFlags.Public;
4007 events = greenType.GetEvents (flags);
4009 Assert.AreEqual (3, events.Length, "#B1");
4010 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#B2");
4011 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#B3");
4012 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#B4");
4014 flags = BindingFlags.Static | BindingFlags.Public;
4015 events = greenType.GetEvents (flags);
4017 Assert.AreEqual (1, events.Length, "#C1");
4018 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#C2");
4020 flags = BindingFlags.Static | BindingFlags.NonPublic;
4021 events = greenType.GetEvents (flags);
4023 Assert.AreEqual (5, events.Length, "#D1");
4024 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#D2");
4025 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#D3");
4026 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#D4");
4027 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#D5");
4028 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#D6");
4030 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4031 BindingFlags.FlattenHierarchy;
4032 events = greenType.GetEvents (flags);
4034 Assert.AreEqual (13, events.Length, "#E1");
4035 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#E2");
4036 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#E3");
4037 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#E4");
4038 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#E5");
4039 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#E6");
4040 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#E7");
4041 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#E8");
4042 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#E9");
4043 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#E10");
4044 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#E11");
4045 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#E12");
4046 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#E13");
4047 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#E14");
4049 flags = BindingFlags.Instance | BindingFlags.Public |
4050 BindingFlags.FlattenHierarchy;
4051 events = greenType.GetEvents (flags);
4053 Assert.AreEqual (3, events.Length, "#F1");
4054 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#F2");
4055 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#F3");
4056 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#F4");
4058 flags = BindingFlags.Static | BindingFlags.Public |
4059 BindingFlags.FlattenHierarchy;
4060 events = greenType.GetEvents (flags);
4062 Assert.AreEqual (3, events.Length, "#G1");
4063 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#G2");
4064 Assert.AreEqual ("OnPublicStaticRed", events [1].Name, "#G3");
4065 Assert.AreEqual ("OnPublicStaticBlue", events [2].Name, "#G4");
4067 flags = BindingFlags.Static | BindingFlags.NonPublic |
4068 BindingFlags.FlattenHierarchy;
4069 events = greenType.GetEvents (flags);
4071 Assert.AreEqual (13, events.Length, "#H1");
4072 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#H2");
4073 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#H3");
4074 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#H4");
4075 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#H5");
4076 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#H6");
4077 Assert.AreEqual ("OnFamilyStaticRed", events [5].Name, "#H7");
4078 Assert.AreEqual ("OnFamANDAssemStaticRed", events [6].Name, "#H8");
4079 Assert.AreEqual ("OnFamORAssemStaticRed", events [7].Name, "#H9");
4080 Assert.AreEqual ("OnAssemblyStaticRed", events [8].Name, "#H10");
4081 Assert.AreEqual ("OnFamilyStaticBlue", events [9].Name, "#H11");
4082 Assert.AreEqual ("OnFamANDAssemStaticBlue", events [10].Name, "#H12");
4083 Assert.AreEqual ("OnFamORAssemStaticBlue", events [11].Name, "#H13");
4084 Assert.AreEqual ("OnAssemblyStaticBlue", events [12].Name, "#H14");
4086 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4087 BindingFlags.DeclaredOnly;
4088 events = greenType.GetEvents (flags);
4090 Assert.AreEqual (5, events.Length, "#I1");
4091 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#I2");
4092 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#I3");
4093 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#I4");
4094 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#I5");
4095 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#I6");
4097 flags = BindingFlags.Instance | BindingFlags.Public |
4098 BindingFlags.DeclaredOnly;
4099 events = greenType.GetEvents (flags);
4101 Assert.AreEqual (1, events.Length, "#J1");
4102 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#J2");
4104 flags = BindingFlags.Static | BindingFlags.Public |
4105 BindingFlags.DeclaredOnly;
4106 events = greenType.GetEvents (flags);
4108 Assert.AreEqual (1, events.Length, "#K1");
4109 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#K2");
4111 flags = BindingFlags.Static | BindingFlags.NonPublic |
4112 BindingFlags.DeclaredOnly;
4113 events = greenType.GetEvents (flags);
4115 Assert.AreEqual (5, events.Length, "#L1");
4116 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#L2");
4117 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#L3");
4118 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#L4");
4119 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#L5");
4120 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#L6");
4122 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4123 BindingFlags.Public;
4124 events = greenType.GetEvents (flags);
4126 Assert.AreEqual (16, events.Length, "#M1");
4127 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#M2");
4128 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#M3");
4129 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#M4");
4130 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#M5");
4131 Assert.AreEqual ("OnPublicInstanceGreen", events [4].Name, "#M6");
4132 Assert.AreEqual ("OnAssemblyInstanceGreen", events [5].Name, "#M7");
4133 Assert.AreEqual ("OnFamilyInstanceRed", events [6].Name, "#M8");
4134 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [7].Name, "#M9");
4135 Assert.AreEqual ("OnFamORAssemInstanceRed", events [8].Name, "#M10");
4136 Assert.AreEqual ("OnPublicInstanceRed", events [9].Name, "#M11");
4137 Assert.AreEqual ("OnAssemblyInstanceRed", events [10].Name, "#M12");
4138 Assert.AreEqual ("OnFamilyInstanceBlue", events [11].Name, "#M13");
4139 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [12].Name, "#M14");
4140 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [13].Name, "#M15");
4141 Assert.AreEqual ("OnPublicInstanceBlue", events [14].Name, "#M16");
4142 Assert.AreEqual ("OnAssemblyInstanceBlue", events [15].Name, "#M17");
4144 flags = BindingFlags.Static | BindingFlags.NonPublic |
4145 BindingFlags.Public;
4146 events = greenType.GetEvents (flags);
4148 Assert.AreEqual (6, events.Length, "#N1");
4149 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#N2");
4150 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#N3");
4151 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#N4");
4152 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#N5");
4153 Assert.AreEqual ("OnPublicStaticGreen", events [4].Name, "#N6");
4154 Assert.AreEqual ("OnAssemblyStaticGreen", events [5].Name, "#N7");
4158 [Ignore ("mcs depends on this")]
4159 public void TestGetEventIncomplete ()
4161 TypeBuilder tb = module.DefineType (genTypeName ());
4163 tb.GetEvent ("FOO");
4165 } catch (NotSupportedException ex) {
4166 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4167 Assert.IsNull (ex.InnerException, "#3");
4168 Assert.IsNotNull (ex.Message, "#4");
4174 public void TestGetEventComplete ()
4176 TypeBuilder tb = module.DefineType (genTypeName ());
4178 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4179 typeof (void), new Type [] { typeof (Object) });
4180 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4182 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4183 typeof (ResolveEventHandler));
4184 eventbuilder.SetRaiseMethod (onclickMethod);
4186 Type emittedType = tb.CreateType ();
4188 Assert.IsNotNull (tb.GetEvent ("Change"));
4189 Assert.AreEqual (tb.GetEvent ("Change"), emittedType.GetEvent ("Change"));
4190 Assert.IsNull (tb.GetEvent ("NotChange"));
4191 Assert.AreEqual (tb.GetEvent ("NotChange"), emittedType.GetEvent ("NotChange"));
4195 [Ignore ("mcs depends on this")]
4196 public void TestGetEventFlagsIncomplete ()
4198 TypeBuilder tb = module.DefineType (genTypeName ());
4200 tb.GetEvent ("FOO", BindingFlags.Public);
4202 } catch (NotSupportedException ex) {
4203 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4204 Assert.IsNull (ex.InnerException, "#3");
4205 Assert.IsNotNull (ex.Message, "#4");
4211 public void TestGetEventFlagsComplete ()
4213 TypeBuilder tb = module.DefineType (genTypeName ());
4215 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4216 typeof (void), new Type [] { typeof (Object) });
4217 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4219 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4220 typeof (ResolveEventHandler));
4221 eventbuilder.SetRaiseMethod (onclickMethod);
4223 Type emittedType = tb.CreateType ();
4225 Assert.IsNotNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4226 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public),
4227 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4228 Assert.IsNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4229 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic),
4230 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4234 public void TestGetEventFlagsComplete_Inheritance ()
4238 TypeBuilder blueType = module.DefineType (genTypeName (),
4239 TypeAttributes.Public);
4240 CreateMembers (blueType, "Blue", false);
4242 TypeBuilder redType = module.DefineType (genTypeName (),
4243 TypeAttributes.Public, blueType);
4244 CreateMembers (redType, "Red", false);
4246 TypeBuilder greenType = module.DefineType (genTypeName (),
4247 TypeAttributes.Public, redType);
4248 CreateMembers (greenType, "Green", false);
4250 blueType.CreateType ();
4251 redType.CreateType ();
4252 greenType.CreateType ();
4254 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4256 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#A1");
4257 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#A2");
4258 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#A3");
4259 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#A4");
4260 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#A5");
4261 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#A6");
4262 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#A7");
4263 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#A8");
4264 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#A9");
4265 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#A10");
4266 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#A11");
4267 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#A12");
4268 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#A13");
4269 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#A14");
4270 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#A15");
4271 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#A16");
4272 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#A17");
4273 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#A18");
4274 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#A19");
4275 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#A20");
4276 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#A21");
4277 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#A22");
4278 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#A23");
4279 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#A24");
4280 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#A25");
4281 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#A26");
4282 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#A27");
4283 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#A28");
4284 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#A29");
4285 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#A30");
4286 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#A31");
4287 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#A32");
4288 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#A33");
4289 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#A34");
4290 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#A35");
4291 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#A36");
4293 flags = BindingFlags.Instance | BindingFlags.Public;
4295 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#B1");
4296 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#B2");
4297 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#B3");
4298 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#B4");
4299 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#B5");
4300 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#B6");
4301 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#B7");
4302 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#B8");
4303 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#B9");
4304 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#B10");
4305 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#B11");
4306 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#B12");
4307 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#B13");
4308 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#B14");
4309 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#B15");
4310 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#B16");
4311 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#B17");
4312 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#B18");
4313 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#B19");
4314 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#B20");
4315 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#B21");
4316 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#B22");
4317 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#B23");
4318 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#B24");
4319 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#B25");
4320 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#B26");
4321 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#B27");
4322 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#B28");
4323 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#B29");
4324 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#B30");
4325 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#B31");
4326 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#B32");
4327 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#B33");
4328 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#B34");
4329 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#B35");
4330 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#B36");
4332 flags = BindingFlags.Static | BindingFlags.Public;
4334 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#C1");
4335 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#C2");
4336 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#C3");
4337 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#C4");
4338 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#C5");
4339 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#C6");
4340 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#C7");
4341 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#C8");
4342 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#C9");
4343 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#C10");
4344 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#C11");
4345 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#C12");
4346 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#C13");
4347 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#C14");
4348 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#C15");
4349 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#C16");
4350 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#C17");
4351 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#C18");
4352 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#C19");
4353 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#C20");
4354 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#C21");
4355 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#C22");
4356 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#C23");
4357 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#C24");
4358 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#C25");
4359 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#C26");
4360 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#C27");
4361 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#C28");
4362 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#C29");
4363 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#C30");
4364 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#C31");
4365 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#C32");
4366 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#C33");
4367 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#C34");
4368 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#C35");
4369 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#C36");
4371 flags = BindingFlags.Static | BindingFlags.NonPublic;
4373 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#D1");
4374 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#D2");
4375 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#D3");
4376 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#D4");
4377 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#D5");
4378 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#D6");
4379 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#D7");
4380 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#D8");
4381 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#D9");
4382 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#D10");
4383 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#D11");
4384 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#D12");
4385 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#D13");
4386 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#D14");
4387 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#D15");
4388 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#D16");
4389 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#D17");
4390 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#D18");
4391 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#D19");
4392 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#D20");
4393 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#D21");
4394 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#D22");
4395 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#D23");
4396 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#D24");
4397 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#D25");
4398 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#D26");
4399 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#D27");
4400 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#D28");
4401 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#D29");
4402 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#D30");
4403 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#D31");
4404 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#D32");
4405 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#D33");
4406 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#D34");
4407 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#D35");
4408 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#D36");
4410 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4411 BindingFlags.FlattenHierarchy;
4413 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#E1");
4414 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#E2");
4415 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#E3");
4416 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#E4");
4417 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#E5");
4418 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#E6");
4419 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#E7");
4420 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#E8");
4421 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#E9");
4422 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#E10");
4423 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#E11");
4424 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#E12");
4425 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#E13");
4426 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#E14");
4427 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#E15");
4428 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#E16");
4429 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#E17");
4430 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#E18");
4431 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#E19");
4432 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#E20");
4433 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#E21");
4434 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#E22");
4435 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#E23");
4436 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#E24");
4437 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#E25");
4438 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#E26");
4439 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#E27");
4440 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#E28");
4441 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#E29");
4442 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#E30");
4443 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#E31");
4444 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#E32");
4445 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#E33");
4446 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#E34");
4447 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#E35");
4448 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#E36");
4450 flags = BindingFlags.Instance | BindingFlags.Public |
4451 BindingFlags.FlattenHierarchy;
4453 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#F1");
4454 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#F2");
4455 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#F3");
4456 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#F4");
4457 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#F5");
4458 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#F6");
4459 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#F7");
4460 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#F8");
4461 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#F9");
4462 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#F10");
4463 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#F11");
4464 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#F12");
4465 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#F13");
4466 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#F14");
4467 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#F15");
4468 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#F16");
4469 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#F17");
4470 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#F18");
4471 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#F19");
4472 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#F20");
4473 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#F21");
4474 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#F22");
4475 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#F23");
4476 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#F24");
4477 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#F25");
4478 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#F26");
4479 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#F27");
4480 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#F28");
4481 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#F29");
4482 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#F30");
4483 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#F31");
4484 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#F32");
4485 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#F33");
4486 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#F34");
4487 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#F35");
4488 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#F36");
4490 flags = BindingFlags.Static | BindingFlags.Public |
4491 BindingFlags.FlattenHierarchy;
4493 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#G1");
4494 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#G2");
4495 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#G3");
4496 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#G4");
4497 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#G5");
4498 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#G6");
4499 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#G7");
4500 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#G8");
4501 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#G9");
4502 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#G10");
4503 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#G11");
4504 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#G12");
4505 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#G13");
4506 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#G14");
4507 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#G15");
4508 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#G16");
4509 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#G17");
4510 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#G18");
4511 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#G19");
4512 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#G20");
4513 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#G21");
4514 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#G22");
4515 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#G23");
4516 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#G24");
4517 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#G25");
4518 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#G26");
4519 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#G27");
4520 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#G28");
4521 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#G29");
4522 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#G30");
4523 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#G31");
4524 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#G32");
4525 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#G33");
4526 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#G34");
4527 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#G35");
4528 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#G36");
4530 flags = BindingFlags.Static | BindingFlags.NonPublic |
4531 BindingFlags.FlattenHierarchy;
4533 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#H1");
4534 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#H2");
4535 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#H3");
4536 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#H4");
4537 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#H5");
4538 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#H6");
4539 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#H7");
4540 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#H8");
4541 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#H9");
4542 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#H10");
4543 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#H11");
4544 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#H12");
4545 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#H13");
4546 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#H14");
4547 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#H15");
4548 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#H16");
4549 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#H17");
4550 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#H18");
4551 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#H19");
4552 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#H20");
4553 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#H21");
4554 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#H22");
4555 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#H23");
4556 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#H24");
4557 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#H25");
4558 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#H26");
4559 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#H27");
4560 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#H28");
4561 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#H29");
4562 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#H30");
4563 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#H31");
4564 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#H32");
4565 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#H33");
4566 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#H34");
4567 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#H35");
4568 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#H36");
4570 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4571 BindingFlags.DeclaredOnly;
4573 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#I1");
4574 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#I2");
4575 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#I3");
4576 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#I4");
4577 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#I5");
4578 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#I6");
4579 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#I7");
4580 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#I8");
4581 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#I9");
4582 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#I10");
4583 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#I11");
4584 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#I12");
4585 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#I13");
4586 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#I14");
4587 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#I15");
4588 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#I16");
4589 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#I17");
4590 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#I18");
4591 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#I19");
4592 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#I20");
4593 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#I21");
4594 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#I22");
4595 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#I23");
4596 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#I24");
4597 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#I25");
4598 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#I26");
4599 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#I27");
4600 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#I28");
4601 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#I29");
4602 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#I30");
4603 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#I31");
4604 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#I32");
4605 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#I33");
4606 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#I34");
4607 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#I35");
4608 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#I36");
4610 flags = BindingFlags.Instance | BindingFlags.Public |
4611 BindingFlags.DeclaredOnly;
4613 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#J1");
4614 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#J2");
4615 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#J3");
4616 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#J4");
4617 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#J5");
4618 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#J6");
4619 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#J7");
4620 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#J8");
4621 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#J9");
4622 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#J10");
4623 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#J11");
4624 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#J12");
4625 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#J13");
4626 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#J14");
4627 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#J15");
4628 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#J16");
4629 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#J17");
4630 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#J18");
4631 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#J19");
4632 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#J20");
4633 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#J21");
4634 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#J22");
4635 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#J23");
4636 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#J24");
4637 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#J25");
4638 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#J26");
4639 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#J27");
4640 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#J28");
4641 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#J29");
4642 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#J30");
4643 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#J31");
4644 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#J32");
4645 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#J33");
4646 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#J34");
4647 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#J35");
4648 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#J36");
4650 flags = BindingFlags.Static | BindingFlags.Public |
4651 BindingFlags.DeclaredOnly;
4653 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#K1");
4654 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#K2");
4655 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#K3");
4656 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#K4");
4657 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#K5");
4658 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#K6");
4659 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#K7");
4660 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#K8");
4661 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#K9");
4662 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#K10");
4663 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#K11");
4664 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#K12");
4665 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#K13");
4666 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#K14");
4667 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#K15");
4668 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#K16");
4669 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#K17");
4670 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#K18");
4671 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#K19");
4672 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#K20");
4673 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#K21");
4674 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#K22");
4675 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#K23");
4676 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#K24");
4677 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#K25");
4678 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#K26");
4679 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#K27");
4680 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#K28");
4681 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#K29");
4682 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#K30");
4683 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#K31");
4684 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#K32");
4685 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#K33");
4686 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#K34");
4687 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#K35");
4688 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#K36");
4690 flags = BindingFlags.Static | BindingFlags.NonPublic |
4691 BindingFlags.DeclaredOnly;
4693 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#L1");
4694 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#L2");
4695 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#L3");
4696 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#L4");
4697 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#L5");
4698 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#L6");
4699 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#L7");
4700 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#L8");
4701 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#L9");
4702 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#L10");
4703 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#L11");
4704 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#L12");
4705 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#L13");
4706 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#L14");
4707 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#L15");
4708 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#L16");
4709 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#L17");
4710 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#L18");
4711 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#L19");
4712 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#L20");
4713 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#L21");
4714 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#L22");
4715 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#L23");
4716 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#L24");
4717 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#L25");
4718 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#L26");
4719 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#L27");
4720 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#L28");
4721 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#L29");
4722 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#L30");
4723 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#L31");
4724 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#L32");
4725 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#L33");
4726 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#L34");
4727 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#L35");
4728 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#L36");
4730 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4731 BindingFlags.Public;
4733 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#M1");
4734 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#M2");
4735 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#M3");
4736 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#M4");
4737 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#M5");
4738 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#M6");
4739 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#M7");
4740 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#M8");
4741 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#M9");
4742 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#M10");
4743 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#M11");
4744 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#M12");
4745 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#M13");
4746 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#M14");
4747 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#M15");
4748 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#M16");
4749 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#M17");
4750 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#M18");
4751 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#M19");
4752 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#M20");
4753 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#M21");
4754 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#M22");
4755 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#M23");
4756 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#M24");
4757 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#M25");
4758 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#M26");
4759 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#M27");
4760 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#M28");
4761 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#M29");
4762 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#M30");
4763 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#M31");
4764 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#M32");
4765 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#M33");
4766 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#M34");
4767 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#M35");
4768 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#M36");
4770 flags = BindingFlags.Static | BindingFlags.NonPublic |
4771 BindingFlags.Public;
4773 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#N1");
4774 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#N2");
4775 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#N3");
4776 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#N4");
4777 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#N5");
4778 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#N6");
4779 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#N7");
4780 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#N8");
4781 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#N9");
4782 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#N10");
4783 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#N11");
4784 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#N12");
4785 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#N13");
4786 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#N14");
4787 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#N15");
4788 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#N16");
4789 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#N17");
4790 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#N18");
4791 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#N19");
4792 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#N20");
4793 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#N21");
4794 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#N22");
4795 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#N23");
4796 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#N24");
4797 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#N25");
4798 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#N26");
4799 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#N27");
4800 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#N28");
4801 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#N29");
4802 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#N30");
4803 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#N31");
4804 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#N32");
4805 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#N33");
4806 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#N34");
4807 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#N35");
4808 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#N36");
4812 [Category ("NotWorking")] // mcs depends on this
4813 public void TestGetFieldsIncomplete_MS ()
4815 TypeBuilder tb = module.DefineType (genTypeName ());
4816 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4820 } catch (NotSupportedException ex) {
4821 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4822 Assert.IsNull (ex.InnerException, "#3");
4823 Assert.IsNotNull (ex.Message, "#4");
4828 [Category ("NotDotNet")] // mcs depends on this
4829 public void TestGetFieldsIncomplete_Mono ()
4831 TypeBuilder tb = module.DefineType (genTypeName ());
4832 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4833 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4834 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4835 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4837 FieldInfo [] fields = tb.GetFields ();
4838 Assert.AreEqual (2, fields.Length, "#A1");
4839 Assert.AreEqual ("Sex", fields [0].Name, "#A2");
4840 Assert.AreEqual ("MALE", fields [1].Name, "#A3");
4842 tb = module.DefineType (genTypeName ());
4843 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4844 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4845 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4846 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4847 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4848 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4850 fields = tb.GetFields ();
4851 Assert.AreEqual (4, fields.Length, "#B1");
4852 Assert.AreEqual ("First", fields [0].Name, "#B2");
4853 Assert.AreEqual ("Second", fields [1].Name, "#B3");
4854 Assert.AreEqual ("Sex", fields [2].Name, "#B4");
4855 Assert.AreEqual ("MALE", fields [3].Name, "#B5");
4859 public void TestGetFieldsComplete ()
4861 TypeBuilder tb = module.DefineType (genTypeName ());
4862 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4864 Type emittedType = tb.CreateType ();
4865 FieldInfo [] dynamicFields = tb.GetFields ();
4866 FieldInfo [] emittedFields = emittedType.GetFields ();
4868 Assert.AreEqual (1, dynamicFields.Length, "#A1");
4869 Assert.AreEqual (dynamicFields.Length, emittedFields.Length, "#A2");
4870 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#A3");
4871 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#A4");
4874 object value = Activator.CreateInstance (emittedType);
4875 emittedFields [0].SetValue (value, 5);
4876 Assert.AreEqual (5, emittedFields [0].GetValue (value), "#B1");
4877 Assert.AreEqual (5, dynamicFields [0].GetValue (value), "#B2");
4878 dynamicFields [0].SetValue (value, 4);
4879 Assert.AreEqual (4, emittedFields [0].GetValue (value), "#B3");
4880 Assert.AreEqual (4, dynamicFields [0].GetValue (value), "#B4");
4883 [Test] // bug #82625 / 325292
4884 public void TestGetFieldsComplete_Generic ()
4886 // FIXME: merge this with TestGetFieldsComplete when
4887 // bug #82625 is fixed
4891 FieldInfo [] dynamicFields;
4892 FieldInfo [] emittedFields;
4894 tb = module.DefineType (genTypeName ());
4895 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4896 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4897 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4898 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4899 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4900 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4902 emittedType = tb.CreateType ();
4903 dynamicFields = tb.GetFields ();
4904 emittedFields = emittedType.GetFields ();
4906 Assert.AreEqual (4, dynamicFields.Length, "#C1");
4907 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#C2");
4908 Assert.IsFalse ((dynamicFields [1]) is FieldBuilder, "#C3");
4909 Assert.IsFalse ((dynamicFields [2]) is FieldBuilder, "#C4");
4910 Assert.IsFalse ((dynamicFields [3]) is FieldBuilder, "#C5");
4911 Assert.AreEqual ("First", dynamicFields [0].Name, "#C6");
4912 Assert.AreEqual ("Second", dynamicFields [1].Name, "#C7");
4913 Assert.AreEqual ("Sex", dynamicFields [2].Name, "#C8");
4914 Assert.AreEqual ("MALE", dynamicFields [3].Name, "#C9");
4916 Assert.AreEqual (4, emittedFields.Length, "#D1");
4917 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#D2");
4918 Assert.IsFalse ((emittedFields [1]) is FieldBuilder, "#D3");
4919 Assert.IsFalse ((emittedFields [2]) is FieldBuilder, "#D4");
4920 Assert.IsFalse ((emittedFields [3]) is FieldBuilder, "#D5");
4921 Assert.AreEqual ("First", emittedFields [0].Name, "#D6");
4922 Assert.AreEqual ("Second", emittedFields [1].Name, "#D7");
4923 Assert.AreEqual ("Sex", emittedFields [2].Name, "#D8");
4924 Assert.AreEqual ("MALE", emittedFields [3].Name, "#D9");
4928 [Category ("NotWorking")] // mcs depends on this
4929 public void TestGetFieldsFlagsIncomplete_MS ()
4931 TypeBuilder tb = module.DefineType (genTypeName ());
4932 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4934 tb.GetFields (BindingFlags.Instance | BindingFlags.Public);
4936 } catch (NotSupportedException ex) {
4937 // The invoked member is not supported in a
4939 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4940 Assert.IsNull (ex.InnerException, "#3");
4941 Assert.IsNotNull (ex.Message, "#4");
4946 [Category ("NotDotNet")] // mcs depends on this
4947 public void TestGetFieldsFlagsIncomplete_Mono ()
4949 FieldInfo [] fields;
4951 TypeBuilder tb = module.DefineType (genTypeName ());
4952 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4953 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4954 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4955 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4957 fields = tb.GetFields (BindingFlags.Public |
4958 BindingFlags.NonPublic | BindingFlags.Instance);
4959 Assert.AreEqual (2, fields.Length, "#A1");
4960 Assert.AreEqual ("name", fields [0].Name, "#A2");
4961 Assert.AreEqual ("Sex", fields [1].Name, "#A3");
4963 fields = tb.GetFields (BindingFlags.Public |
4964 BindingFlags.Instance | BindingFlags.Static);
4965 Assert.AreEqual (2, fields.Length, "#B1");
4966 Assert.AreEqual ("Sex", fields [0].Name, "#B2");
4967 Assert.AreEqual ("MALE", fields [1].Name, "#B3");
4969 fields = tb.GetFields (BindingFlags.Public |
4970 BindingFlags.NonPublic | BindingFlags.Instance |
4971 BindingFlags.Static);
4972 Assert.AreEqual (4, fields.Length, "#C1");
4973 Assert.AreEqual ("name", fields [0].Name, "#C2");
4974 Assert.AreEqual ("Sex", fields [1].Name, "#C3");
4975 Assert.AreEqual ("MALE", fields [2].Name, "#C4");
4976 Assert.AreEqual ("FEMALE", fields [3].Name, "#C5");
4980 public void TestGetFieldsFlagsComplete ()
4982 TypeBuilder tb = module.DefineType (genTypeName ());
4983 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4985 Type emittedType = tb.CreateType ();
4987 Assert.AreEqual (1, tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4988 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length,
4989 emittedType.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4990 Assert.AreEqual (0, tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4991 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length,
4992 emittedType.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4996 public void TestGetFieldsFlagsComplete_Inheritance ()
4998 FieldInfo [] fields;
5001 TypeBuilder blueType = module.DefineType (genTypeName (),
5002 TypeAttributes.Public);
5003 CreateMembers (blueType, "Blue", false);
5005 TypeBuilder redType = module.DefineType (genTypeName (),
5006 TypeAttributes.Public, blueType);
5007 CreateMembers (redType, "Red", false);
5009 TypeBuilder greenType = module.DefineType (genTypeName (),
5010 TypeAttributes.Public, redType);
5011 CreateMembers (greenType, "Green", false);
5013 blueType.CreateType ();
5014 redType.CreateType ();
5015 greenType.CreateType ();
5017 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5018 fields = greenType.GetFields (flags);
5020 Assert.AreEqual (13, fields.Length, "#A1");
5021 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#A2");
5022 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#A3");
5023 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#A4");
5024 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#A5");
5025 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#A6");
5026 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#A7");
5027 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#A8");
5028 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#A9");
5029 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#A10");
5030 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#A11");
5031 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#A12");
5032 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#A13");
5033 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#A14");
5035 flags = BindingFlags.Instance | BindingFlags.Public;
5036 fields = greenType.GetFields (flags);
5038 Assert.AreEqual (3, fields.Length, "#B1");
5039 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#B2");
5040 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#B3");
5041 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#B4");
5043 flags = BindingFlags.Static | BindingFlags.Public;
5044 fields = greenType.GetFields (flags);
5046 Assert.AreEqual (1, fields.Length, "#C1");
5047 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#C2");
5049 flags = BindingFlags.Static | BindingFlags.NonPublic;
5050 fields = greenType.GetFields (flags);
5052 Assert.AreEqual (5, fields.Length, "#D1");
5053 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#D2");
5054 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#D3");
5055 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#D4");
5056 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#D5");
5057 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#D6");
5059 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5060 BindingFlags.FlattenHierarchy;
5061 fields = greenType.GetFields (flags);
5063 Assert.AreEqual (13, fields.Length, "#E1");
5064 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#E2");
5065 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#E3");
5066 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#E4");
5067 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#E5");
5068 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#E6");
5069 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#E7");
5070 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#E8");
5071 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#E9");
5072 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#E10");
5073 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#E11");
5074 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#E12");
5075 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#E13");
5076 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#E14");
5078 flags = BindingFlags.Instance | BindingFlags.Public |
5079 BindingFlags.FlattenHierarchy;
5080 fields = greenType.GetFields (flags);
5082 Assert.AreEqual (3, fields.Length, "#F1");
5083 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#F2");
5084 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#F3");
5085 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#F4");
5087 flags = BindingFlags.Static | BindingFlags.Public |
5088 BindingFlags.FlattenHierarchy;
5089 fields = greenType.GetFields (flags);
5091 Assert.AreEqual (3, fields.Length, "#G1");
5092 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#G2");
5093 Assert.AreEqual ("publicStaticRed", fields [1].Name, "#G3");
5094 Assert.AreEqual ("publicStaticBlue", fields [2].Name, "#G4");
5096 flags = BindingFlags.Static | BindingFlags.NonPublic |
5097 BindingFlags.FlattenHierarchy;
5098 fields = greenType.GetFields (flags);
5100 Assert.AreEqual (13, fields.Length, "#H1");
5101 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#H2");
5102 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#H3");
5103 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#H4");
5104 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#H5");
5105 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#H6");
5106 Assert.AreEqual ("familyStaticRed", fields [5].Name, "#H7");
5107 Assert.AreEqual ("famANDAssemStaticRed", fields [6].Name, "#H8");
5108 Assert.AreEqual ("famORAssemStaticRed", fields [7].Name, "#H9");
5109 Assert.AreEqual ("assemblyStaticRed", fields [8].Name, "#H10");
5110 Assert.AreEqual ("familyStaticBlue", fields [9].Name, "#H11");
5111 Assert.AreEqual ("famANDAssemStaticBlue", fields [10].Name, "#H12");
5112 Assert.AreEqual ("famORAssemStaticBlue", fields [11].Name, "#H13");
5113 Assert.AreEqual ("assemblyStaticBlue", fields [12].Name, "#H14");
5115 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5116 BindingFlags.DeclaredOnly;
5117 fields = greenType.GetFields (flags);
5119 Assert.AreEqual (5, fields.Length, "#I1");
5120 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#I2");
5121 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#I3");
5122 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#I4");
5123 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#I5");
5124 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#I6");
5126 flags = BindingFlags.Instance | BindingFlags.Public |
5127 BindingFlags.DeclaredOnly;
5128 fields = greenType.GetFields (flags);
5130 Assert.AreEqual (1, fields.Length, "#J1");
5131 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#J2");
5133 flags = BindingFlags.Static | BindingFlags.Public |
5134 BindingFlags.DeclaredOnly;
5135 fields = greenType.GetFields (flags);
5137 Assert.AreEqual (1, fields.Length, "#K1");
5138 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#K2");
5140 flags = BindingFlags.Static | BindingFlags.NonPublic |
5141 BindingFlags.DeclaredOnly;
5142 fields = greenType.GetFields (flags);
5144 Assert.AreEqual (5, fields.Length, "#L1");
5145 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#L2");
5146 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#L3");
5147 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#L4");
5148 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#L5");
5149 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#L6");
5151 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5152 BindingFlags.Public;
5153 fields = greenType.GetFields (flags);
5155 Assert.AreEqual (16, fields.Length, "#M1");
5156 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#M2");
5157 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#M3");
5158 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#M4");
5159 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#M5");
5160 Assert.AreEqual ("publicInstanceGreen", fields [4].Name, "#M6");
5161 Assert.AreEqual ("assemblyInstanceGreen", fields [5].Name, "#M7");
5162 Assert.AreEqual ("familyInstanceRed", fields [6].Name, "#M8");
5163 Assert.AreEqual ("famANDAssemInstanceRed", fields [7].Name, "#M9");
5164 Assert.AreEqual ("famORAssemInstanceRed", fields [8].Name, "#M10");
5165 Assert.AreEqual ("publicInstanceRed", fields [9].Name, "#M11");
5166 Assert.AreEqual ("assemblyInstanceRed", fields [10].Name, "#M12");
5167 Assert.AreEqual ("familyInstanceBlue", fields [11].Name, "#M13");
5168 Assert.AreEqual ("famANDAssemInstanceBlue", fields [12].Name, "#M14");
5169 Assert.AreEqual ("famORAssemInstanceBlue", fields [13].Name, "#M15");
5170 Assert.AreEqual ("publicInstanceBlue", fields [14].Name, "#M16");
5171 Assert.AreEqual ("assemblyInstanceBlue", fields [15].Name, "#M17");
5173 flags = BindingFlags.Static | BindingFlags.NonPublic |
5174 BindingFlags.Public;
5175 fields = greenType.GetFields (flags);
5177 Assert.AreEqual (6, fields.Length, "#N1");
5178 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#N2");
5179 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#N3");
5180 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#N4");
5181 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#N5");
5182 Assert.AreEqual ("publicStaticGreen", fields [4].Name, "#N6");
5183 Assert.AreEqual ("assemblyStaticGreen", fields [5].Name, "#N7");
5187 [Category ("NotWorking")] // mcs depends on this
5188 public void TestGetFieldIncomplete_MS ()
5190 TypeBuilder tb = module.DefineType (genTypeName ());
5191 tb.DefineField ("test", typeof (int), FieldAttributes.Public);
5193 tb.GetField ("test");
5195 } catch (NotSupportedException ex) {
5196 // The invoked member is not supported in a
5198 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5199 Assert.IsNull (ex.InnerException, "#3");
5200 Assert.IsNotNull (ex.Message, "#4");
5205 [Category ("NotDotNet")] // mcs depends on this
5206 public void TestGetFieldIncomplete_Mono ()
5208 TypeBuilder tb = module.DefineType (genTypeName ());
5209 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5210 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5212 FieldInfo field = tb.GetField ("TestField");
5213 Assert.IsNotNull (field, "#A1");
5214 Assert.AreEqual ("TestField", field.Name, "#A2");
5215 Assert.IsTrue (field is FieldBuilder, "#A3");
5217 Assert.IsNull (tb.GetField ("OtherField"), "#B1");
5218 Assert.IsNull (tb.GetField ("TestOtherField"), "#B2");
5222 public void TestGetFieldComplete ()
5224 TypeBuilder tb = module.DefineType (genTypeName ());
5225 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5227 Type emittedType = tb.CreateType ();
5229 FieldInfo dynamicField = tb.GetField ("TestField");
5230 FieldInfo emittedField = emittedType.GetField ("TestField");
5231 Assert.IsNotNull (dynamicField, "#A1");
5232 Assert.AreEqual (dynamicField.Name, emittedField.Name, "#A2");
5233 Assert.IsNull (tb.GetField ("TestOtherField"), "#A3");
5234 Assert.IsFalse (emittedField is FieldBuilder, "#A4");
5235 Assert.IsFalse (dynamicField is FieldBuilder, "#A5");
5238 object value = Activator.CreateInstance (emittedType);
5239 emittedField.SetValue (value, 5);
5240 Assert.AreEqual (5, emittedField.GetValue (value), "#B1");
5241 Assert.AreEqual (5, dynamicField.GetValue (value), "#B2");
5242 dynamicField.SetValue (value, 4);
5243 Assert.AreEqual (4, emittedField.GetValue (value), "#B3");
5244 Assert.AreEqual (4, dynamicField.GetValue (value), "#B4");
5247 [Test] // bug #81640
5248 public void TestGetFieldComplete_Type ()
5250 TypeBuilder tb = module.DefineType (genTypeName ());
5251 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5252 Type emittedType = tb.CreateType ();
5253 FieldInfo dynamicField = tb.GetField ("TestField");
5254 Assert.IsFalse (dynamicField is FieldBuilder, "#1");
5256 object value = Activator.CreateInstance (emittedType);
5257 Assert.AreEqual (0, dynamicField.GetValue (value), "#2");
5261 [Category ("NotWorking")] // mcs depends on this
5262 public void TestGetFieldFlagsIncomplete_MS ()
5264 TypeBuilder tb = module.DefineType (genTypeName ());
5265 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5266 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5268 tb.GetField ("test", BindingFlags.Public);
5270 } catch (NotSupportedException ex) {
5271 // The invoked member is not supported in a
5273 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5274 Assert.IsNull (ex.InnerException, "#3");
5275 Assert.IsNotNull (ex.Message, "#4");
5280 [Category ("NotDotNet")] // mcs depends on this
5281 public void TestGetFieldFlagsIncomplete_Mono ()
5283 TypeBuilder tb = module.DefineType (genTypeName ());
5284 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5285 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5287 FieldInfo field = tb.GetField ("TestField", BindingFlags.Public
5288 | BindingFlags.Instance);
5289 Assert.IsNotNull (field, "#A1");
5290 Assert.AreEqual ("TestField", field.Name, "#A2");
5291 Assert.IsTrue (field is FieldBuilder, "#A3");
5293 field = tb.GetField ("OtherField", BindingFlags.NonPublic |
5294 BindingFlags.Instance);
5295 Assert.IsNotNull (field, "#B1");
5296 Assert.AreEqual ("OtherField", field.Name, "#B2");
5297 Assert.IsTrue (field is FieldBuilder, "#B3");
5299 Assert.IsNull (tb.GetField ("TestField", BindingFlags.NonPublic |
5300 BindingFlags.Instance), "#C1");
5301 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Public |
5302 BindingFlags.Static), "#C2");
5303 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5304 BindingFlags.Instance), "#C3");
5305 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5306 BindingFlags.Static), "#C4");
5307 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.NonPublic |
5308 BindingFlags.Instance), "#C5");
5309 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.Public |
5310 BindingFlags.Instance), "#C6");
5314 public void TestGetFieldFlagsComplete ()
5316 TypeBuilder tb = module.DefineType (genTypeName ());
5317 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5319 Type emittedType = tb.CreateType ();
5321 Assert.IsNotNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public));
5322 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name,
5323 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name);
5324 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5325 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic),
5326 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5330 public void TestGetFieldFlagsComplete_Inheritance ()
5334 TypeBuilder blueType = module.DefineType (genTypeName (),
5335 TypeAttributes.Public);
5336 CreateMembers (blueType, "Blue", false);
5338 TypeBuilder redType = module.DefineType (genTypeName (),
5339 TypeAttributes.Public, blueType);
5340 CreateMembers (redType, "Red", false);
5342 TypeBuilder greenType = module.DefineType (genTypeName (),
5343 TypeAttributes.Public, redType);
5344 CreateMembers (greenType, "Green", false);
5346 blueType.CreateType ();
5347 redType.CreateType ();
5348 greenType.CreateType ();
5350 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5352 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#A1");
5353 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#A2");
5354 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#A3");
5355 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#A4");
5356 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#A5");
5357 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#A6");
5358 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#A7");
5359 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#A8");
5360 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#A9");
5361 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#A10");
5362 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#A11");
5363 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#A12");
5364 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#A13");
5365 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#A14");
5366 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#A15");
5367 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#A16");
5368 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#A17");
5369 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#A18");
5370 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#A19");
5371 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#A20");
5372 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#A21");
5373 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#A22");
5374 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#A23");
5375 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#A24");
5376 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#A25");
5377 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#A26");
5378 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#A27");
5379 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#A28");
5380 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#A29");
5381 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#A30");
5382 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#A31");
5383 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#A32");
5384 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#A33");
5385 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#A34");
5386 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#A35");
5387 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#A36");
5389 flags = BindingFlags.Instance | BindingFlags.Public;
5391 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#B1");
5392 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#B2");
5393 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#B3");
5394 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#B4");
5395 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#B5");
5396 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#B6");
5397 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#B7");
5398 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#B8");
5399 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#B9");
5400 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#B10");
5401 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#B11");
5402 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#B12");
5403 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#B13");
5404 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#B14");
5405 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#B15");
5406 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#B16");
5407 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#B17");
5408 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#B18");
5409 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#B19");
5410 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#B20");
5411 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#B21");
5412 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#B22");
5413 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#B23");
5414 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#B24");
5415 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#B25");
5416 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#B26");
5417 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#B27");
5418 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#B28");
5419 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#B29");
5420 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#B30");
5421 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#B31");
5422 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#B32");
5423 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#B33");
5424 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#B34");
5425 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#B35");
5426 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#B36");
5428 flags = BindingFlags.Static | BindingFlags.Public;
5430 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#C1");
5431 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#C2");
5432 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#C3");
5433 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#C4");
5434 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#C5");
5435 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#C6");
5436 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#C7");
5437 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#C8");
5438 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#C9");
5439 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#C10");
5440 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#C11");
5441 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#C12");
5442 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#C13");
5443 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#C14");
5444 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#C15");
5445 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#C16");
5446 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#C17");
5447 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#C18");
5448 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#C19");
5449 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#C20");
5450 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#C21");
5451 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#C22");
5452 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#C23");
5453 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#C24");
5454 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#C25");
5455 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#C26");
5456 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#C27");
5457 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#C28");
5458 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#C29");
5459 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#C30");
5460 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#C31");
5461 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#C32");
5462 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#C33");
5463 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#C34");
5464 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#C35");
5465 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#C36");
5467 flags = BindingFlags.Static | BindingFlags.NonPublic;
5469 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#D1");
5470 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#D2");
5471 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#D3");
5472 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#D4");
5473 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#D5");
5474 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#D6");
5475 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#D7");
5476 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#D8");
5477 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#D9");
5478 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#D10");
5479 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#D11");
5480 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#D12");
5481 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#D13");
5482 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#D14");
5483 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#D15");
5484 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#D16");
5485 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#D17");
5486 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#D18");
5487 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#D19");
5488 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#D20");
5489 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#D21");
5490 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#D22");
5491 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#D23");
5492 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#D24");
5493 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#D25");
5494 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#D26");
5495 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#D27");
5496 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#D28");
5497 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#D29");
5498 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#D30");
5499 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#D31");
5500 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#D32");
5501 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#D33");
5502 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#D34");
5503 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#D35");
5504 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#D36");
5506 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5507 BindingFlags.FlattenHierarchy;
5509 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#E1");
5510 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#E2");
5511 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#E3");
5512 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#E4");
5513 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#E5");
5514 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#E6");
5515 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#E7");
5516 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#E8");
5517 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#E9");
5518 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#E10");
5519 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#E11");
5520 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#E12");
5521 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#E13");
5522 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#E14");
5523 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#E15");
5524 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#E16");
5525 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#E17");
5526 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#E18");
5527 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#E19");
5528 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#E20");
5529 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#E21");
5530 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#E22");
5531 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#E23");
5532 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#E24");
5533 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#E25");
5534 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#E26");
5535 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#E27");
5536 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#E28");
5537 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#E29");
5538 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#E30");
5539 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#E31");
5540 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#E32");
5541 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#E33");
5542 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#E34");
5543 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#E35");
5544 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#E36");
5546 flags = BindingFlags.Instance | BindingFlags.Public |
5547 BindingFlags.FlattenHierarchy;
5549 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#F1");
5550 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#F2");
5551 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#F3");
5552 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#F4");
5553 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#F5");
5554 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#F6");
5555 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#F7");
5556 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#F8");
5557 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#F9");
5558 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#F10");
5559 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#F11");
5560 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#F12");
5561 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#F13");
5562 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#F14");
5563 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#F15");
5564 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#F16");
5565 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#F17");
5566 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#F18");
5567 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#F19");
5568 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#F20");
5569 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#F21");
5570 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#F22");
5571 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#F23");
5572 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#F24");
5573 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#F25");
5574 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#F26");
5575 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#F27");
5576 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#F28");
5577 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#F29");
5578 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#F30");
5579 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#F31");
5580 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#F32");
5581 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#F33");
5582 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#F34");
5583 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#F35");
5584 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#F36");
5586 flags = BindingFlags.Static | BindingFlags.Public |
5587 BindingFlags.FlattenHierarchy;
5589 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#G1");
5590 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#G2");
5591 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#G3");
5592 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#G4");
5593 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#G5");
5594 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#G6");
5595 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#G7");
5596 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#G8");
5597 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#G9");
5598 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#G10");
5599 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#G11");
5600 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#G12");
5601 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#G13");
5602 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#G14");
5603 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#G15");
5604 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#G16");
5605 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#G17");
5606 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#G18");
5607 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#G19");
5608 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#G20");
5609 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#G21");
5610 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#G22");
5611 Assert.IsNotNull (greenType.GetField ("publicStaticBlue", flags), "#G23");
5612 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#G24");
5613 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#G25");
5614 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#G26");
5615 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#G27");
5616 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#G28");
5617 Assert.IsNotNull (greenType.GetField ("publicStaticRed", flags), "#G29");
5618 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#G30");
5619 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#G31");
5620 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#G32");
5621 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#G33");
5622 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#G34");
5623 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#G35");
5624 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#G36");
5626 flags = BindingFlags.Static | BindingFlags.NonPublic |
5627 BindingFlags.FlattenHierarchy;
5629 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#H1");
5630 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#H2");
5631 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#H3");
5632 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#H4");
5633 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#H5");
5634 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#H6");
5635 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#H7");
5636 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#H8");
5637 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#H9");
5638 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#H10");
5639 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#H11");
5640 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#H12");
5641 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#H13");
5642 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#H14");
5643 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#H15");
5644 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#H16");
5645 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#H17");
5646 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#H18");
5647 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#H19");
5648 Assert.IsNotNull (greenType.GetField ("familyStaticBlue", flags), "#H20");
5649 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#H21");
5650 Assert.IsNotNull (greenType.GetField ("famORAssemStaticBlue", flags), "#H22");
5651 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#H23");
5652 Assert.IsNotNull (greenType.GetField ("assemblyStaticBlue", flags), "#H24");
5653 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#H25");
5654 Assert.IsNotNull (greenType.GetField ("familyStaticRed", flags), "#H26");
5655 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticRed", flags), "#H27");
5656 Assert.IsNotNull (greenType.GetField ("famORAssemStaticRed", flags), "#H28");
5657 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#H29");
5658 Assert.IsNotNull (greenType.GetField ("assemblyStaticRed", flags), "#H30");
5659 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#H31");
5660 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#H32");
5661 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#H33");
5662 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#H34");
5663 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#H35");
5664 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#H36");
5666 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5667 BindingFlags.DeclaredOnly;
5669 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#I1");
5670 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#I2");
5671 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#I3");
5672 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#I4");
5673 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#I5");
5674 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#I6");
5675 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#I7");
5676 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#I8");
5677 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#I9");
5678 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#I10");
5679 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#I11");
5680 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#I12");
5681 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#I13");
5682 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#I14");
5683 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#I15");
5684 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#I16");
5685 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#I17");
5686 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#I18");
5687 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#I19");
5688 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#I20");
5689 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#I21");
5690 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#I22");
5691 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#I23");
5692 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#I24");
5693 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#I25");
5694 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#I26");
5695 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#I27");
5696 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#I28");
5697 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#I29");
5698 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#I30");
5699 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#I31");
5700 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#I32");
5701 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#I33");
5702 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#I34");
5703 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#I35");
5704 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#I36");
5706 flags = BindingFlags.Instance | BindingFlags.Public |
5707 BindingFlags.DeclaredOnly;
5709 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#J1");
5710 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#J2");
5711 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#J3");
5712 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#J4");
5713 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#J5");
5714 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#J6");
5715 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#J7");
5716 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#J8");
5717 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#J9");
5718 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#J10");
5719 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#J11");
5720 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#J12");
5721 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#J13");
5722 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#J14");
5723 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#J15");
5724 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#J16");
5725 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#J17");
5726 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#J18");
5727 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#J19");
5728 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#J20");
5729 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#J21");
5730 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#J22");
5731 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#J23");
5732 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#J24");
5733 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#J25");
5734 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#J26");
5735 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#J27");
5736 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#J28");
5737 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#J29");
5738 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#J30");
5739 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#J31");
5740 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#J32");
5741 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#J33");
5742 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#J34");
5743 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#J35");
5744 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#J36");
5746 flags = BindingFlags.Static | BindingFlags.Public |
5747 BindingFlags.DeclaredOnly;
5749 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#K1");
5750 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#K2");
5751 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#K3");
5752 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#K4");
5753 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#K5");
5754 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#K6");
5755 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#K7");
5756 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#K8");
5757 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#K9");
5758 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#K10");
5759 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#K11");
5760 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#K12");
5761 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#K13");
5762 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#K14");
5763 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#K15");
5764 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#K16");
5765 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#K17");
5766 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#K18");
5767 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#K19");
5768 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#K20");
5769 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#K21");
5770 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#K22");
5771 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#K23");
5772 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#K24");
5773 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#K25");
5774 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#K26");
5775 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#K27");
5776 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#K28");
5777 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#K29");
5778 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#K30");
5779 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#K31");
5780 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#K32");
5781 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#K33");
5782 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#K34");
5783 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#K35");
5784 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#K36");
5786 flags = BindingFlags.Static | BindingFlags.NonPublic |
5787 BindingFlags.DeclaredOnly;
5789 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#L1");
5790 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#L2");
5791 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#L3");
5792 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#L4");
5793 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#L5");
5794 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#L6");
5795 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#L7");
5796 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#L8");
5797 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#L9");
5798 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#L10");
5799 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#L11");
5800 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#L12");
5801 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#L13");
5802 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#L14");
5803 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#L15");
5804 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#L16");
5805 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#L17");
5806 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#L18");
5807 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#L19");
5808 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#L20");
5809 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#L21");
5810 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#L22");
5811 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#L23");
5812 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#L24");
5813 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#L25");
5814 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#L26");
5815 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#L27");
5816 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#L28");
5817 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#L29");
5818 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#L30");
5819 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#L31");
5820 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#L32");
5821 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#L33");
5822 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#L34");
5823 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#L35");
5824 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#L36");
5826 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5827 BindingFlags.Public;
5829 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#M1");
5830 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#M2");
5831 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#M3");
5832 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#M4");
5833 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#M5");
5834 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#M6");
5835 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#M7");
5836 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#M8");
5837 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#M9");
5838 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#M10");
5839 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#M11");
5840 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#M12");
5841 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#M13");
5842 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#M14");
5843 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#M15");
5844 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#M16");
5845 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#M17");
5846 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#M18");
5847 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#M19");
5848 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#M20");
5849 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#M21");
5850 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#M22");
5851 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#M23");
5852 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#M24");
5853 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#M25");
5854 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#M26");
5855 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#M27");
5856 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#M28");
5857 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#M29");
5858 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#M30");
5859 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#M31");
5860 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#M32");
5861 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#M33");
5862 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#M34");
5863 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#M35");
5864 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#M36");
5866 flags = BindingFlags.Static | BindingFlags.NonPublic |
5867 BindingFlags.Public;
5869 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#N1");
5870 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#N2");
5871 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#N3");
5872 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#N4");
5873 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#N5");
5874 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#N6");
5875 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#N7");
5876 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#N8");
5877 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#N9");
5878 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#N10");
5879 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#N11");
5880 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#N12");
5881 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#N13");
5882 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#N14");
5883 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#N15");
5884 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#N16");
5885 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#N17");
5886 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#N18");
5887 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#N19");
5888 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#N20");
5889 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#N21");
5890 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#N22");
5891 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#N23");
5892 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#N24");
5893 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#N25");
5894 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#N26");
5895 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#N27");
5896 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#N28");
5897 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#N29");
5898 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#N30");
5899 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#N31");
5900 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#N32");
5901 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#N33");
5902 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#N34");
5903 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#N35");
5904 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#N36");
5908 [Category ("NotDotNet")] // mcs depends on this
5909 public void TestGetPropertiesIncomplete_Mono ()
5911 TypeBuilder tb = module.DefineType (genTypeName ());
5912 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5913 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5914 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5916 PropertyInfo [] properties = tb.GetProperties ();
5917 Assert.AreEqual (2, properties.Length, "#1");
5918 Assert.AreEqual ("Name", properties [0].Name, "#2");
5919 Assert.AreEqual ("FirstName", properties [1].Name, "#3");
5923 [Category ("NotWorking")] // mcs depends on this
5924 public void TestGetPropertiesIncomplete_MS ()
5926 TypeBuilder tb = module.DefineType (genTypeName ());
5927 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5928 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5929 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5932 tb.GetProperties ();
5934 } catch (NotSupportedException ex) {
5935 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5936 Assert.IsNull (ex.InnerException, "#3");
5937 Assert.IsNotNull (ex.Message, "#4");
5942 public void TestGetPropertiesComplete ()
5944 TypeBuilder tb = module.DefineType (genTypeName ());
5945 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
5947 Type emittedType = tb.CreateType ();
5949 Assert.AreEqual (1, tb.GetProperties ().Length);
5950 Assert.AreEqual (tb.GetProperties ().Length, emittedType.GetProperties ().Length);
5954 [Category ("NotDotNet")] // mcs depends on this
5955 public void TestGetPropertiesFlagsIncomplete_Mono ()
5957 PropertyInfo [] properties;
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);
5964 properties = tb.GetProperties (BindingFlags.Public |
5965 BindingFlags.NonPublic | BindingFlags.Instance);
5966 Assert.AreEqual (3, properties.Length, "#A1");
5967 Assert.AreEqual ("Name", properties [0].Name, "#A2");
5968 Assert.AreEqual ("Income", properties [1].Name, "#A3");
5969 Assert.AreEqual ("FirstName", properties [2].Name, "#A4");
5971 properties = tb.GetProperties (BindingFlags.Public |
5972 BindingFlags.Instance);
5973 Assert.AreEqual (2, properties.Length, "#B1");
5974 Assert.AreEqual ("Name", properties [0].Name, "#B2");
5975 Assert.AreEqual ("FirstName", properties [1].Name, "#B3");
5977 properties = tb.GetProperties (BindingFlags.NonPublic |
5978 BindingFlags.Instance);
5979 Assert.AreEqual (1, properties.Length, "#C1");
5980 Assert.AreEqual ("Income", properties [0].Name, "#C2");
5984 [Category ("NotWorking")] // mcs depends on this
5985 public void TestGetPropertiesFlagsIncomplete_MS ()
5987 TypeBuilder tb = module.DefineType (genTypeName ());
5988 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5989 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5990 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5993 tb.GetProperties (BindingFlags.Public);
5995 } catch (NotSupportedException ex) {
5996 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5997 Assert.IsNull (ex.InnerException, "#3");
5998 Assert.IsNotNull (ex.Message, "#4");
6003 public void TestGetPropertiesFlagsComplete ()
6005 TypeBuilder tb = module.DefineType (genTypeName ());
6006 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6008 Type emittedType = tb.CreateType ();
6010 Assert.AreEqual (1, tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
6011 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length,
6012 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
6013 Assert.AreEqual (0, tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
6014 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length,
6015 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
6019 public void TestGetPropertiesFlagsComplete_Inheritance ()
6021 PropertyInfo [] props;
6024 TypeBuilder blueType = module.DefineType (genTypeName (),
6025 TypeAttributes.Public);
6026 CreateMembers (blueType, "Blue", false);
6028 TypeBuilder redType = module.DefineType (genTypeName (),
6029 TypeAttributes.Public, blueType);
6030 CreateMembers (redType, "Red", false);
6032 TypeBuilder greenType = module.DefineType (genTypeName (),
6033 TypeAttributes.Public, redType);
6034 CreateMembers (greenType, "Green", false);
6036 blueType.CreateType ();
6037 redType.CreateType ();
6038 greenType.CreateType ();
6040 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6041 props = greenType.GetProperties (flags);
6043 Assert.AreEqual (13, props.Length, "#A1");
6044 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#A2");
6045 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#A3");
6046 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#A4");
6047 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#A5");
6048 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#A6");
6049 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#A7");
6050 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#A8");
6051 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#A9");
6052 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#A10");
6053 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#A11");
6054 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#A12");
6055 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#A13");
6056 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#A15");
6058 flags = BindingFlags.Instance | BindingFlags.Public;
6059 props = greenType.GetProperties (flags);
6061 Assert.AreEqual (3, props.Length, "#B1");
6062 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#B2");
6063 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#B3");
6064 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#B4");
6066 flags = BindingFlags.Static | BindingFlags.Public;
6067 props = greenType.GetProperties (flags);
6069 Assert.AreEqual (1, props.Length, "#C1");
6070 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#C2");
6072 flags = BindingFlags.Static | BindingFlags.NonPublic;
6073 props = greenType.GetProperties (flags);
6075 Assert.AreEqual (5, props.Length, "#D1");
6076 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#D2");
6077 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#D3");
6078 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#D4");
6079 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#D5");
6080 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#D6");
6082 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6083 BindingFlags.FlattenHierarchy;
6084 props = greenType.GetProperties (flags);
6086 Assert.AreEqual (13, props.Length, "#E1");
6087 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#E2");
6088 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#E3");
6089 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#E4");
6090 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#E5");
6091 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#E6");
6092 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#E7");
6093 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#E8");
6094 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#E9");
6095 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#E10");
6096 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#E11");
6097 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#E12");
6098 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#E13");
6099 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#E14");
6101 flags = BindingFlags.Instance | BindingFlags.Public |
6102 BindingFlags.FlattenHierarchy;
6103 props = greenType.GetProperties (flags);
6105 Assert.AreEqual (3, props.Length, "#F1");
6106 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#F2");
6107 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#F3");
6108 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#F4");
6110 flags = BindingFlags.Static | BindingFlags.Public |
6111 BindingFlags.FlattenHierarchy;
6112 props = greenType.GetProperties (flags);
6114 Assert.AreEqual (3, props.Length, "#G1");
6115 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#G2");
6116 Assert.AreEqual ("PublicStaticRed", props [1].Name, "#G3");
6117 Assert.AreEqual ("PublicStaticBlue", props [2].Name, "#G4");
6119 flags = BindingFlags.Static | BindingFlags.NonPublic |
6120 BindingFlags.FlattenHierarchy;
6121 props = greenType.GetProperties (flags);
6123 Assert.AreEqual (13, props.Length, "#H1");
6124 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#H2");
6125 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#H3");
6126 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#H4");
6127 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#H5");
6128 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#H6");
6129 Assert.AreEqual ("FamilyStaticRed", props [5].Name, "#H7");
6130 Assert.AreEqual ("FamANDAssemStaticRed", props [6].Name, "#H8");
6131 Assert.AreEqual ("FamORAssemStaticRed", props [7].Name, "#H9");
6132 Assert.AreEqual ("AssemblyStaticRed", props [8].Name, "#H10");
6133 Assert.AreEqual ("FamilyStaticBlue", props [9].Name, "#H11");
6134 Assert.AreEqual ("FamANDAssemStaticBlue", props [10].Name, "#H12");
6135 Assert.AreEqual ("FamORAssemStaticBlue", props [11].Name, "#H13");
6136 Assert.AreEqual ("AssemblyStaticBlue", props [12].Name, "#H14");
6138 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6139 BindingFlags.DeclaredOnly;
6140 props = greenType.GetProperties (flags);
6142 Assert.AreEqual (5, props.Length, "#I1");
6143 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#I2");
6144 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#I3");
6145 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#I4");
6146 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#I5");
6147 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#I6");
6149 flags = BindingFlags.Instance | BindingFlags.Public |
6150 BindingFlags.DeclaredOnly;
6151 props = greenType.GetProperties (flags);
6153 Assert.AreEqual (1, props.Length, "#J1");
6154 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#J2");
6156 flags = BindingFlags.Static | BindingFlags.Public |
6157 BindingFlags.DeclaredOnly;
6158 props = greenType.GetProperties (flags);
6160 Assert.AreEqual (1, props.Length, "#K1");
6161 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#K2");
6163 flags = BindingFlags.Static | BindingFlags.NonPublic |
6164 BindingFlags.DeclaredOnly;
6165 props = greenType.GetProperties (flags);
6167 Assert.AreEqual (5, props.Length, "#L1");
6168 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#L2");
6169 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#L3");
6170 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#L4");
6171 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#L5");
6172 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#L6");
6174 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6175 BindingFlags.Public;
6176 props = greenType.GetProperties (flags);
6178 Assert.AreEqual (16, props.Length, "#M1");
6179 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#M2");
6180 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#M3");
6181 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#M4");
6182 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#M5");
6183 Assert.AreEqual ("PublicInstanceGreen", props [4].Name, "#M6");
6184 Assert.AreEqual ("AssemblyInstanceGreen", props [5].Name, "#M7");
6185 Assert.AreEqual ("FamilyInstanceRed", props [6].Name, "#M8");
6186 Assert.AreEqual ("FamANDAssemInstanceRed", props [7].Name, "#M9");
6187 Assert.AreEqual ("FamORAssemInstanceRed", props [8].Name, "#M10");
6188 Assert.AreEqual ("PublicInstanceRed", props [9].Name, "#M11");
6189 Assert.AreEqual ("AssemblyInstanceRed", props [10].Name, "#M12");
6190 Assert.AreEqual ("FamilyInstanceBlue", props [11].Name, "#M13");
6191 Assert.AreEqual ("FamANDAssemInstanceBlue", props [12].Name, "#M14");
6192 Assert.AreEqual ("FamORAssemInstanceBlue", props [13].Name, "#M15");
6193 Assert.AreEqual ("PublicInstanceBlue", props [14].Name, "#M16");
6194 Assert.AreEqual ("AssemblyInstanceBlue", props [15].Name, "#M17");
6196 flags = BindingFlags.Static | BindingFlags.NonPublic |
6197 BindingFlags.Public;
6198 props = greenType.GetProperties (flags);
6200 Assert.AreEqual (6, props.Length, "#N1");
6201 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#N2");
6202 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#N3");
6203 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#N4");
6204 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#N5");
6205 Assert.AreEqual ("PublicStaticGreen", props [4].Name, "#N6");
6206 Assert.AreEqual ("AssemblyStaticGreen", props [5].Name, "#N7");
6210 public void TestGetPropertyIncomplete ()
6212 TypeBuilder tb = module.DefineType (genTypeName ());
6214 tb.GetProperty ("test");
6216 } catch (NotSupportedException ex) {
6217 // The invoked member is not supported in a
6219 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6220 Assert.IsNull (ex.InnerException, "#3");
6221 Assert.IsNotNull (ex.Message, "#4");
6226 public void TestGetPropertyComplete ()
6228 TypeBuilder tb = module.DefineType (genTypeName ());
6229 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6231 Type emittedType = tb.CreateType ();
6233 Assert.IsNotNull (emittedType.GetProperty ("CustomerName"));
6234 Assert.IsNull (emittedType.GetProperty ("OtherCustomerName"));
6237 tb.GetProperty ("CustomerName");
6239 } catch (NotSupportedException ex) {
6240 // The invoked member is not supported in a
6242 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6243 Assert.IsNull (ex.InnerException, "#3");
6244 Assert.IsNotNull (ex.Message, "#4");
6249 public void TestGetPropertyFlagsIncomplete ()
6251 TypeBuilder tb = module.DefineType (genTypeName ());
6253 tb.GetProperty ("test", BindingFlags.Public);
6255 } catch (NotSupportedException ex) {
6256 // The invoked member is not supported in a
6258 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6259 Assert.IsNull (ex.InnerException, "#3");
6260 Assert.IsNotNull (ex.Message, "#4");
6265 public void TestGetPropertyFlagsComplete ()
6267 TypeBuilder tb = module.DefineType (genTypeName ());
6268 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6270 Type emittedType = tb.CreateType ();
6272 Assert.IsNotNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6273 BindingFlags.Public));
6274 Assert.IsNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6275 BindingFlags.NonPublic));
6278 tb.GetProperty ("CustomerName", BindingFlags.Instance | BindingFlags.Public);
6280 } catch (NotSupportedException ex) {
6281 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6282 Assert.IsNull (ex.InnerException, "#3");
6283 Assert.IsNotNull (ex.Message, "#4");
6288 public void TestGetMethodFlagsComplete ()
6292 TypeBuilder blueType = module.DefineType (genTypeName (),
6293 TypeAttributes.Public);
6294 CreateMembers (blueType, "Blue", false);
6296 TypeBuilder redType = module.DefineType (genTypeName (),
6297 TypeAttributes.Public, blueType);
6298 CreateMembers (redType, "Red", false);
6300 TypeBuilder greenType = module.DefineType (genTypeName (),
6301 TypeAttributes.Public, redType);
6302 CreateMembers (greenType, "Green", false);
6304 blueType.CreateType ();
6305 redType.CreateType ();
6306 greenType.CreateType ();
6308 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6310 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#A1");
6311 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#A2");
6312 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#A3");
6313 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#A4");
6314 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#A5");
6315 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#A6");
6316 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#A7");
6317 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#A8");
6318 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#A9");
6319 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#A10");
6320 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#A11");
6321 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#A12");
6322 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#A13");
6323 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#A14");
6324 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#A15");
6325 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#A16");
6326 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#A17");
6327 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#A18");
6328 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#A19");
6329 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#A20");
6330 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#A21");
6331 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#A22");
6332 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#A23");
6333 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#A24");
6334 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#A25");
6335 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#A26");
6336 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#A27");
6337 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#A28");
6338 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#A29");
6339 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#A30");
6340 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#A31");
6341 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#A32");
6342 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#A33");
6343 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#A34");
6344 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#A35");
6345 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#A36");
6347 flags = BindingFlags.Instance | BindingFlags.Public;
6349 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#B1");
6350 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#B2");
6351 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#B3");
6352 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#B4");
6353 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#B5");
6354 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#B6");
6355 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#B7");
6356 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#B8");
6357 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#B9");
6358 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#B10");
6359 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#B11");
6360 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#B12");
6361 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#B13");
6362 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#B14");
6363 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#B15");
6364 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#B16");
6365 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#B17");
6366 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#B18");
6367 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#B19");
6368 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#B20");
6369 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#B21");
6370 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#B22");
6371 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#B23");
6372 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#B24");
6373 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#B25");
6374 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#B26");
6375 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#B27");
6376 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#B28");
6377 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#B29");
6378 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#B30");
6379 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#B31");
6380 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#B32");
6381 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#B33");
6382 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#B34");
6383 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#B35");
6384 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#B36");
6386 flags = BindingFlags.Static | BindingFlags.Public;
6388 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#C1");
6389 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#C2");
6390 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#C3");
6391 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#C4");
6392 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#C5");
6393 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#C6");
6394 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#C7");
6395 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#C8");
6396 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#C9");
6397 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#C10");
6398 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#C11");
6399 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#C12");
6400 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#C13");
6401 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#C14");
6402 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#C15");
6403 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#C16");
6404 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#C17");
6405 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#C18");
6406 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#C19");
6407 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#C20");
6408 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#C21");
6409 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#C22");
6410 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#C23");
6411 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#C24");
6412 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#C25");
6413 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#C26");
6414 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#C27");
6415 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#C28");
6416 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#C29");
6417 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#C30");
6418 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#C31");
6419 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#C32");
6420 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#C33");
6421 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#C34");
6422 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#C35");
6423 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#C36");
6425 flags = BindingFlags.Static | BindingFlags.NonPublic;
6427 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#D1");
6428 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#D2");
6429 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#D3");
6430 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#D4");
6431 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#D5");
6432 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#D6");
6433 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#D7");
6434 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#D8");
6435 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#D9");
6436 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#D10");
6437 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#D11");
6438 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#D12");
6439 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#D13");
6440 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#D14");
6441 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#D15");
6442 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#D16");
6443 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#D17");
6444 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#D18");
6445 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#D19");
6446 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#D20");
6447 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#D21");
6448 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#D22");
6449 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#D23");
6450 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#D24");
6451 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#D25");
6452 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#D26");
6453 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#D27");
6454 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#D28");
6455 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#D29");
6456 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#D30");
6457 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#D31");
6458 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#D32");
6459 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#D33");
6460 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#D34");
6461 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#D35");
6462 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#D36");
6464 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6465 BindingFlags.FlattenHierarchy;
6467 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#E1");
6468 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#E2");
6469 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#E3");
6470 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#E4");
6471 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#E5");
6472 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#E6");
6473 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#E7");
6474 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#E8");
6475 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#E9");
6476 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#E10");
6477 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#E11");
6478 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#E12");
6479 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#E13");
6480 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#E14");
6481 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#E15");
6482 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#E16");
6483 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#E17");
6484 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#E18");
6485 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#E19");
6486 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#E20");
6487 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#E21");
6488 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#E22");
6489 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#E23");
6490 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#E24");
6491 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#E25");
6492 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#E26");
6493 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#E27");
6494 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#E28");
6495 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#E29");
6496 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#E30");
6497 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#E31");
6498 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#E32");
6499 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#E33");
6500 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#E34");
6501 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#E35");
6502 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#E36");
6504 flags = BindingFlags.Instance | BindingFlags.Public |
6505 BindingFlags.FlattenHierarchy;
6507 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#F1");
6508 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#F2");
6509 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#F3");
6510 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#F4");
6511 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#F5");
6512 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#F6");
6513 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#F7");
6514 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#F8");
6515 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#F9");
6516 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#F10");
6517 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#F11");
6518 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#F12");
6519 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#F13");
6520 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#F14");
6521 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#F15");
6522 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#F16");
6523 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#F17");
6524 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#F18");
6525 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#F19");
6526 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#F20");
6527 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#F21");
6528 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#F22");
6529 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#F23");
6530 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#F24");
6531 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#F25");
6532 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#F26");
6533 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#F27");
6534 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#F28");
6535 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#F29");
6536 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#F30");
6537 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#F31");
6538 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#F32");
6539 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#F33");
6540 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#F34");
6541 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#F35");
6542 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#F36");
6544 flags = BindingFlags.Static | BindingFlags.Public |
6545 BindingFlags.FlattenHierarchy;
6547 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#G1");
6548 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#G2");
6549 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#G3");
6550 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#G4");
6551 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#G5");
6552 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#G6");
6553 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#G7");
6554 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#G8");
6555 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#G9");
6556 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#G10");
6557 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#G11");
6558 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#G12");
6559 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#G13");
6560 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#G14");
6561 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#G15");
6562 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#G16");
6563 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#G17");
6564 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#G18");
6565 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#G19");
6566 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#G20");
6567 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#G21");
6568 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#G22");
6569 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#G23");
6570 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#G24");
6571 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#G25");
6572 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#G26");
6573 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#G27");
6574 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#G28");
6575 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#G29");
6576 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#G30");
6577 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#G31");
6578 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#G32");
6579 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#G33");
6580 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#G34");
6581 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#G35");
6582 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#G36");
6584 flags = BindingFlags.Static | BindingFlags.NonPublic |
6585 BindingFlags.FlattenHierarchy;
6587 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#H1");
6588 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#H2");
6589 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#H3");
6590 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#H4");
6591 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#H5");
6592 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#H6");
6593 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#H7");
6594 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#H8");
6595 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#H9");
6596 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#H10");
6597 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#H11");
6598 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#H12");
6599 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#H13");
6600 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#H14");
6601 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#H15");
6602 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#H16");
6603 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#H17");
6604 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#H18");
6605 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#H19");
6606 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#H20");
6607 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#H21");
6608 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#H22");
6609 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#H23");
6610 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#H24");
6611 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#H25");
6612 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#H26");
6613 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#H27");
6614 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#H28");
6615 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#H29");
6616 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#H30");
6617 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#H31");
6618 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#H32");
6619 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#H33");
6620 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#H34");
6621 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#H35");
6622 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#H36");
6624 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6625 BindingFlags.DeclaredOnly;
6627 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#I1");
6628 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#I2");
6629 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#I3");
6630 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#I4");
6631 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#I5");
6632 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#I6");
6633 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#I7");
6634 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#I8");
6635 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#I9");
6636 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#I10");
6637 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#I11");
6638 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#I12");
6639 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#I13");
6640 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#I14");
6641 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#I15");
6642 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#I16");
6643 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#I17");
6644 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#I18");
6645 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#I19");
6646 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#I20");
6647 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#I21");
6648 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#I22");
6649 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#I23");
6650 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#I24");
6651 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#I25");
6652 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#I26");
6653 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#I27");
6654 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#I28");
6655 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#I29");
6656 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#I30");
6657 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#I31");
6658 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#I32");
6659 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#I33");
6660 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#I34");
6661 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#I35");
6662 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#I36");
6664 flags = BindingFlags.Instance | BindingFlags.Public |
6665 BindingFlags.DeclaredOnly;
6667 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#J1");
6668 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#J2");
6669 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#J3");
6670 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#J4");
6671 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#J5");
6672 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#J6");
6673 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#J7");
6674 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#J8");
6675 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#J9");
6676 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#J10");
6677 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#J11");
6678 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#J12");
6679 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#J13");
6680 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#J14");
6681 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#J15");
6682 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#J16");
6683 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#J17");
6684 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#J18");
6685 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#J19");
6686 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#J20");
6687 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#J21");
6688 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#J22");
6689 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#J23");
6690 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#J24");
6691 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#J25");
6692 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#J26");
6693 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#J27");
6694 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#J28");
6695 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#J29");
6696 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#J30");
6697 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#J31");
6698 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#J32");
6699 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#J33");
6700 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#J34");
6701 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#J35");
6702 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#J36");
6704 flags = BindingFlags.Static | BindingFlags.Public |
6705 BindingFlags.DeclaredOnly;
6707 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#K1");
6708 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#K2");
6709 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#K3");
6710 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#K4");
6711 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#K5");
6712 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#K6");
6713 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#K7");
6714 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#K8");
6715 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#K9");
6716 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#K10");
6717 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#K11");
6718 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#K12");
6719 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#K13");
6720 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#K14");
6721 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#K15");
6722 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#K16");
6723 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#K17");
6724 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#K18");
6725 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#K19");
6726 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#K20");
6727 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#K21");
6728 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#K22");
6729 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#K23");
6730 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#K24");
6731 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#K25");
6732 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#K26");
6733 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#K27");
6734 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#K28");
6735 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#K29");
6736 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#K30");
6737 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#K31");
6738 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#K32");
6739 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#K33");
6740 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#K34");
6741 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#K35");
6742 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#K36");
6744 flags = BindingFlags.Static | BindingFlags.NonPublic |
6745 BindingFlags.DeclaredOnly;
6747 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#L1");
6748 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#L2");
6749 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#L3");
6750 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#L4");
6751 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#L5");
6752 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#L6");
6753 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#L7");
6754 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#L8");
6755 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#L9");
6756 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#L10");
6757 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#L11");
6758 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#L12");
6759 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#L13");
6760 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#L14");
6761 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#L15");
6762 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#L16");
6763 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#L17");
6764 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#L18");
6765 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#L19");
6766 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#L20");
6767 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#L21");
6768 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#L22");
6769 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#L23");
6770 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#L24");
6771 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#L25");
6772 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#L26");
6773 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#L27");
6774 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#L28");
6775 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#L29");
6776 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#L30");
6777 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#L31");
6778 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#L32");
6779 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#L33");
6780 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#L34");
6781 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#L35");
6782 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#L36");
6784 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6785 BindingFlags.Public;
6787 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#M1");
6788 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#M2");
6789 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#M3");
6790 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#M4");
6791 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#M5");
6792 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#M6");
6793 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#M7");
6794 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#M8");
6795 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#M9");
6796 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#M10");
6797 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#M11");
6798 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#M12");
6799 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#M13");
6800 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#M14");
6801 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#M15");
6802 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#M16");
6803 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#M17");
6804 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#M18");
6805 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#M19");
6806 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#M20");
6807 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#M21");
6808 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#M22");
6809 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#M23");
6810 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#M24");
6811 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#M25");
6812 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#M26");
6813 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#M27");
6814 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#M28");
6815 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#M29");
6816 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#M30");
6817 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#M31");
6818 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#M32");
6819 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#M33");
6820 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#M34");
6821 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#M35");
6822 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#M36");
6824 flags = BindingFlags.Static | BindingFlags.NonPublic |
6825 BindingFlags.Public;
6827 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#N1");
6828 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#N2");
6829 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#N3");
6830 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#N4");
6831 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#N5");
6832 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#N6");
6833 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#N7");
6834 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#N8");
6835 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#N9");
6836 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#N10");
6837 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#N11");
6838 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#N12");
6839 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#N13");
6840 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#N14");
6841 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#N15");
6842 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#N16");
6843 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#N17");
6844 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#N18");
6845 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#N19");
6846 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#N20");
6847 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#N21");
6848 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#N22");
6849 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#N23");
6850 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#N24");
6851 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#N25");
6852 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#N26");
6853 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#N27");
6854 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#N28");
6855 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#N29");
6856 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#N30");
6857 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#N31");
6858 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#N32");
6859 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#N33");
6860 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#N34");
6861 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#N35");
6862 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#N36");
6866 [Category ("NotDotNet")] // mcs depends on this
6867 public void TestGetMethodsIncomplete_Mono ()
6872 TypeBuilder tb = module.DefineType (genTypeName (),
6873 TypeAttributes.Abstract);
6874 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6875 typeof (void), Type.EmptyTypes);
6876 ilgen = mb.GetILGenerator ();
6877 ilgen.Emit (OpCodes.Ret);
6879 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6880 typeof (void), Type.EmptyTypes);
6881 ilgen = mb.GetILGenerator ();
6882 ilgen.Emit (OpCodes.Ret);
6884 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6885 MethodAttributes.Static,
6886 typeof (void), Type.EmptyTypes);
6887 ilgen = mb.GetILGenerator ();
6888 ilgen.Emit (OpCodes.Ret);
6890 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6891 MethodAttributes.Abstract | MethodAttributes.Virtual,
6892 typeof (void), Type.EmptyTypes);
6894 MethodInfo [] methods = tb.GetMethods ();
6895 Assert.AreEqual (7, methods.Length, "#A");
6897 Assert.AreEqual ("Equals", methods [0].Name, "#B1");
6898 Assert.IsFalse (methods [0].IsStatic, "#B2");
6899 Assert.IsFalse (methods [0].IsAbstract, "#B3");
6901 Assert.AreEqual ("GetHashCode", methods [1].Name, "#C1");
6902 Assert.IsFalse (methods [1].IsStatic, "#C2");
6903 Assert.IsFalse (methods [1].IsAbstract, "#C3");
6905 Assert.AreEqual ("GetType", methods [2].Name, "#D1");
6906 Assert.IsFalse (methods [2].IsStatic, "#D2");
6907 Assert.IsFalse (methods [2].IsAbstract, "#D3");
6909 Assert.AreEqual ("ToString", methods [3].Name, "#E1");
6910 Assert.IsFalse (methods [3].IsStatic, "#E2");
6911 Assert.IsFalse (methods [3].IsAbstract, "#E3");
6913 Assert.AreEqual ("Hello", methods [4].Name, "#F1");
6914 Assert.IsFalse (methods [4].IsStatic, "#F2");
6915 Assert.IsFalse (methods [4].IsAbstract, "#F3");
6917 Assert.AreEqual ("Execute", methods [5].Name, "#G1");
6918 Assert.IsTrue (methods [5].IsStatic, "#G2");
6919 Assert.IsFalse (methods [5].IsAbstract, "#G3");
6921 Assert.AreEqual ("Init", methods [6].Name, "#H1");
6922 Assert.IsFalse (methods [6].IsStatic, "#H2");
6923 Assert.IsTrue (methods [6].IsAbstract, "#H3");
6927 [Category ("NotWorking")] // mcs depends on this
6928 public void TestGetMethodsIncomplete_MS ()
6933 TypeBuilder tb = module.DefineType (genTypeName (),
6934 TypeAttributes.Abstract);
6935 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6936 typeof (void), Type.EmptyTypes);
6937 ilgen = mb.GetILGenerator ();
6938 ilgen.Emit (OpCodes.Ret);
6940 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6941 typeof (void), Type.EmptyTypes);
6942 ilgen = mb.GetILGenerator ();
6943 ilgen.Emit (OpCodes.Ret);
6945 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6946 MethodAttributes.Static,
6947 typeof (void), Type.EmptyTypes);
6948 ilgen = mb.GetILGenerator ();
6949 ilgen.Emit (OpCodes.Ret);
6951 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6952 MethodAttributes.Abstract | MethodAttributes.Virtual,
6953 typeof (void), Type.EmptyTypes);
6958 } catch (NotSupportedException ex) {
6959 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6960 Assert.IsNull (ex.InnerException, "#3");
6961 Assert.IsNotNull (ex.Message, "#4");
6966 public void TestGetMethodsComplete ()
6972 TypeBuilder tb = module.DefineType (genTypeName (),
6973 TypeAttributes.Abstract);
6974 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6975 typeof (string), Type.EmptyTypes);
6976 ilgen = mb.GetILGenerator ();
6977 ilgen.Emit (OpCodes.Ldstr, "Hi! ");
6978 ilgen.Emit (OpCodes.Ldarg_1);
6979 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
6980 new Type [] { typeof (string), typeof (string) });
6981 ilgen.Emit (OpCodes.Call, infoMethod);
6982 ilgen.Emit (OpCodes.Ret);
6984 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6985 typeof (void), Type.EmptyTypes);
6986 ilgen = mb.GetILGenerator ();
6987 ilgen.Emit (OpCodes.Ret);
6989 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6990 MethodAttributes.Static,
6991 typeof (void), Type.EmptyTypes);
6992 ilgen = mb.GetILGenerator ();
6993 ilgen.Emit (OpCodes.Ret);
6995 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6996 MethodAttributes.Abstract | MethodAttributes.Virtual,
6997 typeof (void), Type.EmptyTypes);
6999 Type emittedType = tb.CreateType ();
7001 MethodInfo [] methods = emittedType.GetMethods ();
7002 Assert.AreEqual (7, methods.Length, "#A1");
7003 Assert.AreEqual (7, tb.GetMethods ().Length, "#A2");
7005 mi = GetMethodByName (methods, "Hello");
7006 Assert.IsNotNull (mi, "#B1");
7007 Assert.IsFalse (mi.IsStatic, "#B2");
7008 Assert.IsFalse (mi.IsAbstract, "#B3");
7010 mi = GetMethodByName (methods, "Execute");
7011 Assert.IsNotNull (mi, "#C1");
7012 Assert.IsTrue (mi.IsStatic, "#C2");
7013 Assert.IsFalse (mi.IsAbstract, "#C3");
7015 mi = GetMethodByName (methods, "Init");
7016 Assert.IsNotNull (mi, "#D1");
7017 Assert.IsFalse (mi.IsStatic, "#D2");
7018 Assert.IsTrue (mi.IsAbstract, "#D3");
7020 mi = GetMethodByName (methods, "GetType");
7021 Assert.IsNotNull (mi, "#E1");
7022 Assert.IsFalse (methods [3].IsStatic, "#E2");
7023 Assert.IsFalse (methods [3].IsAbstract, "#E3");
7025 mi = GetMethodByName (methods, "ToString");
7026 Assert.IsNotNull (mi, "#F1");
7027 Assert.IsFalse (mi.IsStatic, "#F2");
7028 Assert.IsFalse (mi.IsAbstract, "#F3");
7030 mi = GetMethodByName (methods, "Equals");
7031 Assert.IsNotNull (mi, "#G1");
7032 Assert.IsFalse (mi.IsStatic, "#G2");
7033 Assert.IsFalse (mi.IsAbstract, "#G3");
7035 mi = GetMethodByName (methods, "GetHashCode");
7036 Assert.IsNotNull (mi, "#H1");
7037 Assert.IsFalse (mi.IsStatic, "#H2");
7038 Assert.IsFalse (mi.IsAbstract, "#H3");
7042 [Category ("NotDotNet")] // mcs depends on this
7043 public void TestGetMethodsFlagsIncomplete_Inheritance ()
7045 MethodInfo [] methods;
7048 TypeBuilder blueType = module.DefineType (genTypeName (),
7049 TypeAttributes.Public);
7050 CreateMembers (blueType, "Blue", false);
7052 TypeBuilder redType = module.DefineType (genTypeName (),
7053 TypeAttributes.Public, blueType);
7054 CreateMembers (redType, "Red", false);
7056 TypeBuilder greenType = module.DefineType (genTypeName (),
7057 TypeAttributes.Public, redType);
7058 CreateMembers (greenType, "Green", false);
7060 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7061 methods = greenType.GetMethods (flags);
7063 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7064 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7065 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7066 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7067 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7068 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7069 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7070 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7071 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7072 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7073 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7074 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7075 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7076 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7077 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7078 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7079 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7080 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7081 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7082 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7083 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7084 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7085 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7086 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7087 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7088 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7089 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7090 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7091 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7092 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7093 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7094 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7095 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7096 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7097 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7098 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7100 flags = BindingFlags.Instance | BindingFlags.Public;
7101 methods = greenType.GetMethods (flags);
7103 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7104 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7105 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7106 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7107 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7108 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7109 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7110 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7111 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7112 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7113 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7114 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7115 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7116 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7117 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7118 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7119 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7120 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7121 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7122 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7123 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7124 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7125 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7126 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7127 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7128 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7129 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7130 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7131 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7132 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7133 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7134 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7135 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7136 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7137 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7138 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7140 flags = BindingFlags.Static | BindingFlags.Public;
7141 methods = greenType.GetMethods (flags);
7143 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7144 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7145 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7146 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7147 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7148 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7149 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7150 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7151 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7152 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7153 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7154 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7155 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7156 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7157 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7158 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7159 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7160 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7161 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7162 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7163 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7164 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7165 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7166 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7167 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7168 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7169 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7170 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7171 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7172 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7173 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7174 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7175 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7176 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7177 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7178 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7180 flags = BindingFlags.Static | BindingFlags.NonPublic;
7181 methods = greenType.GetMethods (flags);
7183 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7184 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7185 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7186 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7187 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7188 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7189 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7190 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7191 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7192 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7193 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7194 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7195 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7196 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7197 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7198 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7199 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7200 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7201 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7202 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7203 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7204 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7205 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7206 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7207 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7208 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7209 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7210 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7211 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7212 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7213 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7214 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7215 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7216 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7217 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7218 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7220 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7221 BindingFlags.FlattenHierarchy;
7222 methods = greenType.GetMethods (flags);
7224 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7225 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7226 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7227 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7228 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7229 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7230 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7231 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7232 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7233 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7234 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7235 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7236 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7237 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7238 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7239 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7240 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7241 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7242 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7243 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7244 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7245 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7246 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7247 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7248 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7249 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7250 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7251 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7252 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7253 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7254 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7255 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7256 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7257 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7258 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7259 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7261 flags = BindingFlags.Instance | BindingFlags.Public |
7262 BindingFlags.FlattenHierarchy;
7263 methods = greenType.GetMethods (flags);
7265 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7266 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7267 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7268 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7269 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7270 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7271 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7272 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7273 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7274 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7275 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7276 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7277 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7278 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7279 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7280 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7281 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
7282 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
7283 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
7284 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
7285 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
7286 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
7287 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
7288 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
7289 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
7290 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
7291 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
7292 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
7293 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
7294 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
7295 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
7296 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
7297 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
7298 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
7299 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
7300 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
7302 flags = BindingFlags.Static | BindingFlags.Public |
7303 BindingFlags.FlattenHierarchy;
7304 methods = greenType.GetMethods (flags);
7306 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
7307 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
7308 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
7309 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
7310 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
7311 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
7312 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
7313 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
7314 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
7315 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
7316 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
7317 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
7318 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
7319 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
7320 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
7321 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
7322 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
7323 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
7324 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
7325 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
7326 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
7327 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
7328 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
7329 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
7330 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
7331 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
7332 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
7333 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
7334 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
7335 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
7336 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
7337 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
7338 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
7339 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
7340 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
7341 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
7343 flags = BindingFlags.Static | BindingFlags.NonPublic |
7344 BindingFlags.FlattenHierarchy;
7345 methods = greenType.GetMethods (flags);
7347 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
7348 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
7349 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
7350 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
7351 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
7352 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
7353 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
7354 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
7355 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
7356 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
7357 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
7358 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
7359 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
7360 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
7361 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
7362 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
7363 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
7364 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
7365 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
7366 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
7367 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
7368 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
7369 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
7370 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
7371 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
7372 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
7373 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
7374 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
7375 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
7376 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
7377 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
7378 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
7379 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
7380 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
7381 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
7382 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
7384 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7385 BindingFlags.DeclaredOnly;
7386 methods = greenType.GetMethods (flags);
7388 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
7389 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
7390 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
7391 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
7392 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
7393 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
7394 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
7395 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
7396 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
7397 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
7398 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
7399 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
7400 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
7401 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
7402 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
7403 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
7404 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
7405 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
7406 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
7407 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
7408 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
7409 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
7410 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
7411 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
7412 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
7413 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
7414 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
7415 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
7416 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
7417 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
7418 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
7419 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
7420 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
7421 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
7422 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
7423 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
7425 flags = BindingFlags.Instance | BindingFlags.Public |
7426 BindingFlags.DeclaredOnly;
7427 methods = greenType.GetMethods (flags);
7429 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
7430 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
7431 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
7432 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
7433 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
7434 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
7435 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
7436 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
7437 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
7438 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
7439 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
7440 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
7441 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
7442 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
7443 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
7444 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
7445 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
7446 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
7447 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
7448 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
7449 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
7450 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
7451 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
7452 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
7453 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
7454 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
7455 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
7456 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
7457 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
7458 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
7459 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
7460 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
7461 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
7462 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
7463 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
7464 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
7466 flags = BindingFlags.Static | BindingFlags.Public |
7467 BindingFlags.DeclaredOnly;
7468 methods = greenType.GetMethods (flags);
7470 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
7471 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
7472 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
7473 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
7474 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
7475 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
7476 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
7477 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
7478 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
7479 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
7480 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
7481 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
7482 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
7483 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
7484 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
7485 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
7486 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
7487 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
7488 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
7489 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
7490 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
7491 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
7492 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
7493 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
7494 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
7495 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
7496 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
7497 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
7498 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
7499 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
7500 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
7501 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
7502 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
7503 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
7504 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
7505 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
7507 flags = BindingFlags.Static | BindingFlags.NonPublic |
7508 BindingFlags.DeclaredOnly;
7509 methods = greenType.GetMethods (flags);
7511 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
7512 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
7513 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
7514 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
7515 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
7516 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
7517 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
7518 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
7519 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
7520 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
7521 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
7522 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
7523 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
7524 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
7525 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
7526 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
7527 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
7528 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
7529 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
7530 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
7531 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
7532 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
7533 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
7534 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
7535 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
7536 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
7537 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
7538 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
7539 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
7540 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
7541 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
7542 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
7543 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
7544 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
7545 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
7546 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
7548 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7549 BindingFlags.Public;
7550 methods = greenType.GetMethods (flags);
7552 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
7553 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
7554 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
7555 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
7556 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
7557 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
7558 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
7559 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
7560 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
7561 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
7562 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
7563 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
7564 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
7565 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
7566 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
7567 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
7568 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
7569 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
7570 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
7571 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
7572 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
7573 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
7574 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
7575 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
7576 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
7577 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
7578 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
7579 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
7580 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
7581 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
7582 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
7583 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
7584 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
7585 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
7586 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
7587 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
7589 flags = BindingFlags.Static | BindingFlags.NonPublic |
7590 BindingFlags.Public;
7591 methods = greenType.GetMethods (flags);
7593 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
7594 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
7595 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
7596 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
7597 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
7598 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
7599 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
7600 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
7601 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
7602 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
7603 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
7604 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
7605 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
7606 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
7607 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
7608 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
7609 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
7610 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
7611 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
7612 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
7613 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
7614 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
7615 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
7616 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
7617 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
7618 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
7619 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
7620 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
7621 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
7622 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
7623 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
7624 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
7625 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
7626 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
7627 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
7628 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
7632 [Category ("NotDotNet")] // mcs depends on this
7633 public void TestGetMethodsFlagsIncomplete_Mono ()
7637 MethodInfo [] methods;
7639 TypeBuilder tb = module.DefineType (genTypeName (),
7640 TypeAttributes.Abstract);
7641 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7642 typeof (void), Type.EmptyTypes);
7643 ilgen = mb.GetILGenerator ();
7644 ilgen.Emit (OpCodes.Ret);
7646 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7647 typeof (void), Type.EmptyTypes);
7648 ilgen = mb.GetILGenerator ();
7649 ilgen.Emit (OpCodes.Ret);
7651 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7652 MethodAttributes.Static,
7653 typeof (void), Type.EmptyTypes);
7654 ilgen = mb.GetILGenerator ();
7655 ilgen.Emit (OpCodes.Ret);
7657 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7658 MethodAttributes.Abstract | MethodAttributes.Virtual,
7659 typeof (void), Type.EmptyTypes);
7661 methods = tb.GetMethods (BindingFlags.Public |
7662 BindingFlags.Instance);
7663 Assert.AreEqual (6, methods.Length, "#A1");
7664 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#A2");
7665 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#A3");
7666 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#A4");
7667 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#A5");
7668 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#A6");
7670 methods = tb.GetMethods (BindingFlags.Public |
7671 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7672 Assert.AreEqual (2, methods.Length, "#B1");
7673 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#B2");
7674 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#B3");
7676 methods = tb.GetMethods (BindingFlags.Public |
7677 BindingFlags.Instance | BindingFlags.Static);
7678 Assert.AreEqual (7, methods.Length, "#C1");
7679 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#C2");
7680 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#C3");
7681 Assert.IsNotNull (GetMethodByName (methods, "Execute"), "#C4");
7682 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#C5");
7683 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#C6");
7684 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#C7");
7686 methods = tb.GetMethods (BindingFlags.NonPublic |
7687 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7688 Assert.AreEqual (1, methods.Length, "#D1");
7689 Assert.IsNotNull (GetMethodByName (methods, "Run"), "#D2");
7694 [Category ("NotWorking")] // mcs depends on this
7695 public void TestGetMethodsFlagsIncomplete_MS ()
7700 TypeBuilder tb = module.DefineType (genTypeName (),
7701 TypeAttributes.Abstract);
7702 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7703 typeof (void), Type.EmptyTypes);
7704 ilgen = mb.GetILGenerator ();
7705 ilgen.Emit (OpCodes.Ret);
7707 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7708 typeof (void), Type.EmptyTypes);
7709 ilgen = mb.GetILGenerator ();
7710 ilgen.Emit (OpCodes.Ret);
7712 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7713 MethodAttributes.Static,
7714 typeof (void), Type.EmptyTypes);
7715 ilgen = mb.GetILGenerator ();
7716 ilgen.Emit (OpCodes.Ret);
7718 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7719 MethodAttributes.Abstract | MethodAttributes.Virtual,
7720 typeof (void), Type.EmptyTypes);
7723 tb.GetMethods (BindingFlags.Public | BindingFlags.Instance);
7725 } catch (NotSupportedException ex) {
7726 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
7727 Assert.IsNull (ex.InnerException, "#3");
7728 Assert.IsNotNull (ex.Message, "#4");
7733 public void TestGetMethodsFlagsComplete ()
7735 TypeBuilder tb = module.DefineType (genTypeName ());
7736 MethodBuilder helloMethod = tb.DefineMethod ("HelloMethod",
7737 MethodAttributes.Public, typeof (string), Type.EmptyTypes);
7738 ILGenerator helloMethodIL = helloMethod.GetILGenerator ();
7739 helloMethodIL.Emit (OpCodes.Ldstr, "Hi! ");
7740 helloMethodIL.Emit (OpCodes.Ldarg_1);
7741 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
7742 new Type [] { typeof (string), typeof (string) });
7743 helloMethodIL.Emit (OpCodes.Call, infoMethod);
7744 helloMethodIL.Emit (OpCodes.Ret);
7746 Type emittedType = tb.CreateType ();
7748 Assert.AreEqual (1, tb.GetMethods (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Length, "#1");
7749 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length,
7750 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length, "#2");
7751 Assert.AreEqual (0, tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).Length, "#3");
7752 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length,
7753 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length, "#4");
7757 public void TestGetMethodsFlagsComplete_Inheritance ()
7759 MethodInfo [] methods;
7762 TypeBuilder blueType = module.DefineType (genTypeName (),
7763 TypeAttributes.Public);
7764 CreateMembers (blueType, "Blue", false);
7766 TypeBuilder redType = module.DefineType (genTypeName (),
7767 TypeAttributes.Public, blueType);
7768 CreateMembers (redType, "Red", false);
7770 TypeBuilder greenType = module.DefineType (genTypeName (),
7771 TypeAttributes.Public, redType);
7772 CreateMembers (greenType, "Green", false);
7774 blueType.CreateType ();
7775 redType.CreateType ();
7776 greenType.CreateType ();
7778 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7779 methods = greenType.GetMethods (flags);
7781 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7782 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7783 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7784 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7785 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7786 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7787 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7788 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7789 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7790 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7791 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7792 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7793 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7794 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7795 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7796 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7797 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7798 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7799 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7800 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7801 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7802 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7803 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7804 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7805 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7806 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7807 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7808 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7809 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7810 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7811 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7812 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7813 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7814 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7815 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7816 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7818 flags = BindingFlags.Instance | BindingFlags.Public;
7819 methods = greenType.GetMethods (flags);
7821 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7822 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7823 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7824 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7825 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7826 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7827 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7828 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7829 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7830 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7831 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7832 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7833 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7834 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7835 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7836 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7837 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7838 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7839 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7840 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7841 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7842 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7843 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7844 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7845 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7846 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7847 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7848 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7849 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7850 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7851 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7852 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7853 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7854 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7855 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7856 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7858 flags = BindingFlags.Static | BindingFlags.Public;
7859 methods = greenType.GetMethods (flags);
7861 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7862 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7863 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7864 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7865 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7866 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7867 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7868 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7869 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7870 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7871 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7872 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7873 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7874 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7875 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7876 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7877 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7878 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7879 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7880 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7881 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7882 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7883 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7884 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7885 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7886 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7887 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7888 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7889 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7890 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7891 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7892 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7893 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7894 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7895 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7896 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7898 flags = BindingFlags.Static | BindingFlags.NonPublic;
7899 methods = greenType.GetMethods (flags);
7901 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7902 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7903 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7904 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7905 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7906 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7907 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7908 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7909 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7910 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7911 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7912 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7913 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7914 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7915 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7916 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7917 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7918 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7919 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7920 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7921 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7922 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7923 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7924 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7925 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7926 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7927 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7928 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7929 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7930 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7931 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7932 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7933 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7934 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7935 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7936 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7938 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7939 BindingFlags.FlattenHierarchy;
7940 methods = greenType.GetMethods (flags);
7942 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7943 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7944 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7945 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7946 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7947 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7948 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7949 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7950 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7951 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7952 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7953 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7954 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7955 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7956 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7957 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7958 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7959 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7960 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7961 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7962 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7963 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7964 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7965 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7966 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7967 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7968 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7969 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7970 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7971 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7972 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7973 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7974 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7975 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7976 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7977 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7979 flags = BindingFlags.Instance | BindingFlags.Public |
7980 BindingFlags.FlattenHierarchy;
7981 methods = greenType.GetMethods (flags);
7983 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7984 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7985 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7986 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7987 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7988 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7989 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7990 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7991 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7992 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7993 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7994 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7995 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7996 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7997 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7998 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7999 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
8000 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
8001 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
8002 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
8003 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
8004 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
8005 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
8006 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
8007 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
8008 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
8009 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
8010 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
8011 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
8012 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
8013 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
8014 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
8015 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
8016 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
8017 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
8018 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
8020 flags = BindingFlags.Static | BindingFlags.Public |
8021 BindingFlags.FlattenHierarchy;
8022 methods = greenType.GetMethods (flags);
8024 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
8025 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
8026 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
8027 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
8028 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
8029 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
8030 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
8031 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
8032 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
8033 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
8034 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
8035 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
8036 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
8037 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
8038 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
8039 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
8040 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
8041 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
8042 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
8043 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
8044 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
8045 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
8046 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
8047 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
8048 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
8049 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
8050 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
8051 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
8052 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
8053 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
8054 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
8055 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
8056 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
8057 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
8058 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
8059 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
8061 flags = BindingFlags.Static | BindingFlags.NonPublic |
8062 BindingFlags.FlattenHierarchy;
8063 methods = greenType.GetMethods (flags);
8065 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
8066 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
8067 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
8068 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
8069 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
8070 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
8071 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
8072 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
8073 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
8074 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
8075 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
8076 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
8077 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
8078 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
8079 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
8080 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
8081 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
8082 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
8083 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
8084 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
8085 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
8086 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
8087 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
8088 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
8089 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
8090 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
8091 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
8092 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
8093 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
8094 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
8095 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
8096 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
8097 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
8098 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
8099 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
8100 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
8102 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8103 BindingFlags.DeclaredOnly;
8104 methods = greenType.GetMethods (flags);
8106 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
8107 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
8108 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
8109 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
8110 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
8111 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
8112 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
8113 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
8114 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
8115 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
8116 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
8117 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
8118 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
8119 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
8120 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
8121 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
8122 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
8123 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
8124 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
8125 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
8126 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
8127 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
8128 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
8129 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
8130 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
8131 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
8132 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
8133 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
8134 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
8135 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
8136 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
8137 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
8138 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
8139 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
8140 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
8141 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
8143 flags = BindingFlags.Instance | BindingFlags.Public |
8144 BindingFlags.DeclaredOnly;
8145 methods = greenType.GetMethods (flags);
8147 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
8148 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
8149 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
8150 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
8151 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
8152 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
8153 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
8154 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
8155 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
8156 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
8157 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
8158 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
8159 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
8160 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
8161 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
8162 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
8163 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
8164 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
8165 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
8166 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
8167 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
8168 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
8169 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
8170 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
8171 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
8172 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
8173 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
8174 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
8175 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
8176 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
8177 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
8178 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
8179 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
8180 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
8181 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
8182 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
8184 flags = BindingFlags.Static | BindingFlags.Public |
8185 BindingFlags.DeclaredOnly;
8186 methods = greenType.GetMethods (flags);
8188 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
8189 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
8190 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
8191 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
8192 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
8193 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
8194 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
8195 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
8196 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
8197 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
8198 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
8199 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
8200 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
8201 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
8202 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
8203 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
8204 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
8205 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
8206 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
8207 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
8208 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
8209 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
8210 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
8211 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
8212 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
8213 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
8214 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
8215 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
8216 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
8217 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
8218 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
8219 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
8220 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
8221 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
8222 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
8223 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
8225 flags = BindingFlags.Static | BindingFlags.NonPublic |
8226 BindingFlags.DeclaredOnly;
8227 methods = greenType.GetMethods (flags);
8229 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
8230 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
8231 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
8232 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
8233 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
8234 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
8235 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
8236 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
8237 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
8238 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
8239 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
8240 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
8241 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
8242 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
8243 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
8244 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
8245 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
8246 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
8247 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
8248 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
8249 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
8250 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
8251 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
8252 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
8253 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
8254 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
8255 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
8256 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
8257 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
8258 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
8259 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
8260 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
8261 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
8262 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
8263 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
8264 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
8266 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8267 BindingFlags.Public;
8268 methods = greenType.GetMethods (flags);
8270 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
8271 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
8272 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
8273 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
8274 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
8275 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
8276 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
8277 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
8278 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
8279 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
8280 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
8281 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
8282 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
8283 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
8284 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
8285 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
8286 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
8287 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
8288 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
8289 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
8290 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
8291 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
8292 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
8293 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
8294 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
8295 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
8296 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
8297 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
8298 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
8299 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
8300 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
8301 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
8302 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
8303 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
8304 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
8305 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
8307 flags = BindingFlags.Static | BindingFlags.NonPublic |
8308 BindingFlags.Public;
8309 methods = greenType.GetMethods (flags);
8311 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
8312 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
8313 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
8314 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
8315 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
8316 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
8317 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
8318 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
8319 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
8320 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
8321 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
8322 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
8323 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
8324 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
8325 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
8326 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
8327 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
8328 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
8329 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
8330 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
8331 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
8332 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
8333 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
8334 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
8335 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
8336 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
8337 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
8338 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
8339 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
8340 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
8341 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
8342 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
8343 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
8344 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
8345 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
8346 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
8350 public void TestGetMemberIncomplete ()
8352 TypeBuilder tb = module.DefineType (genTypeName ());
8354 tb.GetMember ("FOO", MemberTypes.All, BindingFlags.Public);
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 TestGetMemberComplete ()
8368 TypeBuilder tb = module.DefineType (genTypeName ());
8369 tb.DefineField ("FOO", typeof (int), FieldAttributes.Private);
8371 Type emittedType = tb.CreateType ();
8373 Assert.AreEqual (1, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.NonPublic).Length);
8374 Assert.AreEqual (0, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.Public).Length);
8378 public void TestGetMembersIncomplete ()
8380 TypeBuilder tb = module.DefineType (genTypeName ());
8384 } catch (NotSupportedException ex) {
8385 // The invoked member is not supported in a
8387 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8388 Assert.IsNull (ex.InnerException, "#3");
8389 Assert.IsNotNull (ex.Message, "#4");
8394 public void TestGetMembersComplete ()
8396 TypeBuilder tb = module.DefineType (genTypeName ());
8397 Type emittedType = tb.CreateType ();
8399 Assert.AreEqual (tb.GetMembers ().Length, emittedType.GetMembers ().Length);
8403 public void TestGetMembersFlagsIncomplete ()
8405 TypeBuilder tb = module.DefineType (genTypeName ());
8407 tb.GetMembers (BindingFlags.Public);
8409 } catch (NotSupportedException ex) {
8410 // The invoked member is not supported in a
8412 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8413 Assert.IsNull (ex.InnerException, "#3");
8414 Assert.IsNotNull (ex.Message, "#4");
8419 public void TestGetMembersFlagsComplete ()
8421 TypeBuilder tb = module.DefineType (genTypeName ());
8422 tb.DefineField ("FOO", typeof (int), FieldAttributes.Public);
8424 Type emittedType = tb.CreateType ();
8426 Assert.IsTrue (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length != 0);
8427 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length,
8428 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length);
8429 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length,
8430 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length);
8434 public void TestGetInterfaceIncomplete ()
8436 TypeBuilder tb = module.DefineType (genTypeName ());
8438 tb.GetInterface ("FOO", true);
8440 } catch (NotSupportedException ex) {
8441 // The invoked member is not supported in a
8443 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8444 Assert.IsNull (ex.InnerException, "#3");
8445 Assert.IsNotNull (ex.Message, "#4");
8450 public void TestGetInterfaces ()
8452 TypeBuilder tb = module.DefineType (genTypeName ());
8453 Type [] interfaces = tb.GetInterfaces ();
8454 Assert.AreEqual (0, interfaces.Length);
8456 TypeBuilder tbInterface = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
8457 Type emittedInterface = tbInterface.CreateType ();
8459 tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { emittedInterface });
8460 interfaces = tb.GetInterfaces ();
8461 Assert.AreEqual (1, interfaces.Length);
8465 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8466 public void TestAddDeclarativeSecurityAlreadyCreated ()
8468 TypeBuilder tb = module.DefineType (genTypeName ());
8471 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8473 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8475 } catch (InvalidOperationException ex) {
8476 // Unable to change after type has been created
8477 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8478 Assert.IsNull (ex.InnerException, "#3");
8479 Assert.IsNotNull (ex.Message, "#4");
8484 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8485 public void TestAddDeclarativeSecurityNullPermissionSet ()
8487 TypeBuilder tb = module.DefineType (genTypeName ());
8489 tb.AddDeclarativeSecurity (SecurityAction.Demand, null);
8491 } catch (ArgumentNullException ex) {
8492 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
8493 Assert.IsNull (ex.InnerException, "#3");
8494 Assert.IsNotNull (ex.Message, "#4");
8495 Assert.AreEqual ("pset", ex.ParamName, "#5");
8501 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8502 public void TestAddDeclarativeSecurityInvalidAction ()
8504 TypeBuilder tb = module.DefineType (genTypeName ());
8506 SecurityAction [] actions = new SecurityAction [] {
8507 SecurityAction.RequestMinimum,
8508 SecurityAction.RequestOptional,
8509 SecurityAction.RequestRefuse };
8510 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8512 foreach (SecurityAction action in actions) {
8514 tb.AddDeclarativeSecurity (action, set);
8516 } catch (ArgumentOutOfRangeException) {
8522 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8523 public void TestAddDeclarativeSecurityDuplicateAction ()
8525 TypeBuilder tb = module.DefineType (genTypeName ());
8527 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8528 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8530 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8532 } catch (InvalidOperationException ex) {
8533 // Multiple permission sets specified with the
8534 // same SecurityAction
8535 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8536 Assert.IsNull (ex.InnerException, "#3");
8537 Assert.IsNotNull (ex.Message, "#4");
8542 public void TestEnums ()
8544 TypeAttributes typeAttrs = TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed;
8545 TypeBuilder enumToCreate = module.DefineType (genTypeName (), typeAttrs,
8547 enumToCreate.SetCustomAttribute (new CustomAttributeBuilder (typeof (FlagsAttribute).GetConstructors () [0], Type.EmptyTypes));
8548 // add value__ field, see DefineEnum method of ModuleBuilder
8549 enumToCreate.DefineField ("value__", typeof (Int32),
8550 FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
8553 FieldBuilder fb = enumToCreate.DefineField ("A", enumToCreate,
8554 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8555 fb.SetConstant ((Int32) 0);
8557 fb = enumToCreate.DefineField ("B", enumToCreate,
8558 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8559 fb.SetConstant ((Int32) 1);
8561 fb = enumToCreate.DefineField ("C", enumToCreate,
8562 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8563 fb.SetConstant ((Int32) 2);
8565 Type enumType = enumToCreate.CreateType ();
8567 object enumVal = Enum.ToObject (enumType, (Int32) 3);
8569 Assert.AreEqual ("B, C", enumVal.ToString ());
8570 Assert.AreEqual (3, (Int32) enumVal);
8574 public void DefineEnum ()
8576 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8577 TypeAttributes.Public);
8578 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8579 TypeAttributes.Public, typeof (int));
8580 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8581 enumBuilder.CreateType ();
8582 typeBuilder.CreateType ();
8586 [Category ("NotWorking")]
8587 public void DefineEnumThrowIfTypeBuilderCalledBeforeEnumBuilder ()
8589 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8590 TypeAttributes.Public);
8591 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8592 TypeAttributes.Public, typeof (int));
8593 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8595 typeBuilder.CreateType ();
8597 } catch (TypeLoadException) {
8598 // Could not load type '...' from assembly
8599 // 'MonoTests.System.Reflection.Emit.TypeBuilderTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
8601 Assert.IsTrue (typeBuilder.IsCreated (), "#2");
8602 Assert.IsNull (typeBuilder.CreateType (), "#3");
8606 public void SetCustomAttribute_SuppressUnmanagedCodeSecurity ()
8608 TypeBuilder tb = module.DefineType (genTypeName ());
8609 ConstructorInfo attrCtor = typeof (SuppressUnmanagedCodeSecurityAttribute).
8610 GetConstructor (Type.EmptyTypes);
8611 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
8612 attrCtor, new object [0]);
8613 Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#1");
8614 tb.SetCustomAttribute (caBuilder);
8615 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#2");
8616 Type emittedType = tb.CreateType ();
8617 Assert.AreEqual (TypeAttributes.HasSecurity, emittedType.Attributes & TypeAttributes.HasSecurity, "#3");
8618 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#4");
8619 object [] emittedAttrs = emittedType.GetCustomAttributes (typeof (SuppressUnmanagedCodeSecurityAttribute), true);
8620 Assert.AreEqual (1, emittedAttrs.Length, "#5");
8623 private PropertyBuilder DefineStringProperty (TypeBuilder tb, string propertyName, string fieldName, MethodAttributes methodAttribs)
8625 // define the field holding the property value
8626 FieldBuilder fieldBuilder = tb.DefineField (fieldName,
8627 typeof (string), FieldAttributes.Private);
8629 PropertyBuilder propertyBuilder = tb.DefineProperty (
8630 propertyName, PropertyAttributes.HasDefault, typeof (string),
8631 new Type [] { typeof (string) });
8633 // First, we'll define the behavior of the "get" property for CustomerName as a method.
8634 MethodBuilder getMethodBuilder = tb.DefineMethod ("Get" + propertyName,
8639 ILGenerator getIL = getMethodBuilder.GetILGenerator ();
8641 getIL.Emit (OpCodes.Ldarg_0);
8642 getIL.Emit (OpCodes.Ldfld, fieldBuilder);
8643 getIL.Emit (OpCodes.Ret);
8645 // Now, we'll define the behavior of the "set" property for CustomerName.
8646 MethodBuilder setMethodBuilder = tb.DefineMethod ("Set" + propertyName,
8649 new Type [] { typeof (string) });
8651 ILGenerator setIL = setMethodBuilder.GetILGenerator ();
8653 setIL.Emit (OpCodes.Ldarg_0);
8654 setIL.Emit (OpCodes.Ldarg_1);
8655 setIL.Emit (OpCodes.Stfld, fieldBuilder);
8656 setIL.Emit (OpCodes.Ret);
8658 // Last, we must map the two methods created above to our PropertyBuilder to
8659 // their corresponding behaviors, "get" and "set" respectively.
8660 propertyBuilder.SetGetMethod (getMethodBuilder);
8661 propertyBuilder.SetSetMethod (setMethodBuilder);
8662 return propertyBuilder;
8665 static int handler_called = 0;
8668 public void TestTypeResolve ()
8670 string typeName = genTypeName ();
8672 ResolveEventHandler handler = new ResolveEventHandler (TypeResolve);
8673 AppDomain.CurrentDomain.TypeResolve += handler;
8675 Type t = Type.GetType (typeName);
8676 Assert.AreEqual (typeName, t.Name);
8677 Assert.AreEqual (1, handler_called);
8678 AppDomain.CurrentDomain.TypeResolve -= handler;
8681 Assembly TypeResolve (object sender, ResolveEventArgs args)
8683 TypeBuilder tb = module.DefineType (args.Name, TypeAttributes.Public);
8690 public void IsAssignableFrom_Created ()
8692 TypeBuilder tb = module.DefineType (genTypeName (),
8693 TypeAttributes.Public, typeof (MemoryStream),
8694 new Type [] { typeof (IThrowable), typeof (Bar) });
8695 tb.AddInterfaceImplementation (typeof (IDestroyable));
8696 Type emitted_type = tb.CreateType ();
8698 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8699 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8700 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8701 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8702 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb), "#A5");
8703 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#A6");
8704 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#A7");
8705 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#A8");
8706 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#A9");
8707 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#A10");
8708 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#A11");
8709 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#A12");
8710 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A13");
8711 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A14");
8712 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A15");
8713 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A16");
8714 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A17");
8715 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A18");
8717 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#B1");
8718 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#B2");
8719 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#B3");
8720 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#B4");
8721 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#B5");
8722 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#B6");
8723 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#B7");
8724 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#B8");
8725 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#B9");
8726 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#B10");
8728 Assert.IsTrue (tb.IsAssignableFrom (tb), "#C1");
8729 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#C2");
8730 Assert.IsTrue (tb.IsAssignableFrom (emitted_type), "#C3");
8731 Assert.IsTrue (emitted_type.IsAssignableFrom (tb), "#C4");
8732 Assert.IsFalse (emitted_type.IsAssignableFrom ((Type) null), "#C5");
8734 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type), "#D1");
8735 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IThrowable)), "#D2");
8736 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type), "#D3");
8737 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IMoveable)), "#D4");
8738 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type), "#D5");
8739 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Foo)), "#D6");
8740 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type), "#D7");
8741 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Bar)), "#D8");
8742 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type), "#D9");
8743 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Baz)), "#D10");
8744 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type), "#D11");
8745 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDestroyable)), "#D12");
8746 Assert.IsFalse (typeof (IAir).IsAssignableFrom (emitted_type), "#D13");
8747 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IAir)), "#D14");
8748 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type), "#D15");
8749 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IWater)), "#D16");
8750 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type), "#D17");
8751 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (ILiquid)), "#D18");
8753 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type), "#E1");
8754 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (MemoryStream)), "#E2");
8755 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type), "#E3");
8756 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Stream)), "#E4");
8757 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type), "#E5");
8758 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (FileStream)), "#E6");
8759 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type), "#E7");
8760 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (object)), "#E8");
8761 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type), "#E9");
8762 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDisposable)), "#E10");
8764 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8765 tb.FullName + "[]")), "#F1");
8766 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8767 tb.FullName + "[]")), "#F2");
8768 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8769 tb.FullName + "[]")), "#F3");
8771 TypeBuilder tb2 = module.DefineType (genTypeName (),
8772 TypeAttributes.Public, tb,
8773 new Type [] { typeof (IAir) });
8774 Type emitted_type2 = tb2.CreateType ();
8776 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#G1");
8777 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#G2");
8778 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#G3");
8779 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#G4");
8780 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#G5");
8781 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#G6");
8782 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#G7");
8783 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#G8");
8784 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#G9");
8785 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#G10");
8786 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#G11");
8787 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDestroyable)), "#G12");
8788 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#G13");
8789 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#G14");
8790 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#G15");
8791 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#G16");
8792 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#G17");
8793 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#G18");
8795 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#H1");
8796 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#H2");
8797 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#H3");
8798 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#H4");
8799 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#H5");
8800 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#H6");
8801 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#H7");
8802 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#H8");
8803 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#H9");
8804 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#H10");
8806 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#I1");
8807 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#I2");
8808 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type2), "#I3");
8809 Assert.IsFalse (tb2.IsAssignableFrom (emitted_type), "#I4");
8810 Assert.IsFalse (tb2.IsAssignableFrom ((Type) null), "#I5");
8811 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type2), "#I6");
8812 Assert.IsFalse (emitted_type2.IsAssignableFrom (emitted_type), "#I7");
8813 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb2), "#I8");
8814 Assert.IsFalse (emitted_type2.IsAssignableFrom (tb), "#I9");
8815 Assert.IsFalse (emitted_type2.IsAssignableFrom ((Type) null), "#I10");
8816 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#I11");
8817 Assert.IsTrue (tb.IsAssignableFrom (emitted_type2), "#I12");
8818 Assert.IsTrue (emitted_type.IsAssignableFrom (tb2), "#I13");
8819 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type2), "#I14");
8821 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type2), "#J1");
8822 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IThrowable)), "#J2");
8823 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type2), "#J3");
8824 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IMoveable)), "#J4");
8825 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type2), "#J5");
8826 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Foo)), "#J6");
8827 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type2), "#J7");
8828 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Bar)), "#J8");
8829 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type2), "#J9");
8830 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Baz)), "#J10");
8831 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#J11");
8832 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDestroyable)), "#J12");
8833 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type2), "#J13");
8834 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IAir)), "#J14");
8835 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type2), "#J15");
8836 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IWater)), "#J16");
8837 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type2), "#J17");
8838 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (ILiquid)), "#J18");
8840 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type2), "#K1");
8841 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (MemoryStream)), "#K2");
8842 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type2), "#K3");
8843 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Stream)), "#K4");
8844 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type2), "#K5");
8845 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (FileStream)), "#K6");
8846 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type2), "#K7");
8847 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (object)), "#K8");
8848 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type2), "#K9");
8849 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDisposable)), "#K10");
8851 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8852 tb2.FullName + "[]")), "#L1");
8853 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8854 tb2.FullName + "[]")), "#L2");
8855 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8856 tb2.FullName + "[]")), "#L3");
8858 TypeBuilder tb3 = module.DefineType (genTypeName (),
8859 TypeAttributes.Public, tb2,
8860 new Type [] { typeof (IWater) });
8861 Type emitted_type3 = tb3.CreateType ();
8863 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#M1");
8864 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#M2");
8865 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#M3");
8866 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#M4");
8867 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#M5");
8868 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#M6");
8869 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#M7");
8870 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#M8");
8871 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#M9");
8872 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#M10");
8873 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb3), "#M11");
8874 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDestroyable)), "#M12");
8875 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#M13");
8876 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#M14");
8877 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#M15");
8878 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#M16");
8879 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (tb3), "#M17");
8880 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#M18");
8882 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#N1");
8883 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#N2");
8884 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#N3");
8885 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#N4");
8886 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#N5");
8887 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#N6");
8888 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#N7");
8889 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#N8");
8890 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#N9");
8891 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#N10");
8893 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#O1");
8894 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#O2");
8895 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#O3");
8896 Assert.IsTrue (tb3.IsAssignableFrom (emitted_type3), "#O4");
8897 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type2), "#O5");
8898 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type), "#O6");
8899 Assert.IsFalse (tb3.IsAssignableFrom ((Type) null), "#O7");
8900 Assert.IsTrue (emitted_type3.IsAssignableFrom (emitted_type3), "#O8");
8901 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type2), "#O9");
8902 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type), "#O10");
8903 Assert.IsTrue (emitted_type3.IsAssignableFrom (tb3), "#O11");
8904 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb2), "#O12");
8905 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb), "#O13");
8906 Assert.IsFalse (emitted_type3.IsAssignableFrom ((Type) null), "#O14");
8907 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#O15");
8908 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type3), "#O16");
8909 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type3), "#O17");
8910 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb3), "#O18");
8911 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#O19");
8912 Assert.IsTrue (tb.IsAssignableFrom (emitted_type3), "#O20");
8913 Assert.IsTrue (emitted_type.IsAssignableFrom (tb3), "#021");
8914 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type3), "#O22");
8916 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type3), "#P1");
8917 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IThrowable)), "#P2");
8918 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type3), "#P3");
8919 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IMoveable)), "#P4");
8920 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type3), "#P5");
8921 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Foo)), "#P6");
8922 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type3), "#P7");
8923 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Bar)), "#P8");
8924 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type3), "#P9");
8925 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Baz)), "#P10");
8926 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type3), "#P11");
8927 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDestroyable)), "#P12");
8928 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type3), "#P13");
8929 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IAir)), "#P14");
8930 Assert.IsTrue (typeof (IWater).IsAssignableFrom (emitted_type3), "#P15");
8931 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IWater)), "#P16");
8932 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (emitted_type3), "#P17");
8933 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (ILiquid)), "#P18");
8935 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type3), "#Q1");
8936 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (MemoryStream)), "#Q2");
8937 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type3), "#Q3");
8938 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Stream)), "#Q4");
8939 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type3), "#Q5");
8940 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (FileStream)), "#Q6");
8941 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type3), "#Q7");
8942 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (object)), "#Q8");
8943 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type3), "#Q9");
8944 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDisposable)), "#Q10");
8946 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8947 tb3.FullName + "[]")), "#R1");
8948 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8949 tb3.FullName + "[]")), "#R2");
8950 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8951 tb3.FullName + "[]")), "#R3");
8953 TypeBuilder tb4 = module.DefineType (genTypeName (),
8954 TypeAttributes.Public, null,
8955 new Type [] { typeof (IWater) });
8956 tb4.DefineGenericParameters ("T");
8958 Type inst = tb4.MakeGenericType (typeof (int));
8959 Type emitted_type4 = tb4.CreateType ();
8960 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (inst));
8961 // This returns True if CreateType () is called _before_ MakeGenericType...
8962 //Assert.IsFalse (typeof (IWater).IsAssignableFrom (inst));
8966 public void IsAssignableFrom_NotCreated ()
8968 TypeBuilder tb = module.DefineType (genTypeName (),
8969 TypeAttributes.Public, typeof (MemoryStream),
8971 typeof (IThrowable), typeof (Bar),
8972 typeof (IComparable)
8975 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8976 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8977 //Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8978 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8979 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb), "#A5");
8980 Assert.IsFalse (tb.IsAssignableFrom (typeof (IComparable)), "#A6");
8981 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A7");
8982 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A8");
8983 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A9");
8984 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A10");
8985 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A11");
8986 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A12");
8988 //Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb), "#B1");
8989 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#B2");
8990 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#B3");
8991 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#B4");
8992 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#B5");
8993 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#B6");
8995 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#C1");
8996 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#C2");
8997 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#C3");
8998 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#C4");
8999 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#C5");
9000 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#C6");
9001 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#C7");
9002 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#C8");
9003 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#C9");
9004 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#C10");
9006 Assert.IsTrue (tb.IsAssignableFrom (tb), "#D1");
9007 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#D2");
9009 TypeBuilder tb2 = module.DefineType (genTypeName (),
9010 TypeAttributes.Public, tb,
9011 new Type[] { typeof (IAir) });
9013 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#E1");
9014 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#E2");
9015 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#E3");
9016 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#E4");
9017 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb2), "#E5");
9018 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IComparable)), "#E6");
9019 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#E7");
9020 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#E8");
9021 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#E9");
9022 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#E10");
9023 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#E11");
9024 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#E12");
9026 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#F1");
9027 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#F2");
9028 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#F3");
9029 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#F4");
9030 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#F5");
9031 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#F6");
9033 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#G1");
9034 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#G2");
9035 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#G3");
9036 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#G4");
9037 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#G5");
9038 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#G6");
9039 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#G7");
9040 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#G8");
9041 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#G9");
9042 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#G10");
9044 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#H1");
9045 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#H2");
9046 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#H3");
9048 TypeBuilder tb3 = module.DefineType (genTypeName (),
9049 TypeAttributes.Public, tb2,
9050 new Type[] { typeof (IWater) });
9052 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#I1");
9053 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#I2");
9054 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#I3");
9055 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#I4");
9056 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb3), "#I5");
9057 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IComparable)), "#I6");
9058 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#I7");
9059 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#I8");
9060 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#I9");
9061 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#I10");
9062 //Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb3), "#I11");
9063 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#I12");
9065 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#J1");
9066 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#J2");
9067 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#J3");
9068 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#J4");
9069 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#J5");
9070 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#J6");
9072 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#K1");
9073 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#K2");
9074 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#K3");
9075 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#K4");
9076 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#K5");
9077 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#K6");
9078 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#K7");
9079 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#K8");
9080 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#K9");
9081 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#K10");
9083 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#L1");
9084 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#L2");
9085 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#L3");
9086 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#L4");
9087 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#L5");
9091 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9092 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_Mono ()
9094 TypeBuilder tb = module.DefineType (genTypeName (),
9095 TypeAttributes.Public, typeof (FormatException),
9096 new Type [] { typeof (IThrowable) });
9097 tb.AddInterfaceImplementation (typeof (IDestroyable));
9099 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9100 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9102 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9103 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9107 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9108 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_MS ()
9110 TypeBuilder tb = module.DefineType (genTypeName (),
9111 TypeAttributes.Public, typeof (FormatException),
9112 new Type [] { typeof (IThrowable) });
9113 tb.AddInterfaceImplementation (typeof (IDestroyable));
9115 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9116 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9118 Assert.IsFalse (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9119 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9124 // Casts don't work with unfinished types
9125 [Category ("NotWorking")]
9126 [Category ("NotDotNet")]
9127 public void IsAssignableFrom_NotCreated_Array ()
9129 TypeBuilder tb = module.DefineType (genTypeName (),
9130 TypeAttributes.Public, typeof (FormatException),
9132 typeof (IThrowable), typeof (Bar),
9133 typeof (IComparable)
9136 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9137 tb.FullName + "[]")), "#1");
9138 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9139 tb.FullName + "[]")), "#2");
9140 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9141 tb.FullName + "[]")), "#3");
9145 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9146 public void IsAssignableFrom_NotCreated_BaseInterface_Mono ()
9148 TypeBuilder tb = module.DefineType (genTypeName (),
9149 TypeAttributes.Public, typeof (FormatException),
9151 typeof (IThrowable), typeof (Bar),
9152 typeof (IComparable)
9155 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9156 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9160 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9161 public void IsAssignableFrom_NotCreated_BaseInterface_MS ()
9163 TypeBuilder tb = module.DefineType (genTypeName (),
9164 TypeAttributes.Public, typeof (FormatException),
9166 typeof (IThrowable), typeof (Bar),
9167 typeof (IComparable)
9170 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9171 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9175 public void CreateType_EmptyMethodBody ()
9177 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9179 tb.DefineMethod ("foo", MethodAttributes.Public, typeof (void), new Type [] { });
9183 } catch (InvalidOperationException ex) {
9184 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9185 Assert.IsNull (ex.InnerException, "#3");
9186 Assert.IsNotNull (ex.Message, "#4");
9191 public void CreateType_EmptyCtorBody ()
9193 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9195 tb.DefineConstructor (0, CallingConventions.Standard, null);
9199 } catch (InvalidOperationException ex) {
9200 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9201 Assert.IsNull (ex.InnerException, "#3");
9202 Assert.IsNotNull (ex.Message, "#4");
9207 [Category ("NotWorking")]
9208 public void CreateType_Interface_ParentInvalid ()
9212 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9213 typeof (Exception));
9214 Assert.AreEqual (typeof (Exception), tb.BaseType, "#A1");
9217 Assert.Fail ("#A2");
9218 } catch (TypeLoadException ex) {
9219 // Could not load interface 't5' from assembly '...'
9220 // because it must extend from Object
9221 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A3");
9222 Assert.IsNull (ex.InnerException, "#A4");
9223 Assert.IsNotNull (ex.Message, "#A5");
9224 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#A6");
9225 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#A7");
9228 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9230 Assert.AreEqual (typeof (object), tb.BaseType, "#B1");
9233 Assert.Fail ("#B2");
9234 } catch (TypeLoadException ex) {
9235 // Failure has occurred while loading a type
9236 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B3");
9237 Assert.IsNull (ex.InnerException, "#B4");
9238 Assert.IsNotNull (ex.Message, "#B5");
9241 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9242 typeof (EmptyInterface));
9243 Assert.AreEqual (typeof (EmptyInterface), tb.BaseType, "#C1");
9246 Assert.Fail ("#C2");
9247 } catch (TypeLoadException ex) {
9248 // Could not load interface 't5' from assembly '...'
9249 // because the parent type is an interface
9250 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#C3");
9251 Assert.IsNull (ex.InnerException, "#C4");
9252 Assert.IsNotNull (ex.Message, "#C5");
9253 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#C6");
9254 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#C7");
9259 public void CreateType_Parent_DefaultCtorMissing ()
9263 tb = module.DefineType (genTypeName ());
9264 ConstructorBuilder cb = tb.DefineConstructor (
9265 MethodAttributes.Public,
9266 CallingConventions.Standard,
9267 new Type [] { typeof (string) });
9268 cb.GetILGenerator ().Emit (OpCodes.Ret);
9269 Type parent_type = tb.CreateType ();
9271 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
9276 } catch (NotSupportedException ex) {
9277 // Parent does not have a default constructor.
9278 // The default constructor must be explicitly defined
9279 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
9280 Assert.IsNull (ex.InnerException, "#3");
9281 Assert.IsNotNull (ex.Message, "#4");
9286 public void CreateType_Parent_Null ()
9291 tb = module.DefineType (genTypeName (), TypeAttributes.Public, null);
9292 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
9293 emitted_type = tb.CreateType ();
9294 Assert.AreEqual (typeof (object), emitted_type.BaseType, "#A2");
9296 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract, null);
9297 Assert.IsNull (tb.BaseType, "#B1");
9298 emitted_type = tb.CreateType ();
9299 Assert.IsNull (emitted_type.BaseType, "#B2");
9303 [Category ("NotWorking")]
9304 public void DefineGenericParameters_AlreadyDefined ()
9306 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9307 tb.DefineGenericParameters ("K");
9309 tb.DefineGenericParameters ("V");
9311 } catch (InvalidOperationException ex) {
9312 // Operation is not valid due to the current
9313 // state of the object
9314 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9315 Assert.IsNull (ex.InnerException, "#3");
9316 Assert.IsNotNull (ex.Message, "#4");
9321 public void DefineGenericParameters_Names_Empty ()
9323 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9326 tb.DefineGenericParameters (new string [0]);
9328 } catch (ArgumentException ex) {
9329 // Value does not fall within the expected range
9330 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9331 Assert.IsNull (ex.InnerException, "#3");
9332 Assert.IsNotNull (ex.Message, "#4");
9333 Assert.IsNull (ex.ParamName, "#5");
9338 public void DefineGenericParameters_Names_Null ()
9340 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9343 tb.DefineGenericParameters ((string []) null);
9344 Assert.Fail ("#A1");
9345 } catch (ArgumentNullException ex) {
9346 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9347 Assert.IsNull (ex.InnerException, "#A3");
9348 Assert.IsNotNull (ex.Message, "#A4");
9349 Assert.AreEqual ("names", ex.ParamName, "#A5");
9353 tb.DefineGenericParameters ("K", null, "V");
9354 Assert.Fail ("#B1");
9355 } catch (ArgumentNullException ex) {
9356 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9357 Assert.IsNull (ex.InnerException, "#B3");
9358 Assert.IsNotNull (ex.Message, "#B4");
9359 Assert.AreEqual ("names", ex.ParamName, "#B5");
9364 public void GenericType ()
9366 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9367 tb.DefineGenericParameters ("T");
9369 Assert.IsTrue (tb.IsGenericType, "#A1");
9370 Assert.IsTrue (tb.IsGenericTypeDefinition, "#A2");
9371 Assert.IsTrue (tb.ContainsGenericParameters, "#A3");
9372 Assert.IsFalse (tb.IsGenericParameter, "#A4");
9374 Type[] args = tb.GetGenericArguments ();
9375 Assert.IsFalse (args [0].IsGenericType, "#B1");
9376 Assert.IsFalse (args [0].IsGenericTypeDefinition, "#B2");
9377 Assert.IsTrue (args [0].ContainsGenericParameters, "#B3");
9378 Assert.IsTrue (args [0].IsGenericParameter, "#B4");
9382 public void MakeGenericType ()
9387 tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9388 tb.DefineGenericParameters ("T");
9390 generic_type = tb.MakeGenericType (typeof (int));
9391 Assert.IsTrue (generic_type.IsGenericType, "#A1");
9392 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A2");
9393 Assert.IsFalse (generic_type.ContainsGenericParameters, "#A3");
9394 Assert.IsFalse (generic_type.IsGenericParameter, "#A4");
9396 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9397 Assert.IsTrue (generic_type.IsGenericType, "#B1");
9398 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B2");
9399 Assert.IsTrue (generic_type.ContainsGenericParameters, "#B3");
9400 Assert.IsFalse (generic_type.IsGenericParameter, "#B4");
9402 tb = module.DefineType (genTypeName (), TypeAttributes.Interface
9403 | TypeAttributes.Abstract | TypeAttributes.Public);
9404 tb.DefineGenericParameters ("T");
9406 generic_type = tb.MakeGenericType (typeof (int));
9407 Assert.IsTrue (generic_type.IsGenericType, "#C1");
9408 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#C2");
9409 Assert.IsFalse (generic_type.ContainsGenericParameters, "#C3");
9410 Assert.IsFalse (generic_type.IsGenericParameter, "#C4");
9412 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9413 Assert.IsTrue (generic_type.IsGenericType, "#D1");
9414 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#D2");
9415 Assert.IsTrue (generic_type.ContainsGenericParameters, "#D3");
9416 Assert.IsFalse (generic_type.IsGenericParameter, "#D4");
9420 public void MakeGenericType_NoGenericTypeDefinition ()
9422 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9424 tb.MakeGenericType (typeof (int));
9426 } catch (InvalidOperationException ex) {
9427 // Operation is not valid due to the current
9428 // state of the object
9429 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9430 Assert.IsNull (ex.InnerException, "#3");
9431 Assert.IsNotNull (ex.Message, "#4");
9436 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9437 public void MakeGenericType_TypeArguments_Null_Mono ()
9439 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9440 tb.DefineGenericParameters ("K", "V");
9443 tb.MakeGenericType ((Type []) null);
9444 Assert.Fail ("#A1");
9445 } catch (ArgumentNullException ex) {
9446 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9447 Assert.IsNull (ex.InnerException, "#A3");
9448 Assert.IsNotNull (ex.Message, "#A4");
9449 Assert.AreEqual ("typeArguments", ex.ParamName, "#A5");
9453 tb.MakeGenericType (typeof (string), (Type) null);
9454 Assert.Fail ("#B1");
9455 } catch (ArgumentNullException ex) {
9456 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9457 Assert.IsNull (ex.InnerException, "#B3");
9458 Assert.IsNotNull (ex.Message, "#B4");
9459 Assert.AreEqual ("typeArguments", ex.ParamName, "#B5");
9464 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9465 public void MakeGenericType_TypeArguments_Null_MS ()
9470 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9471 tb.DefineGenericParameters ("K", "V");
9473 generic_type = tb.MakeGenericType ((Type []) null);
9474 Assert.IsNotNull (generic_type, "#A1");
9475 Assert.IsTrue (generic_type.IsGenericType, "#A2");
9476 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A3");
9477 type_args = generic_type.GetGenericArguments ();
9478 Assert.IsNull (type_args, "#A4");
9480 generic_type = tb.MakeGenericType (typeof (string), (Type) null);
9481 Assert.IsNotNull (generic_type, "#B1");
9482 Assert.IsTrue (generic_type.IsGenericType, "#B2");
9483 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B3");
9484 type_args = generic_type.GetGenericArguments ();
9485 Assert.IsNotNull (type_args, "#B4");
9486 Assert.AreEqual (2, type_args.Length, "#B5");
9487 Assert.AreEqual (typeof (string), type_args [0], "#B6");
9488 Assert.IsNull (type_args [1], "#B7");
9492 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9493 public void MakeGenericType_TypeArguments_Mismatch_Mono ()
9495 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9496 tb.DefineGenericParameters ("K", "V");
9498 tb.MakeGenericType (typeof (int));
9500 } catch (ArgumentException ex) {
9501 // The type or method has 2 generic prarameter(s)
9502 // but 1 generic argument(s) were provided. A
9503 // generic argument must be provided for each
9504 // generic parameter
9505 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9506 Assert.IsNull (ex.InnerException, "#3");
9507 Assert.IsNotNull (ex.Message, "#4");
9508 Assert.AreEqual ("typeArguments", ex.ParamName, "#5");
9513 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9514 public void MakeGenericType_TypeArguments_Mismatch_MS ()
9516 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9517 tb.DefineGenericParameters ("K", "V");
9519 Type generic_type = tb.MakeGenericType (typeof (int));
9520 Assert.IsTrue (generic_type.IsGenericType, "#1");
9521 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#2");
9522 Type [] type_args = generic_type.GetGenericArguments ();
9523 Assert.IsNotNull (type_args, "#3");
9524 Assert.AreEqual (1, type_args.Length, "#4");
9525 Assert.AreEqual (typeof (int), type_args [0], "#5");
9529 public void MakeArrayType_Complete ()
9532 TypeBuilder tb = module.DefineType (genTypeName (),
9533 TypeAttributes.Sealed | TypeAttributes.Serializable,
9534 typeof (ContextBoundObject));
9535 Type emittedType = tb.CreateType ();
9536 Type arrayType = tb.MakeArrayType ();
9537 Assert.IsTrue (arrayType.IsArray, "#A1");
9538 Assert.IsTrue (arrayType.HasElementType, "#A2");
9539 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9540 Assert.IsFalse (tb.HasElementType, "#A4");
9541 Assert.IsTrue (tb.IsCreated (), "#A5");
9544 tb = module.DefineType (genTypeName (),
9545 TypeAttributes.Sealed | TypeAttributes.Serializable,
9546 typeof (ValueType));
9547 emittedType = tb.CreateType ();
9548 arrayType = tb.MakeArrayType ();
9549 Assert.IsTrue (arrayType.IsArray, "#B1");
9550 Assert.IsTrue (arrayType.HasElementType, "#B2");
9551 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9552 Assert.IsFalse (tb.HasElementType, "#B4");
9553 Assert.IsTrue (tb.IsCreated (), "#B5");
9555 tb = module.DefineType (genTypeName (),
9556 TypeAttributes.Sealed | TypeAttributes.Serializable,
9558 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
9559 FieldAttributes.Private | FieldAttributes.RTSpecialName);
9560 emittedType = tb.CreateType ();
9561 arrayType = tb.MakeArrayType ();
9562 Assert.IsTrue (arrayType.IsArray, "#C1");
9563 Assert.IsTrue (arrayType.HasElementType, "#C2");
9564 Assert.AreEqual (tb, arrayType.GetElementType (), "#C3");
9565 Assert.IsFalse (tb.HasElementType, "#C4");
9566 Assert.IsTrue (tb.IsCreated (), "#C5");
9569 [Test] // bug #82015
9570 public void MakeArrayType_Incomplete ()
9573 TypeBuilder tb = module.DefineType (genTypeName (),
9574 TypeAttributes.Sealed | TypeAttributes.Serializable,
9575 typeof (ContextBoundObject));
9576 Type arrayType = tb.MakeArrayType ();
9577 Assert.IsTrue (arrayType.IsArray, "#A1");
9578 Assert.IsTrue (arrayType.HasElementType, "#A2");
9579 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9580 Assert.IsFalse (tb.HasElementType, "#A4");
9581 Assert.IsFalse (tb.IsCreated (), "#A5");
9584 tb = module.DefineType (genTypeName (),
9585 TypeAttributes.Sealed | TypeAttributes.Serializable,
9586 typeof (ValueType));
9587 arrayType = tb.MakeArrayType ();
9588 Assert.IsTrue (arrayType.IsArray, "#B1");
9589 Assert.IsTrue (arrayType.HasElementType, "#B2");
9590 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9591 Assert.IsFalse (tb.HasElementType, "#B4");
9592 Assert.IsFalse (tb.IsCreated (), "#B5");
9595 tb = module.DefineType (genTypeName (),
9596 TypeAttributes.Sealed | TypeAttributes.Serializable,
9598 arrayType = tb.MakeArrayType ();
9599 Assert.IsTrue (arrayType.IsArray, "#C1");
9600 Assert.IsTrue (arrayType.HasElementType, "#C2");
9601 Assert.IsFalse (tb.HasElementType, "#C3");
9602 Assert.IsFalse (tb.IsCreated (), "#C4");
9606 public void GetCustomAttributes_InflatedType ()
9608 TypeBuilder tb = module.DefineType (genTypeName ());
9609 tb.DefineGenericParameters (new string[] { "FOO" });
9611 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
9612 new Type [] { typeof (string) });
9614 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
9615 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
9617 tb.SetCustomAttribute (caBuilder);
9618 Type t = tb.CreateType ();
9620 Type inflated = t.MakeGenericType (new Type [] { typeof (int) });
9622 Assert.AreEqual (1, inflated.GetCustomAttributes (false).Length);
9626 public void GetField ()
9628 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9629 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
9631 ConstructorBuilder cb = tb.DefineDefaultConstructor (MethodAttributes.Public);
9633 FieldBuilder fb1 = tb.DefineField ("field1", typeParams [0], FieldAttributes.Public);
9635 Type t = tb.MakeGenericType (typeof (int));
9637 // Chect that calling MakeArrayType () does not initialize the class
9641 // Check that the instantiation of a type builder contains live data
9642 TypeBuilder.GetField (t, fb1);
9643 FieldBuilder fb2 = tb.DefineField ("field2", typeParams [0], FieldAttributes.Public);
9644 FieldInfo fi2 = TypeBuilder.GetField (t, fb1);
9646 MethodBuilder mb = tb.DefineMethod ("get_int", MethodAttributes.Public|MethodAttributes.Static, typeof (int), Type.EmptyTypes);
9647 ILGenerator ilgen = mb.GetILGenerator ();
9648 ilgen.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t, cb));
9649 ilgen.Emit (OpCodes.Dup);
9650 ilgen.Emit (OpCodes.Ldc_I4, 42);
9651 ilgen.Emit (OpCodes.Stfld, fi2);
9652 ilgen.Emit (OpCodes.Ldfld, fi2);
9653 ilgen.Emit (OpCodes.Ret);
9655 // Check GetField on a type instantiated with type parameters
9656 Type t3 = tb.MakeGenericType (typeParams [0]);
9657 FieldBuilder fb3 = tb.DefineField ("field3", typeParams [0], FieldAttributes.Public);
9658 FieldInfo fi3 = TypeBuilder.GetField (t3, fb3);
9660 MethodBuilder mb3 = tb.DefineMethod ("get_T", MethodAttributes.Public|MethodAttributes.Static, typeParams [0], Type.EmptyTypes);
9661 ILGenerator ilgen3 = mb3.GetILGenerator ();
9662 ilgen3.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t3, cb));
9663 ilgen3.Emit (OpCodes.Ldfld, fi3);
9664 ilgen3.Emit (OpCodes.Ret);
9666 Type created = tb.CreateType ();
9668 Type inst = created.MakeGenericType (typeof (object));
9670 Assert.AreEqual (42, inst.GetMethod ("get_int").Invoke (null, null));
9672 Assert.AreEqual (null, inst.GetMethod ("get_T").Invoke (null, null));
9675 [Test] //bug #354047
9676 public void CreatedTypeInstantiationOverTypeBuilderArgsIsNotAGenericTypeDefinition ()
9678 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9679 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9680 Type t = tb.CreateType ();
9682 Type inst = tb.MakeGenericType (typeParams [0]);
9683 Assert.IsFalse (inst.IsGenericTypeDefinition, "#1 create type instance is not a generic type definition");
9686 [Test] //bug #354047
9687 public void CreatedTypeAndTypeBuilderOwnTheirGenericArguments ()
9689 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9690 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9691 Type t = tb.CreateType ();
9693 Assert.IsTrue (tb.GetGenericArguments()[0].DeclaringType == tb, "#1 TypeBuilder owns its arguments");
9694 Assert.IsTrue (t.GetGenericArguments()[0].DeclaringType == t, "#1 create type owns its arguments");
9697 [Test] //bug #354047
9698 public void CreatedTypeAndTypeBuilderDontShareGenericArguments ()
9700 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9701 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9702 Type t = tb.CreateType ();
9704 Assert.IsTrue (tb.GetGenericArguments()[0] != t.GetGenericArguments()[0], "#1 TypeBuilder and create type arguments are diferent");
9707 [Test] //bug #399047
9708 public void FieldOnTypeBuilderInstDontInflateWhenEncoded () {
9709 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9711 module = assembly.DefineDynamicModule ("Instance.exe");
9713 TypeBuilder G = module.DefineType ("G", TypeAttributes.Public);
9714 Type T = G.DefineGenericParameters ("T") [0];
9715 ConstructorInfo ctor = G.DefineDefaultConstructor (MethodAttributes.Public);
9716 Type GObj = G.MakeGenericType (new Type [] { T });
9718 FieldBuilder F = G.DefineField ("F", T, FieldAttributes.Public);
9720 TypeBuilder P = module.DefineType ("P", TypeAttributes.Public);
9722 MethodBuilder Test = P.DefineMethod ("Test", MethodAttributes.Public);
9723 Type TATest = Test.DefineGenericParameters ("TA") [0];
9725 Type TestGObj = G.MakeGenericType (new Type [] { TATest });
9727 ILGenerator il = Test.GetILGenerator ();
9729 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (TestGObj, ctor));
9730 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (TestGObj, F));
9731 il.Emit (OpCodes.Pop);
9733 il.Emit (OpCodes.Ret);
9736 MethodBuilder main = P.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static);
9738 ILGenerator il = main.GetILGenerator ();
9739 il.Emit(OpCodes.Newobj, P.DefineDefaultConstructor (MethodAttributes.Public));
9740 il.Emit(OpCodes.Call, Test.MakeGenericMethod (typeof (int)));
9741 il.Emit (OpCodes.Ret);
9744 assembly.SetEntryPoint (main);
9748 assembly.Save ("Instance.exe");
9749 Thread.GetDomain ().ExecuteAssembly(Path.GetTempPath () + Path.DirectorySeparatorChar + "Instance.exe");
9753 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers ()
9755 TypeBuilder tb = module.DefineType ("Type1", TypeAttributes.Public);
9756 FieldBuilder fb = tb.DefineInitializedData ("Foo", new byte [] {1,2,3,4}, FieldAttributes.Static|FieldAttributes.Public);
9759 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME+"2"), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9760 module = assembly.DefineDynamicModule ("Instance.exe");
9762 TypeBuilder tb2 = module.DefineType ("Type2", TypeAttributes.Public);
9763 MethodBuilder mb = tb2.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static, typeof (object), new Type [0]);
9764 ILGenerator il = mb.GetILGenerator ();
9766 il.Emit (OpCodes.Ldc_I4_1);
9767 il.Emit (OpCodes.Newarr, typeof (int));
9768 il.Emit (OpCodes.Dup);
9769 il.Emit (OpCodes.Ldtoken, fb);
9770 il.Emit (OpCodes.Call, typeof (RuntimeHelpers).GetMethod ("InitializeArray"));
9771 il.Emit (OpCodes.Ret);
9773 Type t = tb2.CreateType ();
9774 int[] res = (int[])t.GetMethod ("Test").Invoke (null, new object[0]);
9775 //Console.WriteLine (res[0]);
9779 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers2 ()
9781 TypeBuilder tb = module.DefineType ("Type1", TypeAttributes.Public);
9782 var garg = tb.DefineGenericParameters ("T") [0];
9783 FieldBuilder fb = tb.DefineInitializedData ("Foo", new byte [] {1,2,3,4}, FieldAttributes.Static|FieldAttributes.Public);
9786 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME+"2"), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9787 module = assembly.DefineDynamicModule ("Instance.exe");
9789 TypeBuilder tb2 = module.DefineType ("Type2", TypeAttributes.Public);
9790 MethodBuilder mb = tb2.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static, typeof (object), new Type [0]);
9791 ILGenerator il = mb.GetILGenerator ();
9793 il.Emit (OpCodes.Ldc_I4_1);
9794 il.Emit (OpCodes.Newarr, typeof (int));
9795 il.Emit (OpCodes.Dup);
9796 il.Emit (OpCodes.Ldtoken, fb);
9797 il.Emit (OpCodes.Call, typeof (RuntimeHelpers).GetMethod ("InitializeArray"));
9798 il.Emit (OpCodes.Ret);
9800 Type t = tb2.CreateType ();
9801 int[] res = (int[])t.GetMethod ("Test").Invoke (null, new object[0]);
9802 //Console.WriteLine (res[0]);
9805 public interface IDelegateFactory
9807 Delegate Create (Delegate del);
9811 public void CreateType_Ctor_NoBody ()
9813 TypeBuilder tb = module.DefineType (genTypeName ());
9814 tb.DefineConstructor (MethodAttributes.Public,
9815 CallingConventions.Standard,
9816 new Type [] { typeof (string) });
9820 } catch (InvalidOperationException ex) {
9821 // Method '.ctor' does not have a method body
9822 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9823 Assert.IsNull (ex.InnerException, "#3");
9824 Assert.IsNotNull (ex.Message, "#4");
9825 Assert.IsTrue (ex.Message.IndexOf (".ctor") != -1, "#5");
9829 [Test] //bug #361689
9830 public void CreateTypeFailsWithInvalidMethodOverride ()
9832 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9834 MethodBuilder mc = tb.DefineMethod ("Create", MethodAttributes.Public, typeof (Delegate), new Type[] {typeof (Delegate)});
9835 ILGenerator gen = mc.GetILGenerator ();
9836 gen.Emit (OpCodes.Ldarg_0);
9837 gen.Emit (OpCodes.Ret);
9838 tb.DefineMethodOverride (mc, typeof (IDelegateFactory).GetMethod ("Create"));
9841 Assert.Fail ("#1 create type did not throw TypeLoadException");
9842 } catch (TypeLoadException) {
9847 [Test] //bug #349194
9848 public void IsAssignableToWorksWithInterfacesOnParent ()
9850 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9851 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Public, tb);
9853 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
9854 Type t = tb.CreateType ();
9855 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
9856 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t));
9859 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
9860 Type t2 = tb2.CreateType ();
9861 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
9862 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t2));
9866 [Test] //bug #430508
9867 public void MakeGenericTypeRespectBaseType ()
9869 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9870 EnumBuilder eb = module.DefineEnum (genTypeName (), TypeAttributes.Public, typeof (int));
9872 MethodBuilder mb = tb.DefineMethod ("Test",
9873 MethodAttributes.Public,
9874 typeof (Tuple<,>).MakeGenericType (typeof (int), eb),
9876 ILGenerator il = mb.GetILGenerator();
9877 il.Emit (OpCodes.Ldnull);
9878 il.Emit (OpCodes.Ret);
9880 Type e = eb.CreateType ();
9881 Type c = tb.CreateType ();
9883 Assert.AreEqual (c.GetMethod ("Test").ReturnType.GetGenericArguments ()[1], e, "#1");
9887 public void GetCustomAttrOnFieldOfInflatedType ()
9889 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9890 tb.DefineGenericParameters ("T");
9892 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9893 typeof (SimpleTestAttribute).GetConstructors ()[0],
9896 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
9897 field.SetCustomAttribute (caBuilder);
9899 Type t = tb.CreateType ();
9901 FieldInfo fi = t.GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9902 object[] cattrs = fi.GetCustomAttributes (false);
9903 Assert.AreEqual (1, cattrs.Length);
9905 fi = t.MakeGenericType (typeof (int)).GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9906 cattrs = fi.GetCustomAttributes (false);
9907 Assert.AreEqual (1, cattrs.Length);
9911 public void GetCustomAttrOnPropertyOfInflatedType ()
9913 TypeBuilder tb = module.DefineType (genTypeName ());
9914 tb.DefineGenericParameters ("T");
9916 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9917 typeof (SimpleTestAttribute).GetConstructors ()[0],
9920 PropertyBuilder property = DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
9921 property.SetCustomAttribute (caBuilder);
9923 Type t = tb.CreateType ();
9925 PropertyInfo pi = t.GetProperties ()[0];
9926 object[] cattrs = pi.GetCustomAttributes (false);
9927 Assert.AreEqual (1, cattrs.Length);
9929 pi = t.MakeGenericType (typeof (int)).GetProperties ()[0];
9930 cattrs = pi.GetCustomAttributes (false);
9931 Assert.AreEqual (1, cattrs.Length);
9935 public void GetCustomAttrOnEventOfInflatedType ()
9937 TypeBuilder tb = module.DefineType (genTypeName ());
9938 tb.DefineGenericParameters ("T");
9940 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9941 typeof (SimpleTestAttribute).GetConstructors ()[0],
9944 EventBuilder evt = tb.DefineEvent ("OI", 0, typeof (int));
9945 evt.SetCustomAttribute (caBuilder);
9947 Type t = tb.CreateType ();
9949 EventInfo ei = t.GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9950 object[] cattrs = ei.GetCustomAttributes (false);
9951 Assert.AreEqual (1, cattrs.Length);
9953 ei = t.MakeGenericType (typeof (int)).GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
9954 cattrs = ei.GetCustomAttributes (false);
9955 Assert.AreEqual (1, cattrs.Length);
9958 public void TestDoubleInitializationOfMonoGenericClass () //bug #400643
9960 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9961 tb.DefineGenericParameters ("T");
9963 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
9964 typeof (SimpleTestAttribute).GetConstructors ()[0],
9967 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
9968 field.SetCustomAttribute (caBuilder);
9971 tb.MakeGenericType (typeof (int)).GetMethods ();
9972 tb.MakeGenericType (typeof (double)).GetMethods ();
9974 Type t = tb.CreateType ();
9976 t.MakeGenericType (typeof (int)).GetMethods ();
9977 t.MakeGenericType (typeof (double)).GetMethods ();
9981 public void TestGenericFieldAccess () // bug #467415
9983 AssemblyName asmName = new AssemblyName("DemoMethodBuilder1");
9984 AppDomain domain = AppDomain.CurrentDomain;
9985 AssemblyBuilder demoAssembly =
9986 domain.DefineDynamicAssembly(asmName,
9987 AssemblyBuilderAccess.RunAndSave);
9989 // Define the module that contains the code. For an
9990 // assembly with one module, the module name is the
9991 // assembly name plus a file extension.
9992 ModuleBuilder demoModule =
9993 demoAssembly.DefineDynamicModule(asmName.Name,
9994 asmName.Name+".dll");
9996 TypeBuilder demoType =
9997 demoModule.DefineType("DemoType", TypeAttributes.Public);
9999 MethodBuilder factory =
10000 demoType.DefineMethod("Factory",
10001 MethodAttributes.Public | MethodAttributes.Static);
10003 string[] typeParameterNames = {"T"};
10004 GenericTypeParameterBuilder[] typeParameters =
10005 factory.DefineGenericParameters(typeParameterNames);
10007 GenericTypeParameterBuilder T = typeParameters[0];
10010 factory.SetParameters(parms);
10012 factory.SetReturnType(T);
10014 ILGenerator ilgen = factory.GetILGenerator();
10016 Type G = typeof(Gen<>);
10017 Type GT = G.MakeGenericType (T);
10018 FieldInfo GF = G.GetField("field");
10019 FieldInfo GTF = TypeBuilder.GetField(GT, GF);
10021 ilgen.Emit(OpCodes.Ldsfld, GTF);
10022 ilgen.Emit(OpCodes.Ret);
10024 // Complete the type.
10025 Type dt = demoType.CreateType();
10026 // Save the assembly, so it can be examined with Ildasm.exe.
10027 //demoAssembly.Save(asmName.Name+".dll");
10029 MethodInfo m = dt.GetMethod("Factory");
10030 MethodInfo bound = m.MakeGenericMethod(typeof(int));
10032 // Display a string representing the bound method.
10033 //Console.WriteLine(bound);
10035 object[] parameters = {};
10036 int result = (int)(bound.Invoke(null, parameters));
10038 Assert.AreEqual (0, result, "#1");
10041 static MethodInfo GetMethodByName (MethodInfo [] methods, string name)
10043 foreach (MethodInfo mi in methods)
10044 if (mi.Name == name)
10049 void CreateMembers (TypeBuilder tb, string suffix, bool defineCtors)
10051 ConstructorBuilder cb;
10053 PropertyBuilder pb;
10059 // instance constructors
10061 cb = tb.DefineConstructor (MethodAttributes.Private,
10062 CallingConventions.Standard,
10063 new Type [] { typeof (int), typeof (int) });
10064 cb.GetILGenerator ().Emit (OpCodes.Ret);
10066 cb = tb.DefineConstructor (MethodAttributes.Family,
10067 CallingConventions.Standard,
10068 new Type [] { typeof (string) });
10069 cb.GetILGenerator ().Emit (OpCodes.Ret);
10071 cb = tb.DefineConstructor (MethodAttributes.FamANDAssem,
10072 CallingConventions.Standard,
10073 new Type [] { typeof (string), typeof (string) });
10074 cb.GetILGenerator ().Emit (OpCodes.Ret);
10076 cb = tb.DefineConstructor (MethodAttributes.FamORAssem,
10077 CallingConventions.Standard,
10078 new Type [] { typeof (int) });
10079 cb.GetILGenerator ().Emit (OpCodes.Ret);
10081 cb = tb.DefineConstructor (MethodAttributes.Public,
10082 CallingConventions.Standard,
10083 new Type [] { typeof (int), typeof (bool) });
10084 cb.GetILGenerator ().Emit (OpCodes.Ret);
10086 cb = tb.DefineConstructor (MethodAttributes.Assembly,
10087 CallingConventions.Standard,
10088 new Type [] { typeof (string), typeof (int) });
10089 cb.GetILGenerator ().Emit (OpCodes.Ret);
10092 // static constructors
10095 cb = tb.DefineConstructor (MethodAttributes.Private |
10096 MethodAttributes.Static,
10097 CallingConventions.Standard,
10099 cb.GetILGenerator ().Emit (OpCodes.Ret);
10103 // instance methods
10106 mb = tb.DefineMethod ("GetPrivateInstance" + suffix,
10107 MethodAttributes.Private, typeof (void),
10109 mb.GetILGenerator ().Emit (OpCodes.Ret);
10111 mb = tb.DefineMethod ("GetFamilyInstance" + suffix,
10112 MethodAttributes.Family, typeof (void),
10114 mb.GetILGenerator ().Emit (OpCodes.Ret);
10116 mb = tb.DefineMethod ("GetFamANDAssemInstance" + suffix,
10117 MethodAttributes.FamANDAssem, typeof (void),
10119 mb.GetILGenerator ().Emit (OpCodes.Ret);
10121 mb = tb.DefineMethod ("GetFamORAssemInstance" + suffix,
10122 MethodAttributes.FamORAssem, typeof (void),
10124 mb.GetILGenerator ().Emit (OpCodes.Ret);
10126 mb = tb.DefineMethod ("GetPublicInstance" + suffix,
10127 MethodAttributes.Public, typeof (void),
10129 mb.GetILGenerator ().Emit (OpCodes.Ret);
10131 mb = tb.DefineMethod ("GetAssemblyInstance" + suffix,
10132 MethodAttributes.Assembly, typeof (void),
10134 mb.GetILGenerator ().Emit (OpCodes.Ret);
10140 mb = tb.DefineMethod ("GetPrivateStatic" + suffix,
10141 MethodAttributes.Private | MethodAttributes.Static,
10142 typeof (void), Type.EmptyTypes);
10143 mb.GetILGenerator ().Emit (OpCodes.Ret);
10145 mb = tb.DefineMethod ("GetFamilyStatic" + suffix,
10146 MethodAttributes.Family | MethodAttributes.Static,
10147 typeof (void), Type.EmptyTypes);
10148 mb.GetILGenerator ().Emit (OpCodes.Ret);
10150 mb = tb.DefineMethod ("GetFamANDAssemStatic" + suffix,
10151 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10152 typeof (void), Type.EmptyTypes);
10153 mb.GetILGenerator ().Emit (OpCodes.Ret);
10155 mb = tb.DefineMethod ("GetFamORAssemStatic" + suffix,
10156 MethodAttributes.FamORAssem | MethodAttributes.Static,
10157 typeof (void), Type.EmptyTypes);
10158 mb.GetILGenerator ().Emit (OpCodes.Ret);
10160 mb = tb.DefineMethod ("GetPublicStatic" + suffix,
10161 MethodAttributes.Public | MethodAttributes.Static,
10162 typeof (void), Type.EmptyTypes);
10163 mb.GetILGenerator ().Emit (OpCodes.Ret);
10165 mb = tb.DefineMethod ("GetAssemblyStatic" + suffix,
10166 MethodAttributes.Assembly | MethodAttributes.Static,
10167 typeof (void), Type.EmptyTypes);
10168 mb.GetILGenerator ().Emit (OpCodes.Ret);
10174 tb.DefineField ("privateInstance" + suffix,
10175 typeof (string), FieldAttributes.Private);
10176 tb.DefineField ("familyInstance" + suffix,
10177 typeof (string), FieldAttributes.Family);
10178 tb.DefineField ("famANDAssemInstance" + suffix,
10179 typeof (string), FieldAttributes.FamANDAssem);
10180 tb.DefineField ("famORAssemInstance" + suffix,
10181 typeof (string), FieldAttributes.FamORAssem);
10182 tb.DefineField ("publicInstance" + suffix,
10183 typeof (string), FieldAttributes.Public);
10184 tb.DefineField ("assemblyInstance" + suffix,
10185 typeof (string), FieldAttributes.Assembly);
10191 tb.DefineField ("privateStatic" + suffix,
10192 typeof (string), FieldAttributes.Private |
10193 FieldAttributes.Static);
10194 tb.DefineField ("familyStatic" + suffix,
10195 typeof (string), FieldAttributes.Family |
10196 FieldAttributes.Static);
10197 tb.DefineField ("famANDAssemStatic" + suffix,
10198 typeof (string), FieldAttributes.FamANDAssem |
10199 FieldAttributes.Static);
10200 tb.DefineField ("famORAssemStatic" + suffix,
10201 typeof (string), FieldAttributes.FamORAssem |
10202 FieldAttributes.Static);
10203 tb.DefineField ("publicStatic" + suffix,
10204 typeof (string), FieldAttributes.Public |
10205 FieldAttributes.Static);
10206 tb.DefineField ("assemblyStatic" + suffix,
10207 typeof (string), FieldAttributes.Assembly |
10208 FieldAttributes.Static);
10211 // instance properties
10214 pb = tb.DefineProperty ("PrivateInstance" + suffix,
10215 PropertyAttributes.None, typeof (string),
10217 mb = tb.DefineMethod ("get_PrivateInstance" + suffix,
10218 MethodAttributes.Private, typeof (string),
10220 ilgen = mb.GetILGenerator ();
10221 ilgen.Emit (OpCodes.Ldnull);
10222 ilgen.Emit (OpCodes.Ret);
10223 pb.SetGetMethod (mb);
10225 pb = tb.DefineProperty ("FamilyInstance" + suffix,
10226 PropertyAttributes.None, typeof (string),
10228 mb = tb.DefineMethod ("get_FamilyInstance" + suffix,
10229 MethodAttributes.Family, typeof (string),
10231 ilgen = mb.GetILGenerator ();
10232 ilgen.Emit (OpCodes.Ldnull);
10233 ilgen.Emit (OpCodes.Ret);
10234 pb.SetGetMethod (mb);
10236 pb = tb.DefineProperty ("FamANDAssemInstance" + suffix,
10237 PropertyAttributes.None, typeof (string),
10239 mb = tb.DefineMethod ("get_FamANDAssemInstance" + suffix,
10240 MethodAttributes.FamANDAssem, typeof (string),
10242 ilgen = mb.GetILGenerator ();
10243 ilgen.Emit (OpCodes.Ldnull);
10244 ilgen.Emit (OpCodes.Ret);
10245 pb.SetGetMethod (mb);
10247 pb = tb.DefineProperty ("FamORAssemInstance" + suffix,
10248 PropertyAttributes.None, typeof (string),
10250 mb = tb.DefineMethod ("get_FamORAssemInstance" + suffix,
10251 MethodAttributes.FamORAssem, typeof (string),
10253 ilgen = mb.GetILGenerator ();
10254 ilgen.Emit (OpCodes.Ldnull);
10255 ilgen.Emit (OpCodes.Ret);
10256 pb.SetGetMethod (mb);
10258 pb = tb.DefineProperty ("PublicInstance" + suffix,
10259 PropertyAttributes.None, typeof (string),
10261 mb = tb.DefineMethod ("get_PublicInstance" + suffix,
10262 MethodAttributes.Public, typeof (string),
10264 ilgen = mb.GetILGenerator ();
10265 ilgen.Emit (OpCodes.Ldnull);
10266 ilgen.Emit (OpCodes.Ret);
10267 pb.SetGetMethod (mb);
10269 pb = tb.DefineProperty ("AssemblyInstance" + suffix,
10270 PropertyAttributes.None, typeof (string),
10272 mb = tb.DefineMethod ("get_AssemblyInstance" + suffix,
10273 MethodAttributes.Assembly, typeof (string),
10275 ilgen = mb.GetILGenerator ();
10276 ilgen.Emit (OpCodes.Ldnull);
10277 ilgen.Emit (OpCodes.Ret);
10278 pb.SetGetMethod (mb);
10281 // static properties
10284 pb = tb.DefineProperty ("PrivateStatic" + suffix,
10285 PropertyAttributes.None, typeof (string),
10287 mb = tb.DefineMethod ("get_PrivateStatic" + suffix,
10288 MethodAttributes.Private | MethodAttributes.Static,
10289 typeof (string), Type.EmptyTypes);
10290 ilgen = mb.GetILGenerator ();
10291 ilgen.Emit (OpCodes.Ldnull);
10292 ilgen.Emit (OpCodes.Ret);
10293 pb.SetGetMethod (mb);
10295 pb = tb.DefineProperty ("FamilyStatic" + suffix,
10296 PropertyAttributes.None, typeof (string),
10298 mb = tb.DefineMethod ("get_FamilyStatic" + suffix,
10299 MethodAttributes.Family | MethodAttributes.Static,
10300 typeof (string), Type.EmptyTypes);
10301 ilgen = mb.GetILGenerator ();
10302 ilgen.Emit (OpCodes.Ldnull);
10303 ilgen.Emit (OpCodes.Ret);
10304 pb.SetGetMethod (mb);
10306 pb = tb.DefineProperty ("FamANDAssemStatic" + suffix,
10307 PropertyAttributes.None, typeof (string),
10309 mb = tb.DefineMethod ("get_FamANDAssemStatic" + suffix,
10310 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10311 typeof (string), Type.EmptyTypes);
10312 ilgen = mb.GetILGenerator ();
10313 ilgen.Emit (OpCodes.Ldnull);
10314 ilgen.Emit (OpCodes.Ret);
10315 pb.SetGetMethod (mb);
10317 pb = tb.DefineProperty ("FamORAssemStatic" + suffix,
10318 PropertyAttributes.None, typeof (string),
10320 mb = tb.DefineMethod ("get_FamORAssemStatic" + suffix,
10321 MethodAttributes.FamORAssem | MethodAttributes.Static,
10322 typeof (string), Type.EmptyTypes);
10323 ilgen = mb.GetILGenerator ();
10324 ilgen.Emit (OpCodes.Ldnull);
10325 ilgen.Emit (OpCodes.Ret);
10326 pb.SetGetMethod (mb);
10328 pb = tb.DefineProperty ("PublicStatic" + suffix,
10329 PropertyAttributes.None, typeof (string),
10331 mb = tb.DefineMethod ("get_PublicStatic" + suffix,
10332 MethodAttributes.Public | MethodAttributes.Static,
10333 typeof (string), Type.EmptyTypes);
10334 ilgen = mb.GetILGenerator ();
10335 ilgen.Emit (OpCodes.Ldnull);
10336 ilgen.Emit (OpCodes.Ret);
10337 pb.SetGetMethod (mb);
10339 pb = tb.DefineProperty ("AssemblyStatic" + suffix,
10340 PropertyAttributes.None, typeof (string),
10342 mb = tb.DefineMethod ("get_AssemblyStatic" + suffix,
10343 MethodAttributes.Assembly | MethodAttributes.Static,
10344 typeof (string), Type.EmptyTypes);
10345 ilgen = mb.GetILGenerator ();
10346 ilgen.Emit (OpCodes.Ldnull);
10347 ilgen.Emit (OpCodes.Ret);
10348 pb.SetGetMethod (mb);
10354 eb = tb.DefineEvent ("OnPrivateInstance" + suffix,
10355 EventAttributes.None, typeof (EventHandler));
10356 mb = tb.DefineMethod ("add_OnPrivateInstance" + suffix,
10357 MethodAttributes.Private, typeof (void),
10359 mb.GetILGenerator ().Emit (OpCodes.Ret);
10360 eb.SetAddOnMethod (mb);
10362 eb = tb.DefineEvent ("OnFamilyInstance" + suffix,
10363 EventAttributes.None, typeof (EventHandler));
10364 mb = tb.DefineMethod ("add_OnFamilyInstance" + suffix,
10365 MethodAttributes.Family, typeof (void),
10367 mb.GetILGenerator ().Emit (OpCodes.Ret);
10368 eb.SetAddOnMethod (mb);
10370 eb = tb.DefineEvent ("OnFamANDAssemInstance" + suffix,
10371 EventAttributes.None, typeof (EventHandler));
10372 mb = tb.DefineMethod ("add_OnFamANDAssemInstance" + suffix,
10373 MethodAttributes.FamANDAssem, typeof (void),
10375 mb.GetILGenerator ().Emit (OpCodes.Ret);
10376 eb.SetAddOnMethod (mb);
10378 eb = tb.DefineEvent ("OnFamORAssemInstance" + suffix,
10379 EventAttributes.None, typeof (EventHandler));
10380 mb = tb.DefineMethod ("add_OnFamORAssemInstance" + suffix,
10381 MethodAttributes.FamORAssem, typeof (void),
10383 mb.GetILGenerator ().Emit (OpCodes.Ret);
10384 eb.SetAddOnMethod (mb);
10386 eb = tb.DefineEvent ("OnPublicInstance" + suffix,
10387 EventAttributes.None, typeof (EventHandler));
10388 mb = tb.DefineMethod ("add_OnPublicInstance" + suffix,
10389 MethodAttributes.Public, typeof (void),
10391 mb.GetILGenerator ().Emit (OpCodes.Ret);
10392 eb.SetAddOnMethod (mb);
10394 eb = tb.DefineEvent ("OnAssemblyInstance" + suffix,
10395 EventAttributes.None, typeof (EventHandler));
10396 mb = tb.DefineMethod ("add_OnAssemblyInstance" + suffix,
10397 MethodAttributes.Family, typeof (void),
10399 mb.GetILGenerator ().Emit (OpCodes.Ret);
10400 eb.SetAddOnMethod (mb);
10406 eb = tb.DefineEvent ("OnPrivateStatic" + suffix,
10407 EventAttributes.None, typeof (EventHandler));
10408 mb = tb.DefineMethod ("add_OnPrivateStatic" + suffix,
10409 MethodAttributes.Private | MethodAttributes.Static,
10410 typeof (void), Type.EmptyTypes);
10411 mb.GetILGenerator ().Emit (OpCodes.Ret);
10412 eb.SetAddOnMethod (mb);
10414 eb = tb.DefineEvent ("OnFamilyStatic" + suffix,
10415 EventAttributes.None, typeof (EventHandler));
10416 mb = tb.DefineMethod ("add_OnFamilyStatic" + suffix,
10417 MethodAttributes.Family | MethodAttributes.Static,
10418 typeof (void), Type.EmptyTypes);
10419 mb.GetILGenerator ().Emit (OpCodes.Ret);
10420 eb.SetAddOnMethod (mb);
10422 eb = tb.DefineEvent ("OnFamANDAssemStatic" + suffix,
10423 EventAttributes.None, typeof (EventHandler));
10424 mb = tb.DefineMethod ("add_OnFamANDAssemStatic" + suffix,
10425 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10426 typeof (void), Type.EmptyTypes);
10427 mb.GetILGenerator ().Emit (OpCodes.Ret);
10428 eb.SetAddOnMethod (mb);
10430 eb = tb.DefineEvent ("OnFamORAssemStatic" + suffix,
10431 EventAttributes.None, typeof (EventHandler));
10432 mb = tb.DefineMethod ("add_OnFamORAssemStatic" + suffix,
10433 MethodAttributes.FamORAssem | MethodAttributes.Static,
10434 typeof (void), Type.EmptyTypes);
10435 mb.GetILGenerator ().Emit (OpCodes.Ret);
10436 eb.SetAddOnMethod (mb);
10438 eb = tb.DefineEvent ("OnPublicStatic" + suffix,
10439 EventAttributes.None, typeof (EventHandler));
10440 mb = tb.DefineMethod ("add_OnPublicStatic" + suffix,
10441 MethodAttributes.Public | MethodAttributes.Static,
10442 typeof (void), Type.EmptyTypes);
10443 mb.GetILGenerator ().Emit (OpCodes.Ret);
10444 eb.SetAddOnMethod (mb);
10446 eb = tb.DefineEvent ("OnAssemblyStatic" + suffix,
10447 EventAttributes.None, typeof (EventHandler));
10448 mb = tb.DefineMethod ("add_OnAssemblyStatic" + suffix,
10449 MethodAttributes.Family | MethodAttributes.Static,
10450 typeof (void), Type.EmptyTypes);
10451 mb.GetILGenerator ().Emit (OpCodes.Ret);
10452 eb.SetAddOnMethod (mb);
10455 static TypeBuilder Resolve1_Tb;
10456 static bool Resolve1_Called;
10458 public class Lookup<T>
10460 public static Type t = typeof(T);
10463 Assembly Resolve1 (object sender, ResolveEventArgs args) {
10464 Resolve1_Called = true;
10465 Resolve1_Tb.CreateType ();
10466 return Resolve1_Tb.Assembly;
10470 public void TypeResolveGenericInstances () {
10471 // Test that TypeResolve is called for generic instances (#483852)
10472 TypeBuilder tb1 = null;
10474 AppDomain.CurrentDomain.TypeResolve += Resolve1;
10476 tb1 = module.DefineType("Foo");
10478 FieldInfo field = TypeBuilder.GetField(typeof(Lookup<>).MakeGenericType(tb1), typeof(Lookup<>).GetField("t"));
10479 TypeBuilder tb2 = module.DefineType("Bar");
10480 ConstructorBuilder cb = tb2.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
10481 ILGenerator ilgen = cb.GetILGenerator();
10483 ilgen.Emit(OpCodes.Ldarg_0);
10484 ilgen.Emit(OpCodes.Call, tb2.BaseType.GetConstructor(Type.EmptyTypes));
10486 ilgen.Emit(OpCodes.Ldsfld, field);
10487 ilgen.Emit(OpCodes.Pop);
10488 ilgen.Emit(OpCodes.Ret);
10489 Activator.CreateInstance(tb2.CreateType());
10491 Assert.IsTrue (Resolve1_Called);
10495 public void CreateConcreteTypeWithAbstractMethod ()
10497 TypeBuilder tb = module.DefineType (genTypeName ());
10498 tb.DefineMethod("method", MethodAttributes.Abstract | MethodAttributes.Public, typeof (void), Type.EmptyTypes);
10501 Assert.Fail ("#1");
10502 } catch (InvalidOperationException) {}
10506 public void ConcreteTypeDontLeakGenericParamFromItSelf ()
10508 var tb = module.DefineType (genTypeName ());
10509 var gps = tb.DefineGenericParameters ("T");
10510 var mb = tb.DefineMethod ("m", MethodAttributes.Public | MethodAttributes.Static);
10511 mb.SetParameters (gps);
10512 mb.GetILGenerator ().Emit (OpCodes.Ret);
10514 var ti = tb.CreateType ();
10515 var mi = ti.GetMethod ("m");
10516 var arg0 = mi.GetParameters () [0].ParameterType;
10518 Assert.AreNotSame (arg0, gps [0], "#1");
10522 public void ConcreteTypeDontLeakGenericParamFromMethods ()
10524 var tb = module.DefineType (genTypeName ());
10525 var mb = tb.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Static);
10526 var gps = mb.DefineGenericParameters ("T");
10527 mb.SetParameters (gps);
10528 mb.GetILGenerator ().Emit (OpCodes.Ret);
10530 var ti = tb.CreateType ();
10531 var mi = ti.GetMethod ("m");
10532 var arg0 = mi.GetParameters () [0].ParameterType;
10534 Assert.AreNotSame (arg0, gps [0], "#1");
10538 public void DeclaringMethodReturnsNull ()
10540 TypeBuilder tb = module.DefineType (genTypeName ());
10541 Assert.IsNull (tb.DeclaringMethod, null, "#1");
10545 public void GenericParameterPositionReturns0 ()
10547 TypeBuilder tb = module.DefineType (genTypeName ());
10548 Assert.AreEqual (0, tb.GenericParameterPosition, "#1");
10552 public void GetGenericTypeDefinitionBehavior ()
10554 TypeBuilder tb = module.DefineType (genTypeName ());
10556 tb.GetGenericTypeDefinition ();
10557 Assert.Fail ("#1");
10558 } catch (InvalidOperationException) {}
10560 tb.DefineGenericParameters ("T");
10561 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#2");
10564 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#3");
10568 public void GetElementTypeNotSupported ()
10570 TypeBuilder tb = module.DefineType (genTypeName ());
10572 tb.GetElementType ();
10573 Assert.Fail ("#1");
10574 } catch (NotSupportedException) {}
10578 public void GenericParameterAttributesReturnsNone ()
10580 TypeBuilder tb = module.DefineType (genTypeName ());
10581 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#1");
10583 tb.DefineGenericParameters ("T");
10584 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#2");
10587 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#3");
10591 public void GetGenericArgumentsReturnsNullForNonGenericTypeBuilder ()
10593 TypeBuilder tb = module.DefineType (genTypeName ());
10594 Assert.IsNull (tb.GetGenericArguments (), "#1");
10597 public interface IFaceA {}
10598 public interface IFaceB : IFaceA {}
10600 public void GetInterfacesAfterCreate ()
10602 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type[] { typeof (IFaceB) });
10604 Type[] ifaces = tb.GetInterfaces ();
10605 Assert.AreEqual (1, ifaces.Length, "#1");
10606 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#2");
10609 ifaces = tb.GetInterfaces ();
10610 Assert.AreEqual (2, ifaces.Length, "#3");
10611 //Interfaces can come in any particular order
10612 if (ifaces [0] == typeof (IFaceB)) {
10613 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#4");
10614 Assert.AreEqual (typeof (IFaceA), ifaces [1], "#5");
10616 Assert.AreEqual (typeof (IFaceB), ifaces [1], "#4");
10617 Assert.AreEqual (typeof (IFaceA), ifaces [0], "#5");
10621 public interface MB_Iface
10626 public class MB_Impl : MB_Iface
10628 public virtual int Test () { return 1; }
10631 public void MethodOverrideBodyMustBelongToTypeBuilder ()
10633 TypeBuilder tb = module.DefineType (genTypeName ());
10634 MethodInfo md = typeof (MB_Iface).GetMethod("Test");
10635 MethodInfo md2 = typeof (MB_Impl).GetMethod("Test");
10637 tb.DefineMethodOverride (md, md2);
10638 Assert.Fail ("#1");
10639 } catch (ArgumentException) {}
10643 public void GetConstructorsThrowWhenIncomplete ()
10645 TypeBuilder tb = module.DefineType (genTypeName ());
10647 tb.GetConstructors (BindingFlags.Instance);
10648 Assert.Fail ("#1");
10649 } catch (NotSupportedException) { }
10652 Assert.IsNotNull (tb.GetConstructors (BindingFlags.Instance), "#2");
10656 public void GetEventsThrowWhenIncomplete ()
10658 TypeBuilder tb = module.DefineType (genTypeName ());
10660 tb.GetEvents (BindingFlags.Instance);
10661 Assert.Fail ("#1");
10662 } catch (NotSupportedException) { }
10665 Assert.IsNotNull (tb.GetEvents (BindingFlags.Instance), "#2");
10669 public void GetNestedTypeCreatedAfterTypeIsCreated ()
10671 TypeBuilder tb = module.DefineType (genTypeName ());
10672 TypeBuilder nested = tb.DefineNestedType ("Bar", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10674 Assert.IsNull (tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#1");
10675 Type res = nested.CreateType ();
10676 Assert.AreEqual (res, tb.GetNestedType ("Bar", BindingFlags.NonPublic), "#2");
10678 TypeBuilder nested2 = tb.DefineNestedType ("Bar2", TypeAttributes.Class | TypeAttributes.NestedPrivate);
10679 Assert.IsNull (tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#3");
10680 res = nested2.CreateType ();
10681 Assert.AreEqual (res, tb.GetNestedType ("Bar2", BindingFlags.NonPublic), "#4");
10686 public void IsDefinedThrowWhenIncomplete ()
10688 TypeBuilder tb = module.DefineType (genTypeName ());
10690 tb.IsDefined (typeof (string), true);
10691 Assert.Fail ("#1");
10692 } catch (NotSupportedException) { }
10695 Assert.IsNotNull (tb.IsDefined (typeof (string), true), "#2");
10698 [Test] //Bug #594728
10699 public void IsSubclassOfWorksIfSetParentIsCalledOnParent ()
10701 var tb_a = module.DefineType ("A", TypeAttributes.Public);
10702 var tb_b = module.DefineType ("B", TypeAttributes.Public);
10704 tb_b.SetParent (tb_a);
10705 tb_a.SetParent (typeof (Attribute));
10707 Assert.IsTrue (tb_b.IsSubclassOf (tb_a), "#1");
10708 Assert.IsTrue (tb_b.IsSubclassOf (typeof (Attribute)), "#2");
10709 Assert.IsFalse (tb_a.IsSubclassOf (tb_b), "#3");
10712 var a = tb_a.CreateType ();
10713 var b = tb_b.CreateType ();
10715 Assert.IsTrue (b.IsSubclassOf (a), "#4");
10716 Assert.IsTrue (b.IsSubclassOf (typeof (Attribute)), "#5");
10717 Assert.IsFalse (a.IsSubclassOf (b), "#6");
10721 public void DefinedDefaultConstructorWorksWithGenericBaseType ()
10723 AssemblyName assemblyName = new AssemblyName ("a");
10724 AssemblyBuilder ass = AppDomain.CurrentDomain.DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.RunAndSave);
10725 var mb = ass.DefineDynamicModule ("a.dll");
10727 var tb = mb.DefineType ("Base");
10728 tb.DefineGenericParameters ("F");
10730 var inst = tb.MakeGenericType (typeof (int));
10731 var tb2 = mb.DefineType ("Child", TypeAttributes.Public, inst);
10734 var res = tb2.CreateType ();
10736 Assert.IsNotNull (res, "#1");
10737 Assert.AreEqual (1, res.GetConstructors ().Length, "#2");
10741 * Tests for passing user types to Ref.Emit. Currently these only test
10742 * whenever the runtime code can handle them without crashing, since we
10743 * don't support user types yet.
10744 * These tests are disabled for windows since the MS runtime trips on them.
10747 [Category ("NotDotNet")] //Proper UT handling is a mono extension to SRE bugginess
10748 public void UserTypes () {
10749 TypeDelegator t = new TypeDelegator (typeof (int));
10753 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, t);
10759 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { t });
10766 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10767 tb.DefineField ("Foo", t, FieldAttributes.Public);
10773 /* Custom modifiers on fields */
10774 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10775 tb.DefineField ("Foo", typeof (int), new Type [] { t }, new Type [] { t }, FieldAttributes.Public);
10779 /* this is mono only
10781 UnmanagedMarshal m = UnmanagedMarshal.DefineCustom (t, "foo", "bar", Guid.Empty);
10782 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10783 FieldBuilder fb = tb.DefineField ("Foo", typeof (int), FieldAttributes.Public);
10791 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10792 tb.DefineProperty ("Foo", PropertyAttributes.None, t, null);
10798 /* Custom modifiers on properties */
10799 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10800 // FIXME: These seems to be ignored
10801 tb.DefineProperty ("Foo", PropertyAttributes.None, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10807 /* Method return types */
10808 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10809 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, t, null);
10810 mb.GetILGenerator ().Emit (OpCodes.Ret);
10816 /* Custom modifiers on method return types */
10817 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10818 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10819 mb.GetILGenerator ().Emit (OpCodes.Ret);
10825 /* Method parameters */
10826 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10827 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, typeof (int), new Type [] { t });
10828 mb.GetILGenerator ().Emit (OpCodes.Ret);
10834 /* Custom modifiers on method parameters */
10835 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10836 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 }});
10837 mb.GetILGenerator ().Emit (OpCodes.Ret);
10843 /* Ctor parameters */
10844 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10845 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { t });
10846 mb.GetILGenerator ().Emit (OpCodes.Ret);
10852 /* Custom modifiers on ctor parameters */
10853 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10854 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { typeof (int) }, new Type [][] { new Type [] { t }}, new Type[][] { new Type [] { t }});
10855 mb.GetILGenerator ().Emit (OpCodes.Ret);
10861 /* SignatureHelper arguments */
10862 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10863 sighelper.AddArgument (t, false);
10864 byte[] arr = sighelper.GetSignature ();
10869 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10870 sighelper.AddArgument (t, false);
10871 byte[] arr = sighelper.GetSignature ();
10876 /* Custom modifiers on SignatureHelper arguments */
10877 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10878 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10879 byte[] arr = sighelper.GetSignature ();
10884 /* Custom modifiers on SignatureHelper arguments */
10885 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10886 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10887 byte[] arr = sighelper.GetSignature ();
10891 /* Arguments to ILGenerator methods */
10894 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10895 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10896 ILGenerator ig = mb.GetILGenerator ();
10897 ig.Emit (OpCodes.Ldnull);
10898 ig.Emit (OpCodes.Castclass, t);
10899 ig.Emit (OpCodes.Pop);
10900 ig.Emit (OpCodes.Ret);
10906 /* DeclareLocal () */
10907 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10908 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10909 ILGenerator ig = mb.GetILGenerator ();
10910 ig.DeclareLocal (t);
10911 ig.Emit (OpCodes.Ret);
10917 /* BeginExceptionCatchBlock () */
10918 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10919 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10920 ILGenerator ig = mb.GetILGenerator ();
10921 ig.BeginExceptionBlock ();
10922 ig.BeginCatchBlock (t);
10923 ig.Emit (OpCodes.Ret);
10930 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10931 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10932 ILGenerator ig = mb.GetILGenerator ();
10933 ig.EmitCalli (OpCodes.Call, CallingConventions.Standard, typeof (void), new Type [] { t }, null);
10934 ig.Emit (OpCodes.Ret);
10942 [Category ("MobileNotWorking")] // Mono.CompilerServices.SymbolWriter not available in XA
10943 public void CircularArrayType()
10945 var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess.RunAndSave);
10946 var moduleBuilder = assemblyBuilder.DefineDynamicModule("Test", "Test.dll", true);
10947 var typeBuilder = moduleBuilder.DefineType("Foo", TypeAttributes.Public);
10948 var fieldBuilder = typeBuilder.DefineField("Foos", typeBuilder.MakeArrayType(), FieldAttributes.Public);
10950 var fooType = typeBuilder.CreateType();
10951 Assert.AreSame(fooType.MakeArrayType(), fooType.GetField("Foos").FieldType);
10955 [Test] //Test for #422113
10956 [ExpectedException (typeof (TypeLoadException))]
10957 public void CreateInstanceOfIncompleteType ()
10959 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class, null, new Type[] { typeof (IComparable) });
10960 Type proxyType = tb.CreateType();
10961 Activator.CreateInstance(proxyType);
10964 [Test] //Test for #640780
10965 public void StaticMethodNotUsedInIfaceVtable ()
10967 TypeBuilder tb1 = module.DefineType("Interface", TypeAttributes.Interface | TypeAttributes.Abstract);
10968 tb1.DefineTypeInitializer().GetILGenerator().Emit(OpCodes.Ret);
10969 tb1.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Abstract);
10972 TypeBuilder tb2 = module.DefineType("Class", TypeAttributes.Sealed);
10973 tb2.AddInterfaceImplementation(tb1);
10974 tb2.DefineMethod("m", MethodAttributes.Public | MethodAttributes.Virtual)
10975 .GetILGenerator().Emit(OpCodes.Ret);
10976 tb2.DefineDefaultConstructor(MethodAttributes.Public);
10978 Activator.CreateInstance(tb2.CreateType());
10981 [Test] //Test for #648391
10982 public void GetConstructorCheckCtorDeclaringType ()
10984 TypeBuilder myType = module.DefineType ("Sample", TypeAttributes.Public);
10985 string[] typeParamNames = { "TFirst" };
10986 GenericTypeParameterBuilder[] typeParams = myType.DefineGenericParameters (typeParamNames);
10987 var ctor = myType.DefineDefaultConstructor (MethodAttributes.Public);
10988 var ctori = TypeBuilder.GetConstructor (myType.MakeGenericType (typeof (int)), ctor);
10990 TypeBuilder.GetConstructor (myType.MakeGenericType (typeof (bool)), ctori);
10991 Assert.Fail ("#1");
10992 } catch (ArgumentException) {
10997 [Test] //Test for #649237
10998 public void GetFieldCheckFieldDeclaringType () {
10999 TypeBuilder myType = module.DefineType ("Sample", TypeAttributes.Public);
11000 myType.DefineGenericParameters ( "TFirst");
11001 TypeBuilder otherType = module.DefineType ("Sample2", TypeAttributes.Public);
11002 otherType.DefineGenericParameters ( "TFirst");
11004 var field = myType.DefineField ("field", typeof (object), FieldAttributes.Public);
11007 TypeBuilder.GetField (otherType.MakeGenericType (typeof (int)), field);
11008 Assert.Fail ("#1");
11009 } catch (ArgumentException) {
11015 public void TypeWithFieldRVAWorksUnderSgen () {
11016 AssemblyName an = new AssemblyName("MAIN");
11017 AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(an,
11018 AssemblyBuilderAccess.Run, ".");
11019 ModuleBuilder mob = ab.DefineDynamicModule("MAIN");
11020 TypeBuilder tb = mob.DefineType("MAIN", TypeAttributes.Public |
11021 TypeAttributes.Sealed | TypeAttributes.Abstract |
11022 TypeAttributes.Class | TypeAttributes.BeforeFieldInit);
11024 byte[] source = new byte[] { 42 };
11025 FieldBuilder fb = tb.DefineInitializedData("A0", source, 0);
11027 MethodBuilder mb = tb.DefineMethod("EVAL", MethodAttributes.Static |
11028 MethodAttributes.Public, typeof(byte[]), new Type[] { });
11029 ILGenerator il = mb.GetILGenerator();
11031 il.Emit(OpCodes.Ldc_I4_1);
11032 il.Emit(OpCodes.Newarr, typeof(byte));
11033 il.Emit(OpCodes.Dup);
11034 il.Emit(OpCodes.Ldtoken, fb);
11035 il.Emit(OpCodes.Call, typeof(RuntimeHelpers).GetMethod("InitializeArray"));
11036 il.Emit(OpCodes.Ret);
11038 Type t = tb.CreateType();
11042 byte[] res = (byte[]) t.InvokeMember("EVAL", BindingFlags.Public |
11043 BindingFlags.Static | BindingFlags.InvokeMethod, null, null,
11046 Assert.AreEqual (42, res[0]);
11051 public void Ldfld_Regress_9531 () {
11052 Build<Example<int>> ();
11056 var base_class = typeof(T);
11058 var builder = module.DefineType(genTypeName (),
11059 TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
11062 var field = builder.BaseType.GetField("Field", BindingFlags.Instance | BindingFlags.Public);
11064 var cb = builder.DefineConstructor(
11065 MethodAttributes.Public | MethodAttributes.SpecialName,
11066 CallingConventions.HasThis,
11067 new[] { typeof(string) });
11069 var il = cb.GetILGenerator();
11073 throw new InvalidOperationException("wtf");
11076 il.Emit(OpCodes.Ldarg_0);
11077 il.Emit(OpCodes.Ldarg_1);
11078 il.Emit(OpCodes.Stfld, field);
11079 il.Emit(OpCodes.Ret);
11081 builder.CreateType();
11084 public class Example<T> {
11085 public string Field;
11090 [Category ("AndroidNotWorking")]
11091 // It's not possible to save the assembly in the current directory on Android and AssemblyBuilder.DefineDynamicModule will not
11092 // allow a full path to the assembly to be passed to it. Trying to change the current directory before saving will not work either as
11093 // FileStream will then prepend / to the file name (perhaps it's another bug) and write access to the filesystem root is, obviously, denied
11094 public void Ldfld_Encoding_10122 () {
11095 Build2<Example<int>> ();
11098 void Build2<T> () {
11099 var base_class = typeof(T);
11101 string AssemblyName = genTypeName ();
11102 string AssemblyFileName = AssemblyName + ".dll";
11104 var assemblyBuilderAccess = AssemblyBuilderAccess.Save;
11105 var assemblyName = new AssemblyName(AssemblyName);
11106 var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, assemblyBuilderAccess);
11107 var moduleBuilder = assemblyBuilder.DefineDynamicModule(AssemblyName, AssemblyFileName);
11110 var builder = moduleBuilder.DefineType("Wrapped",
11111 TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
11114 var field = builder.BaseType.GetField("Field", BindingFlags.Instance | BindingFlags.Public);
11116 var cb = builder.DefineConstructor(
11117 MethodAttributes.Public | MethodAttributes.SpecialName,
11118 CallingConventions.HasThis,
11119 new[] { typeof(string) });
11121 var il = cb.GetILGenerator();
11125 throw new InvalidOperationException("wtf");
11128 il.Emit(OpCodes.Ldarg_0);
11129 il.Emit(OpCodes.Ldarg_1);
11130 il.Emit(OpCodes.Stfld, field);
11131 il.Emit(OpCodes.Ret);
11133 builder.CreateType();
11135 assemblyBuilder.Save (AssemblyFileName);
11137 var fromDisk = Assembly.Load (AssemblyName);
11138 Console.WriteLine (fromDisk);
11139 var t = fromDisk.GetType ("Wrapped");
11140 Activator.CreateInstance (t, new object[] { "string"});
11143 public interface IFace16096 {
11148 public void MemberRef_Caching_16096 () {
11149 var outer_class = module.DefineType(
11151 TypeAttributes.Class | TypeAttributes.Public,
11154 var builder = outer_class.DefineNestedType(
11156 TypeAttributes.Class | TypeAttributes.Public,
11159 builder.AddInterfaceImplementation (typeof (IFace16096));
11161 var ctor = builder.DefineDefaultConstructor (MethodAttributes.Public);
11162 var field = builder.DefineField ("Field", typeof (object), FieldAttributes.Public);
11163 var g_args = builder.DefineGenericParameters("b","a");
11164 var method = builder.DefineMethod ("Bar", MethodAttributes.Public | MethodAttributes.Virtual, typeof (object), new Type [0]);
11166 var il = method.GetILGenerator();
11167 il.Emit (OpCodes.Ldarg_0);
11168 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (builder.MakeGenericType (g_args), field));
11169 il.Emit (OpCodes.Pop);
11170 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (builder.MakeGenericType (g_args), ctor));
11171 il.Emit (OpCodes.Ret);
11173 var type = builder.CreateType ();
11175 /*Build a gshared instance. */
11176 var ginst = type.MakeGenericType (typeof (List<char>), typeof (object));
11177 var ins = (IFace16096)Activator.CreateInstance (ginst);
11179 /* This will trigger the runtime to cache the MEMBER_REF to the .ctor as it won't have a context. */
11180 var ins2 = ins.Bar ();
11181 Assert.IsNotNull (ins2);
11183 /* Build an unsharable version. */
11184 var ginst2 = type.MakeGenericType (typeof (List<char>), typeof (char));
11185 var ins3 = (IFace16096)Activator.CreateInstance (ginst2);
11187 /* This will trigger the runtime to use the cached version, which is wrong as it's an open type. */
11188 var ins4 = ins3.Bar ();
11189 Assert.IsNotNull (ins4);
11194 [ExpectedException (typeof (TypeLoadException))]
11195 public void PrivateIface ()
11197 TypeBuilder tb = module.DefineType ("Sample", TypeAttributes.Public, typeof (object), new[] { typeof (IFoo) });
11205 public void GenericFieldInCreatedType () {
11207 * Regression test for #47867.
11208 * We construct the following, but only call CreateType on R.
11210 * public class S<T> {
11214 * public static S<R> sr;
11217 var aname = new AssemblyName ("example1");
11218 var ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Run);
11219 var mb = ab.DefineDynamicModule (aname.Name);
11220 var tbS = mb.DefineType ("S", TypeAttributes.Public);
11221 tbS.DefineGenericParameters (new String [] { "T" });
11222 var tbR = mb.DefineType ("R", TypeAttributes.Public);
11223 tbR.DefineField ("sr", tbS.MakeGenericType(new Type[] { tbR }), FieldAttributes.Public | FieldAttributes.Static);
11225 Type r = tbR.CreateType ();
11227 Assert.IsNotNull (r);
11231 public void GenericFieldInCreatedTypeIncompleteTypeTLE () {
11233 * Regression test for #47867.
11234 * We construct the following, but only call CreateType on R.
11235 * Then we try to use R.sr which is expected throw a
11236 * TLE because S hasn't been created yet.
11238 * public class S<T> {
11242 * public static S<R> sr;
11245 var aname = new AssemblyName ("example1");
11246 var ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Run);
11247 var mb = ab.DefineDynamicModule (aname.Name);
11248 var tbS = mb.DefineType ("S", TypeAttributes.Public);
11249 tbS.DefineGenericParameters (new String [] { "T" });
11250 var tbR = mb.DefineType ("R", TypeAttributes.Public);
11251 tbR.DefineField ("sr", tbS.MakeGenericType(new Type[] { tbR }), FieldAttributes.Public | FieldAttributes.Static);
11253 Type r = tbR.CreateType ();
11255 Assert.IsNotNull (r);
11257 // N.B. tbS has not had CreateType called yet, so expect this to fail.
11258 Assert.Throws<TypeLoadException> (delegate { var ft = r.GetField("sr").FieldType; });
11262 public void GetGenericTypeDefinitionAfterCreateReturnsBuilder () {
11263 var aname = new AssemblyName ("genericDefnAfterCreate");
11264 var ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Run);
11265 var mb = ab.DefineDynamicModule (aname.Name);
11266 var buildX = mb.DefineType ("X", TypeAttributes.Public);
11267 buildX.DefineGenericParameters ("T", "U");
11268 var x = buildX.CreateType ();
11269 var inst = x.MakeGenericType (typeof (string), typeof (int));
11270 var defX = inst.GetGenericTypeDefinition ();
11272 Assert.AreSame (buildX, defX);