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;
29 using System.Collections.Generic;
32 namespace MonoTests.System.Reflection.Emit
34 public interface EmptyInterface
38 public interface OneMethodInterface
43 public class SimpleTestAttribute : Attribute
46 public class EmptyIfaceImpl : EmptyInterface
52 public static T field = default(T);
57 public class TypeBuilderTest
59 private interface AnInterface
67 public interface Bar : Foo
71 public interface Baz : Bar
75 public interface IMoveable
79 public interface IThrowable : IMoveable
83 public interface ILiquid
87 public interface IWater : ILiquid
95 public interface IDestroyable
100 public class Tuple <A,B> {
106 private AssemblyBuilder assembly;
108 private ModuleBuilder module;
110 static string ASSEMBLY_NAME = "MonoTests.System.Reflection.Emit.TypeBuilderTest";
113 protected void SetUp ()
115 AssemblyName assemblyName = new AssemblyName ();
116 assemblyName.Name = ASSEMBLY_NAME;
119 Thread.GetDomain ().DefineDynamicAssembly (
120 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
122 module = assembly.DefineDynamicModule ("module1");
125 static int typeIndexer = 0;
127 // Return a unique type name
128 private string genTypeName ()
130 return "t" + (typeIndexer++);
133 private string nullName ()
135 return String.Format ("{0}", (char) 0);
139 public void TestAssembly ()
141 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
142 Assert.AreEqual (assembly, tb.Assembly);
146 public void TestAssemblyQualifiedName ()
148 TypeBuilder tb = module.DefineType ("A.B.C.D", TypeAttributes.Public);
149 Assert.AreEqual ("A.B.C.D, " + assembly.GetName ().FullName,
150 tb.AssemblyQualifiedName);
154 public void TestAttributes ()
156 TypeAttributes attrs = TypeAttributes.Public | TypeAttributes.BeforeFieldInit;
157 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
158 Assert.AreEqual (attrs, tb.Attributes);
162 public void TestBaseTypeClass ()
164 TypeAttributes attrs = TypeAttributes.Public;
165 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
166 Assert.AreEqual (typeof (object), tb.BaseType, "#1");
168 TypeBuilder tb2 = module.DefineType (genTypeName (), attrs, tb);
169 Assert.AreEqual (tb, tb2.BaseType, "#2");
173 public void TestBaseTypeInterface ()
175 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
176 Assert.IsNull (tb3.BaseType);
180 public void TestDeclaringType ()
182 TypeAttributes attrs = 0;
183 TypeBuilder tb = module.DefineType (genTypeName (), attrs);
184 Assert.IsNull (tb.DeclaringType, "#1");
186 attrs = TypeAttributes.NestedPublic;
187 TypeBuilder tb2 = tb.DefineNestedType (genTypeName (), attrs);
188 TypeBuilder tb3 = tb2.DefineNestedType (genTypeName (), attrs);
189 Assert.AreEqual (tb3.DeclaringType.DeclaringType, tb, "#2");
193 public void TestFullName ()
195 string name = genTypeName ();
196 TypeAttributes attrs = 0;
197 TypeBuilder tb = module.DefineType (name, attrs);
198 Assert.AreEqual (name, tb.FullName, "#1");
200 string name2 = genTypeName ();
201 attrs = TypeAttributes.NestedPublic;
202 TypeBuilder tb2 = tb.DefineNestedType (name2, attrs);
204 string name3 = genTypeName ();
205 attrs = TypeAttributes.NestedPublic;
206 TypeBuilder tb3 = tb2.DefineNestedType (name3, attrs);
208 Assert.AreEqual (name + "+" + name2 + "+" + name3, tb3.FullName, "#2");
212 public void DefineCtorUsingDefineMethod ()
214 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Class);
215 MethodBuilder mb = tb.DefineMethod(
216 ".ctor", MethodAttributes.Public | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName,
218 ILGenerator ilgen = mb.GetILGenerator();
219 ilgen.Emit(OpCodes.Ldarg_0);
220 ilgen.Emit(OpCodes.Call,
221 typeof(object).GetConstructor(Type.EmptyTypes));
222 ilgen.Emit(OpCodes.Ret);
223 Type t = tb.CreateType();
225 Assert.AreEqual (1, t.GetConstructors ().Length);
229 public void TestGUIDIncomplete ()
231 TypeBuilder tb = module.DefineType (genTypeName ());
235 } catch (NotSupportedException ex) {
236 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
237 Assert.IsNull (ex.InnerException, "#3");
238 Assert.IsNotNull (ex.Message, "#4");
243 [Category ("NotWorking")]
244 public void TestGUIDComplete ()
246 TypeBuilder tb = module.DefineType (genTypeName ());
248 Assert.IsTrue (tb.GUID != Guid.Empty);
252 [Category ("NotWorking")]
253 public void TestFixedGUIDComplete ()
255 TypeBuilder tb = module.DefineType (genTypeName ());
257 Guid guid = Guid.NewGuid ();
259 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
260 new Type [] { typeof (string) });
262 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
263 new object [] { guid.ToString ("D") }, new FieldInfo [0], new object [0]);
265 tb.SetCustomAttribute (caBuilder);
267 Assert.AreEqual (guid, tb.GUID);
271 public void TestHasElementType_Incomplete ()
273 // According to the MSDN docs, this member works, but in reality, it
274 // returns a NotSupportedException
275 TypeBuilder tb = module.DefineType (genTypeName ());
277 Assert.IsFalse (tb.HasElementType);
280 bool b = tb.HasElementType;
281 Assert.Fail ("#1: " + b);
282 } catch (NotSupportedException ex) {
283 // The invoked member is not supported in a
285 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
286 Assert.IsNull (ex.InnerException, "#3");
287 Assert.IsNotNull (ex.Message, "#4");
294 [Category ("NotWorking")]
296 public void TestHasElementType_Complete ()
298 // According to the MSDN docs, this member works, but in reality, it
299 // returns a NotSupportedException
300 TypeBuilder tb = module.DefineType (genTypeName ());
303 Assert.IsFalse (tb.HasElementType);
306 bool b = tb.HasElementType;
307 Assert.Fail ("#1: " + b);
308 } catch (NotSupportedException ex) {
309 // The invoked member is not supported in a
311 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
312 Assert.IsNull (ex.InnerException, "#3");
313 Assert.IsNotNull (ex.Message, "#4");
318 [Test] // bug #324692
319 public void CreateType_Enum_NoInstanceField ()
321 TypeBuilder tb = module.DefineType (genTypeName (),
322 TypeAttributes.Sealed | TypeAttributes.Serializable,
327 Assert.Fail ("#1: must throw TypeLoadException");
328 } catch (TypeLoadException) {
332 //Assert.IsTrue (tb.IsCreated (), "#2");
336 [Test] // bug #324692
338 [Category ("NotWorking")] // we do not throw IOE when repeatedly invoking CreateType
340 public void TestCreateTypeReturnsNullOnSecondCallForBadType ()
342 TypeBuilder tb = module.DefineType (genTypeName (),
343 TypeAttributes.Sealed | TypeAttributes.Serializable,
349 } catch (TypeLoadException ex) {
350 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A2");
351 Assert.IsNull (ex.InnerException, "#A3");
352 Assert.IsNotNull (ex.Message, "#A4");
356 //Assert.IsTrue (tb.IsCreated (), "#B1");
357 Assert.IsNull (tb.CreateType (), "#B2");
358 //Assert.IsTrue (tb.IsCreated (), "#B3");
363 } catch (InvalidOperationException ex) {
364 // Unable to change after type has been created
365 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
366 Assert.IsNull (ex.InnerException, "#B3");
367 Assert.IsNotNull (ex.Message, "#B4");
373 public void TestEnumWithEmptyInterfaceBuildsOk ()
375 TypeBuilder tb = module.DefineType (genTypeName (),
376 TypeAttributes.Sealed | TypeAttributes.Serializable,
378 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
379 FieldAttributes.Private | FieldAttributes.RTSpecialName);
381 tb.AddInterfaceImplementation (typeof (EmptyInterface));
385 } catch (TypeLoadException) {
386 Assert.Fail ("#1: must build enum type ok");
390 Assert.IsTrue (tb.IsCreated (), "#2");
395 [Category ("NotWorking")]
396 public void TestEnumWithNonEmptyInterfaceBuildsFails ()
398 TypeBuilder tb = module.DefineType (genTypeName (),
399 TypeAttributes.Sealed | TypeAttributes.Serializable,
401 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
402 FieldAttributes.Private | FieldAttributes.RTSpecialName);
404 tb.AddInterfaceImplementation (typeof (OneMethodInterface));
408 Assert.Fail ("#1: type doesn't have all interface methods");
409 } catch (TypeLoadException) {
413 Assert.IsTrue (tb.IsCreated (), "#2");
418 [Category ("NotWorking")]
419 public void TestTypeDontImplementInterfaceMethodBuildsFails ()
421 TypeBuilder tb = module.DefineType (genTypeName (),
422 TypeAttributes.Sealed | TypeAttributes.Serializable,
425 tb.AddInterfaceImplementation (typeof (OneMethodInterface));
429 Assert.Fail ("#1: type doesn't have all interface methods");
430 } catch (TypeLoadException) {
434 Assert.IsTrue (tb.IsCreated (), "#2");
439 public void TestEnumWithSequentialLayoutBuildsFails ()
441 TypeBuilder tb = module.DefineType (genTypeName (),
442 TypeAttributes.Sealed | TypeAttributes.Serializable |
443 TypeAttributes.SequentialLayout, typeof (Enum));
444 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
445 FieldAttributes.Private | FieldAttributes.RTSpecialName);
449 Assert.Fail ("#1: type doesn't have all interface methods");
450 } catch (TypeLoadException) {
454 //Assert.IsTrue (tb.IsCreated (), "#2");
459 public void TestEnumWithExplicitLayoutBuildsFails ()
461 TypeBuilder tb = module.DefineType (genTypeName (),
462 TypeAttributes.Sealed | TypeAttributes.Serializable |
463 TypeAttributes.ExplicitLayout, typeof (Enum));
464 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
465 FieldAttributes.Private | FieldAttributes.RTSpecialName);
469 Assert.Fail ("#1: type doesn't have all interface methods");
470 } catch (TypeLoadException) {
474 //Assert.IsTrue (tb.IsCreated (), "#2");
479 public void TestEnumWithMethodsBuildFails ()
481 TypeBuilder tb = module.DefineType ("FooEnum7",
482 TypeAttributes.Sealed | TypeAttributes.Serializable,
484 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
485 FieldAttributes.Private | FieldAttributes.RTSpecialName);
487 MethodBuilder methodBuilder = tb.DefineMethod("mmm",
488 MethodAttributes.Public | MethodAttributes.Virtual,
492 methodBuilder.GetILGenerator().Emit(OpCodes.Ret);
495 Assert.Fail ("#1: enum has method");
496 } catch (TypeLoadException) {
500 //Assert.IsTrue (tb.IsCreated (), "#2");
505 public void TestEnumWithBadTypeValueFieldBuildFails ()
513 foreach (Type type in badTypes) {
514 TypeBuilder tb = module.DefineType (genTypeName (),
515 TypeAttributes.Sealed | TypeAttributes.Serializable,
517 tb.DefineField ("value__", type, FieldAttributes.SpecialName |
518 FieldAttributes.Private | FieldAttributes.RTSpecialName);
522 Assert.Fail ("#1: enum using bad type: " + type);
523 } catch (TypeLoadException) {
527 //Assert.IsTrue (tb.IsCreated (), "#2");
533 public void TestEnumWithGoodTypeValueFieldBuildOk ()
536 typeof (byte),typeof (sbyte),typeof (bool),
537 typeof (ushort),typeof (short),typeof (char),
538 typeof (uint),typeof (int),
539 typeof (ulong),typeof (long),
540 typeof (UIntPtr),typeof (IntPtr),
543 foreach (Type type in goodTypes) {
544 TypeBuilder tb = module.DefineType (genTypeName (),
545 TypeAttributes.Sealed | TypeAttributes.Serializable,
547 tb.DefineField ("value__", type, FieldAttributes.SpecialName |
548 FieldAttributes.Private | FieldAttributes.RTSpecialName);
552 } catch (TypeLoadException) {
553 Assert.Fail ("#1: enum using good type: " + type);
559 public void TestEnumWithMultipleValueFieldsBuildFals ()
561 TypeBuilder tb = module.DefineType (genTypeName (),
562 TypeAttributes.Sealed | TypeAttributes.Serializable,
564 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
565 FieldAttributes.Private | FieldAttributes.RTSpecialName);
566 tb.DefineField ("value2__", typeof (int), FieldAttributes.SpecialName |
567 FieldAttributes.Private | FieldAttributes.RTSpecialName);
571 Assert.Fail ("#1: invalid enum type");
572 } catch (TypeLoadException) {
576 //Assert.IsTrue (tb.IsCreated (), "#2");
581 [Category ("NotWorking")]
582 public void TestEnumWithEmptyInterfaceCanBeCasted ()
584 TypeBuilder tb = module.DefineType (genTypeName (),
585 TypeAttributes.Sealed | TypeAttributes.Serializable,
587 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
588 FieldAttributes.Private | FieldAttributes.RTSpecialName);
589 tb.AddInterfaceImplementation (typeof (EmptyInterface));
593 } catch (TypeLoadException) {
594 Assert.Fail ("#1: must build enum type ok");
598 EmptyInterface obj = (EmptyInterface) Activator.CreateInstance (tb);
599 Assert.IsNotNull (obj, "#2");
600 } catch (TypeLoadException) {
601 Assert.Fail ("#3: must cast enum to interface");
606 public void TestEnumWithValueFieldBuildOk ()
608 TypeBuilder tb = module.DefineType (genTypeName (),
609 TypeAttributes.Sealed | TypeAttributes.Serializable,
611 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
612 FieldAttributes.Private | FieldAttributes.RTSpecialName);
616 } catch (TypeLoadException) {
617 Assert.Fail ("#1: must build enum type ok");
622 public void TestIsAbstract ()
624 TypeBuilder tb = module.DefineType (genTypeName ());
625 Assert.IsFalse (tb.IsAbstract, "#1");
627 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Abstract);
628 Assert.IsTrue (tb2.IsAbstract, "#2");
632 public void TestIsAnsiClass ()
634 TypeBuilder tb = module.DefineType (genTypeName ());
635 Assert.IsTrue (tb.IsAnsiClass, "#1");
637 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.UnicodeClass);
638 Assert.IsFalse (tb2.IsAnsiClass, "#2");
642 public void TestIsArray ()
644 // How can a TypeBuilder be an array ?
645 string name = genTypeName ();
646 TypeBuilder tb = module.DefineType (name);
647 Assert.IsFalse (tb.IsArray);
651 public void TestIsAutoClass ()
653 TypeBuilder tb = module.DefineType (genTypeName ());
654 Assert.IsFalse (tb.IsAutoClass, "#1");
656 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.AutoClass);
657 Assert.IsTrue (tb2.IsAutoClass, "#2");
661 public void TestIsAutoLayout ()
663 TypeBuilder tb = module.DefineType (genTypeName ());
664 Assert.IsTrue (tb.IsAutoLayout, "#1");
666 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.ExplicitLayout);
667 Assert.IsFalse (tb2.IsAutoLayout, "#2");
671 public void TestIsByRef ()
673 // How can a TypeBuilder be ByRef ?
674 TypeBuilder tb = module.DefineType (genTypeName ());
675 Assert.IsFalse (tb.IsByRef);
679 public void TestIsClass ()
681 TypeBuilder tb = module.DefineType (genTypeName ());
682 Assert.IsTrue (tb.IsClass, "#1");
684 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
685 Assert.IsFalse (tb2.IsClass, "#2");
687 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
688 Assert.IsFalse (tb3.IsClass, "#3");
690 TypeBuilder tb4 = module.DefineType (genTypeName (), 0, typeof (Enum));
691 Assert.IsFalse (tb4.IsClass, "#4");
695 public void TestIsCOMObject ()
697 TypeBuilder tb = module.DefineType (genTypeName ());
698 Assert.IsFalse (tb.IsCOMObject, "#1");
700 tb = module.DefineType (genTypeName (), TypeAttributes.Import);
701 Assert.IsTrue (tb.IsCOMObject, "#2");
705 public void TestIsContextful ()
707 TypeBuilder tb = module.DefineType (genTypeName ());
708 Assert.IsFalse (tb.IsContextful, "#1");
710 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (ContextBoundObject));
711 Assert.IsTrue (tb2.IsContextful, "#2");
715 public void TestIsEnum ()
717 TypeBuilder tb = module.DefineType (genTypeName ());
718 Assert.IsFalse (tb.IsEnum, "#1");
720 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (ValueType));
721 Assert.IsFalse (tb2.IsEnum, "#2");
723 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (Enum));
724 Assert.IsTrue (tb3.IsEnum, "#3");
728 public void TestIsExplicitLayout ()
730 TypeBuilder tb = module.DefineType (genTypeName ());
731 Assert.IsFalse (tb.IsExplicitLayout, "#1");
733 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.ExplicitLayout);
734 Assert.IsTrue (tb2.IsExplicitLayout, "#2");
738 public void TestIsImport ()
740 TypeBuilder tb = module.DefineType (genTypeName ());
741 Assert.IsFalse (tb.IsImport, "#1");
743 tb = module.DefineType (genTypeName (), TypeAttributes.Import);
744 Assert.IsTrue (tb.IsImport, "#2");
748 public void TestIsInterface ()
750 TypeBuilder tb = module.DefineType (genTypeName ());
751 Assert.IsFalse (tb.IsInterface, "#1");
753 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
754 Assert.IsTrue (tb2.IsInterface, "#2");
756 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
757 Assert.IsFalse (tb3.IsInterface, "#3");
761 public void TestIsLayoutSequential ()
763 TypeBuilder tb = module.DefineType (genTypeName ());
764 Assert.IsFalse (tb.IsLayoutSequential, "#1");
766 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.SequentialLayout);
767 Assert.IsTrue (tb2.IsLayoutSequential, "#2");
771 public void TestIsMarshalByRef ()
773 TypeBuilder tb = module.DefineType (genTypeName ());
774 Assert.IsFalse (tb.IsMarshalByRef, "#1");
776 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (MarshalByRefObject));
777 Assert.IsTrue (tb2.IsMarshalByRef, "#2");
779 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ContextBoundObject));
780 Assert.IsTrue (tb3.IsMarshalByRef, "#3");
783 // TODO: Visibility properties
786 public void TestIsPointer ()
788 // How can this be true?
789 TypeBuilder tb = module.DefineType (genTypeName ());
790 Assert.IsFalse (tb.IsPointer);
794 public void TestIsPrimitive ()
796 TypeBuilder tb = module.DefineType ("int");
797 Assert.IsFalse (tb.IsPrimitive);
801 public void IsSealed ()
803 TypeBuilder tb = module.DefineType (genTypeName ());
804 Assert.IsFalse (tb.IsSealed, "#1");
806 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
807 Assert.IsTrue (tb2.IsSealed, "#2");
810 static string CreateTempAssembly ()
821 path = Path.Combine (Path.GetTempPath (), "tmp" + num.ToString ("x") + ".dll");
824 f = new FileStream (path, FileMode.CreateNew);
831 return "tmp" + num.ToString ("x") + ".dll";
835 public void IsSerializable ()
837 TypeBuilder tb = module.DefineType (genTypeName ());
838 Assert.IsFalse (tb.IsSerializable, "#1");
840 ConstructorInfo [] ctors = typeof (SerializableAttribute).GetConstructors (BindingFlags.Instance | BindingFlags.Public);
841 Assert.IsTrue (ctors.Length > 0, "#2");
843 tb.SetCustomAttribute (new CustomAttributeBuilder (ctors [0], new object [0]));
844 Type createdType = tb.CreateType ();
846 string an = CreateTempAssembly ();
848 Assert.IsTrue (createdType.IsSerializable, "#3");
849 File.Delete (Path.Combine (Path.GetTempPath (), an));
853 public void TestIsSpecialName ()
855 TypeBuilder tb = module.DefineType (genTypeName ());
856 Assert.IsFalse (tb.IsSpecialName, "#1");
858 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.SpecialName);
859 Assert.IsTrue (tb2.IsSpecialName, "#2");
863 public void TestIsUnicodeClass ()
865 TypeBuilder tb = module.DefineType (genTypeName ());
866 Assert.IsFalse (tb.IsUnicodeClass, "#1");
868 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.UnicodeClass);
869 Assert.IsTrue (tb2.IsUnicodeClass, "#2");
873 public void TestIsValueType ()
875 TypeBuilder tb = module.DefineType (genTypeName ());
876 Assert.IsFalse (tb.IsValueType, "#1");
878 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
879 Assert.IsFalse (tb2.IsValueType, "#2");
881 TypeBuilder tb3 = module.DefineType (genTypeName (), 0, typeof (ValueType));
882 Assert.IsTrue (tb3.IsValueType, "#3");
884 TypeBuilder tb4 = module.DefineType (genTypeName (), 0, typeof (Enum));
885 Assert.IsTrue (tb4.IsValueType, "#4");
889 public void TestMemberType ()
891 TypeBuilder tb = module.DefineType (genTypeName ());
892 Assert.AreEqual (MemberTypes.TypeInfo, tb.MemberType);
896 public void TestModule ()
898 TypeBuilder tb = module.DefineType (genTypeName ());
899 Assert.AreEqual (module, tb.Module);
903 public void TestName ()
905 TypeBuilder tb = module.DefineType ("A");
906 Assert.AreEqual ("A", tb.Name, "#1");
908 TypeBuilder tb2 = module.DefineType ("A.B.C.D.E");
909 Assert.AreEqual ("E", tb2.Name, "#2");
911 TypeBuilder tb3 = tb2.DefineNestedType ("A");
912 Assert.AreEqual ("A", tb3.Name, "#3");
914 /* Is .E a valid name ?
915 TypeBuilder tb4 = module.DefineType (".E");
916 Assert.AreEqual ("E", tb4.Name);
921 public void TestNamespace ()
923 TypeBuilder tb = module.DefineType ("A");
924 Assert.AreEqual (string.Empty, tb.Namespace, "#1");
926 TypeBuilder tb2 = module.DefineType ("A.B.C.D.E");
927 Assert.AreEqual ("A.B.C.D", tb2.Namespace, "#2");
929 TypeBuilder tb3 = tb2.DefineNestedType ("A");
930 Assert.AreEqual (string.Empty, tb3.Namespace, "#3");
932 /* Is .E a valid name ?
933 TypeBuilder tb4 = module.DefineType (".E");
934 Assert.AreEqual ("E", tb4.Name);
939 public void TestPackingSize ()
941 TypeBuilder tb = module.DefineType (genTypeName ());
942 Assert.AreEqual (PackingSize.Unspecified, tb.PackingSize, "#1");
944 TypeBuilder tb2 = module.DefineType (genTypeName (), 0, typeof (object),
945 PackingSize.Size16, 16);
946 Assert.AreEqual (PackingSize.Size16, tb2.PackingSize, "#2");
950 public void TestReflectedType ()
952 // It is the same as DeclaringType, but why?
953 TypeBuilder tb = module.DefineType (genTypeName ());
954 Assert.IsNull (tb.ReflectedType, "#1");
956 TypeBuilder tb2 = tb.DefineNestedType (genTypeName ());
957 Assert.AreEqual (tb, tb2.ReflectedType, "#2");
961 public void SetParent_Parent_Null ()
963 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class,
967 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
972 } catch (ArgumentNullException ex) {
973 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
974 Assert.IsNull (ex.InnerException, "#A3");
975 Assert.IsNotNull (ex.Message, "#A4");
976 Assert.AreEqual ("parent", ex.ParamName, "#A5");
980 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
981 TypeAttributes.Abstract);
984 Assert.IsNull (tb.BaseType, "#B1");
989 } catch (ArgumentNullException ex) {
990 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
991 Assert.IsNull (ex.InnerException, "#B3");
992 Assert.IsNotNull (ex.Message, "#B4");
993 Assert.AreEqual ("parent", ex.ParamName, "#B5");
998 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
999 TypeAttributes.Abstract, typeof (ICloneable));
1000 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#C1");
1001 tb.SetParent (null);
1002 Assert.IsNull (tb.BaseType, "#C2");
1004 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
1005 typeof (IDisposable));
1007 tb.SetParent (null);
1008 Assert.Fail ("#D1");
1009 } catch (InvalidOperationException ex) {
1010 // Interface must be declared abstract
1011 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1012 Assert.IsNull (ex.InnerException, "#D3");
1013 Assert.IsNotNull (ex.Message, "#D4");
1019 public void SetParent_Parent_Interface ()
1021 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Class);
1022 tb.SetParent (typeof (ICloneable));
1023 Assert.AreEqual (typeof (ICloneable), tb.BaseType);
1027 public void TestSetParentIncomplete ()
1029 TypeBuilder tb = module.DefineType (genTypeName ());
1030 tb.SetParent (typeof (Attribute));
1031 Assert.AreEqual (typeof (Attribute), tb.BaseType, "#1");
1033 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
1034 TypeAttributes.Abstract);
1035 tb.SetParent (typeof (IDisposable));
1036 Assert.AreEqual (typeof (IDisposable), tb.BaseType, "#2");
1038 tb = module.DefineType (genTypeName ());
1039 tb.SetParent (typeof (IDisposable));
1040 Assert.AreEqual (typeof (IDisposable), tb.BaseType, "#3");
1043 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
1044 TypeAttributes.Abstract, typeof (IDisposable));
1045 tb.SetParent (typeof (ICloneable));
1046 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#4");
1048 tb = module.DefineType (genTypeName (), TypeAttributes.Interface |
1049 TypeAttributes.Abstract, typeof (IDisposable));
1050 tb.SetParent (typeof (ICloneable));
1051 Assert.AreEqual (typeof (ICloneable), tb.BaseType, "#5");
1056 public void TestSetParentComplete ()
1058 TypeBuilder tb = module.DefineType (genTypeName ());
1061 tb.SetParent (typeof (Attribute));
1063 } catch (InvalidOperationException ex) {
1064 // Unable to change after type has been created
1065 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1066 Assert.IsNull (ex.InnerException, "#3");
1067 Assert.IsNotNull (ex.Message, "#4");
1072 public void TestSize ()
1075 TypeBuilder tb = module.DefineType (genTypeName ());
1076 Assert.AreEqual (0, tb.Size, "#1");
1078 Assert.AreEqual (0, tb.Size, "#2");
1082 TypeBuilder tb = module.DefineType (genTypeName (), 0, typeof (object),
1083 PackingSize.Size16, 32);
1084 Assert.AreEqual (32, tb.Size, "#3");
1089 public void TestTypeHandle ()
1091 TypeBuilder tb = module.DefineType (genTypeName ());
1093 RuntimeTypeHandle handle = tb.TypeHandle;
1094 Assert.Fail ("#1:" + handle);
1095 } catch (NotSupportedException ex) {
1096 // The invoked member is not supported in a
1098 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1099 Assert.IsNull (ex.InnerException, "#3");
1100 Assert.IsNotNull (ex.Message, "#4");
1105 public void TestTypeInitializerIncomplete ()
1107 TypeBuilder tb = module.DefineType (genTypeName ());
1109 ConstructorInfo cb = tb.TypeInitializer;
1110 Assert.Fail ("#1:" + (cb != null));
1111 } catch (NotSupportedException ex) {
1112 // The invoked member is not supported in a
1114 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1115 Assert.IsNull (ex.InnerException, "#3");
1116 Assert.IsNotNull (ex.Message, "#4");
1121 public void TestTypeInitializerComplete ()
1123 TypeBuilder tb = module.DefineType (genTypeName ());
1125 ConstructorInfo cb = tb.TypeInitializer;
1129 public void TestTypeToken ()
1131 TypeBuilder tb = module.DefineType (genTypeName ());
1132 TypeToken token = tb.TypeToken;
1136 public void UnderlyingSystemType ()
1141 tb = module.DefineType (genTypeName ());
1142 Assert.AreSame (tb, tb.UnderlyingSystemType, "#A1");
1143 emitted_type = tb.CreateType ();
1144 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#A2");
1146 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1147 Assert.AreSame (tb, tb.UnderlyingSystemType, "#B1");
1148 emitted_type = tb.CreateType ();
1149 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#B2");
1151 tb = module.DefineType (genTypeName (), 0, typeof (ValueType));
1152 Assert.AreSame (tb, tb.UnderlyingSystemType, "#C1");
1153 emitted_type = tb.CreateType ();
1154 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#C2");
1156 tb = module.DefineType (genTypeName (), 0, typeof (Enum));
1158 Type t = tb.UnderlyingSystemType;
1159 Assert.Fail ("#D1:" + t);
1160 } catch (InvalidOperationException ex) {
1161 // Underlying type information on enumeration
1163 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1164 Assert.IsNull (ex.InnerException, "#D3");
1165 Assert.IsNotNull (ex.Message, "#D4");
1167 tb.DefineField ("val", typeof (int), FieldAttributes.Private);
1168 Assert.AreEqual (typeof (int), tb.UnderlyingSystemType, "#D5");
1169 emitted_type = tb.CreateType ();
1170 Assert.AreSame (emitted_type, tb.UnderlyingSystemType, "#D6");
1172 tb = module.DefineType (genTypeName (), 0, typeof (Enum));
1173 tb.DefineField ("val", typeof (int), FieldAttributes.Static);
1175 Type t = tb.UnderlyingSystemType;
1176 Assert.Fail ("#E1:" + t);
1177 } catch (InvalidOperationException ex) {
1178 // Underlying type information on enumeration
1180 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1181 Assert.IsNull (ex.InnerException, "#E3");
1182 Assert.IsNotNull (ex.Message, "#E4");
1184 tb.DefineField ("foo", typeof (long), FieldAttributes.Private);
1185 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E5");
1186 tb.DefineField ("bar", typeof (short), FieldAttributes.Private);
1187 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E6");
1188 tb.DefineField ("boo", typeof (int), FieldAttributes.Static);
1189 Assert.AreEqual (typeof (long), tb.UnderlyingSystemType, "#E7");
1193 public void AddInterfaceImplementation_InterfaceType_Null ()
1195 TypeBuilder tb = module.DefineType (genTypeName ());
1197 tb.AddInterfaceImplementation (null);
1199 } catch (ArgumentNullException ex) {
1200 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1201 Assert.IsNull (ex.InnerException, "#3");
1202 Assert.IsNotNull (ex.Message, "#4");
1203 Assert.AreEqual ("interfaceType", ex.ParamName, "#5");
1208 public void TestAddInterfaceImplementation ()
1210 TypeBuilder tb = module.DefineType (genTypeName ());
1211 tb.AddInterfaceImplementation (typeof (AnInterface));
1212 tb.AddInterfaceImplementation (typeof (AnInterface));
1214 Type t = tb.CreateType ();
1215 Assert.AreEqual (1, tb.GetInterfaces ().Length, "#2");
1217 // Can not be called on a created type
1219 tb.AddInterfaceImplementation (typeof (AnInterface));
1221 } catch (InvalidOperationException) {
1227 [Category ("NotWorking")] // we allow CreateType to be invoked multiple times
1229 public void TestCreateType_Created ()
1231 TypeBuilder tb = module.DefineType (genTypeName ());
1233 Assert.IsFalse (tb.IsCreated (), "#A1");
1235 Type emittedType1 = tb.CreateType ();
1237 Assert.IsTrue (tb.IsCreated (), "#A2");
1239 Assert.IsNotNull (emittedType1, "#A3");
1242 Type emittedType2 = tb.CreateType ();
1243 Assert.IsNotNull (emittedType2, "#B1");
1244 Assert.IsTrue (tb.IsCreated (), "#B2");
1245 Assert.AreSame (emittedType1, emittedType2, "#B3");
1249 Assert.Fail ("#B1");
1250 } catch (InvalidOperationException ex) {
1251 // Unable to change after type has been created
1252 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
1253 Assert.IsNull (ex.InnerException, "#B3");
1254 Assert.IsNotNull (ex.Message, "#B4");
1260 public void TestDefineConstructor ()
1262 TypeBuilder tb = module.DefineType (genTypeName ());
1264 ConstructorBuilder cb = tb.DefineConstructor (0, 0, null);
1265 cb.GetILGenerator ().Emit (OpCodes.Ret);
1268 // Can not be called on a created type
1270 tb.DefineConstructor (0, 0, null);
1272 } catch (InvalidOperationException ex) {
1273 // Unable to change after type has been created
1274 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1275 Assert.IsNull (ex.InnerException, "#3");
1276 Assert.IsNotNull (ex.Message, "#4");
1281 public void DefineDefaultConstructor ()
1283 TypeBuilder tb = module.DefineType (genTypeName ());
1284 tb.DefineDefaultConstructor (0);
1287 // Can not be called on a created type, altough the MSDN docs does not mention this
1289 tb.DefineDefaultConstructor (0);
1291 } catch (InvalidOperationException ex) {
1292 // Unable to change after type has been created
1293 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1294 Assert.IsNull (ex.InnerException, "#3");
1295 Assert.IsNotNull (ex.Message, "#4");
1300 public void DefineDefaultConstructor_Parent_DefaultCtorInaccessible ()
1304 tb = module.DefineType (genTypeName ());
1305 tb.DefineDefaultConstructor (MethodAttributes.Private);
1306 Type parent_type = tb.CreateType ();
1308 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1310 tb.DefineDefaultConstructor (MethodAttributes.Public);
1311 Type emitted_type = tb.CreateType ();
1313 Activator.CreateInstance (emitted_type);
1315 } catch (TargetInvocationException ex) {
1316 Assert.AreEqual (typeof (TargetInvocationException), ex.GetType (), "#2");
1317 Assert.IsNotNull (ex.InnerException, "#3");
1318 Assert.IsNotNull (ex.Message, "#4");
1320 MethodAccessException mae = ex.InnerException as MethodAccessException;
1321 Assert.IsNotNull (mae, "#5");
1322 Assert.AreEqual (typeof (MethodAccessException), mae.GetType (), "#6");
1323 Assert.IsNull (mae.InnerException, "#7");
1324 Assert.IsNotNull (mae.Message, "#8");
1325 Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#9:" + mae.Message);
1326 Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#10:" + mae.Message);
1331 public void DefineDefaultConstructor_Parent_DefaultCtorMissing ()
1335 tb = module.DefineType (genTypeName ());
1336 ConstructorBuilder cb = tb.DefineConstructor (
1337 MethodAttributes.Public,
1338 CallingConventions.Standard,
1339 new Type [] { typeof (string) });
1340 cb.GetILGenerator ().Emit (OpCodes.Ret);
1341 Type parent_type = tb.CreateType ();
1343 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
1346 tb.DefineDefaultConstructor (MethodAttributes.Public);
1348 } catch (NotSupportedException ex) {
1349 // Parent does not have a default constructor.
1350 // The default constructor must be explicitly defined
1351 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
1352 Assert.IsNull (ex.InnerException, "#3");
1353 Assert.IsNotNull (ex.Message, "#4");
1358 public void DefineEvent_Name_NullChar ()
1360 TypeBuilder tb = module.DefineType (genTypeName ());
1363 tb.DefineEvent ("\0test", EventAttributes.None,
1365 Assert.Fail ("#A1");
1366 } catch (ArgumentException ex) {
1368 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1369 Assert.IsNull (ex.InnerException, "#A3");
1370 Assert.IsNotNull (ex.Message, "#A4");
1371 Assert.AreEqual ("name", ex.ParamName, "#A5");
1374 EventBuilder eb = tb.DefineEvent ("te\0st", EventAttributes.None,
1376 Assert.IsNotNull (eb, "#B1");
1380 public void TestDefineEvent ()
1382 TypeBuilder tb = module.DefineType (genTypeName ());
1384 // Test invalid arguments
1386 tb.DefineEvent (null, 0, typeof (int));
1387 Assert.Fail ("#A1");
1388 } catch (ArgumentNullException ex) {
1389 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1390 Assert.IsNull (ex.InnerException, "#A3");
1391 Assert.IsNotNull (ex.Message, "#A4");
1392 Assert.AreEqual ("name", ex.ParamName, "#A5");
1396 tb.DefineEvent ("FOO", 0, null);
1397 Assert.Fail ("#B1");
1398 } catch (ArgumentNullException ex) {
1399 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1400 Assert.IsNull (ex.InnerException, "#B3");
1401 Assert.IsNotNull (ex.Message, "#B4");
1402 Assert.AreEqual ("type", ex.ParamName, "#B5");
1406 tb.DefineEvent (string.Empty, 0, typeof (int));
1407 Assert.Fail ("#C1");
1408 } catch (ArgumentException ex) {
1409 // Empty name is not legal
1410 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1411 Assert.IsNull (ex.InnerException, "#C3");
1412 Assert.IsNotNull (ex.Message, "#C4");
1413 Assert.AreEqual ("name", ex.ParamName, "#C5");
1418 // Can not be called on a created type
1420 tb.DefineEvent ("BAR", 0, typeof (int));
1421 Assert.Fail ("#D1");
1422 } catch (InvalidOperationException ex) {
1423 // Unable to change after type has been created
1424 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1425 Assert.IsNull (ex.InnerException, "#D3");
1426 Assert.IsNotNull (ex.Message, "#D4");
1430 [Test] // DefineField (String, Type, FieldAttributes)
1431 public void DefineField1 ()
1433 TypeBuilder tb = module.DefineType (genTypeName ());
1435 // Check invalid arguments
1437 tb.DefineField (null, typeof (int), 0);
1438 Assert.Fail ("#A1");
1439 } catch (ArgumentNullException ex) {
1440 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1441 Assert.IsNull (ex.InnerException, "#A3");
1442 Assert.IsNotNull (ex.Message, "#A4");
1443 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1447 tb.DefineField (string.Empty, typeof (int), 0);
1448 Assert.Fail ("#B1");
1449 } catch (ArgumentException ex) {
1450 // Empty name is not legal
1451 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1452 Assert.IsNull (ex.InnerException, "#B3");
1453 Assert.IsNotNull (ex.Message, "#B4");
1454 Assert.AreEqual ("fieldName", ex.ParamName, "#B5");
1458 // Strangely, 'A<NULL>' is accepted...
1459 string name = String.Format ("{0}", (char) 0);
1460 tb.DefineField (name, typeof (int), 0);
1461 Assert.Fail ("#C1");
1462 } catch (ArgumentException ex) {
1464 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1465 Assert.IsNull (ex.InnerException, "#C3");
1466 Assert.IsNotNull (ex.Message, "#C4");
1467 Assert.AreEqual ("fieldName", ex.ParamName, "#C5");
1471 tb.DefineField ("A", typeof (void), 0);
1472 Assert.Fail ("#D1");
1473 } catch (ArgumentException ex) {
1474 // Bad field type in defining field
1475 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1476 Assert.IsNull (ex.InnerException, "#D3");
1477 Assert.IsNotNull (ex.Message, "#D4");
1478 Assert.IsNull (ex.ParamName, "#D5");
1483 // Can not be called on a created type
1485 tb.DefineField ("B", typeof (int), 0);
1486 Assert.Fail ("#E1");
1487 } catch (InvalidOperationException ex) {
1488 // Unable to change after type has been created
1489 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
1490 Assert.IsNull (ex.InnerException, "#E3");
1491 Assert.IsNotNull (ex.Message, "#E4");
1495 [Test] // DefineField (String, Type, FieldAttributes)
1496 public void DefineField1_Name_NullChar ()
1498 TypeBuilder tb = module.DefineType (genTypeName ());
1501 tb.DefineField ("\0test", typeof (int),
1502 FieldAttributes.Private);
1503 Assert.Fail ("#A1");
1504 } catch (ArgumentException ex) {
1506 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1507 Assert.IsNull (ex.InnerException, "#A3");
1508 Assert.IsNotNull (ex.Message, "#A4");
1509 Assert.AreEqual ("fieldName", ex.ParamName, "#A5");
1512 FieldBuilder fb = tb.DefineField ("te\0st", typeof (int),
1513 FieldAttributes.Private);
1514 Assert.IsNotNull (fb, "#B1");
1515 Assert.AreEqual ("te\0st", fb.Name, "#B2");
1518 [Test] // DefineField (String, Type, FieldAttributes)
1519 public void DefineField1_Type_Null ()
1521 TypeBuilder tb = module.DefineType (genTypeName ());
1524 tb.DefineField ("test", (Type) null,
1525 FieldAttributes.Private);
1527 } catch (ArgumentNullException ex) {
1528 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1529 Assert.IsNull (ex.InnerException, "#3");
1530 Assert.IsNotNull (ex.Message, "#4");
1531 Assert.AreEqual ("type", ex.ParamName, "#5");
1536 [Test] // DefineField (String, Type, Type [], Type [], FieldAttributes)
1537 public void DefineField2_Type_Null ()
1539 TypeBuilder tb = module.DefineType (genTypeName ());
1542 tb.DefineField ("test", (Type) null, Type.EmptyTypes,
1543 Type.EmptyTypes, FieldAttributes.Private);
1545 } catch (ArgumentNullException ex) {
1546 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1547 Assert.IsNull (ex.InnerException, "#3");
1548 Assert.IsNotNull (ex.Message, "#4");
1549 Assert.AreEqual ("type", ex.ParamName, "#5");
1555 public void TestDefineInitializedData ()
1557 TypeBuilder tb = module.DefineType (genTypeName ());
1559 // Check invalid arguments
1561 tb.DefineInitializedData (null, new byte [1], 0);
1562 Assert.Fail ("#A1");
1563 } catch (ArgumentNullException ex) {
1564 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1565 Assert.IsNull (ex.InnerException, "#A3");
1566 Assert.IsNotNull (ex.Message, "#A4");
1567 Assert.AreEqual ("name", ex.ParamName, "#A5");
1571 tb.DefineInitializedData ("FOO", null, 0);
1572 Assert.Fail ("#B1");
1573 } catch (ArgumentNullException ex) {
1574 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
1575 Assert.IsNull (ex.InnerException, "#B3");
1576 Assert.IsNotNull (ex.Message, "#B4");
1577 Assert.AreEqual ("data", ex.ParamName, "#B5");
1581 tb.DefineInitializedData (string.Empty, new byte [1], 0);
1582 Assert.Fail ("#C1");
1583 } catch (ArgumentException ex) {
1584 // Empty name is not legal
1585 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1586 Assert.IsNull (ex.InnerException, "#C3");
1587 Assert.IsNotNull (ex.Message, "#C4");
1588 Assert.AreEqual ("name", ex.ParamName, "#C5");
1591 // The size of the data is less than or equal to zero ???
1593 tb.DefineInitializedData ("BAR", new byte [0], 0);
1594 Assert.Fail ("#D1");
1595 } catch (ArgumentException ex) {
1596 // Data size must be > 0 and < 0x3f0000
1597 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1598 Assert.IsNull (ex.InnerException, "#D3");
1599 Assert.IsNotNull (ex.Message, "#D4");
1600 Assert.IsNull (ex.ParamName, "#D5");
1604 string name = String.Format ("{0}", (char) 0);
1605 tb.DefineInitializedData (name, new byte [1], 0);
1606 Assert.Fail ("#E1");
1607 } catch (ArgumentException ex) {
1609 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#E2");
1610 Assert.IsNull (ex.InnerException, "#E3");
1611 Assert.IsNotNull (ex.Message, "#E4");
1612 Assert.AreEqual ("fieldName", ex.ParamName, "#E5");
1617 // Can not be called on a created type, altough the MSDN docs does not mention this
1619 tb.DefineInitializedData ("BAR2", new byte [1], 0);
1620 Assert.Fail ("#F1");
1621 } catch (InvalidOperationException ex) {
1622 // Unable to change after type has been created
1623 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
1624 Assert.IsNull (ex.InnerException, "#F3");
1625 Assert.IsNotNull (ex.Message, "#F4");
1630 public void DefineUninitializedDataInvalidArgs ()
1632 TypeBuilder tb = module.DefineType (genTypeName ());
1635 tb.DefineUninitializedData (null, 1, 0);
1636 Assert.Fail ("#A1");
1637 } catch (ArgumentNullException ex) {
1638 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1639 Assert.IsNull (ex.InnerException, "#A3");
1640 Assert.IsNotNull (ex.Message, "#A4");
1641 Assert.AreEqual ("name", ex.ParamName, "#A5");
1645 tb.DefineUninitializedData (string.Empty, 1, 0);
1646 Assert.Fail ("#B1");
1647 } catch (ArgumentException ex) {
1648 // Empty name is not legal
1649 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1650 Assert.IsNull (ex.InnerException, "#B3");
1651 Assert.IsNotNull (ex.Message, "#B4");
1652 Assert.AreEqual ("name", ex.ParamName, "#B5");
1655 // The size of the data is less than or equal to zero ???
1657 tb.DefineUninitializedData ("BAR", 0, 0);
1658 Assert.Fail ("#C1");
1659 } catch (ArgumentException ex) {
1660 // Data size must be > 0 and < 0x3f0000
1661 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1662 Assert.IsNull (ex.InnerException, "#C3");
1663 Assert.IsNotNull (ex.Message, "#C4");
1664 Assert.IsNull (ex.ParamName, "#C5");
1668 string name = String.Format ("{0}", (char) 0);
1669 tb.DefineUninitializedData (name, 1, 0);
1670 Assert.Fail ("#D1");
1671 } catch (ArgumentException ex) {
1673 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
1674 Assert.IsNull (ex.InnerException, "#D3");
1675 Assert.IsNotNull (ex.Message, "#D4");
1676 Assert.AreEqual ("fieldName", ex.ParamName, "#D5");
1681 public void DefineUninitializedDataAlreadyCreated ()
1683 TypeBuilder tb = module.DefineType (genTypeName ());
1686 tb.DefineUninitializedData ("BAR2", 1, 0);
1688 } catch (InvalidOperationException ex) {
1689 // Unable to change after type has been created
1690 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1691 Assert.IsNull (ex.InnerException, "#3");
1692 Assert.IsNotNull (ex.Message, "#4");
1697 public void DefineUninitializedData ()
1699 TypeBuilder tb = module.DefineType (genTypeName ());
1701 tb.DefineUninitializedData ("foo", 4, FieldAttributes.Public);
1703 Type t = tb.CreateType ();
1705 object o = Activator.CreateInstance (t);
1707 FieldInfo fi = t.GetField ("foo");
1709 object fieldVal = fi.GetValue (o);
1711 IntPtr ptr = Marshal.AllocHGlobal (4);
1712 Marshal.StructureToPtr (fieldVal, ptr, true);
1713 Marshal.FreeHGlobal (ptr);
1717 public void DefineMethod_Name_NullChar ()
1719 TypeBuilder tb = module.DefineType (genTypeName ());
1721 tb.DefineMethod ("\0test", MethodAttributes.Private,
1722 typeof (string), Type.EmptyTypes);
1723 Assert.Fail ("#A1");
1724 } catch (ArgumentException ex) {
1726 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1727 Assert.IsNull (ex.InnerException, "#A3");
1728 Assert.IsNotNull (ex.Message, "#A4");
1729 Assert.AreEqual ("name", ex.ParamName, "#A5");
1732 MethodBuilder mb = tb.DefineMethod ("te\0st", MethodAttributes.Private,
1733 typeof (string), Type.EmptyTypes);
1734 Assert.IsNotNull (mb, "#B1");
1735 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1739 public void TestDefineMethod ()
1741 TypeBuilder tb = module.DefineType (genTypeName ());
1743 // Check invalid arguments
1745 tb.DefineMethod (null, 0, null, null);
1746 Assert.Fail ("#A1");
1747 } catch (ArgumentNullException ex) {
1748 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1749 Assert.IsNull (ex.InnerException, "#A3");
1750 Assert.IsNotNull (ex.Message, "#A4");
1751 Assert.AreEqual ("name", ex.ParamName, "#A5");
1755 tb.DefineMethod (string.Empty, 0, null, null);
1756 Assert.Fail ("#B1");
1757 } catch (ArgumentException ex) {
1758 // Empty name is not legal
1759 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1760 Assert.IsNull (ex.InnerException, "#B3");
1761 Assert.IsNotNull (ex.Message, "#B4");
1762 Assert.AreEqual ("name", ex.ParamName, "#B5");
1765 // Check non-virtual methods on an interface
1766 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1768 tb2.DefineMethod ("FOO", MethodAttributes.Abstract, null, null);
1769 Assert.Fail ("#C1");
1770 } catch (ArgumentException ex) {
1771 // Interface method must be abstract and virtual
1772 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1773 Assert.IsNull (ex.InnerException, "#C3");
1774 Assert.IsNotNull (ex.Message, "#C4");
1775 Assert.IsNull (ex.ParamName, "#C5");
1778 // Check static methods on an interface
1779 tb2.DefineMethod ("BAR", MethodAttributes.Public | MethodAttributes.Static,
1784 // Can not be called on a created type
1786 tb.DefineMethod ("bar", 0, null, null);
1787 Assert.Fail ("#D1");
1788 } catch (InvalidOperationException ex) {
1789 // Unable to change after type has been created
1790 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1791 Assert.IsNull (ex.InnerException, "#D3");
1792 Assert.IsNotNull (ex.Message, "#D4");
1796 [Test] // bug #327484
1797 [Category ("NotWorking")]
1798 public void TestDefineMethod_Abstract ()
1800 TypeBuilder tb = module.DefineType (genTypeName ());
1801 tb.DefineMethod ("Run", MethodAttributes.Public |
1802 MethodAttributes.Abstract | MethodAttributes.Virtual,
1803 typeof (void), Type.EmptyTypes);
1807 Assert.Fail ("#A1");
1808 } catch (InvalidOperationException ex) {
1809 // Type must be declared abstract if any of its
1810 // methods are abstract
1811 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1812 Assert.IsNull (ex.InnerException, "#A3");
1813 Assert.IsNotNull (ex.Message, "#A4");
1816 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract);
1817 tb.DefineMethod ("Run", MethodAttributes.Public |
1818 MethodAttributes.Abstract, typeof (void),
1823 Assert.Fail ("#B1");
1824 } catch (TypeLoadException ex) {
1825 // Non-virtual abstract method
1826 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B2");
1827 Assert.IsNull (ex.InnerException, "#B3");
1828 Assert.IsNotNull (ex.Message, "#B4");
1831 tb = module.DefineType (genTypeName (), TypeAttributes.Abstract |
1832 TypeAttributes.Public);
1833 tb.DefineMethod ("Run", MethodAttributes.Public |
1834 MethodAttributes.Abstract | MethodAttributes.Virtual,
1835 typeof (void), Type.EmptyTypes);
1836 Type emittedType = tb.CreateType ();
1838 MethodInfo mi1 = emittedType.GetMethod ("Run");
1839 Assert.IsNotNull (mi1, "#C1");
1840 Assert.IsTrue (mi1.IsAbstract, "#C2");
1842 MethodInfo mi2 = tb.GetMethod ("Run");
1843 Assert.IsNotNull (mi2, "#D1");
1844 Assert.IsTrue (mi2.IsAbstract, "#D2");
1847 // TODO: DefineMethodOverride
1850 public void TestDefineNestedType ()
1852 TypeBuilder tb = module.DefineType (genTypeName ());
1854 // Check invalid arguments
1856 tb.DefineNestedType (null);
1857 Assert.Fail ("#A1");
1858 } catch (ArgumentNullException ex) {
1859 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1860 Assert.IsNull (ex.InnerException, "#A3");
1861 Assert.IsNotNull (ex.Message, "#A4");
1862 Assert.AreEqual ("fullname", ex.ParamName, "#A5");
1866 tb.DefineNestedType (string.Empty);
1867 Assert.Fail ("#B1");
1868 } catch (ArgumentException ex) {
1869 // Empty name is not legal
1870 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1871 Assert.IsNull (ex.InnerException, "#B3");
1872 Assert.IsNotNull (ex.Message, "#B4");
1873 Assert.AreEqual ("fullname", ex.ParamName, "#B5");
1877 tb.DefineNestedType (nullName ());
1878 Assert.Fail ("#C1");
1879 } catch (ArgumentException ex) {
1881 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
1882 Assert.IsNull (ex.InnerException, "#C3");
1883 Assert.IsNotNull (ex.Message, "#C4");
1884 Assert.AreEqual ("fullname", ex.ParamName, "#C5");
1887 // If I fix the code so this works then mcs breaks -> how can mcs
1888 // works under MS .NET in the first place ???
1891 tb.DefineNestedType ("AA", TypeAttributes.Public, null, null);
1892 Fail ("Nested visibility must be specified.");
1894 catch (ArgumentException) {
1899 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1901 Assert.Fail ("#D1");
1902 } catch (ArgumentNullException ex) {
1903 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#D2");
1904 Assert.IsNull (ex.InnerException, "#D3");
1905 Assert.IsNotNull (ex.Message, "#D4");
1906 Assert.AreEqual ("interfaces", ex.ParamName, "#D5");
1909 // I think this should reject non-interfaces, but it does not
1910 tb.DefineNestedType ("BB", TypeAttributes.NestedPublic, null,
1911 new Type [1] { typeof (object) });
1913 // Normal invocation
1914 tb.DefineNestedType ("Nest");
1918 // According to the MSDN docs, this cannnot be called after the type
1919 // is created, but it works.
1920 tb.DefineNestedType ("Nest2");
1922 // According to the MSDN docs, a Sealed class can't contain nested
1923 // types, but this is not true
1924 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Sealed);
1925 tb2.DefineNestedType ("AA");
1927 // According to the MSDN docs, interfaces can only contain interfaces,
1928 // but this is not true
1929 TypeBuilder tb3 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
1931 tb3.DefineNestedType ("AA");
1933 // Check shorter versions
1935 TypeBuilder nested = tb.DefineNestedType ("N1");
1937 Assert.AreEqual ("N1", nested.Name, "#E1");
1938 Assert.AreEqual (typeof (object), nested.BaseType, "#E2");
1939 Assert.AreEqual (TypeAttributes.NestedPrivate, nested.Attributes, "#E3");
1940 Assert.AreEqual (0, nested.GetInterfaces ().Length, "#E4");
1947 public void DefinePInvokeMethod_Name_NullChar ()
1949 TypeBuilder tb = module.DefineType (genTypeName ());
1951 tb.DefinePInvokeMethod ("\0test", "B", "C",
1952 MethodAttributes.Private, CallingConventions.Standard,
1953 typeof (string),Type.EmptyTypes, CallingConvention.Cdecl,
1955 Assert.Fail ("#A1");
1956 } catch (ArgumentException ex) {
1958 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1959 Assert.IsNull (ex.InnerException, "#A3");
1960 Assert.IsNotNull (ex.Message, "#A4");
1961 Assert.AreEqual ("name", ex.ParamName, "#A5");
1964 MethodBuilder mb = tb.DefinePInvokeMethod ("te\0st", "B", "C",
1965 MethodAttributes.Private, CallingConventions.Standard,
1966 typeof (string), Type.EmptyTypes, CallingConvention.Cdecl,
1968 Assert.IsNotNull (mb, "#B1");
1969 Assert.AreEqual ("te\0st", mb.Name, "#B2");
1973 public void TestDefinePInvokeMethod ()
1975 TypeBuilder tb = module.DefineType (genTypeName ());
1977 tb.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1979 // Try invalid parameters
1981 tb.DefinePInvokeMethod (null, "B", "C", 0, 0, null, null, 0, 0);
1982 Assert.Fail ("#A1");
1983 } catch (ArgumentNullException ex) {
1984 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
1985 Assert.IsNull (ex.InnerException, "#A3");
1986 Assert.IsNotNull (ex.Message, "#A4");
1987 Assert.AreEqual ("name", ex.ParamName, "#A5");
1991 // Try invalid attributes
1993 tb.DefinePInvokeMethod ("A2", "B", "C", MethodAttributes.Abstract, 0, null, null, 0, 0);
1994 Assert.Fail ("#B1");
1995 } catch (ArgumentException ex) {
1996 // PInvoke methods must be static and native and
1997 // cannot be abstract
1998 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1999 Assert.IsNull (ex.InnerException, "#B3");
2000 Assert.IsNotNull (ex.Message, "#B4");
2001 Assert.IsNull (ex.ParamName, "#B5");
2004 // Try an interface parent
2005 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract);
2008 tb2.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
2009 Assert.Fail ("#C1");
2010 } catch (ArgumentException ex) {
2011 // PInvoke methods cannot exist on interfaces
2012 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2013 Assert.IsNull (ex.InnerException, "#B3");
2014 Assert.IsNotNull (ex.Message, "#B4");
2015 Assert.IsNull (ex.ParamName, "#B5");
2020 public void DefineProperty_Name_NullChar ()
2022 TypeBuilder tb = module.DefineType (genTypeName ());
2025 tb.DefineProperty ("\0test", 0, typeof (string), Type.EmptyTypes);
2026 Assert.Fail ("#A1");
2027 } catch (ArgumentException ex) {
2029 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2030 Assert.IsNull (ex.InnerException, "#A3");
2031 Assert.IsNotNull (ex.Message, "#A4");
2032 Assert.AreEqual ("name", ex.ParamName, "#A5");
2035 PropertyBuilder pb = tb.DefineProperty ("te\0st", 0,
2036 typeof (string), Type.EmptyTypes);
2037 Assert.IsNotNull (pb, "#B1");
2038 Assert.AreEqual ("te\0st", pb.Name, "#B2");
2042 public void DefineProperty_ParameterTypes_ItemNull ()
2044 TypeBuilder tb = module.DefineType (genTypeName ());
2047 tb.DefineProperty ("A", 0, typeof (string), new Type [1]);
2049 } catch (ArgumentNullException ex) {
2050 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2051 Assert.IsNull (ex.InnerException, "#3");
2052 Assert.IsNotNull (ex.Message, "#4");
2057 public void DefineProperty_ReturnType_Null ()
2059 TypeBuilder tb = module.DefineType (genTypeName ());
2060 tb.DefineProperty ("A", 0, null, Type.EmptyTypes);
2065 public void GetMethod_RejectMethodFromInflatedTypeBuilder () {
2066 TypeBuilder tb = module.DefineType (genTypeName ());
2067 tb.DefineGenericParameters ("T");
2068 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2070 Type ginst = tb.MakeGenericType (typeof (int));
2072 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2074 TypeBuilder.GetMethod (ginst, mi);
2076 } catch (ArgumentException ex) {
2077 Assert.AreEqual ("method", ex.ParamName, "#5");
2082 public void GetMethod_WorkWithInstancesOfCreatedTypeBuilder () {
2083 TypeBuilder tb = module.DefineType (genTypeName ());
2084 tb.DefineGenericParameters ("T");
2085 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2086 ILGenerator ig = mb.GetILGenerator ();
2087 ig.Emit (OpCodes.Ret);
2091 MethodInfo mi = TypeBuilder.GetMethod (tb.MakeGenericType (typeof (int)), mb);
2092 Assert.IsNotNull (mi);
2096 [Category ("NotDotNet")]
2097 [Category ("NotWorking")]
2098 public void GetMethod_AcceptMethodFromInflatedTypeBuilder_UnderCompilerContext () {
2099 AssemblyName assemblyName = new AssemblyName ();
2100 assemblyName.Name = ASSEMBLY_NAME;
2103 Thread.GetDomain ().DefineDynamicAssembly (
2104 assemblyName, AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800, Path.GetTempPath ());
2106 module = assembly.DefineDynamicModule ("module1");
2108 TypeBuilder tb = module.DefineType (genTypeName ());
2109 tb.DefineGenericParameters ("T");
2110 MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
2112 Type ginst = tb.MakeGenericType (typeof (int));
2114 MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
2117 TypeBuilder.GetMethod (ginst, mi);
2118 } catch (ArgumentException ex) {
2125 // Test that changes made to the method builder after a call to GetMethod ()
2127 public void TestGetMethod ()
2129 TypeBuilder tb = module.DefineType (genTypeName ());
2130 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2132 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2134 ig = cb.GetILGenerator ();
2135 ig.Emit (OpCodes.Ret);
2137 Type fooOfT = tb.MakeGenericType (typeParams [0]);
2139 // Create a method builder but do not emit IL yet
2140 MethodBuilder mb1 = tb.DefineMethod ("create", MethodAttributes.Public|MethodAttributes.Static, fooOfT, Type.EmptyTypes);
2142 Type t = tb.MakeGenericType (typeof (int));
2144 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2146 ig = mb.GetILGenerator ();
2147 ig.Emit (OpCodes.Call, TypeBuilder.GetMethod (t, mb1));
2148 ig.Emit (OpCodes.Ret);
2150 // Finish the method
2151 ig = mb1.GetILGenerator ();
2152 ig.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (fooOfT, cb));
2153 ig.Emit (OpCodes.Ret);
2155 Type t2 = tb.CreateType ();
2157 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2161 public void TestGetConstructor ()
2163 TypeBuilder tb = module.DefineType (genTypeName ());
2164 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
2166 ConstructorBuilder cb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
2169 Type t = tb.MakeGenericType (typeof (int));
2171 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public|MethodAttributes.Static, t, Type.EmptyTypes);
2173 ig = mb.GetILGenerator ();
2175 ConstructorInfo ci = TypeBuilder.GetConstructor (t, cb);
2177 ig.Emit (OpCodes.Newobj, ci);
2178 ig.Emit (OpCodes.Ret);
2180 // Finish the ctorbuilder
2181 ig = cb.GetILGenerator ();
2182 ig.Emit (OpCodes.Ret);
2184 Type t2 = tb.CreateType ();
2186 Assert.AreEqual (tb.Name + "[System.Int32]", t2.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2191 [Category ("NotWorking")]
2192 public void TestIsDefinedIncomplete ()
2194 TypeBuilder tb = module.DefineType (genTypeName ());
2196 tb.IsDefined (typeof (int), true);
2198 } catch (NotSupportedException ex) {
2199 // The invoked member is not supported in a
2201 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2202 Assert.IsNull (ex.InnerException, "#3");
2203 Assert.IsNotNull (ex.Message, "#4");
2208 public void TestIsDefinedComplete ()
2210 TypeBuilder tb = module.DefineType (genTypeName ());
2212 ConstructorInfo obsoleteCtor = typeof (ObsoleteAttribute).GetConstructor (
2213 new Type [] { typeof (string) });
2215 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (obsoleteCtor,
2216 new object [] { "obsolete message" }, new FieldInfo [0], new object [0]);
2218 tb.SetCustomAttribute (caBuilder);
2220 Assert.IsTrue (tb.IsDefined (typeof (ObsoleteAttribute), false));
2224 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=293659
2225 public void IsDefined_AttributeType_Null ()
2227 TypeBuilder tb = module.DefineType (genTypeName ());
2231 tb.IsDefined ((Type) null, false);
2233 } catch (ArgumentNullException ex) {
2234 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2235 Assert.IsNull (ex.InnerException, "#3");
2236 Assert.IsNotNull (ex.Message, "#4");
2237 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
2241 [Test] // GetConstructor (Type [])
2242 public void GetConstructor1_Incomplete ()
2244 TypeBuilder tb = module.DefineType (genTypeName ());
2245 ConstructorBuilder cb = tb.DefineConstructor (
2246 MethodAttributes.Public,
2247 CallingConventions.Standard,
2249 cb.GetILGenerator ().Emit (OpCodes.Ret);
2252 tb.GetConstructor (Type.EmptyTypes);
2254 } catch (NotSupportedException ex) {
2255 // The invoked member is not supported in a
2257 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
2258 Assert.IsNull (ex.InnerException, "#3");
2259 Assert.IsNotNull (ex.Message, "#4");
2263 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2264 public void GetConstructor2_Complete ()
2267 ConstructorInfo ctor;
2269 TypeBuilder redType = module.DefineType (genTypeName (),
2270 TypeAttributes.Public);
2271 CreateMembers (redType, "Red", true);
2273 TypeBuilder greenType = module.DefineType (genTypeName (),
2274 TypeAttributes.Public, redType);
2275 CreateMembers (greenType, "Green", false);
2276 ConstructorBuilder cb = greenType.DefineConstructor (
2277 MethodAttributes.Public,
2278 CallingConventions.Standard,
2280 cb.GetILGenerator ().Emit (OpCodes.Ret);
2282 redType.CreateType ();
2283 greenType.CreateType ();
2285 flags = BindingFlags.Instance | BindingFlags.NonPublic;
2287 ctor = greenType.GetConstructor (flags, null,
2288 new Type [] { typeof (int), typeof (int) },
2289 new ParameterModifier [0]);
2290 Assert.IsNull (ctor, "#A1");
2292 ctor = greenType.GetConstructor (flags, null,
2293 new Type [] { typeof (string) },
2294 new ParameterModifier [0]);
2295 Assert.IsNull (ctor, "#A2");
2297 ctor = greenType.GetConstructor (flags, null,
2298 new Type [] { typeof (string), typeof (string) },
2299 new ParameterModifier [0]);
2300 Assert.IsNull (ctor, "#A3");
2302 ctor = greenType.GetConstructor (flags, null,
2303 new Type [] { typeof (int) },
2304 new ParameterModifier [0]);
2305 Assert.IsNull (ctor, "#A4");
2307 ctor = greenType.GetConstructor (flags, null,
2308 new Type [] { typeof (int), typeof (bool) },
2309 new ParameterModifier [0]);
2310 Assert.IsNull (ctor, "#A5");
2312 ctor = greenType.GetConstructor (flags, null,
2313 new Type [] { typeof (string), typeof (int) },
2314 new ParameterModifier [0]);
2315 Assert.IsNull (ctor, "#A6");
2317 ctor = greenType.GetConstructor (flags, null,
2319 new ParameterModifier [0]);
2320 Assert.IsNull (ctor, "#A7");
2322 ctor = redType.GetConstructor (flags, null,
2323 new Type [] { typeof (int), typeof (int) },
2324 new ParameterModifier [0]);
2325 Assert.IsNotNull (ctor, "#A8a");
2326 Assert.IsTrue (ctor.IsPrivate, "#A8b");
2327 Assert.IsFalse (ctor.IsStatic, "#A8c");
2328 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A8d");
2329 Assert.IsFalse (ctor is ConstructorBuilder, "#A8e");
2331 ctor = redType.GetConstructor (flags, null,
2332 new Type [] { typeof (string) },
2333 new ParameterModifier [0]);
2334 Assert.IsNotNull (ctor, "#A9a");
2335 Assert.IsTrue (ctor.IsFamily, "#A9b");
2336 Assert.IsFalse (ctor.IsStatic, "#A9c");
2337 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A9d");
2338 Assert.IsFalse (ctor is ConstructorBuilder, "#A9e");
2340 ctor = redType.GetConstructor (flags, null,
2341 new Type [] { typeof (string), typeof (string) },
2342 new ParameterModifier [0]);
2343 Assert.IsNotNull (ctor, "#A10a");
2344 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#A10b");
2345 Assert.IsFalse (ctor.IsStatic, "#A10c");
2346 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A10d");
2347 Assert.IsFalse (ctor is ConstructorBuilder, "#A10e");
2349 ctor = redType.GetConstructor (flags, null,
2350 new Type [] { typeof (int) },
2351 new ParameterModifier [0]);
2352 Assert.IsNotNull (ctor, "#A11a");
2353 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#A11b");
2354 Assert.IsFalse (ctor.IsStatic, "#A11c");
2355 Assert.AreEqual (1, ctor.GetParameters ().Length, "#A11d");
2356 Assert.IsFalse (ctor is ConstructorBuilder, "#A11e");
2358 ctor = redType.GetConstructor (flags, null,
2359 new Type [] { typeof (int), typeof (bool) },
2360 new ParameterModifier [0]);
2361 Assert.IsNull (ctor, "#A12");
2363 ctor = redType.GetConstructor (flags, null,
2364 new Type [] { typeof (string), typeof (int) },
2365 new ParameterModifier [0]);
2366 Assert.IsNotNull (ctor, "#A13a");
2367 Assert.IsTrue (ctor.IsAssembly, "#A13b");
2368 Assert.IsFalse (ctor.IsStatic, "#A13c");
2369 Assert.AreEqual (2, ctor.GetParameters ().Length, "#A13d");
2370 Assert.IsFalse (ctor is ConstructorBuilder, "#A13e");
2372 ctor = redType.GetConstructor (flags, null,
2374 new ParameterModifier [0]);
2375 Assert.IsNull (ctor, "#A14");
2377 flags = BindingFlags.Instance | BindingFlags.Public;
2379 ctor = greenType.GetConstructor (flags, null,
2380 new Type [] { typeof (int), typeof (int) },
2381 new ParameterModifier [0]);
2382 Assert.IsNull (ctor, "#B1");
2384 ctor = greenType.GetConstructor (flags, null,
2385 new Type [] { typeof (string) },
2386 new ParameterModifier [0]);
2387 Assert.IsNull (ctor, "#B2");
2389 ctor = greenType.GetConstructor (flags, null,
2390 new Type [] { typeof (string), typeof (string) },
2391 new ParameterModifier [0]);
2392 Assert.IsNull (ctor, "#B3");
2394 ctor = greenType.GetConstructor (flags, null,
2395 new Type [] { typeof (int) },
2396 new ParameterModifier [0]);
2397 Assert.IsNull (ctor, "#B4");
2399 ctor = greenType.GetConstructor (flags, null,
2400 new Type [] { typeof (int), typeof (bool) },
2401 new ParameterModifier [0]);
2402 Assert.IsNull (ctor, "#B5");
2404 ctor = greenType.GetConstructor (flags, null,
2405 new Type [] { typeof (string), typeof (int) },
2406 new ParameterModifier [0]);
2407 Assert.IsNull (ctor, "#B6");
2409 ctor = greenType.GetConstructor (flags, null,
2411 new ParameterModifier [0]);
2412 Assert.IsNotNull (ctor, "#B7a");
2413 Assert.IsTrue (ctor.IsPublic, "#B7b");
2414 Assert.IsFalse (ctor.IsStatic, "#B7c");
2415 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B7d");
2416 Assert.IsFalse (ctor is ConstructorBuilder, "#B7e");
2418 ctor = redType.GetConstructor (flags, null,
2419 new Type [] { typeof (int), typeof (int) },
2420 new ParameterModifier [0]);
2421 Assert.IsNull (ctor, "#B8");
2423 ctor = redType.GetConstructor (flags, null,
2424 new Type [] { typeof (string) },
2425 new ParameterModifier [0]);
2426 Assert.IsNull (ctor, "#B9");
2428 ctor = redType.GetConstructor (flags, null,
2429 new Type [] { typeof (string), typeof (string) },
2430 new ParameterModifier [0]);
2431 Assert.IsNull (ctor, "#B10");
2433 ctor = redType.GetConstructor (flags, null,
2434 new Type [] { typeof (int) },
2435 new ParameterModifier [0]);
2436 Assert.IsNull (ctor, "#B11");
2438 ctor = redType.GetConstructor (flags, null,
2439 new Type [] { typeof (int), typeof (bool) },
2440 new ParameterModifier [0]);
2441 Assert.IsNotNull (ctor, "#B12a");
2442 Assert.IsTrue (ctor.IsPublic, "#B12b");
2443 Assert.IsFalse (ctor.IsStatic, "#B12c");
2444 Assert.AreEqual (2, ctor.GetParameters ().Length, "#B12d");
2445 Assert.IsFalse (ctor is ConstructorBuilder, "#B12e");
2447 ctor = redType.GetConstructor (flags, null,
2448 new Type [] { typeof (string), typeof (int) },
2449 new ParameterModifier [0]);
2450 Assert.IsNull (ctor, "#B13");
2452 ctor = redType.GetConstructor (flags, null,
2454 new ParameterModifier [0]);
2455 Assert.IsNull (ctor, "#B14");
2457 flags = BindingFlags.Static | BindingFlags.Public;
2459 ctor = greenType.GetConstructor (flags, null,
2460 new Type [] { typeof (int), typeof (int) },
2461 new ParameterModifier [0]);
2462 Assert.IsNull (ctor, "#C1");
2464 ctor = greenType.GetConstructor (flags, null,
2465 new Type [] { typeof (string) },
2466 new ParameterModifier [0]);
2467 Assert.IsNull (ctor, "#C2");
2469 ctor = greenType.GetConstructor (flags, null,
2470 new Type [] { typeof (string), typeof (string) },
2471 new ParameterModifier [0]);
2472 Assert.IsNull (ctor, "#C3");
2474 ctor = greenType.GetConstructor (flags, null,
2475 new Type [] { typeof (int) },
2476 new ParameterModifier [0]);
2477 Assert.IsNull (ctor, "#C4");
2479 ctor = greenType.GetConstructor (flags, null,
2480 new Type [] { typeof (int), typeof (bool) },
2481 new ParameterModifier [0]);
2482 Assert.IsNull (ctor, "#C5");
2484 ctor = greenType.GetConstructor (flags, null,
2485 new Type [] { typeof (string), typeof (int) },
2486 new ParameterModifier [0]);
2487 Assert.IsNull (ctor, "#C6");
2489 ctor = greenType.GetConstructor (flags, null,
2491 new ParameterModifier [0]);
2492 Assert.IsNull (ctor, "#C7");
2494 ctor = redType.GetConstructor (flags, null,
2495 new Type [] { typeof (int), typeof (int) },
2496 new ParameterModifier [0]);
2497 Assert.IsNull (ctor, "#C8");
2499 ctor = redType.GetConstructor (flags, null,
2500 new Type [] { typeof (string) },
2501 new ParameterModifier [0]);
2502 Assert.IsNull (ctor, "#C9");
2504 ctor = redType.GetConstructor (flags, null,
2505 new Type [] { typeof (string), typeof (string) },
2506 new ParameterModifier [0]);
2507 Assert.IsNull (ctor, "#C10");
2509 ctor = redType.GetConstructor (flags, null,
2510 new Type [] { typeof (int) },
2511 new ParameterModifier [0]);
2512 Assert.IsNull (ctor, "#C11a");
2514 ctor = redType.GetConstructor (flags, null,
2515 new Type [] { typeof (int), typeof (bool) },
2516 new ParameterModifier [0]);
2517 Assert.IsNull (ctor, "#C12");
2519 ctor = redType.GetConstructor (flags, null,
2520 new Type [] { typeof (string), typeof (int) },
2521 new ParameterModifier [0]);
2522 Assert.IsNull (ctor, "#C13");
2524 ctor = redType.GetConstructor (flags, null,
2526 new ParameterModifier [0]);
2527 Assert.IsNull (ctor, "#C14");
2529 flags = BindingFlags.Static | BindingFlags.NonPublic;
2531 ctor = greenType.GetConstructor (flags, null,
2532 new Type [] { typeof (int), typeof (int) },
2533 new ParameterModifier [0]);
2534 Assert.IsNull (ctor, "#D1");
2536 ctor = greenType.GetConstructor (flags, null,
2537 new Type [] { typeof (string) },
2538 new ParameterModifier [0]);
2539 Assert.IsNull (ctor, "#D2");
2541 ctor = greenType.GetConstructor (flags, null,
2542 new Type [] { typeof (string), typeof (string) },
2543 new ParameterModifier [0]);
2544 Assert.IsNull (ctor, "#D3");
2546 ctor = greenType.GetConstructor (flags, null,
2547 new Type [] { typeof (int) },
2548 new ParameterModifier [0]);
2549 Assert.IsNull (ctor, "#D4");
2551 ctor = greenType.GetConstructor (flags, null,
2552 new Type [] { typeof (int), typeof (bool) },
2553 new ParameterModifier [0]);
2554 Assert.IsNull (ctor, "#D5");
2556 ctor = greenType.GetConstructor (flags, null,
2557 new Type [] { typeof (string), typeof (int) },
2558 new ParameterModifier [0]);
2559 Assert.IsNull (ctor, "#D6");
2561 ctor = greenType.GetConstructor (flags, null,
2563 new ParameterModifier [0]);
2564 Assert.IsNull (ctor, "#D7");
2566 ctor = redType.GetConstructor (flags, null,
2567 new Type [] { typeof (int), typeof (int) },
2568 new ParameterModifier [0]);
2569 Assert.IsNull (ctor, "#D8");
2571 ctor = redType.GetConstructor (flags, null,
2572 new Type [] { typeof (string) },
2573 new ParameterModifier [0]);
2574 Assert.IsNull (ctor, "#D9");
2576 ctor = redType.GetConstructor (flags, null,
2577 new Type [] { typeof (string), typeof (string) },
2578 new ParameterModifier [0]);
2579 Assert.IsNull (ctor, "#D10");
2581 ctor = redType.GetConstructor (flags, null,
2582 new Type [] { typeof (int) },
2583 new ParameterModifier [0]);
2584 Assert.IsNull (ctor, "#D11");
2586 ctor = redType.GetConstructor (flags, null,
2587 new Type [] { typeof (int), typeof (bool) },
2588 new ParameterModifier [0]);
2589 Assert.IsNull (ctor, "#D12");
2591 ctor = redType.GetConstructor (flags, null,
2592 new Type [] { typeof (string), typeof (int) },
2593 new ParameterModifier [0]);
2594 Assert.IsNull (ctor, "#D13");
2596 ctor = redType.GetConstructor (flags, null,
2598 new ParameterModifier [0]);
2599 Assert.IsNotNull (ctor, "#D14a");
2600 Assert.IsTrue (ctor.IsPrivate, "#D14b");
2601 Assert.IsTrue (ctor.IsStatic, "#B14c");
2602 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B14d");
2603 Assert.IsFalse (ctor is ConstructorBuilder, "#B14e");
2605 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2606 BindingFlags.FlattenHierarchy;
2608 ctor = greenType.GetConstructor (flags, null,
2609 new Type [] { typeof (int), typeof (int) },
2610 new ParameterModifier [0]);
2611 Assert.IsNull (ctor, "#E1");
2613 ctor = greenType.GetConstructor (flags, null,
2614 new Type [] { typeof (string) },
2615 new ParameterModifier [0]);
2616 Assert.IsNull (ctor, "#E2");
2618 ctor = greenType.GetConstructor (flags, null,
2619 new Type [] { typeof (string), typeof (string) },
2620 new ParameterModifier [0]);
2621 Assert.IsNull (ctor, "#E3");
2623 ctor = greenType.GetConstructor (flags, null,
2624 new Type [] { typeof (int) },
2625 new ParameterModifier [0]);
2626 Assert.IsNull (ctor, "#E4");
2628 ctor = greenType.GetConstructor (flags, null,
2629 new Type [] { typeof (int), typeof (bool) },
2630 new ParameterModifier [0]);
2631 Assert.IsNull (ctor, "#E5");
2633 ctor = greenType.GetConstructor (flags, null,
2634 new Type [] { typeof (string), typeof (int) },
2635 new ParameterModifier [0]);
2636 Assert.IsNull (ctor, "#E6");
2638 ctor = greenType.GetConstructor (flags, null,
2640 new ParameterModifier [0]);
2641 Assert.IsNull (ctor, "#E7");
2643 ctor = redType.GetConstructor (flags, null,
2644 new Type [] { typeof (int), typeof (int) },
2645 new ParameterModifier [0]);
2646 Assert.IsNotNull (ctor, "#E8a");
2647 Assert.IsTrue (ctor.IsPrivate, "#E8b");
2648 Assert.IsFalse (ctor.IsStatic, "#E8c");
2649 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E8d");
2650 Assert.IsFalse (ctor is ConstructorBuilder, "#E8e");
2652 ctor = redType.GetConstructor (flags, null,
2653 new Type [] { typeof (string) },
2654 new ParameterModifier [0]);
2655 Assert.IsNotNull (ctor, "#E9a");
2656 Assert.IsTrue (ctor.IsFamily, "#E9b");
2657 Assert.IsFalse (ctor.IsStatic, "#E9c");
2658 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E9d");
2659 Assert.IsFalse (ctor is ConstructorBuilder, "#E9e");
2661 ctor = redType.GetConstructor (flags, null,
2662 new Type [] { typeof (string), typeof (string) },
2663 new ParameterModifier [0]);
2664 Assert.IsNotNull (ctor, "#E10a");
2665 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#E10b");
2666 Assert.IsFalse (ctor.IsStatic, "#E10c");
2667 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E10d");
2668 Assert.IsFalse (ctor is ConstructorBuilder, "#E10e");
2670 ctor = redType.GetConstructor (flags, null,
2671 new Type [] { typeof (int) },
2672 new ParameterModifier [0]);
2673 Assert.IsNotNull (ctor, "#E11a");
2674 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#E11b");
2675 Assert.IsFalse (ctor.IsStatic, "#E11c");
2676 Assert.AreEqual (1, ctor.GetParameters ().Length, "#E11d");
2677 Assert.IsFalse (ctor is ConstructorBuilder, "#E11e");
2679 ctor = redType.GetConstructor (flags, null,
2680 new Type [] { typeof (int), typeof (bool) },
2681 new ParameterModifier [0]);
2682 Assert.IsNull (ctor, "#E12");
2684 ctor = redType.GetConstructor (flags, null,
2685 new Type [] { typeof (string), typeof (int) },
2686 new ParameterModifier [0]);
2687 Assert.IsNotNull (ctor, "#E13a");
2688 Assert.IsTrue (ctor.IsAssembly, "#E13b");
2689 Assert.IsFalse (ctor.IsStatic, "#E13c");
2690 Assert.AreEqual (2, ctor.GetParameters ().Length, "#E13d");
2691 Assert.IsFalse (ctor is ConstructorBuilder, "#E13e");
2693 ctor = redType.GetConstructor (flags, null,
2695 new ParameterModifier [0]);
2696 Assert.IsNull (ctor, "#E14");
2698 flags = BindingFlags.Instance | BindingFlags.Public |
2699 BindingFlags.FlattenHierarchy;
2701 ctor = greenType.GetConstructor (flags, null,
2702 new Type [] { typeof (int), typeof (int) },
2703 new ParameterModifier [0]);
2704 Assert.IsNull (ctor, "#F1");
2706 ctor = greenType.GetConstructor (flags, null,
2707 new Type [] { typeof (string) },
2708 new ParameterModifier [0]);
2709 Assert.IsNull (ctor, "#F2");
2711 ctor = greenType.GetConstructor (flags, null,
2712 new Type [] { typeof (string), typeof (string) },
2713 new ParameterModifier [0]);
2714 Assert.IsNull (ctor, "#F3");
2716 ctor = greenType.GetConstructor (flags, null,
2717 new Type [] { typeof (int) },
2718 new ParameterModifier [0]);
2719 Assert.IsNull (ctor, "#F4");
2721 ctor = greenType.GetConstructor (flags, null,
2722 new Type [] { typeof (int), typeof (bool) },
2723 new ParameterModifier [0]);
2724 Assert.IsNull (ctor, "#F5");
2726 ctor = greenType.GetConstructor (flags, null,
2727 new Type [] { typeof (string), typeof (int) },
2728 new ParameterModifier [0]);
2729 Assert.IsNull (ctor, "#F6");
2731 ctor = greenType.GetConstructor (flags, null,
2733 new ParameterModifier [0]);
2734 Assert.IsNotNull (ctor, "#F7a");
2735 Assert.IsTrue (ctor.IsPublic, "#F7b");
2736 Assert.IsFalse (ctor.IsStatic, "#F7c");
2737 Assert.AreEqual (0, ctor.GetParameters ().Length, "#F7d");
2738 Assert.IsFalse (ctor is ConstructorBuilder, "#F7e");
2740 ctor = redType.GetConstructor (flags, null,
2741 new Type [] { typeof (int), typeof (int) },
2742 new ParameterModifier [0]);
2743 Assert.IsNull (ctor, "#F8");
2745 ctor = redType.GetConstructor (flags, null,
2746 new Type [] { typeof (string) },
2747 new ParameterModifier [0]);
2748 Assert.IsNull (ctor, "#F9");
2750 ctor = redType.GetConstructor (flags, null,
2751 new Type [] { typeof (string), typeof (string) },
2752 new ParameterModifier [0]);
2753 Assert.IsNull (ctor, "#F10");
2755 ctor = redType.GetConstructor (flags, null,
2756 new Type [] { typeof (int) },
2757 new ParameterModifier [0]);
2758 Assert.IsNull (ctor, "#F11");
2760 ctor = redType.GetConstructor (flags, null,
2761 new Type [] { typeof (int), typeof (bool) },
2762 new ParameterModifier [0]);
2763 Assert.IsNotNull (ctor, "#F12a");
2764 Assert.IsTrue (ctor.IsPublic, "#F12b");
2765 Assert.IsFalse (ctor.IsStatic, "#F12c");
2766 Assert.AreEqual (2, ctor.GetParameters ().Length, "#F12d");
2767 Assert.IsFalse (ctor is ConstructorBuilder, "#F12e");
2769 ctor = redType.GetConstructor (flags, null,
2770 new Type [] { typeof (string), typeof (int) },
2771 new ParameterModifier [0]);
2772 Assert.IsNull (ctor, "#F13");
2774 ctor = redType.GetConstructor (flags, null,
2776 new ParameterModifier [0]);
2777 Assert.IsNull (ctor, "#F14");
2779 flags = BindingFlags.Static | BindingFlags.Public |
2780 BindingFlags.FlattenHierarchy;
2782 ctor = greenType.GetConstructor (flags, null,
2783 new Type [] { typeof (int), typeof (int) },
2784 new ParameterModifier [0]);
2785 Assert.IsNull (ctor, "#G1");
2787 ctor = greenType.GetConstructor (flags, null,
2788 new Type [] { typeof (string) },
2789 new ParameterModifier [0]);
2790 Assert.IsNull (ctor, "#G2");
2792 ctor = greenType.GetConstructor (flags, null,
2793 new Type [] { typeof (string), typeof (string) },
2794 new ParameterModifier [0]);
2795 Assert.IsNull (ctor, "#G3");
2797 ctor = greenType.GetConstructor (flags, null,
2798 new Type [] { typeof (int) },
2799 new ParameterModifier [0]);
2800 Assert.IsNull (ctor, "#G4");
2802 ctor = greenType.GetConstructor (flags, null,
2803 new Type [] { typeof (int), typeof (bool) },
2804 new ParameterModifier [0]);
2805 Assert.IsNull (ctor, "#G5");
2807 ctor = greenType.GetConstructor (flags, null,
2808 new Type [] { typeof (string), typeof (int) },
2809 new ParameterModifier [0]);
2810 Assert.IsNull (ctor, "#G6");
2812 ctor = greenType.GetConstructor (flags, null,
2814 new ParameterModifier [0]);
2815 Assert.IsNull (ctor, "#G7");
2817 ctor = redType.GetConstructor (flags, null,
2818 new Type [] { typeof (int), typeof (int) },
2819 new ParameterModifier [0]);
2820 Assert.IsNull (ctor, "#G8");
2822 ctor = redType.GetConstructor (flags, null,
2823 new Type [] { typeof (string) },
2824 new ParameterModifier [0]);
2825 Assert.IsNull (ctor, "#G9");
2827 ctor = redType.GetConstructor (flags, null,
2828 new Type [] { typeof (string), typeof (string) },
2829 new ParameterModifier [0]);
2830 Assert.IsNull (ctor, "#G10");
2832 ctor = redType.GetConstructor (flags, null,
2833 new Type [] { typeof (int) },
2834 new ParameterModifier [0]);
2835 Assert.IsNull (ctor, "#G11");
2837 ctor = redType.GetConstructor (flags, null,
2838 new Type [] { typeof (int), typeof (bool) },
2839 new ParameterModifier [0]);
2840 Assert.IsNull (ctor, "#G12");
2842 ctor = redType.GetConstructor (flags, null,
2843 new Type [] { typeof (string), typeof (int) },
2844 new ParameterModifier [0]);
2845 Assert.IsNull (ctor, "#G13");
2847 ctor = redType.GetConstructor (flags, null,
2849 new ParameterModifier [0]);
2850 Assert.IsNull (ctor, "#G14");
2852 flags = BindingFlags.Static | BindingFlags.NonPublic |
2853 BindingFlags.FlattenHierarchy;
2855 ctor = greenType.GetConstructor (flags, null,
2856 new Type [] { typeof (int), typeof (int) },
2857 new ParameterModifier [0]);
2858 Assert.IsNull (ctor, "#H1");
2860 ctor = greenType.GetConstructor (flags, null,
2861 new Type [] { typeof (string) },
2862 new ParameterModifier [0]);
2863 Assert.IsNull (ctor, "#H2");
2865 ctor = greenType.GetConstructor (flags, null,
2866 new Type [] { typeof (string), typeof (string) },
2867 new ParameterModifier [0]);
2868 Assert.IsNull (ctor, "#H3");
2870 ctor = greenType.GetConstructor (flags, null,
2871 new Type [] { typeof (int) },
2872 new ParameterModifier [0]);
2873 Assert.IsNull (ctor, "#H4");
2875 ctor = greenType.GetConstructor (flags, null,
2876 new Type [] { typeof (int), typeof (bool) },
2877 new ParameterModifier [0]);
2878 Assert.IsNull (ctor, "#H5");
2880 ctor = greenType.GetConstructor (flags, null,
2881 new Type [] { typeof (string), typeof (int) },
2882 new ParameterModifier [0]);
2883 Assert.IsNull (ctor, "#H6");
2885 ctor = greenType.GetConstructor (flags, null,
2887 new ParameterModifier [0]);
2888 Assert.IsNull (ctor, "#H7");
2890 ctor = redType.GetConstructor (flags, null,
2891 new Type [] { typeof (int), typeof (int) },
2892 new ParameterModifier [0]);
2893 Assert.IsNull (ctor, "#H8");
2895 ctor = redType.GetConstructor (flags, null,
2896 new Type [] { typeof (string) },
2897 new ParameterModifier [0]);
2898 Assert.IsNull (ctor, "#H9");
2900 ctor = redType.GetConstructor (flags, null,
2901 new Type [] { typeof (string), typeof (string) },
2902 new ParameterModifier [0]);
2903 Assert.IsNull (ctor, "#H10");
2905 ctor = redType.GetConstructor (flags, null,
2906 new Type [] { typeof (int) },
2907 new ParameterModifier [0]);
2908 Assert.IsNull (ctor, "#H11");
2910 ctor = redType.GetConstructor (flags, null,
2911 new Type [] { typeof (int), typeof (bool) },
2912 new ParameterModifier [0]);
2913 Assert.IsNull (ctor, "#H12");
2915 ctor = redType.GetConstructor (flags, null,
2916 new Type [] { typeof (string), typeof (int) },
2917 new ParameterModifier [0]);
2918 Assert.IsNull (ctor, "#H13");
2920 ctor = redType.GetConstructor (flags, null,
2922 new ParameterModifier [0]);
2923 Assert.IsNotNull (ctor, "#H14");
2924 Assert.IsTrue (ctor.IsPrivate, "#H14b");
2925 Assert.IsTrue (ctor.IsStatic, "#H14c");
2926 Assert.AreEqual (0, ctor.GetParameters ().Length, "#H14d");
2927 Assert.IsFalse (ctor is ConstructorBuilder, "#H14e");
2929 flags = BindingFlags.Instance | BindingFlags.NonPublic |
2930 BindingFlags.DeclaredOnly;
2932 ctor = greenType.GetConstructor (flags, null,
2933 new Type [] { typeof (int), typeof (int) },
2934 new ParameterModifier [0]);
2935 Assert.IsNull (ctor, "#I1");
2937 ctor = greenType.GetConstructor (flags, null,
2938 new Type [] { typeof (string) },
2939 new ParameterModifier [0]);
2940 Assert.IsNull (ctor, "#I2");
2942 ctor = greenType.GetConstructor (flags, null,
2943 new Type [] { typeof (string), typeof (string) },
2944 new ParameterModifier [0]);
2945 Assert.IsNull (ctor, "#I3");
2947 ctor = greenType.GetConstructor (flags, null,
2948 new Type [] { typeof (int) },
2949 new ParameterModifier [0]);
2950 Assert.IsNull (ctor, "#I4");
2952 ctor = greenType.GetConstructor (flags, null,
2953 new Type [] { typeof (int), typeof (bool) },
2954 new ParameterModifier [0]);
2955 Assert.IsNull (ctor, "#I5");
2957 ctor = greenType.GetConstructor (flags, null,
2958 new Type [] { typeof (string), typeof (int) },
2959 new ParameterModifier [0]);
2960 Assert.IsNull (ctor, "#I6");
2962 ctor = greenType.GetConstructor (flags, null,
2964 new ParameterModifier [0]);
2965 Assert.IsNull (ctor, "#I7");
2967 ctor = redType.GetConstructor (flags, null,
2968 new Type [] { typeof (int), typeof (int) },
2969 new ParameterModifier [0]);
2970 Assert.IsNotNull (ctor, "#I8a");
2971 Assert.IsTrue (ctor.IsPrivate, "#I8b");
2972 Assert.IsFalse (ctor.IsStatic, "#I8c");
2973 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I8d");
2974 Assert.IsFalse (ctor is ConstructorBuilder, "#I8e");
2976 ctor = redType.GetConstructor (flags, null,
2977 new Type [] { typeof (string) },
2978 new ParameterModifier [0]);
2979 Assert.IsNotNull (ctor, "#I9a");
2980 Assert.IsTrue (ctor.IsFamily, "#I9b");
2981 Assert.IsFalse (ctor.IsStatic, "#I9c");
2982 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I9d");
2983 Assert.IsFalse (ctor is ConstructorBuilder, "#I9e");
2985 ctor = redType.GetConstructor (flags, null,
2986 new Type [] { typeof (string), typeof (string) },
2987 new ParameterModifier [0]);
2988 Assert.IsNotNull (ctor, "#I10a");
2989 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#I10b");
2990 Assert.IsFalse (ctor.IsStatic, "#I10c");
2991 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I10d");
2992 Assert.IsFalse (ctor is ConstructorBuilder, "#I10e");
2994 ctor = redType.GetConstructor (flags, null,
2995 new Type [] { typeof (int) },
2996 new ParameterModifier [0]);
2997 Assert.IsNotNull (ctor, "#I11a");
2998 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#I11b");
2999 Assert.IsFalse (ctor.IsStatic, "#I11c");
3000 Assert.AreEqual (1, ctor.GetParameters ().Length, "#I11d");
3001 Assert.IsFalse (ctor is ConstructorBuilder, "#I11e");
3003 ctor = redType.GetConstructor (flags, null,
3004 new Type [] { typeof (int), typeof (bool) },
3005 new ParameterModifier [0]);
3006 Assert.IsNull (ctor, "#I12");
3008 ctor = redType.GetConstructor (flags, null,
3009 new Type [] { typeof (string), typeof (int) },
3010 new ParameterModifier [0]);
3011 Assert.IsNotNull (ctor, "#I13a");
3012 Assert.IsTrue (ctor.IsAssembly, "#I13b");
3013 Assert.IsFalse (ctor.IsStatic, "#I13c");
3014 Assert.AreEqual (2, ctor.GetParameters ().Length, "#I13d");
3015 Assert.IsFalse (ctor is ConstructorBuilder, "#I13e");
3017 ctor = redType.GetConstructor (flags, null,
3019 new ParameterModifier [0]);
3020 Assert.IsNull (ctor, "#I14");
3022 flags = BindingFlags.Instance | BindingFlags.Public |
3023 BindingFlags.DeclaredOnly;
3025 ctor = greenType.GetConstructor (flags, null,
3026 new Type [] { typeof (int), typeof (int) },
3027 new ParameterModifier [0]);
3028 Assert.IsNull (ctor, "#J1");
3030 ctor = greenType.GetConstructor (flags, null,
3031 new Type [] { typeof (string) },
3032 new ParameterModifier [0]);
3033 Assert.IsNull (ctor, "#J2");
3035 ctor = greenType.GetConstructor (flags, null,
3036 new Type [] { typeof (string), typeof (string) },
3037 new ParameterModifier [0]);
3038 Assert.IsNull (ctor, "#J3");
3040 ctor = greenType.GetConstructor (flags, null,
3041 new Type [] { typeof (int) },
3042 new ParameterModifier [0]);
3043 Assert.IsNull (ctor, "#J4");
3045 ctor = greenType.GetConstructor (flags, null,
3046 new Type [] { typeof (int), typeof (bool) },
3047 new ParameterModifier [0]);
3048 Assert.IsNull (ctor, "#J5");
3050 ctor = greenType.GetConstructor (flags, null,
3051 new Type [] { typeof (string), typeof (int) },
3052 new ParameterModifier [0]);
3053 Assert.IsNull (ctor, "#J6");
3055 ctor = greenType.GetConstructor (flags, null,
3057 new ParameterModifier [0]);
3058 Assert.IsNotNull (ctor, "#J7a");
3059 Assert.IsTrue (ctor.IsPublic, "#J7b");
3060 Assert.IsFalse (ctor.IsStatic, "#J7c");
3061 Assert.AreEqual (0, ctor.GetParameters ().Length, "#J7d");
3062 Assert.IsFalse (ctor is ConstructorBuilder, "#J7e");
3064 ctor = redType.GetConstructor (flags, null,
3065 new Type [] { typeof (int), typeof (int) },
3066 new ParameterModifier [0]);
3067 Assert.IsNull (ctor, "#J8");
3069 ctor = redType.GetConstructor (flags, null,
3070 new Type [] { typeof (string) },
3071 new ParameterModifier [0]);
3072 Assert.IsNull (ctor, "#J9");
3074 ctor = redType.GetConstructor (flags, null,
3075 new Type [] { typeof (string), typeof (string) },
3076 new ParameterModifier [0]);
3077 Assert.IsNull (ctor, "#J10");
3079 ctor = redType.GetConstructor (flags, null,
3080 new Type [] { typeof (int) },
3081 new ParameterModifier [0]);
3082 Assert.IsNull (ctor, "#J11");
3084 ctor = redType.GetConstructor (flags, null,
3085 new Type [] { typeof (int), typeof (bool) },
3086 new ParameterModifier [0]);
3087 Assert.IsNotNull (ctor, "#J12a");
3088 Assert.IsTrue (ctor.IsPublic, "#J12b");
3089 Assert.IsFalse (ctor.IsStatic, "#J12c");
3090 Assert.AreEqual (2, ctor.GetParameters ().Length, "#J12d");
3091 Assert.IsFalse (ctor is ConstructorBuilder, "#J12e");
3093 ctor = redType.GetConstructor (flags, null,
3094 new Type [] { typeof (string), typeof (int) },
3095 new ParameterModifier [0]);
3096 Assert.IsNull (ctor, "#J13");
3098 ctor = redType.GetConstructor (flags, null,
3100 new ParameterModifier [0]);
3101 Assert.IsNull (ctor, "#J14");
3103 flags = BindingFlags.Static | BindingFlags.Public |
3104 BindingFlags.DeclaredOnly;
3106 ctor = greenType.GetConstructor (flags, null,
3107 new Type [] { typeof (int), typeof (int) },
3108 new ParameterModifier [0]);
3109 Assert.IsNull (ctor, "#K1");
3111 ctor = greenType.GetConstructor (flags, null,
3112 new Type [] { typeof (string) },
3113 new ParameterModifier [0]);
3114 Assert.IsNull (ctor, "#K2");
3116 ctor = greenType.GetConstructor (flags, null,
3117 new Type [] { typeof (string), typeof (string) },
3118 new ParameterModifier [0]);
3119 Assert.IsNull (ctor, "#K3");
3121 ctor = greenType.GetConstructor (flags, null,
3122 new Type [] { typeof (int) },
3123 new ParameterModifier [0]);
3124 Assert.IsNull (ctor, "#K4");
3126 ctor = greenType.GetConstructor (flags, null,
3127 new Type [] { typeof (int), typeof (bool) },
3128 new ParameterModifier [0]);
3129 Assert.IsNull (ctor, "#K5");
3131 ctor = greenType.GetConstructor (flags, null,
3132 new Type [] { typeof (string), typeof (int) },
3133 new ParameterModifier [0]);
3134 Assert.IsNull (ctor, "#K6");
3136 ctor = greenType.GetConstructor (flags, null,
3138 new ParameterModifier [0]);
3139 Assert.IsNull (ctor, "#K7");
3141 ctor = redType.GetConstructor (flags, null,
3142 new Type [] { typeof (int), typeof (int) },
3143 new ParameterModifier [0]);
3144 Assert.IsNull (ctor, "#K8");
3146 ctor = redType.GetConstructor (flags, null,
3147 new Type [] { typeof (string) },
3148 new ParameterModifier [0]);
3149 Assert.IsNull (ctor, "#K9");
3151 ctor = redType.GetConstructor (flags, null,
3152 new Type [] { typeof (string), typeof (string) },
3153 new ParameterModifier [0]);
3154 Assert.IsNull (ctor, "#K10");
3156 ctor = redType.GetConstructor (flags, null,
3157 new Type [] { typeof (int) },
3158 new ParameterModifier [0]);
3159 Assert.IsNull (ctor, "#K11");
3161 ctor = redType.GetConstructor (flags, null,
3162 new Type [] { typeof (int), typeof (bool) },
3163 new ParameterModifier [0]);
3164 Assert.IsNull (ctor, "#K12");
3166 ctor = redType.GetConstructor (flags, null,
3167 new Type [] { typeof (string), typeof (int) },
3168 new ParameterModifier [0]);
3169 Assert.IsNull (ctor, "#K13");
3171 ctor = redType.GetConstructor (flags, null,
3173 new ParameterModifier [0]);
3174 Assert.IsNull (ctor, "#K14");
3176 flags = BindingFlags.Static | BindingFlags.NonPublic |
3177 BindingFlags.DeclaredOnly;
3179 ctor = greenType.GetConstructor (flags, null,
3180 new Type [] { typeof (int), typeof (int) },
3181 new ParameterModifier [0]);
3182 Assert.IsNull (ctor, "#L1");
3184 ctor = greenType.GetConstructor (flags, null,
3185 new Type [] { typeof (string) },
3186 new ParameterModifier [0]);
3187 Assert.IsNull (ctor, "#L2");
3189 ctor = greenType.GetConstructor (flags, null,
3190 new Type [] { typeof (string), typeof (string) },
3191 new ParameterModifier [0]);
3192 Assert.IsNull (ctor, "#L3");
3194 ctor = greenType.GetConstructor (flags, null,
3195 new Type [] { typeof (int) },
3196 new ParameterModifier [0]);
3197 Assert.IsNull (ctor, "#L4");
3199 ctor = greenType.GetConstructor (flags, null,
3200 new Type [] { typeof (int), typeof (bool) },
3201 new ParameterModifier [0]);
3202 Assert.IsNull (ctor, "#L5");
3204 ctor = greenType.GetConstructor (flags, null,
3205 new Type [] { typeof (string), typeof (int) },
3206 new ParameterModifier [0]);
3207 Assert.IsNull (ctor, "#L6");
3209 ctor = greenType.GetConstructor (flags, null,
3211 new ParameterModifier [0]);
3212 Assert.IsNull (ctor, "#L7");
3214 ctor = redType.GetConstructor (flags, null,
3215 new Type [] { typeof (int), typeof (int) },
3216 new ParameterModifier [0]);
3217 Assert.IsNull (ctor, "#L8");
3219 ctor = redType.GetConstructor (flags, null,
3220 new Type [] { typeof (string) },
3221 new ParameterModifier [0]);
3222 Assert.IsNull (ctor, "#L9");
3224 ctor = redType.GetConstructor (flags, null,
3225 new Type [] { typeof (string), typeof (string) },
3226 new ParameterModifier [0]);
3227 Assert.IsNull (ctor, "#L10");
3229 ctor = redType.GetConstructor (flags, null,
3230 new Type [] { typeof (int) },
3231 new ParameterModifier [0]);
3232 Assert.IsNull (ctor, "#L11");
3234 ctor = redType.GetConstructor (flags, null,
3235 new Type [] { typeof (int), typeof (bool) },
3236 new ParameterModifier [0]);
3237 Assert.IsNull (ctor, "#L12");
3239 ctor = redType.GetConstructor (flags, null,
3240 new Type [] { typeof (string), typeof (int) },
3241 new ParameterModifier [0]);
3242 Assert.IsNull (ctor, "#L13");
3244 ctor = redType.GetConstructor (flags, null,
3246 new ParameterModifier [0]);
3247 Assert.IsNotNull (ctor, "#L14a");
3248 Assert.IsTrue (ctor.IsPrivate, "#L14b");
3249 Assert.IsTrue (ctor.IsStatic, "#L14c");
3250 Assert.AreEqual (0, ctor.GetParameters ().Length, "#L14d");
3251 Assert.IsFalse (ctor is ConstructorBuilder, "#L14e");
3253 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3254 BindingFlags.Public;
3256 ctor = greenType.GetConstructor (flags, null,
3257 new Type [] { typeof (int), typeof (int) },
3258 new ParameterModifier [0]);
3259 Assert.IsNull (ctor, "#M1");
3261 ctor = greenType.GetConstructor (flags, null,
3262 new Type [] { typeof (string) },
3263 new ParameterModifier [0]);
3264 Assert.IsNull (ctor, "#M2");
3266 ctor = greenType.GetConstructor (flags, null,
3267 new Type [] { typeof (string), typeof (string) },
3268 new ParameterModifier [0]);
3269 Assert.IsNull (ctor, "#M3");
3271 ctor = greenType.GetConstructor (flags, null,
3272 new Type [] { typeof (int) },
3273 new ParameterModifier [0]);
3274 Assert.IsNull (ctor, "#M4");
3276 ctor = greenType.GetConstructor (flags, null,
3277 new Type [] { typeof (int), typeof (bool) },
3278 new ParameterModifier [0]);
3279 Assert.IsNull (ctor, "#M5");
3281 ctor = greenType.GetConstructor (flags, null,
3282 new Type [] { typeof (string), typeof (int) },
3283 new ParameterModifier [0]);
3284 Assert.IsNull (ctor, "#M6");
3286 ctor = greenType.GetConstructor (flags, null,
3288 new ParameterModifier [0]);
3289 Assert.IsNotNull (ctor, "#M7a");
3290 Assert.IsTrue (ctor.IsPublic, "#M7b");
3291 Assert.IsFalse (ctor.IsStatic, "#M7c");
3292 Assert.AreEqual (0, ctor.GetParameters ().Length, "#M7d");
3293 Assert.IsFalse (ctor is ConstructorBuilder, "#M7e");
3295 ctor = redType.GetConstructor (flags, null,
3296 new Type [] { typeof (int), typeof (int) },
3297 new ParameterModifier [0]);
3298 Assert.IsNotNull (ctor, "#M8a");
3299 Assert.IsTrue (ctor.IsPrivate, "#M8b");
3300 Assert.IsFalse (ctor.IsStatic, "#M8c");
3301 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M8d");
3302 Assert.IsFalse (ctor is ConstructorBuilder, "#M8e");
3304 ctor = redType.GetConstructor (flags, null,
3305 new Type [] { typeof (string) },
3306 new ParameterModifier [0]);
3307 Assert.IsNotNull (ctor, "#M9a");
3308 Assert.IsTrue (ctor.IsFamily, "#M9b");
3309 Assert.IsFalse (ctor.IsStatic, "#M9c");
3310 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M9d");
3311 Assert.IsFalse (ctor is ConstructorBuilder, "#M9e");
3313 ctor = redType.GetConstructor (flags, null,
3314 new Type [] { typeof (string), typeof (string) },
3315 new ParameterModifier [0]);
3316 Assert.IsNotNull (ctor, "#M10a");
3317 Assert.IsTrue (ctor.IsFamilyAndAssembly, "#M10b");
3318 Assert.IsFalse (ctor.IsStatic, "#M10c");
3319 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M10d");
3320 Assert.IsFalse (ctor is ConstructorBuilder, "#M10e");
3322 ctor = redType.GetConstructor (flags, null,
3323 new Type [] { typeof (int) },
3324 new ParameterModifier [0]);
3325 Assert.IsNotNull (ctor, "#M11a");
3326 Assert.IsTrue (ctor.IsFamilyOrAssembly, "#M11b");
3327 Assert.IsFalse (ctor.IsStatic, "#M11c");
3328 Assert.AreEqual (1, ctor.GetParameters ().Length, "#M11d");
3329 Assert.IsFalse (ctor is ConstructorBuilder, "#M11e");
3331 ctor = redType.GetConstructor (flags, null,
3332 new Type [] { typeof (int), typeof (bool) },
3333 new ParameterModifier [0]);
3334 Assert.IsNotNull (ctor, "#M12a");
3335 Assert.IsTrue (ctor.IsPublic, "#M12b");
3336 Assert.IsFalse (ctor.IsStatic, "#M12c");
3337 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M12d");
3338 Assert.IsFalse (ctor is ConstructorBuilder, "#M12e");
3340 ctor = redType.GetConstructor (flags, null,
3341 new Type [] { typeof (string), typeof (int) },
3342 new ParameterModifier [0]);
3343 Assert.IsNotNull (ctor, "#M13a");
3344 Assert.IsTrue (ctor.IsAssembly, "#M13b");
3345 Assert.IsFalse (ctor.IsStatic, "#M13c");
3346 Assert.AreEqual (2, ctor.GetParameters ().Length, "#M13d");
3347 Assert.IsFalse (ctor is ConstructorBuilder, "#M13e");
3349 ctor = redType.GetConstructor (flags, null,
3351 new ParameterModifier [0]);
3352 Assert.IsNull (ctor, "#M14");
3354 flags = BindingFlags.Static | BindingFlags.NonPublic |
3355 BindingFlags.Public;
3357 ctor = greenType.GetConstructor (flags, null,
3358 new Type [] { typeof (int), typeof (int) },
3359 new ParameterModifier [0]);
3360 Assert.IsNull (ctor, "#N1");
3362 ctor = greenType.GetConstructor (flags, null,
3363 new Type [] { typeof (string) },
3364 new ParameterModifier [0]);
3365 Assert.IsNull (ctor, "#N2");
3367 ctor = greenType.GetConstructor (flags, null,
3368 new Type [] { typeof (string), typeof (string) },
3369 new ParameterModifier [0]);
3370 Assert.IsNull (ctor, "#N3");
3372 ctor = greenType.GetConstructor (flags, null,
3373 new Type [] { typeof (int) },
3374 new ParameterModifier [0]);
3375 Assert.IsNull (ctor, "#N4");
3377 ctor = greenType.GetConstructor (flags, null,
3378 new Type [] { typeof (int), typeof (bool) },
3379 new ParameterModifier [0]);
3380 Assert.IsNull (ctor, "#N5");
3382 ctor = greenType.GetConstructor (flags, null,
3383 new Type [] { typeof (string), typeof (int) },
3384 new ParameterModifier [0]);
3385 Assert.IsNull (ctor, "#N6");
3387 ctor = greenType.GetConstructor (flags, null,
3389 new ParameterModifier [0]);
3390 Assert.IsNull (ctor, "#N7");
3392 ctor = redType.GetConstructor (flags, null,
3393 new Type [] { typeof (int), typeof (int) },
3394 new ParameterModifier [0]);
3395 Assert.IsNull (ctor, "#N8");
3397 ctor = redType.GetConstructor (flags, null,
3398 new Type [] { typeof (string) },
3399 new ParameterModifier [0]);
3400 Assert.IsNull (ctor, "#N9");
3402 ctor = redType.GetConstructor (flags, null,
3403 new Type [] { typeof (string), typeof (string) },
3404 new ParameterModifier [0]);
3405 Assert.IsNull (ctor, "#N10");
3407 ctor = redType.GetConstructor (flags, null,
3408 new Type [] { typeof (int) },
3409 new ParameterModifier [0]);
3410 Assert.IsNull (ctor, "#N11");
3412 ctor = redType.GetConstructor (flags, null,
3413 new Type [] { typeof (int), typeof (bool) },
3414 new ParameterModifier [0]);
3415 Assert.IsNull (ctor, "#N12");
3417 ctor = redType.GetConstructor (flags, null,
3418 new Type [] { typeof (string), typeof (int) },
3419 new ParameterModifier [0]);
3420 Assert.IsNull (ctor, "#N13");
3422 ctor = redType.GetConstructor (flags, null,
3424 new ParameterModifier [0]);
3425 Assert.IsNotNull (ctor, "#N14a");
3426 Assert.IsTrue (ctor.IsPrivate, "#N14b");
3427 Assert.IsTrue (ctor.IsStatic, "#N14c");
3428 Assert.AreEqual (0, ctor.GetParameters ().Length, "#N14d");
3429 Assert.IsFalse (ctor is ConstructorBuilder, "#N14e");
3432 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
3433 public void GetConstructor2_Incomplete ()
3435 TypeBuilder tb = module.DefineType (genTypeName ());
3436 ConstructorBuilder cb = tb.DefineConstructor (
3437 MethodAttributes.Public,
3438 CallingConventions.Standard,
3440 cb.GetILGenerator ().Emit (OpCodes.Ret);
3443 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3444 null, Type.EmptyTypes, new ParameterModifier [0]);
3446 } catch (NotSupportedException ex) {
3447 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3448 Assert.IsNull (ex.InnerException, "#3");
3449 Assert.IsNotNull (ex.Message, "#4");
3453 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
3454 public void GetConstructor3_Incomplete ()
3456 TypeBuilder tb = module.DefineType (genTypeName ());
3457 ConstructorBuilder cb = tb.DefineConstructor (
3458 MethodAttributes.Public,
3459 CallingConventions.Standard,
3461 cb.GetILGenerator ().Emit (OpCodes.Ret);
3464 tb.GetConstructor (BindingFlags.Public | BindingFlags.Instance,
3465 null, CallingConventions.Standard, Type.EmptyTypes,
3466 new ParameterModifier [0]);
3468 } catch (NotSupportedException ex) {
3469 // The invoked member is not supported in a
3471 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3472 Assert.IsNull (ex.InnerException, "#3");
3473 Assert.IsNotNull (ex.Message, "#4");
3477 [Test] // GetConstructors ()
3478 [Category ("NotWorking")] // mcs depends on this
3479 public void GetConstructors1_Incomplete ()
3481 TypeBuilder tb = module.DefineType (genTypeName ());
3482 ConstructorBuilder cb = tb.DefineConstructor (
3483 MethodAttributes.Public,
3484 CallingConventions.Standard,
3486 cb.GetILGenerator ().Emit (OpCodes.Ret);
3489 tb.GetConstructors ();
3491 } catch (NotSupportedException ex) {
3492 // The invoked member is not supported in a
3494 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3495 Assert.IsNull (ex.InnerException, "#3");
3496 Assert.IsNotNull (ex.Message, "#4");
3500 [Test] // GetConstructors (BindingFlags)
3501 public void GetConstructors2_Complete ()
3504 ConstructorInfo [] ctors;
3506 TypeBuilder redType = module.DefineType (genTypeName (),
3507 TypeAttributes.Public);
3508 CreateMembers (redType, "Red", true);
3510 TypeBuilder greenType = module.DefineType (genTypeName (),
3511 TypeAttributes.Public, redType);
3512 CreateMembers (greenType, "Green", false);
3513 ConstructorBuilder cb = greenType.DefineConstructor (
3514 MethodAttributes.Public,
3515 CallingConventions.Standard,
3517 cb.GetILGenerator ().Emit (OpCodes.Ret);
3519 redType.CreateType ();
3520 greenType.CreateType ();
3522 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3524 ctors = greenType.GetConstructors (flags);
3525 Assert.AreEqual (0, ctors.Length, "#A1");
3527 ctors = redType.GetConstructors (flags);
3528 Assert.AreEqual (5, ctors.Length, "#A2");
3529 Assert.IsTrue (ctors [0].IsPrivate, "#A3a");
3530 Assert.IsFalse (ctors [0].IsStatic, "#A3b");
3531 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#A3c");
3532 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#A3d");
3533 Assert.IsTrue (ctors [1].IsFamily, "#A4a");
3534 Assert.IsFalse (ctors [1].IsStatic, "#A4b");
3535 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#A4c");
3536 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#A4d");
3537 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#A5a");
3538 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3539 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#A5c");
3540 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#A5d");
3541 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#A6a");
3542 Assert.IsFalse (ctors [3].IsStatic, "#A6b");
3543 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#A6c");
3544 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#A6d");
3545 Assert.IsTrue (ctors [4].IsAssembly, "#A7a");
3546 Assert.IsFalse (ctors [4].IsStatic, "#A7b");
3547 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#A7c");
3548 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#A7d");
3550 flags = BindingFlags.Instance | BindingFlags.Public;
3552 ctors = greenType.GetConstructors (flags);
3553 Assert.AreEqual (1, ctors.Length, "#B1");
3554 Assert.IsTrue (ctors [0].IsPublic, "#B2a");
3555 Assert.IsFalse (ctors [0].IsStatic, "#B2b");
3556 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#B2c");
3557 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B2d");
3559 ctors = redType.GetConstructors (flags);
3560 Assert.AreEqual (1, ctors.Length, "#B3");
3561 Assert.IsTrue (ctors [0].IsPublic, "#B4a");
3562 Assert.IsFalse (ctors [0].IsStatic, "#B4b");
3563 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#B4c");
3564 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#B4d");
3566 flags = BindingFlags.Static | BindingFlags.Public;
3568 ctors = greenType.GetConstructors (flags);
3569 Assert.AreEqual (0, ctors.Length, "#C1");
3571 ctors = redType.GetConstructors (flags);
3572 Assert.AreEqual (0, ctors.Length, "#C2");
3574 flags = BindingFlags.Static | BindingFlags.NonPublic;
3576 ctors = greenType.GetConstructors (flags);
3577 Assert.AreEqual (0, ctors.Length, "#D1");
3579 ctors = redType.GetConstructors (flags);
3580 Assert.AreEqual (1, ctors.Length, "#D2");
3581 Assert.IsTrue (ctors [0].IsPrivate, "#D3a");
3582 Assert.IsTrue (ctors [0].IsStatic, "#D3b");
3583 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#D3c");
3584 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#D3d");
3586 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3587 BindingFlags.FlattenHierarchy;
3589 ctors = greenType.GetConstructors (flags);
3590 Assert.AreEqual (0, ctors.Length, "#E1");
3592 ctors = redType.GetConstructors (flags);
3593 Assert.AreEqual (5, ctors.Length, "#E2");
3594 Assert.IsTrue (ctors [0].IsPrivate, "#E3a");
3595 Assert.IsFalse (ctors [0].IsStatic, "#E3b");
3596 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#E3c");
3597 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#E3d");
3598 Assert.IsTrue (ctors [1].IsFamily, "#E4a");
3599 Assert.IsFalse (ctors [1].IsStatic, "#E4b");
3600 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#E4c");
3601 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#E4d");
3602 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#E5a");
3603 Assert.IsFalse (ctors [2].IsStatic, "#A5b");
3604 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#E5c");
3605 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#E5d");
3606 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#E6a");
3607 Assert.IsFalse (ctors [3].IsStatic, "#E6b");
3608 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#E6c");
3609 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#E6d");
3610 Assert.IsTrue (ctors [4].IsAssembly, "#E7a");
3611 Assert.IsFalse (ctors [4].IsStatic, "#E7b");
3612 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#E7c");
3613 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#E7d");
3615 flags = BindingFlags.Instance | BindingFlags.Public |
3616 BindingFlags.FlattenHierarchy;
3618 ctors = greenType.GetConstructors (flags);
3619 Assert.AreEqual (1, ctors.Length, "#F1");
3620 Assert.IsTrue (ctors [0].IsPublic, "#F2a");
3621 Assert.IsFalse (ctors [0].IsStatic, "#F2b");
3622 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#F2c");
3623 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F2d");
3625 ctors = redType.GetConstructors (flags);
3626 Assert.AreEqual (1, ctors.Length, "#F3");
3627 Assert.IsTrue (ctors [0].IsPublic, "#F4a");
3628 Assert.IsFalse (ctors [0].IsStatic, "#F4b");
3629 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#F4c");
3630 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#F4d");
3632 flags = BindingFlags.Static | BindingFlags.Public |
3633 BindingFlags.FlattenHierarchy;
3635 ctors = greenType.GetConstructors (flags);
3636 Assert.AreEqual (0, ctors.Length, "#G1");
3638 ctors = redType.GetConstructors (flags);
3639 Assert.AreEqual (0, ctors.Length, "#G2");
3641 flags = BindingFlags.Static | BindingFlags.NonPublic |
3642 BindingFlags.FlattenHierarchy;
3644 ctors = greenType.GetConstructors (flags);
3645 Assert.AreEqual (0, ctors.Length, "#H1");
3647 ctors = redType.GetConstructors (flags);
3648 Assert.AreEqual (1, ctors.Length, "#H2");
3649 Assert.IsTrue (ctors [0].IsPrivate, "#H3a");
3650 Assert.IsTrue (ctors [0].IsStatic, "#H3b");
3651 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#H3c");
3652 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#H3d");
3654 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3655 BindingFlags.DeclaredOnly;
3657 ctors = greenType.GetConstructors (flags);
3658 Assert.AreEqual (0, ctors.Length, "#I1");
3660 ctors = redType.GetConstructors (flags);
3661 Assert.AreEqual (5, ctors.Length, "#I2");
3662 Assert.IsTrue (ctors [0].IsPrivate, "#I3a");
3663 Assert.IsFalse (ctors [0].IsStatic, "#I3b");
3664 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#I3c");
3665 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#I3d");
3666 Assert.IsTrue (ctors [1].IsFamily, "#I4a");
3667 Assert.IsFalse (ctors [1].IsStatic, "#I4b");
3668 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#I4c");
3669 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#I4d");
3670 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#I5a");
3671 Assert.IsFalse (ctors [2].IsStatic, "#I5b");
3672 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#I5c");
3673 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#I5d");
3674 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#I6a");
3675 Assert.IsFalse (ctors [3].IsStatic, "#I6b");
3676 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#I6c");
3677 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#I6d");
3678 Assert.IsTrue (ctors [4].IsAssembly, "#I7a");
3679 Assert.IsFalse (ctors [4].IsStatic, "#I7b");
3680 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#I7c");
3681 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#I7d");
3683 flags = BindingFlags.Instance | BindingFlags.Public |
3684 BindingFlags.DeclaredOnly;
3686 ctors = greenType.GetConstructors (flags);
3687 Assert.AreEqual (1, ctors.Length, "#J1");
3688 Assert.IsTrue (ctors [0].IsPublic, "#J2a");
3689 Assert.IsFalse (ctors [0].IsStatic, "#J2b");
3690 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#J2c");
3691 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J2d");
3693 ctors = redType.GetConstructors (flags);
3694 Assert.AreEqual (1, ctors.Length, "#J3");
3695 Assert.IsTrue (ctors [0].IsPublic, "#J4a");
3696 Assert.IsFalse (ctors [0].IsStatic, "#J4b");
3697 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#J4c");
3698 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#J4d");
3700 flags = BindingFlags.Static | BindingFlags.Public |
3701 BindingFlags.DeclaredOnly;
3703 ctors = greenType.GetConstructors (flags);
3704 Assert.AreEqual (0, ctors.Length, "#K1");
3706 ctors = redType.GetConstructors (flags);
3707 Assert.AreEqual (0, ctors.Length, "#K2");
3709 flags = BindingFlags.Static | BindingFlags.NonPublic |
3710 BindingFlags.DeclaredOnly;
3712 ctors = greenType.GetConstructors (flags);
3713 Assert.AreEqual (0, ctors.Length, "#L1");
3715 ctors = redType.GetConstructors (flags);
3716 Assert.AreEqual (1, ctors.Length, "#L2");
3717 Assert.IsTrue (ctors [0].IsPrivate, "#L3a");
3718 Assert.IsTrue (ctors [0].IsStatic, "#L3b");
3719 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#L3c");
3720 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#L3d");
3722 flags = BindingFlags.Instance | BindingFlags.NonPublic |
3723 BindingFlags.Public;
3725 ctors = greenType.GetConstructors (flags);
3726 Assert.AreEqual (1, ctors.Length, "#M1");
3727 Assert.IsTrue (ctors [0].IsPublic, "#M2a");
3728 Assert.IsFalse (ctors [0].IsStatic, "#M2b");
3729 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#M2c");
3730 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M2d");
3732 ctors = redType.GetConstructors (flags);
3733 Assert.AreEqual (6, ctors.Length, "#M3");
3734 Assert.IsTrue (ctors [0].IsPrivate, "#M4a");
3735 Assert.IsFalse (ctors [0].IsStatic, "#M4b");
3736 Assert.AreEqual (2, ctors [0].GetParameters ().Length, "#M4c");
3737 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#M4d");
3738 Assert.IsTrue (ctors [1].IsFamily, "#M5a");
3739 Assert.IsFalse (ctors [1].IsStatic, "#M5b");
3740 Assert.AreEqual (1, ctors [1].GetParameters ().Length, "#M5c");
3741 Assert.IsFalse (ctors [1] is ConstructorBuilder, "#M5d");
3742 Assert.IsTrue (ctors [2].IsFamilyAndAssembly, "#M6a");
3743 Assert.IsFalse (ctors [2].IsStatic, "#M6b");
3744 Assert.AreEqual (2, ctors [2].GetParameters ().Length, "#M6c");
3745 Assert.IsFalse (ctors [2] is ConstructorBuilder, "#M6d");
3746 Assert.IsTrue (ctors [3].IsFamilyOrAssembly, "#M7a");
3747 Assert.IsFalse (ctors [3].IsStatic, "#M7b");
3748 Assert.AreEqual (1, ctors [3].GetParameters ().Length, "#M7c");
3749 Assert.IsFalse (ctors [3] is ConstructorBuilder, "#M7d");
3750 Assert.IsTrue (ctors [4].IsPublic, "#M8a");
3751 Assert.IsFalse (ctors [4].IsStatic, "#M8b");
3752 Assert.AreEqual (2, ctors [4].GetParameters ().Length, "#M8c");
3753 Assert.IsFalse (ctors [4] is ConstructorBuilder, "#M8d");
3754 Assert.IsTrue (ctors [5].IsAssembly, "#M9a");
3755 Assert.IsFalse (ctors [5].IsStatic, "#M9b");
3756 Assert.AreEqual (2, ctors [5].GetParameters ().Length, "#M9c");
3757 Assert.IsFalse (ctors [5] is ConstructorBuilder, "#M9d");
3759 flags = BindingFlags.Static | BindingFlags.NonPublic |
3760 BindingFlags.Public;
3762 ctors = greenType.GetConstructors (flags);
3763 Assert.AreEqual (0, ctors.Length, "#N1");
3765 ctors = redType.GetConstructors (flags);
3766 Assert.AreEqual (1, ctors.Length, "#N2");
3767 Assert.IsTrue (ctors [0].IsPrivate, "#N3a");
3768 Assert.IsTrue (ctors [0].IsStatic, "#N3b");
3769 Assert.AreEqual (0, ctors [0].GetParameters ().Length, "#N3c");
3770 Assert.IsFalse (ctors [0] is ConstructorBuilder, "#N3d");
3773 [Test] // GetConstructors (BindingFlags)
3774 [Category ("NotWorking")] // mcs depends on this
3775 public void GetConstructors2_Incomplete ()
3777 TypeBuilder tb = module.DefineType (genTypeName ());
3778 ConstructorBuilder cb = tb.DefineConstructor (
3779 MethodAttributes.Public,
3780 CallingConventions.Standard,
3782 cb.GetILGenerator ().Emit (OpCodes.Ret);
3785 tb.GetConstructors (BindingFlags.Public |
3786 BindingFlags.Instance);
3788 } catch (NotSupportedException ex) {
3789 // The invoked member is not supported in a
3791 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3792 Assert.IsNull (ex.InnerException, "#3");
3793 Assert.IsNotNull (ex.Message, "#4");
3798 public void TestGetCustomAttributesIncomplete ()
3800 TypeBuilder tb = module.DefineType (genTypeName ());
3802 tb.GetCustomAttributes (false);
3804 } catch (NotSupportedException ex) {
3805 // The invoked member is not supported in a
3807 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3808 Assert.IsNull (ex.InnerException, "#3");
3809 Assert.IsNotNull (ex.Message, "#4");
3814 public void TestGetCustomAttributesComplete ()
3816 TypeBuilder tb = module.DefineType (genTypeName ());
3818 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3819 new Type [] { typeof (string) });
3821 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3822 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3824 tb.SetCustomAttribute (caBuilder);
3827 Assert.AreEqual (1, tb.GetCustomAttributes (false).Length);
3831 public void TestGetCustomAttributesOfTypeIncomplete ()
3833 TypeBuilder tb = module.DefineType (genTypeName ());
3835 tb.GetCustomAttributes (typeof (ObsoleteAttribute), false);
3837 } catch (NotSupportedException ex) {
3838 // The invoked member is not supported in a
3840 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3841 Assert.IsNull (ex.InnerException, "#3");
3842 Assert.IsNotNull (ex.Message, "#4");
3847 public void TestGetCustomAttributesOfTypeComplete ()
3849 TypeBuilder tb = module.DefineType (genTypeName ());
3851 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
3852 new Type [] { typeof (string) });
3854 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
3855 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
3857 tb.SetCustomAttribute (caBuilder);
3860 Assert.AreEqual (1, tb.GetCustomAttributes (typeof (GuidAttribute), false).Length, "#1");
3861 Assert.AreEqual (0, tb.GetCustomAttributes (typeof (ObsoleteAttribute), false).Length, "#2");
3865 public void TestGetCustomAttributesOfNullTypeComplete ()
3867 TypeBuilder tb = module.DefineType (genTypeName ());
3870 tb.GetCustomAttributes (null, false);
3872 } catch (ArgumentNullException ex) {
3873 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
3874 Assert.IsNull (ex.InnerException, "#3");
3875 Assert.IsNotNull (ex.Message, "#4");
3876 Assert.AreEqual ("attributeType", ex.ParamName, "#5");
3881 [Ignore ("mcs depends on this")]
3882 public void TestGetEventsIncomplete ()
3884 TypeBuilder tb = module.DefineType (genTypeName ());
3888 } catch (NotSupportedException ex) {
3889 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3890 Assert.IsNull (ex.InnerException, "#3");
3891 Assert.IsNotNull (ex.Message, "#4");
3897 public void TestGetEventsComplete ()
3899 TypeBuilder tb = module.DefineType (genTypeName ());
3901 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3902 typeof (void), new Type [] { typeof (Object) });
3903 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
3905 // create public event
3906 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
3907 typeof (ResolveEventHandler));
3908 eventbuilder.SetRaiseMethod (onclickMethod);
3910 Type emittedType = tb.CreateType ();
3912 Assert.AreEqual (1, tb.GetEvents ().Length, "#1");
3913 Assert.AreEqual (tb.GetEvents ().Length, emittedType.GetEvents ().Length, "#2");
3918 [Ignore ("mcs depends on this")]
3919 public void TestGetEventsFlagsIncomplete ()
3921 TypeBuilder tb = module.DefineType (genTypeName ());
3923 tb.GetEvents (BindingFlags.Public);
3925 } catch (NotSupportedException ex) {
3926 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
3927 Assert.IsNull (ex.InnerException, "#3");
3928 Assert.IsNotNull (ex.Message, "#4");
3934 public void TestGetEventsFlagsComplete ()
3936 TypeBuilder tb = module.DefineType (genTypeName ());
3938 MethodBuilder onchangeMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
3939 typeof (void), new Type [] { typeof (Object) });
3940 onchangeMethod.GetILGenerator ().Emit (OpCodes.Ret);
3942 // create public event
3943 EventBuilder changeEvent = tb.DefineEvent ("Change", EventAttributes.None,
3944 typeof (ResolveEventHandler));
3945 changeEvent.SetRaiseMethod (onchangeMethod);
3947 // create non-public event
3948 EventBuilder redoChangeEvent = tb.DefineEvent ("RedoChange", EventAttributes.None,
3949 typeof (ResolveEventHandler));
3951 Type emittedType = tb.CreateType ();
3953 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3954 Assert.AreEqual (1, tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3955 Assert.AreEqual (2, tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3956 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length,
3957 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public).Length);
3958 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length,
3959 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.NonPublic).Length);
3960 Assert.AreEqual (tb.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length,
3961 emittedType.GetEvents (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length);
3965 public void TestGetEventsFlagsComplete_Inheritance ()
3967 EventInfo [] events;
3970 TypeBuilder blueType = module.DefineType (genTypeName (),
3971 TypeAttributes.Public);
3972 CreateMembers (blueType, "Blue", false);
3974 TypeBuilder redType = module.DefineType (genTypeName (),
3975 TypeAttributes.Public, blueType);
3976 CreateMembers (redType, "Red", false);
3978 TypeBuilder greenType = module.DefineType (genTypeName (),
3979 TypeAttributes.Public, redType);
3980 CreateMembers (greenType, "Green", false);
3982 blueType.CreateType ();
3983 redType.CreateType ();
3984 greenType.CreateType ();
3986 flags = BindingFlags.Instance | BindingFlags.NonPublic;
3987 events = greenType.GetEvents (flags);
3989 Assert.AreEqual (13, events.Length, "#A1");
3990 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#A2");
3991 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#A3");
3992 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#A4");
3993 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#A5");
3994 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#A6");
3995 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#A7");
3996 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#A8");
3997 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#A9");
3998 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#A10");
3999 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#A11");
4000 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#A12");
4001 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#A13");
4002 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#A14");
4004 flags = BindingFlags.Instance | BindingFlags.Public;
4005 events = greenType.GetEvents (flags);
4007 Assert.AreEqual (3, events.Length, "#B1");
4008 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#B2");
4009 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#B3");
4010 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#B4");
4012 flags = BindingFlags.Static | BindingFlags.Public;
4013 events = greenType.GetEvents (flags);
4015 Assert.AreEqual (1, events.Length, "#C1");
4016 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#C2");
4018 flags = BindingFlags.Static | BindingFlags.NonPublic;
4019 events = greenType.GetEvents (flags);
4021 Assert.AreEqual (5, events.Length, "#D1");
4022 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#D2");
4023 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#D3");
4024 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#D4");
4025 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#D5");
4026 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#D6");
4028 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4029 BindingFlags.FlattenHierarchy;
4030 events = greenType.GetEvents (flags);
4032 Assert.AreEqual (13, events.Length, "#E1");
4033 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#E2");
4034 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#E3");
4035 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#E4");
4036 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#E5");
4037 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#E6");
4038 Assert.AreEqual ("OnFamilyInstanceRed", events [5].Name, "#E7");
4039 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [6].Name, "#E8");
4040 Assert.AreEqual ("OnFamORAssemInstanceRed", events [7].Name, "#E9");
4041 Assert.AreEqual ("OnAssemblyInstanceRed", events [8].Name, "#E10");
4042 Assert.AreEqual ("OnFamilyInstanceBlue", events [9].Name, "#E11");
4043 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [10].Name, "#E12");
4044 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [11].Name, "#E13");
4045 Assert.AreEqual ("OnAssemblyInstanceBlue", events [12].Name, "#E14");
4047 flags = BindingFlags.Instance | BindingFlags.Public |
4048 BindingFlags.FlattenHierarchy;
4049 events = greenType.GetEvents (flags);
4051 Assert.AreEqual (3, events.Length, "#F1");
4052 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#F2");
4053 Assert.AreEqual ("OnPublicInstanceRed", events [1].Name, "#F3");
4054 Assert.AreEqual ("OnPublicInstanceBlue", events [2].Name, "#F4");
4056 flags = BindingFlags.Static | BindingFlags.Public |
4057 BindingFlags.FlattenHierarchy;
4058 events = greenType.GetEvents (flags);
4060 Assert.AreEqual (3, events.Length, "#G1");
4061 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#G2");
4062 Assert.AreEqual ("OnPublicStaticRed", events [1].Name, "#G3");
4063 Assert.AreEqual ("OnPublicStaticBlue", events [2].Name, "#G4");
4065 flags = BindingFlags.Static | BindingFlags.NonPublic |
4066 BindingFlags.FlattenHierarchy;
4067 events = greenType.GetEvents (flags);
4069 Assert.AreEqual (13, events.Length, "#H1");
4070 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#H2");
4071 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#H3");
4072 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#H4");
4073 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#H5");
4074 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#H6");
4075 Assert.AreEqual ("OnFamilyStaticRed", events [5].Name, "#H7");
4076 Assert.AreEqual ("OnFamANDAssemStaticRed", events [6].Name, "#H8");
4077 Assert.AreEqual ("OnFamORAssemStaticRed", events [7].Name, "#H9");
4078 Assert.AreEqual ("OnAssemblyStaticRed", events [8].Name, "#H10");
4079 Assert.AreEqual ("OnFamilyStaticBlue", events [9].Name, "#H11");
4080 Assert.AreEqual ("OnFamANDAssemStaticBlue", events [10].Name, "#H12");
4081 Assert.AreEqual ("OnFamORAssemStaticBlue", events [11].Name, "#H13");
4082 Assert.AreEqual ("OnAssemblyStaticBlue", events [12].Name, "#H14");
4084 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4085 BindingFlags.DeclaredOnly;
4086 events = greenType.GetEvents (flags);
4088 Assert.AreEqual (5, events.Length, "#I1");
4089 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#I2");
4090 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#I3");
4091 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#I4");
4092 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#I5");
4093 Assert.AreEqual ("OnAssemblyInstanceGreen", events [4].Name, "#I6");
4095 flags = BindingFlags.Instance | BindingFlags.Public |
4096 BindingFlags.DeclaredOnly;
4097 events = greenType.GetEvents (flags);
4099 Assert.AreEqual (1, events.Length, "#J1");
4100 Assert.AreEqual ("OnPublicInstanceGreen", events [0].Name, "#J2");
4102 flags = BindingFlags.Static | BindingFlags.Public |
4103 BindingFlags.DeclaredOnly;
4104 events = greenType.GetEvents (flags);
4106 Assert.AreEqual (1, events.Length, "#K1");
4107 Assert.AreEqual ("OnPublicStaticGreen", events [0].Name, "#K2");
4109 flags = BindingFlags.Static | BindingFlags.NonPublic |
4110 BindingFlags.DeclaredOnly;
4111 events = greenType.GetEvents (flags);
4113 Assert.AreEqual (5, events.Length, "#L1");
4114 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#L2");
4115 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#L3");
4116 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#L4");
4117 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#L5");
4118 Assert.AreEqual ("OnAssemblyStaticGreen", events [4].Name, "#L6");
4120 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4121 BindingFlags.Public;
4122 events = greenType.GetEvents (flags);
4124 Assert.AreEqual (16, events.Length, "#M1");
4125 Assert.AreEqual ("OnPrivateInstanceGreen", events [0].Name, "#M2");
4126 Assert.AreEqual ("OnFamilyInstanceGreen", events [1].Name, "#M3");
4127 Assert.AreEqual ("OnFamANDAssemInstanceGreen", events [2].Name, "#M4");
4128 Assert.AreEqual ("OnFamORAssemInstanceGreen", events [3].Name, "#M5");
4129 Assert.AreEqual ("OnPublicInstanceGreen", events [4].Name, "#M6");
4130 Assert.AreEqual ("OnAssemblyInstanceGreen", events [5].Name, "#M7");
4131 Assert.AreEqual ("OnFamilyInstanceRed", events [6].Name, "#M8");
4132 Assert.AreEqual ("OnFamANDAssemInstanceRed", events [7].Name, "#M9");
4133 Assert.AreEqual ("OnFamORAssemInstanceRed", events [8].Name, "#M10");
4134 Assert.AreEqual ("OnPublicInstanceRed", events [9].Name, "#M11");
4135 Assert.AreEqual ("OnAssemblyInstanceRed", events [10].Name, "#M12");
4136 Assert.AreEqual ("OnFamilyInstanceBlue", events [11].Name, "#M13");
4137 Assert.AreEqual ("OnFamANDAssemInstanceBlue", events [12].Name, "#M14");
4138 Assert.AreEqual ("OnFamORAssemInstanceBlue", events [13].Name, "#M15");
4139 Assert.AreEqual ("OnPublicInstanceBlue", events [14].Name, "#M16");
4140 Assert.AreEqual ("OnAssemblyInstanceBlue", events [15].Name, "#M17");
4142 flags = BindingFlags.Static | BindingFlags.NonPublic |
4143 BindingFlags.Public;
4144 events = greenType.GetEvents (flags);
4146 Assert.AreEqual (6, events.Length, "#N1");
4147 Assert.AreEqual ("OnPrivateStaticGreen", events [0].Name, "#N2");
4148 Assert.AreEqual ("OnFamilyStaticGreen", events [1].Name, "#N3");
4149 Assert.AreEqual ("OnFamANDAssemStaticGreen", events [2].Name, "#N4");
4150 Assert.AreEqual ("OnFamORAssemStaticGreen", events [3].Name, "#N5");
4151 Assert.AreEqual ("OnPublicStaticGreen", events [4].Name, "#N6");
4152 Assert.AreEqual ("OnAssemblyStaticGreen", events [5].Name, "#N7");
4156 [Ignore ("mcs depends on this")]
4157 public void TestGetEventIncomplete ()
4159 TypeBuilder tb = module.DefineType (genTypeName ());
4161 tb.GetEvent ("FOO");
4163 } catch (NotSupportedException ex) {
4164 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4165 Assert.IsNull (ex.InnerException, "#3");
4166 Assert.IsNotNull (ex.Message, "#4");
4172 public void TestGetEventComplete ()
4174 TypeBuilder tb = module.DefineType (genTypeName ());
4176 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4177 typeof (void), new Type [] { typeof (Object) });
4178 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4180 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4181 typeof (ResolveEventHandler));
4182 eventbuilder.SetRaiseMethod (onclickMethod);
4184 Type emittedType = tb.CreateType ();
4186 Assert.IsNotNull (tb.GetEvent ("Change"));
4187 Assert.AreEqual (tb.GetEvent ("Change"), emittedType.GetEvent ("Change"));
4188 Assert.IsNull (tb.GetEvent ("NotChange"));
4189 Assert.AreEqual (tb.GetEvent ("NotChange"), emittedType.GetEvent ("NotChange"));
4193 [Ignore ("mcs depends on this")]
4194 public void TestGetEventFlagsIncomplete ()
4196 TypeBuilder tb = module.DefineType (genTypeName ());
4198 tb.GetEvent ("FOO", BindingFlags.Public);
4200 } catch (NotSupportedException ex) {
4201 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4202 Assert.IsNull (ex.InnerException, "#3");
4203 Assert.IsNotNull (ex.Message, "#4");
4209 public void TestGetEventFlagsComplete ()
4211 TypeBuilder tb = module.DefineType (genTypeName ());
4213 MethodBuilder onclickMethod = tb.DefineMethod ("OnChange", MethodAttributes.Public,
4214 typeof (void), new Type [] { typeof (Object) });
4215 onclickMethod.GetILGenerator ().Emit (OpCodes.Ret);
4217 EventBuilder eventbuilder = tb.DefineEvent ("Change", EventAttributes.None,
4218 typeof (ResolveEventHandler));
4219 eventbuilder.SetRaiseMethod (onclickMethod);
4221 Type emittedType = tb.CreateType ();
4223 Assert.IsNotNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4224 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public),
4225 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.Public));
4226 Assert.IsNull (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4227 Assert.AreEqual (tb.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic),
4228 emittedType.GetEvent ("Change", BindingFlags.Instance | BindingFlags.NonPublic));
4232 public void TestGetEventFlagsComplete_Inheritance ()
4236 TypeBuilder blueType = module.DefineType (genTypeName (),
4237 TypeAttributes.Public);
4238 CreateMembers (blueType, "Blue", false);
4240 TypeBuilder redType = module.DefineType (genTypeName (),
4241 TypeAttributes.Public, blueType);
4242 CreateMembers (redType, "Red", false);
4244 TypeBuilder greenType = module.DefineType (genTypeName (),
4245 TypeAttributes.Public, redType);
4246 CreateMembers (greenType, "Green", false);
4248 blueType.CreateType ();
4249 redType.CreateType ();
4250 greenType.CreateType ();
4252 flags = BindingFlags.Instance | BindingFlags.NonPublic;
4254 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#A1");
4255 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#A2");
4256 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#A3");
4257 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#A4");
4258 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#A5");
4259 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#A6");
4260 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#A7");
4261 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#A8");
4262 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#A9");
4263 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#A10");
4264 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#A11");
4265 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#A12");
4266 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#A13");
4267 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#A14");
4268 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#A15");
4269 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#A16");
4270 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#A17");
4271 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#A18");
4272 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#A19");
4273 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#A20");
4274 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#A21");
4275 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#A22");
4276 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#A23");
4277 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#A24");
4278 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#A25");
4279 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#A26");
4280 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#A27");
4281 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#A28");
4282 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#A29");
4283 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#A30");
4284 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#A31");
4285 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#A32");
4286 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#A33");
4287 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#A34");
4288 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#A35");
4289 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#A36");
4291 flags = BindingFlags.Instance | BindingFlags.Public;
4293 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#B1");
4294 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#B2");
4295 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#B3");
4296 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#B4");
4297 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#B5");
4298 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#B6");
4299 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#B7");
4300 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#B8");
4301 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#B9");
4302 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#B10");
4303 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#B11");
4304 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#B12");
4305 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#B13");
4306 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#B14");
4307 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#B15");
4308 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#B16");
4309 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#B17");
4310 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#B18");
4311 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#B19");
4312 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#B20");
4313 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#B21");
4314 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#B22");
4315 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#B23");
4316 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#B24");
4317 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#B25");
4318 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#B26");
4319 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#B27");
4320 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#B28");
4321 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#B29");
4322 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#B30");
4323 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#B31");
4324 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#B32");
4325 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#B33");
4326 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#B34");
4327 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#B35");
4328 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#B36");
4330 flags = BindingFlags.Static | BindingFlags.Public;
4332 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#C1");
4333 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#C2");
4334 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#C3");
4335 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#C4");
4336 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#C5");
4337 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#C6");
4338 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#C7");
4339 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#C8");
4340 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#C9");
4341 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#C10");
4342 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#C11");
4343 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#C12");
4344 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#C13");
4345 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#C14");
4346 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#C15");
4347 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#C16");
4348 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#C17");
4349 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#C18");
4350 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#C19");
4351 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#C20");
4352 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#C21");
4353 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#C22");
4354 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#C23");
4355 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#C24");
4356 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#C25");
4357 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#C26");
4358 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#C27");
4359 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#C28");
4360 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#C29");
4361 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#C30");
4362 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#C31");
4363 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#C32");
4364 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#C33");
4365 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#C34");
4366 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#C35");
4367 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#C36");
4369 flags = BindingFlags.Static | BindingFlags.NonPublic;
4371 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#D1");
4372 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#D2");
4373 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#D3");
4374 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#D4");
4375 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#D5");
4376 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#D6");
4377 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#D7");
4378 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#D8");
4379 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#D9");
4380 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#D10");
4381 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#D11");
4382 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#D12");
4383 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#D13");
4384 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#D14");
4385 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#D15");
4386 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#D16");
4387 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#D17");
4388 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#D18");
4389 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#D19");
4390 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#D20");
4391 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#D21");
4392 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#D22");
4393 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#D23");
4394 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#D24");
4395 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#D25");
4396 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#D26");
4397 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#D27");
4398 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#D28");
4399 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#D29");
4400 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#D30");
4401 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#D31");
4402 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#D32");
4403 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#D33");
4404 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#D34");
4405 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#D35");
4406 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#D36");
4408 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4409 BindingFlags.FlattenHierarchy;
4411 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#E1");
4412 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#E2");
4413 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#E3");
4414 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#E4");
4415 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#E5");
4416 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#E6");
4417 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#E7");
4418 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#E8");
4419 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#E9");
4420 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#E10");
4421 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#E11");
4422 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#E12");
4423 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#E13");
4424 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#E14");
4425 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#E15");
4426 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#E16");
4427 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#E17");
4428 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#E18");
4429 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#E19");
4430 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#E20");
4431 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#E21");
4432 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#E22");
4433 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#E23");
4434 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#E24");
4435 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#E25");
4436 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#E26");
4437 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#E27");
4438 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#E28");
4439 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#E29");
4440 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#E30");
4441 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#E31");
4442 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#E32");
4443 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#E33");
4444 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#E34");
4445 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#E35");
4446 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#E36");
4448 flags = BindingFlags.Instance | BindingFlags.Public |
4449 BindingFlags.FlattenHierarchy;
4451 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#F1");
4452 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#F2");
4453 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#F3");
4454 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#F4");
4455 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#F5");
4456 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#F6");
4457 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#F7");
4458 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#F8");
4459 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#F9");
4460 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#F10");
4461 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#F11");
4462 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#F12");
4463 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#F13");
4464 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#F14");
4465 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#F15");
4466 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#F16");
4467 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#F17");
4468 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#F18");
4469 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#F19");
4470 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#F20");
4471 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#F21");
4472 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#F22");
4473 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#F23");
4474 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#F24");
4475 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#F25");
4476 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#F26");
4477 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#F27");
4478 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#F28");
4479 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#F29");
4480 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#F30");
4481 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#F31");
4482 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#F32");
4483 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#F33");
4484 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#F34");
4485 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#F35");
4486 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#F36");
4488 flags = BindingFlags.Static | BindingFlags.Public |
4489 BindingFlags.FlattenHierarchy;
4491 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#G1");
4492 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#G2");
4493 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#G3");
4494 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#G4");
4495 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#G5");
4496 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#G6");
4497 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#G7");
4498 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#G8");
4499 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#G9");
4500 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#G10");
4501 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#G11");
4502 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#G12");
4503 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#G13");
4504 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#G14");
4505 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#G15");
4506 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#G16");
4507 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#G17");
4508 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#G18");
4509 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#G19");
4510 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#G20");
4511 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#G21");
4512 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#G22");
4513 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#G23");
4514 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#G24");
4515 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#G25");
4516 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#G26");
4517 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#G27");
4518 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#G28");
4519 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#G29");
4520 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#G30");
4521 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#G31");
4522 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#G32");
4523 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#G33");
4524 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#G34");
4525 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#G35");
4526 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#G36");
4528 flags = BindingFlags.Static | BindingFlags.NonPublic |
4529 BindingFlags.FlattenHierarchy;
4531 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#H1");
4532 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#H2");
4533 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#H3");
4534 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#H4");
4535 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#H5");
4536 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#H6");
4537 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#H7");
4538 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#H8");
4539 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#H9");
4540 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#H10");
4541 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#H11");
4542 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#H12");
4543 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#H13");
4544 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#H14");
4545 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#H15");
4546 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#H16");
4547 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#H17");
4548 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#H18");
4549 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#H19");
4550 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#H20");
4551 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#H21");
4552 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#H22");
4553 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#H23");
4554 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#H24");
4555 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#H25");
4556 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#H26");
4557 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#H27");
4558 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#H28");
4559 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#H29");
4560 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#H30");
4561 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#H31");
4562 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#H32");
4563 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#H33");
4564 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#H34");
4565 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#H35");
4566 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#H36");
4568 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4569 BindingFlags.DeclaredOnly;
4571 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#I1");
4572 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#I2");
4573 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#I3");
4574 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#I4");
4575 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#I5");
4576 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#I6");
4577 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#I7");
4578 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#I8");
4579 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#I9");
4580 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#I10");
4581 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#I11");
4582 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#I12");
4583 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#I13");
4584 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#I14");
4585 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#I15");
4586 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#I16");
4587 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#I17");
4588 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#I18");
4589 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#I19");
4590 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#I20");
4591 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#I21");
4592 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#I22");
4593 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#I23");
4594 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#I24");
4595 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#I25");
4596 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#I26");
4597 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#I27");
4598 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#I28");
4599 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#I29");
4600 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#I30");
4601 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#I31");
4602 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#I32");
4603 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#I33");
4604 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#I34");
4605 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#I35");
4606 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#I36");
4608 flags = BindingFlags.Instance | BindingFlags.Public |
4609 BindingFlags.DeclaredOnly;
4611 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#J1");
4612 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#J2");
4613 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#J3");
4614 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#J4");
4615 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#J5");
4616 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#J6");
4617 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#J7");
4618 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#J8");
4619 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#J9");
4620 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#J10");
4621 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#J11");
4622 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#J12");
4623 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#J13");
4624 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#J14");
4625 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#J15");
4626 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#J16");
4627 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#J17");
4628 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#J18");
4629 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#J19");
4630 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#J20");
4631 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#J21");
4632 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#J22");
4633 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#J23");
4634 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#J24");
4635 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#J25");
4636 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#J26");
4637 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#J27");
4638 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#J28");
4639 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#J29");
4640 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#J30");
4641 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#J31");
4642 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#J32");
4643 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#J33");
4644 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#J34");
4645 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#J35");
4646 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#J36");
4648 flags = BindingFlags.Static | BindingFlags.Public |
4649 BindingFlags.DeclaredOnly;
4651 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#K1");
4652 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#K2");
4653 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#K3");
4654 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#K4");
4655 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#K5");
4656 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#K6");
4657 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#K7");
4658 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#K8");
4659 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#K9");
4660 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#K10");
4661 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#K11");
4662 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#K12");
4663 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#K13");
4664 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#K14");
4665 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#K15");
4666 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#K16");
4667 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#K17");
4668 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#K18");
4669 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#K19");
4670 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#K20");
4671 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#K21");
4672 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#K22");
4673 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#K23");
4674 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#K24");
4675 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#K25");
4676 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#K26");
4677 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#K27");
4678 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#K28");
4679 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#K29");
4680 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#K30");
4681 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#K31");
4682 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#K32");
4683 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#K33");
4684 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#K34");
4685 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#K35");
4686 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#K36");
4688 flags = BindingFlags.Static | BindingFlags.NonPublic |
4689 BindingFlags.DeclaredOnly;
4691 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#L1");
4692 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#L2");
4693 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#L3");
4694 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#L4");
4695 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#L5");
4696 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#L6");
4697 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#L7");
4698 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#L8");
4699 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#L9");
4700 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#L10");
4701 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#L11");
4702 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#L12");
4703 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#L13");
4704 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#L14");
4705 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#L15");
4706 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#L16");
4707 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#L17");
4708 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#L18");
4709 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#L19");
4710 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#L20");
4711 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#L21");
4712 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#L22");
4713 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#L23");
4714 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#L24");
4715 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#L25");
4716 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#L26");
4717 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#L27");
4718 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#L28");
4719 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#L29");
4720 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#L30");
4721 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#L31");
4722 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#L32");
4723 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#L33");
4724 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#L34");
4725 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#L35");
4726 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#L36");
4728 flags = BindingFlags.Instance | BindingFlags.NonPublic |
4729 BindingFlags.Public;
4731 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#M1");
4732 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#M2");
4733 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#M3");
4734 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#M4");
4735 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#M5");
4736 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#M6");
4737 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#M7");
4738 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#M8");
4739 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#M9");
4740 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#M10");
4741 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#M11");
4742 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#M12");
4743 Assert.IsNotNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#M13");
4744 Assert.IsNotNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#M14");
4745 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#M15");
4746 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#M16");
4747 Assert.IsNotNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#M17");
4748 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#M18");
4749 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#M19");
4750 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#M20");
4751 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#M21");
4752 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#M22");
4753 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#M23");
4754 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#M24");
4755 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#M25");
4756 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#M26");
4757 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#M27");
4758 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#M28");
4759 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#M29");
4760 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#M30");
4761 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#M31");
4762 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#M32");
4763 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#M33");
4764 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#M34");
4765 Assert.IsNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#M35");
4766 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#M36");
4768 flags = BindingFlags.Static | BindingFlags.NonPublic |
4769 BindingFlags.Public;
4771 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceBlue", flags), "#N1");
4772 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceBlue", flags), "#N2");
4773 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceBlue", flags), "#N3");
4774 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceBlue", flags), "#N4");
4775 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceBlue", flags), "#N5");
4776 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceBlue", flags), "#N6");
4777 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceRed", flags), "#N7");
4778 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceRed", flags), "#N8");
4779 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceRed", flags), "#N9");
4780 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceRed", flags), "#N10");
4781 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceRed", flags), "#N11");
4782 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceRed", flags), "#N12");
4783 Assert.IsNull (greenType.GetEvent ("OnPrivateInstanceGreen", flags), "#N13");
4784 Assert.IsNull (greenType.GetEvent ("OnFamilyInstanceGreen", flags), "#N14");
4785 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemInstanceGreen", flags), "#N15");
4786 Assert.IsNull (greenType.GetEvent ("OnFamORAssemInstanceGreen", flags), "#N16");
4787 Assert.IsNull (greenType.GetEvent ("OnPublicInstanceGreen", flags), "#N17");
4788 Assert.IsNull (greenType.GetEvent ("OnAssemblyInstanceGreen", flags), "#N18");
4789 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticBlue", flags), "#N19");
4790 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticBlue", flags), "#N20");
4791 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticBlue", flags), "#N21");
4792 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticBlue", flags), "#N22");
4793 Assert.IsNull (greenType.GetEvent ("OnPublicStaticBlue", flags), "#N23");
4794 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticBlue", flags), "#N24");
4795 Assert.IsNull (greenType.GetEvent ("OnPrivateStaticRed", flags), "#N25");
4796 Assert.IsNull (greenType.GetEvent ("OnFamilyStaticRed", flags), "#N26");
4797 Assert.IsNull (greenType.GetEvent ("OnFamANDAssemStaticRed", flags), "#N27");
4798 Assert.IsNull (greenType.GetEvent ("OnFamORAssemStaticRed", flags), "#N28");
4799 Assert.IsNull (greenType.GetEvent ("OnPublicStaticRed", flags), "#N29");
4800 Assert.IsNull (greenType.GetEvent ("OnAssemblyStaticRed", flags), "#N30");
4801 Assert.IsNotNull (greenType.GetEvent ("OnPrivateStaticGreen", flags), "#N31");
4802 Assert.IsNotNull (greenType.GetEvent ("OnFamilyStaticGreen", flags), "#N32");
4803 Assert.IsNotNull (greenType.GetEvent ("OnFamANDAssemStaticGreen", flags), "#N33");
4804 Assert.IsNotNull (greenType.GetEvent ("OnFamORAssemStaticGreen", flags), "#N34");
4805 Assert.IsNotNull (greenType.GetEvent ("OnPublicStaticGreen", flags), "#N35");
4806 Assert.IsNotNull (greenType.GetEvent ("OnAssemblyStaticGreen", flags), "#N36");
4810 [Category ("NotWorking")] // mcs depends on this
4811 public void TestGetFieldsIncomplete_MS ()
4813 TypeBuilder tb = module.DefineType (genTypeName ());
4814 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4818 } catch (NotSupportedException ex) {
4819 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4820 Assert.IsNull (ex.InnerException, "#3");
4821 Assert.IsNotNull (ex.Message, "#4");
4826 [Category ("NotDotNet")] // mcs depends on this
4827 public void TestGetFieldsIncomplete_Mono ()
4829 TypeBuilder tb = module.DefineType (genTypeName ());
4830 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4831 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4832 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4833 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4835 FieldInfo [] fields = tb.GetFields ();
4836 Assert.AreEqual (2, fields.Length, "#A1");
4837 Assert.AreEqual ("Sex", fields [0].Name, "#A2");
4838 Assert.AreEqual ("MALE", fields [1].Name, "#A3");
4841 tb = module.DefineType (genTypeName ());
4842 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4843 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4844 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4845 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4846 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4847 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4849 fields = tb.GetFields ();
4850 Assert.AreEqual (4, fields.Length, "#B1");
4851 Assert.AreEqual ("First", fields [0].Name, "#B2");
4852 Assert.AreEqual ("Second", fields [1].Name, "#B3");
4853 Assert.AreEqual ("Sex", fields [2].Name, "#B4");
4854 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");
4884 [Test] // bug #82625 / 325292
4885 public void TestGetFieldsComplete_Generic ()
4887 // FIXME: merge this with TestGetFieldsComplete when
4888 // bug #82625 is fixed
4892 FieldInfo [] dynamicFields;
4893 FieldInfo [] emittedFields;
4895 tb = module.DefineType (genTypeName ());
4896 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("K", "V");
4897 tb.DefineField ("First", typeParams [0], FieldAttributes.Public);
4898 tb.DefineField ("Second", typeParams [1], FieldAttributes.Public);
4899 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4900 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4901 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4903 emittedType = tb.CreateType ();
4904 dynamicFields = tb.GetFields ();
4905 emittedFields = emittedType.GetFields ();
4907 Assert.AreEqual (4, dynamicFields.Length, "#C1");
4908 Assert.IsFalse ((dynamicFields [0]) is FieldBuilder, "#C2");
4909 Assert.IsFalse ((dynamicFields [1]) is FieldBuilder, "#C3");
4910 Assert.IsFalse ((dynamicFields [2]) is FieldBuilder, "#C4");
4911 Assert.IsFalse ((dynamicFields [3]) is FieldBuilder, "#C5");
4912 Assert.AreEqual ("First", dynamicFields [0].Name, "#C6");
4913 Assert.AreEqual ("Second", dynamicFields [1].Name, "#C7");
4914 Assert.AreEqual ("Sex", dynamicFields [2].Name, "#C8");
4915 Assert.AreEqual ("MALE", dynamicFields [3].Name, "#C9");
4917 Assert.AreEqual (4, emittedFields.Length, "#D1");
4918 Assert.IsFalse ((emittedFields [0]) is FieldBuilder, "#D2");
4919 Assert.IsFalse ((emittedFields [1]) is FieldBuilder, "#D3");
4920 Assert.IsFalse ((emittedFields [2]) is FieldBuilder, "#D4");
4921 Assert.IsFalse ((emittedFields [3]) is FieldBuilder, "#D5");
4922 Assert.AreEqual ("First", emittedFields [0].Name, "#D6");
4923 Assert.AreEqual ("Second", emittedFields [1].Name, "#D7");
4924 Assert.AreEqual ("Sex", emittedFields [2].Name, "#D8");
4925 Assert.AreEqual ("MALE", emittedFields [3].Name, "#D9");
4930 [Category ("NotWorking")] // mcs depends on this
4931 public void TestGetFieldsFlagsIncomplete_MS ()
4933 TypeBuilder tb = module.DefineType (genTypeName ());
4934 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4936 tb.GetFields (BindingFlags.Instance | BindingFlags.Public);
4938 } catch (NotSupportedException ex) {
4939 // The invoked member is not supported in a
4941 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
4942 Assert.IsNull (ex.InnerException, "#3");
4943 Assert.IsNotNull (ex.Message, "#4");
4948 [Category ("NotDotNet")] // mcs depends on this
4949 public void TestGetFieldsFlagsIncomplete_Mono ()
4951 FieldInfo [] fields;
4953 TypeBuilder tb = module.DefineType (genTypeName ());
4954 tb.DefineField ("name", typeof (string), FieldAttributes.Private);
4955 tb.DefineField ("Sex", typeof (int), FieldAttributes.Public);
4956 tb.DefineField ("MALE", typeof (int), FieldAttributes.Public | FieldAttributes.Static);
4957 tb.DefineField ("FEMALE", typeof (int), FieldAttributes.Private | FieldAttributes.Static);
4959 fields = tb.GetFields (BindingFlags.Public |
4960 BindingFlags.NonPublic | BindingFlags.Instance);
4961 Assert.AreEqual (2, fields.Length, "#A1");
4962 Assert.AreEqual ("name", fields [0].Name, "#A2");
4963 Assert.AreEqual ("Sex", fields [1].Name, "#A3");
4965 fields = tb.GetFields (BindingFlags.Public |
4966 BindingFlags.Instance | BindingFlags.Static);
4967 Assert.AreEqual (2, fields.Length, "#B1");
4968 Assert.AreEqual ("Sex", fields [0].Name, "#B2");
4969 Assert.AreEqual ("MALE", fields [1].Name, "#B3");
4971 fields = tb.GetFields (BindingFlags.Public |
4972 BindingFlags.NonPublic | BindingFlags.Instance |
4973 BindingFlags.Static);
4974 Assert.AreEqual (4, fields.Length, "#C1");
4975 Assert.AreEqual ("name", fields [0].Name, "#C2");
4976 Assert.AreEqual ("Sex", fields [1].Name, "#C3");
4977 Assert.AreEqual ("MALE", fields [2].Name, "#C4");
4978 Assert.AreEqual ("FEMALE", fields [3].Name, "#C5");
4982 public void TestGetFieldsFlagsComplete ()
4984 TypeBuilder tb = module.DefineType (genTypeName ());
4985 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
4987 Type emittedType = tb.CreateType ();
4989 Assert.AreEqual (1, tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4990 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.Public).Length,
4991 emittedType.GetFields (BindingFlags.Instance | BindingFlags.Public).Length);
4992 Assert.AreEqual (0, tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4993 Assert.AreEqual (tb.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length,
4994 emittedType.GetFields (BindingFlags.Instance | BindingFlags.NonPublic).Length);
4998 public void TestGetFieldsFlagsComplete_Inheritance ()
5000 FieldInfo [] fields;
5003 TypeBuilder blueType = module.DefineType (genTypeName (),
5004 TypeAttributes.Public);
5005 CreateMembers (blueType, "Blue", false);
5007 TypeBuilder redType = module.DefineType (genTypeName (),
5008 TypeAttributes.Public, blueType);
5009 CreateMembers (redType, "Red", false);
5011 TypeBuilder greenType = module.DefineType (genTypeName (),
5012 TypeAttributes.Public, redType);
5013 CreateMembers (greenType, "Green", false);
5015 blueType.CreateType ();
5016 redType.CreateType ();
5017 greenType.CreateType ();
5019 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5020 fields = greenType.GetFields (flags);
5022 Assert.AreEqual (13, fields.Length, "#A1");
5023 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#A2");
5024 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#A3");
5025 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#A4");
5026 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#A5");
5027 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#A6");
5028 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#A7");
5029 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#A8");
5030 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#A9");
5031 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#A10");
5032 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#A11");
5033 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#A12");
5034 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#A13");
5035 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#A14");
5037 flags = BindingFlags.Instance | BindingFlags.Public;
5038 fields = greenType.GetFields (flags);
5040 Assert.AreEqual (3, fields.Length, "#B1");
5041 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#B2");
5042 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#B3");
5043 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#B4");
5045 flags = BindingFlags.Static | BindingFlags.Public;
5046 fields = greenType.GetFields (flags);
5048 Assert.AreEqual (1, fields.Length, "#C1");
5049 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#C2");
5051 flags = BindingFlags.Static | BindingFlags.NonPublic;
5052 fields = greenType.GetFields (flags);
5054 Assert.AreEqual (5, fields.Length, "#D1");
5055 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#D2");
5056 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#D3");
5057 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#D4");
5058 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#D5");
5059 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#D6");
5061 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5062 BindingFlags.FlattenHierarchy;
5063 fields = greenType.GetFields (flags);
5065 Assert.AreEqual (13, fields.Length, "#E1");
5066 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#E2");
5067 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#E3");
5068 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#E4");
5069 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#E5");
5070 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#E6");
5071 Assert.AreEqual ("familyInstanceRed", fields [5].Name, "#E7");
5072 Assert.AreEqual ("famANDAssemInstanceRed", fields [6].Name, "#E8");
5073 Assert.AreEqual ("famORAssemInstanceRed", fields [7].Name, "#E9");
5074 Assert.AreEqual ("assemblyInstanceRed", fields [8].Name, "#E10");
5075 Assert.AreEqual ("familyInstanceBlue", fields [9].Name, "#E11");
5076 Assert.AreEqual ("famANDAssemInstanceBlue", fields [10].Name, "#E12");
5077 Assert.AreEqual ("famORAssemInstanceBlue", fields [11].Name, "#E13");
5078 Assert.AreEqual ("assemblyInstanceBlue", fields [12].Name, "#E14");
5080 flags = BindingFlags.Instance | BindingFlags.Public |
5081 BindingFlags.FlattenHierarchy;
5082 fields = greenType.GetFields (flags);
5084 Assert.AreEqual (3, fields.Length, "#F1");
5085 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#F2");
5086 Assert.AreEqual ("publicInstanceRed", fields [1].Name, "#F3");
5087 Assert.AreEqual ("publicInstanceBlue", fields [2].Name, "#F4");
5089 flags = BindingFlags.Static | BindingFlags.Public |
5090 BindingFlags.FlattenHierarchy;
5091 fields = greenType.GetFields (flags);
5093 Assert.AreEqual (3, fields.Length, "#G1");
5094 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#G2");
5095 Assert.AreEqual ("publicStaticRed", fields [1].Name, "#G3");
5096 Assert.AreEqual ("publicStaticBlue", fields [2].Name, "#G4");
5098 flags = BindingFlags.Static | BindingFlags.NonPublic |
5099 BindingFlags.FlattenHierarchy;
5100 fields = greenType.GetFields (flags);
5102 Assert.AreEqual (13, fields.Length, "#H1");
5103 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#H2");
5104 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#H3");
5105 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#H4");
5106 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#H5");
5107 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#H6");
5108 Assert.AreEqual ("familyStaticRed", fields [5].Name, "#H7");
5109 Assert.AreEqual ("famANDAssemStaticRed", fields [6].Name, "#H8");
5110 Assert.AreEqual ("famORAssemStaticRed", fields [7].Name, "#H9");
5111 Assert.AreEqual ("assemblyStaticRed", fields [8].Name, "#H10");
5112 Assert.AreEqual ("familyStaticBlue", fields [9].Name, "#H11");
5113 Assert.AreEqual ("famANDAssemStaticBlue", fields [10].Name, "#H12");
5114 Assert.AreEqual ("famORAssemStaticBlue", fields [11].Name, "#H13");
5115 Assert.AreEqual ("assemblyStaticBlue", fields [12].Name, "#H14");
5117 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5118 BindingFlags.DeclaredOnly;
5119 fields = greenType.GetFields (flags);
5121 Assert.AreEqual (5, fields.Length, "#I1");
5122 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#I2");
5123 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#I3");
5124 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#I4");
5125 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#I5");
5126 Assert.AreEqual ("assemblyInstanceGreen", fields [4].Name, "#I6");
5128 flags = BindingFlags.Instance | BindingFlags.Public |
5129 BindingFlags.DeclaredOnly;
5130 fields = greenType.GetFields (flags);
5132 Assert.AreEqual (1, fields.Length, "#J1");
5133 Assert.AreEqual ("publicInstanceGreen", fields [0].Name, "#J2");
5135 flags = BindingFlags.Static | BindingFlags.Public |
5136 BindingFlags.DeclaredOnly;
5137 fields = greenType.GetFields (flags);
5139 Assert.AreEqual (1, fields.Length, "#K1");
5140 Assert.AreEqual ("publicStaticGreen", fields [0].Name, "#K2");
5142 flags = BindingFlags.Static | BindingFlags.NonPublic |
5143 BindingFlags.DeclaredOnly;
5144 fields = greenType.GetFields (flags);
5146 Assert.AreEqual (5, fields.Length, "#L1");
5147 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#L2");
5148 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#L3");
5149 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#L4");
5150 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#L5");
5151 Assert.AreEqual ("assemblyStaticGreen", fields [4].Name, "#L6");
5153 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5154 BindingFlags.Public;
5155 fields = greenType.GetFields (flags);
5157 Assert.AreEqual (16, fields.Length, "#M1");
5158 Assert.AreEqual ("privateInstanceGreen", fields [0].Name, "#M2");
5159 Assert.AreEqual ("familyInstanceGreen", fields [1].Name, "#M3");
5160 Assert.AreEqual ("famANDAssemInstanceGreen", fields [2].Name, "#M4");
5161 Assert.AreEqual ("famORAssemInstanceGreen", fields [3].Name, "#M5");
5162 Assert.AreEqual ("publicInstanceGreen", fields [4].Name, "#M6");
5163 Assert.AreEqual ("assemblyInstanceGreen", fields [5].Name, "#M7");
5164 Assert.AreEqual ("familyInstanceRed", fields [6].Name, "#M8");
5165 Assert.AreEqual ("famANDAssemInstanceRed", fields [7].Name, "#M9");
5166 Assert.AreEqual ("famORAssemInstanceRed", fields [8].Name, "#M10");
5167 Assert.AreEqual ("publicInstanceRed", fields [9].Name, "#M11");
5168 Assert.AreEqual ("assemblyInstanceRed", fields [10].Name, "#M12");
5169 Assert.AreEqual ("familyInstanceBlue", fields [11].Name, "#M13");
5170 Assert.AreEqual ("famANDAssemInstanceBlue", fields [12].Name, "#M14");
5171 Assert.AreEqual ("famORAssemInstanceBlue", fields [13].Name, "#M15");
5172 Assert.AreEqual ("publicInstanceBlue", fields [14].Name, "#M16");
5173 Assert.AreEqual ("assemblyInstanceBlue", fields [15].Name, "#M17");
5175 flags = BindingFlags.Static | BindingFlags.NonPublic |
5176 BindingFlags.Public;
5177 fields = greenType.GetFields (flags);
5179 Assert.AreEqual (6, fields.Length, "#N1");
5180 Assert.AreEqual ("privateStaticGreen", fields [0].Name, "#N2");
5181 Assert.AreEqual ("familyStaticGreen", fields [1].Name, "#N3");
5182 Assert.AreEqual ("famANDAssemStaticGreen", fields [2].Name, "#N4");
5183 Assert.AreEqual ("famORAssemStaticGreen", fields [3].Name, "#N5");
5184 Assert.AreEqual ("publicStaticGreen", fields [4].Name, "#N6");
5185 Assert.AreEqual ("assemblyStaticGreen", fields [5].Name, "#N7");
5189 [Category ("NotWorking")] // mcs depends on this
5190 public void TestGetFieldIncomplete_MS ()
5192 TypeBuilder tb = module.DefineType (genTypeName ());
5193 tb.DefineField ("test", typeof (int), FieldAttributes.Public);
5195 tb.GetField ("test");
5197 } catch (NotSupportedException ex) {
5198 // The invoked member is not supported in a
5200 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5201 Assert.IsNull (ex.InnerException, "#3");
5202 Assert.IsNotNull (ex.Message, "#4");
5207 [Category ("NotDotNet")] // mcs depends on this
5208 public void TestGetFieldIncomplete_Mono ()
5210 TypeBuilder tb = module.DefineType (genTypeName ());
5211 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5212 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5214 FieldInfo field = tb.GetField ("TestField");
5215 Assert.IsNotNull (field, "#A1");
5216 Assert.AreEqual ("TestField", field.Name, "#A2");
5217 Assert.IsTrue (field is FieldBuilder, "#A3");
5219 Assert.IsNull (tb.GetField ("OtherField"), "#B1");
5220 Assert.IsNull (tb.GetField ("TestOtherField"), "#B2");
5224 public void TestGetFieldComplete ()
5226 TypeBuilder tb = module.DefineType (genTypeName ());
5227 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5229 Type emittedType = tb.CreateType ();
5231 FieldInfo dynamicField = tb.GetField ("TestField");
5232 FieldInfo emittedField = emittedType.GetField ("TestField");
5233 Assert.IsNotNull (dynamicField, "#A1");
5234 Assert.AreEqual (dynamicField.Name, emittedField.Name, "#A2");
5235 Assert.IsNull (tb.GetField ("TestOtherField"), "#A3");
5236 Assert.IsFalse (emittedField is FieldBuilder, "#A4");
5237 Assert.IsFalse (dynamicField is FieldBuilder, "#A5");
5240 object value = Activator.CreateInstance (emittedType);
5241 emittedField.SetValue (value, 5);
5242 Assert.AreEqual (5, emittedField.GetValue (value), "#B1");
5243 Assert.AreEqual (5, dynamicField.GetValue (value), "#B2");
5244 dynamicField.SetValue (value, 4);
5245 Assert.AreEqual (4, emittedField.GetValue (value), "#B3");
5246 Assert.AreEqual (4, dynamicField.GetValue (value), "#B4");
5249 [Test] // bug #81640
5250 public void TestGetFieldComplete_Type ()
5252 TypeBuilder tb = module.DefineType (genTypeName ());
5253 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5254 Type emittedType = tb.CreateType ();
5255 FieldInfo dynamicField = tb.GetField ("TestField");
5256 Assert.IsFalse (dynamicField is FieldBuilder, "#1");
5258 object value = Activator.CreateInstance (emittedType);
5259 Assert.AreEqual (0, dynamicField.GetValue (value), "#2");
5263 [Category ("NotWorking")] // mcs depends on this
5264 public void TestGetFieldFlagsIncomplete_MS ()
5266 TypeBuilder tb = module.DefineType (genTypeName ());
5267 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5268 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5270 tb.GetField ("test", BindingFlags.Public);
5272 } catch (NotSupportedException ex) {
5273 // The invoked member is not supported in a
5275 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5276 Assert.IsNull (ex.InnerException, "#3");
5277 Assert.IsNotNull (ex.Message, "#4");
5282 [Category ("NotDotNet")] // mcs depends on this
5283 public void TestGetFieldFlagsIncomplete_Mono ()
5285 TypeBuilder tb = module.DefineType (genTypeName ());
5286 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5287 tb.DefineField ("OtherField", typeof (int), FieldAttributes.Private);
5289 FieldInfo field = tb.GetField ("TestField", BindingFlags.Public
5290 | BindingFlags.Instance);
5291 Assert.IsNotNull (field, "#A1");
5292 Assert.AreEqual ("TestField", field.Name, "#A2");
5293 Assert.IsTrue (field is FieldBuilder, "#A3");
5295 field = tb.GetField ("OtherField", BindingFlags.NonPublic |
5296 BindingFlags.Instance);
5297 Assert.IsNotNull (field, "#B1");
5298 Assert.AreEqual ("OtherField", field.Name, "#B2");
5299 Assert.IsTrue (field is FieldBuilder, "#B3");
5301 Assert.IsNull (tb.GetField ("TestField", BindingFlags.NonPublic |
5302 BindingFlags.Instance), "#C1");
5303 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Public |
5304 BindingFlags.Static), "#C2");
5305 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5306 BindingFlags.Instance), "#C3");
5307 Assert.IsNull (tb.GetField ("OtherField", BindingFlags.Public |
5308 BindingFlags.Static), "#C4");
5309 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.NonPublic |
5310 BindingFlags.Instance), "#C5");
5311 Assert.IsNull (tb.GetField ("NotExist", BindingFlags.Public |
5312 BindingFlags.Instance), "#C6");
5316 public void TestGetFieldFlagsComplete ()
5318 TypeBuilder tb = module.DefineType (genTypeName ());
5319 tb.DefineField ("TestField", typeof (int), FieldAttributes.Public);
5321 Type emittedType = tb.CreateType ();
5323 Assert.IsNotNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public));
5324 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name,
5325 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.Public).Name);
5326 Assert.IsNull (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5327 Assert.AreEqual (tb.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic),
5328 emittedType.GetField ("TestField", BindingFlags.Instance | BindingFlags.NonPublic));
5332 public void TestGetFieldFlagsComplete_Inheritance ()
5336 TypeBuilder blueType = module.DefineType (genTypeName (),
5337 TypeAttributes.Public);
5338 CreateMembers (blueType, "Blue", false);
5340 TypeBuilder redType = module.DefineType (genTypeName (),
5341 TypeAttributes.Public, blueType);
5342 CreateMembers (redType, "Red", false);
5344 TypeBuilder greenType = module.DefineType (genTypeName (),
5345 TypeAttributes.Public, redType);
5346 CreateMembers (greenType, "Green", false);
5348 blueType.CreateType ();
5349 redType.CreateType ();
5350 greenType.CreateType ();
5352 flags = BindingFlags.Instance | BindingFlags.NonPublic;
5354 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#A1");
5355 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#A2");
5356 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#A3");
5357 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#A4");
5358 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#A5");
5359 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#A6");
5360 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#A7");
5361 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#A8");
5362 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#A9");
5363 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#A10");
5364 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#A11");
5365 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#A12");
5366 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#A13");
5367 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#A14");
5368 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#A15");
5369 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#A16");
5370 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#A17");
5371 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#A18");
5372 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#A19");
5373 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#A20");
5374 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#A21");
5375 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#A22");
5376 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#A23");
5377 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#A24");
5378 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#A25");
5379 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#A26");
5380 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#A27");
5381 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#A28");
5382 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#A29");
5383 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#A30");
5384 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#A31");
5385 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#A32");
5386 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#A33");
5387 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#A34");
5388 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#A35");
5389 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#A36");
5391 flags = BindingFlags.Instance | BindingFlags.Public;
5393 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#B1");
5394 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#B2");
5395 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#B3");
5396 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#B4");
5397 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#B5");
5398 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#B6");
5399 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#B7");
5400 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#B8");
5401 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#B9");
5402 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#B10");
5403 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#B11");
5404 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#B12");
5405 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#B13");
5406 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#B14");
5407 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#B15");
5408 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#B16");
5409 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#B17");
5410 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#B18");
5411 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#B19");
5412 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#B20");
5413 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#B21");
5414 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#B22");
5415 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#B23");
5416 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#B24");
5417 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#B25");
5418 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#B26");
5419 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#B27");
5420 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#B28");
5421 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#B29");
5422 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#B30");
5423 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#B31");
5424 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#B32");
5425 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#B33");
5426 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#B34");
5427 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#B35");
5428 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#B36");
5430 flags = BindingFlags.Static | BindingFlags.Public;
5432 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#C1");
5433 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#C2");
5434 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#C3");
5435 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#C4");
5436 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#C5");
5437 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#C6");
5438 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#C7");
5439 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#C8");
5440 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#C9");
5441 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#C10");
5442 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#C11");
5443 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#C12");
5444 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#C13");
5445 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#C14");
5446 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#C15");
5447 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#C16");
5448 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#C17");
5449 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#C18");
5450 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#C19");
5451 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#C20");
5452 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#C21");
5453 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#C22");
5454 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#C23");
5455 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#C24");
5456 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#C25");
5457 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#C26");
5458 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#C27");
5459 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#C28");
5460 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#C29");
5461 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#C30");
5462 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#C31");
5463 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#C32");
5464 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#C33");
5465 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#C34");
5466 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#C35");
5467 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#C36");
5469 flags = BindingFlags.Static | BindingFlags.NonPublic;
5471 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#D1");
5472 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#D2");
5473 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#D3");
5474 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#D4");
5475 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#D5");
5476 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#D6");
5477 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#D7");
5478 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#D8");
5479 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#D9");
5480 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#D10");
5481 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#D11");
5482 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#D12");
5483 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#D13");
5484 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#D14");
5485 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#D15");
5486 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#D16");
5487 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#D17");
5488 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#D18");
5489 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#D19");
5490 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#D20");
5491 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#D21");
5492 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#D22");
5493 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#D23");
5494 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#D24");
5495 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#D25");
5496 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#D26");
5497 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#D27");
5498 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#D28");
5499 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#D29");
5500 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#D30");
5501 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#D31");
5502 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#D32");
5503 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#D33");
5504 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#D34");
5505 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#D35");
5506 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#D36");
5508 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5509 BindingFlags.FlattenHierarchy;
5511 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#E1");
5512 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#E2");
5513 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#E3");
5514 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#E4");
5515 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#E5");
5516 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#E6");
5517 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#E7");
5518 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#E8");
5519 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#E9");
5520 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#E10");
5521 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#E11");
5522 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#E12");
5523 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#E13");
5524 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#E14");
5525 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#E15");
5526 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#E16");
5527 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#E17");
5528 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#E18");
5529 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#E19");
5530 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#E20");
5531 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#E21");
5532 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#E22");
5533 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#E23");
5534 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#E24");
5535 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#E25");
5536 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#E26");
5537 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#E27");
5538 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#E28");
5539 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#E29");
5540 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#E30");
5541 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#E31");
5542 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#E32");
5543 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#E33");
5544 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#E34");
5545 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#E35");
5546 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#E36");
5548 flags = BindingFlags.Instance | BindingFlags.Public |
5549 BindingFlags.FlattenHierarchy;
5551 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#F1");
5552 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#F2");
5553 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#F3");
5554 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#F4");
5555 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#F5");
5556 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#F6");
5557 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#F7");
5558 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#F8");
5559 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#F9");
5560 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#F10");
5561 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#F11");
5562 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#F12");
5563 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#F13");
5564 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#F14");
5565 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#F15");
5566 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#F16");
5567 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#F17");
5568 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#F18");
5569 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#F19");
5570 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#F20");
5571 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#F21");
5572 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#F22");
5573 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#F23");
5574 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#F24");
5575 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#F25");
5576 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#F26");
5577 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#F27");
5578 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#F28");
5579 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#F29");
5580 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#F30");
5581 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#F31");
5582 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#F32");
5583 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#F33");
5584 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#F34");
5585 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#F35");
5586 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#F36");
5588 flags = BindingFlags.Static | BindingFlags.Public |
5589 BindingFlags.FlattenHierarchy;
5591 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#G1");
5592 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#G2");
5593 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#G3");
5594 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#G4");
5595 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#G5");
5596 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#G6");
5597 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#G7");
5598 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#G8");
5599 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#G9");
5600 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#G10");
5601 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#G11");
5602 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#G12");
5603 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#G13");
5604 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#G14");
5605 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#G15");
5606 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#G16");
5607 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#G17");
5608 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#G18");
5609 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#G19");
5610 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#G20");
5611 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#G21");
5612 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#G22");
5613 Assert.IsNotNull (greenType.GetField ("publicStaticBlue", flags), "#G23");
5614 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#G24");
5615 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#G25");
5616 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#G26");
5617 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#G27");
5618 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#G28");
5619 Assert.IsNotNull (greenType.GetField ("publicStaticRed", flags), "#G29");
5620 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#G30");
5621 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#G31");
5622 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#G32");
5623 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#G33");
5624 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#G34");
5625 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#G35");
5626 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#G36");
5628 flags = BindingFlags.Static | BindingFlags.NonPublic |
5629 BindingFlags.FlattenHierarchy;
5631 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#H1");
5632 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#H2");
5633 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#H3");
5634 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#H4");
5635 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#H5");
5636 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#H6");
5637 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#H7");
5638 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#H8");
5639 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#H9");
5640 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#H10");
5641 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#H11");
5642 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#H12");
5643 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#H13");
5644 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#H14");
5645 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#H15");
5646 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#H16");
5647 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#H17");
5648 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#H18");
5649 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#H19");
5650 Assert.IsNotNull (greenType.GetField ("familyStaticBlue", flags), "#H20");
5651 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#H21");
5652 Assert.IsNotNull (greenType.GetField ("famORAssemStaticBlue", flags), "#H22");
5653 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#H23");
5654 Assert.IsNotNull (greenType.GetField ("assemblyStaticBlue", flags), "#H24");
5655 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#H25");
5656 Assert.IsNotNull (greenType.GetField ("familyStaticRed", flags), "#H26");
5657 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticRed", flags), "#H27");
5658 Assert.IsNotNull (greenType.GetField ("famORAssemStaticRed", flags), "#H28");
5659 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#H29");
5660 Assert.IsNotNull (greenType.GetField ("assemblyStaticRed", flags), "#H30");
5661 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#H31");
5662 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#H32");
5663 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#H33");
5664 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#H34");
5665 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#H35");
5666 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#H36");
5668 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5669 BindingFlags.DeclaredOnly;
5671 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#I1");
5672 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#I2");
5673 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#I3");
5674 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#I4");
5675 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#I5");
5676 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#I6");
5677 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#I7");
5678 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#I8");
5679 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#I9");
5680 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#I10");
5681 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#I11");
5682 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#I12");
5683 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#I13");
5684 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#I14");
5685 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#I15");
5686 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#I16");
5687 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#I17");
5688 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#I18");
5689 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#I19");
5690 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#I20");
5691 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#I21");
5692 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#I22");
5693 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#I23");
5694 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#I24");
5695 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#I25");
5696 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#I26");
5697 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#I27");
5698 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#I28");
5699 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#I29");
5700 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#I30");
5701 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#I31");
5702 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#I32");
5703 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#I33");
5704 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#I34");
5705 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#I35");
5706 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#I36");
5708 flags = BindingFlags.Instance | BindingFlags.Public |
5709 BindingFlags.DeclaredOnly;
5711 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#J1");
5712 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#J2");
5713 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#J3");
5714 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#J4");
5715 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#J5");
5716 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#J6");
5717 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#J7");
5718 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#J8");
5719 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#J9");
5720 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#J10");
5721 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#J11");
5722 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#J12");
5723 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#J13");
5724 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#J14");
5725 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#J15");
5726 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#J16");
5727 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#J17");
5728 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#J18");
5729 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#J19");
5730 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#J20");
5731 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#J21");
5732 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#J22");
5733 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#J23");
5734 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#J24");
5735 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#J25");
5736 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#J26");
5737 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#J27");
5738 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#J28");
5739 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#J29");
5740 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#J30");
5741 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#J31");
5742 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#J32");
5743 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#J33");
5744 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#J34");
5745 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#J35");
5746 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#J36");
5748 flags = BindingFlags.Static | BindingFlags.Public |
5749 BindingFlags.DeclaredOnly;
5751 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#K1");
5752 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#K2");
5753 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#K3");
5754 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#K4");
5755 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#K5");
5756 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#K6");
5757 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#K7");
5758 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#K8");
5759 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#K9");
5760 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#K10");
5761 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#K11");
5762 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#K12");
5763 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#K13");
5764 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#K14");
5765 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#K15");
5766 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#K16");
5767 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#K17");
5768 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#K18");
5769 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#K19");
5770 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#K20");
5771 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#K21");
5772 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#K22");
5773 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#K23");
5774 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#K24");
5775 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#K25");
5776 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#K26");
5777 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#K27");
5778 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#K28");
5779 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#K29");
5780 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#K30");
5781 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#K31");
5782 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#K32");
5783 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#K33");
5784 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#K34");
5785 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#K35");
5786 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#K36");
5788 flags = BindingFlags.Static | BindingFlags.NonPublic |
5789 BindingFlags.DeclaredOnly;
5791 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#L1");
5792 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#L2");
5793 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#L3");
5794 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#L4");
5795 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#L5");
5796 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#L6");
5797 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#L7");
5798 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#L8");
5799 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#L9");
5800 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#L10");
5801 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#L11");
5802 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#L12");
5803 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#L13");
5804 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#L14");
5805 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#L15");
5806 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#L16");
5807 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#L17");
5808 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#L18");
5809 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#L19");
5810 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#L20");
5811 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#L21");
5812 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#L22");
5813 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#L23");
5814 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#L24");
5815 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#L25");
5816 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#L26");
5817 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#L27");
5818 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#L28");
5819 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#L29");
5820 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#L30");
5821 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#L31");
5822 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#L32");
5823 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#L33");
5824 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#L34");
5825 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#L35");
5826 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#L36");
5828 flags = BindingFlags.Instance | BindingFlags.NonPublic |
5829 BindingFlags.Public;
5831 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#M1");
5832 Assert.IsNotNull (greenType.GetField ("familyInstanceBlue", flags), "#M2");
5833 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#M3");
5834 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#M4");
5835 Assert.IsNotNull (greenType.GetField ("publicInstanceBlue", flags), "#M5");
5836 Assert.IsNotNull (greenType.GetField ("assemblyInstanceBlue", flags), "#M6");
5837 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#M7");
5838 Assert.IsNotNull (greenType.GetField ("familyInstanceRed", flags), "#M8");
5839 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#M9");
5840 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceRed", flags), "#M10");
5841 Assert.IsNotNull (greenType.GetField ("publicInstanceRed", flags), "#M11");
5842 Assert.IsNotNull (greenType.GetField ("assemblyInstanceRed", flags), "#M12");
5843 Assert.IsNotNull (greenType.GetField ("privateInstanceGreen", flags), "#M13");
5844 Assert.IsNotNull (greenType.GetField ("familyInstanceGreen", flags), "#M14");
5845 Assert.IsNotNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#M15");
5846 Assert.IsNotNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#M16");
5847 Assert.IsNotNull (greenType.GetField ("publicInstanceGreen", flags), "#M17");
5848 Assert.IsNotNull (greenType.GetField ("assemblyInstanceGreen", flags), "#M18");
5849 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#M19");
5850 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#M20");
5851 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#M21");
5852 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#M22");
5853 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#M23");
5854 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#M24");
5855 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#M25");
5856 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#M26");
5857 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#M27");
5858 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#M28");
5859 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#M29");
5860 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#M30");
5861 Assert.IsNull (greenType.GetField ("privateStaticGreen", flags), "#M31");
5862 Assert.IsNull (greenType.GetField ("familyStaticGreen", flags), "#M32");
5863 Assert.IsNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#M33");
5864 Assert.IsNull (greenType.GetField ("famORAssemStaticGreen", flags), "#M34");
5865 Assert.IsNull (greenType.GetField ("publicStaticGreen", flags), "#M35");
5866 Assert.IsNull (greenType.GetField ("assemblyStaticGreen", flags), "#M36");
5868 flags = BindingFlags.Static | BindingFlags.NonPublic |
5869 BindingFlags.Public;
5871 Assert.IsNull (greenType.GetField ("privateInstanceBlue", flags), "#N1");
5872 Assert.IsNull (greenType.GetField ("familyInstanceBlue", flags), "#N2");
5873 Assert.IsNull (greenType.GetField ("famANDAssemInstanceBlue", flags), "#N3");
5874 Assert.IsNull (greenType.GetField ("famORAssemInstanceBlue", flags), "#N4");
5875 Assert.IsNull (greenType.GetField ("publicInstanceBlue", flags), "#N5");
5876 Assert.IsNull (greenType.GetField ("assemblyInstanceBlue", flags), "#N6");
5877 Assert.IsNull (greenType.GetField ("privateInstanceRed", flags), "#N7");
5878 Assert.IsNull (greenType.GetField ("familyInstanceRed", flags), "#N8");
5879 Assert.IsNull (greenType.GetField ("famANDAssemInstanceRed", flags), "#N9");
5880 Assert.IsNull (greenType.GetField ("famORAssemInstanceRed", flags), "#N10");
5881 Assert.IsNull (greenType.GetField ("publicInstanceRed", flags), "#N11");
5882 Assert.IsNull (greenType.GetField ("assemblyInstanceRed", flags), "#N12");
5883 Assert.IsNull (greenType.GetField ("privateInstanceGreen", flags), "#N13");
5884 Assert.IsNull (greenType.GetField ("familyInstanceGreen", flags), "#N14");
5885 Assert.IsNull (greenType.GetField ("famANDAssemInstanceGreen", flags), "#N15");
5886 Assert.IsNull (greenType.GetField ("famORAssemInstanceGreen", flags), "#N16");
5887 Assert.IsNull (greenType.GetField ("publicInstanceGreen", flags), "#N17");
5888 Assert.IsNull (greenType.GetField ("assemblyInstanceGreen", flags), "#N18");
5889 Assert.IsNull (greenType.GetField ("privateStaticBlue", flags), "#N19");
5890 Assert.IsNull (greenType.GetField ("familyStaticBlue", flags), "#N20");
5891 Assert.IsNull (greenType.GetField ("famANDAssemStaticBlue", flags), "#N21");
5892 Assert.IsNull (greenType.GetField ("famORAssemStaticBlue", flags), "#N22");
5893 Assert.IsNull (greenType.GetField ("publicStaticBlue", flags), "#N23");
5894 Assert.IsNull (greenType.GetField ("assemblyStaticBlue", flags), "#N24");
5895 Assert.IsNull (greenType.GetField ("privateStaticRed", flags), "#N25");
5896 Assert.IsNull (greenType.GetField ("familyStaticRed", flags), "#N26");
5897 Assert.IsNull (greenType.GetField ("famANDAssemStaticRed", flags), "#N27");
5898 Assert.IsNull (greenType.GetField ("famORAssemStaticRed", flags), "#N28");
5899 Assert.IsNull (greenType.GetField ("publicStaticRed", flags), "#N29");
5900 Assert.IsNull (greenType.GetField ("assemblyStaticRed", flags), "#N30");
5901 Assert.IsNotNull (greenType.GetField ("privateStaticGreen", flags), "#N31");
5902 Assert.IsNotNull (greenType.GetField ("familyStaticGreen", flags), "#N32");
5903 Assert.IsNotNull (greenType.GetField ("famANDAssemStaticGreen", flags), "#N33");
5904 Assert.IsNotNull (greenType.GetField ("famORAssemStaticGreen", flags), "#N34");
5905 Assert.IsNotNull (greenType.GetField ("publicStaticGreen", flags), "#N35");
5906 Assert.IsNotNull (greenType.GetField ("assemblyStaticGreen", flags), "#N36");
5910 [Category ("NotDotNet")] // mcs depends on this
5911 public void TestGetPropertiesIncomplete_Mono ()
5913 TypeBuilder tb = module.DefineType (genTypeName ());
5914 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5915 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5916 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5918 PropertyInfo [] properties = tb.GetProperties ();
5919 Assert.AreEqual (2, properties.Length, "#1");
5920 Assert.AreEqual ("Name", properties [0].Name, "#2");
5921 Assert.AreEqual ("FirstName", properties [1].Name, "#3");
5925 [Category ("NotWorking")] // mcs depends on this
5926 public void TestGetPropertiesIncomplete_MS ()
5928 TypeBuilder tb = module.DefineType (genTypeName ());
5929 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5930 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5931 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5934 tb.GetProperties ();
5936 } catch (NotSupportedException ex) {
5937 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5938 Assert.IsNull (ex.InnerException, "#3");
5939 Assert.IsNotNull (ex.Message, "#4");
5944 public void TestGetPropertiesComplete ()
5946 TypeBuilder tb = module.DefineType (genTypeName ());
5947 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
5949 Type emittedType = tb.CreateType ();
5951 Assert.AreEqual (1, tb.GetProperties ().Length);
5952 Assert.AreEqual (tb.GetProperties ().Length, emittedType.GetProperties ().Length);
5956 [Category ("NotDotNet")] // mcs depends on this
5957 public void TestGetPropertiesFlagsIncomplete_Mono ()
5959 PropertyInfo [] properties;
5961 TypeBuilder tb = module.DefineType (genTypeName ());
5962 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5963 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5964 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5966 properties = tb.GetProperties (BindingFlags.Public |
5967 BindingFlags.NonPublic | BindingFlags.Instance);
5968 Assert.AreEqual (3, properties.Length, "#A1");
5969 Assert.AreEqual ("Name", properties [0].Name, "#A2");
5970 Assert.AreEqual ("Income", properties [1].Name, "#A3");
5971 Assert.AreEqual ("FirstName", properties [2].Name, "#A4");
5973 properties = tb.GetProperties (BindingFlags.Public |
5974 BindingFlags.Instance);
5975 Assert.AreEqual (2, properties.Length, "#B1");
5976 Assert.AreEqual ("Name", properties [0].Name, "#B2");
5977 Assert.AreEqual ("FirstName", properties [1].Name, "#B3");
5979 properties = tb.GetProperties (BindingFlags.NonPublic |
5980 BindingFlags.Instance);
5981 Assert.AreEqual (1, properties.Length, "#C1");
5982 Assert.AreEqual ("Income", properties [0].Name, "#C2");
5986 [Category ("NotWorking")] // mcs depends on this
5987 public void TestGetPropertiesFlagsIncomplete_MS ()
5989 TypeBuilder tb = module.DefineType (genTypeName ());
5990 DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
5991 DefineStringProperty (tb, "Income", "income", MethodAttributes.Private);
5992 DefineStringProperty (tb, "FirstName", "firstName", MethodAttributes.Public);
5995 tb.GetProperties (BindingFlags.Public);
5997 } catch (NotSupportedException ex) {
5998 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
5999 Assert.IsNull (ex.InnerException, "#3");
6000 Assert.IsNotNull (ex.Message, "#4");
6005 public void TestGetPropertiesFlagsComplete ()
6007 TypeBuilder tb = module.DefineType (genTypeName ());
6008 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6010 Type emittedType = tb.CreateType ();
6012 Assert.AreEqual (1, tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
6013 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length,
6014 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.Public).Length);
6015 Assert.AreEqual (0, tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
6016 Assert.AreEqual (tb.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length,
6017 emittedType.GetProperties (BindingFlags.Instance | BindingFlags.NonPublic).Length);
6021 public void TestGetPropertiesFlagsComplete_Inheritance ()
6023 PropertyInfo [] props;
6026 TypeBuilder blueType = module.DefineType (genTypeName (),
6027 TypeAttributes.Public);
6028 CreateMembers (blueType, "Blue", false);
6030 TypeBuilder redType = module.DefineType (genTypeName (),
6031 TypeAttributes.Public, blueType);
6032 CreateMembers (redType, "Red", false);
6034 TypeBuilder greenType = module.DefineType (genTypeName (),
6035 TypeAttributes.Public, redType);
6036 CreateMembers (greenType, "Green", false);
6038 blueType.CreateType ();
6039 redType.CreateType ();
6040 greenType.CreateType ();
6042 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6043 props = greenType.GetProperties (flags);
6046 Assert.AreEqual (13, props.Length, "#A1");
6048 Assert.AreEqual (11, props.Length, "#A1");
6050 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#A2");
6051 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#A3");
6052 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#A4");
6053 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#A5");
6054 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#A6");
6055 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#A7");
6056 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#A8");
6057 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#A9");
6059 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#A10");
6060 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#A11");
6061 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#A12");
6062 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#A13");
6063 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#A15");
6065 Assert.AreEqual ("FamilyInstanceBlue", props [8].Name, "#A10");
6066 Assert.AreEqual ("FamANDAssemInstanceBlue", props [9].Name, "#A11");
6067 Assert.AreEqual ("FamORAssemInstanceBlue", props [10].Name, "#A12");
6070 flags = BindingFlags.Instance | BindingFlags.Public;
6071 props = greenType.GetProperties (flags);
6073 Assert.AreEqual (3, props.Length, "#B1");
6074 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#B2");
6075 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#B3");
6076 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#B4");
6078 flags = BindingFlags.Static | BindingFlags.Public;
6079 props = greenType.GetProperties (flags);
6081 Assert.AreEqual (1, props.Length, "#C1");
6082 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#C2");
6084 flags = BindingFlags.Static | BindingFlags.NonPublic;
6085 props = greenType.GetProperties (flags);
6087 Assert.AreEqual (5, props.Length, "#D1");
6088 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#D2");
6089 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#D3");
6090 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#D4");
6091 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#D5");
6092 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#D6");
6094 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6095 BindingFlags.FlattenHierarchy;
6096 props = greenType.GetProperties (flags);
6099 Assert.AreEqual (13, props.Length, "#E1");
6101 Assert.AreEqual (11, props.Length, "#E1");
6103 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#E2");
6104 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#E3");
6105 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#E4");
6106 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#E5");
6107 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#E6");
6108 Assert.AreEqual ("FamilyInstanceRed", props [5].Name, "#E7");
6109 Assert.AreEqual ("FamANDAssemInstanceRed", props [6].Name, "#E8");
6110 Assert.AreEqual ("FamORAssemInstanceRed", props [7].Name, "#E9");
6112 Assert.AreEqual ("AssemblyInstanceRed", props [8].Name, "#E10");
6113 Assert.AreEqual ("FamilyInstanceBlue", props [9].Name, "#E11");
6114 Assert.AreEqual ("FamANDAssemInstanceBlue", props [10].Name, "#E12");
6115 Assert.AreEqual ("FamORAssemInstanceBlue", props [11].Name, "#E13");
6116 Assert.AreEqual ("AssemblyInstanceBlue", props [12].Name, "#E14");
6118 Assert.AreEqual ("FamilyInstanceBlue", props [8].Name, "#E10");
6119 Assert.AreEqual ("FamANDAssemInstanceBlue", props [9].Name, "#E11");
6120 Assert.AreEqual ("FamORAssemInstanceBlue", props [10].Name, "#E12");
6123 flags = BindingFlags.Instance | BindingFlags.Public |
6124 BindingFlags.FlattenHierarchy;
6125 props = greenType.GetProperties (flags);
6127 Assert.AreEqual (3, props.Length, "#F1");
6128 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#F2");
6129 Assert.AreEqual ("PublicInstanceRed", props [1].Name, "#F3");
6130 Assert.AreEqual ("PublicInstanceBlue", props [2].Name, "#F4");
6132 flags = BindingFlags.Static | BindingFlags.Public |
6133 BindingFlags.FlattenHierarchy;
6134 props = greenType.GetProperties (flags);
6136 Assert.AreEqual (3, props.Length, "#G1");
6137 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#G2");
6138 Assert.AreEqual ("PublicStaticRed", props [1].Name, "#G3");
6139 Assert.AreEqual ("PublicStaticBlue", props [2].Name, "#G4");
6141 flags = BindingFlags.Static | BindingFlags.NonPublic |
6142 BindingFlags.FlattenHierarchy;
6143 props = greenType.GetProperties (flags);
6146 Assert.AreEqual (13, props.Length, "#H1");
6148 Assert.AreEqual (11, props.Length, "#H1");
6150 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#H2");
6151 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#H3");
6152 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#H4");
6153 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#H5");
6154 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#H6");
6155 Assert.AreEqual ("FamilyStaticRed", props [5].Name, "#H7");
6156 Assert.AreEqual ("FamANDAssemStaticRed", props [6].Name, "#H8");
6157 Assert.AreEqual ("FamORAssemStaticRed", props [7].Name, "#H9");
6159 Assert.AreEqual ("AssemblyStaticRed", props [8].Name, "#H10");
6160 Assert.AreEqual ("FamilyStaticBlue", props [9].Name, "#H11");
6161 Assert.AreEqual ("FamANDAssemStaticBlue", props [10].Name, "#H12");
6162 Assert.AreEqual ("FamORAssemStaticBlue", props [11].Name, "#H13");
6163 Assert.AreEqual ("AssemblyStaticBlue", props [12].Name, "#H14");
6165 Assert.AreEqual ("FamilyStaticBlue", props [8].Name, "#H10");
6166 Assert.AreEqual ("FamANDAssemStaticBlue", props [9].Name, "#H11");
6167 Assert.AreEqual ("FamORAssemStaticBlue", props [10].Name, "#H12");
6170 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6171 BindingFlags.DeclaredOnly;
6172 props = greenType.GetProperties (flags);
6174 Assert.AreEqual (5, props.Length, "#I1");
6175 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#I2");
6176 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#I3");
6177 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#I4");
6178 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#I5");
6179 Assert.AreEqual ("AssemblyInstanceGreen", props [4].Name, "#I6");
6181 flags = BindingFlags.Instance | BindingFlags.Public |
6182 BindingFlags.DeclaredOnly;
6183 props = greenType.GetProperties (flags);
6185 Assert.AreEqual (1, props.Length, "#J1");
6186 Assert.AreEqual ("PublicInstanceGreen", props [0].Name, "#J2");
6188 flags = BindingFlags.Static | BindingFlags.Public |
6189 BindingFlags.DeclaredOnly;
6190 props = greenType.GetProperties (flags);
6192 Assert.AreEqual (1, props.Length, "#K1");
6193 Assert.AreEqual ("PublicStaticGreen", props [0].Name, "#K2");
6195 flags = BindingFlags.Static | BindingFlags.NonPublic |
6196 BindingFlags.DeclaredOnly;
6197 props = greenType.GetProperties (flags);
6199 Assert.AreEqual (5, props.Length, "#L1");
6200 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#L2");
6201 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#L3");
6202 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#L4");
6203 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#L5");
6204 Assert.AreEqual ("AssemblyStaticGreen", props [4].Name, "#L6");
6206 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6207 BindingFlags.Public;
6208 props = greenType.GetProperties (flags);
6211 Assert.AreEqual (16, props.Length, "#M1");
6213 Assert.AreEqual (14, props.Length, "#M1");
6215 Assert.AreEqual ("PrivateInstanceGreen", props [0].Name, "#M2");
6216 Assert.AreEqual ("FamilyInstanceGreen", props [1].Name, "#M3");
6217 Assert.AreEqual ("FamANDAssemInstanceGreen", props [2].Name, "#M4");
6218 Assert.AreEqual ("FamORAssemInstanceGreen", props [3].Name, "#M5");
6219 Assert.AreEqual ("PublicInstanceGreen", props [4].Name, "#M6");
6220 Assert.AreEqual ("AssemblyInstanceGreen", props [5].Name, "#M7");
6221 Assert.AreEqual ("FamilyInstanceRed", props [6].Name, "#M8");
6222 Assert.AreEqual ("FamANDAssemInstanceRed", props [7].Name, "#M9");
6223 Assert.AreEqual ("FamORAssemInstanceRed", props [8].Name, "#M10");
6224 Assert.AreEqual ("PublicInstanceRed", props [9].Name, "#M11");
6226 Assert.AreEqual ("AssemblyInstanceRed", props [10].Name, "#M12");
6227 Assert.AreEqual ("FamilyInstanceBlue", props [11].Name, "#M13");
6228 Assert.AreEqual ("FamANDAssemInstanceBlue", props [12].Name, "#M14");
6229 Assert.AreEqual ("FamORAssemInstanceBlue", props [13].Name, "#M15");
6230 Assert.AreEqual ("PublicInstanceBlue", props [14].Name, "#M16");
6231 Assert.AreEqual ("AssemblyInstanceBlue", props [15].Name, "#M17");
6233 Assert.AreEqual ("FamilyInstanceBlue", props [10].Name, "#M12");
6234 Assert.AreEqual ("FamANDAssemInstanceBlue", props [11].Name, "#M13");
6235 Assert.AreEqual ("FamORAssemInstanceBlue", props [12].Name, "#M14");
6236 Assert.AreEqual ("PublicInstanceBlue", props [13].Name, "#M15");
6239 flags = BindingFlags.Static | BindingFlags.NonPublic |
6240 BindingFlags.Public;
6241 props = greenType.GetProperties (flags);
6243 Assert.AreEqual (6, props.Length, "#N1");
6244 Assert.AreEqual ("PrivateStaticGreen", props [0].Name, "#N2");
6245 Assert.AreEqual ("FamilyStaticGreen", props [1].Name, "#N3");
6246 Assert.AreEqual ("FamANDAssemStaticGreen", props [2].Name, "#N4");
6247 Assert.AreEqual ("FamORAssemStaticGreen", props [3].Name, "#N5");
6248 Assert.AreEqual ("PublicStaticGreen", props [4].Name, "#N6");
6249 Assert.AreEqual ("AssemblyStaticGreen", props [5].Name, "#N7");
6253 public void TestGetPropertyIncomplete ()
6255 TypeBuilder tb = module.DefineType (genTypeName ());
6257 tb.GetProperty ("test");
6259 } catch (NotSupportedException ex) {
6260 // The invoked member is not supported in a
6262 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6263 Assert.IsNull (ex.InnerException, "#3");
6264 Assert.IsNotNull (ex.Message, "#4");
6269 public void TestGetPropertyComplete ()
6271 TypeBuilder tb = module.DefineType (genTypeName ());
6272 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6274 Type emittedType = tb.CreateType ();
6276 Assert.IsNotNull (emittedType.GetProperty ("CustomerName"));
6277 Assert.IsNull (emittedType.GetProperty ("OtherCustomerName"));
6280 tb.GetProperty ("CustomerName");
6282 } catch (NotSupportedException ex) {
6283 // The invoked member is not supported in a
6285 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6286 Assert.IsNull (ex.InnerException, "#3");
6287 Assert.IsNotNull (ex.Message, "#4");
6292 public void TestGetPropertyFlagsIncomplete ()
6294 TypeBuilder tb = module.DefineType (genTypeName ());
6296 tb.GetProperty ("test", BindingFlags.Public);
6298 } catch (NotSupportedException ex) {
6299 // The invoked member is not supported in a
6301 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6302 Assert.IsNull (ex.InnerException, "#3");
6303 Assert.IsNotNull (ex.Message, "#4");
6308 public void TestGetPropertyFlagsComplete ()
6310 TypeBuilder tb = module.DefineType (genTypeName ());
6311 DefineStringProperty (tb, "CustomerName", "customerName", MethodAttributes.Public);
6313 Type emittedType = tb.CreateType ();
6315 Assert.IsNotNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6316 BindingFlags.Public));
6317 Assert.IsNull (emittedType.GetProperty ("CustomerName", BindingFlags.Instance |
6318 BindingFlags.NonPublic));
6321 tb.GetProperty ("CustomerName", BindingFlags.Instance | BindingFlags.Public);
6323 } catch (NotSupportedException ex) {
6324 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
6325 Assert.IsNull (ex.InnerException, "#3");
6326 Assert.IsNotNull (ex.Message, "#4");
6331 public void TestGetMethodFlagsComplete ()
6335 TypeBuilder blueType = module.DefineType (genTypeName (),
6336 TypeAttributes.Public);
6337 CreateMembers (blueType, "Blue", false);
6339 TypeBuilder redType = module.DefineType (genTypeName (),
6340 TypeAttributes.Public, blueType);
6341 CreateMembers (redType, "Red", false);
6343 TypeBuilder greenType = module.DefineType (genTypeName (),
6344 TypeAttributes.Public, redType);
6345 CreateMembers (greenType, "Green", false);
6347 blueType.CreateType ();
6348 redType.CreateType ();
6349 greenType.CreateType ();
6351 flags = BindingFlags.Instance | BindingFlags.NonPublic;
6353 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#A1");
6354 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#A2");
6355 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#A3");
6356 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#A4");
6357 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#A5");
6359 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#A6");
6361 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#A6");
6363 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#A7");
6364 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#A8");
6365 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#A9");
6366 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#A10");
6367 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#A11");
6369 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#A12");
6371 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#A12");
6373 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#A13");
6374 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#A14");
6375 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#A15");
6376 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#A16");
6377 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#A17");
6378 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#A18");
6379 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#A19");
6380 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#A20");
6381 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#A21");
6382 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#A22");
6383 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#A23");
6384 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#A24");
6385 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#A25");
6386 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#A26");
6387 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#A27");
6388 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#A28");
6389 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#A29");
6390 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#A30");
6391 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#A31");
6392 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#A32");
6393 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#A33");
6394 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#A34");
6395 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#A35");
6396 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#A36");
6398 flags = BindingFlags.Instance | BindingFlags.Public;
6400 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#B1");
6401 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#B2");
6402 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#B3");
6403 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#B4");
6404 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#B5");
6405 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#B6");
6406 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#B7");
6407 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#B8");
6408 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#B9");
6409 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#B10");
6410 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#B11");
6411 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#B12");
6412 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#B13");
6413 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#B14");
6414 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#B15");
6415 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#B16");
6416 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#B17");
6417 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#B18");
6418 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#B19");
6419 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#B20");
6420 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#B21");
6421 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#B22");
6422 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#B23");
6423 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#B24");
6424 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#B25");
6425 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#B26");
6426 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#B27");
6427 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#B28");
6428 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#B29");
6429 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#B30");
6430 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#B31");
6431 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#B32");
6432 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#B33");
6433 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#B34");
6434 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#B35");
6435 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#B36");
6437 flags = BindingFlags.Static | BindingFlags.Public;
6439 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#C1");
6440 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#C2");
6441 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#C3");
6442 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#C4");
6443 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#C5");
6444 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#C6");
6445 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#C7");
6446 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#C8");
6447 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#C9");
6448 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#C10");
6449 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#C11");
6450 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#C12");
6451 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#C13");
6452 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#C14");
6453 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#C15");
6454 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#C16");
6455 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#C17");
6456 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#C18");
6457 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#C19");
6458 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#C20");
6459 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#C21");
6460 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#C22");
6461 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#C23");
6462 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#C24");
6463 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#C25");
6464 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#C26");
6465 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#C27");
6466 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#C28");
6467 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#C29");
6468 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#C30");
6469 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#C31");
6470 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#C32");
6471 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#C33");
6472 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#C34");
6473 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#C35");
6474 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#C36");
6476 flags = BindingFlags.Static | BindingFlags.NonPublic;
6478 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#D1");
6479 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#D2");
6480 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#D3");
6481 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#D4");
6482 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#D5");
6483 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#D6");
6484 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#D7");
6485 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#D8");
6486 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#D9");
6487 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#D10");
6488 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#D11");
6489 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#D12");
6490 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#D13");
6491 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#D14");
6492 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#D15");
6493 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#D16");
6494 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#D17");
6495 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#D18");
6496 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#D19");
6497 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#D20");
6498 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#D21");
6499 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#D22");
6500 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#D23");
6501 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#D24");
6502 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#D25");
6503 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#D26");
6504 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#D27");
6505 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#D28");
6506 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#D29");
6507 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#D30");
6508 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#D31");
6509 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#D32");
6510 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#D33");
6511 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#D34");
6512 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#D35");
6513 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#D36");
6515 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6516 BindingFlags.FlattenHierarchy;
6518 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#E1");
6519 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#E2");
6520 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#E3");
6521 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#E4");
6522 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#E5");
6524 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#E6");
6526 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#E6");
6528 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#E7");
6529 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#E8");
6530 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#E9");
6531 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#E10");
6532 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#E11");
6534 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#E12");
6536 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#E12");
6538 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#E13");
6539 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#E14");
6540 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#E15");
6541 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#E16");
6542 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#E17");
6543 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#E18");
6544 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#E19");
6545 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#E20");
6546 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#E21");
6547 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#E22");
6548 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#E23");
6549 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#E24");
6550 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#E25");
6551 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#E26");
6552 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#E27");
6553 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#E28");
6554 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#E29");
6555 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#E30");
6556 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#E31");
6557 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#E32");
6558 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#E33");
6559 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#E34");
6560 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#E35");
6561 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#E36");
6563 flags = BindingFlags.Instance | BindingFlags.Public |
6564 BindingFlags.FlattenHierarchy;
6566 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#F1");
6567 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#F2");
6568 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#F3");
6569 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#F4");
6570 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#F5");
6571 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#F6");
6572 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#F7");
6573 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#F8");
6574 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#F9");
6575 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#F10");
6576 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#F11");
6577 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#F12");
6578 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#F13");
6579 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#F14");
6580 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#F15");
6581 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#F16");
6582 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#F17");
6583 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#F18");
6584 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#F19");
6585 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#F20");
6586 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#F21");
6587 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#F22");
6588 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#F23");
6589 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#F24");
6590 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#F25");
6591 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#F26");
6592 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#F27");
6593 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#F28");
6594 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#F29");
6595 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#F30");
6596 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#F31");
6597 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#F32");
6598 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#F33");
6599 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#F34");
6600 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#F35");
6601 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#F36");
6603 flags = BindingFlags.Static | BindingFlags.Public |
6604 BindingFlags.FlattenHierarchy;
6606 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#G1");
6607 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#G2");
6608 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#G3");
6609 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#G4");
6610 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#G5");
6611 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#G6");
6612 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#G7");
6613 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#G8");
6614 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#G9");
6615 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#G10");
6616 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#G11");
6617 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#G12");
6618 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#G13");
6619 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#G14");
6620 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#G15");
6621 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#G16");
6622 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#G17");
6623 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#G18");
6624 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#G19");
6625 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#G20");
6626 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#G21");
6627 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#G22");
6628 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#G23");
6629 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#G24");
6630 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#G25");
6631 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#G26");
6632 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#G27");
6633 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#G28");
6634 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#G29");
6635 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#G30");
6636 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#G31");
6637 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#G32");
6638 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#G33");
6639 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#G34");
6640 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#G35");
6641 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#G36");
6643 flags = BindingFlags.Static | BindingFlags.NonPublic |
6644 BindingFlags.FlattenHierarchy;
6646 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#H1");
6647 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#H2");
6648 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#H3");
6649 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#H4");
6650 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#H5");
6651 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#H6");
6652 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#H7");
6653 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#H8");
6654 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#H9");
6655 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#H10");
6656 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#H11");
6657 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#H12");
6658 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#H13");
6659 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#H14");
6660 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#H15");
6661 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#H16");
6662 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#H17");
6663 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#H18");
6664 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#H19");
6665 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#H20");
6666 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#H21");
6667 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#H22");
6668 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#H23");
6670 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#H24");
6672 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#H24");
6674 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#H25");
6675 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#H26");
6676 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#H27");
6677 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#H28");
6678 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#H29");
6680 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#H30");
6682 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#H30");
6684 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#H31");
6685 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#H32");
6686 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#H33");
6687 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#H34");
6688 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#H35");
6689 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#H36");
6691 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6692 BindingFlags.DeclaredOnly;
6694 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#I1");
6695 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#I2");
6696 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#I3");
6697 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#I4");
6698 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#I5");
6699 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#I6");
6700 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#I7");
6701 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#I8");
6702 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#I9");
6703 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#I10");
6704 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#I11");
6705 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#I12");
6706 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#I13");
6707 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#I14");
6708 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#I15");
6709 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#I16");
6710 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#I17");
6711 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#I18");
6712 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#I19");
6713 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#I20");
6714 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#I21");
6715 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#I22");
6716 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#I23");
6717 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#I24");
6718 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#I25");
6719 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#I26");
6720 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#I27");
6721 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#I28");
6722 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#I29");
6723 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#I30");
6724 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#I31");
6725 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#I32");
6726 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#I33");
6727 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#I34");
6728 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#I35");
6729 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#I36");
6731 flags = BindingFlags.Instance | BindingFlags.Public |
6732 BindingFlags.DeclaredOnly;
6734 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#J1");
6735 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#J2");
6736 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#J3");
6737 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#J4");
6738 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#J5");
6739 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#J6");
6740 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#J7");
6741 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#J8");
6742 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#J9");
6743 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#J10");
6744 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#J11");
6745 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#J12");
6746 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#J13");
6747 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#J14");
6748 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#J15");
6749 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#J16");
6750 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#J17");
6751 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#J18");
6752 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#J19");
6753 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#J20");
6754 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#J21");
6755 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#J22");
6756 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#J23");
6757 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#J24");
6758 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#J25");
6759 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#J26");
6760 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#J27");
6761 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#J28");
6762 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#J29");
6763 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#J30");
6764 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#J31");
6765 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#J32");
6766 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#J33");
6767 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#J34");
6768 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#J35");
6769 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#J36");
6771 flags = BindingFlags.Static | BindingFlags.Public |
6772 BindingFlags.DeclaredOnly;
6774 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#K1");
6775 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#K2");
6776 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#K3");
6777 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#K4");
6778 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#K5");
6779 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#K6");
6780 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#K7");
6781 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#K8");
6782 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#K9");
6783 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#K10");
6784 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#K11");
6785 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#K12");
6786 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#K13");
6787 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#K14");
6788 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#K15");
6789 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#K16");
6790 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#K17");
6791 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#K18");
6792 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#K19");
6793 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#K20");
6794 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#K21");
6795 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#K22");
6796 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#K23");
6797 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#K24");
6798 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#K25");
6799 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#K26");
6800 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#K27");
6801 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#K28");
6802 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#K29");
6803 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#K30");
6804 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#K31");
6805 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#K32");
6806 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#K33");
6807 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#K34");
6808 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#K35");
6809 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#K36");
6811 flags = BindingFlags.Static | BindingFlags.NonPublic |
6812 BindingFlags.DeclaredOnly;
6814 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#L1");
6815 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#L2");
6816 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#L3");
6817 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#L4");
6818 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#L5");
6819 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#L6");
6820 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#L7");
6821 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#L8");
6822 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#L9");
6823 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#L10");
6824 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#L11");
6825 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#L12");
6826 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#L13");
6827 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#L14");
6828 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#L15");
6829 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#L16");
6830 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#L17");
6831 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#L18");
6832 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#L19");
6833 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#L20");
6834 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#L21");
6835 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#L22");
6836 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#L23");
6837 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#L24");
6838 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#L25");
6839 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#L26");
6840 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#L27");
6841 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#L28");
6842 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#L29");
6843 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#L30");
6844 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#L31");
6845 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#L32");
6846 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#L33");
6847 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#L34");
6848 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#L35");
6849 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#L36");
6851 flags = BindingFlags.Instance | BindingFlags.NonPublic |
6852 BindingFlags.Public;
6854 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#M1");
6855 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#M2");
6856 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#M3");
6857 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#M4");
6858 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#M5");
6860 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#M6");
6862 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#M6");
6864 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#M7");
6865 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#M8");
6866 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#M9");
6867 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#M10");
6868 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#M11");
6870 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#M12");
6872 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#M12");
6874 Assert.IsNotNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#M13");
6875 Assert.IsNotNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#M14");
6876 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#M15");
6877 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#M16");
6878 Assert.IsNotNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#M17");
6879 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#M18");
6880 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#M19");
6881 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#M20");
6882 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#M21");
6883 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#M22");
6884 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#M23");
6885 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#M24");
6886 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#M25");
6887 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#M26");
6888 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#M27");
6889 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#M28");
6890 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#M29");
6891 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#M30");
6892 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#M31");
6893 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#M32");
6894 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#M33");
6895 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#M34");
6896 Assert.IsNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#M35");
6897 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#M36");
6899 flags = BindingFlags.Static | BindingFlags.NonPublic |
6900 BindingFlags.Public;
6902 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceBlue", flags), "#N1");
6903 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceBlue", flags), "#N2");
6904 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceBlue", flags), "#N3");
6905 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceBlue", flags), "#N4");
6906 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceBlue", flags), "#N5");
6907 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceBlue", flags), "#N6");
6908 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceRed", flags), "#N7");
6909 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceRed", flags), "#N8");
6910 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceRed", flags), "#N9");
6911 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceRed", flags), "#N10");
6912 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceRed", flags), "#N11");
6913 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceRed", flags), "#N12");
6914 Assert.IsNull (greenType.GetMethod ("GetPrivateInstanceGreen", flags), "#N13");
6915 Assert.IsNull (greenType.GetMethod ("GetFamilyInstanceGreen", flags), "#N14");
6916 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemInstanceGreen", flags), "#N15");
6917 Assert.IsNull (greenType.GetMethod ("GetFamORAssemInstanceGreen", flags), "#N16");
6918 Assert.IsNull (greenType.GetMethod ("GetPublicInstanceGreen", flags), "#N17");
6919 Assert.IsNull (greenType.GetMethod ("GetAssemblyInstanceGreen", flags), "#N18");
6920 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticBlue", flags), "#N19");
6921 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticBlue", flags), "#N20");
6922 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticBlue", flags), "#N21");
6923 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticBlue", flags), "#N22");
6924 Assert.IsNull (greenType.GetMethod ("GetPublicStaticBlue", flags), "#N23");
6925 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticBlue", flags), "#N24");
6926 Assert.IsNull (greenType.GetMethod ("GetPrivateStaticRed", flags), "#N25");
6927 Assert.IsNull (greenType.GetMethod ("GetFamilyStaticRed", flags), "#N26");
6928 Assert.IsNull (greenType.GetMethod ("GetFamANDAssemStaticRed", flags), "#N27");
6929 Assert.IsNull (greenType.GetMethod ("GetFamORAssemStaticRed", flags), "#N28");
6930 Assert.IsNull (greenType.GetMethod ("GetPublicStaticRed", flags), "#N29");
6931 Assert.IsNull (greenType.GetMethod ("GetAssemblyStaticRed", flags), "#N30");
6932 Assert.IsNotNull (greenType.GetMethod ("GetPrivateStaticGreen", flags), "#N31");
6933 Assert.IsNotNull (greenType.GetMethod ("GetFamilyStaticGreen", flags), "#N32");
6934 Assert.IsNotNull (greenType.GetMethod ("GetFamANDAssemStaticGreen", flags), "#N33");
6935 Assert.IsNotNull (greenType.GetMethod ("GetFamORAssemStaticGreen", flags), "#N34");
6936 Assert.IsNotNull (greenType.GetMethod ("GetPublicStaticGreen", flags), "#N35");
6937 Assert.IsNotNull (greenType.GetMethod ("GetAssemblyStaticGreen", flags), "#N36");
6941 [Category ("NotDotNet")] // mcs depends on this
6942 public void TestGetMethodsIncomplete_Mono ()
6947 TypeBuilder tb = module.DefineType (genTypeName (),
6948 TypeAttributes.Abstract);
6949 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
6950 typeof (void), Type.EmptyTypes);
6951 ilgen = mb.GetILGenerator ();
6952 ilgen.Emit (OpCodes.Ret);
6954 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
6955 typeof (void), Type.EmptyTypes);
6956 ilgen = mb.GetILGenerator ();
6957 ilgen.Emit (OpCodes.Ret);
6959 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
6960 MethodAttributes.Static,
6961 typeof (void), Type.EmptyTypes);
6962 ilgen = mb.GetILGenerator ();
6963 ilgen.Emit (OpCodes.Ret);
6965 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
6966 MethodAttributes.Abstract | MethodAttributes.Virtual,
6967 typeof (void), Type.EmptyTypes);
6969 MethodInfo [] methods = tb.GetMethods ();
6970 Assert.AreEqual (7, methods.Length, "#A");
6972 Assert.AreEqual ("Equals", methods [0].Name, "#B1");
6973 Assert.IsFalse (methods [0].IsStatic, "#B2");
6974 Assert.IsFalse (methods [0].IsAbstract, "#B3");
6976 Assert.AreEqual ("GetHashCode", methods [1].Name, "#C1");
6977 Assert.IsFalse (methods [1].IsStatic, "#C2");
6978 Assert.IsFalse (methods [1].IsAbstract, "#C3");
6980 Assert.AreEqual ("GetType", methods [2].Name, "#D1");
6981 Assert.IsFalse (methods [2].IsStatic, "#D2");
6982 Assert.IsFalse (methods [2].IsAbstract, "#D3");
6984 Assert.AreEqual ("ToString", methods [3].Name, "#E1");
6985 Assert.IsFalse (methods [3].IsStatic, "#E2");
6986 Assert.IsFalse (methods [3].IsAbstract, "#E3");
6988 Assert.AreEqual ("Hello", methods [4].Name, "#F1");
6989 Assert.IsFalse (methods [4].IsStatic, "#F2");
6990 Assert.IsFalse (methods [4].IsAbstract, "#F3");
6992 Assert.AreEqual ("Execute", methods [5].Name, "#G1");
6993 Assert.IsTrue (methods [5].IsStatic, "#G2");
6994 Assert.IsFalse (methods [5].IsAbstract, "#G3");
6996 Assert.AreEqual ("Init", methods [6].Name, "#H1");
6997 Assert.IsFalse (methods [6].IsStatic, "#H2");
6998 Assert.IsTrue (methods [6].IsAbstract, "#H3");
7002 [Category ("NotWorking")] // mcs depends on this
7003 public void TestGetMethodsIncomplete_MS ()
7008 TypeBuilder tb = module.DefineType (genTypeName (),
7009 TypeAttributes.Abstract);
7010 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7011 typeof (void), Type.EmptyTypes);
7012 ilgen = mb.GetILGenerator ();
7013 ilgen.Emit (OpCodes.Ret);
7015 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7016 typeof (void), Type.EmptyTypes);
7017 ilgen = mb.GetILGenerator ();
7018 ilgen.Emit (OpCodes.Ret);
7020 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7021 MethodAttributes.Static,
7022 typeof (void), Type.EmptyTypes);
7023 ilgen = mb.GetILGenerator ();
7024 ilgen.Emit (OpCodes.Ret);
7026 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7027 MethodAttributes.Abstract | MethodAttributes.Virtual,
7028 typeof (void), Type.EmptyTypes);
7033 } catch (NotSupportedException ex) {
7034 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
7035 Assert.IsNull (ex.InnerException, "#3");
7036 Assert.IsNotNull (ex.Message, "#4");
7041 public void TestGetMethodsComplete ()
7047 TypeBuilder tb = module.DefineType (genTypeName (),
7048 TypeAttributes.Abstract);
7049 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7050 typeof (string), Type.EmptyTypes);
7051 ilgen = mb.GetILGenerator ();
7052 ilgen.Emit (OpCodes.Ldstr, "Hi! ");
7053 ilgen.Emit (OpCodes.Ldarg_1);
7054 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
7055 new Type [] { typeof (string), typeof (string) });
7056 ilgen.Emit (OpCodes.Call, infoMethod);
7057 ilgen.Emit (OpCodes.Ret);
7059 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7060 typeof (void), Type.EmptyTypes);
7061 ilgen = mb.GetILGenerator ();
7062 ilgen.Emit (OpCodes.Ret);
7064 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7065 MethodAttributes.Static,
7066 typeof (void), Type.EmptyTypes);
7067 ilgen = mb.GetILGenerator ();
7068 ilgen.Emit (OpCodes.Ret);
7070 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7071 MethodAttributes.Abstract | MethodAttributes.Virtual,
7072 typeof (void), Type.EmptyTypes);
7074 Type emittedType = tb.CreateType ();
7076 MethodInfo [] methods = emittedType.GetMethods ();
7077 Assert.AreEqual (7, methods.Length, "#A1");
7078 Assert.AreEqual (7, tb.GetMethods ().Length, "#A2");
7080 mi = GetMethodByName (methods, "Hello");
7081 Assert.IsNotNull (mi, "#B1");
7082 Assert.IsFalse (mi.IsStatic, "#B2");
7083 Assert.IsFalse (mi.IsAbstract, "#B3");
7085 mi = GetMethodByName (methods, "Execute");
7086 Assert.IsNotNull (mi, "#C1");
7087 Assert.IsTrue (mi.IsStatic, "#C2");
7088 Assert.IsFalse (mi.IsAbstract, "#C3");
7090 mi = GetMethodByName (methods, "Init");
7091 Assert.IsNotNull (mi, "#D1");
7092 Assert.IsFalse (mi.IsStatic, "#D2");
7093 Assert.IsTrue (mi.IsAbstract, "#D3");
7095 mi = GetMethodByName (methods, "GetType");
7096 Assert.IsNotNull (mi, "#E1");
7097 Assert.IsFalse (methods [3].IsStatic, "#E2");
7098 Assert.IsFalse (methods [3].IsAbstract, "#E3");
7100 mi = GetMethodByName (methods, "ToString");
7101 Assert.IsNotNull (mi, "#F1");
7102 Assert.IsFalse (mi.IsStatic, "#F2");
7103 Assert.IsFalse (mi.IsAbstract, "#F3");
7105 mi = GetMethodByName (methods, "Equals");
7106 Assert.IsNotNull (mi, "#G1");
7107 Assert.IsFalse (mi.IsStatic, "#G2");
7108 Assert.IsFalse (mi.IsAbstract, "#G3");
7110 mi = GetMethodByName (methods, "GetHashCode");
7111 Assert.IsNotNull (mi, "#H1");
7112 Assert.IsFalse (mi.IsStatic, "#H2");
7113 Assert.IsFalse (mi.IsAbstract, "#H3");
7117 [Category ("NotDotNet")] // mcs depends on this
7118 public void TestGetMethodsFlagsIncomplete_Inheritance ()
7120 MethodInfo [] methods;
7123 TypeBuilder blueType = module.DefineType (genTypeName (),
7124 TypeAttributes.Public);
7125 CreateMembers (blueType, "Blue", false);
7127 TypeBuilder redType = module.DefineType (genTypeName (),
7128 TypeAttributes.Public, blueType);
7129 CreateMembers (redType, "Red", false);
7131 TypeBuilder greenType = module.DefineType (genTypeName (),
7132 TypeAttributes.Public, redType);
7133 CreateMembers (greenType, "Green", false);
7135 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7136 methods = greenType.GetMethods (flags);
7138 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7139 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7140 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7141 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7142 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7144 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7146 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7148 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7149 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7150 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7151 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7152 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7154 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7156 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7158 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7159 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7160 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7161 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7162 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7163 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7164 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7165 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7166 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7167 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7168 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7169 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7170 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7171 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7172 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7173 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7174 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7175 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7176 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7177 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7178 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7179 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7180 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7181 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7183 flags = BindingFlags.Instance | BindingFlags.Public;
7184 methods = greenType.GetMethods (flags);
7186 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7187 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7188 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7189 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7190 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7191 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7192 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7193 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7194 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7195 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7196 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7197 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7198 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7199 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7200 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7201 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7202 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7203 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7204 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7205 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7206 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7207 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7208 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7209 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7210 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7211 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7212 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7213 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7214 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7215 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7216 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7217 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7218 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7219 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7220 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7221 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7223 flags = BindingFlags.Static | BindingFlags.Public;
7224 methods = greenType.GetMethods (flags);
7226 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7227 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7228 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7229 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7230 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7231 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7232 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7233 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7234 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7235 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7236 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7237 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7238 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7239 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7240 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7241 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7242 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7243 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7244 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7245 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7246 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7247 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7248 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7249 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
7250 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
7251 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
7252 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
7253 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
7254 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
7255 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
7256 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
7257 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
7258 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
7259 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
7260 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
7261 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
7263 flags = BindingFlags.Static | BindingFlags.NonPublic;
7264 methods = greenType.GetMethods (flags);
7266 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
7267 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
7268 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
7269 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
7270 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
7271 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
7272 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
7273 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
7274 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
7275 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
7276 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
7277 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
7278 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
7279 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
7280 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
7281 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
7282 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
7283 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
7284 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
7285 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
7286 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
7287 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
7288 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
7289 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
7290 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
7291 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
7292 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
7293 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
7294 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
7295 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
7296 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
7297 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
7298 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
7299 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
7300 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
7301 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
7303 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7304 BindingFlags.FlattenHierarchy;
7305 methods = greenType.GetMethods (flags);
7307 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
7308 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
7309 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
7310 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
7311 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
7313 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7315 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
7317 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
7318 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
7319 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
7320 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
7321 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
7323 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7325 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
7327 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
7328 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
7329 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
7330 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
7331 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
7332 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
7333 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
7334 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
7335 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
7336 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
7337 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
7338 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
7339 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
7340 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
7341 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
7342 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
7343 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
7344 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
7345 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
7346 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
7347 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
7348 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
7349 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
7350 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
7352 flags = BindingFlags.Instance | BindingFlags.Public |
7353 BindingFlags.FlattenHierarchy;
7354 methods = greenType.GetMethods (flags);
7356 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
7357 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
7358 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
7359 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
7360 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
7361 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
7362 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
7363 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
7364 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
7365 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
7366 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
7367 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
7368 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
7369 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
7370 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
7371 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
7372 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
7373 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
7374 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
7375 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
7376 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
7377 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
7378 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
7379 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
7380 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
7381 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
7382 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
7383 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
7384 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
7385 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
7386 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
7387 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
7388 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
7389 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
7390 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
7391 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
7393 flags = BindingFlags.Static | BindingFlags.Public |
7394 BindingFlags.FlattenHierarchy;
7395 methods = greenType.GetMethods (flags);
7397 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
7398 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
7399 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
7400 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
7401 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
7402 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
7403 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
7404 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
7405 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
7406 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
7407 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
7408 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
7409 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
7410 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
7411 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
7412 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
7413 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
7414 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
7415 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
7416 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
7417 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
7418 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
7419 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
7420 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
7421 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
7422 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
7423 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
7424 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
7425 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
7426 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
7427 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
7428 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
7429 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
7430 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
7431 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
7432 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
7434 flags = BindingFlags.Static | BindingFlags.NonPublic |
7435 BindingFlags.FlattenHierarchy;
7436 methods = greenType.GetMethods (flags);
7438 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
7439 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
7440 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
7441 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
7442 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
7443 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
7444 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
7445 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
7446 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
7447 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
7448 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
7449 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
7450 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
7451 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
7452 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
7453 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
7454 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
7455 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
7456 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
7457 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
7458 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
7459 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
7460 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
7462 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
7464 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
7466 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
7467 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
7468 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
7469 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
7470 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
7472 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
7474 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
7476 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
7477 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
7478 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
7479 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
7480 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
7481 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
7483 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7484 BindingFlags.DeclaredOnly;
7485 methods = greenType.GetMethods (flags);
7487 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
7488 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
7489 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
7490 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
7491 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
7492 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
7493 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
7494 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
7495 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
7496 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
7497 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
7498 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
7499 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
7500 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
7501 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
7502 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
7503 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
7504 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
7505 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
7506 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
7507 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
7508 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
7509 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
7510 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
7511 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
7512 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
7513 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
7514 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
7515 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
7516 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
7517 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
7518 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
7519 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
7520 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
7521 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
7522 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
7524 flags = BindingFlags.Instance | BindingFlags.Public |
7525 BindingFlags.DeclaredOnly;
7526 methods = greenType.GetMethods (flags);
7528 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
7529 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
7530 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
7531 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
7532 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
7533 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
7534 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
7535 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
7536 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
7537 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
7538 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
7539 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
7540 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
7541 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
7542 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
7543 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
7544 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
7545 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
7546 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
7547 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
7548 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
7549 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
7550 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
7551 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
7552 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
7553 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
7554 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
7555 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
7556 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
7557 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
7558 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
7559 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
7560 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
7561 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
7562 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
7563 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
7565 flags = BindingFlags.Static | BindingFlags.Public |
7566 BindingFlags.DeclaredOnly;
7567 methods = greenType.GetMethods (flags);
7569 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
7570 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
7571 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
7572 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
7573 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
7574 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
7575 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
7576 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
7577 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
7578 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
7579 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
7580 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
7581 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
7582 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
7583 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
7584 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
7585 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
7586 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
7587 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
7588 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
7589 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
7590 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
7591 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
7592 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
7593 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
7594 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
7595 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
7596 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
7597 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
7598 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
7599 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
7600 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
7601 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
7602 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
7603 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
7604 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
7606 flags = BindingFlags.Static | BindingFlags.NonPublic |
7607 BindingFlags.DeclaredOnly;
7608 methods = greenType.GetMethods (flags);
7610 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
7611 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
7612 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
7613 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
7614 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
7615 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
7616 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
7617 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
7618 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
7619 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
7620 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
7621 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
7622 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
7623 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
7624 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
7625 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
7626 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
7627 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
7628 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
7629 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
7630 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
7631 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
7632 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
7633 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
7634 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
7635 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
7636 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
7637 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
7638 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
7639 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
7640 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
7641 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
7642 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
7643 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
7644 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
7645 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
7647 flags = BindingFlags.Instance | BindingFlags.NonPublic |
7648 BindingFlags.Public;
7649 methods = greenType.GetMethods (flags);
7651 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
7652 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
7653 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
7654 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
7655 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
7657 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
7659 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
7661 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
7662 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
7663 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
7664 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
7665 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
7667 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
7669 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
7671 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
7672 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
7673 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
7674 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
7675 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
7676 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
7677 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
7678 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
7679 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
7680 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
7681 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
7682 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
7683 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
7684 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
7685 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
7686 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
7687 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
7688 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
7689 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
7690 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
7691 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
7692 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
7693 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
7694 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
7696 flags = BindingFlags.Static | BindingFlags.NonPublic |
7697 BindingFlags.Public;
7698 methods = greenType.GetMethods (flags);
7700 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
7701 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
7702 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
7703 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
7704 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
7705 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
7706 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
7707 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
7708 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
7709 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
7710 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
7711 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
7712 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
7713 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
7714 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
7715 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
7716 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
7717 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
7718 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
7719 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
7720 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
7721 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
7722 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
7723 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
7724 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
7725 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
7726 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
7727 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
7728 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
7729 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
7730 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
7731 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
7732 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
7733 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
7734 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
7735 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
7739 [Category ("NotDotNet")] // mcs depends on this
7740 public void TestGetMethodsFlagsIncomplete_Mono ()
7744 MethodInfo [] methods;
7746 TypeBuilder tb = module.DefineType (genTypeName (),
7747 TypeAttributes.Abstract);
7748 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7749 typeof (void), Type.EmptyTypes);
7750 ilgen = mb.GetILGenerator ();
7751 ilgen.Emit (OpCodes.Ret);
7753 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7754 typeof (void), Type.EmptyTypes);
7755 ilgen = mb.GetILGenerator ();
7756 ilgen.Emit (OpCodes.Ret);
7758 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7759 MethodAttributes.Static,
7760 typeof (void), Type.EmptyTypes);
7761 ilgen = mb.GetILGenerator ();
7762 ilgen.Emit (OpCodes.Ret);
7764 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7765 MethodAttributes.Abstract | MethodAttributes.Virtual,
7766 typeof (void), Type.EmptyTypes);
7768 methods = tb.GetMethods (BindingFlags.Public |
7769 BindingFlags.Instance);
7770 Assert.AreEqual (6, methods.Length, "#A1");
7771 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#A2");
7772 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#A3");
7773 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#A4");
7774 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#A5");
7775 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#A6");
7777 methods = tb.GetMethods (BindingFlags.Public |
7778 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7779 Assert.AreEqual (2, methods.Length, "#B1");
7780 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#B2");
7781 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#B3");
7783 methods = tb.GetMethods (BindingFlags.Public |
7784 BindingFlags.Instance | BindingFlags.Static);
7785 Assert.AreEqual (7, methods.Length, "#C1");
7786 Assert.IsNotNull (GetMethodByName (methods, "Hello"), "#C2");
7787 Assert.IsNotNull (GetMethodByName (methods, "Init"), "#C3");
7788 Assert.IsNotNull (GetMethodByName (methods, "Execute"), "#C4");
7789 Assert.IsNotNull (GetMethodByName (methods, "ToString"), "#C5");
7790 Assert.IsNotNull (GetMethodByName (methods, "Equals"), "#C6");
7791 Assert.IsNotNull (GetMethodByName (methods, "GetHashCode"), "#C7");
7793 methods = tb.GetMethods (BindingFlags.NonPublic |
7794 BindingFlags.Instance | BindingFlags.DeclaredOnly);
7795 Assert.AreEqual (1, methods.Length, "#D1");
7796 Assert.IsNotNull (GetMethodByName (methods, "Run"), "#D2");
7801 [Category ("NotWorking")] // mcs depends on this
7802 public void TestGetMethodsFlagsIncomplete_MS ()
7807 TypeBuilder tb = module.DefineType (genTypeName (),
7808 TypeAttributes.Abstract);
7809 mb = tb.DefineMethod ("Hello", MethodAttributes.Public,
7810 typeof (void), Type.EmptyTypes);
7811 ilgen = mb.GetILGenerator ();
7812 ilgen.Emit (OpCodes.Ret);
7814 mb = tb.DefineMethod ("Run", MethodAttributes.Private,
7815 typeof (void), Type.EmptyTypes);
7816 ilgen = mb.GetILGenerator ();
7817 ilgen.Emit (OpCodes.Ret);
7819 mb = tb.DefineMethod ("Execute", MethodAttributes.Public |
7820 MethodAttributes.Static,
7821 typeof (void), Type.EmptyTypes);
7822 ilgen = mb.GetILGenerator ();
7823 ilgen.Emit (OpCodes.Ret);
7825 mb = tb.DefineMethod ("Init", MethodAttributes.Public |
7826 MethodAttributes.Abstract | MethodAttributes.Virtual,
7827 typeof (void), Type.EmptyTypes);
7830 tb.GetMethods (BindingFlags.Public | BindingFlags.Instance);
7832 } catch (NotSupportedException ex) {
7833 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
7834 Assert.IsNull (ex.InnerException, "#3");
7835 Assert.IsNotNull (ex.Message, "#4");
7840 public void TestGetMethodsFlagsComplete ()
7842 TypeBuilder tb = module.DefineType (genTypeName ());
7843 MethodBuilder helloMethod = tb.DefineMethod ("HelloMethod",
7844 MethodAttributes.Public, typeof (string), Type.EmptyTypes);
7845 ILGenerator helloMethodIL = helloMethod.GetILGenerator ();
7846 helloMethodIL.Emit (OpCodes.Ldstr, "Hi! ");
7847 helloMethodIL.Emit (OpCodes.Ldarg_1);
7848 MethodInfo infoMethod = typeof (string).GetMethod ("Concat",
7849 new Type [] { typeof (string), typeof (string) });
7850 helloMethodIL.Emit (OpCodes.Call, infoMethod);
7851 helloMethodIL.Emit (OpCodes.Ret);
7853 Type emittedType = tb.CreateType ();
7855 Assert.AreEqual (1, tb.GetMethods (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Length, "#1");
7856 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length,
7857 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.Public).Length, "#2");
7858 Assert.AreEqual (0, tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).Length, "#3");
7859 Assert.AreEqual (tb.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length,
7860 emittedType.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic).Length, "#4");
7864 public void TestGetMethodsFlagsComplete_Inheritance ()
7866 MethodInfo [] methods;
7869 TypeBuilder blueType = module.DefineType (genTypeName (),
7870 TypeAttributes.Public);
7871 CreateMembers (blueType, "Blue", false);
7873 TypeBuilder redType = module.DefineType (genTypeName (),
7874 TypeAttributes.Public, blueType);
7875 CreateMembers (redType, "Red", false);
7877 TypeBuilder greenType = module.DefineType (genTypeName (),
7878 TypeAttributes.Public, redType);
7879 CreateMembers (greenType, "Green", false);
7881 blueType.CreateType ();
7882 redType.CreateType ();
7883 greenType.CreateType ();
7885 flags = BindingFlags.Instance | BindingFlags.NonPublic;
7886 methods = greenType.GetMethods (flags);
7888 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#A1");
7889 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#A2");
7890 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#A3");
7891 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#A4");
7892 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#A5");
7894 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7896 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#A6");
7898 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#A7");
7899 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#A8");
7900 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#A9");
7901 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#A10");
7902 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#A11");
7904 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7906 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#A12");
7908 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#A13");
7909 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#A14");
7910 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#A15");
7911 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#A16");
7912 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#A17");
7913 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#A18");
7914 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#A19");
7915 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#A20");
7916 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#A21");
7917 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#A22");
7918 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#A23");
7919 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#A24");
7920 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#A25");
7921 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#A26");
7922 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#A27");
7923 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#A28");
7924 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#A29");
7925 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#A30");
7926 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#A31");
7927 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#A32");
7928 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#A33");
7929 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#A34");
7930 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#A35");
7931 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#A36");
7933 flags = BindingFlags.Instance | BindingFlags.Public;
7934 methods = greenType.GetMethods (flags);
7936 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#B1");
7937 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#B2");
7938 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#B3");
7939 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#B4");
7940 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#B5");
7941 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#B6");
7942 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#B7");
7943 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#B8");
7944 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#B9");
7945 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#B10");
7946 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#B11");
7947 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#B12");
7948 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#B13");
7949 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#B14");
7950 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#B15");
7951 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#B16");
7952 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#B17");
7953 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#B18");
7954 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#B19");
7955 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#B20");
7956 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#B21");
7957 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#B22");
7958 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#B23");
7959 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#B24");
7960 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#B25");
7961 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#B26");
7962 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#B27");
7963 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#B28");
7964 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#B29");
7965 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#B30");
7966 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#B31");
7967 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#B32");
7968 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#B33");
7969 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#B34");
7970 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#B35");
7971 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#B36");
7973 flags = BindingFlags.Static | BindingFlags.Public;
7974 methods = greenType.GetMethods (flags);
7976 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#C1");
7977 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#C2");
7978 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#C3");
7979 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#C4");
7980 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#C5");
7981 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#C6");
7982 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#C7");
7983 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#C8");
7984 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#C9");
7985 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#C10");
7986 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#C11");
7987 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#C12");
7988 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#C13");
7989 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#C14");
7990 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#C15");
7991 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#C16");
7992 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#C17");
7993 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#C18");
7994 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#C19");
7995 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#C20");
7996 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#C21");
7997 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#C22");
7998 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#C23");
7999 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#C24");
8000 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#C25");
8001 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#C26");
8002 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#C27");
8003 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#C28");
8004 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#C29");
8005 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#C30");
8006 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#C31");
8007 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#C32");
8008 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#C33");
8009 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#C34");
8010 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#C35");
8011 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#C36");
8013 flags = BindingFlags.Static | BindingFlags.NonPublic;
8014 methods = greenType.GetMethods (flags);
8016 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#D1");
8017 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#D2");
8018 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#D3");
8019 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#D4");
8020 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#D5");
8021 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#D6");
8022 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#D7");
8023 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#D8");
8024 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#D9");
8025 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#D10");
8026 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#D11");
8027 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#D12");
8028 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#D13");
8029 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#D14");
8030 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#D15");
8031 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#D16");
8032 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#D17");
8033 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#D18");
8034 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#D19");
8035 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#D20");
8036 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#D21");
8037 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#D22");
8038 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#D23");
8039 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#D24");
8040 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#D25");
8041 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#D26");
8042 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#D27");
8043 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#D28");
8044 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#D29");
8045 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#D30");
8046 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#D31");
8047 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#D32");
8048 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#D33");
8049 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#D34");
8050 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#D35");
8051 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#D36");
8053 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8054 BindingFlags.FlattenHierarchy;
8055 methods = greenType.GetMethods (flags);
8057 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#E1");
8058 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#E2");
8059 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#E3");
8060 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#E4");
8061 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#E5");
8063 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
8065 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#E6");
8067 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#E7");
8068 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#E8");
8069 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#E9");
8070 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#E10");
8071 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#E11");
8073 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
8075 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#E12");
8077 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#E13");
8078 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#E14");
8079 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#E15");
8080 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#E16");
8081 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#E17");
8082 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#E18");
8083 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#E19");
8084 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#E20");
8085 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#E21");
8086 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#E22");
8087 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#E23");
8088 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#E24");
8089 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#E25");
8090 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#E26");
8091 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#E27");
8092 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#E28");
8093 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#E29");
8094 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#E30");
8095 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#E31");
8096 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#E32");
8097 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#E33");
8098 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#E34");
8099 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#E35");
8100 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#E36");
8102 flags = BindingFlags.Instance | BindingFlags.Public |
8103 BindingFlags.FlattenHierarchy;
8104 methods = greenType.GetMethods (flags);
8106 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#F1");
8107 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#F2");
8108 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#F3");
8109 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#F4");
8110 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#F5");
8111 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#F6");
8112 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#F7");
8113 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#F8");
8114 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#F9");
8115 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#F10");
8116 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#F11");
8117 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#F12");
8118 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#F13");
8119 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#F14");
8120 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#F15");
8121 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#F16");
8122 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#F17");
8123 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#F18");
8124 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#F19");
8125 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#F20");
8126 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#F21");
8127 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#F22");
8128 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#F23");
8129 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#F24");
8130 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#F25");
8131 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#F26");
8132 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#F27");
8133 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#F28");
8134 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#F29");
8135 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#F30");
8136 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#F31");
8137 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#F32");
8138 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#F33");
8139 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#F34");
8140 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#F35");
8141 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#F36");
8143 flags = BindingFlags.Static | BindingFlags.Public |
8144 BindingFlags.FlattenHierarchy;
8145 methods = greenType.GetMethods (flags);
8147 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#G1");
8148 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#G2");
8149 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#G3");
8150 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#G4");
8151 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#G5");
8152 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#G6");
8153 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#G7");
8154 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#G8");
8155 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#G9");
8156 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#G10");
8157 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#G11");
8158 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#G12");
8159 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#G13");
8160 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#G14");
8161 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#G15");
8162 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#G16");
8163 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#G17");
8164 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#G18");
8165 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#G19");
8166 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#G20");
8167 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#G21");
8168 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#G22");
8169 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#G23");
8170 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#G24");
8171 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#G25");
8172 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#G26");
8173 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#G27");
8174 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#G28");
8175 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticRed"), "#G29");
8176 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#G30");
8177 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#G31");
8178 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#G32");
8179 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#G33");
8180 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#G34");
8181 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#G35");
8182 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#G36");
8184 flags = BindingFlags.Static | BindingFlags.NonPublic |
8185 BindingFlags.FlattenHierarchy;
8186 methods = greenType.GetMethods (flags);
8188 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#H1");
8189 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#H2");
8190 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#H3");
8191 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#H4");
8192 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#H5");
8193 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#H6");
8194 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#H7");
8195 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#H8");
8196 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#H9");
8197 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#H10");
8198 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#H11");
8199 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#H12");
8200 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#H13");
8201 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#H14");
8202 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#H15");
8203 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#H16");
8204 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#H17");
8205 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#H18");
8206 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#H19");
8207 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#H20");
8208 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#H21");
8209 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#H22");
8210 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#H23");
8212 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
8214 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#H24");
8216 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#H25");
8217 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#H26");
8218 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#H27");
8219 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#H28");
8220 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#H29");
8222 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
8224 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#H30");
8226 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#H31");
8227 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#H32");
8228 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#H33");
8229 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#H34");
8230 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#H35");
8231 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#H36");
8233 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8234 BindingFlags.DeclaredOnly;
8235 methods = greenType.GetMethods (flags);
8237 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#I1");
8238 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#I2");
8239 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#I3");
8240 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#I4");
8241 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#I5");
8242 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#I6");
8243 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#I7");
8244 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#I8");
8245 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#I9");
8246 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#I10");
8247 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#I11");
8248 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#I12");
8249 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#I13");
8250 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#I14");
8251 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#I15");
8252 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#I16");
8253 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#I17");
8254 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#I18");
8255 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#I19");
8256 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#I20");
8257 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#I21");
8258 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#I22");
8259 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#I23");
8260 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#I24");
8261 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#I25");
8262 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#I26");
8263 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#I27");
8264 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#I28");
8265 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#I29");
8266 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#I30");
8267 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#I31");
8268 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#I32");
8269 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#I33");
8270 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#I34");
8271 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#I35");
8272 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#I36");
8274 flags = BindingFlags.Instance | BindingFlags.Public |
8275 BindingFlags.DeclaredOnly;
8276 methods = greenType.GetMethods (flags);
8278 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#J1");
8279 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#J2");
8280 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#J3");
8281 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#J4");
8282 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#J5");
8283 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#J6");
8284 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#J7");
8285 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#J8");
8286 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#J9");
8287 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#J10");
8288 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#J11");
8289 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#J12");
8290 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#J13");
8291 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#J14");
8292 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#J15");
8293 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#J16");
8294 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#J17");
8295 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#J18");
8296 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#J19");
8297 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#J20");
8298 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#J21");
8299 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#J22");
8300 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#J23");
8301 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#J24");
8302 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#J25");
8303 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#J26");
8304 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#J27");
8305 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#J28");
8306 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#J29");
8307 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#J30");
8308 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#J31");
8309 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#J32");
8310 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#J33");
8311 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#J34");
8312 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#J35");
8313 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#J36");
8315 flags = BindingFlags.Static | BindingFlags.Public |
8316 BindingFlags.DeclaredOnly;
8317 methods = greenType.GetMethods (flags);
8319 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#K1");
8320 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#K2");
8321 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#K3");
8322 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#K4");
8323 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#K5");
8324 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#K6");
8325 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#K7");
8326 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#K8");
8327 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#K9");
8328 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#K10");
8329 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#K11");
8330 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#K12");
8331 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#K13");
8332 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#K14");
8333 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#K15");
8334 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#K16");
8335 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#K17");
8336 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#K18");
8337 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#K19");
8338 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#K20");
8339 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#K21");
8340 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#K22");
8341 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#K23");
8342 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#K24");
8343 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#K25");
8344 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#K26");
8345 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#K27");
8346 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#K28");
8347 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#K29");
8348 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#K30");
8349 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#K31");
8350 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#K32");
8351 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#K33");
8352 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#K34");
8353 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#K35");
8354 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#K36");
8356 flags = BindingFlags.Static | BindingFlags.NonPublic |
8357 BindingFlags.DeclaredOnly;
8358 methods = greenType.GetMethods (flags);
8360 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#L1");
8361 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#L2");
8362 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#L3");
8363 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#L4");
8364 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#L5");
8365 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#L6");
8366 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#L7");
8367 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#L8");
8368 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#L9");
8369 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#L10");
8370 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#L11");
8371 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#L12");
8372 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#L13");
8373 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#L14");
8374 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#L15");
8375 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#L16");
8376 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#L17");
8377 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#L18");
8378 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#L19");
8379 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#L20");
8380 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#L21");
8381 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#L22");
8382 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#L23");
8383 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#L24");
8384 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#L25");
8385 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#L26");
8386 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#L27");
8387 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#L28");
8388 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#L29");
8389 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#L30");
8390 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#L31");
8391 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#L32");
8392 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#L33");
8393 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#L34");
8394 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#L35");
8395 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#L36");
8397 flags = BindingFlags.Instance | BindingFlags.NonPublic |
8398 BindingFlags.Public;
8399 methods = greenType.GetMethods (flags);
8401 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#M1");
8402 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#M2");
8403 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#M3");
8404 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#M4");
8405 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#M5");
8407 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
8409 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#M6");
8411 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#M7");
8412 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#M8");
8413 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#M9");
8414 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#M10");
8415 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#M11");
8417 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
8419 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#M12");
8421 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#M13");
8422 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#M14");
8423 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#M15");
8424 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#M16");
8425 Assert.IsNotNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#M17");
8426 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#M18");
8427 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#M19");
8428 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#M20");
8429 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#M21");
8430 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#M22");
8431 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#M23");
8432 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#M24");
8433 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#M25");
8434 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#M26");
8435 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#M27");
8436 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#M28");
8437 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#M29");
8438 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#M30");
8439 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#M31");
8440 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#M32");
8441 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#M33");
8442 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#M34");
8443 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#M35");
8444 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#M36");
8446 flags = BindingFlags.Static | BindingFlags.NonPublic |
8447 BindingFlags.Public;
8448 methods = greenType.GetMethods (flags);
8450 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceBlue"), "#N1");
8451 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceBlue"), "#N2");
8452 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceBlue"), "#N3");
8453 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceBlue"), "#N4");
8454 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceBlue"), "#N5");
8455 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceBlue"), "#N6");
8456 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceRed"), "#N7");
8457 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceRed"), "#N8");
8458 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceRed"), "#N9");
8459 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceRed"), "#N10");
8460 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceRed"), "#N11");
8461 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceRed"), "#N12");
8462 Assert.IsNull (GetMethodByName (methods, "GetPrivateInstanceGreen"), "#N13");
8463 Assert.IsNull (GetMethodByName (methods, "GetFamilyInstanceGreen"), "#N14");
8464 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemInstanceGreen"), "#N15");
8465 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemInstanceGreen"), "#N16");
8466 Assert.IsNull (GetMethodByName (methods, "GetPublicInstanceGreen"), "#N17");
8467 Assert.IsNull (GetMethodByName (methods, "GetAssemblyInstanceGreen"), "#N18");
8468 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticBlue"), "#N19");
8469 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticBlue"), "#N20");
8470 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticBlue"), "#N21");
8471 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticBlue"), "#N22");
8472 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticBlue"), "#N23");
8473 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticBlue"), "#N24");
8474 Assert.IsNull (GetMethodByName (methods, "GetPrivateStaticRed"), "#N25");
8475 Assert.IsNull (GetMethodByName (methods, "GetFamilyStaticRed"), "#N26");
8476 Assert.IsNull (GetMethodByName (methods, "GetFamANDAssemStaticRed"), "#N27");
8477 Assert.IsNull (GetMethodByName (methods, "GetFamORAssemStaticRed"), "#N28");
8478 Assert.IsNull (GetMethodByName (methods, "GetPublicStaticRed"), "#N29");
8479 Assert.IsNull (GetMethodByName (methods, "GetAssemblyStaticRed"), "#N30");
8480 Assert.IsNotNull (GetMethodByName (methods, "GetPrivateStaticGreen"), "#N31");
8481 Assert.IsNotNull (GetMethodByName (methods, "GetFamilyStaticGreen"), "#N32");
8482 Assert.IsNotNull (GetMethodByName (methods, "GetFamANDAssemStaticGreen"), "#N33");
8483 Assert.IsNotNull (GetMethodByName (methods, "GetFamORAssemStaticGreen"), "#N34");
8484 Assert.IsNotNull (GetMethodByName (methods, "GetPublicStaticGreen"), "#N35");
8485 Assert.IsNotNull (GetMethodByName (methods, "GetAssemblyStaticGreen"), "#N36");
8489 public void TestGetMemberIncomplete ()
8491 TypeBuilder tb = module.DefineType (genTypeName ());
8493 tb.GetMember ("FOO", MemberTypes.All, BindingFlags.Public);
8495 } catch (NotSupportedException ex) {
8496 // The invoked member is not supported in a
8498 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8499 Assert.IsNull (ex.InnerException, "#3");
8500 Assert.IsNotNull (ex.Message, "#4");
8505 public void TestGetMemberComplete ()
8507 TypeBuilder tb = module.DefineType (genTypeName ());
8508 tb.DefineField ("FOO", typeof (int), FieldAttributes.Private);
8510 Type emittedType = tb.CreateType ();
8512 Assert.AreEqual (1, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.NonPublic).Length);
8513 Assert.AreEqual (0, tb.GetMember ("FOO", MemberTypes.Field, BindingFlags.Instance | BindingFlags.Public).Length);
8517 public void TestGetMembersIncomplete ()
8519 TypeBuilder tb = module.DefineType (genTypeName ());
8523 } catch (NotSupportedException ex) {
8524 // The invoked member is not supported in a
8526 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8527 Assert.IsNull (ex.InnerException, "#3");
8528 Assert.IsNotNull (ex.Message, "#4");
8533 public void TestGetMembersComplete ()
8535 TypeBuilder tb = module.DefineType (genTypeName ());
8536 Type emittedType = tb.CreateType ();
8538 Assert.AreEqual (tb.GetMembers ().Length, emittedType.GetMembers ().Length);
8542 public void TestGetMembersFlagsIncomplete ()
8544 TypeBuilder tb = module.DefineType (genTypeName ());
8546 tb.GetMembers (BindingFlags.Public);
8548 } catch (NotSupportedException ex) {
8549 // The invoked member is not supported in a
8551 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8552 Assert.IsNull (ex.InnerException, "#3");
8553 Assert.IsNotNull (ex.Message, "#4");
8558 public void TestGetMembersFlagsComplete ()
8560 TypeBuilder tb = module.DefineType (genTypeName ());
8561 tb.DefineField ("FOO", typeof (int), FieldAttributes.Public);
8563 Type emittedType = tb.CreateType ();
8565 Assert.IsTrue (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length != 0);
8566 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length,
8567 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.Public).Length);
8568 Assert.AreEqual (tb.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length,
8569 emittedType.GetMembers (BindingFlags.Instance | BindingFlags.NonPublic).Length);
8573 public void TestGetInterfaceIncomplete ()
8575 TypeBuilder tb = module.DefineType (genTypeName ());
8577 tb.GetInterface ("FOO", true);
8579 } catch (NotSupportedException ex) {
8580 // The invoked member is not supported in a
8582 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
8583 Assert.IsNull (ex.InnerException, "#3");
8584 Assert.IsNotNull (ex.Message, "#4");
8589 public void TestGetInterfaces ()
8591 TypeBuilder tb = module.DefineType (genTypeName ());
8592 Type [] interfaces = tb.GetInterfaces ();
8593 Assert.AreEqual (0, interfaces.Length);
8595 TypeBuilder tbInterface = module.DefineType (genTypeName (), TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
8596 Type emittedInterface = tbInterface.CreateType ();
8598 tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { emittedInterface });
8599 interfaces = tb.GetInterfaces ();
8600 Assert.AreEqual (1, interfaces.Length);
8604 public void TestAddDeclarativeSecurityAlreadyCreated ()
8606 TypeBuilder tb = module.DefineType (genTypeName ());
8609 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8611 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8613 } catch (InvalidOperationException ex) {
8614 // Unable to change after type has been created
8615 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8616 Assert.IsNull (ex.InnerException, "#3");
8617 Assert.IsNotNull (ex.Message, "#4");
8622 public void TestAddDeclarativeSecurityNullPermissionSet ()
8624 TypeBuilder tb = module.DefineType (genTypeName ());
8626 tb.AddDeclarativeSecurity (SecurityAction.Demand, null);
8628 } catch (ArgumentNullException ex) {
8629 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
8630 Assert.IsNull (ex.InnerException, "#3");
8631 Assert.IsNotNull (ex.Message, "#4");
8632 Assert.AreEqual ("pset", ex.ParamName, "#5");
8638 public void TestAddDeclarativeSecurityInvalidAction ()
8640 TypeBuilder tb = module.DefineType (genTypeName ());
8642 SecurityAction [] actions = new SecurityAction [] {
8643 SecurityAction.RequestMinimum,
8644 SecurityAction.RequestOptional,
8645 SecurityAction.RequestRefuse };
8646 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8648 foreach (SecurityAction action in actions) {
8650 tb.AddDeclarativeSecurity (action, set);
8652 } catch (ArgumentOutOfRangeException) {
8658 public void TestAddDeclarativeSecurityDuplicateAction ()
8660 TypeBuilder tb = module.DefineType (genTypeName ());
8662 PermissionSet set = new PermissionSet (PermissionState.Unrestricted);
8663 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8665 tb.AddDeclarativeSecurity (SecurityAction.Demand, set);
8667 } catch (InvalidOperationException ex) {
8668 // Multiple permission sets specified with the
8669 // same SecurityAction
8670 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
8671 Assert.IsNull (ex.InnerException, "#3");
8672 Assert.IsNotNull (ex.Message, "#4");
8677 public void TestEnums ()
8679 TypeAttributes typeAttrs = TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed;
8680 TypeBuilder enumToCreate = module.DefineType (genTypeName (), typeAttrs,
8682 enumToCreate.SetCustomAttribute (new CustomAttributeBuilder (typeof (FlagsAttribute).GetConstructors () [0], Type.EmptyTypes));
8683 // add value__ field, see DefineEnum method of ModuleBuilder
8684 enumToCreate.DefineField ("value__", typeof (Int32),
8685 FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
8688 FieldBuilder fb = enumToCreate.DefineField ("A", enumToCreate,
8689 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8690 fb.SetConstant ((Int32) 0);
8692 fb = enumToCreate.DefineField ("B", enumToCreate,
8693 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8694 fb.SetConstant ((Int32) 1);
8696 fb = enumToCreate.DefineField ("C", enumToCreate,
8697 FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
8698 fb.SetConstant ((Int32) 2);
8700 Type enumType = enumToCreate.CreateType ();
8702 object enumVal = Enum.ToObject (enumType, (Int32) 3);
8704 Assert.AreEqual ("B, C", enumVal.ToString ());
8705 Assert.AreEqual (3, (Int32) enumVal);
8709 public void DefineEnum ()
8711 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8712 TypeAttributes.Public);
8713 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8714 TypeAttributes.Public, typeof (int));
8715 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8716 enumBuilder.CreateType ();
8717 typeBuilder.CreateType ();
8721 [Category ("NotWorking")]
8722 public void DefineEnumThrowIfTypeBuilderCalledBeforeEnumBuilder ()
8724 TypeBuilder typeBuilder = module.DefineType (genTypeName (),
8725 TypeAttributes.Public);
8726 EnumBuilder enumBuilder = module.DefineEnum (genTypeName (),
8727 TypeAttributes.Public, typeof (int));
8728 typeBuilder.DefineField ("myField", enumBuilder, FieldAttributes.Private);
8730 typeBuilder.CreateType ();
8732 } catch (TypeLoadException) {
8733 // Could not load type '...' from assembly
8734 // 'MonoTests.System.Reflection.Emit.TypeBuilderTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
8737 Assert.IsTrue (typeBuilder.IsCreated (), "#2");
8738 Assert.IsNull (typeBuilder.CreateType (), "#3");
8741 typeBuilder.CreateType ();
8742 } catch (InvalidOperationException ex) {
8743 // Unable to change after type has been created
8744 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
8745 Assert.IsNull (ex.InnerException, "#B3");
8746 Assert.IsNotNull (ex.Message, "#B4");
8752 public void SetCustomAttribute_SuppressUnmanagedCodeSecurity ()
8754 TypeBuilder tb = module.DefineType (genTypeName ());
8755 ConstructorInfo attrCtor = typeof (SuppressUnmanagedCodeSecurityAttribute).
8756 GetConstructor (Type.EmptyTypes);
8757 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
8758 attrCtor, new object [0]);
8759 Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#1");
8760 tb.SetCustomAttribute (caBuilder);
8761 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#2");
8762 Type emittedType = tb.CreateType ();
8763 Assert.AreEqual (TypeAttributes.HasSecurity, emittedType.Attributes & TypeAttributes.HasSecurity, "#3");
8764 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#4");
8765 object [] emittedAttrs = emittedType.GetCustomAttributes (typeof (SuppressUnmanagedCodeSecurityAttribute), true);
8766 Assert.AreEqual (1, emittedAttrs.Length, "#5");
8769 private PropertyBuilder DefineStringProperty (TypeBuilder tb, string propertyName, string fieldName, MethodAttributes methodAttribs)
8771 // define the field holding the property value
8772 FieldBuilder fieldBuilder = tb.DefineField (fieldName,
8773 typeof (string), FieldAttributes.Private);
8775 PropertyBuilder propertyBuilder = tb.DefineProperty (
8776 propertyName, PropertyAttributes.HasDefault, typeof (string),
8777 new Type [] { typeof (string) });
8779 // First, we'll define the behavior of the "get" property for CustomerName as a method.
8780 MethodBuilder getMethodBuilder = tb.DefineMethod ("Get" + propertyName,
8785 ILGenerator getIL = getMethodBuilder.GetILGenerator ();
8787 getIL.Emit (OpCodes.Ldarg_0);
8788 getIL.Emit (OpCodes.Ldfld, fieldBuilder);
8789 getIL.Emit (OpCodes.Ret);
8791 // Now, we'll define the behavior of the "set" property for CustomerName.
8792 MethodBuilder setMethodBuilder = tb.DefineMethod ("Set" + propertyName,
8795 new Type [] { typeof (string) });
8797 ILGenerator setIL = setMethodBuilder.GetILGenerator ();
8799 setIL.Emit (OpCodes.Ldarg_0);
8800 setIL.Emit (OpCodes.Ldarg_1);
8801 setIL.Emit (OpCodes.Stfld, fieldBuilder);
8802 setIL.Emit (OpCodes.Ret);
8804 // Last, we must map the two methods created above to our PropertyBuilder to
8805 // their corresponding behaviors, "get" and "set" respectively.
8806 propertyBuilder.SetGetMethod (getMethodBuilder);
8807 propertyBuilder.SetSetMethod (setMethodBuilder);
8808 return propertyBuilder;
8811 static int handler_called = 0;
8814 public void TestTypeResolve ()
8816 string typeName = genTypeName ();
8818 ResolveEventHandler handler = new ResolveEventHandler (TypeResolve);
8819 AppDomain.CurrentDomain.TypeResolve += handler;
8821 Type t = Type.GetType (typeName);
8822 Assert.AreEqual (typeName, t.Name);
8823 Assert.AreEqual (1, handler_called);
8824 AppDomain.CurrentDomain.TypeResolve -= handler;
8827 Assembly TypeResolve (object sender, ResolveEventArgs args)
8829 TypeBuilder tb = module.DefineType (args.Name, TypeAttributes.Public);
8836 public void IsAssignableFrom_Created ()
8838 TypeBuilder tb = module.DefineType (genTypeName (),
8839 TypeAttributes.Public, typeof (MemoryStream),
8840 new Type [] { typeof (IThrowable), typeof (Bar) });
8841 tb.AddInterfaceImplementation (typeof (IDestroyable));
8842 Type emitted_type = tb.CreateType ();
8844 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
8845 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
8846 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
8847 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
8848 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb), "#A5");
8849 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#A6");
8850 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#A7");
8851 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#A8");
8852 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#A9");
8853 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#A10");
8854 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#A11");
8855 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#A12");
8856 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A13");
8857 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A14");
8858 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A15");
8859 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A16");
8860 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A17");
8861 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A18");
8863 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#B1");
8864 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#B2");
8865 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#B3");
8866 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#B4");
8867 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#B5");
8868 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#B6");
8869 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#B7");
8870 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#B8");
8871 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb), "#B9");
8872 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#B10");
8874 Assert.IsTrue (tb.IsAssignableFrom (tb), "#C1");
8875 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#C2");
8876 Assert.IsTrue (tb.IsAssignableFrom (emitted_type), "#C3");
8877 Assert.IsTrue (emitted_type.IsAssignableFrom (tb), "#C4");
8878 Assert.IsFalse (emitted_type.IsAssignableFrom ((Type) null), "#C5");
8880 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type), "#D1");
8881 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IThrowable)), "#D2");
8882 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type), "#D3");
8883 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IMoveable)), "#D4");
8884 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type), "#D5");
8885 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Foo)), "#D6");
8886 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type), "#D7");
8887 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Bar)), "#D8");
8888 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type), "#D9");
8889 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Baz)), "#D10");
8890 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type), "#D11");
8891 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDestroyable)), "#D12");
8892 Assert.IsFalse (typeof (IAir).IsAssignableFrom (emitted_type), "#D13");
8893 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IAir)), "#D14");
8894 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type), "#D15");
8895 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IWater)), "#D16");
8896 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type), "#D17");
8897 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (ILiquid)), "#D18");
8899 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type), "#E1");
8900 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (MemoryStream)), "#E2");
8901 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type), "#E3");
8902 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (Stream)), "#E4");
8903 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type), "#E5");
8904 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (FileStream)), "#E6");
8905 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type), "#E7");
8906 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (object)), "#E8");
8907 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type), "#E9");
8908 Assert.IsFalse (emitted_type.IsAssignableFrom (typeof (IDisposable)), "#E10");
8910 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8911 tb.FullName + "[]")), "#F1");
8912 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
8913 tb.FullName + "[]")), "#F2");
8914 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
8915 tb.FullName + "[]")), "#F3");
8917 TypeBuilder tb2 = module.DefineType (genTypeName (),
8918 TypeAttributes.Public, tb,
8919 new Type [] { typeof (IAir) });
8920 Type emitted_type2 = tb2.CreateType ();
8922 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb2), "#G1");
8923 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#G2");
8924 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb2), "#G3");
8925 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#G4");
8926 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb2), "#G5");
8927 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#G6");
8928 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb2), "#G7");
8929 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#G8");
8930 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#G9");
8931 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#G10");
8932 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#G11");
8933 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDestroyable)), "#G12");
8934 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#G13");
8935 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#G14");
8936 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#G15");
8937 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#G16");
8938 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#G17");
8939 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#G18");
8941 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#H1");
8942 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#H2");
8943 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#H3");
8944 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#H4");
8945 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#H5");
8946 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#H6");
8947 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#H7");
8948 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#H8");
8949 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb2), "#H9");
8950 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#H10");
8952 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#I1");
8953 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#I2");
8954 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type2), "#I3");
8955 Assert.IsFalse (tb2.IsAssignableFrom (emitted_type), "#I4");
8956 Assert.IsFalse (tb2.IsAssignableFrom ((Type) null), "#I5");
8957 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type2), "#I6");
8958 Assert.IsFalse (emitted_type2.IsAssignableFrom (emitted_type), "#I7");
8959 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb2), "#I8");
8960 Assert.IsFalse (emitted_type2.IsAssignableFrom (tb), "#I9");
8961 Assert.IsFalse (emitted_type2.IsAssignableFrom ((Type) null), "#I10");
8962 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#I11");
8963 Assert.IsTrue (tb.IsAssignableFrom (emitted_type2), "#I12");
8964 Assert.IsTrue (emitted_type.IsAssignableFrom (tb2), "#I13");
8965 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type2), "#I14");
8967 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type2), "#J1");
8968 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IThrowable)), "#J2");
8969 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type2), "#J3");
8970 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IMoveable)), "#J4");
8971 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type2), "#J5");
8972 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Foo)), "#J6");
8973 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type2), "#J7");
8974 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Bar)), "#J8");
8975 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type2), "#J9");
8976 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Baz)), "#J10");
8977 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb2), "#J11");
8978 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDestroyable)), "#J12");
8979 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type2), "#J13");
8980 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IAir)), "#J14");
8981 Assert.IsFalse (typeof (IWater).IsAssignableFrom (emitted_type2), "#J15");
8982 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IWater)), "#J16");
8983 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (emitted_type2), "#J17");
8984 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (ILiquid)), "#J18");
8986 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type2), "#K1");
8987 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (MemoryStream)), "#K2");
8988 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type2), "#K3");
8989 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (Stream)), "#K4");
8990 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type2), "#K5");
8991 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (FileStream)), "#K6");
8992 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type2), "#K7");
8993 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (object)), "#K8");
8994 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type2), "#K9");
8995 Assert.IsFalse (emitted_type2.IsAssignableFrom (typeof (IDisposable)), "#K10");
8997 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
8998 tb2.FullName + "[]")), "#L1");
8999 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9000 tb2.FullName + "[]")), "#L2");
9001 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9002 tb2.FullName + "[]")), "#L3");
9004 TypeBuilder tb3 = module.DefineType (genTypeName (),
9005 TypeAttributes.Public, tb2,
9006 new Type [] { typeof (IWater) });
9007 Type emitted_type3 = tb3.CreateType ();
9009 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb3), "#M1");
9010 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#M2");
9011 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb3), "#M3");
9012 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#M4");
9013 Assert.IsTrue (typeof (Foo).IsAssignableFrom (tb3), "#M5");
9014 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#M6");
9015 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb3), "#M7");
9016 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#M8");
9017 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#M9");
9018 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#M10");
9019 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb3), "#M11");
9020 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDestroyable)), "#M12");
9021 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb3), "#M13");
9022 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#M14");
9023 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#M15");
9024 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#M16");
9025 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (tb3), "#M17");
9026 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#M18");
9028 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#N1");
9029 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#N2");
9030 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#N3");
9031 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#N4");
9032 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#N5");
9033 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#N6");
9034 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#N7");
9035 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#N8");
9036 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (tb3), "#N9");
9037 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#N10");
9039 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#O1");
9040 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#O2");
9041 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#O3");
9042 Assert.IsTrue (tb3.IsAssignableFrom (emitted_type3), "#O4");
9043 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type2), "#O5");
9044 Assert.IsFalse (tb3.IsAssignableFrom (emitted_type), "#O6");
9045 Assert.IsFalse (tb3.IsAssignableFrom ((Type) null), "#O7");
9046 Assert.IsTrue (emitted_type3.IsAssignableFrom (emitted_type3), "#O8");
9047 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type2), "#O9");
9048 Assert.IsFalse (emitted_type3.IsAssignableFrom (emitted_type), "#O10");
9049 Assert.IsTrue (emitted_type3.IsAssignableFrom (tb3), "#O11");
9050 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb2), "#O12");
9051 Assert.IsFalse (emitted_type3.IsAssignableFrom (tb), "#O13");
9052 Assert.IsFalse (emitted_type3.IsAssignableFrom ((Type) null), "#O14");
9053 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#O15");
9054 Assert.IsTrue (tb2.IsAssignableFrom (emitted_type3), "#O16");
9055 Assert.IsTrue (emitted_type2.IsAssignableFrom (emitted_type3), "#O17");
9056 Assert.IsTrue (emitted_type2.IsAssignableFrom (tb3), "#O18");
9057 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#O19");
9058 Assert.IsTrue (tb.IsAssignableFrom (emitted_type3), "#O20");
9059 Assert.IsTrue (emitted_type.IsAssignableFrom (tb3), "#021");
9060 Assert.IsTrue (emitted_type.IsAssignableFrom (emitted_type3), "#O22");
9062 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (emitted_type3), "#P1");
9063 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IThrowable)), "#P2");
9064 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (emitted_type3), "#P3");
9065 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IMoveable)), "#P4");
9066 Assert.IsTrue (typeof (Foo).IsAssignableFrom (emitted_type3), "#P5");
9067 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Foo)), "#P6");
9068 Assert.IsTrue (typeof (Bar).IsAssignableFrom (emitted_type3), "#P7");
9069 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Bar)), "#P8");
9070 Assert.IsFalse (typeof (Baz).IsAssignableFrom (emitted_type3), "#P9");
9071 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Baz)), "#P10");
9072 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (emitted_type3), "#P11");
9073 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDestroyable)), "#P12");
9074 Assert.IsTrue (typeof (IAir).IsAssignableFrom (emitted_type3), "#P13");
9075 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IAir)), "#P14");
9076 Assert.IsTrue (typeof (IWater).IsAssignableFrom (emitted_type3), "#P15");
9077 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IWater)), "#P16");
9078 Assert.IsTrue (typeof (ILiquid).IsAssignableFrom (emitted_type3), "#P17");
9079 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (ILiquid)), "#P18");
9081 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (emitted_type3), "#Q1");
9082 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (MemoryStream)), "#Q2");
9083 Assert.IsTrue (typeof (Stream).IsAssignableFrom (emitted_type3), "#Q3");
9084 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (Stream)), "#Q4");
9085 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (emitted_type3), "#Q5");
9086 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (FileStream)), "#Q6");
9087 Assert.IsTrue (typeof (object).IsAssignableFrom (emitted_type3), "#Q7");
9088 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (object)), "#Q8");
9089 Assert.IsTrue (typeof (IDisposable).IsAssignableFrom (emitted_type3), "#Q9");
9090 Assert.IsFalse (emitted_type3.IsAssignableFrom (typeof (IDisposable)), "#Q10");
9092 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9093 tb3.FullName + "[]")), "#R1");
9094 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9095 tb3.FullName + "[]")), "#R2");
9096 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9097 tb3.FullName + "[]")), "#R3");
9100 TypeBuilder tb4 = module.DefineType (genTypeName (),
9101 TypeAttributes.Public, null,
9102 new Type [] { typeof (IWater) });
9103 tb4.DefineGenericParameters ("T");
9105 Type inst = tb4.MakeGenericType (typeof (int));
9106 Type emitted_type4 = tb4.CreateType ();
9107 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (inst));
9108 // This returns True if CreateType () is called _before_ MakeGenericType...
9109 //Assert.IsFalse (typeof (IWater).IsAssignableFrom (inst));
9114 public void IsAssignableFrom_NotCreated ()
9116 TypeBuilder tb = module.DefineType (genTypeName (),
9117 TypeAttributes.Public, typeof (MemoryStream),
9119 typeof (IThrowable), typeof (Bar),
9120 typeof (IComparable)
9123 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9124 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9125 //Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
9126 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#A4");
9127 Assert.IsTrue (typeof (IComparable).IsAssignableFrom (tb), "#A5");
9128 Assert.IsFalse (tb.IsAssignableFrom (typeof (IComparable)), "#A6");
9129 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb), "#A7");
9130 Assert.IsFalse (tb.IsAssignableFrom (typeof (IAir)), "#A8");
9131 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb), "#A9");
9132 Assert.IsFalse (tb.IsAssignableFrom (typeof (IWater)), "#A10");
9133 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb), "#A11");
9134 Assert.IsFalse (tb.IsAssignableFrom (typeof (ILiquid)), "#A12");
9136 //Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb), "#B1");
9137 Assert.IsFalse (tb.IsAssignableFrom (typeof (Foo)), "#B2");
9138 Assert.IsTrue (typeof (Bar).IsAssignableFrom (tb), "#B3");
9139 Assert.IsFalse (tb.IsAssignableFrom (typeof (Bar)), "#B4");
9140 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb), "#B5");
9141 Assert.IsFalse (tb.IsAssignableFrom (typeof (Baz)), "#B6");
9143 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb), "#C1");
9144 Assert.IsFalse (tb.IsAssignableFrom (typeof (MemoryStream)), "#C2");
9145 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb), "#C3");
9146 Assert.IsFalse (tb.IsAssignableFrom (typeof (Stream)), "#C4");
9147 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb), "#C5");
9148 Assert.IsFalse (tb.IsAssignableFrom (typeof (FileStream)), "#C6");
9149 Assert.IsTrue (typeof (object).IsAssignableFrom (tb), "#C7");
9150 Assert.IsFalse (tb.IsAssignableFrom (typeof (object)), "#C8");
9151 Assert.IsFalse (typeof (IDisposable).IsAssignableFrom (tb), "#C9");
9152 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDisposable)), "#C10");
9154 Assert.IsTrue (tb.IsAssignableFrom (tb), "#D1");
9155 Assert.IsFalse (tb.IsAssignableFrom ((Type) null), "#D2");
9157 TypeBuilder tb2 = module.DefineType (genTypeName (),
9158 TypeAttributes.Public, tb,
9159 new Type [] { typeof (IAir) });
9161 Assert.IsFalse (typeof (IThrowable).IsAssignableFrom (tb2), "#E1");
9162 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IThrowable)), "#E2");
9163 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb2), "#E3");
9164 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IMoveable)), "#E4");
9165 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (tb2), "#E5");
9166 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IComparable)), "#E6");
9167 Assert.IsTrue (typeof (IAir).IsAssignableFrom (tb2), "#E7");
9168 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IAir)), "#E8");
9169 Assert.IsFalse (typeof (IWater).IsAssignableFrom (tb2), "#E9");
9170 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IWater)), "#E10");
9171 Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb2), "#E11");
9172 Assert.IsFalse (tb2.IsAssignableFrom (typeof (ILiquid)), "#E12");
9174 Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb2), "#F1");
9175 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Foo)), "#F2");
9176 Assert.IsFalse (typeof (Bar).IsAssignableFrom (tb2), "#F3");
9177 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Bar)), "#F4");
9178 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb2), "#F5");
9179 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Baz)), "#F6");
9181 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb2), "#G1");
9182 Assert.IsFalse (tb2.IsAssignableFrom (typeof (MemoryStream)), "#G2");
9183 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb2), "#G3");
9184 Assert.IsFalse (tb2.IsAssignableFrom (typeof (Stream)), "#G4");
9185 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb2), "#G5");
9186 Assert.IsFalse (tb2.IsAssignableFrom (typeof (FileStream)), "#G6");
9187 Assert.IsTrue (typeof (object).IsAssignableFrom (tb2), "#G7");
9188 Assert.IsFalse (tb2.IsAssignableFrom (typeof (object)), "#G8");
9189 Assert.IsFalse (typeof (IDisposable).IsAssignableFrom (tb2), "#G9");
9190 Assert.IsFalse (tb2.IsAssignableFrom (typeof (IDisposable)), "#G10");
9192 Assert.IsTrue (tb2.IsAssignableFrom (tb2), "#H1");
9193 Assert.IsFalse (tb2.IsAssignableFrom (tb), "#H2");
9194 Assert.IsTrue (tb.IsAssignableFrom (tb2), "#H3");
9196 TypeBuilder tb3 = module.DefineType (genTypeName (),
9197 TypeAttributes.Public, tb2,
9198 new Type [] { typeof (IWater) });
9200 Assert.IsFalse (typeof (IThrowable).IsAssignableFrom (tb3), "#I1");
9201 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IThrowable)), "#I2");
9202 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb3), "#I3");
9203 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IMoveable)), "#I4");
9204 Assert.IsFalse (typeof (IComparable).IsAssignableFrom (tb3), "#I5");
9205 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IComparable)), "#I6");
9206 Assert.IsFalse (typeof (IAir).IsAssignableFrom (tb3), "#I7");
9207 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IAir)), "#I8");
9208 Assert.IsTrue (typeof (IWater).IsAssignableFrom (tb3), "#I9");
9209 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IWater)), "#I10");
9210 //Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb3), "#I11");
9211 Assert.IsFalse (tb3.IsAssignableFrom (typeof (ILiquid)), "#I12");
9213 Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb3), "#J1");
9214 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Foo)), "#J2");
9215 Assert.IsFalse (typeof (Bar).IsAssignableFrom (tb3), "#J3");
9216 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Bar)), "#J4");
9217 Assert.IsFalse (typeof (Baz).IsAssignableFrom (tb3), "#J5");
9218 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Baz)), "#J6");
9220 Assert.IsTrue (typeof (MemoryStream).IsAssignableFrom (tb3), "#K1");
9221 Assert.IsFalse (tb3.IsAssignableFrom (typeof (MemoryStream)), "#K2");
9222 Assert.IsTrue (typeof (Stream).IsAssignableFrom (tb3), "#K3");
9223 Assert.IsFalse (tb3.IsAssignableFrom (typeof (Stream)), "#K4");
9224 Assert.IsFalse (typeof (FileStream).IsAssignableFrom (tb3), "#K5");
9225 Assert.IsFalse (tb3.IsAssignableFrom (typeof (FileStream)), "#K6");
9226 Assert.IsTrue (typeof (object).IsAssignableFrom (tb3), "#K7");
9227 Assert.IsFalse (tb3.IsAssignableFrom (typeof (object)), "#K8");
9228 Assert.IsFalse (typeof (IDisposable).IsAssignableFrom (tb3), "#K9");
9229 Assert.IsFalse (tb3.IsAssignableFrom (typeof (IDisposable)), "#K10");
9231 Assert.IsTrue (tb3.IsAssignableFrom (tb3), "#L1");
9232 Assert.IsFalse (tb3.IsAssignableFrom (tb2), "#L2");
9233 Assert.IsFalse (tb3.IsAssignableFrom (tb), "#L3");
9234 Assert.IsTrue (tb2.IsAssignableFrom (tb3), "#L4");
9235 Assert.IsTrue (tb.IsAssignableFrom (tb3), "#L5");
9239 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9240 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_Mono ()
9242 TypeBuilder tb = module.DefineType (genTypeName (),
9243 TypeAttributes.Public, typeof (FormatException),
9244 new Type [] { typeof (IThrowable) });
9245 tb.AddInterfaceImplementation (typeof (IDestroyable));
9247 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9248 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9250 Assert.IsTrue (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9251 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9255 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9256 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_MS ()
9258 TypeBuilder tb = module.DefineType (genTypeName (),
9259 TypeAttributes.Public, typeof (FormatException),
9260 new Type [] { typeof (IThrowable) });
9261 tb.AddInterfaceImplementation (typeof (IDestroyable));
9263 Assert.IsTrue (typeof (IThrowable).IsAssignableFrom (tb), "#A1");
9264 Assert.IsFalse (tb.IsAssignableFrom (typeof (IThrowable)), "#A2");
9266 Assert.IsFalse (typeof (IDestroyable).IsAssignableFrom (tb), "#B1");
9267 Assert.IsFalse (tb.IsAssignableFrom (typeof (IDestroyable)), "#B2");
9272 [Category ("NotDotNet")]
9273 public void IsAssignableFrom_NotCreated_Array ()
9275 TypeBuilder tb = module.DefineType (genTypeName (),
9276 TypeAttributes.Public, typeof (FormatException),
9278 typeof (IThrowable), typeof (Bar),
9279 typeof (IComparable)
9282 Assert.IsTrue (typeof (Foo []).IsAssignableFrom (module.GetType (
9283 tb.FullName + "[]")), "#1");
9284 Assert.IsTrue (typeof (Bar []).IsAssignableFrom (module.GetType (
9285 tb.FullName + "[]")), "#2");
9286 Assert.IsFalse (typeof (Baz []).IsAssignableFrom (module.GetType (
9287 tb.FullName + "[]")), "#3");
9291 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9292 public void IsAssignableFrom_NotCreated_BaseInterface_Mono ()
9294 TypeBuilder tb = module.DefineType (genTypeName (),
9295 TypeAttributes.Public, typeof (FormatException),
9297 typeof (IThrowable), typeof (Bar),
9298 typeof (IComparable)
9301 Assert.IsTrue (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9302 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9306 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9307 public void IsAssignableFrom_NotCreated_BaseInterface_MS ()
9309 TypeBuilder tb = module.DefineType (genTypeName (),
9310 TypeAttributes.Public, typeof (FormatException),
9312 typeof (IThrowable), typeof (Bar),
9313 typeof (IComparable)
9316 Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#1");
9317 Assert.IsFalse (tb.IsAssignableFrom (typeof (IMoveable)), "#2");
9321 public void CreateType_EmptyMethodBody ()
9323 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9325 tb.DefineMethod ("foo", MethodAttributes.Public, typeof (void), new Type [] { });
9329 } catch (InvalidOperationException ex) {
9330 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9331 Assert.IsNull (ex.InnerException, "#3");
9332 Assert.IsNotNull (ex.Message, "#4");
9337 public void CreateType_EmptyCtorBody ()
9339 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9341 tb.DefineConstructor (0, CallingConventions.Standard, null);
9345 } catch (InvalidOperationException ex) {
9346 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9347 Assert.IsNull (ex.InnerException, "#3");
9348 Assert.IsNotNull (ex.Message, "#4");
9354 [Category ("NotDotNet")] // Parent type was not extensible by the given type
9356 [Category ("NotWorking")]
9357 public void CreateType_Interface_ParentInvalid ()
9361 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9362 typeof (Exception));
9363 Assert.AreEqual (typeof (Exception), tb.BaseType, "#A1");
9366 Assert.Fail ("#A2");
9367 } catch (TypeLoadException ex) {
9368 // Could not load interface 't5' from assembly '...'
9369 // because it must extend from Object
9370 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#A3");
9371 Assert.IsNull (ex.InnerException, "#A4");
9372 Assert.IsNotNull (ex.Message, "#A5");
9373 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#A6");
9374 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#A7");
9377 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9379 Assert.AreEqual (typeof (object), tb.BaseType, "#B1");
9382 Assert.Fail ("#B2");
9383 } catch (TypeLoadException ex) {
9384 // Failure has occurred while loading a type
9385 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#B3");
9386 Assert.IsNull (ex.InnerException, "#B4");
9387 Assert.IsNotNull (ex.Message, "#B5");
9390 tb = module.DefineType (genTypeName (), TypeAttributes.Interface,
9391 typeof (EmptyInterface));
9392 Assert.AreEqual (typeof (EmptyInterface), tb.BaseType, "#C1");
9395 Assert.Fail ("#C2");
9396 } catch (TypeLoadException ex) {
9397 // Could not load interface 't5' from assembly '...'
9398 // because the parent type is an interface
9399 Assert.AreEqual (typeof (TypeLoadException), ex.GetType (), "#C3");
9400 Assert.IsNull (ex.InnerException, "#C4");
9401 Assert.IsNotNull (ex.Message, "#C5");
9402 Assert.IsTrue (ex.Message.IndexOf (tb.Name) != -1, "#C6");
9403 Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#C7");
9408 public void CreateType_Parent_DefaultCtorMissing ()
9412 tb = module.DefineType (genTypeName ());
9413 ConstructorBuilder cb = tb.DefineConstructor (
9414 MethodAttributes.Public,
9415 CallingConventions.Standard,
9416 new Type [] { typeof (string) });
9417 cb.GetILGenerator ().Emit (OpCodes.Ret);
9418 Type parent_type = tb.CreateType ();
9420 tb = module.DefineType (genTypeName (), TypeAttributes.Class,
9425 } catch (NotSupportedException ex) {
9426 // Parent does not have a default constructor.
9427 // The default constructor must be explicitly defined
9428 Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
9429 Assert.IsNull (ex.InnerException, "#3");
9430 Assert.IsNotNull (ex.Message, "#4");
9435 public void CreateType_Parent_Null ()
9440 tb = module.DefineType (genTypeName (), TypeAttributes.Public, null);
9441 Assert.AreEqual (typeof (object), tb.BaseType, "#A1");
9442 emitted_type = tb.CreateType ();
9443 Assert.AreEqual (typeof (object), emitted_type.BaseType, "#A2");
9445 tb = module.DefineType (genTypeName (), TypeAttributes.Interface | TypeAttributes.Abstract, null);
9446 Assert.IsNull (tb.BaseType, "#B1");
9447 emitted_type = tb.CreateType ();
9448 Assert.IsNull (emitted_type.BaseType, "#B2");
9453 [Category ("NotWorking")]
9454 public void DefineGenericParameters_AlreadyDefined ()
9456 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9457 tb.DefineGenericParameters ("K");
9459 tb.DefineGenericParameters ("V");
9461 } catch (InvalidOperationException ex) {
9462 // Operation is not valid due to the current
9463 // state of the object
9464 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9465 Assert.IsNull (ex.InnerException, "#3");
9466 Assert.IsNotNull (ex.Message, "#4");
9471 [Category ("NotWorking")]
9472 public void DefineGenericParameters_Names_Empty ()
9474 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9477 tb.DefineGenericParameters (new string [0]);
9479 } catch (ArgumentException ex) {
9480 // Value does not fall within the expected range
9481 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9482 Assert.IsNull (ex.InnerException, "#3");
9483 Assert.IsNotNull (ex.Message, "#4");
9484 Assert.IsNull (ex.ParamName, "#5");
9489 [Category ("NotWorking")]
9490 public void DefineGenericParameters_Names_Null ()
9492 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9495 tb.DefineGenericParameters ((string []) null);
9496 Assert.Fail ("#A1");
9497 } catch (ArgumentNullException ex) {
9498 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9499 Assert.IsNull (ex.InnerException, "#A3");
9500 Assert.IsNotNull (ex.Message, "#A4");
9501 Assert.AreEqual ("names", ex.ParamName, "#A5");
9505 tb.DefineGenericParameters ("K", null, "V");
9506 Assert.Fail ("#B1");
9507 } catch (ArgumentNullException ex) {
9508 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9509 Assert.IsNull (ex.InnerException, "#B3");
9510 Assert.IsNotNull (ex.Message, "#B4");
9511 Assert.AreEqual ("names", ex.ParamName, "#B5");
9516 public void GenericType ()
9518 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9519 tb.DefineGenericParameters ("T");
9521 Assert.IsTrue (tb.IsGenericType, "#A1");
9522 Assert.IsTrue (tb.IsGenericTypeDefinition, "#A2");
9523 Assert.IsTrue (tb.ContainsGenericParameters, "#A3");
9524 Assert.IsFalse (tb.IsGenericParameter, "#A4");
9526 Type[] args = tb.GetGenericArguments ();
9527 Assert.IsFalse (args [0].IsGenericType, "#B1");
9528 Assert.IsFalse (args [0].IsGenericTypeDefinition, "#B2");
9529 Assert.IsTrue (args [0].ContainsGenericParameters, "#B3");
9530 Assert.IsTrue (args [0].IsGenericParameter, "#B4");
9534 public void MakeGenericType ()
9539 tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9540 tb.DefineGenericParameters ("T");
9542 generic_type = tb.MakeGenericType (typeof (int));
9543 Assert.IsTrue (generic_type.IsGenericType, "#A1");
9544 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A2");
9545 Assert.IsFalse (generic_type.ContainsGenericParameters, "#A3");
9546 Assert.IsFalse (generic_type.IsGenericParameter, "#A4");
9548 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9549 Assert.IsTrue (generic_type.IsGenericType, "#B1");
9550 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B2");
9551 Assert.IsTrue (generic_type.ContainsGenericParameters, "#B3");
9552 Assert.IsFalse (generic_type.IsGenericParameter, "#B4");
9554 tb = module.DefineType (genTypeName (), TypeAttributes.Interface
9555 | TypeAttributes.Abstract | TypeAttributes.Public);
9556 tb.DefineGenericParameters ("T");
9558 generic_type = tb.MakeGenericType (typeof (int));
9559 Assert.IsTrue (generic_type.IsGenericType, "#C1");
9560 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#C2");
9561 Assert.IsFalse (generic_type.ContainsGenericParameters, "#C3");
9562 Assert.IsFalse (generic_type.IsGenericParameter, "#C4");
9564 generic_type = tb.MakeGenericType (typeof (List<>).GetGenericArguments ());
9565 Assert.IsTrue (generic_type.IsGenericType, "#D1");
9566 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#D2");
9567 Assert.IsTrue (generic_type.ContainsGenericParameters, "#D3");
9568 Assert.IsFalse (generic_type.IsGenericParameter, "#D4");
9572 public void MakeGenericType_NoGenericTypeDefinition ()
9574 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9576 tb.MakeGenericType (typeof (int));
9578 } catch (InvalidOperationException ex) {
9579 // Operation is not valid due to the current
9580 // state of the object
9581 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9582 Assert.IsNull (ex.InnerException, "#3");
9583 Assert.IsNotNull (ex.Message, "#4");
9588 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9589 public void MakeGenericType_TypeArguments_Null_Mono ()
9591 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9592 tb.DefineGenericParameters ("K", "V");
9595 tb.MakeGenericType ((Type []) null);
9596 Assert.Fail ("#A1");
9597 } catch (ArgumentNullException ex) {
9598 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
9599 Assert.IsNull (ex.InnerException, "#A3");
9600 Assert.IsNotNull (ex.Message, "#A4");
9601 Assert.AreEqual ("typeArguments", ex.ParamName, "#A5");
9605 tb.MakeGenericType (typeof (string), (Type) null);
9606 Assert.Fail ("#B1");
9607 } catch (ArgumentNullException ex) {
9608 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
9609 Assert.IsNull (ex.InnerException, "#B3");
9610 Assert.IsNotNull (ex.Message, "#B4");
9611 Assert.AreEqual ("typeArguments", ex.ParamName, "#B5");
9616 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9617 public void MakeGenericType_TypeArguments_Null_MS ()
9622 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9623 tb.DefineGenericParameters ("K", "V");
9625 generic_type = tb.MakeGenericType ((Type []) null);
9626 Assert.IsNotNull (generic_type, "#A1");
9627 Assert.IsTrue (generic_type.IsGenericType, "#A2");
9628 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#A3");
9629 type_args = generic_type.GetGenericArguments ();
9630 Assert.IsNull (type_args, "#A4");
9632 generic_type = tb.MakeGenericType (typeof (string), (Type) null);
9633 Assert.IsNotNull (generic_type, "#B1");
9634 Assert.IsTrue (generic_type.IsGenericType, "#B2");
9635 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#B3");
9636 type_args = generic_type.GetGenericArguments ();
9637 Assert.IsNotNull (type_args, "#B4");
9638 Assert.AreEqual (2, type_args.Length, "#B5");
9639 Assert.AreEqual (typeof (string), type_args [0], "#B6");
9640 Assert.IsNull (type_args [1], "#B7");
9644 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9645 public void MakeGenericType_TypeArguments_Mismatch_Mono ()
9647 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9648 tb.DefineGenericParameters ("K", "V");
9650 tb.MakeGenericType (typeof (int));
9652 } catch (ArgumentException ex) {
9653 // The type or method has 2 generic prarameter(s)
9654 // but 1 generic argument(s) were provided. A
9655 // generic argument must be provided for each
9656 // generic parameter
9657 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
9658 Assert.IsNull (ex.InnerException, "#3");
9659 Assert.IsNotNull (ex.Message, "#4");
9660 Assert.AreEqual ("typeArguments", ex.ParamName, "#5");
9665 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9666 public void MakeGenericType_TypeArguments_Mismatch_MS ()
9668 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9669 tb.DefineGenericParameters ("K", "V");
9671 Type generic_type = tb.MakeGenericType (typeof (int));
9672 Assert.IsTrue (generic_type.IsGenericType, "#1");
9673 Assert.IsFalse (generic_type.IsGenericTypeDefinition, "#2");
9674 Type [] type_args = generic_type.GetGenericArguments ();
9675 Assert.IsNotNull (type_args, "#3");
9676 Assert.AreEqual (1, type_args.Length, "#4");
9677 Assert.AreEqual (typeof (int), type_args [0], "#5");
9681 public void MakeArrayType_Complete ()
9684 TypeBuilder tb = module.DefineType (genTypeName (),
9685 TypeAttributes.Sealed | TypeAttributes.Serializable,
9686 typeof (ContextBoundObject));
9687 Type emittedType = tb.CreateType ();
9688 Type arrayType = tb.MakeArrayType ();
9689 Assert.IsTrue (arrayType.IsArray, "#A1");
9690 Assert.IsTrue (arrayType.HasElementType, "#A2");
9691 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9692 Assert.IsFalse (tb.HasElementType, "#A4");
9693 Assert.IsTrue (tb.IsCreated (), "#A5");
9696 tb = module.DefineType (genTypeName (),
9697 TypeAttributes.Sealed | TypeAttributes.Serializable,
9698 typeof (ValueType));
9699 emittedType = tb.CreateType ();
9700 arrayType = tb.MakeArrayType ();
9701 Assert.IsTrue (arrayType.IsArray, "#B1");
9702 Assert.IsTrue (arrayType.HasElementType, "#B2");
9703 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9704 Assert.IsFalse (tb.HasElementType, "#B4");
9705 Assert.IsTrue (tb.IsCreated (), "#B5");
9707 tb = module.DefineType (genTypeName (),
9708 TypeAttributes.Sealed | TypeAttributes.Serializable,
9710 tb.DefineField ("value__", typeof (int), FieldAttributes.SpecialName |
9711 FieldAttributes.Private | FieldAttributes.RTSpecialName);
9712 emittedType = tb.CreateType ();
9713 arrayType = tb.MakeArrayType ();
9714 Assert.IsTrue (arrayType.IsArray, "#C1");
9715 Assert.IsTrue (arrayType.HasElementType, "#C2");
9716 Assert.AreEqual (tb, arrayType.GetElementType (), "#C3");
9717 Assert.IsFalse (tb.HasElementType, "#C4");
9718 Assert.IsTrue (tb.IsCreated (), "#C5");
9721 [Test] // bug #82015
9722 public void MakeArrayType_Incomplete ()
9725 TypeBuilder tb = module.DefineType (genTypeName (),
9726 TypeAttributes.Sealed | TypeAttributes.Serializable,
9727 typeof (ContextBoundObject));
9728 Type arrayType = tb.MakeArrayType ();
9729 Assert.IsTrue (arrayType.IsArray, "#A1");
9730 Assert.IsTrue (arrayType.HasElementType, "#A2");
9731 Assert.AreEqual (tb, arrayType.GetElementType (), "#A3");
9732 Assert.IsFalse (tb.HasElementType, "#A4");
9733 Assert.IsFalse (tb.IsCreated (), "#A5");
9736 tb = module.DefineType (genTypeName (),
9737 TypeAttributes.Sealed | TypeAttributes.Serializable,
9738 typeof (ValueType));
9739 arrayType = tb.MakeArrayType ();
9740 Assert.IsTrue (arrayType.IsArray, "#B1");
9741 Assert.IsTrue (arrayType.HasElementType, "#B2");
9742 Assert.AreEqual (tb, arrayType.GetElementType (), "#B3");
9743 Assert.IsFalse (tb.HasElementType, "#B4");
9744 Assert.IsFalse (tb.IsCreated (), "#B5");
9747 tb = module.DefineType (genTypeName (),
9748 TypeAttributes.Sealed | TypeAttributes.Serializable,
9750 arrayType = tb.MakeArrayType ();
9751 Assert.IsTrue (arrayType.IsArray, "#C1");
9752 Assert.IsTrue (arrayType.HasElementType, "#C2");
9753 Assert.IsFalse (tb.HasElementType, "#C3");
9754 Assert.IsFalse (tb.IsCreated (), "#C4");
9758 public void GetCustomAttributes_InflatedType ()
9760 TypeBuilder tb = module.DefineType (genTypeName ());
9761 tb.DefineGenericParameters (new string[] { "FOO" });
9763 ConstructorInfo guidCtor = typeof (GuidAttribute).GetConstructor (
9764 new Type [] { typeof (string) });
9766 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (guidCtor,
9767 new object [] { Guid.NewGuid ().ToString ("D") }, new FieldInfo [0], new object [0]);
9769 tb.SetCustomAttribute (caBuilder);
9770 Type t = tb.CreateType ();
9772 Type inflated = t.MakeGenericType (new Type [] { typeof (int) });
9774 Assert.AreEqual (1, inflated.GetCustomAttributes (false).Length);
9778 public void GetField ()
9780 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
9781 GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");
9783 ConstructorBuilder cb = tb.DefineDefaultConstructor (MethodAttributes.Public);
9785 FieldBuilder fb1 = tb.DefineField ("field1", typeParams [0], FieldAttributes.Public);
9787 Type t = tb.MakeGenericType (typeof (int));
9789 // Chect that calling MakeArrayType () does not initialize the class
9793 // Check that the instantiation of a type builder contains live data
9794 TypeBuilder.GetField (t, fb1);
9795 FieldBuilder fb2 = tb.DefineField ("field2", typeParams [0], FieldAttributes.Public);
9796 FieldInfo fi2 = TypeBuilder.GetField (t, fb1);
9798 MethodBuilder mb = tb.DefineMethod ("get_int", MethodAttributes.Public|MethodAttributes.Static, typeof (int), Type.EmptyTypes);
9799 ILGenerator ilgen = mb.GetILGenerator ();
9800 ilgen.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t, cb));
9801 ilgen.Emit (OpCodes.Dup);
9802 ilgen.Emit (OpCodes.Ldc_I4, 42);
9803 ilgen.Emit (OpCodes.Stfld, fi2);
9804 ilgen.Emit (OpCodes.Ldfld, fi2);
9805 ilgen.Emit (OpCodes.Ret);
9807 // Check GetField on a type instantiated with type parameters
9808 Type t3 = tb.MakeGenericType (typeParams [0]);
9809 FieldBuilder fb3 = tb.DefineField ("field3", typeParams [0], FieldAttributes.Public);
9810 FieldInfo fi3 = TypeBuilder.GetField (t3, fb3);
9812 MethodBuilder mb3 = tb.DefineMethod ("get_T", MethodAttributes.Public|MethodAttributes.Static, typeParams [0], Type.EmptyTypes);
9813 ILGenerator ilgen3 = mb3.GetILGenerator ();
9814 ilgen3.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (t3, cb));
9815 ilgen3.Emit (OpCodes.Ldfld, fi3);
9816 ilgen3.Emit (OpCodes.Ret);
9818 Type created = tb.CreateType ();
9820 Type inst = created.MakeGenericType (typeof (object));
9822 Assert.AreEqual (42, inst.GetMethod ("get_int").Invoke (null, null));
9824 Assert.AreEqual (null, inst.GetMethod ("get_T").Invoke (null, null));
9827 [Test] //bug #354047
9828 public void CreatedTypeInstantiationOverTypeBuilderArgsIsNotAGenericTypeDefinition ()
9830 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9831 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9832 Type t = tb.CreateType ();
9834 Type inst = tb.MakeGenericType (typeParams [0]);
9835 Assert.IsFalse (inst.IsGenericTypeDefinition, "#1 create type instance is not a generic type definition");
9838 [Test] //bug #354047
9839 public void CreatedTypeAndTypeBuilderOwnTheirGenericArguments ()
9841 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9842 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9843 Type t = tb.CreateType ();
9845 Assert.IsTrue (tb.GetGenericArguments()[0].DeclaringType == tb, "#1 TypeBuilder owns its arguments");
9846 Assert.IsTrue (t.GetGenericArguments()[0].DeclaringType == t, "#1 create type owns its arguments");
9849 [Test] //bug #354047
9850 public void CreatedTypeAndTypeBuilderDontShareGenericArguments ()
9852 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9853 GenericTypeParameterBuilder[] typeParams = tb.DefineGenericParameters (new String[] { "T" });
9854 Type t = tb.CreateType ();
9856 Assert.IsTrue (tb.GetGenericArguments()[0] != t.GetGenericArguments()[0], "#1 TypeBuilder and create type arguments are diferent");
9859 [Test] //bug #399047
9860 public void FieldOnTypeBuilderInstDontInflateWhenEncoded () {
9861 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9863 module = assembly.DefineDynamicModule ("Instance.exe");
9865 TypeBuilder G = module.DefineType ("G", TypeAttributes.Public);
9866 Type T = G.DefineGenericParameters ("T") [0];
9867 ConstructorInfo ctor = G.DefineDefaultConstructor (MethodAttributes.Public);
9868 Type GObj = G.MakeGenericType (new Type [] { T });
9870 FieldBuilder F = G.DefineField ("F", T, FieldAttributes.Public);
9872 TypeBuilder P = module.DefineType ("P", TypeAttributes.Public);
9874 MethodBuilder Test = P.DefineMethod ("Test", MethodAttributes.Public);
9875 Type TATest = Test.DefineGenericParameters ("TA") [0];
9877 Type TestGObj = G.MakeGenericType (new Type [] { TATest });
9879 ILGenerator il = Test.GetILGenerator ();
9881 il.Emit (OpCodes.Newobj, TypeBuilder.GetConstructor (TestGObj, ctor));
9882 il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (TestGObj, F));
9883 il.Emit (OpCodes.Pop);
9885 il.Emit (OpCodes.Ret);
9888 MethodBuilder main = P.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static);
9890 ILGenerator il = main.GetILGenerator ();
9891 il.Emit(OpCodes.Newobj, P.DefineDefaultConstructor (MethodAttributes.Public));
9892 il.Emit(OpCodes.Call, Test.MakeGenericMethod (typeof (int)));
9893 il.Emit (OpCodes.Ret);
9896 assembly.SetEntryPoint (main);
9900 assembly.Save ("Instance.exe");
9901 Thread.GetDomain ().ExecuteAssembly(Path.GetTempPath () + Path.DirectorySeparatorChar + "Instance.exe");
9905 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers ()
9907 TypeBuilder tb = module.DefineType ("Type1", TypeAttributes.Public);
9908 FieldBuilder fb = tb.DefineInitializedData ("Foo", new byte [] {1,2,3,4}, FieldAttributes.Static|FieldAttributes.Public);
9911 assembly = Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME+"2"), AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
9912 module = assembly.DefineDynamicModule ("Instance.exe");
9914 TypeBuilder tb2 = module.DefineType ("Type2", TypeAttributes.Public);
9915 MethodBuilder mb = tb2.DefineMethod ("Test", MethodAttributes.Public | MethodAttributes.Static, typeof (object), new Type [0]);
9916 ILGenerator il = mb.GetILGenerator ();
9918 il.Emit (OpCodes.Ldc_I4_1);
9919 il.Emit (OpCodes.Newarr, typeof (int));
9920 il.Emit (OpCodes.Dup);
9921 il.Emit (OpCodes.Ldtoken, fb);
9922 il.Emit (OpCodes.Call, typeof (RuntimeHelpers).GetMethod ("InitializeArray"));
9923 il.Emit (OpCodes.Ret);
9925 Type t = tb2.CreateType ();
9926 int[] res = (int[])t.GetMethod ("Test").Invoke (null, new object[0]);
9927 //Console.WriteLine (res[0]);
9931 public interface IDelegateFactory
9933 Delegate Create (Delegate del);
9937 public void CreateType_Ctor_NoBody ()
9939 TypeBuilder tb = module.DefineType (genTypeName ());
9940 tb.DefineConstructor (MethodAttributes.Public,
9941 CallingConventions.Standard,
9942 new Type [] { typeof (string) });
9946 } catch (InvalidOperationException ex) {
9947 // Method '.ctor' does not have a method body
9948 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
9949 Assert.IsNull (ex.InnerException, "#3");
9950 Assert.IsNotNull (ex.Message, "#4");
9951 Assert.IsTrue (ex.Message.IndexOf (".ctor") != -1, "#5");
9955 [Test] //bug #361689
9956 public void CreateTypeFailsWithInvalidMethodOverride ()
9958 TypeBuilder tb = module.DefineType ("TheType", TypeAttributes.Public, typeof (object), new Type [] {typeof (IDelegateFactory)});
9960 MethodBuilder mc = tb.DefineMethod ("Create", MethodAttributes.Public, typeof (Delegate), new Type[] {typeof (Delegate)});
9961 ILGenerator gen = mc.GetILGenerator ();
9962 gen.Emit (OpCodes.Ldarg_0);
9963 gen.Emit (OpCodes.Ret);
9964 tb.DefineMethodOverride (mc, typeof (IDelegateFactory).GetMethod ("Create"));
9967 Assert.Fail ("#1 create type did not throw TypeLoadException");
9968 } catch (TypeLoadException) {
9973 [Test] //bug #349194
9974 public void IsAssignableToWorksWithInterfacesOnParent ()
9976 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9977 TypeBuilder tb2 = module.DefineType (genTypeName (), TypeAttributes.Public, tb);
9979 Assert.IsFalse (typeof (EmptyInterface).IsAssignableFrom (tb));
9980 Type t = tb.CreateType ();
9981 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb));
9982 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t));
9985 Assert.IsFalse (typeof (EmptyInterface).IsAssignableFrom (tb2));
9986 Type t2 = tb2.CreateType ();
9987 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (tb2));
9988 Assert.IsTrue (typeof (EmptyInterface).IsAssignableFrom (t2));
9993 [Test] //bug #430508
9994 public void MakeGenericTypeRespectBaseType ()
9996 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (EmptyIfaceImpl));
9997 EnumBuilder eb = module.DefineEnum (genTypeName (), TypeAttributes.Public, typeof (int));
9999 MethodBuilder mb = tb.DefineMethod ("Test",
10000 MethodAttributes.Public,
10001 typeof (Tuple<,>).MakeGenericType (typeof (int), eb),
10003 ILGenerator il = mb.GetILGenerator();
10004 il.Emit (OpCodes.Ldnull);
10005 il.Emit (OpCodes.Ret);
10007 Type e = eb.CreateType ();
10008 Type c = tb.CreateType ();
10010 Assert.AreEqual (c.GetMethod ("Test").ReturnType.GetGenericArguments ()[1], e, "#1");
10014 public void GetCustomAttrOnFieldOfInflatedType ()
10016 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
10017 tb.DefineGenericParameters ("T");
10019 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10020 typeof (SimpleTestAttribute).GetConstructors ()[0],
10023 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
10024 field.SetCustomAttribute (caBuilder);
10026 Type t = tb.CreateType ();
10028 FieldInfo fi = t.GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10029 object[] cattrs = fi.GetCustomAttributes (false);
10030 Assert.AreEqual (1, cattrs.Length);
10032 fi = t.MakeGenericType (typeof (int)).GetFields (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10033 cattrs = fi.GetCustomAttributes (false);
10034 Assert.AreEqual (1, cattrs.Length);
10038 public void GetCustomAttrOnPropertyOfInflatedType ()
10040 TypeBuilder tb = module.DefineType (genTypeName ());
10041 tb.DefineGenericParameters ("T");
10043 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10044 typeof (SimpleTestAttribute).GetConstructors ()[0],
10047 PropertyBuilder property = DefineStringProperty (tb, "Name", "name", MethodAttributes.Public);
10048 property.SetCustomAttribute (caBuilder);
10050 Type t = tb.CreateType ();
10052 PropertyInfo pi = t.GetProperties ()[0];
10053 object[] cattrs = pi.GetCustomAttributes (false);
10054 Assert.AreEqual (1, cattrs.Length);
10056 pi = t.MakeGenericType (typeof (int)).GetProperties ()[0];
10057 cattrs = pi.GetCustomAttributes (false);
10058 Assert.AreEqual (1, cattrs.Length);
10062 public void GetCustomAttrOnEventOfInflatedType ()
10064 TypeBuilder tb = module.DefineType (genTypeName ());
10065 tb.DefineGenericParameters ("T");
10067 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10068 typeof (SimpleTestAttribute).GetConstructors ()[0],
10071 EventBuilder evt = tb.DefineEvent ("OI", 0, typeof (int));
10072 evt.SetCustomAttribute (caBuilder);
10074 Type t = tb.CreateType ();
10076 EventInfo ei = t.GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10077 object[] cattrs = ei.GetCustomAttributes (false);
10078 Assert.AreEqual (1, cattrs.Length);
10080 ei = t.MakeGenericType (typeof (int)).GetEvents (BindingFlags.NonPublic | BindingFlags.Instance)[0];
10081 cattrs = ei.GetCustomAttributes (false);
10082 Assert.AreEqual (1, cattrs.Length);
10085 public void TestDoubleInitializationOfMonoGenericClass () //bug #400643
10087 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public);
10088 tb.DefineGenericParameters ("T");
10090 CustomAttributeBuilder caBuilder = new CustomAttributeBuilder (
10091 typeof (SimpleTestAttribute).GetConstructors ()[0],
10094 FieldBuilder field = tb.DefineField ("OI", typeof (int), 0);
10095 field.SetCustomAttribute (caBuilder);
10098 tb.MakeGenericType (typeof (int)).GetMethods ();
10099 tb.MakeGenericType (typeof (double)).GetMethods ();
10101 Type t = tb.CreateType ();
10103 t.MakeGenericType (typeof (int)).GetMethods ();
10104 t.MakeGenericType (typeof (double)).GetMethods ();
10108 public void TestGenericFieldAccess () // bug #467415
10110 AssemblyName asmName = new AssemblyName("DemoMethodBuilder1");
10111 AppDomain domain = AppDomain.CurrentDomain;
10112 AssemblyBuilder demoAssembly =
10113 domain.DefineDynamicAssembly(asmName,
10114 AssemblyBuilderAccess.RunAndSave);
10116 // Define the module that contains the code. For an
10117 // assembly with one module, the module name is the
10118 // assembly name plus a file extension.
10119 ModuleBuilder demoModule =
10120 demoAssembly.DefineDynamicModule(asmName.Name,
10121 asmName.Name+".dll");
10123 TypeBuilder demoType =
10124 demoModule.DefineType("DemoType", TypeAttributes.Public);
10126 MethodBuilder factory =
10127 demoType.DefineMethod("Factory",
10128 MethodAttributes.Public | MethodAttributes.Static);
10130 string[] typeParameterNames = {"T"};
10131 GenericTypeParameterBuilder[] typeParameters =
10132 factory.DefineGenericParameters(typeParameterNames);
10134 GenericTypeParameterBuilder T = typeParameters[0];
10137 factory.SetParameters(parms);
10139 factory.SetReturnType(T);
10141 ILGenerator ilgen = factory.GetILGenerator();
10143 Type G = typeof(Gen<>);
10144 Type GT = G.MakeGenericType (T);
10145 FieldInfo GF = G.GetField("field");
10146 FieldInfo GTF = TypeBuilder.GetField(GT, GF);
10148 ilgen.Emit(OpCodes.Ldsfld, GTF);
10149 ilgen.Emit(OpCodes.Ret);
10151 // Complete the type.
10152 Type dt = demoType.CreateType();
10153 // Save the assembly, so it can be examined with Ildasm.exe.
10154 //demoAssembly.Save(asmName.Name+".dll");
10156 MethodInfo m = dt.GetMethod("Factory");
10157 MethodInfo bound = m.MakeGenericMethod(typeof(int));
10159 // Display a string representing the bound method.
10160 //Console.WriteLine(bound);
10162 object[] parameters = {};
10163 int result = (int)(bound.Invoke(null, parameters));
10165 Assert.AreEqual (0, result, "#1");
10169 static MethodInfo GetMethodByName (MethodInfo [] methods, string name)
10171 foreach (MethodInfo mi in methods)
10172 if (mi.Name == name)
10177 void CreateMembers (TypeBuilder tb, string suffix, bool defineCtors)
10179 ConstructorBuilder cb;
10181 PropertyBuilder pb;
10187 // instance constructors
10189 cb = tb.DefineConstructor (MethodAttributes.Private,
10190 CallingConventions.Standard,
10191 new Type [] { typeof (int), typeof (int) });
10192 cb.GetILGenerator ().Emit (OpCodes.Ret);
10194 cb = tb.DefineConstructor (MethodAttributes.Family,
10195 CallingConventions.Standard,
10196 new Type [] { typeof (string) });
10197 cb.GetILGenerator ().Emit (OpCodes.Ret);
10199 cb = tb.DefineConstructor (MethodAttributes.FamANDAssem,
10200 CallingConventions.Standard,
10201 new Type [] { typeof (string), typeof (string) });
10202 cb.GetILGenerator ().Emit (OpCodes.Ret);
10204 cb = tb.DefineConstructor (MethodAttributes.FamORAssem,
10205 CallingConventions.Standard,
10206 new Type [] { typeof (int) });
10207 cb.GetILGenerator ().Emit (OpCodes.Ret);
10209 cb = tb.DefineConstructor (MethodAttributes.Public,
10210 CallingConventions.Standard,
10211 new Type [] { typeof (int), typeof (bool) });
10212 cb.GetILGenerator ().Emit (OpCodes.Ret);
10214 cb = tb.DefineConstructor (MethodAttributes.Assembly,
10215 CallingConventions.Standard,
10216 new Type [] { typeof (string), typeof (int) });
10217 cb.GetILGenerator ().Emit (OpCodes.Ret);
10220 // static constructors
10223 cb = tb.DefineConstructor (MethodAttributes.Private |
10224 MethodAttributes.Static,
10225 CallingConventions.Standard,
10227 cb.GetILGenerator ().Emit (OpCodes.Ret);
10231 // instance methods
10234 mb = tb.DefineMethod ("GetPrivateInstance" + suffix,
10235 MethodAttributes.Private, typeof (void),
10237 mb.GetILGenerator ().Emit (OpCodes.Ret);
10239 mb = tb.DefineMethod ("GetFamilyInstance" + suffix,
10240 MethodAttributes.Family, typeof (void),
10242 mb.GetILGenerator ().Emit (OpCodes.Ret);
10244 mb = tb.DefineMethod ("GetFamANDAssemInstance" + suffix,
10245 MethodAttributes.FamANDAssem, typeof (void),
10247 mb.GetILGenerator ().Emit (OpCodes.Ret);
10249 mb = tb.DefineMethod ("GetFamORAssemInstance" + suffix,
10250 MethodAttributes.FamORAssem, typeof (void),
10252 mb.GetILGenerator ().Emit (OpCodes.Ret);
10254 mb = tb.DefineMethod ("GetPublicInstance" + suffix,
10255 MethodAttributes.Public, typeof (void),
10257 mb.GetILGenerator ().Emit (OpCodes.Ret);
10259 mb = tb.DefineMethod ("GetAssemblyInstance" + suffix,
10260 MethodAttributes.Assembly, typeof (void),
10262 mb.GetILGenerator ().Emit (OpCodes.Ret);
10268 mb = tb.DefineMethod ("GetPrivateStatic" + suffix,
10269 MethodAttributes.Private | MethodAttributes.Static,
10270 typeof (void), Type.EmptyTypes);
10271 mb.GetILGenerator ().Emit (OpCodes.Ret);
10273 mb = tb.DefineMethod ("GetFamilyStatic" + suffix,
10274 MethodAttributes.Family | MethodAttributes.Static,
10275 typeof (void), Type.EmptyTypes);
10276 mb.GetILGenerator ().Emit (OpCodes.Ret);
10278 mb = tb.DefineMethod ("GetFamANDAssemStatic" + suffix,
10279 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10280 typeof (void), Type.EmptyTypes);
10281 mb.GetILGenerator ().Emit (OpCodes.Ret);
10283 mb = tb.DefineMethod ("GetFamORAssemStatic" + suffix,
10284 MethodAttributes.FamORAssem | MethodAttributes.Static,
10285 typeof (void), Type.EmptyTypes);
10286 mb.GetILGenerator ().Emit (OpCodes.Ret);
10288 mb = tb.DefineMethod ("GetPublicStatic" + suffix,
10289 MethodAttributes.Public | MethodAttributes.Static,
10290 typeof (void), Type.EmptyTypes);
10291 mb.GetILGenerator ().Emit (OpCodes.Ret);
10293 mb = tb.DefineMethod ("GetAssemblyStatic" + suffix,
10294 MethodAttributes.Assembly | MethodAttributes.Static,
10295 typeof (void), Type.EmptyTypes);
10296 mb.GetILGenerator ().Emit (OpCodes.Ret);
10302 tb.DefineField ("privateInstance" + suffix,
10303 typeof (string), FieldAttributes.Private);
10304 tb.DefineField ("familyInstance" + suffix,
10305 typeof (string), FieldAttributes.Family);
10306 tb.DefineField ("famANDAssemInstance" + suffix,
10307 typeof (string), FieldAttributes.FamANDAssem);
10308 tb.DefineField ("famORAssemInstance" + suffix,
10309 typeof (string), FieldAttributes.FamORAssem);
10310 tb.DefineField ("publicInstance" + suffix,
10311 typeof (string), FieldAttributes.Public);
10312 tb.DefineField ("assemblyInstance" + suffix,
10313 typeof (string), FieldAttributes.Assembly);
10319 tb.DefineField ("privateStatic" + suffix,
10320 typeof (string), FieldAttributes.Private |
10321 FieldAttributes.Static);
10322 tb.DefineField ("familyStatic" + suffix,
10323 typeof (string), FieldAttributes.Family |
10324 FieldAttributes.Static);
10325 tb.DefineField ("famANDAssemStatic" + suffix,
10326 typeof (string), FieldAttributes.FamANDAssem |
10327 FieldAttributes.Static);
10328 tb.DefineField ("famORAssemStatic" + suffix,
10329 typeof (string), FieldAttributes.FamORAssem |
10330 FieldAttributes.Static);
10331 tb.DefineField ("publicStatic" + suffix,
10332 typeof (string), FieldAttributes.Public |
10333 FieldAttributes.Static);
10334 tb.DefineField ("assemblyStatic" + suffix,
10335 typeof (string), FieldAttributes.Assembly |
10336 FieldAttributes.Static);
10339 // instance properties
10342 pb = tb.DefineProperty ("PrivateInstance" + suffix,
10343 PropertyAttributes.None, typeof (string),
10345 mb = tb.DefineMethod ("get_PrivateInstance" + suffix,
10346 MethodAttributes.Private, typeof (string),
10348 ilgen = mb.GetILGenerator ();
10349 ilgen.Emit (OpCodes.Ldnull);
10350 ilgen.Emit (OpCodes.Ret);
10351 pb.SetGetMethod (mb);
10353 pb = tb.DefineProperty ("FamilyInstance" + suffix,
10354 PropertyAttributes.None, typeof (string),
10356 mb = tb.DefineMethod ("get_FamilyInstance" + suffix,
10357 MethodAttributes.Family, typeof (string),
10359 ilgen = mb.GetILGenerator ();
10360 ilgen.Emit (OpCodes.Ldnull);
10361 ilgen.Emit (OpCodes.Ret);
10362 pb.SetGetMethod (mb);
10364 pb = tb.DefineProperty ("FamANDAssemInstance" + suffix,
10365 PropertyAttributes.None, typeof (string),
10367 mb = tb.DefineMethod ("get_FamANDAssemInstance" + suffix,
10368 MethodAttributes.FamANDAssem, typeof (string),
10370 ilgen = mb.GetILGenerator ();
10371 ilgen.Emit (OpCodes.Ldnull);
10372 ilgen.Emit (OpCodes.Ret);
10373 pb.SetGetMethod (mb);
10375 pb = tb.DefineProperty ("FamORAssemInstance" + suffix,
10376 PropertyAttributes.None, typeof (string),
10378 mb = tb.DefineMethod ("get_FamORAssemInstance" + suffix,
10379 MethodAttributes.FamORAssem, typeof (string),
10381 ilgen = mb.GetILGenerator ();
10382 ilgen.Emit (OpCodes.Ldnull);
10383 ilgen.Emit (OpCodes.Ret);
10384 pb.SetGetMethod (mb);
10386 pb = tb.DefineProperty ("PublicInstance" + suffix,
10387 PropertyAttributes.None, typeof (string),
10389 mb = tb.DefineMethod ("get_PublicInstance" + suffix,
10390 MethodAttributes.Public, typeof (string),
10392 ilgen = mb.GetILGenerator ();
10393 ilgen.Emit (OpCodes.Ldnull);
10394 ilgen.Emit (OpCodes.Ret);
10395 pb.SetGetMethod (mb);
10397 pb = tb.DefineProperty ("AssemblyInstance" + suffix,
10398 PropertyAttributes.None, typeof (string),
10400 mb = tb.DefineMethod ("get_AssemblyInstance" + suffix,
10401 MethodAttributes.Assembly, typeof (string),
10403 ilgen = mb.GetILGenerator ();
10404 ilgen.Emit (OpCodes.Ldnull);
10405 ilgen.Emit (OpCodes.Ret);
10406 pb.SetGetMethod (mb);
10409 // static properties
10412 pb = tb.DefineProperty ("PrivateStatic" + suffix,
10413 PropertyAttributes.None, typeof (string),
10415 mb = tb.DefineMethod ("get_PrivateStatic" + suffix,
10416 MethodAttributes.Private | MethodAttributes.Static,
10417 typeof (string), Type.EmptyTypes);
10418 ilgen = mb.GetILGenerator ();
10419 ilgen.Emit (OpCodes.Ldnull);
10420 ilgen.Emit (OpCodes.Ret);
10421 pb.SetGetMethod (mb);
10423 pb = tb.DefineProperty ("FamilyStatic" + suffix,
10424 PropertyAttributes.None, typeof (string),
10426 mb = tb.DefineMethod ("get_FamilyStatic" + suffix,
10427 MethodAttributes.Family | MethodAttributes.Static,
10428 typeof (string), Type.EmptyTypes);
10429 ilgen = mb.GetILGenerator ();
10430 ilgen.Emit (OpCodes.Ldnull);
10431 ilgen.Emit (OpCodes.Ret);
10432 pb.SetGetMethod (mb);
10434 pb = tb.DefineProperty ("FamANDAssemStatic" + suffix,
10435 PropertyAttributes.None, typeof (string),
10437 mb = tb.DefineMethod ("get_FamANDAssemStatic" + suffix,
10438 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10439 typeof (string), Type.EmptyTypes);
10440 ilgen = mb.GetILGenerator ();
10441 ilgen.Emit (OpCodes.Ldnull);
10442 ilgen.Emit (OpCodes.Ret);
10443 pb.SetGetMethod (mb);
10445 pb = tb.DefineProperty ("FamORAssemStatic" + suffix,
10446 PropertyAttributes.None, typeof (string),
10448 mb = tb.DefineMethod ("get_FamORAssemStatic" + suffix,
10449 MethodAttributes.FamORAssem | MethodAttributes.Static,
10450 typeof (string), Type.EmptyTypes);
10451 ilgen = mb.GetILGenerator ();
10452 ilgen.Emit (OpCodes.Ldnull);
10453 ilgen.Emit (OpCodes.Ret);
10454 pb.SetGetMethod (mb);
10456 pb = tb.DefineProperty ("PublicStatic" + suffix,
10457 PropertyAttributes.None, typeof (string),
10459 mb = tb.DefineMethod ("get_PublicStatic" + suffix,
10460 MethodAttributes.Public | MethodAttributes.Static,
10461 typeof (string), Type.EmptyTypes);
10462 ilgen = mb.GetILGenerator ();
10463 ilgen.Emit (OpCodes.Ldnull);
10464 ilgen.Emit (OpCodes.Ret);
10465 pb.SetGetMethod (mb);
10467 pb = tb.DefineProperty ("AssemblyStatic" + suffix,
10468 PropertyAttributes.None, typeof (string),
10470 mb = tb.DefineMethod ("get_AssemblyStatic" + suffix,
10471 MethodAttributes.Assembly | MethodAttributes.Static,
10472 typeof (string), Type.EmptyTypes);
10473 ilgen = mb.GetILGenerator ();
10474 ilgen.Emit (OpCodes.Ldnull);
10475 ilgen.Emit (OpCodes.Ret);
10476 pb.SetGetMethod (mb);
10482 eb = tb.DefineEvent ("OnPrivateInstance" + suffix,
10483 EventAttributes.None, typeof (EventHandler));
10484 mb = tb.DefineMethod ("add_OnPrivateInstance" + suffix,
10485 MethodAttributes.Private, typeof (void),
10487 mb.GetILGenerator ().Emit (OpCodes.Ret);
10488 eb.SetAddOnMethod (mb);
10490 eb = tb.DefineEvent ("OnFamilyInstance" + suffix,
10491 EventAttributes.None, typeof (EventHandler));
10492 mb = tb.DefineMethod ("add_OnFamilyInstance" + suffix,
10493 MethodAttributes.Family, typeof (void),
10495 mb.GetILGenerator ().Emit (OpCodes.Ret);
10496 eb.SetAddOnMethod (mb);
10498 eb = tb.DefineEvent ("OnFamANDAssemInstance" + suffix,
10499 EventAttributes.None, typeof (EventHandler));
10500 mb = tb.DefineMethod ("add_OnFamANDAssemInstance" + suffix,
10501 MethodAttributes.FamANDAssem, typeof (void),
10503 mb.GetILGenerator ().Emit (OpCodes.Ret);
10504 eb.SetAddOnMethod (mb);
10506 eb = tb.DefineEvent ("OnFamORAssemInstance" + suffix,
10507 EventAttributes.None, typeof (EventHandler));
10508 mb = tb.DefineMethod ("add_OnFamORAssemInstance" + suffix,
10509 MethodAttributes.FamORAssem, typeof (void),
10511 mb.GetILGenerator ().Emit (OpCodes.Ret);
10512 eb.SetAddOnMethod (mb);
10514 eb = tb.DefineEvent ("OnPublicInstance" + suffix,
10515 EventAttributes.None, typeof (EventHandler));
10516 mb = tb.DefineMethod ("add_OnPublicInstance" + suffix,
10517 MethodAttributes.Public, typeof (void),
10519 mb.GetILGenerator ().Emit (OpCodes.Ret);
10520 eb.SetAddOnMethod (mb);
10522 eb = tb.DefineEvent ("OnAssemblyInstance" + suffix,
10523 EventAttributes.None, typeof (EventHandler));
10524 mb = tb.DefineMethod ("add_OnAssemblyInstance" + suffix,
10525 MethodAttributes.Family, typeof (void),
10527 mb.GetILGenerator ().Emit (OpCodes.Ret);
10528 eb.SetAddOnMethod (mb);
10534 eb = tb.DefineEvent ("OnPrivateStatic" + suffix,
10535 EventAttributes.None, typeof (EventHandler));
10536 mb = tb.DefineMethod ("add_OnPrivateStatic" + suffix,
10537 MethodAttributes.Private | MethodAttributes.Static,
10538 typeof (void), Type.EmptyTypes);
10539 mb.GetILGenerator ().Emit (OpCodes.Ret);
10540 eb.SetAddOnMethod (mb);
10542 eb = tb.DefineEvent ("OnFamilyStatic" + suffix,
10543 EventAttributes.None, typeof (EventHandler));
10544 mb = tb.DefineMethod ("add_OnFamilyStatic" + suffix,
10545 MethodAttributes.Family | MethodAttributes.Static,
10546 typeof (void), Type.EmptyTypes);
10547 mb.GetILGenerator ().Emit (OpCodes.Ret);
10548 eb.SetAddOnMethod (mb);
10550 eb = tb.DefineEvent ("OnFamANDAssemStatic" + suffix,
10551 EventAttributes.None, typeof (EventHandler));
10552 mb = tb.DefineMethod ("add_OnFamANDAssemStatic" + suffix,
10553 MethodAttributes.FamANDAssem | MethodAttributes.Static,
10554 typeof (void), Type.EmptyTypes);
10555 mb.GetILGenerator ().Emit (OpCodes.Ret);
10556 eb.SetAddOnMethod (mb);
10558 eb = tb.DefineEvent ("OnFamORAssemStatic" + suffix,
10559 EventAttributes.None, typeof (EventHandler));
10560 mb = tb.DefineMethod ("add_OnFamORAssemStatic" + suffix,
10561 MethodAttributes.FamORAssem | MethodAttributes.Static,
10562 typeof (void), Type.EmptyTypes);
10563 mb.GetILGenerator ().Emit (OpCodes.Ret);
10564 eb.SetAddOnMethod (mb);
10566 eb = tb.DefineEvent ("OnPublicStatic" + suffix,
10567 EventAttributes.None, typeof (EventHandler));
10568 mb = tb.DefineMethod ("add_OnPublicStatic" + suffix,
10569 MethodAttributes.Public | MethodAttributes.Static,
10570 typeof (void), Type.EmptyTypes);
10571 mb.GetILGenerator ().Emit (OpCodes.Ret);
10572 eb.SetAddOnMethod (mb);
10574 eb = tb.DefineEvent ("OnAssemblyStatic" + suffix,
10575 EventAttributes.None, typeof (EventHandler));
10576 mb = tb.DefineMethod ("add_OnAssemblyStatic" + suffix,
10577 MethodAttributes.Family | MethodAttributes.Static,
10578 typeof (void), Type.EmptyTypes);
10579 mb.GetILGenerator ().Emit (OpCodes.Ret);
10580 eb.SetAddOnMethod (mb);
10584 static TypeBuilder Resolve1_Tb;
10585 static bool Resolve1_Called;
10587 public class Lookup<T>
10589 public static Type t = typeof(T);
10592 Assembly Resolve1 (object sender, ResolveEventArgs args) {
10593 Resolve1_Called = true;
10594 Resolve1_Tb.CreateType ();
10595 return Resolve1_Tb.Assembly;
10599 public void TypeResolveGenericInstances () {
10600 // Test that TypeResolve is called for generic instances (#483852)
10601 TypeBuilder tb1 = null;
10603 AppDomain.CurrentDomain.TypeResolve += Resolve1;
10605 tb1 = module.DefineType("Foo");
10607 FieldInfo field = TypeBuilder.GetField(typeof(Lookup<>).MakeGenericType(tb1), typeof(Lookup<>).GetField("t"));
10608 TypeBuilder tb2 = module.DefineType("Bar");
10609 ConstructorBuilder cb = tb2.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
10610 ILGenerator ilgen = cb.GetILGenerator();
10611 ilgen.Emit(OpCodes.Ldsfld, field);
10612 ilgen.Emit(OpCodes.Pop);
10613 ilgen.Emit(OpCodes.Ret);
10614 Activator.CreateInstance(tb2.CreateType());
10616 Assert.IsTrue (Resolve1_Called);
10621 public void CreateConcreteTypeWithAbstractMethod ()
10623 TypeBuilder tb = module.DefineType (genTypeName ());
10624 tb.DefineMethod("method", MethodAttributes.Abstract | MethodAttributes.Public);
10627 Assert.Fail ("#1");
10628 } catch (InvalidOperationException) {}
10633 public void DeclaringMethodReturnsNull ()
10635 TypeBuilder tb = module.DefineType (genTypeName ());
10636 Assert.IsNull (tb.DeclaringMethod, null, "#1");
10640 public void GenericParameterPositionReturns0 ()
10642 TypeBuilder tb = module.DefineType (genTypeName ());
10643 Assert.AreEqual (0, tb.GenericParameterPosition, "#1");
10647 public void GetGenericTypeDefinitionBehavior ()
10649 TypeBuilder tb = module.DefineType (genTypeName ());
10651 tb.GetGenericTypeDefinition ();
10652 Assert.Fail ("#1");
10653 } catch (InvalidOperationException) {}
10655 tb.DefineGenericParameters ("T");
10656 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#2");
10659 Assert.AreEqual (tb, tb.GetGenericTypeDefinition (), "#3");
10663 public void GetElementTypeNotSupported ()
10665 TypeBuilder tb = module.DefineType (genTypeName ());
10667 tb.GetElementType ();
10668 Assert.Fail ("#1");
10669 } catch (NotSupportedException) {}
10673 public void GenericParameterAttributesReturnsNone ()
10675 TypeBuilder tb = module.DefineType (genTypeName ());
10676 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#1");
10678 tb.DefineGenericParameters ("T");
10679 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#2");
10682 Assert.AreEqual (GenericParameterAttributes.None, tb.GenericParameterAttributes, "#3");
10686 public void GetGenericArgumentsReturnsNullForNonGenericTypeBuilder ()
10688 TypeBuilder tb = module.DefineType (genTypeName ());
10689 Assert.IsNull (tb.GetGenericArguments (), "#1");
10692 public interface IFaceA {}
10693 public interface IFaceB : IFaceA {}
10695 public void GetInterfacesAfterCreate ()
10697 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type[] { typeof (IFaceB) });
10699 Type[] ifaces = tb.GetInterfaces ();
10700 Assert.AreEqual (1, ifaces.Length, "#1");
10701 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#2");
10704 ifaces = tb.GetInterfaces ();
10705 Assert.AreEqual (2, ifaces.Length, "#3");
10706 Assert.AreEqual (typeof (IFaceB), ifaces [0], "#4");
10707 Assert.AreEqual (typeof (IFaceA), ifaces [1], "#5");
10710 public interface MB_Iface
10715 public class MB_Impl : MB_Iface
10717 public virtual int Test () { return 1; }
10720 public void MethodOverrideBodyMustBelongToTypeBuilder ()
10722 TypeBuilder tb = module.DefineType (genTypeName ());
10723 MethodInfo md = typeof (MB_Iface).GetMethod("Test");
10724 MethodInfo md2 = typeof (MB_Impl).GetMethod("Test");
10726 tb.DefineMethodOverride (md, md2);
10727 Assert.Fail ("#1");
10728 } catch (ArgumentException) {}
10732 public void GetConstructorsThrowWhenIncomplete ()
10734 TypeBuilder tb = module.DefineType (genTypeName ());
10736 tb.GetConstructors (BindingFlags.Instance);
10737 Assert.Fail ("#1");
10738 } catch (NotSupportedException) { }
10741 Assert.IsNotNull (tb.GetConstructors (BindingFlags.Instance), "#2");
10747 * Tests for passing user types to Ref.Emit. Currently these only test
10748 * whenever the runtime code can handle them without crashing, since we
10749 * don't support user types yet.
10750 * These tests are disabled for windows since the MS runtime trips on them.
10753 public void UserTypes () {
10754 TypeDelegator t = new TypeDelegator (typeof (int));
10758 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, t);
10764 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object), new Type [] { t });
10771 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10772 tb.DefineField ("Foo", t, FieldAttributes.Public);
10778 /* Custom modifiers on fields */
10779 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10780 tb.DefineField ("Foo", typeof (int), new Type [] { t }, new Type [] { t }, FieldAttributes.Public);
10787 /* This is mono only */
10788 UnmanagedMarshal m = UnmanagedMarshal.DefineCustom (t, "foo", "bar", Guid.Empty);
10789 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10790 FieldBuilder fb = tb.DefineField ("Foo", typeof (int), FieldAttributes.Public);
10799 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10800 tb.DefineProperty ("Foo", PropertyAttributes.None, t, null);
10806 /* Custom modifiers on properties */
10807 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10808 // FIXME: These seems to be ignored
10809 tb.DefineProperty ("Foo", PropertyAttributes.None, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10815 /* Method return types */
10816 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10817 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, t, null);
10818 mb.GetILGenerator ().Emit (OpCodes.Ret);
10824 /* Custom modifiers on method return types */
10825 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10826 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { t }, new Type [] { t }, null, null, null);
10827 mb.GetILGenerator ().Emit (OpCodes.Ret);
10833 /* Method parameters */
10834 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10835 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, typeof (int), new Type [] { t });
10836 mb.GetILGenerator ().Emit (OpCodes.Ret);
10842 /* Custom modifiers on method parameters */
10843 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10844 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 }});
10845 mb.GetILGenerator ().Emit (OpCodes.Ret);
10851 /* Ctor parameters */
10852 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10853 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { t });
10854 mb.GetILGenerator ().Emit (OpCodes.Ret);
10860 /* Custom modifiers on ctor parameters */
10861 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10862 ConstructorBuilder mb = tb.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type [] { typeof (int) }, new Type [][] { new Type [] { t }}, new Type[][] { new Type [] { t }});
10863 mb.GetILGenerator ().Emit (OpCodes.Ret);
10869 /* SignatureHelper arguments */
10870 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10871 sighelper.AddArgument (t, false);
10872 byte[] arr = sighelper.GetSignature ();
10877 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10878 sighelper.AddArgument (t, false);
10879 byte[] arr = sighelper.GetSignature ();
10884 /* Custom modifiers on SignatureHelper arguments */
10885 SignatureHelper sighelper = SignatureHelper.GetFieldSigHelper (module);
10886 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10887 byte[] arr = sighelper.GetSignature ();
10892 /* Custom modifiers on SignatureHelper arguments */
10893 SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
10894 sighelper.AddArgument (typeof (int), new Type [] { t }, new Type [] { t });
10895 byte[] arr = sighelper.GetSignature ();
10899 /* Arguments to ILGenerator methods */
10902 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10903 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10904 ILGenerator ig = mb.GetILGenerator ();
10905 ig.Emit (OpCodes.Ldnull);
10906 ig.Emit (OpCodes.Castclass, t);
10907 ig.Emit (OpCodes.Pop);
10908 ig.Emit (OpCodes.Ret);
10914 /* DeclareLocal () */
10915 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10916 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10917 ILGenerator ig = mb.GetILGenerator ();
10918 ig.DeclareLocal (t);
10919 ig.Emit (OpCodes.Ret);
10925 /* BeginExceptionCatchBlock () */
10926 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10927 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10928 ILGenerator ig = mb.GetILGenerator ();
10929 ig.BeginExceptionBlock ();
10930 ig.BeginCatchBlock (t);
10931 ig.Emit (OpCodes.Ret);
10938 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10939 MethodBuilder mb = tb.DefineMethod ("foo", MethodAttributes.Public, CallingConventions.Standard, typeof (int), new Type [] { });
10940 ILGenerator ig = mb.GetILGenerator ();
10941 ig.EmitCalli (OpCodes.Call, CallingConventions.Standard, typeof (void), new Type [] { t }, null);
10942 ig.Emit (OpCodes.Ret);