2 // TypeBuilderTest.cs - NUnit Test Cases for the TypeBuilder class
4 // Zoltan Varga (vargaz@freemail.hu)
6 // (C) Ximian, Inc. http://www.ximian.com
9 // - implement a mechnanism for easier testing of null argument exceptions
10 // - with overloaded methods like DefineNestedType (), check the defaults
11 // on the shorter versions.
12 // - ToString on enums with the flags attribute set should print all
13 // values which match, e.g. 0 == AutoLayou,AnsiClass,NotPublic
17 using System
.Collections
;
18 using System
.Threading
;
19 using System
.Reflection
;
20 using System
.Reflection
.Emit
;
22 using System
.Security
;
23 using System
.Security
.Permissions
;
24 using System
.Runtime
.InteropServices
;
25 using NUnit
.Framework
;
26 using System
.Runtime
.CompilerServices
;
27 using System
.Collections
.Generic
;
29 namespace MonoTests
.System
.Reflection
.Emit
31 public interface EmptyInterface
35 public interface OneMethodInterface
40 public class SimpleTestAttribute
: Attribute
43 public class EmptyIfaceImpl
: EmptyInterface
48 public static T field
= default(T
);
52 public class TypeBuilderTest
54 public interface AnInterface
62 public interface Bar
: Foo
66 public interface Baz
: Bar
70 public interface IMoveable
74 public interface IThrowable
: IMoveable
78 public interface ILiquid
82 public interface IWater
: ILiquid
90 public interface IDestroyable
94 public class Tuple
<A
,B
> {
99 private AssemblyBuilder assembly
;
101 private ModuleBuilder module
;
103 string tempDir
= Path
.Combine (Path
.GetTempPath (), typeof (TypeBuilderTest
).FullName
);
105 static string ASSEMBLY_NAME
= "MonoTests.System.Reflection.Emit.TypeBuilderTest";
108 protected void SetUp ()
110 Random AutoRand
= new Random ();
111 string basePath
= tempDir
;
112 while (Directory
.Exists (tempDir
))
113 tempDir
= Path
.Combine (basePath
, AutoRand
.Next ().ToString ());
114 Directory
.CreateDirectory (tempDir
);
116 AssemblyName assemblyName
= new AssemblyName ();
117 assemblyName
.Name
= ASSEMBLY_NAME
;
120 Thread
.GetDomain ().DefineDynamicAssembly (
121 assemblyName
, AssemblyBuilderAccess
.RunAndSave
, tempDir
);
123 module
= assembly
.DefineDynamicModule (ASSEMBLY_NAME
, ASSEMBLY_NAME
+ ".dll");
127 protected void TearDown ()
130 Directory
.Delete (tempDir
, true);
131 } catch (DirectoryNotFoundException
) {
132 } catch (IOException
) {
133 // Can happen on Windows if assemblies from this dir are still used
138 static int typeIndexer
= 0;
140 // Return a unique type name
141 private string genTypeName ()
143 return "t" + (typeIndexer
++);
146 private string nullName ()
148 return String
.Format ("{0}", (char) 0);
152 public void TestAssembly ()
154 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
155 Assert
.AreEqual (assembly
, tb
.Assembly
);
159 public void TestAssemblyQualifiedName ()
161 TypeBuilder tb
= module
.DefineType ("A.B.C.D", TypeAttributes
.Public
);
162 Assert
.AreEqual ("A.B.C.D, " + assembly
.GetName ().FullName
,
163 tb
.AssemblyQualifiedName
);
167 public void TestAttributes ()
169 TypeAttributes attrs
= TypeAttributes
.Public
| TypeAttributes
.BeforeFieldInit
;
170 TypeBuilder tb
= module
.DefineType (genTypeName (), attrs
);
171 Assert
.AreEqual (attrs
, tb
.Attributes
);
175 public void TestBaseTypeClass ()
177 TypeAttributes attrs
= TypeAttributes
.Public
;
178 TypeBuilder tb
= module
.DefineType (genTypeName (), attrs
);
179 Assert
.AreEqual (typeof (object), tb
.BaseType
, "#1");
181 TypeBuilder tb2
= module
.DefineType (genTypeName (), attrs
, tb
);
182 Assert
.AreEqual (tb
, tb2
.BaseType
, "#2");
186 public void TestBaseTypeInterface ()
188 TypeBuilder tb3
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
189 Assert
.IsNull (tb3
.BaseType
);
193 public void TestDeclaringType ()
195 TypeAttributes attrs
= 0;
196 TypeBuilder tb
= module
.DefineType (genTypeName (), attrs
);
197 Assert
.IsNull (tb
.DeclaringType
, "#1");
199 attrs
= TypeAttributes
.NestedPublic
;
200 TypeBuilder tb2
= tb
.DefineNestedType (genTypeName (), attrs
);
201 TypeBuilder tb3
= tb2
.DefineNestedType (genTypeName (), attrs
);
202 Assert
.AreEqual (tb3
.DeclaringType
.DeclaringType
, tb
, "#2");
206 public void TestFullName ()
208 string name
= genTypeName ();
209 TypeAttributes attrs
= 0;
210 TypeBuilder tb
= module
.DefineType (name
, attrs
);
211 Assert
.AreEqual (name
, tb
.FullName
, "#1");
213 string name2
= genTypeName ();
214 attrs
= TypeAttributes
.NestedPublic
;
215 TypeBuilder tb2
= tb
.DefineNestedType (name2
, attrs
);
217 string name3
= genTypeName ();
218 attrs
= TypeAttributes
.NestedPublic
;
219 TypeBuilder tb3
= tb2
.DefineNestedType (name3
, attrs
);
221 Assert
.AreEqual (name
+ "+" + name2
+ "+" + name3
, tb3
.FullName
, "#2");
225 public void DefineCtorUsingDefineMethod ()
227 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
| TypeAttributes
.Class
);
228 MethodBuilder mb
= tb
.DefineMethod(
229 ".ctor", MethodAttributes
.Public
| MethodAttributes
.RTSpecialName
| MethodAttributes
.SpecialName
,
231 ILGenerator ilgen
= mb
.GetILGenerator();
232 ilgen
.Emit(OpCodes
.Ldarg_0
);
233 ilgen
.Emit(OpCodes
.Call
,
234 typeof(object).GetConstructor(Type
.EmptyTypes
));
235 ilgen
.Emit(OpCodes
.Ret
);
236 Type t
= tb
.CreateType();
238 Assert
.AreEqual (1, t
.GetConstructors ().Length
);
242 public void TestGUIDIncomplete ()
244 TypeBuilder tb
= module
.DefineType (genTypeName ());
248 } catch (NotSupportedException ex
) {
249 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
250 Assert
.IsNull (ex
.InnerException
, "#3");
251 Assert
.IsNotNull (ex
.Message
, "#4");
256 [Category ("NotWorking")]
257 public void TestGUIDComplete ()
259 TypeBuilder tb
= module
.DefineType (genTypeName ());
261 Assert
.IsTrue (tb
.GUID
!= Guid
.Empty
);
265 [Category ("NotWorking")]
266 public void TestFixedGUIDComplete ()
268 TypeBuilder tb
= module
.DefineType (genTypeName ());
270 Guid guid
= Guid
.NewGuid ();
272 ConstructorInfo guidCtor
= typeof (GuidAttribute
).GetConstructor (
273 new Type
[] { typeof (string) }
);
275 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (guidCtor
,
276 new object [] { guid.ToString ("D") }
, new FieldInfo
[0], new object [0]);
278 tb
.SetCustomAttribute (caBuilder
);
280 Assert
.AreEqual (guid
, tb
.GUID
);
284 public void TestHasElementType_Incomplete ()
286 // According to the MSDN docs, this member works, but in reality, it
287 // returns a NotSupportedException
288 TypeBuilder tb
= module
.DefineType (genTypeName ());
289 Assert
.IsFalse (tb
.HasElementType
);
293 public void TestHasElementType_Complete ()
295 // According to the MSDN docs, this member works, but in reality, it
296 // returns a NotSupportedException
297 TypeBuilder tb
= module
.DefineType (genTypeName ());
299 Assert
.IsFalse (tb
.HasElementType
);
302 [Test
] // bug #324692
303 public void CreateType_Enum_NoInstanceField ()
305 TypeBuilder tb
= module
.DefineType (genTypeName (),
306 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
311 Assert
.Fail ("#1: must throw TypeLoadException");
312 } catch (TypeLoadException
) {
315 Assert
.IsTrue (tb
.IsCreated (), "#2");
318 [Test
] // bug #324692
319 public void TestCreateTypeReturnsNullOnSecondCallForBadType ()
321 TypeBuilder tb
= module
.DefineType (genTypeName (),
322 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
328 } catch (TypeLoadException ex
) {
329 Assert
.AreEqual (typeof (TypeLoadException
), ex
.GetType (), "#A2");
330 Assert
.IsNull (ex
.InnerException
, "#A3");
331 Assert
.IsNotNull (ex
.Message
, "#A4");
334 Assert
.IsTrue (tb
.IsCreated (), "#B1");
335 Assert
.IsNull (tb
.CreateType (), "#B2");
336 Assert
.IsTrue (tb
.IsCreated (), "#B3");
340 public void TestEnumWithEmptyInterfaceBuildsOk ()
342 TypeBuilder tb
= module
.DefineType (genTypeName (),
343 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
345 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
346 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
348 tb
.AddInterfaceImplementation (typeof (EmptyInterface
));
352 } catch (TypeLoadException
) {
353 Assert
.Fail ("#1: must build enum type ok");
356 Assert
.IsTrue (tb
.IsCreated (), "#2");
360 [Category ("NotWorking")]
361 public void TestEnumWithNonEmptyInterfaceBuildsFails ()
363 TypeBuilder tb
= module
.DefineType (genTypeName (),
364 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
366 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
367 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
369 tb
.AddInterfaceImplementation (typeof (OneMethodInterface
));
373 Assert
.Fail ("#1: type doesn't have all interface methods");
374 } catch (TypeLoadException
) {
377 Assert
.IsTrue (tb
.IsCreated (), "#2");
381 [Category ("NotWorking")]
382 public void TestTypeDontImplementInterfaceMethodBuildsFails ()
384 TypeBuilder tb
= module
.DefineType (genTypeName (),
385 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
388 tb
.AddInterfaceImplementation (typeof (OneMethodInterface
));
392 Assert
.Fail ("#1: type doesn't have all interface methods");
393 } catch (TypeLoadException
) {
396 Assert
.IsTrue (tb
.IsCreated (), "#2");
400 public void TestEnumWithSequentialLayoutBuildsFails ()
402 TypeBuilder tb
= module
.DefineType (genTypeName (),
403 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
|
404 TypeAttributes
.SequentialLayout
, typeof (Enum
));
405 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
406 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
410 Assert
.Fail ("#1: type doesn't have all interface methods");
411 } catch (TypeLoadException
) {
414 Assert
.IsTrue (tb
.IsCreated (), "#2");
418 public void TestEnumWithExplicitLayoutBuildsFails ()
420 TypeBuilder tb
= module
.DefineType (genTypeName (),
421 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
|
422 TypeAttributes
.ExplicitLayout
, typeof (Enum
));
423 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
424 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
428 Assert
.Fail ("#1: type doesn't have all interface methods");
429 } catch (TypeLoadException
) {
432 Assert
.IsTrue (tb
.IsCreated (), "#2");
436 public void TestEnumWithMethodsBuildFails ()
438 TypeBuilder tb
= module
.DefineType ("FooEnum7",
439 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
441 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
442 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
444 MethodBuilder methodBuilder
= tb
.DefineMethod("mmm",
445 MethodAttributes
.Public
| MethodAttributes
.Virtual
,
449 methodBuilder
.GetILGenerator().Emit(OpCodes
.Ret
);
452 Assert
.Fail ("#1: enum has method");
453 } catch (TypeLoadException
) {
456 Assert
.IsTrue (tb
.IsCreated (), "#2");
460 public void TestEnumWithBadTypeValueFieldBuildFails ()
468 foreach (Type type
in badTypes
) {
469 TypeBuilder tb
= module
.DefineType (genTypeName (),
470 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
472 tb
.DefineField ("value__", type
, FieldAttributes
.SpecialName
|
473 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
477 Assert
.Fail ("#1: enum using bad type: " + type
);
478 } catch (TypeLoadException
) {
481 Assert
.IsTrue (tb
.IsCreated (), "#2");
486 public void TestEnumWithGoodTypeValueFieldBuildOk ()
489 typeof (byte),typeof (sbyte),typeof (bool),
490 typeof (ushort),typeof (short),typeof (char),
491 typeof (uint),typeof (int),
492 typeof (ulong),typeof (long),
493 typeof (UIntPtr
),typeof (IntPtr
),
496 foreach (Type type
in goodTypes
) {
497 TypeBuilder tb
= module
.DefineType (genTypeName (),
498 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
500 tb
.DefineField ("value__", type
, FieldAttributes
.SpecialName
|
501 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
505 } catch (TypeLoadException
) {
506 Assert
.Fail ("#1: enum using good type: " + type
);
512 public void TestEnumWithMultipleValueFieldsBuildFals ()
514 TypeBuilder tb
= module
.DefineType (genTypeName (),
515 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
517 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
518 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
519 tb
.DefineField ("value2__", typeof (int), FieldAttributes
.SpecialName
|
520 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
524 Assert
.Fail ("#1: invalid enum type");
525 } catch (TypeLoadException
) {
528 Assert
.IsTrue (tb
.IsCreated (), "#2");
532 [Category ("NotWorking")]
533 public void TestEnumWithEmptyInterfaceCanBeCasted ()
535 TypeBuilder tb
= module
.DefineType (genTypeName (),
536 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
538 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
539 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
540 tb
.AddInterfaceImplementation (typeof (EmptyInterface
));
544 } catch (TypeLoadException
) {
545 Assert
.Fail ("#1: must build enum type ok");
549 EmptyInterface obj
= (EmptyInterface
) Activator
.CreateInstance (tb
);
550 Assert
.IsNotNull (obj
, "#2");
551 } catch (TypeLoadException
) {
552 Assert
.Fail ("#3: must cast enum to interface");
557 public void TestEnumWithValueFieldBuildOk ()
559 TypeBuilder tb
= module
.DefineType (genTypeName (),
560 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
562 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
563 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
567 } catch (TypeLoadException
) {
568 Assert
.Fail ("#1: must build enum type ok");
573 public void TestEnumWithLateUnderlyingField ()
575 TypeBuilder enumToCreate
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (Enum
));
576 enumToCreate
.DefineField ("value__", typeof (Int32
),
577 FieldAttributes
.Public
| FieldAttributes
.SpecialName
| FieldAttributes
.RTSpecialName
);
579 TypeBuilder enumToCreate2
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (Enum
));
581 TypeBuilder ivTypeBld
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
583 ConstructorBuilder ivCtor
= ivTypeBld
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
585 ILGenerator ctorIL
= ivCtor
.GetILGenerator ();
587 ctorIL
.Emit (OpCodes
.Ldtoken
, typeof (Object
));
588 ctorIL
.Emit (OpCodes
.Pop
);
589 ctorIL
.Emit (OpCodes
.Ldtoken
, enumToCreate
);
590 ctorIL
.Emit (OpCodes
.Pop
);
591 ctorIL
.Emit (OpCodes
.Ldtoken
, enumToCreate2
);
592 ctorIL
.Emit (OpCodes
.Pop
);
593 ctorIL
.Emit (OpCodes
.Ret
);
595 var ivType
= ivTypeBld
.CreateType ();
597 enumToCreate2
.DefineField ("value__", typeof (Int32
), FieldAttributes
.Public
| FieldAttributes
.SpecialName
| FieldAttributes
.RTSpecialName
);
599 FieldBuilder fb
= enumToCreate2
.DefineField ("A", enumToCreate
, FieldAttributes
.Public
| FieldAttributes
.Static
| FieldAttributes
.Literal
);
602 enumToCreate
.CreateType ();
603 enumToCreate2
.CreateType ();
607 public void TestIsAbstract ()
609 TypeBuilder tb
= module
.DefineType (genTypeName ());
610 Assert
.IsFalse (tb
.IsAbstract
, "#1");
612 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Abstract
);
613 Assert
.IsTrue (tb2
.IsAbstract
, "#2");
617 public void TestIsAnsiClass ()
619 TypeBuilder tb
= module
.DefineType (genTypeName ());
620 Assert
.IsTrue (tb
.IsAnsiClass
, "#1");
622 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.UnicodeClass
);
623 Assert
.IsFalse (tb2
.IsAnsiClass
, "#2");
627 public void TestIsArray ()
629 // How can a TypeBuilder be an array ?
630 string name
= genTypeName ();
631 TypeBuilder tb
= module
.DefineType (name
);
632 Assert
.IsFalse (tb
.IsArray
);
636 public void TestIsAutoClass ()
638 TypeBuilder tb
= module
.DefineType (genTypeName ());
639 Assert
.IsFalse (tb
.IsAutoClass
, "#1");
641 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.AutoClass
);
642 Assert
.IsTrue (tb2
.IsAutoClass
, "#2");
646 public void TestIsAutoLayout ()
648 TypeBuilder tb
= module
.DefineType (genTypeName ());
649 Assert
.IsTrue (tb
.IsAutoLayout
, "#1");
651 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.ExplicitLayout
);
652 Assert
.IsFalse (tb2
.IsAutoLayout
, "#2");
656 public void TestIsByRef ()
658 // How can a TypeBuilder be ByRef ?
659 TypeBuilder tb
= module
.DefineType (genTypeName ());
660 Assert
.IsFalse (tb
.IsByRef
);
664 public void TestIsClass ()
666 TypeBuilder tb
= module
.DefineType (genTypeName ());
667 Assert
.IsTrue (tb
.IsClass
, "#1");
669 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
670 Assert
.IsFalse (tb2
.IsClass
, "#2");
672 TypeBuilder tb3
= module
.DefineType (genTypeName (), 0, typeof (ValueType
));
673 Assert
.IsFalse (tb3
.IsClass
, "#3");
675 TypeBuilder tb4
= module
.DefineType (genTypeName (), 0, typeof (Enum
));
676 Assert
.IsFalse (tb4
.IsClass
, "#4");
680 public void TestIsCOMObject ()
682 TypeBuilder tb
= module
.DefineType (genTypeName ());
683 Assert
.IsFalse (tb
.IsCOMObject
, "#1");
685 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Import
);
686 Assert
.IsTrue (tb
.IsCOMObject
, "#2");
690 public void TestIsContextful ()
692 TypeBuilder tb
= module
.DefineType (genTypeName ());
693 Assert
.IsFalse (tb
.IsContextful
, "#1");
695 TypeBuilder tb2
= module
.DefineType (genTypeName (), 0, typeof (ContextBoundObject
));
696 Assert
.IsTrue (tb2
.IsContextful
, "#2");
700 public void TestIsEnum ()
702 TypeBuilder tb
= module
.DefineType (genTypeName ());
703 Assert
.IsFalse (tb
.IsEnum
, "#1");
705 TypeBuilder tb2
= module
.DefineType (genTypeName (), 0, typeof (ValueType
));
706 Assert
.IsFalse (tb2
.IsEnum
, "#2");
708 TypeBuilder tb3
= module
.DefineType (genTypeName (), 0, typeof (Enum
));
709 Assert
.IsTrue (tb3
.IsEnum
, "#3");
713 public void TestIsExplicitLayout ()
715 TypeBuilder tb
= module
.DefineType (genTypeName ());
716 Assert
.IsFalse (tb
.IsExplicitLayout
, "#1");
718 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.ExplicitLayout
);
719 Assert
.IsTrue (tb2
.IsExplicitLayout
, "#2");
723 public void TestIsImport ()
725 TypeBuilder tb
= module
.DefineType (genTypeName ());
726 Assert
.IsFalse (tb
.IsImport
, "#1");
728 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Import
);
729 Assert
.IsTrue (tb
.IsImport
, "#2");
733 public void TestIsInterface ()
735 TypeBuilder tb
= module
.DefineType (genTypeName ());
736 Assert
.IsFalse (tb
.IsInterface
, "#1");
738 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
739 Assert
.IsTrue (tb2
.IsInterface
, "#2");
741 TypeBuilder tb3
= module
.DefineType (genTypeName (), 0, typeof (ValueType
));
742 Assert
.IsFalse (tb3
.IsInterface
, "#3");
746 public void TestIsLayoutSequential ()
748 TypeBuilder tb
= module
.DefineType (genTypeName ());
749 Assert
.IsFalse (tb
.IsLayoutSequential
, "#1");
751 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.SequentialLayout
);
752 Assert
.IsTrue (tb2
.IsLayoutSequential
, "#2");
756 public void TestIsMarshalByRef ()
758 TypeBuilder tb
= module
.DefineType (genTypeName ());
759 Assert
.IsFalse (tb
.IsMarshalByRef
, "#1");
761 TypeBuilder tb2
= module
.DefineType (genTypeName (), 0, typeof (MarshalByRefObject
));
762 Assert
.IsTrue (tb2
.IsMarshalByRef
, "#2");
764 TypeBuilder tb3
= module
.DefineType (genTypeName (), 0, typeof (ContextBoundObject
));
765 Assert
.IsTrue (tb3
.IsMarshalByRef
, "#3");
768 // TODO: Visibility properties
771 public void TestIsPointer ()
773 // How can this be true?
774 TypeBuilder tb
= module
.DefineType (genTypeName ());
775 Assert
.IsFalse (tb
.IsPointer
);
779 public void TestIsPrimitive ()
781 TypeBuilder tb
= module
.DefineType ("int");
782 Assert
.IsFalse (tb
.IsPrimitive
);
786 public void IsSealed ()
788 TypeBuilder tb
= module
.DefineType (genTypeName ());
789 Assert
.IsFalse (tb
.IsSealed
, "#1");
791 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Sealed
);
792 Assert
.IsTrue (tb2
.IsSealed
, "#2");
796 public void IsSerializable ()
798 TypeBuilder tb
= module
.DefineType (genTypeName ());
799 Assert
.IsFalse (tb
.IsSerializable
, "#1");
801 ConstructorInfo
[] ctors
= typeof (SerializableAttribute
).GetConstructors (BindingFlags
.Instance
| BindingFlags
.Public
);
802 Assert
.IsTrue (ctors
.Length
> 0, "#2");
804 tb
.SetCustomAttribute (new CustomAttributeBuilder (ctors
[0], new object [0]));
805 Type createdType
= tb
.CreateType ();
807 string an
= "IsSerializableTestAssembly.dll";
809 Assert
.IsTrue (createdType
.IsSerializable
, "#3");
810 File
.Delete (Path
.Combine (tempDir
, an
));
814 public void TestIsSpecialName ()
816 TypeBuilder tb
= module
.DefineType (genTypeName ());
817 Assert
.IsFalse (tb
.IsSpecialName
, "#1");
819 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.SpecialName
);
820 Assert
.IsTrue (tb2
.IsSpecialName
, "#2");
824 public void TestIsUnicodeClass ()
826 TypeBuilder tb
= module
.DefineType (genTypeName ());
827 Assert
.IsFalse (tb
.IsUnicodeClass
, "#1");
829 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.UnicodeClass
);
830 Assert
.IsTrue (tb2
.IsUnicodeClass
, "#2");
834 public void TestIsValueType ()
836 TypeBuilder tb
= module
.DefineType (genTypeName ());
837 Assert
.IsFalse (tb
.IsValueType
, "#1");
839 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
840 Assert
.IsFalse (tb2
.IsValueType
, "#2");
842 TypeBuilder tb3
= module
.DefineType (genTypeName (), 0, typeof (ValueType
));
843 Assert
.IsTrue (tb3
.IsValueType
, "#3");
845 TypeBuilder tb4
= module
.DefineType (genTypeName (), 0, typeof (Enum
));
846 Assert
.IsTrue (tb4
.IsValueType
, "#4");
850 public void TestMemberType ()
852 TypeBuilder tb
= module
.DefineType (genTypeName ());
853 Assert
.AreEqual (MemberTypes
.TypeInfo
, tb
.MemberType
);
857 public void TestModule ()
859 TypeBuilder tb
= module
.DefineType (genTypeName ());
860 Assert
.AreEqual (module
, tb
.Module
);
864 public void TestName ()
866 TypeBuilder tb
= module
.DefineType ("A");
867 Assert
.AreEqual ("A", tb
.Name
, "#1");
869 TypeBuilder tb2
= module
.DefineType ("A.B.C.D.E");
870 Assert
.AreEqual ("E", tb2
.Name
, "#2");
872 TypeBuilder tb3
= tb2
.DefineNestedType ("A");
873 Assert
.AreEqual ("A", tb3
.Name
, "#3");
875 /* Is .E a valid name ?
876 TypeBuilder tb4 = module.DefineType (".E");
877 Assert.AreEqual ("E", tb4.Name);
882 public void TestNamespace ()
884 TypeBuilder tb
= module
.DefineType ("A");
885 Assert
.AreEqual (string.Empty
, tb
.Namespace
, "#1");
887 TypeBuilder tb2
= module
.DefineType ("A.B.C.D.E");
888 Assert
.AreEqual ("A.B.C.D", tb2
.Namespace
, "#2");
890 TypeBuilder tb3
= tb2
.DefineNestedType ("A");
891 Assert
.AreEqual (string.Empty
, tb3
.Namespace
, "#3");
893 /* Is .E a valid name ?
894 TypeBuilder tb4 = module.DefineType (".E");
895 Assert.AreEqual ("E", tb4.Name);
900 public void TestPackingSize ()
902 TypeBuilder tb
= module
.DefineType (genTypeName ());
903 Assert
.AreEqual (PackingSize
.Unspecified
, tb
.PackingSize
, "#1");
905 TypeBuilder tb2
= module
.DefineType (genTypeName (), 0, typeof (object),
906 PackingSize
.Size16
, 16);
907 Assert
.AreEqual (PackingSize
.Size16
, tb2
.PackingSize
, "#2");
911 public void TestReflectedType ()
913 // It is the same as DeclaringType, but why?
914 TypeBuilder tb
= module
.DefineType (genTypeName ());
915 Assert
.IsNull (tb
.ReflectedType
, "#1");
917 TypeBuilder tb2
= tb
.DefineNestedType (genTypeName ());
918 Assert
.AreEqual (tb
, tb2
.ReflectedType
, "#2");
922 public void SetParent_Parent_Null ()
924 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Class
,
927 Assert
.AreEqual (typeof (object), tb
.BaseType
, "#A1");
929 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
|
930 TypeAttributes
.Abstract
);
932 Assert
.IsNull (tb
.BaseType
, "#B1");
934 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
|
935 TypeAttributes
.Abstract
, typeof (ICloneable
));
936 Assert
.AreEqual (typeof (ICloneable
), tb
.BaseType
, "#C1");
938 Assert
.IsNull (tb
.BaseType
, "#C2");
940 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
,
941 typeof (IDisposable
));
945 } catch (InvalidOperationException ex
) {
946 // Interface must be declared abstract
947 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#D2");
948 Assert
.IsNull (ex
.InnerException
, "#D3");
949 Assert
.IsNotNull (ex
.Message
, "#D4");
954 public void SetParent_Parent_Interface ()
956 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Class
);
957 tb
.SetParent (typeof (ICloneable
));
958 Assert
.AreEqual (typeof (ICloneable
), tb
.BaseType
);
962 public void TestSetParentIncomplete ()
964 TypeBuilder tb
= module
.DefineType (genTypeName ());
965 tb
.SetParent (typeof (Attribute
));
966 Assert
.AreEqual (typeof (Attribute
), tb
.BaseType
, "#1");
968 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
|
969 TypeAttributes
.Abstract
);
970 tb
.SetParent (typeof (IDisposable
));
971 Assert
.AreEqual (typeof (IDisposable
), tb
.BaseType
, "#2");
973 tb
= module
.DefineType (genTypeName ());
974 tb
.SetParent (typeof (IDisposable
));
975 Assert
.AreEqual (typeof (IDisposable
), tb
.BaseType
, "#3");
977 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
|
978 TypeAttributes
.Abstract
, typeof (IDisposable
));
979 tb
.SetParent (typeof (ICloneable
));
980 Assert
.AreEqual (typeof (ICloneable
), tb
.BaseType
, "#4");
982 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
|
983 TypeAttributes
.Abstract
, typeof (IDisposable
));
984 tb
.SetParent (typeof (ICloneable
));
985 Assert
.AreEqual (typeof (ICloneable
), tb
.BaseType
, "#5");
989 public void TestSetParentComplete ()
991 TypeBuilder tb
= module
.DefineType (genTypeName ());
994 tb
.SetParent (typeof (Attribute
));
996 } catch (InvalidOperationException ex
) {
997 // Unable to change after type has been created
998 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
999 Assert
.IsNull (ex
.InnerException
, "#3");
1000 Assert
.IsNotNull (ex
.Message
, "#4");
1005 public void TestSize ()
1008 TypeBuilder tb
= module
.DefineType (genTypeName ());
1009 Assert
.AreEqual (0, tb
.Size
, "#1");
1011 Assert
.AreEqual (0, tb
.Size
, "#2");
1015 TypeBuilder tb
= module
.DefineType (genTypeName (), 0, typeof (object),
1016 PackingSize
.Size16
, 32);
1017 Assert
.AreEqual (32, tb
.Size
, "#3");
1022 public void TestTypeHandle ()
1024 TypeBuilder tb
= module
.DefineType (genTypeName ());
1026 RuntimeTypeHandle handle
= tb
.TypeHandle
;
1027 Assert
.Fail ("#1:" + handle
);
1028 } catch (NotSupportedException ex
) {
1029 // The invoked member is not supported in a
1031 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
1032 Assert
.IsNull (ex
.InnerException
, "#3");
1033 Assert
.IsNotNull (ex
.Message
, "#4");
1038 public void TestTypeInitializerIncomplete ()
1040 TypeBuilder tb
= module
.DefineType (genTypeName ());
1042 ConstructorInfo cb
= tb
.TypeInitializer
;
1043 Assert
.Fail ("#1:" + (cb
!= null));
1044 } catch (NotSupportedException ex
) {
1045 // The invoked member is not supported in a
1047 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
1048 Assert
.IsNull (ex
.InnerException
, "#3");
1049 Assert
.IsNotNull (ex
.Message
, "#4");
1054 public void TestTypeInitializerComplete ()
1056 TypeBuilder tb
= module
.DefineType (genTypeName ());
1058 ConstructorInfo cb
= tb
.TypeInitializer
;
1062 public void TestTypeToken ()
1064 TypeBuilder tb
= module
.DefineType (genTypeName ());
1065 TypeToken token
= tb
.TypeToken
;
1069 public void UnderlyingSystemType ()
1074 tb
= module
.DefineType (genTypeName ());
1075 Assert
.AreSame (tb
, tb
.UnderlyingSystemType
, "#A1");
1076 emitted_type
= tb
.CreateType ();
1077 Assert
.AreSame (emitted_type
, tb
.UnderlyingSystemType
, "#A2");
1079 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
1080 Assert
.AreSame (tb
, tb
.UnderlyingSystemType
, "#B1");
1081 emitted_type
= tb
.CreateType ();
1082 Assert
.AreSame (emitted_type
, tb
.UnderlyingSystemType
, "#B2");
1084 tb
= module
.DefineType (genTypeName (), 0, typeof (ValueType
));
1085 Assert
.AreSame (tb
, tb
.UnderlyingSystemType
, "#C1");
1086 emitted_type
= tb
.CreateType ();
1087 Assert
.AreSame (emitted_type
, tb
.UnderlyingSystemType
, "#C2");
1089 tb
= module
.DefineType (genTypeName (), 0, typeof (Enum
));
1091 Type t
= tb
.UnderlyingSystemType
;
1092 Assert
.Fail ("#D1:" + t
);
1093 } catch (InvalidOperationException ex
) {
1094 // Underlying type information on enumeration
1096 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#D2");
1097 Assert
.IsNull (ex
.InnerException
, "#D3");
1098 Assert
.IsNotNull (ex
.Message
, "#D4");
1100 tb
.DefineField ("val", typeof (int), FieldAttributes
.Private
);
1101 Assert
.AreEqual (typeof (int), tb
.UnderlyingSystemType
, "#D5");
1102 emitted_type
= tb
.CreateType ();
1103 Assert
.AreSame (emitted_type
, tb
.UnderlyingSystemType
, "#D6");
1105 tb
= module
.DefineType (genTypeName (), 0, typeof (Enum
));
1106 tb
.DefineField ("val", typeof (int), FieldAttributes
.Static
);
1108 Type t
= tb
.UnderlyingSystemType
;
1109 Assert
.Fail ("#E1:" + t
);
1110 } catch (InvalidOperationException ex
) {
1111 // Underlying type information on enumeration
1113 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#E2");
1114 Assert
.IsNull (ex
.InnerException
, "#E3");
1115 Assert
.IsNotNull (ex
.Message
, "#E4");
1117 tb
.DefineField ("foo", typeof (long), FieldAttributes
.Private
);
1118 Assert
.AreEqual (typeof (long), tb
.UnderlyingSystemType
, "#E5");
1119 tb
.DefineField ("bar", typeof (short), FieldAttributes
.Private
);
1120 Assert
.AreEqual (typeof (long), tb
.UnderlyingSystemType
, "#E6");
1121 tb
.DefineField ("boo", typeof (int), FieldAttributes
.Static
);
1122 Assert
.AreEqual (typeof (long), tb
.UnderlyingSystemType
, "#E7");
1126 public void AddInterfaceImplementation_InterfaceType_Null ()
1128 TypeBuilder tb
= module
.DefineType (genTypeName ());
1130 tb
.AddInterfaceImplementation (null);
1132 } catch (ArgumentNullException ex
) {
1133 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
1134 Assert
.IsNull (ex
.InnerException
, "#3");
1135 Assert
.IsNotNull (ex
.Message
, "#4");
1136 Assert
.AreEqual ("interfaceType", ex
.ParamName
, "#5");
1141 public void TestAddInterfaceImplementation ()
1143 TypeBuilder tb
= module
.DefineType (genTypeName ());
1144 tb
.AddInterfaceImplementation (typeof (AnInterface
));
1145 tb
.AddInterfaceImplementation (typeof (AnInterface
));
1147 Type t
= tb
.CreateType ();
1148 Assert
.AreEqual (1, tb
.GetInterfaces ().Length
, "#2");
1150 // Can not be called on a created type
1152 tb
.AddInterfaceImplementation (typeof (AnInterface
));
1154 } catch (InvalidOperationException
) {
1159 public void TestCreateType_Created ()
1161 TypeBuilder tb
= module
.DefineType (genTypeName ());
1162 Assert
.IsFalse (tb
.IsCreated (), "#A1");
1164 Type emittedType1
= tb
.CreateType ();
1165 Assert
.IsTrue (tb
.IsCreated (), "#A2");
1166 Assert
.IsNotNull (emittedType1
, "#A3");
1168 Type emittedType2
= tb
.CreateType ();
1169 Assert
.IsNotNull (emittedType2
, "#B1");
1170 Assert
.IsTrue (tb
.IsCreated (), "#B2");
1171 Assert
.AreSame (emittedType1
, emittedType2
, "#B3");
1175 public void TestDefineConstructor ()
1177 TypeBuilder tb
= module
.DefineType (genTypeName ());
1179 ConstructorBuilder cb
= tb
.DefineConstructor (0, 0, null);
1180 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
1183 // Can not be called on a created type
1185 tb
.DefineConstructor (0, 0, null);
1187 } catch (InvalidOperationException ex
) {
1188 // Unable to change after type has been created
1189 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
1190 Assert
.IsNull (ex
.InnerException
, "#3");
1191 Assert
.IsNotNull (ex
.Message
, "#4");
1196 public void DefineDefaultConstructor ()
1198 TypeBuilder tb
= module
.DefineType (genTypeName ());
1199 tb
.DefineDefaultConstructor (0);
1202 // Can not be called on a created type, altough the MSDN docs does not mention this
1204 tb
.DefineDefaultConstructor (0);
1206 } catch (InvalidOperationException ex
) {
1207 // Unable to change after type has been created
1208 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
1209 Assert
.IsNull (ex
.InnerException
, "#3");
1210 Assert
.IsNotNull (ex
.Message
, "#4");
1215 public void DefineDefaultConstructor_Parent_DefaultCtorInaccessible ()
1219 tb
= module
.DefineType (genTypeName ());
1220 tb
.DefineDefaultConstructor (MethodAttributes
.Private
);
1221 Type parent_type
= tb
.CreateType ();
1223 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Class
,
1225 tb
.DefineDefaultConstructor (MethodAttributes
.Public
);
1226 Type emitted_type
= tb
.CreateType ();
1228 Activator
.CreateInstance (emitted_type
);
1231 /* MOBILE special case MethodAccessException on reflection invokes and don't wrap them. */
1233 } catch (MethodAccessException mae
) {
1234 Assert
.IsNull (mae
.InnerException
, "#2");
1235 Assert
.IsNotNull (mae
.Message
, "#3");
1236 Assert
.IsTrue (mae
.Message
.IndexOf (parent_type
.FullName
) != -1, "#4:" + mae
.Message
);
1237 Assert
.IsTrue (mae
.Message
.IndexOf (".ctor") != -1, "#4:" + mae
.Message
);
1240 } catch (TargetInvocationException ex
) {
1241 Assert
.AreEqual (typeof (TargetInvocationException
), ex
.GetType (), "#2");
1242 Assert
.IsNotNull (ex
.InnerException
, "#3");
1243 Assert
.IsNotNull (ex
.Message
, "#4");
1245 MethodAccessException mae
= ex
.InnerException
as MethodAccessException
;
1246 Assert
.IsNotNull (mae
, "#5");
1247 Assert
.AreEqual (typeof (MethodAccessException
), mae
.GetType (), "#6");
1248 Assert
.IsNull (mae
.InnerException
, "#7");
1249 Assert
.IsNotNull (mae
.Message
, "#8");
1250 Assert
.IsTrue (mae
.Message
.IndexOf (parent_type
.FullName
) != -1, "#9:" + mae
.Message
);
1251 Assert
.IsTrue (mae
.Message
.IndexOf (".ctor") != -1, "#10:" + mae
.Message
);
1257 public void DefineDefaultConstructor_Parent_DefaultCtorMissing ()
1261 tb
= module
.DefineType (genTypeName ());
1262 ConstructorBuilder cb
= tb
.DefineConstructor (
1263 MethodAttributes
.Public
,
1264 CallingConventions
.Standard
,
1265 new Type
[] { typeof (string) }
);
1266 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
1267 Type parent_type
= tb
.CreateType ();
1269 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Class
,
1272 tb
.DefineDefaultConstructor (MethodAttributes
.Public
);
1274 } catch (NotSupportedException ex
) {
1275 // Parent does not have a default constructor.
1276 // The default constructor must be explicitly defined
1277 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
1278 Assert
.IsNull (ex
.InnerException
, "#3");
1279 Assert
.IsNotNull (ex
.Message
, "#4");
1284 public void DefineEvent_Name_NullChar ()
1286 TypeBuilder tb
= module
.DefineType (genTypeName ());
1289 tb
.DefineEvent ("\0test", EventAttributes
.None
,
1291 Assert
.Fail ("#A1");
1292 } catch (ArgumentException ex
) {
1294 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
1295 Assert
.IsNull (ex
.InnerException
, "#A3");
1296 Assert
.IsNotNull (ex
.Message
, "#A4");
1297 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1300 EventBuilder eb
= tb
.DefineEvent ("te\0st", EventAttributes
.None
,
1302 Assert
.IsNotNull (eb
, "#B1");
1306 public void TestDefineEvent ()
1308 TypeBuilder tb
= module
.DefineType (genTypeName ());
1310 // Test invalid arguments
1312 tb
.DefineEvent (null, 0, typeof (int));
1313 Assert
.Fail ("#A1");
1314 } catch (ArgumentNullException ex
) {
1315 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
1316 Assert
.IsNull (ex
.InnerException
, "#A3");
1317 Assert
.IsNotNull (ex
.Message
, "#A4");
1318 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1322 tb
.DefineEvent ("FOO", 0, null);
1323 Assert
.Fail ("#B1");
1324 } catch (ArgumentNullException ex
) {
1325 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#B2");
1326 Assert
.IsNull (ex
.InnerException
, "#B3");
1327 Assert
.IsNotNull (ex
.Message
, "#B4");
1328 Assert
.AreEqual ("type", ex
.ParamName
, "#B5");
1332 tb
.DefineEvent (string.Empty
, 0, typeof (int));
1333 Assert
.Fail ("#C1");
1334 } catch (ArgumentException ex
) {
1335 // Empty name is not legal
1336 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
1337 Assert
.IsNull (ex
.InnerException
, "#C3");
1338 Assert
.IsNotNull (ex
.Message
, "#C4");
1339 Assert
.AreEqual ("name", ex
.ParamName
, "#C5");
1344 // Can not be called on a created type
1346 tb
.DefineEvent ("BAR", 0, typeof (int));
1347 Assert
.Fail ("#D1");
1348 } catch (InvalidOperationException ex
) {
1349 // Unable to change after type has been created
1350 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#D2");
1351 Assert
.IsNull (ex
.InnerException
, "#D3");
1352 Assert
.IsNotNull (ex
.Message
, "#D4");
1356 [Test
] // DefineField (String, Type, FieldAttributes)
1357 public void DefineField1 ()
1359 TypeBuilder tb
= module
.DefineType (genTypeName ());
1361 // Check invalid arguments
1363 tb
.DefineField (null, typeof (int), 0);
1364 Assert
.Fail ("#A1");
1365 } catch (ArgumentNullException ex
) {
1366 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
1367 Assert
.IsNull (ex
.InnerException
, "#A3");
1368 Assert
.IsNotNull (ex
.Message
, "#A4");
1369 Assert
.AreEqual ("fieldName", ex
.ParamName
, "#A5");
1373 tb
.DefineField (string.Empty
, typeof (int), 0);
1374 Assert
.Fail ("#B1");
1375 } catch (ArgumentException ex
) {
1376 // Empty name is not legal
1377 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
1378 Assert
.IsNull (ex
.InnerException
, "#B3");
1379 Assert
.IsNotNull (ex
.Message
, "#B4");
1380 Assert
.AreEqual ("fieldName", ex
.ParamName
, "#B5");
1384 // Strangely, 'A<NULL>' is accepted...
1385 string name
= String
.Format ("{0}", (char) 0);
1386 tb
.DefineField (name
, typeof (int), 0);
1387 Assert
.Fail ("#C1");
1388 } catch (ArgumentException ex
) {
1390 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
1391 Assert
.IsNull (ex
.InnerException
, "#C3");
1392 Assert
.IsNotNull (ex
.Message
, "#C4");
1393 Assert
.AreEqual ("fieldName", ex
.ParamName
, "#C5");
1397 tb
.DefineField ("A", typeof (void), 0);
1398 Assert
.Fail ("#D1");
1399 } catch (ArgumentException ex
) {
1400 // Bad field type in defining field
1401 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#D2");
1402 Assert
.IsNull (ex
.InnerException
, "#D3");
1403 Assert
.IsNotNull (ex
.Message
, "#D4");
1404 Assert
.IsNull (ex
.ParamName
, "#D5");
1409 // Can not be called on a created type
1411 tb
.DefineField ("B", typeof (int), 0);
1412 Assert
.Fail ("#E1");
1413 } catch (InvalidOperationException ex
) {
1414 // Unable to change after type has been created
1415 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#E2");
1416 Assert
.IsNull (ex
.InnerException
, "#E3");
1417 Assert
.IsNotNull (ex
.Message
, "#E4");
1421 [Test
] // DefineField (String, Type, FieldAttributes)
1422 public void DefineField1_Name_NullChar ()
1424 TypeBuilder tb
= module
.DefineType (genTypeName ());
1427 tb
.DefineField ("\0test", typeof (int),
1428 FieldAttributes
.Private
);
1429 Assert
.Fail ("#A1");
1430 } catch (ArgumentException ex
) {
1432 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
1433 Assert
.IsNull (ex
.InnerException
, "#A3");
1434 Assert
.IsNotNull (ex
.Message
, "#A4");
1435 Assert
.AreEqual ("fieldName", ex
.ParamName
, "#A5");
1438 FieldBuilder fb
= tb
.DefineField ("te\0st", typeof (int),
1439 FieldAttributes
.Private
);
1440 Assert
.IsNotNull (fb
, "#B1");
1441 Assert
.AreEqual ("te\0st", fb
.Name
, "#B2");
1444 [Test
] // DefineField (String, Type, FieldAttributes)
1445 public void DefineField1_Type_Null ()
1447 TypeBuilder tb
= module
.DefineType (genTypeName ());
1450 tb
.DefineField ("test", (Type
) null,
1451 FieldAttributes
.Private
);
1453 } catch (ArgumentNullException ex
) {
1454 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
1455 Assert
.IsNull (ex
.InnerException
, "#3");
1456 Assert
.IsNotNull (ex
.Message
, "#4");
1457 Assert
.AreEqual ("type", ex
.ParamName
, "#5");
1461 [Test
] // DefineField (String, Type, Type [], Type [], FieldAttributes)
1462 public void DefineField2_Type_Null ()
1464 TypeBuilder tb
= module
.DefineType (genTypeName ());
1467 tb
.DefineField ("test", (Type
) null, Type
.EmptyTypes
,
1468 Type
.EmptyTypes
, FieldAttributes
.Private
);
1470 } catch (ArgumentNullException ex
) {
1471 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
1472 Assert
.IsNull (ex
.InnerException
, "#3");
1473 Assert
.IsNotNull (ex
.Message
, "#4");
1474 Assert
.AreEqual ("type", ex
.ParamName
, "#5");
1479 public void TestDefineInitializedData ()
1481 TypeBuilder tb
= module
.DefineType (genTypeName ());
1483 // Check invalid arguments
1485 tb
.DefineInitializedData (null, new byte [1], 0);
1486 Assert
.Fail ("#A1");
1487 } catch (ArgumentNullException ex
) {
1488 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
1489 Assert
.IsNull (ex
.InnerException
, "#A3");
1490 Assert
.IsNotNull (ex
.Message
, "#A4");
1491 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1495 tb
.DefineInitializedData ("FOO", null, 0);
1496 Assert
.Fail ("#B1");
1497 } catch (ArgumentNullException ex
) {
1498 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#B2");
1499 Assert
.IsNull (ex
.InnerException
, "#B3");
1500 Assert
.IsNotNull (ex
.Message
, "#B4");
1501 Assert
.AreEqual ("data", ex
.ParamName
, "#B5");
1505 tb
.DefineInitializedData (string.Empty
, new byte [1], 0);
1506 Assert
.Fail ("#C1");
1507 } catch (ArgumentException ex
) {
1508 // Empty name is not legal
1509 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
1510 Assert
.IsNull (ex
.InnerException
, "#C3");
1511 Assert
.IsNotNull (ex
.Message
, "#C4");
1512 Assert
.AreEqual ("name", ex
.ParamName
, "#C5");
1515 // The size of the data is less than or equal to zero ???
1517 tb
.DefineInitializedData ("BAR", new byte [0], 0);
1518 Assert
.Fail ("#D1");
1519 } catch (ArgumentException ex
) {
1520 // Data size must be > 0 and < 0x3f0000
1521 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#D2");
1522 Assert
.IsNull (ex
.InnerException
, "#D3");
1523 Assert
.IsNotNull (ex
.Message
, "#D4");
1524 Assert
.IsNull (ex
.ParamName
, "#D5");
1528 string name
= String
.Format ("{0}", (char) 0);
1529 tb
.DefineInitializedData (name
, new byte [1], 0);
1530 Assert
.Fail ("#E1");
1531 } catch (ArgumentException ex
) {
1533 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#E2");
1534 Assert
.IsNull (ex
.InnerException
, "#E3");
1535 Assert
.IsNotNull (ex
.Message
, "#E4");
1536 Assert
.AreEqual ("fieldName", ex
.ParamName
, "#E5");
1541 // Can not be called on a created type, altough the MSDN docs does not mention this
1543 tb
.DefineInitializedData ("BAR2", new byte [1], 0);
1544 Assert
.Fail ("#F1");
1545 } catch (InvalidOperationException ex
) {
1546 // Unable to change after type has been created
1547 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#F2");
1548 Assert
.IsNull (ex
.InnerException
, "#F3");
1549 Assert
.IsNotNull (ex
.Message
, "#F4");
1554 public void DefineUninitializedDataInvalidArgs ()
1556 TypeBuilder tb
= module
.DefineType (genTypeName ());
1559 tb
.DefineUninitializedData (null, 1, 0);
1560 Assert
.Fail ("#A1");
1561 } catch (ArgumentNullException ex
) {
1562 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
1563 Assert
.IsNull (ex
.InnerException
, "#A3");
1564 Assert
.IsNotNull (ex
.Message
, "#A4");
1565 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1569 tb
.DefineUninitializedData (string.Empty
, 1, 0);
1570 Assert
.Fail ("#B1");
1571 } catch (ArgumentException ex
) {
1572 // Empty name is not legal
1573 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
1574 Assert
.IsNull (ex
.InnerException
, "#B3");
1575 Assert
.IsNotNull (ex
.Message
, "#B4");
1576 Assert
.AreEqual ("name", ex
.ParamName
, "#B5");
1579 // The size of the data is less than or equal to zero ???
1581 tb
.DefineUninitializedData ("BAR", 0, 0);
1582 Assert
.Fail ("#C1");
1583 } catch (ArgumentException ex
) {
1584 // Data size must be > 0 and < 0x3f0000
1585 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
1586 Assert
.IsNull (ex
.InnerException
, "#C3");
1587 Assert
.IsNotNull (ex
.Message
, "#C4");
1588 Assert
.IsNull (ex
.ParamName
, "#C5");
1592 string name
= String
.Format ("{0}", (char) 0);
1593 tb
.DefineUninitializedData (name
, 1, 0);
1594 Assert
.Fail ("#D1");
1595 } catch (ArgumentException ex
) {
1597 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#D2");
1598 Assert
.IsNull (ex
.InnerException
, "#D3");
1599 Assert
.IsNotNull (ex
.Message
, "#D4");
1600 Assert
.AreEqual ("fieldName", ex
.ParamName
, "#D5");
1605 public void DefineUninitializedDataAlreadyCreated ()
1607 TypeBuilder tb
= module
.DefineType (genTypeName ());
1610 tb
.DefineUninitializedData ("BAR2", 1, 0);
1612 } catch (InvalidOperationException ex
) {
1613 // Unable to change after type has been created
1614 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
1615 Assert
.IsNull (ex
.InnerException
, "#3");
1616 Assert
.IsNotNull (ex
.Message
, "#4");
1621 public void DefineUninitializedData ()
1623 TypeBuilder tb
= module
.DefineType (genTypeName ());
1625 tb
.DefineUninitializedData ("foo", 4, FieldAttributes
.Public
);
1627 Type t
= tb
.CreateType ();
1629 object o
= Activator
.CreateInstance (t
);
1631 FieldInfo fi
= t
.GetField ("foo");
1633 object fieldVal
= fi
.GetValue (o
);
1635 IntPtr ptr
= Marshal
.AllocHGlobal (4);
1636 Marshal
.StructureToPtr (fieldVal
, ptr
, true);
1637 Marshal
.FreeHGlobal (ptr
);
1641 public void DefineMethod_Name_NullChar ()
1643 TypeBuilder tb
= module
.DefineType (genTypeName ());
1645 tb
.DefineMethod ("\0test", MethodAttributes
.Private
,
1646 typeof (string), Type
.EmptyTypes
);
1647 Assert
.Fail ("#A1");
1648 } catch (ArgumentException ex
) {
1650 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
1651 Assert
.IsNull (ex
.InnerException
, "#A3");
1652 Assert
.IsNotNull (ex
.Message
, "#A4");
1653 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1656 MethodBuilder mb
= tb
.DefineMethod ("te\0st", MethodAttributes
.Private
,
1657 typeof (string), Type
.EmptyTypes
);
1658 Assert
.IsNotNull (mb
, "#B1");
1659 Assert
.AreEqual ("te\0st", mb
.Name
, "#B2");
1663 public void TestDefineMethod ()
1665 TypeBuilder tb
= module
.DefineType (genTypeName ());
1667 // Check invalid arguments
1669 tb
.DefineMethod (null, 0, null, null);
1670 Assert
.Fail ("#A1");
1671 } catch (ArgumentNullException ex
) {
1672 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
1673 Assert
.IsNull (ex
.InnerException
, "#A3");
1674 Assert
.IsNotNull (ex
.Message
, "#A4");
1675 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1679 tb
.DefineMethod (string.Empty
, 0, null, null);
1680 Assert
.Fail ("#B1");
1681 } catch (ArgumentException ex
) {
1682 // Empty name is not legal
1683 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
1684 Assert
.IsNull (ex
.InnerException
, "#B3");
1685 Assert
.IsNotNull (ex
.Message
, "#B4");
1686 Assert
.AreEqual ("name", ex
.ParamName
, "#B5");
1689 // Check non-virtual methods on an interface
1690 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
1692 tb2
.DefineMethod ("FOO", MethodAttributes
.Abstract
, null, null);
1693 Assert
.Fail ("#C1");
1694 } catch (ArgumentException ex
) {
1695 // Interface method must be abstract and virtual
1696 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
1697 Assert
.IsNull (ex
.InnerException
, "#C3");
1698 Assert
.IsNotNull (ex
.Message
, "#C4");
1699 Assert
.IsNull (ex
.ParamName
, "#C5");
1702 // Check static methods on an interface
1703 tb2
.DefineMethod ("BAR", MethodAttributes
.Public
| MethodAttributes
.Static
,
1708 // Can not be called on a created type
1710 tb
.DefineMethod ("bar", 0, null, null);
1711 Assert
.Fail ("#D1");
1712 } catch (InvalidOperationException ex
) {
1713 // Unable to change after type has been created
1714 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#D2");
1715 Assert
.IsNull (ex
.InnerException
, "#D3");
1716 Assert
.IsNotNull (ex
.Message
, "#D4");
1720 [Test
] // bug #327484
1721 [Category ("NotWorking")]
1722 public void TestDefineMethod_Abstract ()
1724 TypeBuilder tb
= module
.DefineType (genTypeName ());
1725 tb
.DefineMethod ("Run", MethodAttributes
.Public
|
1726 MethodAttributes
.Abstract
| MethodAttributes
.Virtual
,
1727 typeof (void), Type
.EmptyTypes
);
1731 Assert
.Fail ("#A1");
1732 } catch (InvalidOperationException ex
) {
1733 // Type must be declared abstract if any of its
1734 // methods are abstract
1735 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#A2");
1736 Assert
.IsNull (ex
.InnerException
, "#A3");
1737 Assert
.IsNotNull (ex
.Message
, "#A4");
1740 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Abstract
);
1741 tb
.DefineMethod ("Run", MethodAttributes
.Public
|
1742 MethodAttributes
.Abstract
, typeof (void),
1747 Assert
.Fail ("#B1");
1748 } catch (TypeLoadException ex
) {
1749 // Non-virtual abstract method
1750 Assert
.AreEqual (typeof (TypeLoadException
), ex
.GetType (), "#B2");
1751 Assert
.IsNull (ex
.InnerException
, "#B3");
1752 Assert
.IsNotNull (ex
.Message
, "#B4");
1755 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Abstract
|
1756 TypeAttributes
.Public
);
1757 tb
.DefineMethod ("Run", MethodAttributes
.Public
|
1758 MethodAttributes
.Abstract
| MethodAttributes
.Virtual
,
1759 typeof (void), Type
.EmptyTypes
);
1760 Type emittedType
= tb
.CreateType ();
1762 MethodInfo mi1
= emittedType
.GetMethod ("Run");
1763 Assert
.IsNotNull (mi1
, "#C1");
1764 Assert
.IsTrue (mi1
.IsAbstract
, "#C2");
1766 MethodInfo mi2
= tb
.GetMethod ("Run");
1767 Assert
.IsNotNull (mi2
, "#D1");
1768 Assert
.IsTrue (mi2
.IsAbstract
, "#D2");
1771 // TODO: DefineMethodOverride
1774 public void TestDefineNestedType ()
1776 TypeBuilder tb
= module
.DefineType (genTypeName ());
1778 // Check invalid arguments
1780 tb
.DefineNestedType (null);
1781 Assert
.Fail ("#A1");
1782 } catch (ArgumentNullException ex
) {
1783 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
1784 Assert
.IsNull (ex
.InnerException
, "#A3");
1785 Assert
.IsNotNull (ex
.Message
, "#A4");
1786 Assert
.AreEqual ("fullname", ex
.ParamName
, "#A5");
1790 tb
.DefineNestedType (string.Empty
);
1791 Assert
.Fail ("#B1");
1792 } catch (ArgumentException ex
) {
1793 // Empty name is not legal
1794 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
1795 Assert
.IsNull (ex
.InnerException
, "#B3");
1796 Assert
.IsNotNull (ex
.Message
, "#B4");
1797 Assert
.AreEqual ("fullname", ex
.ParamName
, "#B5");
1801 tb
.DefineNestedType (nullName ());
1802 Assert
.Fail ("#C1");
1803 } catch (ArgumentException ex
) {
1805 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
1806 Assert
.IsNull (ex
.InnerException
, "#C3");
1807 Assert
.IsNotNull (ex
.Message
, "#C4");
1808 Assert
.AreEqual ("fullname", ex
.ParamName
, "#C5");
1811 // If I fix the code so this works then mcs breaks -> how can mcs
1812 // works under MS .NET in the first place ???
1815 tb.DefineNestedType ("AA", TypeAttributes.Public, null, null);
1816 Fail ("Nested visibility must be specified.");
1818 catch (ArgumentException) {
1823 tb
.DefineNestedType ("BB", TypeAttributes
.NestedPublic
, null,
1825 Assert
.Fail ("#D1");
1826 } catch (ArgumentNullException ex
) {
1827 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#D2");
1828 Assert
.IsNull (ex
.InnerException
, "#D3");
1829 Assert
.IsNotNull (ex
.Message
, "#D4");
1830 Assert
.AreEqual ("interfaces", ex
.ParamName
, "#D5");
1833 // I think this should reject non-interfaces, but it does not
1834 tb
.DefineNestedType ("BB", TypeAttributes
.NestedPublic
, null,
1835 new Type
[1] { typeof (object) }
);
1837 // Normal invocation
1838 tb
.DefineNestedType ("Nest");
1842 // According to the MSDN docs, this cannnot be called after the type
1843 // is created, but it works.
1844 tb
.DefineNestedType ("Nest2");
1846 // According to the MSDN docs, a Sealed class can't contain nested
1847 // types, but this is not true
1848 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Sealed
);
1849 tb2
.DefineNestedType ("AA");
1851 // According to the MSDN docs, interfaces can only contain interfaces,
1852 // but this is not true
1853 TypeBuilder tb3
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
1855 tb3
.DefineNestedType ("AA");
1857 // Check shorter versions
1859 TypeBuilder nested
= tb
.DefineNestedType ("N1");
1861 Assert
.AreEqual ("N1", nested
.Name
, "#E1");
1862 Assert
.AreEqual (typeof (object), nested
.BaseType
, "#E2");
1863 Assert
.AreEqual (TypeAttributes
.NestedPrivate
, nested
.Attributes
, "#E3");
1864 Assert
.AreEqual (0, nested
.GetInterfaces ().Length
, "#E4");
1871 public void NestedTypeSave () {
1872 var tb
= module
.DefineType (genTypeName ());
1874 var tbuilder
= tb
.DefineNestedType ("Test.CodeGen", TypeAttributes
.Public
| TypeAttributes
.Class
);
1875 var entryp
= tbuilder
.DefineMethod("Main", MethodAttributes
.Public
| MethodAttributes
.Static
, typeof (void), null);
1876 var ilg
= entryp
.GetILGenerator (128);
1877 ilg
.Emit (OpCodes
.Ldtoken
, tb
);
1878 ilg
.Emit (OpCodes
.Pop
);
1879 ilg
.Emit (OpCodes
.Ret
);
1881 tbuilder
.CreateType ();
1884 assembly
.Save (ASSEMBLY_NAME
+ ".dll");
1888 public void DefinePInvokeMethod_Name_NullChar ()
1890 TypeBuilder tb
= module
.DefineType (genTypeName ());
1892 tb
.DefinePInvokeMethod ("\0test", "B", "C",
1893 MethodAttributes
.Private
, CallingConventions
.Standard
,
1894 typeof (string),Type
.EmptyTypes
, CallingConvention
.Cdecl
,
1896 Assert
.Fail ("#A1");
1897 } catch (ArgumentException ex
) {
1899 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
1900 Assert
.IsNull (ex
.InnerException
, "#A3");
1901 Assert
.IsNotNull (ex
.Message
, "#A4");
1902 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1905 MethodBuilder mb
= tb
.DefinePInvokeMethod ("te\0st", "B", "C",
1906 MethodAttributes
.Private
, CallingConventions
.Standard
,
1907 typeof (string), Type
.EmptyTypes
, CallingConvention
.Cdecl
,
1909 Assert
.IsNotNull (mb
, "#B1");
1910 Assert
.AreEqual ("te\0st", mb
.Name
, "#B2");
1914 public void TestDefinePInvokeMethod ()
1916 TypeBuilder tb
= module
.DefineType (genTypeName ());
1918 tb
.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1920 // Try invalid parameters
1922 tb
.DefinePInvokeMethod (null, "B", "C", 0, 0, null, null, 0, 0);
1923 Assert
.Fail ("#A1");
1924 } catch (ArgumentNullException ex
) {
1925 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
1926 Assert
.IsNull (ex
.InnerException
, "#A3");
1927 Assert
.IsNotNull (ex
.Message
, "#A4");
1928 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1932 // Try invalid attributes
1934 tb
.DefinePInvokeMethod ("A2", "B", "C", MethodAttributes
.Abstract
, 0, null, null, 0, 0);
1935 Assert
.Fail ("#B1");
1936 } catch (ArgumentException ex
) {
1937 // PInvoke methods must be static and native and
1938 // cannot be abstract
1939 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
1940 Assert
.IsNull (ex
.InnerException
, "#B3");
1941 Assert
.IsNotNull (ex
.Message
, "#B4");
1942 Assert
.IsNull (ex
.ParamName
, "#B5");
1945 // Try an interface parent
1946 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
1949 tb2
.DefinePInvokeMethod ("A", "B", "C", 0, 0, null, null, 0, 0);
1950 Assert
.Fail ("#C1");
1951 } catch (ArgumentException ex
) {
1952 // PInvoke methods cannot exist on interfaces
1953 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
1954 Assert
.IsNull (ex
.InnerException
, "#B3");
1955 Assert
.IsNotNull (ex
.Message
, "#B4");
1956 Assert
.IsNull (ex
.ParamName
, "#B5");
1961 public void DefineProperty_Name_NullChar ()
1963 TypeBuilder tb
= module
.DefineType (genTypeName ());
1966 tb
.DefineProperty ("\0test", 0, typeof (string), Type
.EmptyTypes
);
1967 Assert
.Fail ("#A1");
1968 } catch (ArgumentException ex
) {
1970 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
1971 Assert
.IsNull (ex
.InnerException
, "#A3");
1972 Assert
.IsNotNull (ex
.Message
, "#A4");
1973 Assert
.AreEqual ("name", ex
.ParamName
, "#A5");
1976 PropertyBuilder pb
= tb
.DefineProperty ("te\0st", 0,
1977 typeof (string), Type
.EmptyTypes
);
1978 Assert
.IsNotNull (pb
, "#B1");
1979 Assert
.AreEqual ("te\0st", pb
.Name
, "#B2");
1983 public void DefineProperty_ParameterTypes_ItemNull ()
1985 TypeBuilder tb
= module
.DefineType (genTypeName ());
1988 tb
.DefineProperty ("A", 0, typeof (string), new Type
[1]);
1990 } catch (ArgumentNullException ex
) {
1991 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
1992 Assert
.IsNull (ex
.InnerException
, "#3");
1993 Assert
.IsNotNull (ex
.Message
, "#4");
1998 public void DefineProperty_ReturnType_Null ()
2000 TypeBuilder tb
= module
.DefineType (genTypeName ());
2001 tb
.DefineProperty ("A", 0, null, Type
.EmptyTypes
);
2005 public void GetMethod_WorksWithTypeBuilderParameter () {
2006 TypeBuilder tb
= module
.DefineType (genTypeName ());
2007 var garg
= tb
.DefineGenericParameters ("T") [0];
2008 MethodBuilder mb
= tb
.DefineMethod ("create", MethodAttributes
.Public
, typeof (void), Type
.EmptyTypes
);
2010 var mi
= TypeBuilder
.GetMethod (tb
, mb
);
2011 var decl
= mi
.DeclaringType
;
2013 Assert
.IsTrue (decl
.IsGenericType
, "#1");
2014 Assert
.IsFalse (decl
.IsGenericTypeDefinition
, "#2");
2015 Assert
.AreEqual (tb
, decl
.GetGenericTypeDefinition (), "#3");
2016 Assert
.AreEqual (garg
, decl
.GetGenericArguments () [0], "#4");
2020 public void GetConstructor_FailWithTypeBuilderParameter () {
2021 TypeBuilder tb
= module
.DefineType (genTypeName ());
2022 var garg
= tb
.DefineGenericParameters ("T") [0];
2023 var cb
= tb
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
2026 TypeBuilder
.GetConstructor (tb
, cb
);
2028 } catch (ArgumentException ex
) {
2029 Assert
.AreEqual ("type", ex
.ParamName
, "#2");
2034 public void GetField_FailWithTypeBuilderParameter () {
2035 TypeBuilder tb
= module
.DefineType (genTypeName ());
2036 var garg
= tb
.DefineGenericParameters ("T") [0];
2037 var fb
= tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
2040 TypeBuilder
.GetField (tb
, fb
);
2042 } catch (ArgumentException ex
) {
2043 Assert
.AreEqual ("type", ex
.ParamName
, "#2");
2048 public void GetMethod_RejectMethodFromInflatedTypeBuilder () {
2049 TypeBuilder tb
= module
.DefineType (genTypeName ());
2050 tb
.DefineGenericParameters ("T");
2051 MethodBuilder mb
= tb
.DefineMethod ("create", MethodAttributes
.Public
, typeof (void), Type
.EmptyTypes
);
2053 Type ginst
= tb
.MakeGenericType (typeof (int));
2055 MethodInfo mi
= TypeBuilder
.GetMethod (ginst
, mb
);
2057 TypeBuilder
.GetMethod (ginst
, mi
);
2059 } catch (ArgumentException ex
) {
2060 Assert
.AreEqual ("method", ex
.ParamName
, "#5");
2065 public void GetMethod_WorkWithInstancesOfCreatedTypeBuilder () {
2066 TypeBuilder tb
= module
.DefineType (genTypeName ());
2067 tb
.DefineGenericParameters ("T");
2068 MethodBuilder mb
= tb
.DefineMethod ("create", MethodAttributes
.Public
, typeof (void), Type
.EmptyTypes
);
2069 ILGenerator ig
= mb
.GetILGenerator ();
2070 ig
.Emit (OpCodes
.Ret
);
2074 MethodInfo mi
= TypeBuilder
.GetMethod (tb
.MakeGenericType (typeof (int)), mb
);
2075 Assert
.IsNotNull (mi
);
2079 [Category ("NotDotNet")]
2080 [Category ("NotWorking")]
2081 public void GetMethod_AcceptMethodFromInflatedTypeBuilder_UnderCompilerContext () {
2082 AssemblyName assemblyName
= new AssemblyName ();
2083 assemblyName
.Name
= ASSEMBLY_NAME
;
2086 Thread
.GetDomain ().DefineDynamicAssembly (
2087 assemblyName
, AssemblyBuilderAccess
.RunAndSave
| (AssemblyBuilderAccess
)0x800, tempDir
);
2089 module
= assembly
.DefineDynamicModule ("module1");
2091 TypeBuilder tb
= module
.DefineType (genTypeName ());
2092 tb
.DefineGenericParameters ("T");
2093 MethodBuilder mb
= tb
.DefineMethod ("create", MethodAttributes
.Public
, typeof (void), Type
.EmptyTypes
);
2095 Type ginst
= tb
.MakeGenericType (typeof (int));
2097 MethodInfo mi
= TypeBuilder
.GetMethod (ginst
, mb
);
2100 TypeBuilder
.GetMethod (ginst
, mi
);
2101 } catch (ArgumentException ex
) {
2108 // Test that changes made to the method builder after a call to GetMethod ()
2110 public void TestGetMethod ()
2112 TypeBuilder tb
= module
.DefineType (genTypeName ());
2113 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters ("T");
2115 ConstructorBuilder cb
= tb
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
2117 ig
= cb
.GetILGenerator ();
2118 ig
.Emit (OpCodes
.Ret
);
2120 Type fooOfT
= tb
.MakeGenericType (typeParams
[0]);
2122 // Create a method builder but do not emit IL yet
2123 MethodBuilder mb1
= tb
.DefineMethod ("create", MethodAttributes
.Public
|MethodAttributes
.Static
, fooOfT
, Type
.EmptyTypes
);
2125 Type t
= tb
.MakeGenericType (typeof (int));
2127 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
|MethodAttributes
.Static
, t
, Type
.EmptyTypes
);
2129 ig
= mb
.GetILGenerator ();
2130 ig
.Emit (OpCodes
.Call
, TypeBuilder
.GetMethod (t
, mb1
));
2131 ig
.Emit (OpCodes
.Ret
);
2133 // Finish the method
2134 ig
= mb1
.GetILGenerator ();
2135 ig
.Emit (OpCodes
.Newobj
, TypeBuilder
.GetConstructor (fooOfT
, cb
));
2136 ig
.Emit (OpCodes
.Ret
);
2138 Type t2
= tb
.CreateType ();
2140 Assert
.AreEqual (tb
.Name
+ "[System.Int32]", t2
.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2144 public void TestGetConstructor ()
2146 TypeBuilder tb
= module
.DefineType (genTypeName ());
2147 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters ("T");
2149 ConstructorBuilder cb
= tb
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
2152 Type t
= tb
.MakeGenericType (typeof (int));
2154 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
|MethodAttributes
.Static
, t
, Type
.EmptyTypes
);
2156 ig
= mb
.GetILGenerator ();
2158 ConstructorInfo ci
= TypeBuilder
.GetConstructor (t
, cb
);
2160 ig
.Emit (OpCodes
.Newobj
, ci
);
2161 ig
.Emit (OpCodes
.Ret
);
2163 // Finish the ctorbuilder
2164 ig
= cb
.GetILGenerator ();
2165 ig
.Emit(OpCodes
.Ldarg_0
);
2166 ig
.Emit(OpCodes
.Call
, tb
.BaseType
.GetConstructor(Type
.EmptyTypes
));
2167 ig
.Emit (OpCodes
.Ret
);
2169 Type t2
= tb
.CreateType ();
2171 Assert
.AreEqual (tb
.Name
+ "[System.Int32]", t2
.MakeGenericType (typeof (int)).GetMethod ("foo").Invoke (null, null).GetType ().ToString ());
2175 [ExpectedException (typeof (ArgumentException
))]
2176 public void Static_GetConstructor_TypeNull ()
2178 ConstructorInfo ci
= typeof (object).GetConstructor (Type
.EmptyTypes
);
2179 // null is non-generic (from exception message)
2180 TypeBuilder
.GetConstructor (null, ci
);
2184 [ExpectedException (typeof (ArgumentException
))]
2185 public void Static_GetConstructor_TypeGeneric ()
2187 Type t
= typeof (List
<>).MakeGenericType (typeof (int));
2188 ConstructorInfo ci
= typeof (object).GetConstructor (Type
.EmptyTypes
);
2189 // type is not 'TypeBuilder' (from exception message)
2190 TypeBuilder
.GetConstructor (t
, ci
);
2194 public void Static_GetConstructor_TypeBuilderGeneric_ConstructorInfoNull ()
2196 TypeBuilder tb
= module
.DefineType ("XXX");
2197 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters ("T");
2198 Type fooOfT
= tb
.MakeGenericType (typeParams
[0]);
2200 TypeBuilder
.GetConstructor (fooOfT
, null);
2201 Assert
.Fail ("Expected NullReferenceException");
2203 catch (NullReferenceException
) {
2208 public void CreateTypeThrowsForMethodsWithBadLabels ()
2210 TypeBuilder tb
= module
.DefineType (genTypeName ());
2212 MethodBuilder mb
= tb
.DefineMethod("F", MethodAttributes
.Public
, typeof(string), null);
2213 ILGenerator il_gen
= mb
.GetILGenerator ();
2214 il_gen
.DefineLabel ();
2215 il_gen
.Emit (OpCodes
.Leave
, new Label ());
2219 } catch (ArgumentException
) {}
2223 [Category ("NotWorking")]
2224 public void TestIsDefinedIncomplete ()
2226 TypeBuilder tb
= module
.DefineType (genTypeName ());
2228 tb
.IsDefined (typeof (int), true);
2230 } catch (NotSupportedException ex
) {
2231 // The invoked member is not supported in a
2233 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
2234 Assert
.IsNull (ex
.InnerException
, "#3");
2235 Assert
.IsNotNull (ex
.Message
, "#4");
2240 public void TestIsDefinedComplete ()
2242 TypeBuilder tb
= module
.DefineType (genTypeName ());
2244 ConstructorInfo obsoleteCtor
= typeof (ObsoleteAttribute
).GetConstructor (
2245 new Type
[] { typeof (string) }
);
2247 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (obsoleteCtor
,
2248 new object [] { "obsolete message" }
, new FieldInfo
[0], new object [0]);
2250 tb
.SetCustomAttribute (caBuilder
);
2252 Assert
.IsTrue (tb
.IsDefined (typeof (ObsoleteAttribute
), false));
2256 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=293659
2257 public void IsDefined_AttributeType_Null ()
2259 TypeBuilder tb
= module
.DefineType (genTypeName ());
2263 tb
.IsDefined ((Type
) null, false);
2265 } catch (ArgumentNullException ex
) {
2266 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
2267 Assert
.IsNull (ex
.InnerException
, "#3");
2268 Assert
.IsNotNull (ex
.Message
, "#4");
2269 Assert
.AreEqual ("attributeType", ex
.ParamName
, "#5");
2273 [Test
] // GetConstructor (Type [])
2274 public void GetConstructor1_Incomplete ()
2276 TypeBuilder tb
= module
.DefineType (genTypeName ());
2277 ConstructorBuilder cb
= tb
.DefineConstructor (
2278 MethodAttributes
.Public
,
2279 CallingConventions
.Standard
,
2281 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
2284 tb
.GetConstructor (Type
.EmptyTypes
);
2286 } catch (NotSupportedException ex
) {
2287 // The invoked member is not supported in a
2289 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
2290 Assert
.IsNull (ex
.InnerException
, "#3");
2291 Assert
.IsNotNull (ex
.Message
, "#4");
2295 [Test
] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2296 public void GetConstructor2_Complete ()
2299 ConstructorInfo ctor
;
2301 TypeBuilder redType
= module
.DefineType (genTypeName (),
2302 TypeAttributes
.Public
);
2303 CreateMembers (redType
, "Red", true);
2305 TypeBuilder greenType
= module
.DefineType (genTypeName (),
2306 TypeAttributes
.Public
, redType
);
2307 CreateMembers (greenType
, "Green", false);
2308 ConstructorBuilder cb
= greenType
.DefineConstructor (
2309 MethodAttributes
.Public
,
2310 CallingConventions
.Standard
,
2312 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
2314 redType
.CreateType ();
2315 greenType
.CreateType ();
2317 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
2319 ctor
= greenType
.GetConstructor (flags
, null,
2320 new Type
[] { typeof (int), typeof (int) }
,
2321 new ParameterModifier
[0]);
2322 Assert
.IsNull (ctor
, "#A1");
2324 ctor
= greenType
.GetConstructor (flags
, null,
2325 new Type
[] { typeof (string) }
,
2326 new ParameterModifier
[0]);
2327 Assert
.IsNull (ctor
, "#A2");
2329 ctor
= greenType
.GetConstructor (flags
, null,
2330 new Type
[] { typeof (string), typeof (string) }
,
2331 new ParameterModifier
[0]);
2332 Assert
.IsNull (ctor
, "#A3");
2334 ctor
= greenType
.GetConstructor (flags
, null,
2335 new Type
[] { typeof (int) }
,
2336 new ParameterModifier
[0]);
2337 Assert
.IsNull (ctor
, "#A4");
2339 ctor
= greenType
.GetConstructor (flags
, null,
2340 new Type
[] { typeof (int), typeof (bool) }
,
2341 new ParameterModifier
[0]);
2342 Assert
.IsNull (ctor
, "#A5");
2344 ctor
= greenType
.GetConstructor (flags
, null,
2345 new Type
[] { typeof (string), typeof (int) }
,
2346 new ParameterModifier
[0]);
2347 Assert
.IsNull (ctor
, "#A6");
2349 ctor
= greenType
.GetConstructor (flags
, null,
2351 new ParameterModifier
[0]);
2352 Assert
.IsNull (ctor
, "#A7");
2354 ctor
= redType
.GetConstructor (flags
, null,
2355 new Type
[] { typeof (int), typeof (int) }
,
2356 new ParameterModifier
[0]);
2357 Assert
.IsNotNull (ctor
, "#A8a");
2358 Assert
.IsTrue (ctor
.IsPrivate
, "#A8b");
2359 Assert
.IsFalse (ctor
.IsStatic
, "#A8c");
2360 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#A8d");
2361 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#A8e");
2363 ctor
= redType
.GetConstructor (flags
, null,
2364 new Type
[] { typeof (string) }
,
2365 new ParameterModifier
[0]);
2366 Assert
.IsNotNull (ctor
, "#A9a");
2367 Assert
.IsTrue (ctor
.IsFamily
, "#A9b");
2368 Assert
.IsFalse (ctor
.IsStatic
, "#A9c");
2369 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#A9d");
2370 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#A9e");
2372 ctor
= redType
.GetConstructor (flags
, null,
2373 new Type
[] { typeof (string), typeof (string) }
,
2374 new ParameterModifier
[0]);
2375 Assert
.IsNotNull (ctor
, "#A10a");
2376 Assert
.IsTrue (ctor
.IsFamilyAndAssembly
, "#A10b");
2377 Assert
.IsFalse (ctor
.IsStatic
, "#A10c");
2378 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#A10d");
2379 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#A10e");
2381 ctor
= redType
.GetConstructor (flags
, null,
2382 new Type
[] { typeof (int) }
,
2383 new ParameterModifier
[0]);
2384 Assert
.IsNotNull (ctor
, "#A11a");
2385 Assert
.IsTrue (ctor
.IsFamilyOrAssembly
, "#A11b");
2386 Assert
.IsFalse (ctor
.IsStatic
, "#A11c");
2387 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#A11d");
2388 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#A11e");
2390 ctor
= redType
.GetConstructor (flags
, null,
2391 new Type
[] { typeof (int), typeof (bool) }
,
2392 new ParameterModifier
[0]);
2393 Assert
.IsNull (ctor
, "#A12");
2395 ctor
= redType
.GetConstructor (flags
, null,
2396 new Type
[] { typeof (string), typeof (int) }
,
2397 new ParameterModifier
[0]);
2398 Assert
.IsNotNull (ctor
, "#A13a");
2399 Assert
.IsTrue (ctor
.IsAssembly
, "#A13b");
2400 Assert
.IsFalse (ctor
.IsStatic
, "#A13c");
2401 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#A13d");
2402 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#A13e");
2404 ctor
= redType
.GetConstructor (flags
, null,
2406 new ParameterModifier
[0]);
2407 Assert
.IsNull (ctor
, "#A14");
2409 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
2411 ctor
= greenType
.GetConstructor (flags
, null,
2412 new Type
[] { typeof (int), typeof (int) }
,
2413 new ParameterModifier
[0]);
2414 Assert
.IsNull (ctor
, "#B1");
2416 ctor
= greenType
.GetConstructor (flags
, null,
2417 new Type
[] { typeof (string) }
,
2418 new ParameterModifier
[0]);
2419 Assert
.IsNull (ctor
, "#B2");
2421 ctor
= greenType
.GetConstructor (flags
, null,
2422 new Type
[] { typeof (string), typeof (string) }
,
2423 new ParameterModifier
[0]);
2424 Assert
.IsNull (ctor
, "#B3");
2426 ctor
= greenType
.GetConstructor (flags
, null,
2427 new Type
[] { typeof (int) }
,
2428 new ParameterModifier
[0]);
2429 Assert
.IsNull (ctor
, "#B4");
2431 ctor
= greenType
.GetConstructor (flags
, null,
2432 new Type
[] { typeof (int), typeof (bool) }
,
2433 new ParameterModifier
[0]);
2434 Assert
.IsNull (ctor
, "#B5");
2436 ctor
= greenType
.GetConstructor (flags
, null,
2437 new Type
[] { typeof (string), typeof (int) }
,
2438 new ParameterModifier
[0]);
2439 Assert
.IsNull (ctor
, "#B6");
2441 ctor
= greenType
.GetConstructor (flags
, null,
2443 new ParameterModifier
[0]);
2444 Assert
.IsNotNull (ctor
, "#B7a");
2445 Assert
.IsTrue (ctor
.IsPublic
, "#B7b");
2446 Assert
.IsFalse (ctor
.IsStatic
, "#B7c");
2447 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#B7d");
2448 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#B7e");
2450 ctor
= redType
.GetConstructor (flags
, null,
2451 new Type
[] { typeof (int), typeof (int) }
,
2452 new ParameterModifier
[0]);
2453 Assert
.IsNull (ctor
, "#B8");
2455 ctor
= redType
.GetConstructor (flags
, null,
2456 new Type
[] { typeof (string) }
,
2457 new ParameterModifier
[0]);
2458 Assert
.IsNull (ctor
, "#B9");
2460 ctor
= redType
.GetConstructor (flags
, null,
2461 new Type
[] { typeof (string), typeof (string) }
,
2462 new ParameterModifier
[0]);
2463 Assert
.IsNull (ctor
, "#B10");
2465 ctor
= redType
.GetConstructor (flags
, null,
2466 new Type
[] { typeof (int) }
,
2467 new ParameterModifier
[0]);
2468 Assert
.IsNull (ctor
, "#B11");
2470 ctor
= redType
.GetConstructor (flags
, null,
2471 new Type
[] { typeof (int), typeof (bool) }
,
2472 new ParameterModifier
[0]);
2473 Assert
.IsNotNull (ctor
, "#B12a");
2474 Assert
.IsTrue (ctor
.IsPublic
, "#B12b");
2475 Assert
.IsFalse (ctor
.IsStatic
, "#B12c");
2476 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#B12d");
2477 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#B12e");
2479 ctor
= redType
.GetConstructor (flags
, null,
2480 new Type
[] { typeof (string), typeof (int) }
,
2481 new ParameterModifier
[0]);
2482 Assert
.IsNull (ctor
, "#B13");
2484 ctor
= redType
.GetConstructor (flags
, null,
2486 new ParameterModifier
[0]);
2487 Assert
.IsNull (ctor
, "#B14");
2489 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
2491 ctor
= greenType
.GetConstructor (flags
, null,
2492 new Type
[] { typeof (int), typeof (int) }
,
2493 new ParameterModifier
[0]);
2494 Assert
.IsNull (ctor
, "#C1");
2496 ctor
= greenType
.GetConstructor (flags
, null,
2497 new Type
[] { typeof (string) }
,
2498 new ParameterModifier
[0]);
2499 Assert
.IsNull (ctor
, "#C2");
2501 ctor
= greenType
.GetConstructor (flags
, null,
2502 new Type
[] { typeof (string), typeof (string) }
,
2503 new ParameterModifier
[0]);
2504 Assert
.IsNull (ctor
, "#C3");
2506 ctor
= greenType
.GetConstructor (flags
, null,
2507 new Type
[] { typeof (int) }
,
2508 new ParameterModifier
[0]);
2509 Assert
.IsNull (ctor
, "#C4");
2511 ctor
= greenType
.GetConstructor (flags
, null,
2512 new Type
[] { typeof (int), typeof (bool) }
,
2513 new ParameterModifier
[0]);
2514 Assert
.IsNull (ctor
, "#C5");
2516 ctor
= greenType
.GetConstructor (flags
, null,
2517 new Type
[] { typeof (string), typeof (int) }
,
2518 new ParameterModifier
[0]);
2519 Assert
.IsNull (ctor
, "#C6");
2521 ctor
= greenType
.GetConstructor (flags
, null,
2523 new ParameterModifier
[0]);
2524 Assert
.IsNull (ctor
, "#C7");
2526 ctor
= redType
.GetConstructor (flags
, null,
2527 new Type
[] { typeof (int), typeof (int) }
,
2528 new ParameterModifier
[0]);
2529 Assert
.IsNull (ctor
, "#C8");
2531 ctor
= redType
.GetConstructor (flags
, null,
2532 new Type
[] { typeof (string) }
,
2533 new ParameterModifier
[0]);
2534 Assert
.IsNull (ctor
, "#C9");
2536 ctor
= redType
.GetConstructor (flags
, null,
2537 new Type
[] { typeof (string), typeof (string) }
,
2538 new ParameterModifier
[0]);
2539 Assert
.IsNull (ctor
, "#C10");
2541 ctor
= redType
.GetConstructor (flags
, null,
2542 new Type
[] { typeof (int) }
,
2543 new ParameterModifier
[0]);
2544 Assert
.IsNull (ctor
, "#C11a");
2546 ctor
= redType
.GetConstructor (flags
, null,
2547 new Type
[] { typeof (int), typeof (bool) }
,
2548 new ParameterModifier
[0]);
2549 Assert
.IsNull (ctor
, "#C12");
2551 ctor
= redType
.GetConstructor (flags
, null,
2552 new Type
[] { typeof (string), typeof (int) }
,
2553 new ParameterModifier
[0]);
2554 Assert
.IsNull (ctor
, "#C13");
2556 ctor
= redType
.GetConstructor (flags
, null,
2558 new ParameterModifier
[0]);
2559 Assert
.IsNull (ctor
, "#C14");
2561 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
2563 ctor
= greenType
.GetConstructor (flags
, null,
2564 new Type
[] { typeof (int), typeof (int) }
,
2565 new ParameterModifier
[0]);
2566 Assert
.IsNull (ctor
, "#D1");
2568 ctor
= greenType
.GetConstructor (flags
, null,
2569 new Type
[] { typeof (string) }
,
2570 new ParameterModifier
[0]);
2571 Assert
.IsNull (ctor
, "#D2");
2573 ctor
= greenType
.GetConstructor (flags
, null,
2574 new Type
[] { typeof (string), typeof (string) }
,
2575 new ParameterModifier
[0]);
2576 Assert
.IsNull (ctor
, "#D3");
2578 ctor
= greenType
.GetConstructor (flags
, null,
2579 new Type
[] { typeof (int) }
,
2580 new ParameterModifier
[0]);
2581 Assert
.IsNull (ctor
, "#D4");
2583 ctor
= greenType
.GetConstructor (flags
, null,
2584 new Type
[] { typeof (int), typeof (bool) }
,
2585 new ParameterModifier
[0]);
2586 Assert
.IsNull (ctor
, "#D5");
2588 ctor
= greenType
.GetConstructor (flags
, null,
2589 new Type
[] { typeof (string), typeof (int) }
,
2590 new ParameterModifier
[0]);
2591 Assert
.IsNull (ctor
, "#D6");
2593 ctor
= greenType
.GetConstructor (flags
, null,
2595 new ParameterModifier
[0]);
2596 Assert
.IsNull (ctor
, "#D7");
2598 ctor
= redType
.GetConstructor (flags
, null,
2599 new Type
[] { typeof (int), typeof (int) }
,
2600 new ParameterModifier
[0]);
2601 Assert
.IsNull (ctor
, "#D8");
2603 ctor
= redType
.GetConstructor (flags
, null,
2604 new Type
[] { typeof (string) }
,
2605 new ParameterModifier
[0]);
2606 Assert
.IsNull (ctor
, "#D9");
2608 ctor
= redType
.GetConstructor (flags
, null,
2609 new Type
[] { typeof (string), typeof (string) }
,
2610 new ParameterModifier
[0]);
2611 Assert
.IsNull (ctor
, "#D10");
2613 ctor
= redType
.GetConstructor (flags
, null,
2614 new Type
[] { typeof (int) }
,
2615 new ParameterModifier
[0]);
2616 Assert
.IsNull (ctor
, "#D11");
2618 ctor
= redType
.GetConstructor (flags
, null,
2619 new Type
[] { typeof (int), typeof (bool) }
,
2620 new ParameterModifier
[0]);
2621 Assert
.IsNull (ctor
, "#D12");
2623 ctor
= redType
.GetConstructor (flags
, null,
2624 new Type
[] { typeof (string), typeof (int) }
,
2625 new ParameterModifier
[0]);
2626 Assert
.IsNull (ctor
, "#D13");
2628 ctor
= redType
.GetConstructor (flags
, null,
2630 new ParameterModifier
[0]);
2631 Assert
.IsNotNull (ctor
, "#D14a");
2632 Assert
.IsTrue (ctor
.IsPrivate
, "#D14b");
2633 Assert
.IsTrue (ctor
.IsStatic
, "#B14c");
2634 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#B14d");
2635 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#B14e");
2637 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
2638 BindingFlags
.FlattenHierarchy
;
2640 ctor
= greenType
.GetConstructor (flags
, null,
2641 new Type
[] { typeof (int), typeof (int) }
,
2642 new ParameterModifier
[0]);
2643 Assert
.IsNull (ctor
, "#E1");
2645 ctor
= greenType
.GetConstructor (flags
, null,
2646 new Type
[] { typeof (string) }
,
2647 new ParameterModifier
[0]);
2648 Assert
.IsNull (ctor
, "#E2");
2650 ctor
= greenType
.GetConstructor (flags
, null,
2651 new Type
[] { typeof (string), typeof (string) }
,
2652 new ParameterModifier
[0]);
2653 Assert
.IsNull (ctor
, "#E3");
2655 ctor
= greenType
.GetConstructor (flags
, null,
2656 new Type
[] { typeof (int) }
,
2657 new ParameterModifier
[0]);
2658 Assert
.IsNull (ctor
, "#E4");
2660 ctor
= greenType
.GetConstructor (flags
, null,
2661 new Type
[] { typeof (int), typeof (bool) }
,
2662 new ParameterModifier
[0]);
2663 Assert
.IsNull (ctor
, "#E5");
2665 ctor
= greenType
.GetConstructor (flags
, null,
2666 new Type
[] { typeof (string), typeof (int) }
,
2667 new ParameterModifier
[0]);
2668 Assert
.IsNull (ctor
, "#E6");
2670 ctor
= greenType
.GetConstructor (flags
, null,
2672 new ParameterModifier
[0]);
2673 Assert
.IsNull (ctor
, "#E7");
2675 ctor
= redType
.GetConstructor (flags
, null,
2676 new Type
[] { typeof (int), typeof (int) }
,
2677 new ParameterModifier
[0]);
2678 Assert
.IsNotNull (ctor
, "#E8a");
2679 Assert
.IsTrue (ctor
.IsPrivate
, "#E8b");
2680 Assert
.IsFalse (ctor
.IsStatic
, "#E8c");
2681 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#E8d");
2682 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#E8e");
2684 ctor
= redType
.GetConstructor (flags
, null,
2685 new Type
[] { typeof (string) }
,
2686 new ParameterModifier
[0]);
2687 Assert
.IsNotNull (ctor
, "#E9a");
2688 Assert
.IsTrue (ctor
.IsFamily
, "#E9b");
2689 Assert
.IsFalse (ctor
.IsStatic
, "#E9c");
2690 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#E9d");
2691 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#E9e");
2693 ctor
= redType
.GetConstructor (flags
, null,
2694 new Type
[] { typeof (string), typeof (string) }
,
2695 new ParameterModifier
[0]);
2696 Assert
.IsNotNull (ctor
, "#E10a");
2697 Assert
.IsTrue (ctor
.IsFamilyAndAssembly
, "#E10b");
2698 Assert
.IsFalse (ctor
.IsStatic
, "#E10c");
2699 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#E10d");
2700 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#E10e");
2702 ctor
= redType
.GetConstructor (flags
, null,
2703 new Type
[] { typeof (int) }
,
2704 new ParameterModifier
[0]);
2705 Assert
.IsNotNull (ctor
, "#E11a");
2706 Assert
.IsTrue (ctor
.IsFamilyOrAssembly
, "#E11b");
2707 Assert
.IsFalse (ctor
.IsStatic
, "#E11c");
2708 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#E11d");
2709 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#E11e");
2711 ctor
= redType
.GetConstructor (flags
, null,
2712 new Type
[] { typeof (int), typeof (bool) }
,
2713 new ParameterModifier
[0]);
2714 Assert
.IsNull (ctor
, "#E12");
2716 ctor
= redType
.GetConstructor (flags
, null,
2717 new Type
[] { typeof (string), typeof (int) }
,
2718 new ParameterModifier
[0]);
2719 Assert
.IsNotNull (ctor
, "#E13a");
2720 Assert
.IsTrue (ctor
.IsAssembly
, "#E13b");
2721 Assert
.IsFalse (ctor
.IsStatic
, "#E13c");
2722 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#E13d");
2723 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#E13e");
2725 ctor
= redType
.GetConstructor (flags
, null,
2727 new ParameterModifier
[0]);
2728 Assert
.IsNull (ctor
, "#E14");
2730 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
2731 BindingFlags
.FlattenHierarchy
;
2733 ctor
= greenType
.GetConstructor (flags
, null,
2734 new Type
[] { typeof (int), typeof (int) }
,
2735 new ParameterModifier
[0]);
2736 Assert
.IsNull (ctor
, "#F1");
2738 ctor
= greenType
.GetConstructor (flags
, null,
2739 new Type
[] { typeof (string) }
,
2740 new ParameterModifier
[0]);
2741 Assert
.IsNull (ctor
, "#F2");
2743 ctor
= greenType
.GetConstructor (flags
, null,
2744 new Type
[] { typeof (string), typeof (string) }
,
2745 new ParameterModifier
[0]);
2746 Assert
.IsNull (ctor
, "#F3");
2748 ctor
= greenType
.GetConstructor (flags
, null,
2749 new Type
[] { typeof (int) }
,
2750 new ParameterModifier
[0]);
2751 Assert
.IsNull (ctor
, "#F4");
2753 ctor
= greenType
.GetConstructor (flags
, null,
2754 new Type
[] { typeof (int), typeof (bool) }
,
2755 new ParameterModifier
[0]);
2756 Assert
.IsNull (ctor
, "#F5");
2758 ctor
= greenType
.GetConstructor (flags
, null,
2759 new Type
[] { typeof (string), typeof (int) }
,
2760 new ParameterModifier
[0]);
2761 Assert
.IsNull (ctor
, "#F6");
2763 ctor
= greenType
.GetConstructor (flags
, null,
2765 new ParameterModifier
[0]);
2766 Assert
.IsNotNull (ctor
, "#F7a");
2767 Assert
.IsTrue (ctor
.IsPublic
, "#F7b");
2768 Assert
.IsFalse (ctor
.IsStatic
, "#F7c");
2769 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#F7d");
2770 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#F7e");
2772 ctor
= redType
.GetConstructor (flags
, null,
2773 new Type
[] { typeof (int), typeof (int) }
,
2774 new ParameterModifier
[0]);
2775 Assert
.IsNull (ctor
, "#F8");
2777 ctor
= redType
.GetConstructor (flags
, null,
2778 new Type
[] { typeof (string) }
,
2779 new ParameterModifier
[0]);
2780 Assert
.IsNull (ctor
, "#F9");
2782 ctor
= redType
.GetConstructor (flags
, null,
2783 new Type
[] { typeof (string), typeof (string) }
,
2784 new ParameterModifier
[0]);
2785 Assert
.IsNull (ctor
, "#F10");
2787 ctor
= redType
.GetConstructor (flags
, null,
2788 new Type
[] { typeof (int) }
,
2789 new ParameterModifier
[0]);
2790 Assert
.IsNull (ctor
, "#F11");
2792 ctor
= redType
.GetConstructor (flags
, null,
2793 new Type
[] { typeof (int), typeof (bool) }
,
2794 new ParameterModifier
[0]);
2795 Assert
.IsNotNull (ctor
, "#F12a");
2796 Assert
.IsTrue (ctor
.IsPublic
, "#F12b");
2797 Assert
.IsFalse (ctor
.IsStatic
, "#F12c");
2798 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#F12d");
2799 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#F12e");
2801 ctor
= redType
.GetConstructor (flags
, null,
2802 new Type
[] { typeof (string), typeof (int) }
,
2803 new ParameterModifier
[0]);
2804 Assert
.IsNull (ctor
, "#F13");
2806 ctor
= redType
.GetConstructor (flags
, null,
2808 new ParameterModifier
[0]);
2809 Assert
.IsNull (ctor
, "#F14");
2811 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
2812 BindingFlags
.FlattenHierarchy
;
2814 ctor
= greenType
.GetConstructor (flags
, null,
2815 new Type
[] { typeof (int), typeof (int) }
,
2816 new ParameterModifier
[0]);
2817 Assert
.IsNull (ctor
, "#G1");
2819 ctor
= greenType
.GetConstructor (flags
, null,
2820 new Type
[] { typeof (string) }
,
2821 new ParameterModifier
[0]);
2822 Assert
.IsNull (ctor
, "#G2");
2824 ctor
= greenType
.GetConstructor (flags
, null,
2825 new Type
[] { typeof (string), typeof (string) }
,
2826 new ParameterModifier
[0]);
2827 Assert
.IsNull (ctor
, "#G3");
2829 ctor
= greenType
.GetConstructor (flags
, null,
2830 new Type
[] { typeof (int) }
,
2831 new ParameterModifier
[0]);
2832 Assert
.IsNull (ctor
, "#G4");
2834 ctor
= greenType
.GetConstructor (flags
, null,
2835 new Type
[] { typeof (int), typeof (bool) }
,
2836 new ParameterModifier
[0]);
2837 Assert
.IsNull (ctor
, "#G5");
2839 ctor
= greenType
.GetConstructor (flags
, null,
2840 new Type
[] { typeof (string), typeof (int) }
,
2841 new ParameterModifier
[0]);
2842 Assert
.IsNull (ctor
, "#G6");
2844 ctor
= greenType
.GetConstructor (flags
, null,
2846 new ParameterModifier
[0]);
2847 Assert
.IsNull (ctor
, "#G7");
2849 ctor
= redType
.GetConstructor (flags
, null,
2850 new Type
[] { typeof (int), typeof (int) }
,
2851 new ParameterModifier
[0]);
2852 Assert
.IsNull (ctor
, "#G8");
2854 ctor
= redType
.GetConstructor (flags
, null,
2855 new Type
[] { typeof (string) }
,
2856 new ParameterModifier
[0]);
2857 Assert
.IsNull (ctor
, "#G9");
2859 ctor
= redType
.GetConstructor (flags
, null,
2860 new Type
[] { typeof (string), typeof (string) }
,
2861 new ParameterModifier
[0]);
2862 Assert
.IsNull (ctor
, "#G10");
2864 ctor
= redType
.GetConstructor (flags
, null,
2865 new Type
[] { typeof (int) }
,
2866 new ParameterModifier
[0]);
2867 Assert
.IsNull (ctor
, "#G11");
2869 ctor
= redType
.GetConstructor (flags
, null,
2870 new Type
[] { typeof (int), typeof (bool) }
,
2871 new ParameterModifier
[0]);
2872 Assert
.IsNull (ctor
, "#G12");
2874 ctor
= redType
.GetConstructor (flags
, null,
2875 new Type
[] { typeof (string), typeof (int) }
,
2876 new ParameterModifier
[0]);
2877 Assert
.IsNull (ctor
, "#G13");
2879 ctor
= redType
.GetConstructor (flags
, null,
2881 new ParameterModifier
[0]);
2882 Assert
.IsNull (ctor
, "#G14");
2884 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
2885 BindingFlags
.FlattenHierarchy
;
2887 ctor
= greenType
.GetConstructor (flags
, null,
2888 new Type
[] { typeof (int), typeof (int) }
,
2889 new ParameterModifier
[0]);
2890 Assert
.IsNull (ctor
, "#H1");
2892 ctor
= greenType
.GetConstructor (flags
, null,
2893 new Type
[] { typeof (string) }
,
2894 new ParameterModifier
[0]);
2895 Assert
.IsNull (ctor
, "#H2");
2897 ctor
= greenType
.GetConstructor (flags
, null,
2898 new Type
[] { typeof (string), typeof (string) }
,
2899 new ParameterModifier
[0]);
2900 Assert
.IsNull (ctor
, "#H3");
2902 ctor
= greenType
.GetConstructor (flags
, null,
2903 new Type
[] { typeof (int) }
,
2904 new ParameterModifier
[0]);
2905 Assert
.IsNull (ctor
, "#H4");
2907 ctor
= greenType
.GetConstructor (flags
, null,
2908 new Type
[] { typeof (int), typeof (bool) }
,
2909 new ParameterModifier
[0]);
2910 Assert
.IsNull (ctor
, "#H5");
2912 ctor
= greenType
.GetConstructor (flags
, null,
2913 new Type
[] { typeof (string), typeof (int) }
,
2914 new ParameterModifier
[0]);
2915 Assert
.IsNull (ctor
, "#H6");
2917 ctor
= greenType
.GetConstructor (flags
, null,
2919 new ParameterModifier
[0]);
2920 Assert
.IsNull (ctor
, "#H7");
2922 ctor
= redType
.GetConstructor (flags
, null,
2923 new Type
[] { typeof (int), typeof (int) }
,
2924 new ParameterModifier
[0]);
2925 Assert
.IsNull (ctor
, "#H8");
2927 ctor
= redType
.GetConstructor (flags
, null,
2928 new Type
[] { typeof (string) }
,
2929 new ParameterModifier
[0]);
2930 Assert
.IsNull (ctor
, "#H9");
2932 ctor
= redType
.GetConstructor (flags
, null,
2933 new Type
[] { typeof (string), typeof (string) }
,
2934 new ParameterModifier
[0]);
2935 Assert
.IsNull (ctor
, "#H10");
2937 ctor
= redType
.GetConstructor (flags
, null,
2938 new Type
[] { typeof (int) }
,
2939 new ParameterModifier
[0]);
2940 Assert
.IsNull (ctor
, "#H11");
2942 ctor
= redType
.GetConstructor (flags
, null,
2943 new Type
[] { typeof (int), typeof (bool) }
,
2944 new ParameterModifier
[0]);
2945 Assert
.IsNull (ctor
, "#H12");
2947 ctor
= redType
.GetConstructor (flags
, null,
2948 new Type
[] { typeof (string), typeof (int) }
,
2949 new ParameterModifier
[0]);
2950 Assert
.IsNull (ctor
, "#H13");
2952 ctor
= redType
.GetConstructor (flags
, null,
2954 new ParameterModifier
[0]);
2955 Assert
.IsNotNull (ctor
, "#H14");
2956 Assert
.IsTrue (ctor
.IsPrivate
, "#H14b");
2957 Assert
.IsTrue (ctor
.IsStatic
, "#H14c");
2958 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#H14d");
2959 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#H14e");
2961 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
2962 BindingFlags
.DeclaredOnly
;
2964 ctor
= greenType
.GetConstructor (flags
, null,
2965 new Type
[] { typeof (int), typeof (int) }
,
2966 new ParameterModifier
[0]);
2967 Assert
.IsNull (ctor
, "#I1");
2969 ctor
= greenType
.GetConstructor (flags
, null,
2970 new Type
[] { typeof (string) }
,
2971 new ParameterModifier
[0]);
2972 Assert
.IsNull (ctor
, "#I2");
2974 ctor
= greenType
.GetConstructor (flags
, null,
2975 new Type
[] { typeof (string), typeof (string) }
,
2976 new ParameterModifier
[0]);
2977 Assert
.IsNull (ctor
, "#I3");
2979 ctor
= greenType
.GetConstructor (flags
, null,
2980 new Type
[] { typeof (int) }
,
2981 new ParameterModifier
[0]);
2982 Assert
.IsNull (ctor
, "#I4");
2984 ctor
= greenType
.GetConstructor (flags
, null,
2985 new Type
[] { typeof (int), typeof (bool) }
,
2986 new ParameterModifier
[0]);
2987 Assert
.IsNull (ctor
, "#I5");
2989 ctor
= greenType
.GetConstructor (flags
, null,
2990 new Type
[] { typeof (string), typeof (int) }
,
2991 new ParameterModifier
[0]);
2992 Assert
.IsNull (ctor
, "#I6");
2994 ctor
= greenType
.GetConstructor (flags
, null,
2996 new ParameterModifier
[0]);
2997 Assert
.IsNull (ctor
, "#I7");
2999 ctor
= redType
.GetConstructor (flags
, null,
3000 new Type
[] { typeof (int), typeof (int) }
,
3001 new ParameterModifier
[0]);
3002 Assert
.IsNotNull (ctor
, "#I8a");
3003 Assert
.IsTrue (ctor
.IsPrivate
, "#I8b");
3004 Assert
.IsFalse (ctor
.IsStatic
, "#I8c");
3005 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#I8d");
3006 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#I8e");
3008 ctor
= redType
.GetConstructor (flags
, null,
3009 new Type
[] { typeof (string) }
,
3010 new ParameterModifier
[0]);
3011 Assert
.IsNotNull (ctor
, "#I9a");
3012 Assert
.IsTrue (ctor
.IsFamily
, "#I9b");
3013 Assert
.IsFalse (ctor
.IsStatic
, "#I9c");
3014 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#I9d");
3015 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#I9e");
3017 ctor
= redType
.GetConstructor (flags
, null,
3018 new Type
[] { typeof (string), typeof (string) }
,
3019 new ParameterModifier
[0]);
3020 Assert
.IsNotNull (ctor
, "#I10a");
3021 Assert
.IsTrue (ctor
.IsFamilyAndAssembly
, "#I10b");
3022 Assert
.IsFalse (ctor
.IsStatic
, "#I10c");
3023 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#I10d");
3024 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#I10e");
3026 ctor
= redType
.GetConstructor (flags
, null,
3027 new Type
[] { typeof (int) }
,
3028 new ParameterModifier
[0]);
3029 Assert
.IsNotNull (ctor
, "#I11a");
3030 Assert
.IsTrue (ctor
.IsFamilyOrAssembly
, "#I11b");
3031 Assert
.IsFalse (ctor
.IsStatic
, "#I11c");
3032 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#I11d");
3033 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#I11e");
3035 ctor
= redType
.GetConstructor (flags
, null,
3036 new Type
[] { typeof (int), typeof (bool) }
,
3037 new ParameterModifier
[0]);
3038 Assert
.IsNull (ctor
, "#I12");
3040 ctor
= redType
.GetConstructor (flags
, null,
3041 new Type
[] { typeof (string), typeof (int) }
,
3042 new ParameterModifier
[0]);
3043 Assert
.IsNotNull (ctor
, "#I13a");
3044 Assert
.IsTrue (ctor
.IsAssembly
, "#I13b");
3045 Assert
.IsFalse (ctor
.IsStatic
, "#I13c");
3046 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#I13d");
3047 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#I13e");
3049 ctor
= redType
.GetConstructor (flags
, null,
3051 new ParameterModifier
[0]);
3052 Assert
.IsNull (ctor
, "#I14");
3054 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
3055 BindingFlags
.DeclaredOnly
;
3057 ctor
= greenType
.GetConstructor (flags
, null,
3058 new Type
[] { typeof (int), typeof (int) }
,
3059 new ParameterModifier
[0]);
3060 Assert
.IsNull (ctor
, "#J1");
3062 ctor
= greenType
.GetConstructor (flags
, null,
3063 new Type
[] { typeof (string) }
,
3064 new ParameterModifier
[0]);
3065 Assert
.IsNull (ctor
, "#J2");
3067 ctor
= greenType
.GetConstructor (flags
, null,
3068 new Type
[] { typeof (string), typeof (string) }
,
3069 new ParameterModifier
[0]);
3070 Assert
.IsNull (ctor
, "#J3");
3072 ctor
= greenType
.GetConstructor (flags
, null,
3073 new Type
[] { typeof (int) }
,
3074 new ParameterModifier
[0]);
3075 Assert
.IsNull (ctor
, "#J4");
3077 ctor
= greenType
.GetConstructor (flags
, null,
3078 new Type
[] { typeof (int), typeof (bool) }
,
3079 new ParameterModifier
[0]);
3080 Assert
.IsNull (ctor
, "#J5");
3082 ctor
= greenType
.GetConstructor (flags
, null,
3083 new Type
[] { typeof (string), typeof (int) }
,
3084 new ParameterModifier
[0]);
3085 Assert
.IsNull (ctor
, "#J6");
3087 ctor
= greenType
.GetConstructor (flags
, null,
3089 new ParameterModifier
[0]);
3090 Assert
.IsNotNull (ctor
, "#J7a");
3091 Assert
.IsTrue (ctor
.IsPublic
, "#J7b");
3092 Assert
.IsFalse (ctor
.IsStatic
, "#J7c");
3093 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#J7d");
3094 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#J7e");
3096 ctor
= redType
.GetConstructor (flags
, null,
3097 new Type
[] { typeof (int), typeof (int) }
,
3098 new ParameterModifier
[0]);
3099 Assert
.IsNull (ctor
, "#J8");
3101 ctor
= redType
.GetConstructor (flags
, null,
3102 new Type
[] { typeof (string) }
,
3103 new ParameterModifier
[0]);
3104 Assert
.IsNull (ctor
, "#J9");
3106 ctor
= redType
.GetConstructor (flags
, null,
3107 new Type
[] { typeof (string), typeof (string) }
,
3108 new ParameterModifier
[0]);
3109 Assert
.IsNull (ctor
, "#J10");
3111 ctor
= redType
.GetConstructor (flags
, null,
3112 new Type
[] { typeof (int) }
,
3113 new ParameterModifier
[0]);
3114 Assert
.IsNull (ctor
, "#J11");
3116 ctor
= redType
.GetConstructor (flags
, null,
3117 new Type
[] { typeof (int), typeof (bool) }
,
3118 new ParameterModifier
[0]);
3119 Assert
.IsNotNull (ctor
, "#J12a");
3120 Assert
.IsTrue (ctor
.IsPublic
, "#J12b");
3121 Assert
.IsFalse (ctor
.IsStatic
, "#J12c");
3122 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#J12d");
3123 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#J12e");
3125 ctor
= redType
.GetConstructor (flags
, null,
3126 new Type
[] { typeof (string), typeof (int) }
,
3127 new ParameterModifier
[0]);
3128 Assert
.IsNull (ctor
, "#J13");
3130 ctor
= redType
.GetConstructor (flags
, null,
3132 new ParameterModifier
[0]);
3133 Assert
.IsNull (ctor
, "#J14");
3135 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
3136 BindingFlags
.DeclaredOnly
;
3138 ctor
= greenType
.GetConstructor (flags
, null,
3139 new Type
[] { typeof (int), typeof (int) }
,
3140 new ParameterModifier
[0]);
3141 Assert
.IsNull (ctor
, "#K1");
3143 ctor
= greenType
.GetConstructor (flags
, null,
3144 new Type
[] { typeof (string) }
,
3145 new ParameterModifier
[0]);
3146 Assert
.IsNull (ctor
, "#K2");
3148 ctor
= greenType
.GetConstructor (flags
, null,
3149 new Type
[] { typeof (string), typeof (string) }
,
3150 new ParameterModifier
[0]);
3151 Assert
.IsNull (ctor
, "#K3");
3153 ctor
= greenType
.GetConstructor (flags
, null,
3154 new Type
[] { typeof (int) }
,
3155 new ParameterModifier
[0]);
3156 Assert
.IsNull (ctor
, "#K4");
3158 ctor
= greenType
.GetConstructor (flags
, null,
3159 new Type
[] { typeof (int), typeof (bool) }
,
3160 new ParameterModifier
[0]);
3161 Assert
.IsNull (ctor
, "#K5");
3163 ctor
= greenType
.GetConstructor (flags
, null,
3164 new Type
[] { typeof (string), typeof (int) }
,
3165 new ParameterModifier
[0]);
3166 Assert
.IsNull (ctor
, "#K6");
3168 ctor
= greenType
.GetConstructor (flags
, null,
3170 new ParameterModifier
[0]);
3171 Assert
.IsNull (ctor
, "#K7");
3173 ctor
= redType
.GetConstructor (flags
, null,
3174 new Type
[] { typeof (int), typeof (int) }
,
3175 new ParameterModifier
[0]);
3176 Assert
.IsNull (ctor
, "#K8");
3178 ctor
= redType
.GetConstructor (flags
, null,
3179 new Type
[] { typeof (string) }
,
3180 new ParameterModifier
[0]);
3181 Assert
.IsNull (ctor
, "#K9");
3183 ctor
= redType
.GetConstructor (flags
, null,
3184 new Type
[] { typeof (string), typeof (string) }
,
3185 new ParameterModifier
[0]);
3186 Assert
.IsNull (ctor
, "#K10");
3188 ctor
= redType
.GetConstructor (flags
, null,
3189 new Type
[] { typeof (int) }
,
3190 new ParameterModifier
[0]);
3191 Assert
.IsNull (ctor
, "#K11");
3193 ctor
= redType
.GetConstructor (flags
, null,
3194 new Type
[] { typeof (int), typeof (bool) }
,
3195 new ParameterModifier
[0]);
3196 Assert
.IsNull (ctor
, "#K12");
3198 ctor
= redType
.GetConstructor (flags
, null,
3199 new Type
[] { typeof (string), typeof (int) }
,
3200 new ParameterModifier
[0]);
3201 Assert
.IsNull (ctor
, "#K13");
3203 ctor
= redType
.GetConstructor (flags
, null,
3205 new ParameterModifier
[0]);
3206 Assert
.IsNull (ctor
, "#K14");
3208 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
3209 BindingFlags
.DeclaredOnly
;
3211 ctor
= greenType
.GetConstructor (flags
, null,
3212 new Type
[] { typeof (int), typeof (int) }
,
3213 new ParameterModifier
[0]);
3214 Assert
.IsNull (ctor
, "#L1");
3216 ctor
= greenType
.GetConstructor (flags
, null,
3217 new Type
[] { typeof (string) }
,
3218 new ParameterModifier
[0]);
3219 Assert
.IsNull (ctor
, "#L2");
3221 ctor
= greenType
.GetConstructor (flags
, null,
3222 new Type
[] { typeof (string), typeof (string) }
,
3223 new ParameterModifier
[0]);
3224 Assert
.IsNull (ctor
, "#L3");
3226 ctor
= greenType
.GetConstructor (flags
, null,
3227 new Type
[] { typeof (int) }
,
3228 new ParameterModifier
[0]);
3229 Assert
.IsNull (ctor
, "#L4");
3231 ctor
= greenType
.GetConstructor (flags
, null,
3232 new Type
[] { typeof (int), typeof (bool) }
,
3233 new ParameterModifier
[0]);
3234 Assert
.IsNull (ctor
, "#L5");
3236 ctor
= greenType
.GetConstructor (flags
, null,
3237 new Type
[] { typeof (string), typeof (int) }
,
3238 new ParameterModifier
[0]);
3239 Assert
.IsNull (ctor
, "#L6");
3241 ctor
= greenType
.GetConstructor (flags
, null,
3243 new ParameterModifier
[0]);
3244 Assert
.IsNull (ctor
, "#L7");
3246 ctor
= redType
.GetConstructor (flags
, null,
3247 new Type
[] { typeof (int), typeof (int) }
,
3248 new ParameterModifier
[0]);
3249 Assert
.IsNull (ctor
, "#L8");
3251 ctor
= redType
.GetConstructor (flags
, null,
3252 new Type
[] { typeof (string) }
,
3253 new ParameterModifier
[0]);
3254 Assert
.IsNull (ctor
, "#L9");
3256 ctor
= redType
.GetConstructor (flags
, null,
3257 new Type
[] { typeof (string), typeof (string) }
,
3258 new ParameterModifier
[0]);
3259 Assert
.IsNull (ctor
, "#L10");
3261 ctor
= redType
.GetConstructor (flags
, null,
3262 new Type
[] { typeof (int) }
,
3263 new ParameterModifier
[0]);
3264 Assert
.IsNull (ctor
, "#L11");
3266 ctor
= redType
.GetConstructor (flags
, null,
3267 new Type
[] { typeof (int), typeof (bool) }
,
3268 new ParameterModifier
[0]);
3269 Assert
.IsNull (ctor
, "#L12");
3271 ctor
= redType
.GetConstructor (flags
, null,
3272 new Type
[] { typeof (string), typeof (int) }
,
3273 new ParameterModifier
[0]);
3274 Assert
.IsNull (ctor
, "#L13");
3276 ctor
= redType
.GetConstructor (flags
, null,
3278 new ParameterModifier
[0]);
3279 Assert
.IsNotNull (ctor
, "#L14a");
3280 Assert
.IsTrue (ctor
.IsPrivate
, "#L14b");
3281 Assert
.IsTrue (ctor
.IsStatic
, "#L14c");
3282 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#L14d");
3283 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#L14e");
3285 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
3286 BindingFlags
.Public
;
3288 ctor
= greenType
.GetConstructor (flags
, null,
3289 new Type
[] { typeof (int), typeof (int) }
,
3290 new ParameterModifier
[0]);
3291 Assert
.IsNull (ctor
, "#M1");
3293 ctor
= greenType
.GetConstructor (flags
, null,
3294 new Type
[] { typeof (string) }
,
3295 new ParameterModifier
[0]);
3296 Assert
.IsNull (ctor
, "#M2");
3298 ctor
= greenType
.GetConstructor (flags
, null,
3299 new Type
[] { typeof (string), typeof (string) }
,
3300 new ParameterModifier
[0]);
3301 Assert
.IsNull (ctor
, "#M3");
3303 ctor
= greenType
.GetConstructor (flags
, null,
3304 new Type
[] { typeof (int) }
,
3305 new ParameterModifier
[0]);
3306 Assert
.IsNull (ctor
, "#M4");
3308 ctor
= greenType
.GetConstructor (flags
, null,
3309 new Type
[] { typeof (int), typeof (bool) }
,
3310 new ParameterModifier
[0]);
3311 Assert
.IsNull (ctor
, "#M5");
3313 ctor
= greenType
.GetConstructor (flags
, null,
3314 new Type
[] { typeof (string), typeof (int) }
,
3315 new ParameterModifier
[0]);
3316 Assert
.IsNull (ctor
, "#M6");
3318 ctor
= greenType
.GetConstructor (flags
, null,
3320 new ParameterModifier
[0]);
3321 Assert
.IsNotNull (ctor
, "#M7a");
3322 Assert
.IsTrue (ctor
.IsPublic
, "#M7b");
3323 Assert
.IsFalse (ctor
.IsStatic
, "#M7c");
3324 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#M7d");
3325 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#M7e");
3327 ctor
= redType
.GetConstructor (flags
, null,
3328 new Type
[] { typeof (int), typeof (int) }
,
3329 new ParameterModifier
[0]);
3330 Assert
.IsNotNull (ctor
, "#M8a");
3331 Assert
.IsTrue (ctor
.IsPrivate
, "#M8b");
3332 Assert
.IsFalse (ctor
.IsStatic
, "#M8c");
3333 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#M8d");
3334 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#M8e");
3336 ctor
= redType
.GetConstructor (flags
, null,
3337 new Type
[] { typeof (string) }
,
3338 new ParameterModifier
[0]);
3339 Assert
.IsNotNull (ctor
, "#M9a");
3340 Assert
.IsTrue (ctor
.IsFamily
, "#M9b");
3341 Assert
.IsFalse (ctor
.IsStatic
, "#M9c");
3342 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#M9d");
3343 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#M9e");
3345 ctor
= redType
.GetConstructor (flags
, null,
3346 new Type
[] { typeof (string), typeof (string) }
,
3347 new ParameterModifier
[0]);
3348 Assert
.IsNotNull (ctor
, "#M10a");
3349 Assert
.IsTrue (ctor
.IsFamilyAndAssembly
, "#M10b");
3350 Assert
.IsFalse (ctor
.IsStatic
, "#M10c");
3351 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#M10d");
3352 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#M10e");
3354 ctor
= redType
.GetConstructor (flags
, null,
3355 new Type
[] { typeof (int) }
,
3356 new ParameterModifier
[0]);
3357 Assert
.IsNotNull (ctor
, "#M11a");
3358 Assert
.IsTrue (ctor
.IsFamilyOrAssembly
, "#M11b");
3359 Assert
.IsFalse (ctor
.IsStatic
, "#M11c");
3360 Assert
.AreEqual (1, ctor
.GetParameters ().Length
, "#M11d");
3361 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#M11e");
3363 ctor
= redType
.GetConstructor (flags
, null,
3364 new Type
[] { typeof (int), typeof (bool) }
,
3365 new ParameterModifier
[0]);
3366 Assert
.IsNotNull (ctor
, "#M12a");
3367 Assert
.IsTrue (ctor
.IsPublic
, "#M12b");
3368 Assert
.IsFalse (ctor
.IsStatic
, "#M12c");
3369 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#M12d");
3370 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#M12e");
3372 ctor
= redType
.GetConstructor (flags
, null,
3373 new Type
[] { typeof (string), typeof (int) }
,
3374 new ParameterModifier
[0]);
3375 Assert
.IsNotNull (ctor
, "#M13a");
3376 Assert
.IsTrue (ctor
.IsAssembly
, "#M13b");
3377 Assert
.IsFalse (ctor
.IsStatic
, "#M13c");
3378 Assert
.AreEqual (2, ctor
.GetParameters ().Length
, "#M13d");
3379 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#M13e");
3381 ctor
= redType
.GetConstructor (flags
, null,
3383 new ParameterModifier
[0]);
3384 Assert
.IsNull (ctor
, "#M14");
3386 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
3387 BindingFlags
.Public
;
3389 ctor
= greenType
.GetConstructor (flags
, null,
3390 new Type
[] { typeof (int), typeof (int) }
,
3391 new ParameterModifier
[0]);
3392 Assert
.IsNull (ctor
, "#N1");
3394 ctor
= greenType
.GetConstructor (flags
, null,
3395 new Type
[] { typeof (string) }
,
3396 new ParameterModifier
[0]);
3397 Assert
.IsNull (ctor
, "#N2");
3399 ctor
= greenType
.GetConstructor (flags
, null,
3400 new Type
[] { typeof (string), typeof (string) }
,
3401 new ParameterModifier
[0]);
3402 Assert
.IsNull (ctor
, "#N3");
3404 ctor
= greenType
.GetConstructor (flags
, null,
3405 new Type
[] { typeof (int) }
,
3406 new ParameterModifier
[0]);
3407 Assert
.IsNull (ctor
, "#N4");
3409 ctor
= greenType
.GetConstructor (flags
, null,
3410 new Type
[] { typeof (int), typeof (bool) }
,
3411 new ParameterModifier
[0]);
3412 Assert
.IsNull (ctor
, "#N5");
3414 ctor
= greenType
.GetConstructor (flags
, null,
3415 new Type
[] { typeof (string), typeof (int) }
,
3416 new ParameterModifier
[0]);
3417 Assert
.IsNull (ctor
, "#N6");
3419 ctor
= greenType
.GetConstructor (flags
, null,
3421 new ParameterModifier
[0]);
3422 Assert
.IsNull (ctor
, "#N7");
3424 ctor
= redType
.GetConstructor (flags
, null,
3425 new Type
[] { typeof (int), typeof (int) }
,
3426 new ParameterModifier
[0]);
3427 Assert
.IsNull (ctor
, "#N8");
3429 ctor
= redType
.GetConstructor (flags
, null,
3430 new Type
[] { typeof (string) }
,
3431 new ParameterModifier
[0]);
3432 Assert
.IsNull (ctor
, "#N9");
3434 ctor
= redType
.GetConstructor (flags
, null,
3435 new Type
[] { typeof (string), typeof (string) }
,
3436 new ParameterModifier
[0]);
3437 Assert
.IsNull (ctor
, "#N10");
3439 ctor
= redType
.GetConstructor (flags
, null,
3440 new Type
[] { typeof (int) }
,
3441 new ParameterModifier
[0]);
3442 Assert
.IsNull (ctor
, "#N11");
3444 ctor
= redType
.GetConstructor (flags
, null,
3445 new Type
[] { typeof (int), typeof (bool) }
,
3446 new ParameterModifier
[0]);
3447 Assert
.IsNull (ctor
, "#N12");
3449 ctor
= redType
.GetConstructor (flags
, null,
3450 new Type
[] { typeof (string), typeof (int) }
,
3451 new ParameterModifier
[0]);
3452 Assert
.IsNull (ctor
, "#N13");
3454 ctor
= redType
.GetConstructor (flags
, null,
3456 new ParameterModifier
[0]);
3457 Assert
.IsNotNull (ctor
, "#N14a");
3458 Assert
.IsTrue (ctor
.IsPrivate
, "#N14b");
3459 Assert
.IsTrue (ctor
.IsStatic
, "#N14c");
3460 Assert
.AreEqual (0, ctor
.GetParameters ().Length
, "#N14d");
3461 Assert
.IsFalse (ctor
is ConstructorBuilder
, "#N14e");
3464 [Test
] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
3465 public void GetConstructor2_Incomplete ()
3467 TypeBuilder tb
= module
.DefineType (genTypeName ());
3468 ConstructorBuilder cb
= tb
.DefineConstructor (
3469 MethodAttributes
.Public
,
3470 CallingConventions
.Standard
,
3472 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
3475 tb
.GetConstructor (BindingFlags
.Public
| BindingFlags
.Instance
,
3476 null, Type
.EmptyTypes
, new ParameterModifier
[0]);
3478 } catch (NotSupportedException ex
) {
3479 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3480 Assert
.IsNull (ex
.InnerException
, "#3");
3481 Assert
.IsNotNull (ex
.Message
, "#4");
3485 [Test
] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
3486 public void GetConstructor3_Incomplete ()
3488 TypeBuilder tb
= module
.DefineType (genTypeName ());
3489 ConstructorBuilder cb
= tb
.DefineConstructor (
3490 MethodAttributes
.Public
,
3491 CallingConventions
.Standard
,
3493 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
3496 tb
.GetConstructor (BindingFlags
.Public
| BindingFlags
.Instance
,
3497 null, CallingConventions
.Standard
, Type
.EmptyTypes
,
3498 new ParameterModifier
[0]);
3500 } catch (NotSupportedException ex
) {
3501 // The invoked member is not supported in a
3503 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3504 Assert
.IsNull (ex
.InnerException
, "#3");
3505 Assert
.IsNotNull (ex
.Message
, "#4");
3509 [Test
] // GetConstructors ()
3510 [Category ("NotWorking")] // mcs depends on this
3511 public void GetConstructors1_Incomplete ()
3513 TypeBuilder tb
= module
.DefineType (genTypeName ());
3514 ConstructorBuilder cb
= tb
.DefineConstructor (
3515 MethodAttributes
.Public
,
3516 CallingConventions
.Standard
,
3518 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
3521 tb
.GetConstructors ();
3523 } catch (NotSupportedException ex
) {
3524 // The invoked member is not supported in a
3526 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3527 Assert
.IsNull (ex
.InnerException
, "#3");
3528 Assert
.IsNotNull (ex
.Message
, "#4");
3532 [Test
] // GetConstructors (BindingFlags)
3533 public void GetConstructors2_Complete ()
3536 ConstructorInfo
[] ctors
;
3538 TypeBuilder redType
= module
.DefineType (genTypeName (),
3539 TypeAttributes
.Public
);
3540 CreateMembers (redType
, "Red", true);
3542 TypeBuilder greenType
= module
.DefineType (genTypeName (),
3543 TypeAttributes
.Public
, redType
);
3544 CreateMembers (greenType
, "Green", false);
3545 ConstructorBuilder cb
= greenType
.DefineConstructor (
3546 MethodAttributes
.Public
,
3547 CallingConventions
.Standard
,
3549 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
3551 redType
.CreateType ();
3552 greenType
.CreateType ();
3554 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
3556 ctors
= greenType
.GetConstructors (flags
);
3557 Assert
.AreEqual (0, ctors
.Length
, "#A1");
3559 ctors
= redType
.GetConstructors (flags
);
3560 Assert
.AreEqual (5, ctors
.Length
, "#A2");
3561 Assert
.IsTrue (ctors
[0].IsPrivate
, "#A3a");
3562 Assert
.IsFalse (ctors
[0].IsStatic
, "#A3b");
3563 Assert
.AreEqual (2, ctors
[0].GetParameters ().Length
, "#A3c");
3564 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#A3d");
3565 Assert
.IsTrue (ctors
[1].IsFamily
, "#A4a");
3566 Assert
.IsFalse (ctors
[1].IsStatic
, "#A4b");
3567 Assert
.AreEqual (1, ctors
[1].GetParameters ().Length
, "#A4c");
3568 Assert
.IsFalse (ctors
[1] is ConstructorBuilder
, "#A4d");
3569 Assert
.IsTrue (ctors
[2].IsFamilyAndAssembly
, "#A5a");
3570 Assert
.IsFalse (ctors
[2].IsStatic
, "#A5b");
3571 Assert
.AreEqual (2, ctors
[2].GetParameters ().Length
, "#A5c");
3572 Assert
.IsFalse (ctors
[2] is ConstructorBuilder
, "#A5d");
3573 Assert
.IsTrue (ctors
[3].IsFamilyOrAssembly
, "#A6a");
3574 Assert
.IsFalse (ctors
[3].IsStatic
, "#A6b");
3575 Assert
.AreEqual (1, ctors
[3].GetParameters ().Length
, "#A6c");
3576 Assert
.IsFalse (ctors
[3] is ConstructorBuilder
, "#A6d");
3577 Assert
.IsTrue (ctors
[4].IsAssembly
, "#A7a");
3578 Assert
.IsFalse (ctors
[4].IsStatic
, "#A7b");
3579 Assert
.AreEqual (2, ctors
[4].GetParameters ().Length
, "#A7c");
3580 Assert
.IsFalse (ctors
[4] is ConstructorBuilder
, "#A7d");
3582 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
3584 ctors
= greenType
.GetConstructors (flags
);
3585 Assert
.AreEqual (1, ctors
.Length
, "#B1");
3586 Assert
.IsTrue (ctors
[0].IsPublic
, "#B2a");
3587 Assert
.IsFalse (ctors
[0].IsStatic
, "#B2b");
3588 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#B2c");
3589 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#B2d");
3591 ctors
= redType
.GetConstructors (flags
);
3592 Assert
.AreEqual (1, ctors
.Length
, "#B3");
3593 Assert
.IsTrue (ctors
[0].IsPublic
, "#B4a");
3594 Assert
.IsFalse (ctors
[0].IsStatic
, "#B4b");
3595 Assert
.AreEqual (2, ctors
[0].GetParameters ().Length
, "#B4c");
3596 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#B4d");
3598 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
3600 ctors
= greenType
.GetConstructors (flags
);
3601 Assert
.AreEqual (0, ctors
.Length
, "#C1");
3603 ctors
= redType
.GetConstructors (flags
);
3604 Assert
.AreEqual (0, ctors
.Length
, "#C2");
3606 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
3608 ctors
= greenType
.GetConstructors (flags
);
3609 Assert
.AreEqual (0, ctors
.Length
, "#D1");
3611 ctors
= redType
.GetConstructors (flags
);
3612 Assert
.AreEqual (1, ctors
.Length
, "#D2");
3613 Assert
.IsTrue (ctors
[0].IsPrivate
, "#D3a");
3614 Assert
.IsTrue (ctors
[0].IsStatic
, "#D3b");
3615 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#D3c");
3616 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#D3d");
3618 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
3619 BindingFlags
.FlattenHierarchy
;
3621 ctors
= greenType
.GetConstructors (flags
);
3622 Assert
.AreEqual (0, ctors
.Length
, "#E1");
3624 ctors
= redType
.GetConstructors (flags
);
3625 Assert
.AreEqual (5, ctors
.Length
, "#E2");
3626 Assert
.IsTrue (ctors
[0].IsPrivate
, "#E3a");
3627 Assert
.IsFalse (ctors
[0].IsStatic
, "#E3b");
3628 Assert
.AreEqual (2, ctors
[0].GetParameters ().Length
, "#E3c");
3629 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#E3d");
3630 Assert
.IsTrue (ctors
[1].IsFamily
, "#E4a");
3631 Assert
.IsFalse (ctors
[1].IsStatic
, "#E4b");
3632 Assert
.AreEqual (1, ctors
[1].GetParameters ().Length
, "#E4c");
3633 Assert
.IsFalse (ctors
[1] is ConstructorBuilder
, "#E4d");
3634 Assert
.IsTrue (ctors
[2].IsFamilyAndAssembly
, "#E5a");
3635 Assert
.IsFalse (ctors
[2].IsStatic
, "#A5b");
3636 Assert
.AreEqual (2, ctors
[2].GetParameters ().Length
, "#E5c");
3637 Assert
.IsFalse (ctors
[2] is ConstructorBuilder
, "#E5d");
3638 Assert
.IsTrue (ctors
[3].IsFamilyOrAssembly
, "#E6a");
3639 Assert
.IsFalse (ctors
[3].IsStatic
, "#E6b");
3640 Assert
.AreEqual (1, ctors
[3].GetParameters ().Length
, "#E6c");
3641 Assert
.IsFalse (ctors
[3] is ConstructorBuilder
, "#E6d");
3642 Assert
.IsTrue (ctors
[4].IsAssembly
, "#E7a");
3643 Assert
.IsFalse (ctors
[4].IsStatic
, "#E7b");
3644 Assert
.AreEqual (2, ctors
[4].GetParameters ().Length
, "#E7c");
3645 Assert
.IsFalse (ctors
[4] is ConstructorBuilder
, "#E7d");
3647 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
3648 BindingFlags
.FlattenHierarchy
;
3650 ctors
= greenType
.GetConstructors (flags
);
3651 Assert
.AreEqual (1, ctors
.Length
, "#F1");
3652 Assert
.IsTrue (ctors
[0].IsPublic
, "#F2a");
3653 Assert
.IsFalse (ctors
[0].IsStatic
, "#F2b");
3654 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#F2c");
3655 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#F2d");
3657 ctors
= redType
.GetConstructors (flags
);
3658 Assert
.AreEqual (1, ctors
.Length
, "#F3");
3659 Assert
.IsTrue (ctors
[0].IsPublic
, "#F4a");
3660 Assert
.IsFalse (ctors
[0].IsStatic
, "#F4b");
3661 Assert
.AreEqual (2, ctors
[0].GetParameters ().Length
, "#F4c");
3662 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#F4d");
3664 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
3665 BindingFlags
.FlattenHierarchy
;
3667 ctors
= greenType
.GetConstructors (flags
);
3668 Assert
.AreEqual (0, ctors
.Length
, "#G1");
3670 ctors
= redType
.GetConstructors (flags
);
3671 Assert
.AreEqual (0, ctors
.Length
, "#G2");
3673 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
3674 BindingFlags
.FlattenHierarchy
;
3676 ctors
= greenType
.GetConstructors (flags
);
3677 Assert
.AreEqual (0, ctors
.Length
, "#H1");
3679 ctors
= redType
.GetConstructors (flags
);
3680 Assert
.AreEqual (1, ctors
.Length
, "#H2");
3681 Assert
.IsTrue (ctors
[0].IsPrivate
, "#H3a");
3682 Assert
.IsTrue (ctors
[0].IsStatic
, "#H3b");
3683 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#H3c");
3684 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#H3d");
3686 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
3687 BindingFlags
.DeclaredOnly
;
3689 ctors
= greenType
.GetConstructors (flags
);
3690 Assert
.AreEqual (0, ctors
.Length
, "#I1");
3692 ctors
= redType
.GetConstructors (flags
);
3693 Assert
.AreEqual (5, ctors
.Length
, "#I2");
3694 Assert
.IsTrue (ctors
[0].IsPrivate
, "#I3a");
3695 Assert
.IsFalse (ctors
[0].IsStatic
, "#I3b");
3696 Assert
.AreEqual (2, ctors
[0].GetParameters ().Length
, "#I3c");
3697 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#I3d");
3698 Assert
.IsTrue (ctors
[1].IsFamily
, "#I4a");
3699 Assert
.IsFalse (ctors
[1].IsStatic
, "#I4b");
3700 Assert
.AreEqual (1, ctors
[1].GetParameters ().Length
, "#I4c");
3701 Assert
.IsFalse (ctors
[1] is ConstructorBuilder
, "#I4d");
3702 Assert
.IsTrue (ctors
[2].IsFamilyAndAssembly
, "#I5a");
3703 Assert
.IsFalse (ctors
[2].IsStatic
, "#I5b");
3704 Assert
.AreEqual (2, ctors
[2].GetParameters ().Length
, "#I5c");
3705 Assert
.IsFalse (ctors
[2] is ConstructorBuilder
, "#I5d");
3706 Assert
.IsTrue (ctors
[3].IsFamilyOrAssembly
, "#I6a");
3707 Assert
.IsFalse (ctors
[3].IsStatic
, "#I6b");
3708 Assert
.AreEqual (1, ctors
[3].GetParameters ().Length
, "#I6c");
3709 Assert
.IsFalse (ctors
[3] is ConstructorBuilder
, "#I6d");
3710 Assert
.IsTrue (ctors
[4].IsAssembly
, "#I7a");
3711 Assert
.IsFalse (ctors
[4].IsStatic
, "#I7b");
3712 Assert
.AreEqual (2, ctors
[4].GetParameters ().Length
, "#I7c");
3713 Assert
.IsFalse (ctors
[4] is ConstructorBuilder
, "#I7d");
3715 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
3716 BindingFlags
.DeclaredOnly
;
3718 ctors
= greenType
.GetConstructors (flags
);
3719 Assert
.AreEqual (1, ctors
.Length
, "#J1");
3720 Assert
.IsTrue (ctors
[0].IsPublic
, "#J2a");
3721 Assert
.IsFalse (ctors
[0].IsStatic
, "#J2b");
3722 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#J2c");
3723 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#J2d");
3725 ctors
= redType
.GetConstructors (flags
);
3726 Assert
.AreEqual (1, ctors
.Length
, "#J3");
3727 Assert
.IsTrue (ctors
[0].IsPublic
, "#J4a");
3728 Assert
.IsFalse (ctors
[0].IsStatic
, "#J4b");
3729 Assert
.AreEqual (2, ctors
[0].GetParameters ().Length
, "#J4c");
3730 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#J4d");
3732 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
3733 BindingFlags
.DeclaredOnly
;
3735 ctors
= greenType
.GetConstructors (flags
);
3736 Assert
.AreEqual (0, ctors
.Length
, "#K1");
3738 ctors
= redType
.GetConstructors (flags
);
3739 Assert
.AreEqual (0, ctors
.Length
, "#K2");
3741 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
3742 BindingFlags
.DeclaredOnly
;
3744 ctors
= greenType
.GetConstructors (flags
);
3745 Assert
.AreEqual (0, ctors
.Length
, "#L1");
3747 ctors
= redType
.GetConstructors (flags
);
3748 Assert
.AreEqual (1, ctors
.Length
, "#L2");
3749 Assert
.IsTrue (ctors
[0].IsPrivate
, "#L3a");
3750 Assert
.IsTrue (ctors
[0].IsStatic
, "#L3b");
3751 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#L3c");
3752 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#L3d");
3754 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
3755 BindingFlags
.Public
;
3757 ctors
= greenType
.GetConstructors (flags
);
3758 Assert
.AreEqual (1, ctors
.Length
, "#M1");
3759 Assert
.IsTrue (ctors
[0].IsPublic
, "#M2a");
3760 Assert
.IsFalse (ctors
[0].IsStatic
, "#M2b");
3761 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#M2c");
3762 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#M2d");
3764 ctors
= redType
.GetConstructors (flags
);
3765 Assert
.AreEqual (6, ctors
.Length
, "#M3");
3766 Assert
.IsTrue (ctors
[0].IsPrivate
, "#M4a");
3767 Assert
.IsFalse (ctors
[0].IsStatic
, "#M4b");
3768 Assert
.AreEqual (2, ctors
[0].GetParameters ().Length
, "#M4c");
3769 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#M4d");
3770 Assert
.IsTrue (ctors
[1].IsFamily
, "#M5a");
3771 Assert
.IsFalse (ctors
[1].IsStatic
, "#M5b");
3772 Assert
.AreEqual (1, ctors
[1].GetParameters ().Length
, "#M5c");
3773 Assert
.IsFalse (ctors
[1] is ConstructorBuilder
, "#M5d");
3774 Assert
.IsTrue (ctors
[2].IsFamilyAndAssembly
, "#M6a");
3775 Assert
.IsFalse (ctors
[2].IsStatic
, "#M6b");
3776 Assert
.AreEqual (2, ctors
[2].GetParameters ().Length
, "#M6c");
3777 Assert
.IsFalse (ctors
[2] is ConstructorBuilder
, "#M6d");
3778 Assert
.IsTrue (ctors
[3].IsFamilyOrAssembly
, "#M7a");
3779 Assert
.IsFalse (ctors
[3].IsStatic
, "#M7b");
3780 Assert
.AreEqual (1, ctors
[3].GetParameters ().Length
, "#M7c");
3781 Assert
.IsFalse (ctors
[3] is ConstructorBuilder
, "#M7d");
3782 Assert
.IsTrue (ctors
[4].IsPublic
, "#M8a");
3783 Assert
.IsFalse (ctors
[4].IsStatic
, "#M8b");
3784 Assert
.AreEqual (2, ctors
[4].GetParameters ().Length
, "#M8c");
3785 Assert
.IsFalse (ctors
[4] is ConstructorBuilder
, "#M8d");
3786 Assert
.IsTrue (ctors
[5].IsAssembly
, "#M9a");
3787 Assert
.IsFalse (ctors
[5].IsStatic
, "#M9b");
3788 Assert
.AreEqual (2, ctors
[5].GetParameters ().Length
, "#M9c");
3789 Assert
.IsFalse (ctors
[5] is ConstructorBuilder
, "#M9d");
3791 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
3792 BindingFlags
.Public
;
3794 ctors
= greenType
.GetConstructors (flags
);
3795 Assert
.AreEqual (0, ctors
.Length
, "#N1");
3797 ctors
= redType
.GetConstructors (flags
);
3798 Assert
.AreEqual (1, ctors
.Length
, "#N2");
3799 Assert
.IsTrue (ctors
[0].IsPrivate
, "#N3a");
3800 Assert
.IsTrue (ctors
[0].IsStatic
, "#N3b");
3801 Assert
.AreEqual (0, ctors
[0].GetParameters ().Length
, "#N3c");
3802 Assert
.IsFalse (ctors
[0] is ConstructorBuilder
, "#N3d");
3805 [Test
] // GetConstructors (BindingFlags)
3806 [Category ("NotWorking")] // mcs depends on this
3807 public void GetConstructors2_Incomplete ()
3809 TypeBuilder tb
= module
.DefineType (genTypeName ());
3810 ConstructorBuilder cb
= tb
.DefineConstructor (
3811 MethodAttributes
.Public
,
3812 CallingConventions
.Standard
,
3814 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
3817 tb
.GetConstructors (BindingFlags
.Public
|
3818 BindingFlags
.Instance
);
3820 } catch (NotSupportedException ex
) {
3821 // The invoked member is not supported in a
3823 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3824 Assert
.IsNull (ex
.InnerException
, "#3");
3825 Assert
.IsNotNull (ex
.Message
, "#4");
3830 public void TestGetCustomAttributesIncomplete ()
3832 TypeBuilder tb
= module
.DefineType (genTypeName ());
3834 tb
.GetCustomAttributes (false);
3836 } catch (NotSupportedException ex
) {
3837 // The invoked member is not supported in a
3839 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3840 Assert
.IsNull (ex
.InnerException
, "#3");
3841 Assert
.IsNotNull (ex
.Message
, "#4");
3846 public void TestGetCustomAttributesComplete ()
3848 TypeBuilder tb
= module
.DefineType (genTypeName ());
3850 ConstructorInfo guidCtor
= typeof (GuidAttribute
).GetConstructor (
3851 new Type
[] { typeof (string) }
);
3853 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (guidCtor
,
3854 new object [] { Guid.NewGuid ().ToString ("D") }
, new FieldInfo
[0], new object [0]);
3856 tb
.SetCustomAttribute (caBuilder
);
3859 Assert
.AreEqual (1, tb
.GetCustomAttributes (false).Length
);
3863 public void TestGetCustomAttributesOfTypeIncomplete ()
3865 TypeBuilder tb
= module
.DefineType (genTypeName ());
3867 tb
.GetCustomAttributes (typeof (ObsoleteAttribute
), false);
3869 } catch (NotSupportedException ex
) {
3870 // The invoked member is not supported in a
3872 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3873 Assert
.IsNull (ex
.InnerException
, "#3");
3874 Assert
.IsNotNull (ex
.Message
, "#4");
3879 public void TestGetCustomAttributesOfTypeComplete ()
3881 TypeBuilder tb
= module
.DefineType (genTypeName ());
3883 ConstructorInfo guidCtor
= typeof (GuidAttribute
).GetConstructor (
3884 new Type
[] { typeof (string) }
);
3886 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (guidCtor
,
3887 new object [] { Guid.NewGuid ().ToString ("D") }
, new FieldInfo
[0], new object [0]);
3889 tb
.SetCustomAttribute (caBuilder
);
3892 Assert
.AreEqual (1, tb
.GetCustomAttributes (typeof (GuidAttribute
), false).Length
, "#1");
3893 Assert
.AreEqual (0, tb
.GetCustomAttributes (typeof (ObsoleteAttribute
), false).Length
, "#2");
3897 public void TestGetCustomAttributesOfNullTypeComplete ()
3899 TypeBuilder tb
= module
.DefineType (genTypeName ());
3902 tb
.GetCustomAttributes (null, false);
3904 } catch (ArgumentNullException ex
) {
3905 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
3906 Assert
.IsNull (ex
.InnerException
, "#3");
3907 Assert
.IsNotNull (ex
.Message
, "#4");
3908 Assert
.AreEqual ("attributeType", ex
.ParamName
, "#5");
3913 [Ignore ("mcs depends on this")]
3914 public void TestGetEventsIncomplete ()
3916 TypeBuilder tb
= module
.DefineType (genTypeName ());
3920 } catch (NotSupportedException ex
) {
3921 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3922 Assert
.IsNull (ex
.InnerException
, "#3");
3923 Assert
.IsNotNull (ex
.Message
, "#4");
3929 public void TestGetEventsComplete ()
3931 TypeBuilder tb
= module
.DefineType (genTypeName ());
3933 MethodBuilder onclickMethod
= tb
.DefineMethod ("OnChange", MethodAttributes
.Public
,
3934 typeof (void), new Type
[] { typeof (Object) }
);
3935 onclickMethod
.GetILGenerator ().Emit (OpCodes
.Ret
);
3937 // create public event
3938 EventBuilder eventbuilder
= tb
.DefineEvent ("Change", EventAttributes
.None
,
3939 typeof (ResolveEventHandler
));
3940 eventbuilder
.SetRaiseMethod (onclickMethod
);
3942 Type emittedType
= tb
.CreateType ();
3944 Assert
.AreEqual (1, tb
.GetEvents ().Length
, "#1");
3945 Assert
.AreEqual (tb
.GetEvents ().Length
, emittedType
.GetEvents ().Length
, "#2");
3950 [Ignore ("mcs depends on this")]
3951 public void TestGetEventsFlagsIncomplete ()
3953 TypeBuilder tb
= module
.DefineType (genTypeName ());
3955 tb
.GetEvents (BindingFlags
.Public
);
3957 } catch (NotSupportedException ex
) {
3958 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
3959 Assert
.IsNull (ex
.InnerException
, "#3");
3960 Assert
.IsNotNull (ex
.Message
, "#4");
3966 public void TestGetEventsFlagsComplete ()
3968 TypeBuilder tb
= module
.DefineType (genTypeName ());
3970 MethodBuilder onchangeMethod
= tb
.DefineMethod ("OnChange", MethodAttributes
.Public
,
3971 typeof (void), new Type
[] { typeof (Object) }
);
3972 onchangeMethod
.GetILGenerator ().Emit (OpCodes
.Ret
);
3974 // create public event
3975 EventBuilder changeEvent
= tb
.DefineEvent ("Change", EventAttributes
.None
,
3976 typeof (ResolveEventHandler
));
3977 changeEvent
.SetRaiseMethod (onchangeMethod
);
3979 // create non-public event
3980 EventBuilder redoChangeEvent
= tb
.DefineEvent ("RedoChange", EventAttributes
.None
,
3981 typeof (ResolveEventHandler
));
3983 Type emittedType
= tb
.CreateType ();
3985 Assert
.AreEqual (1, tb
.GetEvents (BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
3986 Assert
.AreEqual (1, tb
.GetEvents (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
3987 Assert
.AreEqual (2, tb
.GetEvents (BindingFlags
.Instance
| BindingFlags
.Public
| BindingFlags
.NonPublic
).Length
);
3988 Assert
.AreEqual (tb
.GetEvents (BindingFlags
.Instance
| BindingFlags
.Public
).Length
,
3989 emittedType
.GetEvents (BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
3990 Assert
.AreEqual (tb
.GetEvents (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
,
3991 emittedType
.GetEvents (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
3992 Assert
.AreEqual (tb
.GetEvents (BindingFlags
.Instance
| BindingFlags
.Public
| BindingFlags
.NonPublic
).Length
,
3993 emittedType
.GetEvents (BindingFlags
.Instance
| BindingFlags
.Public
| BindingFlags
.NonPublic
).Length
);
3997 public void TestGetEventsFlagsComplete_Inheritance ()
3999 EventInfo
[] events
;
4002 TypeBuilder blueType
= module
.DefineType (genTypeName (),
4003 TypeAttributes
.Public
);
4004 CreateMembers (blueType
, "Blue", false);
4006 TypeBuilder redType
= module
.DefineType (genTypeName (),
4007 TypeAttributes
.Public
, blueType
);
4008 CreateMembers (redType
, "Red", false);
4010 TypeBuilder greenType
= module
.DefineType (genTypeName (),
4011 TypeAttributes
.Public
, redType
);
4012 CreateMembers (greenType
, "Green", false);
4014 blueType
.CreateType ();
4015 redType
.CreateType ();
4016 greenType
.CreateType ();
4018 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
4019 events
= greenType
.GetEvents (flags
);
4021 Assert
.AreEqual (13, events
.Length
, "#A1");
4022 Assert
.AreEqual ("OnPrivateInstanceGreen", events
[0].Name
, "#A2");
4023 Assert
.AreEqual ("OnFamilyInstanceGreen", events
[1].Name
, "#A3");
4024 Assert
.AreEqual ("OnFamANDAssemInstanceGreen", events
[2].Name
, "#A4");
4025 Assert
.AreEqual ("OnFamORAssemInstanceGreen", events
[3].Name
, "#A5");
4026 Assert
.AreEqual ("OnAssemblyInstanceGreen", events
[4].Name
, "#A6");
4027 Assert
.AreEqual ("OnFamilyInstanceRed", events
[5].Name
, "#A7");
4028 Assert
.AreEqual ("OnFamANDAssemInstanceRed", events
[6].Name
, "#A8");
4029 Assert
.AreEqual ("OnFamORAssemInstanceRed", events
[7].Name
, "#A9");
4030 Assert
.AreEqual ("OnAssemblyInstanceRed", events
[8].Name
, "#A10");
4031 Assert
.AreEqual ("OnFamilyInstanceBlue", events
[9].Name
, "#A11");
4032 Assert
.AreEqual ("OnFamANDAssemInstanceBlue", events
[10].Name
, "#A12");
4033 Assert
.AreEqual ("OnFamORAssemInstanceBlue", events
[11].Name
, "#A13");
4034 Assert
.AreEqual ("OnAssemblyInstanceBlue", events
[12].Name
, "#A14");
4036 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
4037 events
= greenType
.GetEvents (flags
);
4039 Assert
.AreEqual (3, events
.Length
, "#B1");
4040 Assert
.AreEqual ("OnPublicInstanceGreen", events
[0].Name
, "#B2");
4041 Assert
.AreEqual ("OnPublicInstanceRed", events
[1].Name
, "#B3");
4042 Assert
.AreEqual ("OnPublicInstanceBlue", events
[2].Name
, "#B4");
4044 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
4045 events
= greenType
.GetEvents (flags
);
4047 Assert
.AreEqual (1, events
.Length
, "#C1");
4048 Assert
.AreEqual ("OnPublicStaticGreen", events
[0].Name
, "#C2");
4050 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
4051 events
= greenType
.GetEvents (flags
);
4053 Assert
.AreEqual (5, events
.Length
, "#D1");
4054 Assert
.AreEqual ("OnPrivateStaticGreen", events
[0].Name
, "#D2");
4055 Assert
.AreEqual ("OnFamilyStaticGreen", events
[1].Name
, "#D3");
4056 Assert
.AreEqual ("OnFamANDAssemStaticGreen", events
[2].Name
, "#D4");
4057 Assert
.AreEqual ("OnFamORAssemStaticGreen", events
[3].Name
, "#D5");
4058 Assert
.AreEqual ("OnAssemblyStaticGreen", events
[4].Name
, "#D6");
4060 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
4061 BindingFlags
.FlattenHierarchy
;
4062 events
= greenType
.GetEvents (flags
);
4064 Assert
.AreEqual (13, events
.Length
, "#E1");
4065 Assert
.AreEqual ("OnPrivateInstanceGreen", events
[0].Name
, "#E2");
4066 Assert
.AreEqual ("OnFamilyInstanceGreen", events
[1].Name
, "#E3");
4067 Assert
.AreEqual ("OnFamANDAssemInstanceGreen", events
[2].Name
, "#E4");
4068 Assert
.AreEqual ("OnFamORAssemInstanceGreen", events
[3].Name
, "#E5");
4069 Assert
.AreEqual ("OnAssemblyInstanceGreen", events
[4].Name
, "#E6");
4070 Assert
.AreEqual ("OnFamilyInstanceRed", events
[5].Name
, "#E7");
4071 Assert
.AreEqual ("OnFamANDAssemInstanceRed", events
[6].Name
, "#E8");
4072 Assert
.AreEqual ("OnFamORAssemInstanceRed", events
[7].Name
, "#E9");
4073 Assert
.AreEqual ("OnAssemblyInstanceRed", events
[8].Name
, "#E10");
4074 Assert
.AreEqual ("OnFamilyInstanceBlue", events
[9].Name
, "#E11");
4075 Assert
.AreEqual ("OnFamANDAssemInstanceBlue", events
[10].Name
, "#E12");
4076 Assert
.AreEqual ("OnFamORAssemInstanceBlue", events
[11].Name
, "#E13");
4077 Assert
.AreEqual ("OnAssemblyInstanceBlue", events
[12].Name
, "#E14");
4079 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
4080 BindingFlags
.FlattenHierarchy
;
4081 events
= greenType
.GetEvents (flags
);
4083 Assert
.AreEqual (3, events
.Length
, "#F1");
4084 Assert
.AreEqual ("OnPublicInstanceGreen", events
[0].Name
, "#F2");
4085 Assert
.AreEqual ("OnPublicInstanceRed", events
[1].Name
, "#F3");
4086 Assert
.AreEqual ("OnPublicInstanceBlue", events
[2].Name
, "#F4");
4088 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
4089 BindingFlags
.FlattenHierarchy
;
4090 events
= greenType
.GetEvents (flags
);
4092 Assert
.AreEqual (3, events
.Length
, "#G1");
4093 Assert
.AreEqual ("OnPublicStaticGreen", events
[0].Name
, "#G2");
4094 Assert
.AreEqual ("OnPublicStaticRed", events
[1].Name
, "#G3");
4095 Assert
.AreEqual ("OnPublicStaticBlue", events
[2].Name
, "#G4");
4097 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
4098 BindingFlags
.FlattenHierarchy
;
4099 events
= greenType
.GetEvents (flags
);
4101 Assert
.AreEqual (13, events
.Length
, "#H1");
4102 Assert
.AreEqual ("OnPrivateStaticGreen", events
[0].Name
, "#H2");
4103 Assert
.AreEqual ("OnFamilyStaticGreen", events
[1].Name
, "#H3");
4104 Assert
.AreEqual ("OnFamANDAssemStaticGreen", events
[2].Name
, "#H4");
4105 Assert
.AreEqual ("OnFamORAssemStaticGreen", events
[3].Name
, "#H5");
4106 Assert
.AreEqual ("OnAssemblyStaticGreen", events
[4].Name
, "#H6");
4107 Assert
.AreEqual ("OnFamilyStaticRed", events
[5].Name
, "#H7");
4108 Assert
.AreEqual ("OnFamANDAssemStaticRed", events
[6].Name
, "#H8");
4109 Assert
.AreEqual ("OnFamORAssemStaticRed", events
[7].Name
, "#H9");
4110 Assert
.AreEqual ("OnAssemblyStaticRed", events
[8].Name
, "#H10");
4111 Assert
.AreEqual ("OnFamilyStaticBlue", events
[9].Name
, "#H11");
4112 Assert
.AreEqual ("OnFamANDAssemStaticBlue", events
[10].Name
, "#H12");
4113 Assert
.AreEqual ("OnFamORAssemStaticBlue", events
[11].Name
, "#H13");
4114 Assert
.AreEqual ("OnAssemblyStaticBlue", events
[12].Name
, "#H14");
4116 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
4117 BindingFlags
.DeclaredOnly
;
4118 events
= greenType
.GetEvents (flags
);
4120 Assert
.AreEqual (5, events
.Length
, "#I1");
4121 Assert
.AreEqual ("OnPrivateInstanceGreen", events
[0].Name
, "#I2");
4122 Assert
.AreEqual ("OnFamilyInstanceGreen", events
[1].Name
, "#I3");
4123 Assert
.AreEqual ("OnFamANDAssemInstanceGreen", events
[2].Name
, "#I4");
4124 Assert
.AreEqual ("OnFamORAssemInstanceGreen", events
[3].Name
, "#I5");
4125 Assert
.AreEqual ("OnAssemblyInstanceGreen", events
[4].Name
, "#I6");
4127 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
4128 BindingFlags
.DeclaredOnly
;
4129 events
= greenType
.GetEvents (flags
);
4131 Assert
.AreEqual (1, events
.Length
, "#J1");
4132 Assert
.AreEqual ("OnPublicInstanceGreen", events
[0].Name
, "#J2");
4134 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
4135 BindingFlags
.DeclaredOnly
;
4136 events
= greenType
.GetEvents (flags
);
4138 Assert
.AreEqual (1, events
.Length
, "#K1");
4139 Assert
.AreEqual ("OnPublicStaticGreen", events
[0].Name
, "#K2");
4141 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
4142 BindingFlags
.DeclaredOnly
;
4143 events
= greenType
.GetEvents (flags
);
4145 Assert
.AreEqual (5, events
.Length
, "#L1");
4146 Assert
.AreEqual ("OnPrivateStaticGreen", events
[0].Name
, "#L2");
4147 Assert
.AreEqual ("OnFamilyStaticGreen", events
[1].Name
, "#L3");
4148 Assert
.AreEqual ("OnFamANDAssemStaticGreen", events
[2].Name
, "#L4");
4149 Assert
.AreEqual ("OnFamORAssemStaticGreen", events
[3].Name
, "#L5");
4150 Assert
.AreEqual ("OnAssemblyStaticGreen", events
[4].Name
, "#L6");
4152 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
4153 BindingFlags
.Public
;
4154 events
= greenType
.GetEvents (flags
);
4156 Assert
.AreEqual (16, events
.Length
, "#M1");
4157 Assert
.AreEqual ("OnPrivateInstanceGreen", events
[0].Name
, "#M2");
4158 Assert
.AreEqual ("OnFamilyInstanceGreen", events
[1].Name
, "#M3");
4159 Assert
.AreEqual ("OnFamANDAssemInstanceGreen", events
[2].Name
, "#M4");
4160 Assert
.AreEqual ("OnFamORAssemInstanceGreen", events
[3].Name
, "#M5");
4161 Assert
.AreEqual ("OnPublicInstanceGreen", events
[4].Name
, "#M6");
4162 Assert
.AreEqual ("OnAssemblyInstanceGreen", events
[5].Name
, "#M7");
4163 Assert
.AreEqual ("OnFamilyInstanceRed", events
[6].Name
, "#M8");
4164 Assert
.AreEqual ("OnFamANDAssemInstanceRed", events
[7].Name
, "#M9");
4165 Assert
.AreEqual ("OnFamORAssemInstanceRed", events
[8].Name
, "#M10");
4166 Assert
.AreEqual ("OnPublicInstanceRed", events
[9].Name
, "#M11");
4167 Assert
.AreEqual ("OnAssemblyInstanceRed", events
[10].Name
, "#M12");
4168 Assert
.AreEqual ("OnFamilyInstanceBlue", events
[11].Name
, "#M13");
4169 Assert
.AreEqual ("OnFamANDAssemInstanceBlue", events
[12].Name
, "#M14");
4170 Assert
.AreEqual ("OnFamORAssemInstanceBlue", events
[13].Name
, "#M15");
4171 Assert
.AreEqual ("OnPublicInstanceBlue", events
[14].Name
, "#M16");
4172 Assert
.AreEqual ("OnAssemblyInstanceBlue", events
[15].Name
, "#M17");
4174 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
4175 BindingFlags
.Public
;
4176 events
= greenType
.GetEvents (flags
);
4178 Assert
.AreEqual (6, events
.Length
, "#N1");
4179 Assert
.AreEqual ("OnPrivateStaticGreen", events
[0].Name
, "#N2");
4180 Assert
.AreEqual ("OnFamilyStaticGreen", events
[1].Name
, "#N3");
4181 Assert
.AreEqual ("OnFamANDAssemStaticGreen", events
[2].Name
, "#N4");
4182 Assert
.AreEqual ("OnFamORAssemStaticGreen", events
[3].Name
, "#N5");
4183 Assert
.AreEqual ("OnPublicStaticGreen", events
[4].Name
, "#N6");
4184 Assert
.AreEqual ("OnAssemblyStaticGreen", events
[5].Name
, "#N7");
4188 [Ignore ("mcs depends on this")]
4189 public void TestGetEventIncomplete ()
4191 TypeBuilder tb
= module
.DefineType (genTypeName ());
4193 tb
.GetEvent ("FOO");
4195 } catch (NotSupportedException ex
) {
4196 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
4197 Assert
.IsNull (ex
.InnerException
, "#3");
4198 Assert
.IsNotNull (ex
.Message
, "#4");
4204 public void TestGetEventComplete ()
4206 TypeBuilder tb
= module
.DefineType (genTypeName ());
4208 MethodBuilder onclickMethod
= tb
.DefineMethod ("OnChange", MethodAttributes
.Public
,
4209 typeof (void), new Type
[] { typeof (Object) }
);
4210 onclickMethod
.GetILGenerator ().Emit (OpCodes
.Ret
);
4212 EventBuilder eventbuilder
= tb
.DefineEvent ("Change", EventAttributes
.None
,
4213 typeof (ResolveEventHandler
));
4214 eventbuilder
.SetRaiseMethod (onclickMethod
);
4216 Type emittedType
= tb
.CreateType ();
4218 Assert
.IsNotNull (tb
.GetEvent ("Change"));
4219 Assert
.AreEqual (tb
.GetEvent ("Change"), emittedType
.GetEvent ("Change"));
4220 Assert
.IsNull (tb
.GetEvent ("NotChange"));
4221 Assert
.AreEqual (tb
.GetEvent ("NotChange"), emittedType
.GetEvent ("NotChange"));
4225 [Ignore ("mcs depends on this")]
4226 public void TestGetEventFlagsIncomplete ()
4228 TypeBuilder tb
= module
.DefineType (genTypeName ());
4230 tb
.GetEvent ("FOO", BindingFlags
.Public
);
4232 } catch (NotSupportedException ex
) {
4233 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
4234 Assert
.IsNull (ex
.InnerException
, "#3");
4235 Assert
.IsNotNull (ex
.Message
, "#4");
4241 public void TestGetEventFlagsComplete ()
4243 TypeBuilder tb
= module
.DefineType (genTypeName ());
4245 MethodBuilder onclickMethod
= tb
.DefineMethod ("OnChange", MethodAttributes
.Public
,
4246 typeof (void), new Type
[] { typeof (Object) }
);
4247 onclickMethod
.GetILGenerator ().Emit (OpCodes
.Ret
);
4249 EventBuilder eventbuilder
= tb
.DefineEvent ("Change", EventAttributes
.None
,
4250 typeof (ResolveEventHandler
));
4251 eventbuilder
.SetRaiseMethod (onclickMethod
);
4253 Type emittedType
= tb
.CreateType ();
4255 Assert
.IsNotNull (tb
.GetEvent ("Change", BindingFlags
.Instance
| BindingFlags
.Public
));
4256 Assert
.AreEqual (tb
.GetEvent ("Change", BindingFlags
.Instance
| BindingFlags
.Public
),
4257 emittedType
.GetEvent ("Change", BindingFlags
.Instance
| BindingFlags
.Public
));
4258 Assert
.IsNull (tb
.GetEvent ("Change", BindingFlags
.Instance
| BindingFlags
.NonPublic
));
4259 Assert
.AreEqual (tb
.GetEvent ("Change", BindingFlags
.Instance
| BindingFlags
.NonPublic
),
4260 emittedType
.GetEvent ("Change", BindingFlags
.Instance
| BindingFlags
.NonPublic
));
4264 public void TestGetEventFlagsComplete_Inheritance ()
4268 TypeBuilder blueType
= module
.DefineType (genTypeName (),
4269 TypeAttributes
.Public
);
4270 CreateMembers (blueType
, "Blue", false);
4272 TypeBuilder redType
= module
.DefineType (genTypeName (),
4273 TypeAttributes
.Public
, blueType
);
4274 CreateMembers (redType
, "Red", false);
4276 TypeBuilder greenType
= module
.DefineType (genTypeName (),
4277 TypeAttributes
.Public
, redType
);
4278 CreateMembers (greenType
, "Green", false);
4280 blueType
.CreateType ();
4281 redType
.CreateType ();
4282 greenType
.CreateType ();
4284 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
4286 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#A1");
4287 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#A2");
4288 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#A3");
4289 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#A4");
4290 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#A5");
4291 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#A6");
4292 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#A7");
4293 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#A8");
4294 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#A9");
4295 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#A10");
4296 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#A11");
4297 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#A12");
4298 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#A13");
4299 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#A14");
4300 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#A15");
4301 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#A16");
4302 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#A17");
4303 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#A18");
4304 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#A19");
4305 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#A20");
4306 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#A21");
4307 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#A22");
4308 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#A23");
4309 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#A24");
4310 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#A25");
4311 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#A26");
4312 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#A27");
4313 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#A28");
4314 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#A29");
4315 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#A30");
4316 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#A31");
4317 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#A32");
4318 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#A33");
4319 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#A34");
4320 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#A35");
4321 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#A36");
4323 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
4325 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#B1");
4326 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#B2");
4327 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#B3");
4328 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#B4");
4329 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#B5");
4330 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#B6");
4331 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#B7");
4332 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#B8");
4333 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#B9");
4334 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#B10");
4335 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#B11");
4336 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#B12");
4337 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#B13");
4338 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#B14");
4339 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#B15");
4340 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#B16");
4341 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#B17");
4342 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#B18");
4343 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#B19");
4344 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#B20");
4345 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#B21");
4346 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#B22");
4347 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#B23");
4348 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#B24");
4349 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#B25");
4350 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#B26");
4351 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#B27");
4352 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#B28");
4353 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#B29");
4354 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#B30");
4355 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#B31");
4356 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#B32");
4357 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#B33");
4358 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#B34");
4359 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#B35");
4360 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#B36");
4362 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
4364 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#C1");
4365 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#C2");
4366 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#C3");
4367 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#C4");
4368 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#C5");
4369 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#C6");
4370 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#C7");
4371 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#C8");
4372 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#C9");
4373 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#C10");
4374 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#C11");
4375 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#C12");
4376 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#C13");
4377 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#C14");
4378 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#C15");
4379 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#C16");
4380 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#C17");
4381 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#C18");
4382 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#C19");
4383 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#C20");
4384 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#C21");
4385 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#C22");
4386 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#C23");
4387 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#C24");
4388 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#C25");
4389 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#C26");
4390 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#C27");
4391 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#C28");
4392 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#C29");
4393 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#C30");
4394 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#C31");
4395 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#C32");
4396 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#C33");
4397 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#C34");
4398 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#C35");
4399 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#C36");
4401 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
4403 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#D1");
4404 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#D2");
4405 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#D3");
4406 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#D4");
4407 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#D5");
4408 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#D6");
4409 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#D7");
4410 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#D8");
4411 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#D9");
4412 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#D10");
4413 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#D11");
4414 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#D12");
4415 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#D13");
4416 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#D14");
4417 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#D15");
4418 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#D16");
4419 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#D17");
4420 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#D18");
4421 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#D19");
4422 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#D20");
4423 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#D21");
4424 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#D22");
4425 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#D23");
4426 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#D24");
4427 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#D25");
4428 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#D26");
4429 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#D27");
4430 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#D28");
4431 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#D29");
4432 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#D30");
4433 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#D31");
4434 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#D32");
4435 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#D33");
4436 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#D34");
4437 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#D35");
4438 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#D36");
4440 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
4441 BindingFlags
.FlattenHierarchy
;
4443 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#E1");
4444 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#E2");
4445 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#E3");
4446 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#E4");
4447 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#E5");
4448 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#E6");
4449 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#E7");
4450 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#E8");
4451 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#E9");
4452 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#E10");
4453 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#E11");
4454 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#E12");
4455 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#E13");
4456 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#E14");
4457 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#E15");
4458 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#E16");
4459 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#E17");
4460 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#E18");
4461 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#E19");
4462 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#E20");
4463 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#E21");
4464 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#E22");
4465 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#E23");
4466 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#E24");
4467 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#E25");
4468 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#E26");
4469 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#E27");
4470 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#E28");
4471 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#E29");
4472 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#E30");
4473 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#E31");
4474 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#E32");
4475 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#E33");
4476 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#E34");
4477 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#E35");
4478 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#E36");
4480 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
4481 BindingFlags
.FlattenHierarchy
;
4483 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#F1");
4484 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#F2");
4485 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#F3");
4486 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#F4");
4487 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#F5");
4488 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#F6");
4489 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#F7");
4490 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#F8");
4491 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#F9");
4492 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#F10");
4493 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#F11");
4494 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#F12");
4495 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#F13");
4496 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#F14");
4497 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#F15");
4498 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#F16");
4499 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#F17");
4500 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#F18");
4501 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#F19");
4502 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#F20");
4503 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#F21");
4504 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#F22");
4505 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#F23");
4506 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#F24");
4507 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#F25");
4508 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#F26");
4509 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#F27");
4510 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#F28");
4511 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#F29");
4512 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#F30");
4513 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#F31");
4514 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#F32");
4515 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#F33");
4516 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#F34");
4517 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#F35");
4518 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#F36");
4520 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
4521 BindingFlags
.FlattenHierarchy
;
4523 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#G1");
4524 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#G2");
4525 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#G3");
4526 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#G4");
4527 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#G5");
4528 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#G6");
4529 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#G7");
4530 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#G8");
4531 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#G9");
4532 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#G10");
4533 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#G11");
4534 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#G12");
4535 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#G13");
4536 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#G14");
4537 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#G15");
4538 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#G16");
4539 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#G17");
4540 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#G18");
4541 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#G19");
4542 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#G20");
4543 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#G21");
4544 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#G22");
4545 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#G23");
4546 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#G24");
4547 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#G25");
4548 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#G26");
4549 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#G27");
4550 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#G28");
4551 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#G29");
4552 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#G30");
4553 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#G31");
4554 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#G32");
4555 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#G33");
4556 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#G34");
4557 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#G35");
4558 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#G36");
4560 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
4561 BindingFlags
.FlattenHierarchy
;
4563 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#H1");
4564 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#H2");
4565 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#H3");
4566 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#H4");
4567 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#H5");
4568 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#H6");
4569 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#H7");
4570 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#H8");
4571 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#H9");
4572 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#H10");
4573 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#H11");
4574 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#H12");
4575 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#H13");
4576 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#H14");
4577 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#H15");
4578 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#H16");
4579 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#H17");
4580 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#H18");
4581 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#H19");
4582 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#H20");
4583 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#H21");
4584 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#H22");
4585 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#H23");
4586 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#H24");
4587 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#H25");
4588 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#H26");
4589 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#H27");
4590 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#H28");
4591 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#H29");
4592 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#H30");
4593 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#H31");
4594 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#H32");
4595 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#H33");
4596 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#H34");
4597 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#H35");
4598 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#H36");
4600 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
4601 BindingFlags
.DeclaredOnly
;
4603 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#I1");
4604 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#I2");
4605 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#I3");
4606 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#I4");
4607 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#I5");
4608 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#I6");
4609 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#I7");
4610 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#I8");
4611 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#I9");
4612 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#I10");
4613 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#I11");
4614 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#I12");
4615 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#I13");
4616 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#I14");
4617 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#I15");
4618 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#I16");
4619 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#I17");
4620 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#I18");
4621 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#I19");
4622 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#I20");
4623 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#I21");
4624 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#I22");
4625 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#I23");
4626 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#I24");
4627 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#I25");
4628 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#I26");
4629 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#I27");
4630 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#I28");
4631 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#I29");
4632 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#I30");
4633 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#I31");
4634 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#I32");
4635 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#I33");
4636 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#I34");
4637 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#I35");
4638 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#I36");
4640 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
4641 BindingFlags
.DeclaredOnly
;
4643 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#J1");
4644 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#J2");
4645 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#J3");
4646 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#J4");
4647 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#J5");
4648 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#J6");
4649 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#J7");
4650 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#J8");
4651 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#J9");
4652 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#J10");
4653 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#J11");
4654 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#J12");
4655 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#J13");
4656 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#J14");
4657 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#J15");
4658 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#J16");
4659 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#J17");
4660 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#J18");
4661 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#J19");
4662 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#J20");
4663 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#J21");
4664 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#J22");
4665 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#J23");
4666 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#J24");
4667 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#J25");
4668 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#J26");
4669 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#J27");
4670 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#J28");
4671 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#J29");
4672 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#J30");
4673 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#J31");
4674 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#J32");
4675 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#J33");
4676 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#J34");
4677 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#J35");
4678 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#J36");
4680 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
4681 BindingFlags
.DeclaredOnly
;
4683 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#K1");
4684 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#K2");
4685 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#K3");
4686 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#K4");
4687 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#K5");
4688 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#K6");
4689 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#K7");
4690 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#K8");
4691 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#K9");
4692 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#K10");
4693 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#K11");
4694 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#K12");
4695 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#K13");
4696 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#K14");
4697 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#K15");
4698 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#K16");
4699 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#K17");
4700 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#K18");
4701 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#K19");
4702 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#K20");
4703 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#K21");
4704 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#K22");
4705 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#K23");
4706 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#K24");
4707 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#K25");
4708 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#K26");
4709 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#K27");
4710 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#K28");
4711 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#K29");
4712 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#K30");
4713 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#K31");
4714 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#K32");
4715 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#K33");
4716 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#K34");
4717 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#K35");
4718 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#K36");
4720 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
4721 BindingFlags
.DeclaredOnly
;
4723 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#L1");
4724 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#L2");
4725 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#L3");
4726 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#L4");
4727 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#L5");
4728 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#L6");
4729 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#L7");
4730 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#L8");
4731 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#L9");
4732 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#L10");
4733 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#L11");
4734 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#L12");
4735 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#L13");
4736 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#L14");
4737 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#L15");
4738 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#L16");
4739 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#L17");
4740 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#L18");
4741 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#L19");
4742 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#L20");
4743 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#L21");
4744 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#L22");
4745 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#L23");
4746 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#L24");
4747 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#L25");
4748 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#L26");
4749 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#L27");
4750 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#L28");
4751 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#L29");
4752 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#L30");
4753 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#L31");
4754 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#L32");
4755 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#L33");
4756 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#L34");
4757 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#L35");
4758 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#L36");
4760 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
4761 BindingFlags
.Public
;
4763 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#M1");
4764 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#M2");
4765 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#M3");
4766 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#M4");
4767 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#M5");
4768 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#M6");
4769 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#M7");
4770 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#M8");
4771 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#M9");
4772 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#M10");
4773 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#M11");
4774 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#M12");
4775 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#M13");
4776 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#M14");
4777 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#M15");
4778 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#M16");
4779 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#M17");
4780 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#M18");
4781 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#M19");
4782 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#M20");
4783 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#M21");
4784 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#M22");
4785 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#M23");
4786 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#M24");
4787 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#M25");
4788 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#M26");
4789 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#M27");
4790 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#M28");
4791 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#M29");
4792 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#M30");
4793 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#M31");
4794 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#M32");
4795 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#M33");
4796 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#M34");
4797 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#M35");
4798 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#M36");
4800 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
4801 BindingFlags
.Public
;
4803 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceBlue", flags
), "#N1");
4804 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceBlue", flags
), "#N2");
4805 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceBlue", flags
), "#N3");
4806 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceBlue", flags
), "#N4");
4807 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceBlue", flags
), "#N5");
4808 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceBlue", flags
), "#N6");
4809 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceRed", flags
), "#N7");
4810 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceRed", flags
), "#N8");
4811 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceRed", flags
), "#N9");
4812 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceRed", flags
), "#N10");
4813 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceRed", flags
), "#N11");
4814 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceRed", flags
), "#N12");
4815 Assert
.IsNull (greenType
.GetEvent ("OnPrivateInstanceGreen", flags
), "#N13");
4816 Assert
.IsNull (greenType
.GetEvent ("OnFamilyInstanceGreen", flags
), "#N14");
4817 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemInstanceGreen", flags
), "#N15");
4818 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemInstanceGreen", flags
), "#N16");
4819 Assert
.IsNull (greenType
.GetEvent ("OnPublicInstanceGreen", flags
), "#N17");
4820 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyInstanceGreen", flags
), "#N18");
4821 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticBlue", flags
), "#N19");
4822 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticBlue", flags
), "#N20");
4823 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticBlue", flags
), "#N21");
4824 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticBlue", flags
), "#N22");
4825 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticBlue", flags
), "#N23");
4826 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticBlue", flags
), "#N24");
4827 Assert
.IsNull (greenType
.GetEvent ("OnPrivateStaticRed", flags
), "#N25");
4828 Assert
.IsNull (greenType
.GetEvent ("OnFamilyStaticRed", flags
), "#N26");
4829 Assert
.IsNull (greenType
.GetEvent ("OnFamANDAssemStaticRed", flags
), "#N27");
4830 Assert
.IsNull (greenType
.GetEvent ("OnFamORAssemStaticRed", flags
), "#N28");
4831 Assert
.IsNull (greenType
.GetEvent ("OnPublicStaticRed", flags
), "#N29");
4832 Assert
.IsNull (greenType
.GetEvent ("OnAssemblyStaticRed", flags
), "#N30");
4833 Assert
.IsNotNull (greenType
.GetEvent ("OnPrivateStaticGreen", flags
), "#N31");
4834 Assert
.IsNotNull (greenType
.GetEvent ("OnFamilyStaticGreen", flags
), "#N32");
4835 Assert
.IsNotNull (greenType
.GetEvent ("OnFamANDAssemStaticGreen", flags
), "#N33");
4836 Assert
.IsNotNull (greenType
.GetEvent ("OnFamORAssemStaticGreen", flags
), "#N34");
4837 Assert
.IsNotNull (greenType
.GetEvent ("OnPublicStaticGreen", flags
), "#N35");
4838 Assert
.IsNotNull (greenType
.GetEvent ("OnAssemblyStaticGreen", flags
), "#N36");
4842 [Category ("NotWorking")] // mcs depends on this
4843 public void TestGetFieldsIncomplete_MS ()
4845 TypeBuilder tb
= module
.DefineType (genTypeName ());
4846 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
4850 } catch (NotSupportedException ex
) {
4851 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
4852 Assert
.IsNull (ex
.InnerException
, "#3");
4853 Assert
.IsNotNull (ex
.Message
, "#4");
4858 [Category ("NotDotNet")] // mcs depends on this
4859 public void TestGetFieldsIncomplete_Mono ()
4861 TypeBuilder tb
= module
.DefineType (genTypeName ());
4862 tb
.DefineField ("name", typeof (string), FieldAttributes
.Private
);
4863 tb
.DefineField ("Sex", typeof (int), FieldAttributes
.Public
);
4864 tb
.DefineField ("MALE", typeof (int), FieldAttributes
.Public
| FieldAttributes
.Static
);
4865 tb
.DefineField ("FEMALE", typeof (int), FieldAttributes
.Private
| FieldAttributes
.Static
);
4867 FieldInfo
[] fields
= tb
.GetFields ();
4868 Assert
.AreEqual (2, fields
.Length
, "#A1");
4869 Assert
.AreEqual ("Sex", fields
[0].Name
, "#A2");
4870 Assert
.AreEqual ("MALE", fields
[1].Name
, "#A3");
4872 tb
= module
.DefineType (genTypeName ());
4873 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters ("K", "V");
4874 tb
.DefineField ("First", typeParams
[0], FieldAttributes
.Public
);
4875 tb
.DefineField ("Second", typeParams
[1], FieldAttributes
.Public
);
4876 tb
.DefineField ("Sex", typeof (int), FieldAttributes
.Public
);
4877 tb
.DefineField ("MALE", typeof (int), FieldAttributes
.Public
| FieldAttributes
.Static
);
4878 tb
.DefineField ("FEMALE", typeof (int), FieldAttributes
.Private
| FieldAttributes
.Static
);
4880 fields
= tb
.GetFields ();
4881 Assert
.AreEqual (4, fields
.Length
, "#B1");
4882 Assert
.AreEqual ("First", fields
[0].Name
, "#B2");
4883 Assert
.AreEqual ("Second", fields
[1].Name
, "#B3");
4884 Assert
.AreEqual ("Sex", fields
[2].Name
, "#B4");
4885 Assert
.AreEqual ("MALE", fields
[3].Name
, "#B5");
4889 public void TestGetFieldsComplete ()
4891 TypeBuilder tb
= module
.DefineType (genTypeName ());
4892 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
4894 Type emittedType
= tb
.CreateType ();
4895 FieldInfo
[] dynamicFields
= tb
.GetFields ();
4896 FieldInfo
[] emittedFields
= emittedType
.GetFields ();
4898 Assert
.AreEqual (1, dynamicFields
.Length
, "#A1");
4899 Assert
.AreEqual (dynamicFields
.Length
, emittedFields
.Length
, "#A2");
4900 Assert
.IsFalse ((dynamicFields
[0]) is FieldBuilder
, "#A3");
4901 Assert
.IsFalse ((emittedFields
[0]) is FieldBuilder
, "#A4");
4904 object value = Activator
.CreateInstance (emittedType
);
4905 emittedFields
[0].SetValue (value, 5);
4906 Assert
.AreEqual (5, emittedFields
[0].GetValue (value), "#B1");
4907 Assert
.AreEqual (5, dynamicFields
[0].GetValue (value), "#B2");
4908 dynamicFields
[0].SetValue (value, 4);
4909 Assert
.AreEqual (4, emittedFields
[0].GetValue (value), "#B3");
4910 Assert
.AreEqual (4, dynamicFields
[0].GetValue (value), "#B4");
4913 [Test
] // bug #82625 / 325292
4914 public void TestGetFieldsComplete_Generic ()
4916 // FIXME: merge this with TestGetFieldsComplete when
4917 // bug #82625 is fixed
4921 FieldInfo
[] dynamicFields
;
4922 FieldInfo
[] emittedFields
;
4924 tb
= module
.DefineType (genTypeName ());
4925 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters ("K", "V");
4926 tb
.DefineField ("First", typeParams
[0], FieldAttributes
.Public
);
4927 tb
.DefineField ("Second", typeParams
[1], FieldAttributes
.Public
);
4928 tb
.DefineField ("Sex", typeof (int), FieldAttributes
.Public
);
4929 tb
.DefineField ("MALE", typeof (int), FieldAttributes
.Public
| FieldAttributes
.Static
);
4930 tb
.DefineField ("FEMALE", typeof (int), FieldAttributes
.Private
| FieldAttributes
.Static
);
4932 emittedType
= tb
.CreateType ();
4933 dynamicFields
= tb
.GetFields ();
4934 emittedFields
= emittedType
.GetFields ();
4936 Assert
.AreEqual (4, dynamicFields
.Length
, "#C1");
4937 Assert
.IsFalse ((dynamicFields
[0]) is FieldBuilder
, "#C2");
4938 Assert
.IsFalse ((dynamicFields
[1]) is FieldBuilder
, "#C3");
4939 Assert
.IsFalse ((dynamicFields
[2]) is FieldBuilder
, "#C4");
4940 Assert
.IsFalse ((dynamicFields
[3]) is FieldBuilder
, "#C5");
4941 Assert
.AreEqual ("First", dynamicFields
[0].Name
, "#C6");
4942 Assert
.AreEqual ("Second", dynamicFields
[1].Name
, "#C7");
4943 Assert
.AreEqual ("Sex", dynamicFields
[2].Name
, "#C8");
4944 Assert
.AreEqual ("MALE", dynamicFields
[3].Name
, "#C9");
4946 Assert
.AreEqual (4, emittedFields
.Length
, "#D1");
4947 Assert
.IsFalse ((emittedFields
[0]) is FieldBuilder
, "#D2");
4948 Assert
.IsFalse ((emittedFields
[1]) is FieldBuilder
, "#D3");
4949 Assert
.IsFalse ((emittedFields
[2]) is FieldBuilder
, "#D4");
4950 Assert
.IsFalse ((emittedFields
[3]) is FieldBuilder
, "#D5");
4951 Assert
.AreEqual ("First", emittedFields
[0].Name
, "#D6");
4952 Assert
.AreEqual ("Second", emittedFields
[1].Name
, "#D7");
4953 Assert
.AreEqual ("Sex", emittedFields
[2].Name
, "#D8");
4954 Assert
.AreEqual ("MALE", emittedFields
[3].Name
, "#D9");
4958 [Category ("NotWorking")] // mcs depends on this
4959 public void TestGetFieldsFlagsIncomplete_MS ()
4961 TypeBuilder tb
= module
.DefineType (genTypeName ());
4962 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
4964 tb
.GetFields (BindingFlags
.Instance
| BindingFlags
.Public
);
4966 } catch (NotSupportedException ex
) {
4967 // The invoked member is not supported in a
4969 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
4970 Assert
.IsNull (ex
.InnerException
, "#3");
4971 Assert
.IsNotNull (ex
.Message
, "#4");
4976 [Category ("NotDotNet")] // mcs depends on this
4977 public void TestGetFieldsFlagsIncomplete_Mono ()
4979 FieldInfo
[] fields
;
4981 TypeBuilder tb
= module
.DefineType (genTypeName ());
4982 tb
.DefineField ("name", typeof (string), FieldAttributes
.Private
);
4983 tb
.DefineField ("Sex", typeof (int), FieldAttributes
.Public
);
4984 tb
.DefineField ("MALE", typeof (int), FieldAttributes
.Public
| FieldAttributes
.Static
);
4985 tb
.DefineField ("FEMALE", typeof (int), FieldAttributes
.Private
| FieldAttributes
.Static
);
4987 fields
= tb
.GetFields (BindingFlags
.Public
|
4988 BindingFlags
.NonPublic
| BindingFlags
.Instance
);
4989 Assert
.AreEqual (2, fields
.Length
, "#A1");
4990 Assert
.AreEqual ("name", fields
[0].Name
, "#A2");
4991 Assert
.AreEqual ("Sex", fields
[1].Name
, "#A3");
4993 fields
= tb
.GetFields (BindingFlags
.Public
|
4994 BindingFlags
.Instance
| BindingFlags
.Static
);
4995 Assert
.AreEqual (2, fields
.Length
, "#B1");
4996 Assert
.AreEqual ("Sex", fields
[0].Name
, "#B2");
4997 Assert
.AreEqual ("MALE", fields
[1].Name
, "#B3");
4999 fields
= tb
.GetFields (BindingFlags
.Public
|
5000 BindingFlags
.NonPublic
| BindingFlags
.Instance
|
5001 BindingFlags
.Static
);
5002 Assert
.AreEqual (4, fields
.Length
, "#C1");
5003 Assert
.AreEqual ("name", fields
[0].Name
, "#C2");
5004 Assert
.AreEqual ("Sex", fields
[1].Name
, "#C3");
5005 Assert
.AreEqual ("MALE", fields
[2].Name
, "#C4");
5006 Assert
.AreEqual ("FEMALE", fields
[3].Name
, "#C5");
5010 public void TestGetFieldsFlagsComplete ()
5012 TypeBuilder tb
= module
.DefineType (genTypeName ());
5013 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
5015 Type emittedType
= tb
.CreateType ();
5017 Assert
.AreEqual (1, tb
.GetFields (BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
5018 Assert
.AreEqual (tb
.GetFields (BindingFlags
.Instance
| BindingFlags
.Public
).Length
,
5019 emittedType
.GetFields (BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
5020 Assert
.AreEqual (0, tb
.GetFields (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
5021 Assert
.AreEqual (tb
.GetFields (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
,
5022 emittedType
.GetFields (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
5026 public void TestGetFieldsFlagsComplete_Inheritance ()
5028 FieldInfo
[] fields
;
5031 TypeBuilder blueType
= module
.DefineType (genTypeName (),
5032 TypeAttributes
.Public
);
5033 CreateMembers (blueType
, "Blue", false);
5035 TypeBuilder redType
= module
.DefineType (genTypeName (),
5036 TypeAttributes
.Public
, blueType
);
5037 CreateMembers (redType
, "Red", false);
5039 TypeBuilder greenType
= module
.DefineType (genTypeName (),
5040 TypeAttributes
.Public
, redType
);
5041 CreateMembers (greenType
, "Green", false);
5043 blueType
.CreateType ();
5044 redType
.CreateType ();
5045 greenType
.CreateType ();
5047 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
5048 fields
= greenType
.GetFields (flags
);
5050 Assert
.AreEqual (13, fields
.Length
, "#A1");
5051 Assert
.AreEqual ("privateInstanceGreen", fields
[0].Name
, "#A2");
5052 Assert
.AreEqual ("familyInstanceGreen", fields
[1].Name
, "#A3");
5053 Assert
.AreEqual ("famANDAssemInstanceGreen", fields
[2].Name
, "#A4");
5054 Assert
.AreEqual ("famORAssemInstanceGreen", fields
[3].Name
, "#A5");
5055 Assert
.AreEqual ("assemblyInstanceGreen", fields
[4].Name
, "#A6");
5056 Assert
.AreEqual ("familyInstanceRed", fields
[5].Name
, "#A7");
5057 Assert
.AreEqual ("famANDAssemInstanceRed", fields
[6].Name
, "#A8");
5058 Assert
.AreEqual ("famORAssemInstanceRed", fields
[7].Name
, "#A9");
5059 Assert
.AreEqual ("assemblyInstanceRed", fields
[8].Name
, "#A10");
5060 Assert
.AreEqual ("familyInstanceBlue", fields
[9].Name
, "#A11");
5061 Assert
.AreEqual ("famANDAssemInstanceBlue", fields
[10].Name
, "#A12");
5062 Assert
.AreEqual ("famORAssemInstanceBlue", fields
[11].Name
, "#A13");
5063 Assert
.AreEqual ("assemblyInstanceBlue", fields
[12].Name
, "#A14");
5065 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
5066 fields
= greenType
.GetFields (flags
);
5068 Assert
.AreEqual (3, fields
.Length
, "#B1");
5069 Assert
.AreEqual ("publicInstanceGreen", fields
[0].Name
, "#B2");
5070 Assert
.AreEqual ("publicInstanceRed", fields
[1].Name
, "#B3");
5071 Assert
.AreEqual ("publicInstanceBlue", fields
[2].Name
, "#B4");
5073 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
5074 fields
= greenType
.GetFields (flags
);
5076 Assert
.AreEqual (1, fields
.Length
, "#C1");
5077 Assert
.AreEqual ("publicStaticGreen", fields
[0].Name
, "#C2");
5079 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
5080 fields
= greenType
.GetFields (flags
);
5082 Assert
.AreEqual (5, fields
.Length
, "#D1");
5083 Assert
.AreEqual ("privateStaticGreen", fields
[0].Name
, "#D2");
5084 Assert
.AreEqual ("familyStaticGreen", fields
[1].Name
, "#D3");
5085 Assert
.AreEqual ("famANDAssemStaticGreen", fields
[2].Name
, "#D4");
5086 Assert
.AreEqual ("famORAssemStaticGreen", fields
[3].Name
, "#D5");
5087 Assert
.AreEqual ("assemblyStaticGreen", fields
[4].Name
, "#D6");
5089 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
5090 BindingFlags
.FlattenHierarchy
;
5091 fields
= greenType
.GetFields (flags
);
5093 Assert
.AreEqual (13, fields
.Length
, "#E1");
5094 Assert
.AreEqual ("privateInstanceGreen", fields
[0].Name
, "#E2");
5095 Assert
.AreEqual ("familyInstanceGreen", fields
[1].Name
, "#E3");
5096 Assert
.AreEqual ("famANDAssemInstanceGreen", fields
[2].Name
, "#E4");
5097 Assert
.AreEqual ("famORAssemInstanceGreen", fields
[3].Name
, "#E5");
5098 Assert
.AreEqual ("assemblyInstanceGreen", fields
[4].Name
, "#E6");
5099 Assert
.AreEqual ("familyInstanceRed", fields
[5].Name
, "#E7");
5100 Assert
.AreEqual ("famANDAssemInstanceRed", fields
[6].Name
, "#E8");
5101 Assert
.AreEqual ("famORAssemInstanceRed", fields
[7].Name
, "#E9");
5102 Assert
.AreEqual ("assemblyInstanceRed", fields
[8].Name
, "#E10");
5103 Assert
.AreEqual ("familyInstanceBlue", fields
[9].Name
, "#E11");
5104 Assert
.AreEqual ("famANDAssemInstanceBlue", fields
[10].Name
, "#E12");
5105 Assert
.AreEqual ("famORAssemInstanceBlue", fields
[11].Name
, "#E13");
5106 Assert
.AreEqual ("assemblyInstanceBlue", fields
[12].Name
, "#E14");
5108 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
5109 BindingFlags
.FlattenHierarchy
;
5110 fields
= greenType
.GetFields (flags
);
5112 Assert
.AreEqual (3, fields
.Length
, "#F1");
5113 Assert
.AreEqual ("publicInstanceGreen", fields
[0].Name
, "#F2");
5114 Assert
.AreEqual ("publicInstanceRed", fields
[1].Name
, "#F3");
5115 Assert
.AreEqual ("publicInstanceBlue", fields
[2].Name
, "#F4");
5117 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
5118 BindingFlags
.FlattenHierarchy
;
5119 fields
= greenType
.GetFields (flags
);
5121 Assert
.AreEqual (3, fields
.Length
, "#G1");
5122 Assert
.AreEqual ("publicStaticGreen", fields
[0].Name
, "#G2");
5123 Assert
.AreEqual ("publicStaticRed", fields
[1].Name
, "#G3");
5124 Assert
.AreEqual ("publicStaticBlue", fields
[2].Name
, "#G4");
5126 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
5127 BindingFlags
.FlattenHierarchy
;
5128 fields
= greenType
.GetFields (flags
);
5130 Assert
.AreEqual (13, fields
.Length
, "#H1");
5131 Assert
.AreEqual ("privateStaticGreen", fields
[0].Name
, "#H2");
5132 Assert
.AreEqual ("familyStaticGreen", fields
[1].Name
, "#H3");
5133 Assert
.AreEqual ("famANDAssemStaticGreen", fields
[2].Name
, "#H4");
5134 Assert
.AreEqual ("famORAssemStaticGreen", fields
[3].Name
, "#H5");
5135 Assert
.AreEqual ("assemblyStaticGreen", fields
[4].Name
, "#H6");
5136 Assert
.AreEqual ("familyStaticRed", fields
[5].Name
, "#H7");
5137 Assert
.AreEqual ("famANDAssemStaticRed", fields
[6].Name
, "#H8");
5138 Assert
.AreEqual ("famORAssemStaticRed", fields
[7].Name
, "#H9");
5139 Assert
.AreEqual ("assemblyStaticRed", fields
[8].Name
, "#H10");
5140 Assert
.AreEqual ("familyStaticBlue", fields
[9].Name
, "#H11");
5141 Assert
.AreEqual ("famANDAssemStaticBlue", fields
[10].Name
, "#H12");
5142 Assert
.AreEqual ("famORAssemStaticBlue", fields
[11].Name
, "#H13");
5143 Assert
.AreEqual ("assemblyStaticBlue", fields
[12].Name
, "#H14");
5145 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
5146 BindingFlags
.DeclaredOnly
;
5147 fields
= greenType
.GetFields (flags
);
5149 Assert
.AreEqual (5, fields
.Length
, "#I1");
5150 Assert
.AreEqual ("privateInstanceGreen", fields
[0].Name
, "#I2");
5151 Assert
.AreEqual ("familyInstanceGreen", fields
[1].Name
, "#I3");
5152 Assert
.AreEqual ("famANDAssemInstanceGreen", fields
[2].Name
, "#I4");
5153 Assert
.AreEqual ("famORAssemInstanceGreen", fields
[3].Name
, "#I5");
5154 Assert
.AreEqual ("assemblyInstanceGreen", fields
[4].Name
, "#I6");
5156 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
5157 BindingFlags
.DeclaredOnly
;
5158 fields
= greenType
.GetFields (flags
);
5160 Assert
.AreEqual (1, fields
.Length
, "#J1");
5161 Assert
.AreEqual ("publicInstanceGreen", fields
[0].Name
, "#J2");
5163 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
5164 BindingFlags
.DeclaredOnly
;
5165 fields
= greenType
.GetFields (flags
);
5167 Assert
.AreEqual (1, fields
.Length
, "#K1");
5168 Assert
.AreEqual ("publicStaticGreen", fields
[0].Name
, "#K2");
5170 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
5171 BindingFlags
.DeclaredOnly
;
5172 fields
= greenType
.GetFields (flags
);
5174 Assert
.AreEqual (5, fields
.Length
, "#L1");
5175 Assert
.AreEqual ("privateStaticGreen", fields
[0].Name
, "#L2");
5176 Assert
.AreEqual ("familyStaticGreen", fields
[1].Name
, "#L3");
5177 Assert
.AreEqual ("famANDAssemStaticGreen", fields
[2].Name
, "#L4");
5178 Assert
.AreEqual ("famORAssemStaticGreen", fields
[3].Name
, "#L5");
5179 Assert
.AreEqual ("assemblyStaticGreen", fields
[4].Name
, "#L6");
5181 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
5182 BindingFlags
.Public
;
5183 fields
= greenType
.GetFields (flags
);
5185 Assert
.AreEqual (16, fields
.Length
, "#M1");
5186 Assert
.AreEqual ("privateInstanceGreen", fields
[0].Name
, "#M2");
5187 Assert
.AreEqual ("familyInstanceGreen", fields
[1].Name
, "#M3");
5188 Assert
.AreEqual ("famANDAssemInstanceGreen", fields
[2].Name
, "#M4");
5189 Assert
.AreEqual ("famORAssemInstanceGreen", fields
[3].Name
, "#M5");
5190 Assert
.AreEqual ("publicInstanceGreen", fields
[4].Name
, "#M6");
5191 Assert
.AreEqual ("assemblyInstanceGreen", fields
[5].Name
, "#M7");
5192 Assert
.AreEqual ("familyInstanceRed", fields
[6].Name
, "#M8");
5193 Assert
.AreEqual ("famANDAssemInstanceRed", fields
[7].Name
, "#M9");
5194 Assert
.AreEqual ("famORAssemInstanceRed", fields
[8].Name
, "#M10");
5195 Assert
.AreEqual ("publicInstanceRed", fields
[9].Name
, "#M11");
5196 Assert
.AreEqual ("assemblyInstanceRed", fields
[10].Name
, "#M12");
5197 Assert
.AreEqual ("familyInstanceBlue", fields
[11].Name
, "#M13");
5198 Assert
.AreEqual ("famANDAssemInstanceBlue", fields
[12].Name
, "#M14");
5199 Assert
.AreEqual ("famORAssemInstanceBlue", fields
[13].Name
, "#M15");
5200 Assert
.AreEqual ("publicInstanceBlue", fields
[14].Name
, "#M16");
5201 Assert
.AreEqual ("assemblyInstanceBlue", fields
[15].Name
, "#M17");
5203 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
5204 BindingFlags
.Public
;
5205 fields
= greenType
.GetFields (flags
);
5207 Assert
.AreEqual (6, fields
.Length
, "#N1");
5208 Assert
.AreEqual ("privateStaticGreen", fields
[0].Name
, "#N2");
5209 Assert
.AreEqual ("familyStaticGreen", fields
[1].Name
, "#N3");
5210 Assert
.AreEqual ("famANDAssemStaticGreen", fields
[2].Name
, "#N4");
5211 Assert
.AreEqual ("famORAssemStaticGreen", fields
[3].Name
, "#N5");
5212 Assert
.AreEqual ("publicStaticGreen", fields
[4].Name
, "#N6");
5213 Assert
.AreEqual ("assemblyStaticGreen", fields
[5].Name
, "#N7");
5217 [Category ("NotWorking")] // mcs depends on this
5218 public void TestGetFieldIncomplete_MS ()
5220 TypeBuilder tb
= module
.DefineType (genTypeName ());
5221 tb
.DefineField ("test", typeof (int), FieldAttributes
.Public
);
5223 tb
.GetField ("test");
5225 } catch (NotSupportedException ex
) {
5226 // The invoked member is not supported in a
5228 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
5229 Assert
.IsNull (ex
.InnerException
, "#3");
5230 Assert
.IsNotNull (ex
.Message
, "#4");
5235 [Category ("NotDotNet")] // mcs depends on this
5236 public void TestGetFieldIncomplete_Mono ()
5238 TypeBuilder tb
= module
.DefineType (genTypeName ());
5239 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
5240 tb
.DefineField ("OtherField", typeof (int), FieldAttributes
.Private
);
5242 FieldInfo field
= tb
.GetField ("TestField");
5243 Assert
.IsNotNull (field
, "#A1");
5244 Assert
.AreEqual ("TestField", field
.Name
, "#A2");
5245 Assert
.IsTrue (field
is FieldBuilder
, "#A3");
5247 Assert
.IsNull (tb
.GetField ("OtherField"), "#B1");
5248 Assert
.IsNull (tb
.GetField ("TestOtherField"), "#B2");
5252 public void TestGetFieldComplete ()
5254 TypeBuilder tb
= module
.DefineType (genTypeName ());
5255 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
5257 Type emittedType
= tb
.CreateType ();
5259 FieldInfo dynamicField
= tb
.GetField ("TestField");
5260 FieldInfo emittedField
= emittedType
.GetField ("TestField");
5261 Assert
.IsNotNull (dynamicField
, "#A1");
5262 Assert
.AreEqual (dynamicField
.Name
, emittedField
.Name
, "#A2");
5263 Assert
.IsNull (tb
.GetField ("TestOtherField"), "#A3");
5264 Assert
.IsFalse (emittedField
is FieldBuilder
, "#A4");
5265 Assert
.IsFalse (dynamicField
is FieldBuilder
, "#A5");
5268 object value = Activator
.CreateInstance (emittedType
);
5269 emittedField
.SetValue (value, 5);
5270 Assert
.AreEqual (5, emittedField
.GetValue (value), "#B1");
5271 Assert
.AreEqual (5, dynamicField
.GetValue (value), "#B2");
5272 dynamicField
.SetValue (value, 4);
5273 Assert
.AreEqual (4, emittedField
.GetValue (value), "#B3");
5274 Assert
.AreEqual (4, dynamicField
.GetValue (value), "#B4");
5277 [Test
] // bug #81640
5278 public void TestGetFieldComplete_Type ()
5280 TypeBuilder tb
= module
.DefineType (genTypeName ());
5281 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
5282 Type emittedType
= tb
.CreateType ();
5283 FieldInfo dynamicField
= tb
.GetField ("TestField");
5284 Assert
.IsFalse (dynamicField
is FieldBuilder
, "#1");
5286 object value = Activator
.CreateInstance (emittedType
);
5287 Assert
.AreEqual (0, dynamicField
.GetValue (value), "#2");
5291 [Category ("NotWorking")] // mcs depends on this
5292 public void TestGetFieldFlagsIncomplete_MS ()
5294 TypeBuilder tb
= module
.DefineType (genTypeName ());
5295 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
5296 tb
.DefineField ("OtherField", typeof (int), FieldAttributes
.Private
);
5298 tb
.GetField ("test", BindingFlags
.Public
);
5300 } catch (NotSupportedException ex
) {
5301 // The invoked member is not supported in a
5303 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
5304 Assert
.IsNull (ex
.InnerException
, "#3");
5305 Assert
.IsNotNull (ex
.Message
, "#4");
5310 [Category ("NotDotNet")] // mcs depends on this
5311 public void TestGetFieldFlagsIncomplete_Mono ()
5313 TypeBuilder tb
= module
.DefineType (genTypeName ());
5314 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
5315 tb
.DefineField ("OtherField", typeof (int), FieldAttributes
.Private
);
5317 FieldInfo field
= tb
.GetField ("TestField", BindingFlags
.Public
5318 | BindingFlags
.Instance
);
5319 Assert
.IsNotNull (field
, "#A1");
5320 Assert
.AreEqual ("TestField", field
.Name
, "#A2");
5321 Assert
.IsTrue (field
is FieldBuilder
, "#A3");
5323 field
= tb
.GetField ("OtherField", BindingFlags
.NonPublic
|
5324 BindingFlags
.Instance
);
5325 Assert
.IsNotNull (field
, "#B1");
5326 Assert
.AreEqual ("OtherField", field
.Name
, "#B2");
5327 Assert
.IsTrue (field
is FieldBuilder
, "#B3");
5329 Assert
.IsNull (tb
.GetField ("TestField", BindingFlags
.NonPublic
|
5330 BindingFlags
.Instance
), "#C1");
5331 Assert
.IsNull (tb
.GetField ("TestField", BindingFlags
.Public
|
5332 BindingFlags
.Static
), "#C2");
5333 Assert
.IsNull (tb
.GetField ("OtherField", BindingFlags
.Public
|
5334 BindingFlags
.Instance
), "#C3");
5335 Assert
.IsNull (tb
.GetField ("OtherField", BindingFlags
.Public
|
5336 BindingFlags
.Static
), "#C4");
5337 Assert
.IsNull (tb
.GetField ("NotExist", BindingFlags
.NonPublic
|
5338 BindingFlags
.Instance
), "#C5");
5339 Assert
.IsNull (tb
.GetField ("NotExist", BindingFlags
.Public
|
5340 BindingFlags
.Instance
), "#C6");
5344 public void TestGetFieldFlagsComplete ()
5346 TypeBuilder tb
= module
.DefineType (genTypeName ());
5347 tb
.DefineField ("TestField", typeof (int), FieldAttributes
.Public
);
5349 Type emittedType
= tb
.CreateType ();
5351 Assert
.IsNotNull (tb
.GetField ("TestField", BindingFlags
.Instance
| BindingFlags
.Public
));
5352 Assert
.AreEqual (tb
.GetField ("TestField", BindingFlags
.Instance
| BindingFlags
.Public
).Name
,
5353 emittedType
.GetField ("TestField", BindingFlags
.Instance
| BindingFlags
.Public
).Name
);
5354 Assert
.IsNull (tb
.GetField ("TestField", BindingFlags
.Instance
| BindingFlags
.NonPublic
));
5355 Assert
.AreEqual (tb
.GetField ("TestField", BindingFlags
.Instance
| BindingFlags
.NonPublic
),
5356 emittedType
.GetField ("TestField", BindingFlags
.Instance
| BindingFlags
.NonPublic
));
5360 public void TestGetFieldFlagsComplete_Inheritance ()
5364 TypeBuilder blueType
= module
.DefineType (genTypeName (),
5365 TypeAttributes
.Public
);
5366 CreateMembers (blueType
, "Blue", false);
5368 TypeBuilder redType
= module
.DefineType (genTypeName (),
5369 TypeAttributes
.Public
, blueType
);
5370 CreateMembers (redType
, "Red", false);
5372 TypeBuilder greenType
= module
.DefineType (genTypeName (),
5373 TypeAttributes
.Public
, redType
);
5374 CreateMembers (greenType
, "Green", false);
5376 blueType
.CreateType ();
5377 redType
.CreateType ();
5378 greenType
.CreateType ();
5380 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
5382 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#A1");
5383 Assert
.IsNotNull (greenType
.GetField ("familyInstanceBlue", flags
), "#A2");
5384 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#A3");
5385 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#A4");
5386 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#A5");
5387 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#A6");
5388 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#A7");
5389 Assert
.IsNotNull (greenType
.GetField ("familyInstanceRed", flags
), "#A8");
5390 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#A9");
5391 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#A10");
5392 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#A11");
5393 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#A12");
5394 Assert
.IsNotNull (greenType
.GetField ("privateInstanceGreen", flags
), "#A13");
5395 Assert
.IsNotNull (greenType
.GetField ("familyInstanceGreen", flags
), "#A14");
5396 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#A15");
5397 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#A16");
5398 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#A17");
5399 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#A18");
5400 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#A19");
5401 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#A20");
5402 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#A21");
5403 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#A22");
5404 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#A23");
5405 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#A24");
5406 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#A25");
5407 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#A26");
5408 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#A27");
5409 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#A28");
5410 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#A29");
5411 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#A30");
5412 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#A31");
5413 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#A32");
5414 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#A33");
5415 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#A34");
5416 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#A35");
5417 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#A36");
5419 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
5421 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#B1");
5422 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#B2");
5423 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#B3");
5424 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#B4");
5425 Assert
.IsNotNull (greenType
.GetField ("publicInstanceBlue", flags
), "#B5");
5426 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#B6");
5427 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#B7");
5428 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#B8");
5429 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#B9");
5430 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#B10");
5431 Assert
.IsNotNull (greenType
.GetField ("publicInstanceRed", flags
), "#B11");
5432 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#B12");
5433 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#B13");
5434 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#B14");
5435 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#B15");
5436 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#B16");
5437 Assert
.IsNotNull (greenType
.GetField ("publicInstanceGreen", flags
), "#B17");
5438 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#B18");
5439 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#B19");
5440 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#B20");
5441 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#B21");
5442 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#B22");
5443 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#B23");
5444 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#B24");
5445 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#B25");
5446 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#B26");
5447 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#B27");
5448 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#B28");
5449 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#B29");
5450 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#B30");
5451 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#B31");
5452 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#B32");
5453 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#B33");
5454 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#B34");
5455 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#B35");
5456 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#B36");
5458 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
5460 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#C1");
5461 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#C2");
5462 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#C3");
5463 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#C4");
5464 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#C5");
5465 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#C6");
5466 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#C7");
5467 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#C8");
5468 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#C9");
5469 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#C10");
5470 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#C11");
5471 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#C12");
5472 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#C13");
5473 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#C14");
5474 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#C15");
5475 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#C16");
5476 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#C17");
5477 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#C18");
5478 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#C19");
5479 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#C20");
5480 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#C21");
5481 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#C22");
5482 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#C23");
5483 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#C24");
5484 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#C25");
5485 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#C26");
5486 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#C27");
5487 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#C28");
5488 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#C29");
5489 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#C30");
5490 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#C31");
5491 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#C32");
5492 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#C33");
5493 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#C34");
5494 Assert
.IsNotNull (greenType
.GetField ("publicStaticGreen", flags
), "#C35");
5495 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#C36");
5497 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
5499 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#D1");
5500 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#D2");
5501 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#D3");
5502 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#D4");
5503 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#D5");
5504 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#D6");
5505 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#D7");
5506 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#D8");
5507 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#D9");
5508 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#D10");
5509 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#D11");
5510 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#D12");
5511 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#D13");
5512 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#D14");
5513 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#D15");
5514 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#D16");
5515 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#D17");
5516 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#D18");
5517 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#D19");
5518 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#D20");
5519 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#D21");
5520 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#D22");
5521 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#D23");
5522 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#D24");
5523 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#D25");
5524 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#D26");
5525 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#D27");
5526 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#D28");
5527 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#D29");
5528 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#D30");
5529 Assert
.IsNotNull (greenType
.GetField ("privateStaticGreen", flags
), "#D31");
5530 Assert
.IsNotNull (greenType
.GetField ("familyStaticGreen", flags
), "#D32");
5531 Assert
.IsNotNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#D33");
5532 Assert
.IsNotNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#D34");
5533 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#D35");
5534 Assert
.IsNotNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#D36");
5536 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
5537 BindingFlags
.FlattenHierarchy
;
5539 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#E1");
5540 Assert
.IsNotNull (greenType
.GetField ("familyInstanceBlue", flags
), "#E2");
5541 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#E3");
5542 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#E4");
5543 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#E5");
5544 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#E6");
5545 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#E7");
5546 Assert
.IsNotNull (greenType
.GetField ("familyInstanceRed", flags
), "#E8");
5547 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#E9");
5548 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#E10");
5549 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#E11");
5550 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#E12");
5551 Assert
.IsNotNull (greenType
.GetField ("privateInstanceGreen", flags
), "#E13");
5552 Assert
.IsNotNull (greenType
.GetField ("familyInstanceGreen", flags
), "#E14");
5553 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#E15");
5554 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#E16");
5555 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#E17");
5556 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#E18");
5557 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#E19");
5558 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#E20");
5559 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#E21");
5560 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#E22");
5561 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#E23");
5562 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#E24");
5563 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#E25");
5564 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#E26");
5565 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#E27");
5566 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#E28");
5567 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#E29");
5568 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#E30");
5569 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#E31");
5570 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#E32");
5571 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#E33");
5572 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#E34");
5573 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#E35");
5574 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#E36");
5576 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
5577 BindingFlags
.FlattenHierarchy
;
5579 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#F1");
5580 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#F2");
5581 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#F3");
5582 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#F4");
5583 Assert
.IsNotNull (greenType
.GetField ("publicInstanceBlue", flags
), "#F5");
5584 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#F6");
5585 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#F7");
5586 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#F8");
5587 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#F9");
5588 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#F10");
5589 Assert
.IsNotNull (greenType
.GetField ("publicInstanceRed", flags
), "#F11");
5590 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#F12");
5591 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#F13");
5592 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#F14");
5593 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#F15");
5594 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#F16");
5595 Assert
.IsNotNull (greenType
.GetField ("publicInstanceGreen", flags
), "#F17");
5596 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#F18");
5597 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#F19");
5598 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#F20");
5599 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#F21");
5600 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#F22");
5601 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#F23");
5602 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#F24");
5603 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#F25");
5604 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#F26");
5605 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#F27");
5606 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#F28");
5607 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#F29");
5608 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#F30");
5609 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#F31");
5610 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#F32");
5611 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#F33");
5612 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#F34");
5613 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#F35");
5614 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#F36");
5616 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
5617 BindingFlags
.FlattenHierarchy
;
5619 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#G1");
5620 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#G2");
5621 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#G3");
5622 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#G4");
5623 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#G5");
5624 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#G6");
5625 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#G7");
5626 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#G8");
5627 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#G9");
5628 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#G10");
5629 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#G11");
5630 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#G12");
5631 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#G13");
5632 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#G14");
5633 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#G15");
5634 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#G16");
5635 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#G17");
5636 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#G18");
5637 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#G19");
5638 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#G20");
5639 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#G21");
5640 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#G22");
5641 Assert
.IsNotNull (greenType
.GetField ("publicStaticBlue", flags
), "#G23");
5642 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#G24");
5643 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#G25");
5644 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#G26");
5645 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#G27");
5646 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#G28");
5647 Assert
.IsNotNull (greenType
.GetField ("publicStaticRed", flags
), "#G29");
5648 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#G30");
5649 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#G31");
5650 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#G32");
5651 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#G33");
5652 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#G34");
5653 Assert
.IsNotNull (greenType
.GetField ("publicStaticGreen", flags
), "#G35");
5654 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#G36");
5656 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
5657 BindingFlags
.FlattenHierarchy
;
5659 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#H1");
5660 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#H2");
5661 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#H3");
5662 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#H4");
5663 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#H5");
5664 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#H6");
5665 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#H7");
5666 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#H8");
5667 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#H9");
5668 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#H10");
5669 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#H11");
5670 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#H12");
5671 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#H13");
5672 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#H14");
5673 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#H15");
5674 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#H16");
5675 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#H17");
5676 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#H18");
5677 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#H19");
5678 Assert
.IsNotNull (greenType
.GetField ("familyStaticBlue", flags
), "#H20");
5679 Assert
.IsNotNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#H21");
5680 Assert
.IsNotNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#H22");
5681 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#H23");
5682 Assert
.IsNotNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#H24");
5683 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#H25");
5684 Assert
.IsNotNull (greenType
.GetField ("familyStaticRed", flags
), "#H26");
5685 Assert
.IsNotNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#H27");
5686 Assert
.IsNotNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#H28");
5687 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#H29");
5688 Assert
.IsNotNull (greenType
.GetField ("assemblyStaticRed", flags
), "#H30");
5689 Assert
.IsNotNull (greenType
.GetField ("privateStaticGreen", flags
), "#H31");
5690 Assert
.IsNotNull (greenType
.GetField ("familyStaticGreen", flags
), "#H32");
5691 Assert
.IsNotNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#H33");
5692 Assert
.IsNotNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#H34");
5693 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#H35");
5694 Assert
.IsNotNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#H36");
5696 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
5697 BindingFlags
.DeclaredOnly
;
5699 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#I1");
5700 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#I2");
5701 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#I3");
5702 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#I4");
5703 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#I5");
5704 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#I6");
5705 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#I7");
5706 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#I8");
5707 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#I9");
5708 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#I10");
5709 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#I11");
5710 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#I12");
5711 Assert
.IsNotNull (greenType
.GetField ("privateInstanceGreen", flags
), "#I13");
5712 Assert
.IsNotNull (greenType
.GetField ("familyInstanceGreen", flags
), "#I14");
5713 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#I15");
5714 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#I16");
5715 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#I17");
5716 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#I18");
5717 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#I19");
5718 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#I20");
5719 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#I21");
5720 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#I22");
5721 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#I23");
5722 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#I24");
5723 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#I25");
5724 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#I26");
5725 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#I27");
5726 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#I28");
5727 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#I29");
5728 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#I30");
5729 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#I31");
5730 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#I32");
5731 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#I33");
5732 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#I34");
5733 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#I35");
5734 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#I36");
5736 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
5737 BindingFlags
.DeclaredOnly
;
5739 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#J1");
5740 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#J2");
5741 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#J3");
5742 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#J4");
5743 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#J5");
5744 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#J6");
5745 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#J7");
5746 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#J8");
5747 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#J9");
5748 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#J10");
5749 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#J11");
5750 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#J12");
5751 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#J13");
5752 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#J14");
5753 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#J15");
5754 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#J16");
5755 Assert
.IsNotNull (greenType
.GetField ("publicInstanceGreen", flags
), "#J17");
5756 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#J18");
5757 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#J19");
5758 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#J20");
5759 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#J21");
5760 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#J22");
5761 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#J23");
5762 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#J24");
5763 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#J25");
5764 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#J26");
5765 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#J27");
5766 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#J28");
5767 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#J29");
5768 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#J30");
5769 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#J31");
5770 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#J32");
5771 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#J33");
5772 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#J34");
5773 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#J35");
5774 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#J36");
5776 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
5777 BindingFlags
.DeclaredOnly
;
5779 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#K1");
5780 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#K2");
5781 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#K3");
5782 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#K4");
5783 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#K5");
5784 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#K6");
5785 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#K7");
5786 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#K8");
5787 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#K9");
5788 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#K10");
5789 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#K11");
5790 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#K12");
5791 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#K13");
5792 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#K14");
5793 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#K15");
5794 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#K16");
5795 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#K17");
5796 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#K18");
5797 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#K19");
5798 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#K20");
5799 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#K21");
5800 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#K22");
5801 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#K23");
5802 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#K24");
5803 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#K25");
5804 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#K26");
5805 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#K27");
5806 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#K28");
5807 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#K29");
5808 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#K30");
5809 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#K31");
5810 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#K32");
5811 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#K33");
5812 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#K34");
5813 Assert
.IsNotNull (greenType
.GetField ("publicStaticGreen", flags
), "#K35");
5814 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#K36");
5816 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
5817 BindingFlags
.DeclaredOnly
;
5819 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#L1");
5820 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#L2");
5821 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#L3");
5822 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#L4");
5823 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#L5");
5824 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#L6");
5825 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#L7");
5826 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#L8");
5827 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#L9");
5828 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#L10");
5829 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#L11");
5830 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#L12");
5831 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#L13");
5832 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#L14");
5833 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#L15");
5834 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#L16");
5835 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#L17");
5836 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#L18");
5837 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#L19");
5838 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#L20");
5839 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#L21");
5840 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#L22");
5841 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#L23");
5842 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#L24");
5843 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#L25");
5844 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#L26");
5845 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#L27");
5846 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#L28");
5847 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#L29");
5848 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#L30");
5849 Assert
.IsNotNull (greenType
.GetField ("privateStaticGreen", flags
), "#L31");
5850 Assert
.IsNotNull (greenType
.GetField ("familyStaticGreen", flags
), "#L32");
5851 Assert
.IsNotNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#L33");
5852 Assert
.IsNotNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#L34");
5853 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#L35");
5854 Assert
.IsNotNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#L36");
5856 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
5857 BindingFlags
.Public
;
5859 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#M1");
5860 Assert
.IsNotNull (greenType
.GetField ("familyInstanceBlue", flags
), "#M2");
5861 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#M3");
5862 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#M4");
5863 Assert
.IsNotNull (greenType
.GetField ("publicInstanceBlue", flags
), "#M5");
5864 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#M6");
5865 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#M7");
5866 Assert
.IsNotNull (greenType
.GetField ("familyInstanceRed", flags
), "#M8");
5867 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#M9");
5868 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#M10");
5869 Assert
.IsNotNull (greenType
.GetField ("publicInstanceRed", flags
), "#M11");
5870 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#M12");
5871 Assert
.IsNotNull (greenType
.GetField ("privateInstanceGreen", flags
), "#M13");
5872 Assert
.IsNotNull (greenType
.GetField ("familyInstanceGreen", flags
), "#M14");
5873 Assert
.IsNotNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#M15");
5874 Assert
.IsNotNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#M16");
5875 Assert
.IsNotNull (greenType
.GetField ("publicInstanceGreen", flags
), "#M17");
5876 Assert
.IsNotNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#M18");
5877 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#M19");
5878 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#M20");
5879 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#M21");
5880 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#M22");
5881 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#M23");
5882 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#M24");
5883 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#M25");
5884 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#M26");
5885 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#M27");
5886 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#M28");
5887 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#M29");
5888 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#M30");
5889 Assert
.IsNull (greenType
.GetField ("privateStaticGreen", flags
), "#M31");
5890 Assert
.IsNull (greenType
.GetField ("familyStaticGreen", flags
), "#M32");
5891 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#M33");
5892 Assert
.IsNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#M34");
5893 Assert
.IsNull (greenType
.GetField ("publicStaticGreen", flags
), "#M35");
5894 Assert
.IsNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#M36");
5896 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
5897 BindingFlags
.Public
;
5899 Assert
.IsNull (greenType
.GetField ("privateInstanceBlue", flags
), "#N1");
5900 Assert
.IsNull (greenType
.GetField ("familyInstanceBlue", flags
), "#N2");
5901 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceBlue", flags
), "#N3");
5902 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceBlue", flags
), "#N4");
5903 Assert
.IsNull (greenType
.GetField ("publicInstanceBlue", flags
), "#N5");
5904 Assert
.IsNull (greenType
.GetField ("assemblyInstanceBlue", flags
), "#N6");
5905 Assert
.IsNull (greenType
.GetField ("privateInstanceRed", flags
), "#N7");
5906 Assert
.IsNull (greenType
.GetField ("familyInstanceRed", flags
), "#N8");
5907 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceRed", flags
), "#N9");
5908 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceRed", flags
), "#N10");
5909 Assert
.IsNull (greenType
.GetField ("publicInstanceRed", flags
), "#N11");
5910 Assert
.IsNull (greenType
.GetField ("assemblyInstanceRed", flags
), "#N12");
5911 Assert
.IsNull (greenType
.GetField ("privateInstanceGreen", flags
), "#N13");
5912 Assert
.IsNull (greenType
.GetField ("familyInstanceGreen", flags
), "#N14");
5913 Assert
.IsNull (greenType
.GetField ("famANDAssemInstanceGreen", flags
), "#N15");
5914 Assert
.IsNull (greenType
.GetField ("famORAssemInstanceGreen", flags
), "#N16");
5915 Assert
.IsNull (greenType
.GetField ("publicInstanceGreen", flags
), "#N17");
5916 Assert
.IsNull (greenType
.GetField ("assemblyInstanceGreen", flags
), "#N18");
5917 Assert
.IsNull (greenType
.GetField ("privateStaticBlue", flags
), "#N19");
5918 Assert
.IsNull (greenType
.GetField ("familyStaticBlue", flags
), "#N20");
5919 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticBlue", flags
), "#N21");
5920 Assert
.IsNull (greenType
.GetField ("famORAssemStaticBlue", flags
), "#N22");
5921 Assert
.IsNull (greenType
.GetField ("publicStaticBlue", flags
), "#N23");
5922 Assert
.IsNull (greenType
.GetField ("assemblyStaticBlue", flags
), "#N24");
5923 Assert
.IsNull (greenType
.GetField ("privateStaticRed", flags
), "#N25");
5924 Assert
.IsNull (greenType
.GetField ("familyStaticRed", flags
), "#N26");
5925 Assert
.IsNull (greenType
.GetField ("famANDAssemStaticRed", flags
), "#N27");
5926 Assert
.IsNull (greenType
.GetField ("famORAssemStaticRed", flags
), "#N28");
5927 Assert
.IsNull (greenType
.GetField ("publicStaticRed", flags
), "#N29");
5928 Assert
.IsNull (greenType
.GetField ("assemblyStaticRed", flags
), "#N30");
5929 Assert
.IsNotNull (greenType
.GetField ("privateStaticGreen", flags
), "#N31");
5930 Assert
.IsNotNull (greenType
.GetField ("familyStaticGreen", flags
), "#N32");
5931 Assert
.IsNotNull (greenType
.GetField ("famANDAssemStaticGreen", flags
), "#N33");
5932 Assert
.IsNotNull (greenType
.GetField ("famORAssemStaticGreen", flags
), "#N34");
5933 Assert
.IsNotNull (greenType
.GetField ("publicStaticGreen", flags
), "#N35");
5934 Assert
.IsNotNull (greenType
.GetField ("assemblyStaticGreen", flags
), "#N36");
5938 [Category ("NotDotNet")] // mcs depends on this
5939 public void TestGetPropertiesIncomplete_Mono ()
5941 TypeBuilder tb
= module
.DefineType (genTypeName ());
5942 DefineStringProperty (tb
, "Name", "name", MethodAttributes
.Public
);
5943 DefineStringProperty (tb
, "Income", "income", MethodAttributes
.Private
);
5944 DefineStringProperty (tb
, "FirstName", "firstName", MethodAttributes
.Public
);
5946 PropertyInfo
[] properties
= tb
.GetProperties ();
5947 Assert
.AreEqual (2, properties
.Length
, "#1");
5948 Assert
.AreEqual ("Name", properties
[0].Name
, "#2");
5949 Assert
.AreEqual ("FirstName", properties
[1].Name
, "#3");
5953 [Category ("NotWorking")] // mcs depends on this
5954 public void TestGetPropertiesIncomplete_MS ()
5956 TypeBuilder tb
= module
.DefineType (genTypeName ());
5957 DefineStringProperty (tb
, "Name", "name", MethodAttributes
.Public
);
5958 DefineStringProperty (tb
, "FirstName", "firstName", MethodAttributes
.Public
);
5959 DefineStringProperty (tb
, "Income", "income", MethodAttributes
.Private
);
5962 tb
.GetProperties ();
5964 } catch (NotSupportedException ex
) {
5965 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
5966 Assert
.IsNull (ex
.InnerException
, "#3");
5967 Assert
.IsNotNull (ex
.Message
, "#4");
5972 public void TestGetPropertiesComplete ()
5974 TypeBuilder tb
= module
.DefineType (genTypeName ());
5975 DefineStringProperty (tb
, "CustomerName", "customerName", MethodAttributes
.Public
);
5977 Type emittedType
= tb
.CreateType ();
5979 Assert
.AreEqual (1, tb
.GetProperties ().Length
);
5980 Assert
.AreEqual (tb
.GetProperties ().Length
, emittedType
.GetProperties ().Length
);
5984 [Category ("NotDotNet")] // mcs depends on this
5985 public void TestGetPropertiesFlagsIncomplete_Mono ()
5987 PropertyInfo
[] properties
;
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
);
5994 properties
= tb
.GetProperties (BindingFlags
.Public
|
5995 BindingFlags
.NonPublic
| BindingFlags
.Instance
);
5996 Assert
.AreEqual (3, properties
.Length
, "#A1");
5997 Assert
.AreEqual ("Name", properties
[0].Name
, "#A2");
5998 Assert
.AreEqual ("Income", properties
[1].Name
, "#A3");
5999 Assert
.AreEqual ("FirstName", properties
[2].Name
, "#A4");
6001 properties
= tb
.GetProperties (BindingFlags
.Public
|
6002 BindingFlags
.Instance
);
6003 Assert
.AreEqual (2, properties
.Length
, "#B1");
6004 Assert
.AreEqual ("Name", properties
[0].Name
, "#B2");
6005 Assert
.AreEqual ("FirstName", properties
[1].Name
, "#B3");
6007 properties
= tb
.GetProperties (BindingFlags
.NonPublic
|
6008 BindingFlags
.Instance
);
6009 Assert
.AreEqual (1, properties
.Length
, "#C1");
6010 Assert
.AreEqual ("Income", properties
[0].Name
, "#C2");
6014 [Category ("NotWorking")] // mcs depends on this
6015 public void TestGetPropertiesFlagsIncomplete_MS ()
6017 TypeBuilder tb
= module
.DefineType (genTypeName ());
6018 DefineStringProperty (tb
, "Name", "name", MethodAttributes
.Public
);
6019 DefineStringProperty (tb
, "Income", "income", MethodAttributes
.Private
);
6020 DefineStringProperty (tb
, "FirstName", "firstName", MethodAttributes
.Public
);
6023 tb
.GetProperties (BindingFlags
.Public
);
6025 } catch (NotSupportedException ex
) {
6026 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
6027 Assert
.IsNull (ex
.InnerException
, "#3");
6028 Assert
.IsNotNull (ex
.Message
, "#4");
6033 public void TestGetPropertiesFlagsComplete ()
6035 TypeBuilder tb
= module
.DefineType (genTypeName ());
6036 DefineStringProperty (tb
, "CustomerName", "customerName", MethodAttributes
.Public
);
6038 Type emittedType
= tb
.CreateType ();
6040 Assert
.AreEqual (1, tb
.GetProperties (BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
6041 Assert
.AreEqual (tb
.GetProperties (BindingFlags
.Instance
| BindingFlags
.Public
).Length
,
6042 emittedType
.GetProperties (BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
6043 Assert
.AreEqual (0, tb
.GetProperties (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
6044 Assert
.AreEqual (tb
.GetProperties (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
,
6045 emittedType
.GetProperties (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
6049 public void TestGetPropertiesFlagsComplete_Inheritance ()
6051 PropertyInfo
[] props
;
6054 TypeBuilder blueType
= module
.DefineType (genTypeName (),
6055 TypeAttributes
.Public
);
6056 CreateMembers (blueType
, "Blue", false);
6058 TypeBuilder redType
= module
.DefineType (genTypeName (),
6059 TypeAttributes
.Public
, blueType
);
6060 CreateMembers (redType
, "Red", false);
6062 TypeBuilder greenType
= module
.DefineType (genTypeName (),
6063 TypeAttributes
.Public
, redType
);
6064 CreateMembers (greenType
, "Green", false);
6066 blueType
.CreateType ();
6067 redType
.CreateType ();
6068 greenType
.CreateType ();
6070 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
6071 props
= greenType
.GetProperties (flags
);
6073 Assert
.AreEqual (13, props
.Length
, "#A1");
6074 Assert
.AreEqual ("PrivateInstanceGreen", props
[0].Name
, "#A2");
6075 Assert
.AreEqual ("FamilyInstanceGreen", props
[1].Name
, "#A3");
6076 Assert
.AreEqual ("FamANDAssemInstanceGreen", props
[2].Name
, "#A4");
6077 Assert
.AreEqual ("FamORAssemInstanceGreen", props
[3].Name
, "#A5");
6078 Assert
.AreEqual ("AssemblyInstanceGreen", props
[4].Name
, "#A6");
6079 Assert
.AreEqual ("FamilyInstanceRed", props
[5].Name
, "#A7");
6080 Assert
.AreEqual ("FamANDAssemInstanceRed", props
[6].Name
, "#A8");
6081 Assert
.AreEqual ("FamORAssemInstanceRed", props
[7].Name
, "#A9");
6082 Assert
.AreEqual ("AssemblyInstanceRed", props
[8].Name
, "#A10");
6083 Assert
.AreEqual ("FamilyInstanceBlue", props
[9].Name
, "#A11");
6084 Assert
.AreEqual ("FamANDAssemInstanceBlue", props
[10].Name
, "#A12");
6085 Assert
.AreEqual ("FamORAssemInstanceBlue", props
[11].Name
, "#A13");
6086 Assert
.AreEqual ("AssemblyInstanceBlue", props
[12].Name
, "#A15");
6088 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
6089 props
= greenType
.GetProperties (flags
);
6091 Assert
.AreEqual (3, props
.Length
, "#B1");
6092 Assert
.AreEqual ("PublicInstanceGreen", props
[0].Name
, "#B2");
6093 Assert
.AreEqual ("PublicInstanceRed", props
[1].Name
, "#B3");
6094 Assert
.AreEqual ("PublicInstanceBlue", props
[2].Name
, "#B4");
6096 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
6097 props
= greenType
.GetProperties (flags
);
6099 Assert
.AreEqual (1, props
.Length
, "#C1");
6100 Assert
.AreEqual ("PublicStaticGreen", props
[0].Name
, "#C2");
6102 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
6103 props
= greenType
.GetProperties (flags
);
6105 Assert
.AreEqual (5, props
.Length
, "#D1");
6106 Assert
.AreEqual ("PrivateStaticGreen", props
[0].Name
, "#D2");
6107 Assert
.AreEqual ("FamilyStaticGreen", props
[1].Name
, "#D3");
6108 Assert
.AreEqual ("FamANDAssemStaticGreen", props
[2].Name
, "#D4");
6109 Assert
.AreEqual ("FamORAssemStaticGreen", props
[3].Name
, "#D5");
6110 Assert
.AreEqual ("AssemblyStaticGreen", props
[4].Name
, "#D6");
6112 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
6113 BindingFlags
.FlattenHierarchy
;
6114 props
= greenType
.GetProperties (flags
);
6116 Assert
.AreEqual (13, props
.Length
, "#E1");
6117 Assert
.AreEqual ("PrivateInstanceGreen", props
[0].Name
, "#E2");
6118 Assert
.AreEqual ("FamilyInstanceGreen", props
[1].Name
, "#E3");
6119 Assert
.AreEqual ("FamANDAssemInstanceGreen", props
[2].Name
, "#E4");
6120 Assert
.AreEqual ("FamORAssemInstanceGreen", props
[3].Name
, "#E5");
6121 Assert
.AreEqual ("AssemblyInstanceGreen", props
[4].Name
, "#E6");
6122 Assert
.AreEqual ("FamilyInstanceRed", props
[5].Name
, "#E7");
6123 Assert
.AreEqual ("FamANDAssemInstanceRed", props
[6].Name
, "#E8");
6124 Assert
.AreEqual ("FamORAssemInstanceRed", props
[7].Name
, "#E9");
6125 Assert
.AreEqual ("AssemblyInstanceRed", props
[8].Name
, "#E10");
6126 Assert
.AreEqual ("FamilyInstanceBlue", props
[9].Name
, "#E11");
6127 Assert
.AreEqual ("FamANDAssemInstanceBlue", props
[10].Name
, "#E12");
6128 Assert
.AreEqual ("FamORAssemInstanceBlue", props
[11].Name
, "#E13");
6129 Assert
.AreEqual ("AssemblyInstanceBlue", props
[12].Name
, "#E14");
6131 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
6132 BindingFlags
.FlattenHierarchy
;
6133 props
= greenType
.GetProperties (flags
);
6135 Assert
.AreEqual (3, props
.Length
, "#F1");
6136 Assert
.AreEqual ("PublicInstanceGreen", props
[0].Name
, "#F2");
6137 Assert
.AreEqual ("PublicInstanceRed", props
[1].Name
, "#F3");
6138 Assert
.AreEqual ("PublicInstanceBlue", props
[2].Name
, "#F4");
6140 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
6141 BindingFlags
.FlattenHierarchy
;
6142 props
= greenType
.GetProperties (flags
);
6144 Assert
.AreEqual (3, props
.Length
, "#G1");
6145 Assert
.AreEqual ("PublicStaticGreen", props
[0].Name
, "#G2");
6146 Assert
.AreEqual ("PublicStaticRed", props
[1].Name
, "#G3");
6147 Assert
.AreEqual ("PublicStaticBlue", props
[2].Name
, "#G4");
6149 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
6150 BindingFlags
.FlattenHierarchy
;
6151 props
= greenType
.GetProperties (flags
);
6153 Assert
.AreEqual (13, props
.Length
, "#H1");
6154 Assert
.AreEqual ("PrivateStaticGreen", props
[0].Name
, "#H2");
6155 Assert
.AreEqual ("FamilyStaticGreen", props
[1].Name
, "#H3");
6156 Assert
.AreEqual ("FamANDAssemStaticGreen", props
[2].Name
, "#H4");
6157 Assert
.AreEqual ("FamORAssemStaticGreen", props
[3].Name
, "#H5");
6158 Assert
.AreEqual ("AssemblyStaticGreen", props
[4].Name
, "#H6");
6159 Assert
.AreEqual ("FamilyStaticRed", props
[5].Name
, "#H7");
6160 Assert
.AreEqual ("FamANDAssemStaticRed", props
[6].Name
, "#H8");
6161 Assert
.AreEqual ("FamORAssemStaticRed", props
[7].Name
, "#H9");
6162 Assert
.AreEqual ("AssemblyStaticRed", props
[8].Name
, "#H10");
6163 Assert
.AreEqual ("FamilyStaticBlue", props
[9].Name
, "#H11");
6164 Assert
.AreEqual ("FamANDAssemStaticBlue", props
[10].Name
, "#H12");
6165 Assert
.AreEqual ("FamORAssemStaticBlue", props
[11].Name
, "#H13");
6166 Assert
.AreEqual ("AssemblyStaticBlue", props
[12].Name
, "#H14");
6168 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
6169 BindingFlags
.DeclaredOnly
;
6170 props
= greenType
.GetProperties (flags
);
6172 Assert
.AreEqual (5, props
.Length
, "#I1");
6173 Assert
.AreEqual ("PrivateInstanceGreen", props
[0].Name
, "#I2");
6174 Assert
.AreEqual ("FamilyInstanceGreen", props
[1].Name
, "#I3");
6175 Assert
.AreEqual ("FamANDAssemInstanceGreen", props
[2].Name
, "#I4");
6176 Assert
.AreEqual ("FamORAssemInstanceGreen", props
[3].Name
, "#I5");
6177 Assert
.AreEqual ("AssemblyInstanceGreen", props
[4].Name
, "#I6");
6179 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
6180 BindingFlags
.DeclaredOnly
;
6181 props
= greenType
.GetProperties (flags
);
6183 Assert
.AreEqual (1, props
.Length
, "#J1");
6184 Assert
.AreEqual ("PublicInstanceGreen", props
[0].Name
, "#J2");
6186 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
6187 BindingFlags
.DeclaredOnly
;
6188 props
= greenType
.GetProperties (flags
);
6190 Assert
.AreEqual (1, props
.Length
, "#K1");
6191 Assert
.AreEqual ("PublicStaticGreen", props
[0].Name
, "#K2");
6193 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
6194 BindingFlags
.DeclaredOnly
;
6195 props
= greenType
.GetProperties (flags
);
6197 Assert
.AreEqual (5, props
.Length
, "#L1");
6198 Assert
.AreEqual ("PrivateStaticGreen", props
[0].Name
, "#L2");
6199 Assert
.AreEqual ("FamilyStaticGreen", props
[1].Name
, "#L3");
6200 Assert
.AreEqual ("FamANDAssemStaticGreen", props
[2].Name
, "#L4");
6201 Assert
.AreEqual ("FamORAssemStaticGreen", props
[3].Name
, "#L5");
6202 Assert
.AreEqual ("AssemblyStaticGreen", props
[4].Name
, "#L6");
6204 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
6205 BindingFlags
.Public
;
6206 props
= greenType
.GetProperties (flags
);
6208 Assert
.AreEqual (16, props
.Length
, "#M1");
6209 Assert
.AreEqual ("PrivateInstanceGreen", props
[0].Name
, "#M2");
6210 Assert
.AreEqual ("FamilyInstanceGreen", props
[1].Name
, "#M3");
6211 Assert
.AreEqual ("FamANDAssemInstanceGreen", props
[2].Name
, "#M4");
6212 Assert
.AreEqual ("FamORAssemInstanceGreen", props
[3].Name
, "#M5");
6213 Assert
.AreEqual ("PublicInstanceGreen", props
[4].Name
, "#M6");
6214 Assert
.AreEqual ("AssemblyInstanceGreen", props
[5].Name
, "#M7");
6215 Assert
.AreEqual ("FamilyInstanceRed", props
[6].Name
, "#M8");
6216 Assert
.AreEqual ("FamANDAssemInstanceRed", props
[7].Name
, "#M9");
6217 Assert
.AreEqual ("FamORAssemInstanceRed", props
[8].Name
, "#M10");
6218 Assert
.AreEqual ("PublicInstanceRed", props
[9].Name
, "#M11");
6219 Assert
.AreEqual ("AssemblyInstanceRed", props
[10].Name
, "#M12");
6220 Assert
.AreEqual ("FamilyInstanceBlue", props
[11].Name
, "#M13");
6221 Assert
.AreEqual ("FamANDAssemInstanceBlue", props
[12].Name
, "#M14");
6222 Assert
.AreEqual ("FamORAssemInstanceBlue", props
[13].Name
, "#M15");
6223 Assert
.AreEqual ("PublicInstanceBlue", props
[14].Name
, "#M16");
6224 Assert
.AreEqual ("AssemblyInstanceBlue", props
[15].Name
, "#M17");
6226 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
6227 BindingFlags
.Public
;
6228 props
= greenType
.GetProperties (flags
);
6230 Assert
.AreEqual (6, props
.Length
, "#N1");
6231 Assert
.AreEqual ("PrivateStaticGreen", props
[0].Name
, "#N2");
6232 Assert
.AreEqual ("FamilyStaticGreen", props
[1].Name
, "#N3");
6233 Assert
.AreEqual ("FamANDAssemStaticGreen", props
[2].Name
, "#N4");
6234 Assert
.AreEqual ("FamORAssemStaticGreen", props
[3].Name
, "#N5");
6235 Assert
.AreEqual ("PublicStaticGreen", props
[4].Name
, "#N6");
6236 Assert
.AreEqual ("AssemblyStaticGreen", props
[5].Name
, "#N7");
6240 public void TestGetPropertyIncomplete ()
6242 TypeBuilder tb
= module
.DefineType (genTypeName ());
6244 tb
.GetProperty ("test");
6246 } catch (NotSupportedException ex
) {
6247 // The invoked member is not supported in a
6249 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
6250 Assert
.IsNull (ex
.InnerException
, "#3");
6251 Assert
.IsNotNull (ex
.Message
, "#4");
6256 public void TestGetPropertyComplete ()
6258 TypeBuilder tb
= module
.DefineType (genTypeName ());
6259 DefineStringProperty (tb
, "CustomerName", "customerName", MethodAttributes
.Public
);
6261 Type emittedType
= tb
.CreateType ();
6263 Assert
.IsNotNull (emittedType
.GetProperty ("CustomerName"));
6264 Assert
.IsNull (emittedType
.GetProperty ("OtherCustomerName"));
6267 tb
.GetProperty ("CustomerName");
6269 } catch (NotSupportedException ex
) {
6270 // The invoked member is not supported in a
6272 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
6273 Assert
.IsNull (ex
.InnerException
, "#3");
6274 Assert
.IsNotNull (ex
.Message
, "#4");
6279 public void TestGetPropertyFlagsIncomplete ()
6281 TypeBuilder tb
= module
.DefineType (genTypeName ());
6283 tb
.GetProperty ("test", BindingFlags
.Public
);
6285 } catch (NotSupportedException ex
) {
6286 // The invoked member is not supported in a
6288 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
6289 Assert
.IsNull (ex
.InnerException
, "#3");
6290 Assert
.IsNotNull (ex
.Message
, "#4");
6295 public void TestGetPropertyFlagsComplete ()
6297 TypeBuilder tb
= module
.DefineType (genTypeName ());
6298 DefineStringProperty (tb
, "CustomerName", "customerName", MethodAttributes
.Public
);
6300 Type emittedType
= tb
.CreateType ();
6302 Assert
.IsNotNull (emittedType
.GetProperty ("CustomerName", BindingFlags
.Instance
|
6303 BindingFlags
.Public
));
6304 Assert
.IsNull (emittedType
.GetProperty ("CustomerName", BindingFlags
.Instance
|
6305 BindingFlags
.NonPublic
));
6308 tb
.GetProperty ("CustomerName", BindingFlags
.Instance
| BindingFlags
.Public
);
6310 } catch (NotSupportedException ex
) {
6311 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
6312 Assert
.IsNull (ex
.InnerException
, "#3");
6313 Assert
.IsNotNull (ex
.Message
, "#4");
6318 public void TestGetMethodFlagsComplete ()
6322 TypeBuilder blueType
= module
.DefineType (genTypeName (),
6323 TypeAttributes
.Public
);
6324 CreateMembers (blueType
, "Blue", false);
6326 TypeBuilder redType
= module
.DefineType (genTypeName (),
6327 TypeAttributes
.Public
, blueType
);
6328 CreateMembers (redType
, "Red", false);
6330 TypeBuilder greenType
= module
.DefineType (genTypeName (),
6331 TypeAttributes
.Public
, redType
);
6332 CreateMembers (greenType
, "Green", false);
6334 blueType
.CreateType ();
6335 redType
.CreateType ();
6336 greenType
.CreateType ();
6338 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
6340 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#A1");
6341 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#A2");
6342 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#A3");
6343 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#A4");
6344 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#A5");
6345 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#A6");
6346 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#A7");
6347 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#A8");
6348 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#A9");
6349 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#A10");
6350 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#A11");
6351 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#A12");
6352 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#A13");
6353 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#A14");
6354 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#A15");
6355 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#A16");
6356 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#A17");
6357 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#A18");
6358 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#A19");
6359 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#A20");
6360 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#A21");
6361 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#A22");
6362 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#A23");
6363 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#A24");
6364 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#A25");
6365 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#A26");
6366 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#A27");
6367 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#A28");
6368 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#A29");
6369 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#A30");
6370 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#A31");
6371 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#A32");
6372 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#A33");
6373 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#A34");
6374 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#A35");
6375 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#A36");
6377 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
6379 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#B1");
6380 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#B2");
6381 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#B3");
6382 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#B4");
6383 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#B5");
6384 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#B6");
6385 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#B7");
6386 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#B8");
6387 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#B9");
6388 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#B10");
6389 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#B11");
6390 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#B12");
6391 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#B13");
6392 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#B14");
6393 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#B15");
6394 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#B16");
6395 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#B17");
6396 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#B18");
6397 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#B19");
6398 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#B20");
6399 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#B21");
6400 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#B22");
6401 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#B23");
6402 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#B24");
6403 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#B25");
6404 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#B26");
6405 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#B27");
6406 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#B28");
6407 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#B29");
6408 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#B30");
6409 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#B31");
6410 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#B32");
6411 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#B33");
6412 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#B34");
6413 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#B35");
6414 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#B36");
6416 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
6418 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#C1");
6419 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#C2");
6420 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#C3");
6421 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#C4");
6422 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#C5");
6423 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#C6");
6424 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#C7");
6425 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#C8");
6426 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#C9");
6427 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#C10");
6428 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#C11");
6429 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#C12");
6430 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#C13");
6431 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#C14");
6432 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#C15");
6433 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#C16");
6434 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#C17");
6435 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#C18");
6436 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#C19");
6437 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#C20");
6438 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#C21");
6439 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#C22");
6440 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#C23");
6441 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#C24");
6442 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#C25");
6443 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#C26");
6444 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#C27");
6445 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#C28");
6446 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#C29");
6447 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#C30");
6448 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#C31");
6449 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#C32");
6450 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#C33");
6451 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#C34");
6452 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#C35");
6453 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#C36");
6455 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
6457 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#D1");
6458 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#D2");
6459 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#D3");
6460 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#D4");
6461 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#D5");
6462 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#D6");
6463 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#D7");
6464 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#D8");
6465 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#D9");
6466 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#D10");
6467 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#D11");
6468 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#D12");
6469 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#D13");
6470 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#D14");
6471 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#D15");
6472 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#D16");
6473 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#D17");
6474 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#D18");
6475 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#D19");
6476 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#D20");
6477 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#D21");
6478 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#D22");
6479 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#D23");
6480 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#D24");
6481 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#D25");
6482 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#D26");
6483 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#D27");
6484 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#D28");
6485 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#D29");
6486 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#D30");
6487 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#D31");
6488 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#D32");
6489 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#D33");
6490 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#D34");
6491 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#D35");
6492 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#D36");
6494 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
6495 BindingFlags
.FlattenHierarchy
;
6497 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#E1");
6498 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#E2");
6499 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#E3");
6500 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#E4");
6501 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#E5");
6502 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#E6");
6503 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#E7");
6504 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#E8");
6505 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#E9");
6506 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#E10");
6507 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#E11");
6508 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#E12");
6509 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#E13");
6510 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#E14");
6511 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#E15");
6512 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#E16");
6513 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#E17");
6514 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#E18");
6515 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#E19");
6516 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#E20");
6517 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#E21");
6518 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#E22");
6519 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#E23");
6520 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#E24");
6521 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#E25");
6522 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#E26");
6523 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#E27");
6524 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#E28");
6525 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#E29");
6526 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#E30");
6527 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#E31");
6528 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#E32");
6529 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#E33");
6530 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#E34");
6531 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#E35");
6532 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#E36");
6534 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
6535 BindingFlags
.FlattenHierarchy
;
6537 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#F1");
6538 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#F2");
6539 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#F3");
6540 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#F4");
6541 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#F5");
6542 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#F6");
6543 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#F7");
6544 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#F8");
6545 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#F9");
6546 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#F10");
6547 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#F11");
6548 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#F12");
6549 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#F13");
6550 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#F14");
6551 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#F15");
6552 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#F16");
6553 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#F17");
6554 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#F18");
6555 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#F19");
6556 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#F20");
6557 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#F21");
6558 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#F22");
6559 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#F23");
6560 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#F24");
6561 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#F25");
6562 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#F26");
6563 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#F27");
6564 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#F28");
6565 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#F29");
6566 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#F30");
6567 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#F31");
6568 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#F32");
6569 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#F33");
6570 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#F34");
6571 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#F35");
6572 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#F36");
6574 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
6575 BindingFlags
.FlattenHierarchy
;
6577 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#G1");
6578 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#G2");
6579 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#G3");
6580 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#G4");
6581 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#G5");
6582 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#G6");
6583 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#G7");
6584 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#G8");
6585 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#G9");
6586 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#G10");
6587 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#G11");
6588 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#G12");
6589 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#G13");
6590 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#G14");
6591 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#G15");
6592 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#G16");
6593 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#G17");
6594 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#G18");
6595 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#G19");
6596 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#G20");
6597 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#G21");
6598 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#G22");
6599 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#G23");
6600 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#G24");
6601 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#G25");
6602 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#G26");
6603 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#G27");
6604 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#G28");
6605 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#G29");
6606 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#G30");
6607 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#G31");
6608 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#G32");
6609 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#G33");
6610 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#G34");
6611 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#G35");
6612 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#G36");
6614 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
6615 BindingFlags
.FlattenHierarchy
;
6617 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#H1");
6618 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#H2");
6619 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#H3");
6620 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#H4");
6621 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#H5");
6622 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#H6");
6623 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#H7");
6624 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#H8");
6625 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#H9");
6626 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#H10");
6627 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#H11");
6628 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#H12");
6629 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#H13");
6630 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#H14");
6631 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#H15");
6632 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#H16");
6633 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#H17");
6634 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#H18");
6635 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#H19");
6636 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#H20");
6637 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#H21");
6638 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#H22");
6639 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#H23");
6640 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#H24");
6641 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#H25");
6642 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#H26");
6643 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#H27");
6644 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#H28");
6645 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#H29");
6646 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#H30");
6647 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#H31");
6648 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#H32");
6649 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#H33");
6650 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#H34");
6651 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#H35");
6652 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#H36");
6654 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
6655 BindingFlags
.DeclaredOnly
;
6657 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#I1");
6658 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#I2");
6659 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#I3");
6660 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#I4");
6661 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#I5");
6662 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#I6");
6663 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#I7");
6664 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#I8");
6665 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#I9");
6666 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#I10");
6667 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#I11");
6668 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#I12");
6669 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#I13");
6670 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#I14");
6671 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#I15");
6672 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#I16");
6673 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#I17");
6674 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#I18");
6675 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#I19");
6676 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#I20");
6677 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#I21");
6678 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#I22");
6679 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#I23");
6680 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#I24");
6681 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#I25");
6682 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#I26");
6683 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#I27");
6684 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#I28");
6685 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#I29");
6686 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#I30");
6687 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#I31");
6688 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#I32");
6689 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#I33");
6690 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#I34");
6691 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#I35");
6692 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#I36");
6694 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
6695 BindingFlags
.DeclaredOnly
;
6697 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#J1");
6698 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#J2");
6699 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#J3");
6700 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#J4");
6701 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#J5");
6702 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#J6");
6703 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#J7");
6704 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#J8");
6705 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#J9");
6706 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#J10");
6707 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#J11");
6708 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#J12");
6709 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#J13");
6710 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#J14");
6711 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#J15");
6712 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#J16");
6713 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#J17");
6714 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#J18");
6715 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#J19");
6716 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#J20");
6717 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#J21");
6718 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#J22");
6719 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#J23");
6720 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#J24");
6721 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#J25");
6722 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#J26");
6723 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#J27");
6724 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#J28");
6725 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#J29");
6726 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#J30");
6727 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#J31");
6728 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#J32");
6729 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#J33");
6730 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#J34");
6731 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#J35");
6732 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#J36");
6734 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
6735 BindingFlags
.DeclaredOnly
;
6737 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#K1");
6738 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#K2");
6739 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#K3");
6740 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#K4");
6741 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#K5");
6742 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#K6");
6743 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#K7");
6744 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#K8");
6745 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#K9");
6746 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#K10");
6747 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#K11");
6748 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#K12");
6749 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#K13");
6750 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#K14");
6751 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#K15");
6752 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#K16");
6753 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#K17");
6754 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#K18");
6755 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#K19");
6756 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#K20");
6757 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#K21");
6758 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#K22");
6759 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#K23");
6760 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#K24");
6761 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#K25");
6762 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#K26");
6763 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#K27");
6764 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#K28");
6765 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#K29");
6766 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#K30");
6767 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#K31");
6768 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#K32");
6769 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#K33");
6770 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#K34");
6771 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#K35");
6772 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#K36");
6774 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
6775 BindingFlags
.DeclaredOnly
;
6777 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#L1");
6778 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#L2");
6779 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#L3");
6780 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#L4");
6781 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#L5");
6782 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#L6");
6783 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#L7");
6784 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#L8");
6785 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#L9");
6786 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#L10");
6787 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#L11");
6788 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#L12");
6789 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#L13");
6790 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#L14");
6791 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#L15");
6792 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#L16");
6793 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#L17");
6794 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#L18");
6795 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#L19");
6796 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#L20");
6797 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#L21");
6798 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#L22");
6799 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#L23");
6800 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#L24");
6801 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#L25");
6802 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#L26");
6803 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#L27");
6804 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#L28");
6805 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#L29");
6806 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#L30");
6807 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#L31");
6808 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#L32");
6809 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#L33");
6810 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#L34");
6811 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#L35");
6812 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#L36");
6814 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
6815 BindingFlags
.Public
;
6817 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#M1");
6818 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#M2");
6819 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#M3");
6820 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#M4");
6821 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#M5");
6822 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#M6");
6823 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#M7");
6824 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#M8");
6825 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#M9");
6826 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#M10");
6827 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#M11");
6828 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#M12");
6829 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#M13");
6830 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#M14");
6831 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#M15");
6832 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#M16");
6833 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#M17");
6834 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#M18");
6835 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#M19");
6836 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#M20");
6837 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#M21");
6838 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#M22");
6839 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#M23");
6840 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#M24");
6841 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#M25");
6842 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#M26");
6843 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#M27");
6844 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#M28");
6845 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#M29");
6846 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#M30");
6847 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#M31");
6848 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#M32");
6849 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#M33");
6850 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#M34");
6851 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#M35");
6852 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#M36");
6854 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
6855 BindingFlags
.Public
;
6857 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceBlue", flags
), "#N1");
6858 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceBlue", flags
), "#N2");
6859 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceBlue", flags
), "#N3");
6860 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceBlue", flags
), "#N4");
6861 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceBlue", flags
), "#N5");
6862 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceBlue", flags
), "#N6");
6863 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceRed", flags
), "#N7");
6864 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceRed", flags
), "#N8");
6865 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceRed", flags
), "#N9");
6866 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceRed", flags
), "#N10");
6867 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceRed", flags
), "#N11");
6868 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceRed", flags
), "#N12");
6869 Assert
.IsNull (greenType
.GetMethod ("GetPrivateInstanceGreen", flags
), "#N13");
6870 Assert
.IsNull (greenType
.GetMethod ("GetFamilyInstanceGreen", flags
), "#N14");
6871 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemInstanceGreen", flags
), "#N15");
6872 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemInstanceGreen", flags
), "#N16");
6873 Assert
.IsNull (greenType
.GetMethod ("GetPublicInstanceGreen", flags
), "#N17");
6874 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyInstanceGreen", flags
), "#N18");
6875 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticBlue", flags
), "#N19");
6876 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticBlue", flags
), "#N20");
6877 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticBlue", flags
), "#N21");
6878 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticBlue", flags
), "#N22");
6879 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticBlue", flags
), "#N23");
6880 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticBlue", flags
), "#N24");
6881 Assert
.IsNull (greenType
.GetMethod ("GetPrivateStaticRed", flags
), "#N25");
6882 Assert
.IsNull (greenType
.GetMethod ("GetFamilyStaticRed", flags
), "#N26");
6883 Assert
.IsNull (greenType
.GetMethod ("GetFamANDAssemStaticRed", flags
), "#N27");
6884 Assert
.IsNull (greenType
.GetMethod ("GetFamORAssemStaticRed", flags
), "#N28");
6885 Assert
.IsNull (greenType
.GetMethod ("GetPublicStaticRed", flags
), "#N29");
6886 Assert
.IsNull (greenType
.GetMethod ("GetAssemblyStaticRed", flags
), "#N30");
6887 Assert
.IsNotNull (greenType
.GetMethod ("GetPrivateStaticGreen", flags
), "#N31");
6888 Assert
.IsNotNull (greenType
.GetMethod ("GetFamilyStaticGreen", flags
), "#N32");
6889 Assert
.IsNotNull (greenType
.GetMethod ("GetFamANDAssemStaticGreen", flags
), "#N33");
6890 Assert
.IsNotNull (greenType
.GetMethod ("GetFamORAssemStaticGreen", flags
), "#N34");
6891 Assert
.IsNotNull (greenType
.GetMethod ("GetPublicStaticGreen", flags
), "#N35");
6892 Assert
.IsNotNull (greenType
.GetMethod ("GetAssemblyStaticGreen", flags
), "#N36");
6896 [Category ("NotDotNet")] // mcs depends on this
6897 public void TestGetMethodsIncomplete_Mono ()
6902 TypeBuilder tb
= module
.DefineType (genTypeName (),
6903 TypeAttributes
.Abstract
);
6904 mb
= tb
.DefineMethod ("Hello", MethodAttributes
.Public
,
6905 typeof (void), Type
.EmptyTypes
);
6906 ilgen
= mb
.GetILGenerator ();
6907 ilgen
.Emit (OpCodes
.Ret
);
6909 mb
= tb
.DefineMethod ("Run", MethodAttributes
.Private
,
6910 typeof (void), Type
.EmptyTypes
);
6911 ilgen
= mb
.GetILGenerator ();
6912 ilgen
.Emit (OpCodes
.Ret
);
6914 mb
= tb
.DefineMethod ("Execute", MethodAttributes
.Public
|
6915 MethodAttributes
.Static
,
6916 typeof (void), Type
.EmptyTypes
);
6917 ilgen
= mb
.GetILGenerator ();
6918 ilgen
.Emit (OpCodes
.Ret
);
6920 mb
= tb
.DefineMethod ("Init", MethodAttributes
.Public
|
6921 MethodAttributes
.Abstract
| MethodAttributes
.Virtual
,
6922 typeof (void), Type
.EmptyTypes
);
6924 MethodInfo
[] methods
= tb
.GetMethods ();
6925 Assert
.AreEqual (7, methods
.Length
, "#A");
6927 Assert
.AreEqual ("Equals", methods
[0].Name
, "#B1");
6928 Assert
.IsFalse (methods
[0].IsStatic
, "#B2");
6929 Assert
.IsFalse (methods
[0].IsAbstract
, "#B3");
6931 Assert
.AreEqual ("GetHashCode", methods
[1].Name
, "#C1");
6932 Assert
.IsFalse (methods
[1].IsStatic
, "#C2");
6933 Assert
.IsFalse (methods
[1].IsAbstract
, "#C3");
6935 Assert
.AreEqual ("GetType", methods
[2].Name
, "#D1");
6936 Assert
.IsFalse (methods
[2].IsStatic
, "#D2");
6937 Assert
.IsFalse (methods
[2].IsAbstract
, "#D3");
6939 Assert
.AreEqual ("ToString", methods
[3].Name
, "#E1");
6940 Assert
.IsFalse (methods
[3].IsStatic
, "#E2");
6941 Assert
.IsFalse (methods
[3].IsAbstract
, "#E3");
6943 Assert
.AreEqual ("Hello", methods
[4].Name
, "#F1");
6944 Assert
.IsFalse (methods
[4].IsStatic
, "#F2");
6945 Assert
.IsFalse (methods
[4].IsAbstract
, "#F3");
6947 Assert
.AreEqual ("Execute", methods
[5].Name
, "#G1");
6948 Assert
.IsTrue (methods
[5].IsStatic
, "#G2");
6949 Assert
.IsFalse (methods
[5].IsAbstract
, "#G3");
6951 Assert
.AreEqual ("Init", methods
[6].Name
, "#H1");
6952 Assert
.IsFalse (methods
[6].IsStatic
, "#H2");
6953 Assert
.IsTrue (methods
[6].IsAbstract
, "#H3");
6957 [Category ("NotWorking")] // mcs depends on this
6958 public void TestGetMethodsIncomplete_MS ()
6963 TypeBuilder tb
= module
.DefineType (genTypeName (),
6964 TypeAttributes
.Abstract
);
6965 mb
= tb
.DefineMethod ("Hello", MethodAttributes
.Public
,
6966 typeof (void), Type
.EmptyTypes
);
6967 ilgen
= mb
.GetILGenerator ();
6968 ilgen
.Emit (OpCodes
.Ret
);
6970 mb
= tb
.DefineMethod ("Run", MethodAttributes
.Private
,
6971 typeof (void), Type
.EmptyTypes
);
6972 ilgen
= mb
.GetILGenerator ();
6973 ilgen
.Emit (OpCodes
.Ret
);
6975 mb
= tb
.DefineMethod ("Execute", MethodAttributes
.Public
|
6976 MethodAttributes
.Static
,
6977 typeof (void), Type
.EmptyTypes
);
6978 ilgen
= mb
.GetILGenerator ();
6979 ilgen
.Emit (OpCodes
.Ret
);
6981 mb
= tb
.DefineMethod ("Init", MethodAttributes
.Public
|
6982 MethodAttributes
.Abstract
| MethodAttributes
.Virtual
,
6983 typeof (void), Type
.EmptyTypes
);
6988 } catch (NotSupportedException ex
) {
6989 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
6990 Assert
.IsNull (ex
.InnerException
, "#3");
6991 Assert
.IsNotNull (ex
.Message
, "#4");
6996 public void TestGetMethodsComplete ()
7002 TypeBuilder tb
= module
.DefineType (genTypeName (),
7003 TypeAttributes
.Abstract
);
7004 mb
= tb
.DefineMethod ("Hello", MethodAttributes
.Public
,
7005 typeof (string), Type
.EmptyTypes
);
7006 ilgen
= mb
.GetILGenerator ();
7007 ilgen
.Emit (OpCodes
.Ldstr
, "Hi! ");
7008 ilgen
.Emit (OpCodes
.Ldarg_1
);
7009 MethodInfo infoMethod
= typeof (string).GetMethod ("Concat",
7010 new Type
[] { typeof (string), typeof (string) }
);
7011 ilgen
.Emit (OpCodes
.Call
, infoMethod
);
7012 ilgen
.Emit (OpCodes
.Ret
);
7014 mb
= tb
.DefineMethod ("Run", MethodAttributes
.Private
,
7015 typeof (void), Type
.EmptyTypes
);
7016 ilgen
= mb
.GetILGenerator ();
7017 ilgen
.Emit (OpCodes
.Ret
);
7019 mb
= tb
.DefineMethod ("Execute", MethodAttributes
.Public
|
7020 MethodAttributes
.Static
,
7021 typeof (void), Type
.EmptyTypes
);
7022 ilgen
= mb
.GetILGenerator ();
7023 ilgen
.Emit (OpCodes
.Ret
);
7025 mb
= tb
.DefineMethod ("Init", MethodAttributes
.Public
|
7026 MethodAttributes
.Abstract
| MethodAttributes
.Virtual
,
7027 typeof (void), Type
.EmptyTypes
);
7029 Type emittedType
= tb
.CreateType ();
7031 MethodInfo
[] methods
= emittedType
.GetMethods ();
7032 Assert
.AreEqual (7, methods
.Length
, "#A1");
7033 Assert
.AreEqual (7, tb
.GetMethods ().Length
, "#A2");
7035 mi
= GetMethodByName (methods
, "Hello");
7036 Assert
.IsNotNull (mi
, "#B1");
7037 Assert
.IsFalse (mi
.IsStatic
, "#B2");
7038 Assert
.IsFalse (mi
.IsAbstract
, "#B3");
7040 mi
= GetMethodByName (methods
, "Execute");
7041 Assert
.IsNotNull (mi
, "#C1");
7042 Assert
.IsTrue (mi
.IsStatic
, "#C2");
7043 Assert
.IsFalse (mi
.IsAbstract
, "#C3");
7045 mi
= GetMethodByName (methods
, "Init");
7046 Assert
.IsNotNull (mi
, "#D1");
7047 Assert
.IsFalse (mi
.IsStatic
, "#D2");
7048 Assert
.IsTrue (mi
.IsAbstract
, "#D3");
7050 mi
= GetMethodByName (methods
, "GetType");
7051 Assert
.IsNotNull (mi
, "#E1");
7052 Assert
.IsFalse (methods
[3].IsStatic
, "#E2");
7053 Assert
.IsFalse (methods
[3].IsAbstract
, "#E3");
7055 mi
= GetMethodByName (methods
, "ToString");
7056 Assert
.IsNotNull (mi
, "#F1");
7057 Assert
.IsFalse (mi
.IsStatic
, "#F2");
7058 Assert
.IsFalse (mi
.IsAbstract
, "#F3");
7060 mi
= GetMethodByName (methods
, "Equals");
7061 Assert
.IsNotNull (mi
, "#G1");
7062 Assert
.IsFalse (mi
.IsStatic
, "#G2");
7063 Assert
.IsFalse (mi
.IsAbstract
, "#G3");
7065 mi
= GetMethodByName (methods
, "GetHashCode");
7066 Assert
.IsNotNull (mi
, "#H1");
7067 Assert
.IsFalse (mi
.IsStatic
, "#H2");
7068 Assert
.IsFalse (mi
.IsAbstract
, "#H3");
7072 [Category ("NotDotNet")] // mcs depends on this
7073 public void TestGetMethodsFlagsIncomplete_Inheritance ()
7075 MethodInfo
[] methods
;
7078 TypeBuilder blueType
= module
.DefineType (genTypeName (),
7079 TypeAttributes
.Public
);
7080 CreateMembers (blueType
, "Blue", false);
7082 TypeBuilder redType
= module
.DefineType (genTypeName (),
7083 TypeAttributes
.Public
, blueType
);
7084 CreateMembers (redType
, "Red", false);
7086 TypeBuilder greenType
= module
.DefineType (genTypeName (),
7087 TypeAttributes
.Public
, redType
);
7088 CreateMembers (greenType
, "Green", false);
7090 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
7091 methods
= greenType
.GetMethods (flags
);
7093 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#A1");
7094 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#A2");
7095 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#A3");
7096 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#A4");
7097 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#A5");
7098 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#A6");
7099 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#A7");
7100 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#A8");
7101 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#A9");
7102 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#A10");
7103 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#A11");
7104 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#A12");
7105 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#A13");
7106 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#A14");
7107 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#A15");
7108 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#A16");
7109 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#A17");
7110 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#A18");
7111 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#A19");
7112 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#A20");
7113 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#A21");
7114 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#A22");
7115 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#A23");
7116 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#A24");
7117 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#A25");
7118 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#A26");
7119 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#A27");
7120 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#A28");
7121 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#A29");
7122 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#A30");
7123 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#A31");
7124 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#A32");
7125 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#A33");
7126 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#A34");
7127 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#A35");
7128 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#A36");
7130 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
7131 methods
= greenType
.GetMethods (flags
);
7133 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#B1");
7134 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#B2");
7135 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#B3");
7136 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#B4");
7137 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#B5");
7138 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#B6");
7139 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#B7");
7140 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#B8");
7141 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#B9");
7142 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#B10");
7143 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#B11");
7144 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#B12");
7145 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#B13");
7146 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#B14");
7147 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#B15");
7148 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#B16");
7149 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#B17");
7150 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#B18");
7151 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#B19");
7152 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#B20");
7153 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#B21");
7154 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#B22");
7155 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#B23");
7156 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#B24");
7157 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#B25");
7158 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#B26");
7159 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#B27");
7160 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#B28");
7161 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#B29");
7162 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#B30");
7163 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#B31");
7164 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#B32");
7165 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#B33");
7166 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#B34");
7167 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#B35");
7168 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#B36");
7170 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
7171 methods
= greenType
.GetMethods (flags
);
7173 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#C1");
7174 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#C2");
7175 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#C3");
7176 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#C4");
7177 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#C5");
7178 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#C6");
7179 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#C7");
7180 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#C8");
7181 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#C9");
7182 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#C10");
7183 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#C11");
7184 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#C12");
7185 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#C13");
7186 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#C14");
7187 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#C15");
7188 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#C16");
7189 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#C17");
7190 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#C18");
7191 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#C19");
7192 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#C20");
7193 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#C21");
7194 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#C22");
7195 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#C23");
7196 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#C24");
7197 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#C25");
7198 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#C26");
7199 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#C27");
7200 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#C28");
7201 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#C29");
7202 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#C30");
7203 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#C31");
7204 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#C32");
7205 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#C33");
7206 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#C34");
7207 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#C35");
7208 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#C36");
7210 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
7211 methods
= greenType
.GetMethods (flags
);
7213 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#D1");
7214 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#D2");
7215 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#D3");
7216 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#D4");
7217 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#D5");
7218 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#D6");
7219 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#D7");
7220 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#D8");
7221 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#D9");
7222 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#D10");
7223 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#D11");
7224 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#D12");
7225 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#D13");
7226 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#D14");
7227 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#D15");
7228 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#D16");
7229 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#D17");
7230 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#D18");
7231 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#D19");
7232 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#D20");
7233 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#D21");
7234 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#D22");
7235 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#D23");
7236 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#D24");
7237 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#D25");
7238 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#D26");
7239 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#D27");
7240 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#D28");
7241 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#D29");
7242 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#D30");
7243 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#D31");
7244 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#D32");
7245 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#D33");
7246 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#D34");
7247 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#D35");
7248 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#D36");
7250 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
7251 BindingFlags
.FlattenHierarchy
;
7252 methods
= greenType
.GetMethods (flags
);
7254 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#E1");
7255 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#E2");
7256 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#E3");
7257 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#E4");
7258 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#E5");
7259 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#E6");
7260 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#E7");
7261 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#E8");
7262 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#E9");
7263 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#E10");
7264 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#E11");
7265 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#E12");
7266 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#E13");
7267 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#E14");
7268 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#E15");
7269 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#E16");
7270 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#E17");
7271 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#E18");
7272 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#E19");
7273 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#E20");
7274 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#E21");
7275 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#E22");
7276 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#E23");
7277 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#E24");
7278 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#E25");
7279 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#E26");
7280 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#E27");
7281 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#E28");
7282 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#E29");
7283 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#E30");
7284 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#E31");
7285 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#E32");
7286 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#E33");
7287 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#E34");
7288 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#E35");
7289 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#E36");
7291 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
7292 BindingFlags
.FlattenHierarchy
;
7293 methods
= greenType
.GetMethods (flags
);
7295 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#F1");
7296 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#F2");
7297 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#F3");
7298 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#F4");
7299 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#F5");
7300 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#F6");
7301 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#F7");
7302 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#F8");
7303 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#F9");
7304 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#F10");
7305 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#F11");
7306 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#F12");
7307 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#F13");
7308 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#F14");
7309 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#F15");
7310 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#F16");
7311 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#F17");
7312 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#F18");
7313 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#F19");
7314 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#F20");
7315 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#F21");
7316 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#F22");
7317 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#F23");
7318 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#F24");
7319 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#F25");
7320 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#F26");
7321 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#F27");
7322 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#F28");
7323 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#F29");
7324 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#F30");
7325 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#F31");
7326 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#F32");
7327 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#F33");
7328 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#F34");
7329 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#F35");
7330 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#F36");
7332 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
7333 BindingFlags
.FlattenHierarchy
;
7334 methods
= greenType
.GetMethods (flags
);
7336 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#G1");
7337 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#G2");
7338 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#G3");
7339 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#G4");
7340 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#G5");
7341 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#G6");
7342 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#G7");
7343 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#G8");
7344 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#G9");
7345 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#G10");
7346 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#G11");
7347 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#G12");
7348 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#G13");
7349 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#G14");
7350 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#G15");
7351 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#G16");
7352 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#G17");
7353 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#G18");
7354 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#G19");
7355 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#G20");
7356 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#G21");
7357 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#G22");
7358 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#G23");
7359 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#G24");
7360 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#G25");
7361 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#G26");
7362 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#G27");
7363 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#G28");
7364 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#G29");
7365 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#G30");
7366 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#G31");
7367 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#G32");
7368 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#G33");
7369 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#G34");
7370 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#G35");
7371 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#G36");
7373 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
7374 BindingFlags
.FlattenHierarchy
;
7375 methods
= greenType
.GetMethods (flags
);
7377 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#H1");
7378 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#H2");
7379 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#H3");
7380 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#H4");
7381 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#H5");
7382 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#H6");
7383 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#H7");
7384 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#H8");
7385 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#H9");
7386 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#H10");
7387 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#H11");
7388 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#H12");
7389 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#H13");
7390 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#H14");
7391 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#H15");
7392 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#H16");
7393 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#H17");
7394 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#H18");
7395 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#H19");
7396 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#H20");
7397 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#H21");
7398 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#H22");
7399 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#H23");
7400 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#H24");
7401 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#H25");
7402 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#H26");
7403 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#H27");
7404 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#H28");
7405 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#H29");
7406 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#H30");
7407 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#H31");
7408 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#H32");
7409 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#H33");
7410 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#H34");
7411 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#H35");
7412 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#H36");
7414 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
7415 BindingFlags
.DeclaredOnly
;
7416 methods
= greenType
.GetMethods (flags
);
7418 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#I1");
7419 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#I2");
7420 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#I3");
7421 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#I4");
7422 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#I5");
7423 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#I6");
7424 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#I7");
7425 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#I8");
7426 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#I9");
7427 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#I10");
7428 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#I11");
7429 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#I12");
7430 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#I13");
7431 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#I14");
7432 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#I15");
7433 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#I16");
7434 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#I17");
7435 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#I18");
7436 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#I19");
7437 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#I20");
7438 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#I21");
7439 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#I22");
7440 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#I23");
7441 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#I24");
7442 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#I25");
7443 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#I26");
7444 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#I27");
7445 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#I28");
7446 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#I29");
7447 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#I30");
7448 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#I31");
7449 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#I32");
7450 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#I33");
7451 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#I34");
7452 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#I35");
7453 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#I36");
7455 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
7456 BindingFlags
.DeclaredOnly
;
7457 methods
= greenType
.GetMethods (flags
);
7459 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#J1");
7460 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#J2");
7461 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#J3");
7462 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#J4");
7463 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#J5");
7464 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#J6");
7465 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#J7");
7466 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#J8");
7467 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#J9");
7468 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#J10");
7469 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#J11");
7470 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#J12");
7471 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#J13");
7472 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#J14");
7473 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#J15");
7474 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#J16");
7475 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#J17");
7476 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#J18");
7477 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#J19");
7478 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#J20");
7479 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#J21");
7480 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#J22");
7481 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#J23");
7482 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#J24");
7483 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#J25");
7484 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#J26");
7485 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#J27");
7486 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#J28");
7487 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#J29");
7488 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#J30");
7489 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#J31");
7490 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#J32");
7491 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#J33");
7492 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#J34");
7493 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#J35");
7494 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#J36");
7496 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
7497 BindingFlags
.DeclaredOnly
;
7498 methods
= greenType
.GetMethods (flags
);
7500 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#K1");
7501 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#K2");
7502 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#K3");
7503 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#K4");
7504 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#K5");
7505 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#K6");
7506 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#K7");
7507 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#K8");
7508 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#K9");
7509 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#K10");
7510 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#K11");
7511 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#K12");
7512 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#K13");
7513 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#K14");
7514 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#K15");
7515 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#K16");
7516 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#K17");
7517 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#K18");
7518 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#K19");
7519 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#K20");
7520 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#K21");
7521 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#K22");
7522 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#K23");
7523 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#K24");
7524 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#K25");
7525 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#K26");
7526 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#K27");
7527 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#K28");
7528 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#K29");
7529 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#K30");
7530 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#K31");
7531 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#K32");
7532 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#K33");
7533 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#K34");
7534 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#K35");
7535 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#K36");
7537 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
7538 BindingFlags
.DeclaredOnly
;
7539 methods
= greenType
.GetMethods (flags
);
7541 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#L1");
7542 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#L2");
7543 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#L3");
7544 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#L4");
7545 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#L5");
7546 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#L6");
7547 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#L7");
7548 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#L8");
7549 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#L9");
7550 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#L10");
7551 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#L11");
7552 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#L12");
7553 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#L13");
7554 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#L14");
7555 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#L15");
7556 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#L16");
7557 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#L17");
7558 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#L18");
7559 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#L19");
7560 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#L20");
7561 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#L21");
7562 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#L22");
7563 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#L23");
7564 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#L24");
7565 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#L25");
7566 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#L26");
7567 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#L27");
7568 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#L28");
7569 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#L29");
7570 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#L30");
7571 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#L31");
7572 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#L32");
7573 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#L33");
7574 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#L34");
7575 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#L35");
7576 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#L36");
7578 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
7579 BindingFlags
.Public
;
7580 methods
= greenType
.GetMethods (flags
);
7582 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#M1");
7583 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#M2");
7584 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#M3");
7585 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#M4");
7586 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#M5");
7587 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#M6");
7588 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#M7");
7589 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#M8");
7590 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#M9");
7591 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#M10");
7592 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#M11");
7593 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#M12");
7594 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#M13");
7595 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#M14");
7596 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#M15");
7597 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#M16");
7598 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#M17");
7599 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#M18");
7600 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#M19");
7601 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#M20");
7602 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#M21");
7603 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#M22");
7604 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#M23");
7605 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#M24");
7606 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#M25");
7607 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#M26");
7608 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#M27");
7609 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#M28");
7610 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#M29");
7611 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#M30");
7612 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#M31");
7613 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#M32");
7614 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#M33");
7615 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#M34");
7616 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#M35");
7617 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#M36");
7619 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
7620 BindingFlags
.Public
;
7621 methods
= greenType
.GetMethods (flags
);
7623 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#N1");
7624 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#N2");
7625 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#N3");
7626 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#N4");
7627 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#N5");
7628 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#N6");
7629 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#N7");
7630 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#N8");
7631 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#N9");
7632 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#N10");
7633 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#N11");
7634 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#N12");
7635 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#N13");
7636 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#N14");
7637 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#N15");
7638 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#N16");
7639 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#N17");
7640 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#N18");
7641 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#N19");
7642 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#N20");
7643 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#N21");
7644 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#N22");
7645 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#N23");
7646 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#N24");
7647 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#N25");
7648 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#N26");
7649 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#N27");
7650 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#N28");
7651 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#N29");
7652 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#N30");
7653 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#N31");
7654 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#N32");
7655 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#N33");
7656 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#N34");
7657 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#N35");
7658 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#N36");
7662 [Category ("NotDotNet")] // mcs depends on this
7663 public void TestGetMethodsFlagsIncomplete_Mono ()
7667 MethodInfo
[] methods
;
7669 TypeBuilder tb
= module
.DefineType (genTypeName (),
7670 TypeAttributes
.Abstract
);
7671 mb
= tb
.DefineMethod ("Hello", MethodAttributes
.Public
,
7672 typeof (void), Type
.EmptyTypes
);
7673 ilgen
= mb
.GetILGenerator ();
7674 ilgen
.Emit (OpCodes
.Ret
);
7676 mb
= tb
.DefineMethod ("Run", MethodAttributes
.Private
,
7677 typeof (void), Type
.EmptyTypes
);
7678 ilgen
= mb
.GetILGenerator ();
7679 ilgen
.Emit (OpCodes
.Ret
);
7681 mb
= tb
.DefineMethod ("Execute", MethodAttributes
.Public
|
7682 MethodAttributes
.Static
,
7683 typeof (void), Type
.EmptyTypes
);
7684 ilgen
= mb
.GetILGenerator ();
7685 ilgen
.Emit (OpCodes
.Ret
);
7687 mb
= tb
.DefineMethod ("Init", MethodAttributes
.Public
|
7688 MethodAttributes
.Abstract
| MethodAttributes
.Virtual
,
7689 typeof (void), Type
.EmptyTypes
);
7691 methods
= tb
.GetMethods (BindingFlags
.Public
|
7692 BindingFlags
.Instance
);
7693 Assert
.AreEqual (6, methods
.Length
, "#A1");
7694 Assert
.IsNotNull (GetMethodByName (methods
, "Hello"), "#A2");
7695 Assert
.IsNotNull (GetMethodByName (methods
, "Init"), "#A3");
7696 Assert
.IsNotNull (GetMethodByName (methods
, "ToString"), "#A4");
7697 Assert
.IsNotNull (GetMethodByName (methods
, "Equals"), "#A5");
7698 Assert
.IsNotNull (GetMethodByName (methods
, "GetHashCode"), "#A6");
7700 methods
= tb
.GetMethods (BindingFlags
.Public
|
7701 BindingFlags
.Instance
| BindingFlags
.DeclaredOnly
);
7702 Assert
.AreEqual (2, methods
.Length
, "#B1");
7703 Assert
.IsNotNull (GetMethodByName (methods
, "Hello"), "#B2");
7704 Assert
.IsNotNull (GetMethodByName (methods
, "Init"), "#B3");
7706 methods
= tb
.GetMethods (BindingFlags
.Public
|
7707 BindingFlags
.Instance
| BindingFlags
.Static
);
7708 Assert
.AreEqual (7, methods
.Length
, "#C1");
7709 Assert
.IsNotNull (GetMethodByName (methods
, "Hello"), "#C2");
7710 Assert
.IsNotNull (GetMethodByName (methods
, "Init"), "#C3");
7711 Assert
.IsNotNull (GetMethodByName (methods
, "Execute"), "#C4");
7712 Assert
.IsNotNull (GetMethodByName (methods
, "ToString"), "#C5");
7713 Assert
.IsNotNull (GetMethodByName (methods
, "Equals"), "#C6");
7714 Assert
.IsNotNull (GetMethodByName (methods
, "GetHashCode"), "#C7");
7716 methods
= tb
.GetMethods (BindingFlags
.NonPublic
|
7717 BindingFlags
.Instance
| BindingFlags
.DeclaredOnly
);
7718 Assert
.AreEqual (1, methods
.Length
, "#D1");
7719 Assert
.IsNotNull (GetMethodByName (methods
, "Run"), "#D2");
7724 [Category ("NotWorking")] // mcs depends on this
7725 public void TestGetMethodsFlagsIncomplete_MS ()
7730 TypeBuilder tb
= module
.DefineType (genTypeName (),
7731 TypeAttributes
.Abstract
);
7732 mb
= tb
.DefineMethod ("Hello", MethodAttributes
.Public
,
7733 typeof (void), Type
.EmptyTypes
);
7734 ilgen
= mb
.GetILGenerator ();
7735 ilgen
.Emit (OpCodes
.Ret
);
7737 mb
= tb
.DefineMethod ("Run", MethodAttributes
.Private
,
7738 typeof (void), Type
.EmptyTypes
);
7739 ilgen
= mb
.GetILGenerator ();
7740 ilgen
.Emit (OpCodes
.Ret
);
7742 mb
= tb
.DefineMethod ("Execute", MethodAttributes
.Public
|
7743 MethodAttributes
.Static
,
7744 typeof (void), Type
.EmptyTypes
);
7745 ilgen
= mb
.GetILGenerator ();
7746 ilgen
.Emit (OpCodes
.Ret
);
7748 mb
= tb
.DefineMethod ("Init", MethodAttributes
.Public
|
7749 MethodAttributes
.Abstract
| MethodAttributes
.Virtual
,
7750 typeof (void), Type
.EmptyTypes
);
7753 tb
.GetMethods (BindingFlags
.Public
| BindingFlags
.Instance
);
7755 } catch (NotSupportedException ex
) {
7756 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
7757 Assert
.IsNull (ex
.InnerException
, "#3");
7758 Assert
.IsNotNull (ex
.Message
, "#4");
7763 public void TestGetMethodsFlagsComplete ()
7765 TypeBuilder tb
= module
.DefineType (genTypeName ());
7766 MethodBuilder helloMethod
= tb
.DefineMethod ("HelloMethod",
7767 MethodAttributes
.Public
, typeof (string), Type
.EmptyTypes
);
7768 ILGenerator helloMethodIL
= helloMethod
.GetILGenerator ();
7769 helloMethodIL
.Emit (OpCodes
.Ldstr
, "Hi! ");
7770 helloMethodIL
.Emit (OpCodes
.Ldarg_1
);
7771 MethodInfo infoMethod
= typeof (string).GetMethod ("Concat",
7772 new Type
[] { typeof (string), typeof (string) }
);
7773 helloMethodIL
.Emit (OpCodes
.Call
, infoMethod
);
7774 helloMethodIL
.Emit (OpCodes
.Ret
);
7776 Type emittedType
= tb
.CreateType ();
7778 Assert
.AreEqual (1, tb
.GetMethods (BindingFlags
.Instance
| BindingFlags
.Public
| BindingFlags
.DeclaredOnly
).Length
, "#1");
7779 Assert
.AreEqual (tb
.GetMethods (BindingFlags
.Instance
| BindingFlags
.Public
).Length
,
7780 emittedType
.GetMethods (BindingFlags
.Instance
| BindingFlags
.Public
).Length
, "#2");
7781 Assert
.AreEqual (0, tb
.GetMethods (BindingFlags
.Instance
| BindingFlags
.NonPublic
| BindingFlags
.DeclaredOnly
).Length
, "#3");
7782 Assert
.AreEqual (tb
.GetMethods (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
,
7783 emittedType
.GetMethods (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
, "#4");
7787 public void TestGetMethodsFlagsComplete_Inheritance ()
7789 MethodInfo
[] methods
;
7792 TypeBuilder blueType
= module
.DefineType (genTypeName (),
7793 TypeAttributes
.Public
);
7794 CreateMembers (blueType
, "Blue", false);
7796 TypeBuilder redType
= module
.DefineType (genTypeName (),
7797 TypeAttributes
.Public
, blueType
);
7798 CreateMembers (redType
, "Red", false);
7800 TypeBuilder greenType
= module
.DefineType (genTypeName (),
7801 TypeAttributes
.Public
, redType
);
7802 CreateMembers (greenType
, "Green", false);
7804 blueType
.CreateType ();
7805 redType
.CreateType ();
7806 greenType
.CreateType ();
7808 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
;
7809 methods
= greenType
.GetMethods (flags
);
7811 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#A1");
7812 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#A2");
7813 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#A3");
7814 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#A4");
7815 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#A5");
7816 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#A6");
7817 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#A7");
7818 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#A8");
7819 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#A9");
7820 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#A10");
7821 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#A11");
7822 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#A12");
7823 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#A13");
7824 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#A14");
7825 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#A15");
7826 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#A16");
7827 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#A17");
7828 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#A18");
7829 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#A19");
7830 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#A20");
7831 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#A21");
7832 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#A22");
7833 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#A23");
7834 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#A24");
7835 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#A25");
7836 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#A26");
7837 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#A27");
7838 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#A28");
7839 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#A29");
7840 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#A30");
7841 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#A31");
7842 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#A32");
7843 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#A33");
7844 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#A34");
7845 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#A35");
7846 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#A36");
7848 flags
= BindingFlags
.Instance
| BindingFlags
.Public
;
7849 methods
= greenType
.GetMethods (flags
);
7851 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#B1");
7852 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#B2");
7853 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#B3");
7854 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#B4");
7855 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#B5");
7856 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#B6");
7857 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#B7");
7858 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#B8");
7859 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#B9");
7860 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#B10");
7861 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#B11");
7862 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#B12");
7863 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#B13");
7864 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#B14");
7865 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#B15");
7866 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#B16");
7867 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#B17");
7868 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#B18");
7869 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#B19");
7870 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#B20");
7871 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#B21");
7872 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#B22");
7873 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#B23");
7874 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#B24");
7875 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#B25");
7876 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#B26");
7877 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#B27");
7878 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#B28");
7879 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#B29");
7880 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#B30");
7881 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#B31");
7882 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#B32");
7883 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#B33");
7884 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#B34");
7885 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#B35");
7886 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#B36");
7888 flags
= BindingFlags
.Static
| BindingFlags
.Public
;
7889 methods
= greenType
.GetMethods (flags
);
7891 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#C1");
7892 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#C2");
7893 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#C3");
7894 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#C4");
7895 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#C5");
7896 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#C6");
7897 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#C7");
7898 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#C8");
7899 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#C9");
7900 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#C10");
7901 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#C11");
7902 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#C12");
7903 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#C13");
7904 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#C14");
7905 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#C15");
7906 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#C16");
7907 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#C17");
7908 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#C18");
7909 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#C19");
7910 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#C20");
7911 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#C21");
7912 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#C22");
7913 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#C23");
7914 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#C24");
7915 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#C25");
7916 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#C26");
7917 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#C27");
7918 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#C28");
7919 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#C29");
7920 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#C30");
7921 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#C31");
7922 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#C32");
7923 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#C33");
7924 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#C34");
7925 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#C35");
7926 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#C36");
7928 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
;
7929 methods
= greenType
.GetMethods (flags
);
7931 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#D1");
7932 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#D2");
7933 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#D3");
7934 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#D4");
7935 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#D5");
7936 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#D6");
7937 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#D7");
7938 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#D8");
7939 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#D9");
7940 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#D10");
7941 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#D11");
7942 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#D12");
7943 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#D13");
7944 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#D14");
7945 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#D15");
7946 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#D16");
7947 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#D17");
7948 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#D18");
7949 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#D19");
7950 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#D20");
7951 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#D21");
7952 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#D22");
7953 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#D23");
7954 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#D24");
7955 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#D25");
7956 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#D26");
7957 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#D27");
7958 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#D28");
7959 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#D29");
7960 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#D30");
7961 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#D31");
7962 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#D32");
7963 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#D33");
7964 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#D34");
7965 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#D35");
7966 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#D36");
7968 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
7969 BindingFlags
.FlattenHierarchy
;
7970 methods
= greenType
.GetMethods (flags
);
7972 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#E1");
7973 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#E2");
7974 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#E3");
7975 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#E4");
7976 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#E5");
7977 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#E6");
7978 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#E7");
7979 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#E8");
7980 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#E9");
7981 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#E10");
7982 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#E11");
7983 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#E12");
7984 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#E13");
7985 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#E14");
7986 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#E15");
7987 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#E16");
7988 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#E17");
7989 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#E18");
7990 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#E19");
7991 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#E20");
7992 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#E21");
7993 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#E22");
7994 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#E23");
7995 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#E24");
7996 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#E25");
7997 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#E26");
7998 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#E27");
7999 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#E28");
8000 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#E29");
8001 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#E30");
8002 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#E31");
8003 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#E32");
8004 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#E33");
8005 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#E34");
8006 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#E35");
8007 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#E36");
8009 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
8010 BindingFlags
.FlattenHierarchy
;
8011 methods
= greenType
.GetMethods (flags
);
8013 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#F1");
8014 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#F2");
8015 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#F3");
8016 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#F4");
8017 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#F5");
8018 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#F6");
8019 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#F7");
8020 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#F8");
8021 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#F9");
8022 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#F10");
8023 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#F11");
8024 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#F12");
8025 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#F13");
8026 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#F14");
8027 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#F15");
8028 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#F16");
8029 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#F17");
8030 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#F18");
8031 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#F19");
8032 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#F20");
8033 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#F21");
8034 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#F22");
8035 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#F23");
8036 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#F24");
8037 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#F25");
8038 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#F26");
8039 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#F27");
8040 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#F28");
8041 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#F29");
8042 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#F30");
8043 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#F31");
8044 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#F32");
8045 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#F33");
8046 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#F34");
8047 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#F35");
8048 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#F36");
8050 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
8051 BindingFlags
.FlattenHierarchy
;
8052 methods
= greenType
.GetMethods (flags
);
8054 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#G1");
8055 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#G2");
8056 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#G3");
8057 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#G4");
8058 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#G5");
8059 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#G6");
8060 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#G7");
8061 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#G8");
8062 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#G9");
8063 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#G10");
8064 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#G11");
8065 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#G12");
8066 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#G13");
8067 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#G14");
8068 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#G15");
8069 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#G16");
8070 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#G17");
8071 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#G18");
8072 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#G19");
8073 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#G20");
8074 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#G21");
8075 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#G22");
8076 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#G23");
8077 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#G24");
8078 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#G25");
8079 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#G26");
8080 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#G27");
8081 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#G28");
8082 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#G29");
8083 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#G30");
8084 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#G31");
8085 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#G32");
8086 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#G33");
8087 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#G34");
8088 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#G35");
8089 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#G36");
8091 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
8092 BindingFlags
.FlattenHierarchy
;
8093 methods
= greenType
.GetMethods (flags
);
8095 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#H1");
8096 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#H2");
8097 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#H3");
8098 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#H4");
8099 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#H5");
8100 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#H6");
8101 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#H7");
8102 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#H8");
8103 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#H9");
8104 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#H10");
8105 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#H11");
8106 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#H12");
8107 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#H13");
8108 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#H14");
8109 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#H15");
8110 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#H16");
8111 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#H17");
8112 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#H18");
8113 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#H19");
8114 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#H20");
8115 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#H21");
8116 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#H22");
8117 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#H23");
8118 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#H24");
8119 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#H25");
8120 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#H26");
8121 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#H27");
8122 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#H28");
8123 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#H29");
8124 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#H30");
8125 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#H31");
8126 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#H32");
8127 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#H33");
8128 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#H34");
8129 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#H35");
8130 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#H36");
8132 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
8133 BindingFlags
.DeclaredOnly
;
8134 methods
= greenType
.GetMethods (flags
);
8136 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#I1");
8137 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#I2");
8138 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#I3");
8139 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#I4");
8140 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#I5");
8141 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#I6");
8142 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#I7");
8143 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#I8");
8144 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#I9");
8145 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#I10");
8146 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#I11");
8147 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#I12");
8148 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#I13");
8149 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#I14");
8150 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#I15");
8151 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#I16");
8152 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#I17");
8153 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#I18");
8154 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#I19");
8155 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#I20");
8156 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#I21");
8157 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#I22");
8158 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#I23");
8159 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#I24");
8160 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#I25");
8161 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#I26");
8162 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#I27");
8163 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#I28");
8164 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#I29");
8165 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#I30");
8166 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#I31");
8167 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#I32");
8168 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#I33");
8169 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#I34");
8170 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#I35");
8171 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#I36");
8173 flags
= BindingFlags
.Instance
| BindingFlags
.Public
|
8174 BindingFlags
.DeclaredOnly
;
8175 methods
= greenType
.GetMethods (flags
);
8177 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#J1");
8178 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#J2");
8179 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#J3");
8180 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#J4");
8181 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#J5");
8182 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#J6");
8183 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#J7");
8184 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#J8");
8185 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#J9");
8186 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#J10");
8187 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#J11");
8188 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#J12");
8189 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#J13");
8190 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#J14");
8191 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#J15");
8192 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#J16");
8193 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#J17");
8194 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#J18");
8195 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#J19");
8196 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#J20");
8197 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#J21");
8198 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#J22");
8199 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#J23");
8200 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#J24");
8201 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#J25");
8202 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#J26");
8203 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#J27");
8204 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#J28");
8205 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#J29");
8206 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#J30");
8207 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#J31");
8208 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#J32");
8209 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#J33");
8210 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#J34");
8211 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#J35");
8212 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#J36");
8214 flags
= BindingFlags
.Static
| BindingFlags
.Public
|
8215 BindingFlags
.DeclaredOnly
;
8216 methods
= greenType
.GetMethods (flags
);
8218 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#K1");
8219 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#K2");
8220 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#K3");
8221 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#K4");
8222 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#K5");
8223 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#K6");
8224 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#K7");
8225 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#K8");
8226 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#K9");
8227 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#K10");
8228 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#K11");
8229 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#K12");
8230 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#K13");
8231 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#K14");
8232 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#K15");
8233 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#K16");
8234 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#K17");
8235 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#K18");
8236 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#K19");
8237 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#K20");
8238 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#K21");
8239 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#K22");
8240 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#K23");
8241 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#K24");
8242 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#K25");
8243 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#K26");
8244 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#K27");
8245 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#K28");
8246 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#K29");
8247 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#K30");
8248 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#K31");
8249 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#K32");
8250 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#K33");
8251 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#K34");
8252 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#K35");
8253 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#K36");
8255 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
8256 BindingFlags
.DeclaredOnly
;
8257 methods
= greenType
.GetMethods (flags
);
8259 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#L1");
8260 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#L2");
8261 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#L3");
8262 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#L4");
8263 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#L5");
8264 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#L6");
8265 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#L7");
8266 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#L8");
8267 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#L9");
8268 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#L10");
8269 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#L11");
8270 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#L12");
8271 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#L13");
8272 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#L14");
8273 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#L15");
8274 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#L16");
8275 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#L17");
8276 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#L18");
8277 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#L19");
8278 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#L20");
8279 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#L21");
8280 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#L22");
8281 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#L23");
8282 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#L24");
8283 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#L25");
8284 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#L26");
8285 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#L27");
8286 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#L28");
8287 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#L29");
8288 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#L30");
8289 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#L31");
8290 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#L32");
8291 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#L33");
8292 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#L34");
8293 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#L35");
8294 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#L36");
8296 flags
= BindingFlags
.Instance
| BindingFlags
.NonPublic
|
8297 BindingFlags
.Public
;
8298 methods
= greenType
.GetMethods (flags
);
8300 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#M1");
8301 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#M2");
8302 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#M3");
8303 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#M4");
8304 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#M5");
8305 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#M6");
8306 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#M7");
8307 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#M8");
8308 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#M9");
8309 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#M10");
8310 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#M11");
8311 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#M12");
8312 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#M13");
8313 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#M14");
8314 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#M15");
8315 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#M16");
8316 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#M17");
8317 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#M18");
8318 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#M19");
8319 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#M20");
8320 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#M21");
8321 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#M22");
8322 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#M23");
8323 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#M24");
8324 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#M25");
8325 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#M26");
8326 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#M27");
8327 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#M28");
8328 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#M29");
8329 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#M30");
8330 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#M31");
8331 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#M32");
8332 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#M33");
8333 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#M34");
8334 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#M35");
8335 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#M36");
8337 flags
= BindingFlags
.Static
| BindingFlags
.NonPublic
|
8338 BindingFlags
.Public
;
8339 methods
= greenType
.GetMethods (flags
);
8341 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceBlue"), "#N1");
8342 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceBlue"), "#N2");
8343 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceBlue"), "#N3");
8344 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceBlue"), "#N4");
8345 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceBlue"), "#N5");
8346 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceBlue"), "#N6");
8347 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceRed"), "#N7");
8348 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceRed"), "#N8");
8349 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceRed"), "#N9");
8350 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceRed"), "#N10");
8351 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceRed"), "#N11");
8352 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceRed"), "#N12");
8353 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateInstanceGreen"), "#N13");
8354 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyInstanceGreen"), "#N14");
8355 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemInstanceGreen"), "#N15");
8356 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemInstanceGreen"), "#N16");
8357 Assert
.IsNull (GetMethodByName (methods
, "GetPublicInstanceGreen"), "#N17");
8358 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyInstanceGreen"), "#N18");
8359 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticBlue"), "#N19");
8360 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticBlue"), "#N20");
8361 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticBlue"), "#N21");
8362 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticBlue"), "#N22");
8363 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticBlue"), "#N23");
8364 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticBlue"), "#N24");
8365 Assert
.IsNull (GetMethodByName (methods
, "GetPrivateStaticRed"), "#N25");
8366 Assert
.IsNull (GetMethodByName (methods
, "GetFamilyStaticRed"), "#N26");
8367 Assert
.IsNull (GetMethodByName (methods
, "GetFamANDAssemStaticRed"), "#N27");
8368 Assert
.IsNull (GetMethodByName (methods
, "GetFamORAssemStaticRed"), "#N28");
8369 Assert
.IsNull (GetMethodByName (methods
, "GetPublicStaticRed"), "#N29");
8370 Assert
.IsNull (GetMethodByName (methods
, "GetAssemblyStaticRed"), "#N30");
8371 Assert
.IsNotNull (GetMethodByName (methods
, "GetPrivateStaticGreen"), "#N31");
8372 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamilyStaticGreen"), "#N32");
8373 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamANDAssemStaticGreen"), "#N33");
8374 Assert
.IsNotNull (GetMethodByName (methods
, "GetFamORAssemStaticGreen"), "#N34");
8375 Assert
.IsNotNull (GetMethodByName (methods
, "GetPublicStaticGreen"), "#N35");
8376 Assert
.IsNotNull (GetMethodByName (methods
, "GetAssemblyStaticGreen"), "#N36");
8380 public void TestGetMemberIncomplete ()
8382 TypeBuilder tb
= module
.DefineType (genTypeName ());
8384 tb
.GetMember ("FOO", MemberTypes
.All
, BindingFlags
.Public
);
8386 } catch (NotSupportedException ex
) {
8387 // The invoked member is not supported in a
8389 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
8390 Assert
.IsNull (ex
.InnerException
, "#3");
8391 Assert
.IsNotNull (ex
.Message
, "#4");
8396 public void TestGetMemberComplete ()
8398 TypeBuilder tb
= module
.DefineType (genTypeName ());
8399 tb
.DefineField ("FOO", typeof (int), FieldAttributes
.Private
);
8401 Type emittedType
= tb
.CreateType ();
8403 Assert
.AreEqual (1, tb
.GetMember ("FOO", MemberTypes
.Field
, BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
8404 Assert
.AreEqual (0, tb
.GetMember ("FOO", MemberTypes
.Field
, BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
8408 public void TestGetMembersIncomplete ()
8410 TypeBuilder tb
= module
.DefineType (genTypeName ());
8414 } catch (NotSupportedException ex
) {
8415 // The invoked member is not supported in a
8417 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
8418 Assert
.IsNull (ex
.InnerException
, "#3");
8419 Assert
.IsNotNull (ex
.Message
, "#4");
8424 public void TestGetMembersComplete ()
8426 TypeBuilder tb
= module
.DefineType (genTypeName ());
8427 Type emittedType
= tb
.CreateType ();
8429 Assert
.AreEqual (tb
.GetMembers ().Length
, emittedType
.GetMembers ().Length
);
8433 public void TestGetMembersFlagsIncomplete ()
8435 TypeBuilder tb
= module
.DefineType (genTypeName ());
8437 tb
.GetMembers (BindingFlags
.Public
);
8439 } catch (NotSupportedException ex
) {
8440 // The invoked member is not supported in a
8442 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
8443 Assert
.IsNull (ex
.InnerException
, "#3");
8444 Assert
.IsNotNull (ex
.Message
, "#4");
8449 public void TestGetMembersFlagsComplete ()
8451 TypeBuilder tb
= module
.DefineType (genTypeName ());
8452 tb
.DefineField ("FOO", typeof (int), FieldAttributes
.Public
);
8454 Type emittedType
= tb
.CreateType ();
8456 Assert
.IsTrue (tb
.GetMembers (BindingFlags
.Instance
| BindingFlags
.Public
).Length
!= 0);
8457 Assert
.AreEqual (tb
.GetMembers (BindingFlags
.Instance
| BindingFlags
.Public
).Length
,
8458 emittedType
.GetMembers (BindingFlags
.Instance
| BindingFlags
.Public
).Length
);
8459 Assert
.AreEqual (tb
.GetMembers (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
,
8460 emittedType
.GetMembers (BindingFlags
.Instance
| BindingFlags
.NonPublic
).Length
);
8464 public void TestGetInterfaceIncomplete ()
8466 TypeBuilder tb
= module
.DefineType (genTypeName ());
8468 tb
.GetInterface ("FOO", true);
8470 } catch (NotSupportedException ex
) {
8471 // The invoked member is not supported in a
8473 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
8474 Assert
.IsNull (ex
.InnerException
, "#3");
8475 Assert
.IsNotNull (ex
.Message
, "#4");
8480 public void TestGetInterfaces ()
8482 TypeBuilder tb
= module
.DefineType (genTypeName ());
8483 Type
[] interfaces
= tb
.GetInterfaces ();
8484 Assert
.AreEqual (0, interfaces
.Length
);
8486 TypeBuilder tbInterface
= module
.DefineType (genTypeName (), TypeAttributes
.Public
| TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
8487 Type emittedInterface
= tbInterface
.CreateType ();
8489 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object), new Type
[] { emittedInterface }
);
8490 interfaces
= tb
.GetInterfaces ();
8491 Assert
.AreEqual (1, interfaces
.Length
);
8495 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8496 public void TestAddDeclarativeSecurityAlreadyCreated ()
8498 TypeBuilder tb
= module
.DefineType (genTypeName ());
8501 PermissionSet
set = new PermissionSet (PermissionState
.Unrestricted
);
8503 tb
.AddDeclarativeSecurity (SecurityAction
.Demand
, set);
8505 } catch (InvalidOperationException ex
) {
8506 // Unable to change after type has been created
8507 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
8508 Assert
.IsNull (ex
.InnerException
, "#3");
8509 Assert
.IsNotNull (ex
.Message
, "#4");
8514 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8515 public void TestAddDeclarativeSecurityNullPermissionSet ()
8517 TypeBuilder tb
= module
.DefineType (genTypeName ());
8519 tb
.AddDeclarativeSecurity (SecurityAction
.Demand
, null);
8521 } catch (ArgumentNullException ex
) {
8522 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
8523 Assert
.IsNull (ex
.InnerException
, "#3");
8524 Assert
.IsNotNull (ex
.Message
, "#4");
8525 Assert
.AreEqual ("pset", ex
.ParamName
, "#5");
8531 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8532 public void TestAddDeclarativeSecurityInvalidAction ()
8534 TypeBuilder tb
= module
.DefineType (genTypeName ());
8536 SecurityAction
[] actions
= new SecurityAction
[] {
8537 SecurityAction
.RequestMinimum
,
8538 SecurityAction
.RequestOptional
,
8539 SecurityAction
.RequestRefuse
};
8540 PermissionSet
set = new PermissionSet (PermissionState
.Unrestricted
);
8542 foreach (SecurityAction action
in actions
) {
8544 tb
.AddDeclarativeSecurity (action
, set);
8546 } catch (ArgumentOutOfRangeException
) {
8552 [Category ("MobileNotWorking")] // Not available in the 2.1 profile
8553 public void TestAddDeclarativeSecurityDuplicateAction ()
8555 TypeBuilder tb
= module
.DefineType (genTypeName ());
8557 PermissionSet
set = new PermissionSet (PermissionState
.Unrestricted
);
8558 tb
.AddDeclarativeSecurity (SecurityAction
.Demand
, set);
8560 tb
.AddDeclarativeSecurity (SecurityAction
.Demand
, set);
8562 } catch (InvalidOperationException ex
) {
8563 // Multiple permission sets specified with the
8564 // same SecurityAction
8565 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
8566 Assert
.IsNull (ex
.InnerException
, "#3");
8567 Assert
.IsNotNull (ex
.Message
, "#4");
8572 public void TestEnums ()
8574 TypeAttributes typeAttrs
= TypeAttributes
.Class
| TypeAttributes
.Public
| TypeAttributes
.Sealed
;
8575 TypeBuilder enumToCreate
= module
.DefineType (genTypeName (), typeAttrs
,
8577 enumToCreate
.SetCustomAttribute (new CustomAttributeBuilder (typeof (FlagsAttribute
).GetConstructors () [0], Type
.EmptyTypes
));
8578 // add value__ field, see DefineEnum method of ModuleBuilder
8579 enumToCreate
.DefineField ("value__", typeof (Int32
),
8580 FieldAttributes
.Public
| FieldAttributes
.SpecialName
| FieldAttributes
.RTSpecialName
);
8583 FieldBuilder fb
= enumToCreate
.DefineField ("A", enumToCreate
,
8584 FieldAttributes
.Public
| FieldAttributes
.Static
| FieldAttributes
.Literal
);
8585 fb
.SetConstant ((Int32
) 0);
8587 fb
= enumToCreate
.DefineField ("B", enumToCreate
,
8588 FieldAttributes
.Public
| FieldAttributes
.Static
| FieldAttributes
.Literal
);
8589 fb
.SetConstant ((Int32
) 1);
8591 fb
= enumToCreate
.DefineField ("C", enumToCreate
,
8592 FieldAttributes
.Public
| FieldAttributes
.Static
| FieldAttributes
.Literal
);
8593 fb
.SetConstant ((Int32
) 2);
8595 Type enumType
= enumToCreate
.CreateType ();
8597 object enumVal
= Enum
.ToObject (enumType
, (Int32
) 3);
8599 Assert
.AreEqual ("B, C", enumVal
.ToString ());
8600 Assert
.AreEqual (3, (Int32
) enumVal
);
8604 public void DefineEnum ()
8606 TypeBuilder typeBuilder
= module
.DefineType (genTypeName (),
8607 TypeAttributes
.Public
);
8608 EnumBuilder enumBuilder
= module
.DefineEnum (genTypeName (),
8609 TypeAttributes
.Public
, typeof (int));
8610 typeBuilder
.DefineField ("myField", enumBuilder
, FieldAttributes
.Private
);
8611 enumBuilder
.CreateType ();
8612 typeBuilder
.CreateType ();
8616 [Category ("NotWorking")]
8617 public void DefineEnumThrowIfTypeBuilderCalledBeforeEnumBuilder ()
8619 TypeBuilder typeBuilder
= module
.DefineType (genTypeName (),
8620 TypeAttributes
.Public
);
8621 EnumBuilder enumBuilder
= module
.DefineEnum (genTypeName (),
8622 TypeAttributes
.Public
, typeof (int));
8623 typeBuilder
.DefineField ("myField", enumBuilder
, FieldAttributes
.Private
);
8625 typeBuilder
.CreateType ();
8627 } catch (TypeLoadException
) {
8628 // Could not load type '...' from assembly
8629 // 'MonoTests.System.Reflection.Emit.TypeBuilderTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
8631 Assert
.IsTrue (typeBuilder
.IsCreated (), "#2");
8632 Assert
.IsNull (typeBuilder
.CreateType (), "#3");
8636 public void SetCustomAttribute_SuppressUnmanagedCodeSecurity ()
8638 TypeBuilder tb
= module
.DefineType (genTypeName ());
8639 ConstructorInfo attrCtor
= typeof (SuppressUnmanagedCodeSecurityAttribute
).
8640 GetConstructor (Type
.EmptyTypes
);
8641 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (
8642 attrCtor
, new object [0]);
8643 Assert
.IsTrue ((tb
.Attributes
& TypeAttributes
.HasSecurity
) == 0, "#1");
8644 tb
.SetCustomAttribute (caBuilder
);
8645 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#2");
8646 Type emittedType
= tb
.CreateType ();
8647 Assert
.AreEqual (TypeAttributes
.HasSecurity
, emittedType
.Attributes
& TypeAttributes
.HasSecurity
, "#3");
8648 //Assert.IsTrue ((tb.Attributes & TypeAttributes.HasSecurity) == 0, "#4");
8649 object [] emittedAttrs
= emittedType
.GetCustomAttributes (typeof (SuppressUnmanagedCodeSecurityAttribute
), true);
8650 Assert
.AreEqual (1, emittedAttrs
.Length
, "#5");
8653 private PropertyBuilder
DefineStringProperty (TypeBuilder tb
, string propertyName
, string fieldName
, MethodAttributes methodAttribs
)
8655 // define the field holding the property value
8656 FieldBuilder fieldBuilder
= tb
.DefineField (fieldName
,
8657 typeof (string), FieldAttributes
.Private
);
8659 PropertyBuilder propertyBuilder
= tb
.DefineProperty (
8660 propertyName
, PropertyAttributes
.HasDefault
, typeof (string),
8661 new Type
[] { typeof (string) }
);
8663 // First, we'll define the behavior of the "get" property for CustomerName as a method.
8664 MethodBuilder getMethodBuilder
= tb
.DefineMethod ("Get" + propertyName
,
8669 ILGenerator getIL
= getMethodBuilder
.GetILGenerator ();
8671 getIL
.Emit (OpCodes
.Ldarg_0
);
8672 getIL
.Emit (OpCodes
.Ldfld
, fieldBuilder
);
8673 getIL
.Emit (OpCodes
.Ret
);
8675 // Now, we'll define the behavior of the "set" property for CustomerName.
8676 MethodBuilder setMethodBuilder
= tb
.DefineMethod ("Set" + propertyName
,
8679 new Type
[] { typeof (string) }
);
8681 ILGenerator setIL
= setMethodBuilder
.GetILGenerator ();
8683 setIL
.Emit (OpCodes
.Ldarg_0
);
8684 setIL
.Emit (OpCodes
.Ldarg_1
);
8685 setIL
.Emit (OpCodes
.Stfld
, fieldBuilder
);
8686 setIL
.Emit (OpCodes
.Ret
);
8688 // Last, we must map the two methods created above to our PropertyBuilder to
8689 // their corresponding behaviors, "get" and "set" respectively.
8690 propertyBuilder
.SetGetMethod (getMethodBuilder
);
8691 propertyBuilder
.SetSetMethod (setMethodBuilder
);
8692 return propertyBuilder
;
8695 static int handler_called
= 0;
8698 public void TestTypeResolve ()
8700 string typeName
= genTypeName ();
8702 ResolveEventHandler handler
= new ResolveEventHandler (TypeResolve
);
8703 AppDomain
.CurrentDomain
.TypeResolve
+= handler
;
8705 Type t
= Type
.GetType (typeName
);
8706 Assert
.AreEqual (typeName
, t
.Name
);
8707 Assert
.AreEqual (1, handler_called
);
8708 AppDomain
.CurrentDomain
.TypeResolve
-= handler
;
8711 Assembly
TypeResolve (object sender
, ResolveEventArgs args
)
8713 TypeBuilder tb
= module
.DefineType (args
.Name
, TypeAttributes
.Public
);
8720 public void IsAssignableFrom_Created ()
8722 TypeBuilder tb
= module
.DefineType (genTypeName (),
8723 TypeAttributes
.Public
, typeof (MemoryStream
),
8724 new Type
[] { typeof (IThrowable), typeof (Bar) }
);
8725 tb
.AddInterfaceImplementation (typeof (IDestroyable
));
8726 Type emitted_type
= tb
.CreateType ();
8728 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb
), "#A1");
8729 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IThrowable
)), "#A2");
8730 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (tb
), "#A3");
8731 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IMoveable
)), "#A4");
8732 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (tb
), "#A5");
8733 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Foo
)), "#A6");
8734 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (tb
), "#A7");
8735 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Bar
)), "#A8");
8736 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (tb
), "#A9");
8737 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Baz
)), "#A10");
8738 Assert
.IsTrue (typeof (IDestroyable
).IsAssignableFrom (tb
), "#A11");
8739 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IDestroyable
)), "#A12");
8740 Assert
.IsFalse (typeof (IAir
).IsAssignableFrom (tb
), "#A13");
8741 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IAir
)), "#A14");
8742 Assert
.IsFalse (typeof (IWater
).IsAssignableFrom (tb
), "#A15");
8743 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IWater
)), "#A16");
8744 Assert
.IsFalse (typeof (ILiquid
).IsAssignableFrom (tb
), "#A17");
8745 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (ILiquid
)), "#A18");
8747 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (tb
), "#B1");
8748 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (MemoryStream
)), "#B2");
8749 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (tb
), "#B3");
8750 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Stream
)), "#B4");
8751 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (tb
), "#B5");
8752 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (FileStream
)), "#B6");
8753 Assert
.IsTrue (typeof (object).IsAssignableFrom (tb
), "#B7");
8754 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (object)), "#B8");
8755 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (tb
), "#B9");
8756 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IDisposable
)), "#B10");
8758 Assert
.IsTrue (tb
.IsAssignableFrom (tb
), "#C1");
8759 Assert
.IsFalse (tb
.IsAssignableFrom ((Type
) null), "#C2");
8760 Assert
.IsTrue (tb
.IsAssignableFrom (emitted_type
), "#C3");
8761 Assert
.IsTrue (emitted_type
.IsAssignableFrom (tb
), "#C4");
8762 Assert
.IsFalse (emitted_type
.IsAssignableFrom ((Type
) null), "#C5");
8764 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (emitted_type
), "#D1");
8765 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (IThrowable
)), "#D2");
8766 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (emitted_type
), "#D3");
8767 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (IMoveable
)), "#D4");
8768 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (emitted_type
), "#D5");
8769 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (Foo
)), "#D6");
8770 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (emitted_type
), "#D7");
8771 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (Bar
)), "#D8");
8772 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (emitted_type
), "#D9");
8773 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (Baz
)), "#D10");
8774 Assert
.IsTrue (typeof (IDestroyable
).IsAssignableFrom (emitted_type
), "#D11");
8775 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (IDestroyable
)), "#D12");
8776 Assert
.IsFalse (typeof (IAir
).IsAssignableFrom (emitted_type
), "#D13");
8777 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (IAir
)), "#D14");
8778 Assert
.IsFalse (typeof (IWater
).IsAssignableFrom (emitted_type
), "#D15");
8779 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (IWater
)), "#D16");
8780 Assert
.IsFalse (typeof (ILiquid
).IsAssignableFrom (emitted_type
), "#D17");
8781 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (ILiquid
)), "#D18");
8783 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (emitted_type
), "#E1");
8784 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (MemoryStream
)), "#E2");
8785 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (emitted_type
), "#E3");
8786 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (Stream
)), "#E4");
8787 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (emitted_type
), "#E5");
8788 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (FileStream
)), "#E6");
8789 Assert
.IsTrue (typeof (object).IsAssignableFrom (emitted_type
), "#E7");
8790 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (object)), "#E8");
8791 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (emitted_type
), "#E9");
8792 Assert
.IsFalse (emitted_type
.IsAssignableFrom (typeof (IDisposable
)), "#E10");
8794 Assert
.IsTrue (typeof (Foo
[]).IsAssignableFrom (module
.GetType (
8795 tb
.FullName
+ "[]")), "#F1");
8796 Assert
.IsTrue (typeof (Bar
[]).IsAssignableFrom (module
.GetType (
8797 tb
.FullName
+ "[]")), "#F2");
8798 Assert
.IsFalse (typeof (Baz
[]).IsAssignableFrom (module
.GetType (
8799 tb
.FullName
+ "[]")), "#F3");
8801 TypeBuilder tb2
= module
.DefineType (genTypeName (),
8802 TypeAttributes
.Public
, tb
,
8803 new Type
[] { typeof (IAir) }
);
8804 Type emitted_type2
= tb2
.CreateType ();
8806 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb2
), "#G1");
8807 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IThrowable
)), "#G2");
8808 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (tb2
), "#G3");
8809 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IMoveable
)), "#G4");
8810 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (tb2
), "#G5");
8811 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Foo
)), "#G6");
8812 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (tb2
), "#G7");
8813 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Bar
)), "#G8");
8814 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (tb2
), "#G9");
8815 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Baz
)), "#G10");
8816 Assert
.IsTrue (typeof (IDestroyable
).IsAssignableFrom (tb2
), "#G11");
8817 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IDestroyable
)), "#G12");
8818 Assert
.IsTrue (typeof (IAir
).IsAssignableFrom (tb2
), "#G13");
8819 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IAir
)), "#G14");
8820 Assert
.IsFalse (typeof (IWater
).IsAssignableFrom (tb2
), "#G15");
8821 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IWater
)), "#G16");
8822 Assert
.IsFalse (typeof (ILiquid
).IsAssignableFrom (tb2
), "#G17");
8823 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (ILiquid
)), "#G18");
8825 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (tb2
), "#H1");
8826 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (MemoryStream
)), "#H2");
8827 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (tb2
), "#H3");
8828 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Stream
)), "#H4");
8829 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (tb2
), "#H5");
8830 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (FileStream
)), "#H6");
8831 Assert
.IsTrue (typeof (object).IsAssignableFrom (tb2
), "#H7");
8832 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (object)), "#H8");
8833 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (tb2
), "#H9");
8834 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IDisposable
)), "#H10");
8836 Assert
.IsTrue (tb2
.IsAssignableFrom (tb2
), "#I1");
8837 Assert
.IsFalse (tb2
.IsAssignableFrom (tb
), "#I2");
8838 Assert
.IsTrue (tb2
.IsAssignableFrom (emitted_type2
), "#I3");
8839 Assert
.IsFalse (tb2
.IsAssignableFrom (emitted_type
), "#I4");
8840 Assert
.IsFalse (tb2
.IsAssignableFrom ((Type
) null), "#I5");
8841 Assert
.IsTrue (emitted_type2
.IsAssignableFrom (emitted_type2
), "#I6");
8842 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (emitted_type
), "#I7");
8843 Assert
.IsTrue (emitted_type2
.IsAssignableFrom (tb2
), "#I8");
8844 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (tb
), "#I9");
8845 Assert
.IsFalse (emitted_type2
.IsAssignableFrom ((Type
) null), "#I10");
8846 Assert
.IsTrue (tb
.IsAssignableFrom (tb2
), "#I11");
8847 Assert
.IsTrue (tb
.IsAssignableFrom (emitted_type2
), "#I12");
8848 Assert
.IsTrue (emitted_type
.IsAssignableFrom (tb2
), "#I13");
8849 Assert
.IsTrue (emitted_type
.IsAssignableFrom (emitted_type2
), "#I14");
8851 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (emitted_type2
), "#J1");
8852 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (IThrowable
)), "#J2");
8853 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (emitted_type2
), "#J3");
8854 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (IMoveable
)), "#J4");
8855 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (emitted_type2
), "#J5");
8856 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (Foo
)), "#J6");
8857 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (emitted_type2
), "#J7");
8858 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (Bar
)), "#J8");
8859 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (emitted_type2
), "#J9");
8860 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (Baz
)), "#J10");
8861 Assert
.IsTrue (typeof (IDestroyable
).IsAssignableFrom (tb2
), "#J11");
8862 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (IDestroyable
)), "#J12");
8863 Assert
.IsTrue (typeof (IAir
).IsAssignableFrom (emitted_type2
), "#J13");
8864 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (IAir
)), "#J14");
8865 Assert
.IsFalse (typeof (IWater
).IsAssignableFrom (emitted_type2
), "#J15");
8866 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (IWater
)), "#J16");
8867 Assert
.IsFalse (typeof (ILiquid
).IsAssignableFrom (emitted_type2
), "#J17");
8868 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (ILiquid
)), "#J18");
8870 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (emitted_type2
), "#K1");
8871 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (MemoryStream
)), "#K2");
8872 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (emitted_type2
), "#K3");
8873 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (Stream
)), "#K4");
8874 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (emitted_type2
), "#K5");
8875 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (FileStream
)), "#K6");
8876 Assert
.IsTrue (typeof (object).IsAssignableFrom (emitted_type2
), "#K7");
8877 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (object)), "#K8");
8878 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (emitted_type2
), "#K9");
8879 Assert
.IsFalse (emitted_type2
.IsAssignableFrom (typeof (IDisposable
)), "#K10");
8881 Assert
.IsTrue (typeof (Foo
[]).IsAssignableFrom (module
.GetType (
8882 tb2
.FullName
+ "[]")), "#L1");
8883 Assert
.IsTrue (typeof (Bar
[]).IsAssignableFrom (module
.GetType (
8884 tb2
.FullName
+ "[]")), "#L2");
8885 Assert
.IsFalse (typeof (Baz
[]).IsAssignableFrom (module
.GetType (
8886 tb2
.FullName
+ "[]")), "#L3");
8888 TypeBuilder tb3
= module
.DefineType (genTypeName (),
8889 TypeAttributes
.Public
, tb2
,
8890 new Type
[] { typeof (IWater) }
);
8891 Type emitted_type3
= tb3
.CreateType ();
8893 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb3
), "#M1");
8894 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IThrowable
)), "#M2");
8895 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (tb3
), "#M3");
8896 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IMoveable
)), "#M4");
8897 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (tb3
), "#M5");
8898 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Foo
)), "#M6");
8899 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (tb3
), "#M7");
8900 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Bar
)), "#M8");
8901 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (tb3
), "#M9");
8902 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Baz
)), "#M10");
8903 Assert
.IsTrue (typeof (IDestroyable
).IsAssignableFrom (tb3
), "#M11");
8904 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IDestroyable
)), "#M12");
8905 Assert
.IsTrue (typeof (IAir
).IsAssignableFrom (tb3
), "#M13");
8906 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IAir
)), "#M14");
8907 Assert
.IsTrue (typeof (IWater
).IsAssignableFrom (tb3
), "#M15");
8908 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IWater
)), "#M16");
8909 Assert
.IsTrue (typeof (ILiquid
).IsAssignableFrom (tb3
), "#M17");
8910 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (ILiquid
)), "#M18");
8912 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (tb3
), "#N1");
8913 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (MemoryStream
)), "#N2");
8914 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (tb3
), "#N3");
8915 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Stream
)), "#N4");
8916 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (tb3
), "#N5");
8917 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (FileStream
)), "#N6");
8918 Assert
.IsTrue (typeof (object).IsAssignableFrom (tb3
), "#N7");
8919 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (object)), "#N8");
8920 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (tb3
), "#N9");
8921 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IDisposable
)), "#N10");
8923 Assert
.IsTrue (tb3
.IsAssignableFrom (tb3
), "#O1");
8924 Assert
.IsFalse (tb3
.IsAssignableFrom (tb2
), "#O2");
8925 Assert
.IsFalse (tb3
.IsAssignableFrom (tb
), "#O3");
8926 Assert
.IsTrue (tb3
.IsAssignableFrom (emitted_type3
), "#O4");
8927 Assert
.IsFalse (tb3
.IsAssignableFrom (emitted_type2
), "#O5");
8928 Assert
.IsFalse (tb3
.IsAssignableFrom (emitted_type
), "#O6");
8929 Assert
.IsFalse (tb3
.IsAssignableFrom ((Type
) null), "#O7");
8930 Assert
.IsTrue (emitted_type3
.IsAssignableFrom (emitted_type3
), "#O8");
8931 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (emitted_type2
), "#O9");
8932 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (emitted_type
), "#O10");
8933 Assert
.IsTrue (emitted_type3
.IsAssignableFrom (tb3
), "#O11");
8934 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (tb2
), "#O12");
8935 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (tb
), "#O13");
8936 Assert
.IsFalse (emitted_type3
.IsAssignableFrom ((Type
) null), "#O14");
8937 Assert
.IsTrue (tb2
.IsAssignableFrom (tb3
), "#O15");
8938 Assert
.IsTrue (tb2
.IsAssignableFrom (emitted_type3
), "#O16");
8939 Assert
.IsTrue (emitted_type2
.IsAssignableFrom (emitted_type3
), "#O17");
8940 Assert
.IsTrue (emitted_type2
.IsAssignableFrom (tb3
), "#O18");
8941 Assert
.IsTrue (tb
.IsAssignableFrom (tb3
), "#O19");
8942 Assert
.IsTrue (tb
.IsAssignableFrom (emitted_type3
), "#O20");
8943 Assert
.IsTrue (emitted_type
.IsAssignableFrom (tb3
), "#021");
8944 Assert
.IsTrue (emitted_type
.IsAssignableFrom (emitted_type3
), "#O22");
8946 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (emitted_type3
), "#P1");
8947 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (IThrowable
)), "#P2");
8948 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (emitted_type3
), "#P3");
8949 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (IMoveable
)), "#P4");
8950 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (emitted_type3
), "#P5");
8951 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (Foo
)), "#P6");
8952 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (emitted_type3
), "#P7");
8953 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (Bar
)), "#P8");
8954 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (emitted_type3
), "#P9");
8955 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (Baz
)), "#P10");
8956 Assert
.IsTrue (typeof (IDestroyable
).IsAssignableFrom (emitted_type3
), "#P11");
8957 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (IDestroyable
)), "#P12");
8958 Assert
.IsTrue (typeof (IAir
).IsAssignableFrom (emitted_type3
), "#P13");
8959 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (IAir
)), "#P14");
8960 Assert
.IsTrue (typeof (IWater
).IsAssignableFrom (emitted_type3
), "#P15");
8961 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (IWater
)), "#P16");
8962 Assert
.IsTrue (typeof (ILiquid
).IsAssignableFrom (emitted_type3
), "#P17");
8963 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (ILiquid
)), "#P18");
8965 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (emitted_type3
), "#Q1");
8966 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (MemoryStream
)), "#Q2");
8967 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (emitted_type3
), "#Q3");
8968 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (Stream
)), "#Q4");
8969 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (emitted_type3
), "#Q5");
8970 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (FileStream
)), "#Q6");
8971 Assert
.IsTrue (typeof (object).IsAssignableFrom (emitted_type3
), "#Q7");
8972 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (object)), "#Q8");
8973 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (emitted_type3
), "#Q9");
8974 Assert
.IsFalse (emitted_type3
.IsAssignableFrom (typeof (IDisposable
)), "#Q10");
8976 Assert
.IsTrue (typeof (Foo
[]).IsAssignableFrom (module
.GetType (
8977 tb3
.FullName
+ "[]")), "#R1");
8978 Assert
.IsTrue (typeof (Bar
[]).IsAssignableFrom (module
.GetType (
8979 tb3
.FullName
+ "[]")), "#R2");
8980 Assert
.IsFalse (typeof (Baz
[]).IsAssignableFrom (module
.GetType (
8981 tb3
.FullName
+ "[]")), "#R3");
8983 TypeBuilder tb4
= module
.DefineType (genTypeName (),
8984 TypeAttributes
.Public
, null,
8985 new Type
[] { typeof (IWater) }
);
8986 tb4
.DefineGenericParameters ("T");
8988 Type inst
= tb4
.MakeGenericType (typeof (int));
8989 Type emitted_type4
= tb4
.CreateType ();
8990 Assert
.IsFalse (typeof (IComparable
).IsAssignableFrom (inst
));
8991 // This returns True if CreateType () is called _before_ MakeGenericType...
8992 //Assert.IsFalse (typeof (IWater).IsAssignableFrom (inst));
8996 public void IsAssignableFrom_NotCreated ()
8998 TypeBuilder tb
= module
.DefineType (genTypeName (),
8999 TypeAttributes
.Public
, typeof (MemoryStream
),
9001 typeof (IThrowable
), typeof (Bar
),
9002 typeof (IComparable
)
9005 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb
), "#A1");
9006 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IThrowable
)), "#A2");
9007 //Assert.IsFalse (typeof (IMoveable).IsAssignableFrom (tb), "#A3");
9008 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IMoveable
)), "#A4");
9009 Assert
.IsTrue (typeof (IComparable
).IsAssignableFrom (tb
), "#A5");
9010 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IComparable
)), "#A6");
9011 Assert
.IsFalse (typeof (IAir
).IsAssignableFrom (tb
), "#A7");
9012 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IAir
)), "#A8");
9013 Assert
.IsFalse (typeof (IWater
).IsAssignableFrom (tb
), "#A9");
9014 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IWater
)), "#A10");
9015 Assert
.IsFalse (typeof (ILiquid
).IsAssignableFrom (tb
), "#A11");
9016 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (ILiquid
)), "#A12");
9018 //Assert.IsFalse (typeof (Foo).IsAssignableFrom (tb), "#B1");
9019 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Foo
)), "#B2");
9020 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (tb
), "#B3");
9021 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Bar
)), "#B4");
9022 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (tb
), "#B5");
9023 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Baz
)), "#B6");
9025 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (tb
), "#C1");
9026 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (MemoryStream
)), "#C2");
9027 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (tb
), "#C3");
9028 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (Stream
)), "#C4");
9029 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (tb
), "#C5");
9030 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (FileStream
)), "#C6");
9031 Assert
.IsTrue (typeof (object).IsAssignableFrom (tb
), "#C7");
9032 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (object)), "#C8");
9033 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (tb
), "#C9");
9034 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IDisposable
)), "#C10");
9036 Assert
.IsTrue (tb
.IsAssignableFrom (tb
), "#D1");
9037 Assert
.IsFalse (tb
.IsAssignableFrom ((Type
) null), "#D2");
9039 TypeBuilder tb2
= module
.DefineType (genTypeName (),
9040 TypeAttributes
.Public
, tb
,
9041 new Type
[] { typeof (IAir) }
);
9043 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb2
), "#E1");
9044 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IThrowable
)), "#E2");
9045 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (tb2
), "#E3");
9046 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IMoveable
)), "#E4");
9047 Assert
.IsTrue (typeof (IComparable
).IsAssignableFrom (tb2
), "#E5");
9048 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IComparable
)), "#E6");
9049 Assert
.IsTrue (typeof (IAir
).IsAssignableFrom (tb2
), "#E7");
9050 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IAir
)), "#E8");
9051 Assert
.IsFalse (typeof (IWater
).IsAssignableFrom (tb2
), "#E9");
9052 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IWater
)), "#E10");
9053 Assert
.IsFalse (typeof (ILiquid
).IsAssignableFrom (tb2
), "#E11");
9054 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (ILiquid
)), "#E12");
9056 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (tb2
), "#F1");
9057 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Foo
)), "#F2");
9058 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (tb2
), "#F3");
9059 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Bar
)), "#F4");
9060 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (tb2
), "#F5");
9061 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Baz
)), "#F6");
9063 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (tb2
), "#G1");
9064 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (MemoryStream
)), "#G2");
9065 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (tb2
), "#G3");
9066 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (Stream
)), "#G4");
9067 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (tb2
), "#G5");
9068 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (FileStream
)), "#G6");
9069 Assert
.IsTrue (typeof (object).IsAssignableFrom (tb2
), "#G7");
9070 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (object)), "#G8");
9071 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (tb2
), "#G9");
9072 Assert
.IsFalse (tb2
.IsAssignableFrom (typeof (IDisposable
)), "#G10");
9074 Assert
.IsTrue (tb2
.IsAssignableFrom (tb2
), "#H1");
9075 Assert
.IsFalse (tb2
.IsAssignableFrom (tb
), "#H2");
9076 Assert
.IsTrue (tb
.IsAssignableFrom (tb2
), "#H3");
9078 TypeBuilder tb3
= module
.DefineType (genTypeName (),
9079 TypeAttributes
.Public
, tb2
,
9080 new Type
[] { typeof (IWater) }
);
9082 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb3
), "#I1");
9083 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IThrowable
)), "#I2");
9084 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (tb3
), "#I3");
9085 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IMoveable
)), "#I4");
9086 Assert
.IsTrue (typeof (IComparable
).IsAssignableFrom (tb3
), "#I5");
9087 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IComparable
)), "#I6");
9088 Assert
.IsTrue (typeof (IAir
).IsAssignableFrom (tb3
), "#I7");
9089 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IAir
)), "#I8");
9090 Assert
.IsTrue (typeof (IWater
).IsAssignableFrom (tb3
), "#I9");
9091 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IWater
)), "#I10");
9092 //Assert.IsFalse (typeof (ILiquid).IsAssignableFrom (tb3), "#I11");
9093 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (ILiquid
)), "#I12");
9095 Assert
.IsTrue (typeof (Foo
).IsAssignableFrom (tb3
), "#J1");
9096 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Foo
)), "#J2");
9097 Assert
.IsTrue (typeof (Bar
).IsAssignableFrom (tb3
), "#J3");
9098 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Bar
)), "#J4");
9099 Assert
.IsFalse (typeof (Baz
).IsAssignableFrom (tb3
), "#J5");
9100 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Baz
)), "#J6");
9102 Assert
.IsTrue (typeof (MemoryStream
).IsAssignableFrom (tb3
), "#K1");
9103 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (MemoryStream
)), "#K2");
9104 Assert
.IsTrue (typeof (Stream
).IsAssignableFrom (tb3
), "#K3");
9105 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (Stream
)), "#K4");
9106 Assert
.IsFalse (typeof (FileStream
).IsAssignableFrom (tb3
), "#K5");
9107 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (FileStream
)), "#K6");
9108 Assert
.IsTrue (typeof (object).IsAssignableFrom (tb3
), "#K7");
9109 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (object)), "#K8");
9110 Assert
.IsTrue (typeof (IDisposable
).IsAssignableFrom (tb3
), "#K9");
9111 Assert
.IsFalse (tb3
.IsAssignableFrom (typeof (IDisposable
)), "#K10");
9113 Assert
.IsTrue (tb3
.IsAssignableFrom (tb3
), "#L1");
9114 Assert
.IsFalse (tb3
.IsAssignableFrom (tb2
), "#L2");
9115 Assert
.IsFalse (tb3
.IsAssignableFrom (tb
), "#L3");
9116 Assert
.IsTrue (tb2
.IsAssignableFrom (tb3
), "#L4");
9117 Assert
.IsTrue (tb
.IsAssignableFrom (tb3
), "#L5");
9121 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9122 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_Mono ()
9124 TypeBuilder tb
= module
.DefineType (genTypeName (),
9125 TypeAttributes
.Public
, typeof (FormatException
),
9126 new Type
[] { typeof (IThrowable) }
);
9127 tb
.AddInterfaceImplementation (typeof (IDestroyable
));
9129 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb
), "#A1");
9130 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IThrowable
)), "#A2");
9132 Assert
.IsTrue (typeof (IDestroyable
).IsAssignableFrom (tb
), "#B1");
9133 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IDestroyable
)), "#B2");
9137 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344549
9138 public void IsAssignableFrom_NotCreated_AddInterfaceImplementation_MS ()
9140 TypeBuilder tb
= module
.DefineType (genTypeName (),
9141 TypeAttributes
.Public
, typeof (FormatException
),
9142 new Type
[] { typeof (IThrowable) }
);
9143 tb
.AddInterfaceImplementation (typeof (IDestroyable
));
9145 Assert
.IsTrue (typeof (IThrowable
).IsAssignableFrom (tb
), "#A1");
9146 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IThrowable
)), "#A2");
9148 Assert
.IsFalse (typeof (IDestroyable
).IsAssignableFrom (tb
), "#B1");
9149 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IDestroyable
)), "#B2");
9154 // Casts don't work with unfinished types
9155 [Category ("NotWorking")]
9156 [Category ("NotDotNet")]
9157 public void IsAssignableFrom_NotCreated_Array ()
9159 TypeBuilder tb
= module
.DefineType (genTypeName (),
9160 TypeAttributes
.Public
, typeof (FormatException
),
9162 typeof (IThrowable
), typeof (Bar
),
9163 typeof (IComparable
)
9166 Assert
.IsTrue (typeof (Foo
[]).IsAssignableFrom (module
.GetType (
9167 tb
.FullName
+ "[]")), "#1");
9168 Assert
.IsTrue (typeof (Bar
[]).IsAssignableFrom (module
.GetType (
9169 tb
.FullName
+ "[]")), "#2");
9170 Assert
.IsFalse (typeof (Baz
[]).IsAssignableFrom (module
.GetType (
9171 tb
.FullName
+ "[]")), "#3");
9175 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9176 public void IsAssignableFrom_NotCreated_BaseInterface_Mono ()
9178 TypeBuilder tb
= module
.DefineType (genTypeName (),
9179 TypeAttributes
.Public
, typeof (FormatException
),
9181 typeof (IThrowable
), typeof (Bar
),
9182 typeof (IComparable
)
9185 Assert
.IsTrue (typeof (IMoveable
).IsAssignableFrom (tb
), "#1");
9186 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IMoveable
)), "#2");
9190 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344353
9191 public void IsAssignableFrom_NotCreated_BaseInterface_MS ()
9193 TypeBuilder tb
= module
.DefineType (genTypeName (),
9194 TypeAttributes
.Public
, typeof (FormatException
),
9196 typeof (IThrowable
), typeof (Bar
),
9197 typeof (IComparable
)
9200 Assert
.IsFalse (typeof (IMoveable
).IsAssignableFrom (tb
), "#1");
9201 Assert
.IsFalse (tb
.IsAssignableFrom (typeof (IMoveable
)), "#2");
9205 public void CreateType_EmptyMethodBody ()
9207 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9209 tb
.DefineMethod ("foo", MethodAttributes
.Public
, typeof (void), new Type
[] { }
);
9213 } catch (InvalidOperationException ex
) {
9214 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
9215 Assert
.IsNull (ex
.InnerException
, "#3");
9216 Assert
.IsNotNull (ex
.Message
, "#4");
9221 public void CreateType_EmptyCtorBody ()
9223 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9225 tb
.DefineConstructor (0, CallingConventions
.Standard
, null);
9229 } catch (InvalidOperationException ex
) {
9230 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
9231 Assert
.IsNull (ex
.InnerException
, "#3");
9232 Assert
.IsNotNull (ex
.Message
, "#4");
9237 [Category ("NotWorking")]
9238 public void CreateType_Interface_ParentInvalid ()
9242 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
,
9243 typeof (Exception
));
9244 Assert
.AreEqual (typeof (Exception
), tb
.BaseType
, "#A1");
9247 Assert
.Fail ("#A2");
9248 } catch (TypeLoadException ex
) {
9249 // Could not load interface 't5' from assembly '...'
9250 // because it must extend from Object
9251 Assert
.AreEqual (typeof (TypeLoadException
), ex
.GetType (), "#A3");
9252 Assert
.IsNull (ex
.InnerException
, "#A4");
9253 Assert
.IsNotNull (ex
.Message
, "#A5");
9254 Assert
.IsTrue (ex
.Message
.IndexOf (tb
.Name
) != -1, "#A6");
9255 Assert
.IsTrue (ex
.Message
.IndexOf (assembly
.FullName
) != -1, "#A7");
9258 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
,
9260 Assert
.AreEqual (typeof (object), tb
.BaseType
, "#B1");
9263 Assert
.Fail ("#B2");
9264 } catch (TypeLoadException ex
) {
9265 // Failure has occurred while loading a type
9266 Assert
.AreEqual (typeof (TypeLoadException
), ex
.GetType (), "#B3");
9267 Assert
.IsNull (ex
.InnerException
, "#B4");
9268 Assert
.IsNotNull (ex
.Message
, "#B5");
9271 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
,
9272 typeof (EmptyInterface
));
9273 Assert
.AreEqual (typeof (EmptyInterface
), tb
.BaseType
, "#C1");
9276 Assert
.Fail ("#C2");
9277 } catch (TypeLoadException ex
) {
9278 // Could not load interface 't5' from assembly '...'
9279 // because the parent type is an interface
9280 Assert
.AreEqual (typeof (TypeLoadException
), ex
.GetType (), "#C3");
9281 Assert
.IsNull (ex
.InnerException
, "#C4");
9282 Assert
.IsNotNull (ex
.Message
, "#C5");
9283 Assert
.IsTrue (ex
.Message
.IndexOf (tb
.Name
) != -1, "#C6");
9284 Assert
.IsTrue (ex
.Message
.IndexOf (assembly
.FullName
) != -1, "#C7");
9289 public void CreateType_Parent_DefaultCtorMissing ()
9293 tb
= module
.DefineType (genTypeName ());
9294 ConstructorBuilder cb
= tb
.DefineConstructor (
9295 MethodAttributes
.Public
,
9296 CallingConventions
.Standard
,
9297 new Type
[] { typeof (string) }
);
9298 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
9299 Type parent_type
= tb
.CreateType ();
9301 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Class
,
9306 } catch (NotSupportedException ex
) {
9307 // Parent does not have a default constructor.
9308 // The default constructor must be explicitly defined
9309 Assert
.AreEqual (typeof (NotSupportedException
), ex
.GetType (), "#2");
9310 Assert
.IsNull (ex
.InnerException
, "#3");
9311 Assert
.IsNotNull (ex
.Message
, "#4");
9316 public void CreateType_Parent_Null ()
9321 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, null);
9322 Assert
.AreEqual (typeof (object), tb
.BaseType
, "#A1");
9323 emitted_type
= tb
.CreateType ();
9324 Assert
.AreEqual (typeof (object), emitted_type
.BaseType
, "#A2");
9326 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
| TypeAttributes
.Abstract
, null);
9327 Assert
.IsNull (tb
.BaseType
, "#B1");
9328 emitted_type
= tb
.CreateType ();
9329 Assert
.IsNull (emitted_type
.BaseType
, "#B2");
9333 [Category ("NotWorking")]
9334 public void DefineGenericParameters_AlreadyDefined ()
9336 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9337 tb
.DefineGenericParameters ("K");
9339 tb
.DefineGenericParameters ("V");
9341 } catch (InvalidOperationException ex
) {
9342 // Operation is not valid due to the current
9343 // state of the object
9344 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
9345 Assert
.IsNull (ex
.InnerException
, "#3");
9346 Assert
.IsNotNull (ex
.Message
, "#4");
9351 public void DefineGenericParameters_Names_Empty ()
9353 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9356 tb
.DefineGenericParameters (new string [0]);
9358 } catch (ArgumentException ex
) {
9359 // Value does not fall within the expected range
9360 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#2");
9361 Assert
.IsNull (ex
.InnerException
, "#3");
9362 Assert
.IsNotNull (ex
.Message
, "#4");
9363 Assert
.IsNull (ex
.ParamName
, "#5");
9368 public void DefineGenericParameters_Names_Null ()
9370 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9373 tb
.DefineGenericParameters ((string []) null);
9374 Assert
.Fail ("#A1");
9375 } catch (ArgumentNullException ex
) {
9376 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
9377 Assert
.IsNull (ex
.InnerException
, "#A3");
9378 Assert
.IsNotNull (ex
.Message
, "#A4");
9379 Assert
.AreEqual ("names", ex
.ParamName
, "#A5");
9383 tb
.DefineGenericParameters ("K", null, "V");
9384 Assert
.Fail ("#B1");
9385 } catch (ArgumentNullException ex
) {
9386 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#B2");
9387 Assert
.IsNull (ex
.InnerException
, "#B3");
9388 Assert
.IsNotNull (ex
.Message
, "#B4");
9389 Assert
.AreEqual ("names", ex
.ParamName
, "#B5");
9394 public void GenericType ()
9396 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9397 tb
.DefineGenericParameters ("T");
9399 Assert
.IsTrue (tb
.IsGenericType
, "#A1");
9400 Assert
.IsTrue (tb
.IsGenericTypeDefinition
, "#A2");
9401 Assert
.IsTrue (tb
.ContainsGenericParameters
, "#A3");
9402 Assert
.IsFalse (tb
.IsGenericParameter
, "#A4");
9404 Type
[] args
= tb
.GetGenericArguments ();
9405 Assert
.IsFalse (args
[0].IsGenericType
, "#B1");
9406 Assert
.IsFalse (args
[0].IsGenericTypeDefinition
, "#B2");
9407 Assert
.IsTrue (args
[0].ContainsGenericParameters
, "#B3");
9408 Assert
.IsTrue (args
[0].IsGenericParameter
, "#B4");
9412 public void MakeGenericType ()
9417 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9418 tb
.DefineGenericParameters ("T");
9420 generic_type
= tb
.MakeGenericType (typeof (int));
9421 Assert
.IsTrue (generic_type
.IsGenericType
, "#A1");
9422 Assert
.IsFalse (generic_type
.IsGenericTypeDefinition
, "#A2");
9423 Assert
.IsFalse (generic_type
.ContainsGenericParameters
, "#A3");
9424 Assert
.IsFalse (generic_type
.IsGenericParameter
, "#A4");
9426 generic_type
= tb
.MakeGenericType (typeof (List
<>).GetGenericArguments ());
9427 Assert
.IsTrue (generic_type
.IsGenericType
, "#B1");
9428 Assert
.IsFalse (generic_type
.IsGenericTypeDefinition
, "#B2");
9429 Assert
.IsTrue (generic_type
.ContainsGenericParameters
, "#B3");
9430 Assert
.IsFalse (generic_type
.IsGenericParameter
, "#B4");
9432 tb
= module
.DefineType (genTypeName (), TypeAttributes
.Interface
9433 | TypeAttributes
.Abstract
| TypeAttributes
.Public
);
9434 tb
.DefineGenericParameters ("T");
9436 generic_type
= tb
.MakeGenericType (typeof (int));
9437 Assert
.IsTrue (generic_type
.IsGenericType
, "#C1");
9438 Assert
.IsFalse (generic_type
.IsGenericTypeDefinition
, "#C2");
9439 Assert
.IsFalse (generic_type
.ContainsGenericParameters
, "#C3");
9440 Assert
.IsFalse (generic_type
.IsGenericParameter
, "#C4");
9442 generic_type
= tb
.MakeGenericType (typeof (List
<>).GetGenericArguments ());
9443 Assert
.IsTrue (generic_type
.IsGenericType
, "#D1");
9444 Assert
.IsFalse (generic_type
.IsGenericTypeDefinition
, "#D2");
9445 Assert
.IsTrue (generic_type
.ContainsGenericParameters
, "#D3");
9446 Assert
.IsFalse (generic_type
.IsGenericParameter
, "#D4");
9450 public void MakeGenericType_NoGenericTypeDefinition ()
9452 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9454 tb
.MakeGenericType (typeof (int));
9456 } catch (InvalidOperationException ex
) {
9457 // Operation is not valid due to the current
9458 // state of the object
9459 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
9460 Assert
.IsNull (ex
.InnerException
, "#3");
9461 Assert
.IsNotNull (ex
.Message
, "#4");
9466 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9467 public void MakeGenericType_TypeArguments_Null_Mono ()
9469 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9470 tb
.DefineGenericParameters ("K", "V");
9473 tb
.MakeGenericType ((Type
[]) null);
9474 Assert
.Fail ("#A1");
9475 } catch (ArgumentNullException ex
) {
9476 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#A2");
9477 Assert
.IsNull (ex
.InnerException
, "#A3");
9478 Assert
.IsNotNull (ex
.Message
, "#A4");
9479 Assert
.AreEqual ("typeArguments", ex
.ParamName
, "#A5");
9483 tb
.MakeGenericType (typeof (string), (Type
) null);
9484 Assert
.Fail ("#B1");
9485 } catch (ArgumentNullException ex
) {
9486 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#B2");
9487 Assert
.IsNull (ex
.InnerException
, "#B3");
9488 Assert
.IsNotNull (ex
.Message
, "#B4");
9489 Assert
.AreEqual ("typeArguments", ex
.ParamName
, "#B5");
9494 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351169
9495 public void MakeGenericType_TypeArguments_Null_MS ()
9500 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9501 tb
.DefineGenericParameters ("K", "V");
9503 generic_type
= tb
.MakeGenericType ((Type
[]) null);
9504 Assert
.IsNotNull (generic_type
, "#A1");
9505 Assert
.IsTrue (generic_type
.IsGenericType
, "#A2");
9506 Assert
.IsFalse (generic_type
.IsGenericTypeDefinition
, "#A3");
9507 type_args
= generic_type
.GetGenericArguments ();
9508 Assert
.IsNull (type_args
, "#A4");
9510 generic_type
= tb
.MakeGenericType (typeof (string), (Type
) null);
9511 Assert
.IsNotNull (generic_type
, "#B1");
9512 Assert
.IsTrue (generic_type
.IsGenericType
, "#B2");
9513 Assert
.IsFalse (generic_type
.IsGenericTypeDefinition
, "#B3");
9514 type_args
= generic_type
.GetGenericArguments ();
9515 Assert
.IsNotNull (type_args
, "#B4");
9516 Assert
.AreEqual (2, type_args
.Length
, "#B5");
9517 Assert
.AreEqual (typeof (string), type_args
[0], "#B6");
9518 Assert
.IsNull (type_args
[1], "#B7");
9522 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9523 public void MakeGenericType_TypeArguments_Mismatch_Mono ()
9525 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9526 tb
.DefineGenericParameters ("K", "V");
9528 tb
.MakeGenericType (typeof (int));
9530 } catch (ArgumentException ex
) {
9531 // The type or method has 2 generic prarameter(s)
9532 // but 1 generic argument(s) were provided. A
9533 // generic argument must be provided for each
9534 // generic parameter
9535 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#2");
9536 Assert
.IsNull (ex
.InnerException
, "#3");
9537 Assert
.IsNotNull (ex
.Message
, "#4");
9538 Assert
.AreEqual ("typeArguments", ex
.ParamName
, "#5");
9543 [Category ("NotWorking")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351143
9544 public void MakeGenericType_TypeArguments_Mismatch_MS ()
9546 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9547 tb
.DefineGenericParameters ("K", "V");
9549 Type generic_type
= tb
.MakeGenericType (typeof (int));
9550 Assert
.IsTrue (generic_type
.IsGenericType
, "#1");
9551 Assert
.IsFalse (generic_type
.IsGenericTypeDefinition
, "#2");
9552 Type
[] type_args
= generic_type
.GetGenericArguments ();
9553 Assert
.IsNotNull (type_args
, "#3");
9554 Assert
.AreEqual (1, type_args
.Length
, "#4");
9555 Assert
.AreEqual (typeof (int), type_args
[0], "#5");
9559 public void MakeArrayType_Complete ()
9562 TypeBuilder tb
= module
.DefineType (genTypeName (),
9563 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
9564 typeof (ContextBoundObject
));
9565 Type emittedType
= tb
.CreateType ();
9566 Type arrayType
= tb
.MakeArrayType ();
9567 Assert
.IsTrue (arrayType
.IsArray
, "#A1");
9568 Assert
.IsTrue (arrayType
.HasElementType
, "#A2");
9569 Assert
.AreEqual (tb
, arrayType
.GetElementType (), "#A3");
9570 Assert
.IsFalse (tb
.HasElementType
, "#A4");
9571 Assert
.IsTrue (tb
.IsCreated (), "#A5");
9574 tb
= module
.DefineType (genTypeName (),
9575 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
9576 typeof (ValueType
));
9577 emittedType
= tb
.CreateType ();
9578 arrayType
= tb
.MakeArrayType ();
9579 Assert
.IsTrue (arrayType
.IsArray
, "#B1");
9580 Assert
.IsTrue (arrayType
.HasElementType
, "#B2");
9581 Assert
.AreEqual (tb
, arrayType
.GetElementType (), "#B3");
9582 Assert
.IsFalse (tb
.HasElementType
, "#B4");
9583 Assert
.IsTrue (tb
.IsCreated (), "#B5");
9585 tb
= module
.DefineType (genTypeName (),
9586 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
9588 tb
.DefineField ("value__", typeof (int), FieldAttributes
.SpecialName
|
9589 FieldAttributes
.Private
| FieldAttributes
.RTSpecialName
);
9590 emittedType
= tb
.CreateType ();
9591 arrayType
= tb
.MakeArrayType ();
9592 Assert
.IsTrue (arrayType
.IsArray
, "#C1");
9593 Assert
.IsTrue (arrayType
.HasElementType
, "#C2");
9594 Assert
.AreEqual (tb
, arrayType
.GetElementType (), "#C3");
9595 Assert
.IsFalse (tb
.HasElementType
, "#C4");
9596 Assert
.IsTrue (tb
.IsCreated (), "#C5");
9599 [Test
] // bug #82015
9600 public void MakeArrayType_Incomplete ()
9603 TypeBuilder tb
= module
.DefineType (genTypeName (),
9604 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
9605 typeof (ContextBoundObject
));
9606 Type arrayType
= tb
.MakeArrayType ();
9607 Assert
.IsTrue (arrayType
.IsArray
, "#A1");
9608 Assert
.IsTrue (arrayType
.HasElementType
, "#A2");
9609 Assert
.AreEqual (tb
, arrayType
.GetElementType (), "#A3");
9610 Assert
.IsFalse (tb
.HasElementType
, "#A4");
9611 Assert
.IsFalse (tb
.IsCreated (), "#A5");
9614 tb
= module
.DefineType (genTypeName (),
9615 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
9616 typeof (ValueType
));
9617 arrayType
= tb
.MakeArrayType ();
9618 Assert
.IsTrue (arrayType
.IsArray
, "#B1");
9619 Assert
.IsTrue (arrayType
.HasElementType
, "#B2");
9620 Assert
.AreEqual (tb
, arrayType
.GetElementType (), "#B3");
9621 Assert
.IsFalse (tb
.HasElementType
, "#B4");
9622 Assert
.IsFalse (tb
.IsCreated (), "#B5");
9625 tb
= module
.DefineType (genTypeName (),
9626 TypeAttributes
.Sealed
| TypeAttributes
.Serializable
,
9628 arrayType
= tb
.MakeArrayType ();
9629 Assert
.IsTrue (arrayType
.IsArray
, "#C1");
9630 Assert
.IsTrue (arrayType
.HasElementType
, "#C2");
9631 Assert
.IsFalse (tb
.HasElementType
, "#C3");
9632 Assert
.IsFalse (tb
.IsCreated (), "#C4");
9636 public void GetCustomAttributes_InflatedType ()
9638 TypeBuilder tb
= module
.DefineType (genTypeName ());
9639 tb
.DefineGenericParameters (new string[] { "FOO" }
);
9641 ConstructorInfo guidCtor
= typeof (GuidAttribute
).GetConstructor (
9642 new Type
[] { typeof (string) }
);
9644 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (guidCtor
,
9645 new object [] { Guid.NewGuid ().ToString ("D") }
, new FieldInfo
[0], new object [0]);
9647 tb
.SetCustomAttribute (caBuilder
);
9648 Type t
= tb
.CreateType ();
9650 Type inflated
= t
.MakeGenericType (new Type
[] { typeof (int) }
);
9652 Assert
.AreEqual (1, inflated
.GetCustomAttributes (false).Length
);
9656 public void GetField ()
9658 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9659 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters ("T");
9661 ConstructorBuilder cb
= tb
.DefineDefaultConstructor (MethodAttributes
.Public
);
9663 FieldBuilder fb1
= tb
.DefineField ("field1", typeParams
[0], FieldAttributes
.Public
);
9665 Type t
= tb
.MakeGenericType (typeof (int));
9667 // Chect that calling MakeArrayType () does not initialize the class
9671 // Check that the instantiation of a type builder contains live data
9672 TypeBuilder
.GetField (t
, fb1
);
9673 FieldBuilder fb2
= tb
.DefineField ("field2", typeParams
[0], FieldAttributes
.Public
);
9674 FieldInfo fi2
= TypeBuilder
.GetField (t
, fb1
);
9676 MethodBuilder mb
= tb
.DefineMethod ("get_int", MethodAttributes
.Public
|MethodAttributes
.Static
, typeof (int), Type
.EmptyTypes
);
9677 ILGenerator ilgen
= mb
.GetILGenerator ();
9678 ilgen
.Emit (OpCodes
.Newobj
, TypeBuilder
.GetConstructor (t
, cb
));
9679 ilgen
.Emit (OpCodes
.Dup
);
9680 ilgen
.Emit (OpCodes
.Ldc_I4
, 42);
9681 ilgen
.Emit (OpCodes
.Stfld
, fi2
);
9682 ilgen
.Emit (OpCodes
.Ldfld
, fi2
);
9683 ilgen
.Emit (OpCodes
.Ret
);
9685 // Check GetField on a type instantiated with type parameters
9686 Type t3
= tb
.MakeGenericType (typeParams
[0]);
9687 FieldBuilder fb3
= tb
.DefineField ("field3", typeParams
[0], FieldAttributes
.Public
);
9688 FieldInfo fi3
= TypeBuilder
.GetField (t3
, fb3
);
9690 MethodBuilder mb3
= tb
.DefineMethod ("get_T", MethodAttributes
.Public
|MethodAttributes
.Static
, typeParams
[0], Type
.EmptyTypes
);
9691 ILGenerator ilgen3
= mb3
.GetILGenerator ();
9692 ilgen3
.Emit (OpCodes
.Newobj
, TypeBuilder
.GetConstructor (t3
, cb
));
9693 ilgen3
.Emit (OpCodes
.Ldfld
, fi3
);
9694 ilgen3
.Emit (OpCodes
.Ret
);
9696 Type created
= tb
.CreateType ();
9698 Type inst
= created
.MakeGenericType (typeof (object));
9700 Assert
.AreEqual (42, inst
.GetMethod ("get_int").Invoke (null, null));
9702 Assert
.AreEqual (null, inst
.GetMethod ("get_T").Invoke (null, null));
9705 [Test
] //bug #354047
9706 public void CreatedTypeInstantiationOverTypeBuilderArgsIsNotAGenericTypeDefinition ()
9708 TypeBuilder tb
= module
.DefineType ("TheType", TypeAttributes
.Public
, typeof (object), new Type
[] {typeof (IDelegateFactory)}
);
9709 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters (new String
[] { "T" }
);
9710 Type t
= tb
.CreateType ();
9712 Type inst
= tb
.MakeGenericType (typeParams
[0]);
9713 Assert
.IsFalse (inst
.IsGenericTypeDefinition
, "#1 create type instance is not a generic type definition");
9716 [Test
] //bug #354047
9717 public void CreatedTypeAndTypeBuilderOwnTheirGenericArguments ()
9719 TypeBuilder tb
= module
.DefineType ("TheType", TypeAttributes
.Public
, typeof (object), new Type
[] {typeof (IDelegateFactory)}
);
9720 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters (new String
[] { "T" }
);
9721 Type t
= tb
.CreateType ();
9723 Assert
.IsTrue (tb
.GetGenericArguments()[0].DeclaringType
== tb
, "#1 TypeBuilder owns its arguments");
9724 Assert
.IsTrue (t
.GetGenericArguments()[0].DeclaringType
== t
, "#1 create type owns its arguments");
9727 [Test
] //bug #354047
9728 public void CreatedTypeAndTypeBuilderDontShareGenericArguments ()
9730 TypeBuilder tb
= module
.DefineType ("TheType", TypeAttributes
.Public
, typeof (object), new Type
[] {typeof (IDelegateFactory)}
);
9731 GenericTypeParameterBuilder
[] typeParams
= tb
.DefineGenericParameters (new String
[] { "T" }
);
9732 Type t
= tb
.CreateType ();
9734 Assert
.IsTrue (tb
.GetGenericArguments()[0] != t
.GetGenericArguments()[0], "#1 TypeBuilder and create type arguments are diferent");
9737 [Test
] //bug #399047
9738 public void FieldOnTypeBuilderInstDontInflateWhenEncoded () {
9739 assembly
= Thread
.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME
), AssemblyBuilderAccess
.RunAndSave
, tempDir
);
9741 module
= assembly
.DefineDynamicModule ("Instance.exe");
9743 TypeBuilder G
= module
.DefineType ("G", TypeAttributes
.Public
);
9744 Type T
= G
.DefineGenericParameters ("T") [0];
9745 ConstructorInfo ctor
= G
.DefineDefaultConstructor (MethodAttributes
.Public
);
9746 Type GObj
= G
.MakeGenericType (new Type
[] { T }
);
9748 FieldBuilder F
= G
.DefineField ("F", T
, FieldAttributes
.Public
);
9750 TypeBuilder P
= module
.DefineType ("P", TypeAttributes
.Public
);
9752 MethodBuilder Test
= P
.DefineMethod ("Test", MethodAttributes
.Public
);
9753 Type TATest
= Test
.DefineGenericParameters ("TA") [0];
9755 Type TestGObj
= G
.MakeGenericType (new Type
[] { TATest }
);
9757 ILGenerator il
= Test
.GetILGenerator ();
9759 il
.Emit (OpCodes
.Newobj
, TypeBuilder
.GetConstructor (TestGObj
, ctor
));
9760 il
.Emit (OpCodes
.Ldfld
, TypeBuilder
.GetField (TestGObj
, F
));
9761 il
.Emit (OpCodes
.Pop
);
9763 il
.Emit (OpCodes
.Ret
);
9766 MethodBuilder main
= P
.DefineMethod ("Main", MethodAttributes
.Public
| MethodAttributes
.Static
);
9768 ILGenerator il
= main
.GetILGenerator ();
9769 il
.Emit(OpCodes
.Newobj
, P
.DefineDefaultConstructor (MethodAttributes
.Public
));
9770 il
.Emit(OpCodes
.Call
, Test
.MakeGenericMethod (typeof (int)));
9771 il
.Emit (OpCodes
.Ret
);
9774 assembly
.SetEntryPoint (main
);
9776 var PCreated
= P
.CreateType ();
9778 assembly
.Save ("Instance.exe");
9780 PCreated
.InvokeMember ("Main", BindingFlags
.Public
| BindingFlags
.Static
| BindingFlags
.InvokeMethod
, null, null, null);
9784 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers ()
9786 TypeBuilder tb
= module
.DefineType ("Type1", TypeAttributes
.Public
);
9787 FieldBuilder fb
= tb
.DefineInitializedData ("Foo", new byte [] {1,2,3,4}
, FieldAttributes
.Static
|FieldAttributes
.Public
);
9790 assembly
= Thread
.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME
+"2"), AssemblyBuilderAccess
.RunAndSave
, tempDir
);
9791 module
= assembly
.DefineDynamicModule ("Instance.exe");
9793 TypeBuilder tb2
= module
.DefineType ("Type2", TypeAttributes
.Public
);
9794 MethodBuilder mb
= tb2
.DefineMethod ("Test", MethodAttributes
.Public
| MethodAttributes
.Static
, typeof (object), new Type
[0]);
9795 ILGenerator il
= mb
.GetILGenerator ();
9797 il
.Emit (OpCodes
.Ldc_I4_1
);
9798 il
.Emit (OpCodes
.Newarr
, typeof (int));
9799 il
.Emit (OpCodes
.Dup
);
9800 il
.Emit (OpCodes
.Ldtoken
, fb
);
9801 il
.Emit (OpCodes
.Call
, typeof (RuntimeHelpers
).GetMethod ("InitializeArray"));
9802 il
.Emit (OpCodes
.Ret
);
9804 Type t
= tb2
.CreateType ();
9805 int[] res
= (int[])t
.GetMethod ("Test").Invoke (null, new object[0]);
9806 //Console.WriteLine (res[0]);
9810 public void FieldWithInitializedDataWorksWithCompilerRuntimeHelpers2 ()
9812 TypeBuilder tb
= module
.DefineType ("Type1", TypeAttributes
.Public
);
9813 var garg
= tb
.DefineGenericParameters ("T") [0];
9814 FieldBuilder fb
= tb
.DefineInitializedData ("Foo", new byte [] {1,2,3,4}
, FieldAttributes
.Static
|FieldAttributes
.Public
);
9817 assembly
= Thread
.GetDomain ().DefineDynamicAssembly (new AssemblyName (ASSEMBLY_NAME
+"2"), AssemblyBuilderAccess
.RunAndSave
, tempDir
);
9818 module
= assembly
.DefineDynamicModule ("Instance.exe");
9820 TypeBuilder tb2
= module
.DefineType ("Type2", TypeAttributes
.Public
);
9821 MethodBuilder mb
= tb2
.DefineMethod ("Test", MethodAttributes
.Public
| MethodAttributes
.Static
, typeof (object), new Type
[0]);
9822 ILGenerator il
= mb
.GetILGenerator ();
9824 il
.Emit (OpCodes
.Ldc_I4_1
);
9825 il
.Emit (OpCodes
.Newarr
, typeof (int));
9826 il
.Emit (OpCodes
.Dup
);
9827 il
.Emit (OpCodes
.Ldtoken
, fb
);
9828 il
.Emit (OpCodes
.Call
, typeof (RuntimeHelpers
).GetMethod ("InitializeArray"));
9829 il
.Emit (OpCodes
.Ret
);
9831 Type t
= tb2
.CreateType ();
9832 int[] res
= (int[])t
.GetMethod ("Test").Invoke (null, new object[0]);
9833 //Console.WriteLine (res[0]);
9836 public interface IDelegateFactory
9838 Delegate
Create (Delegate del
);
9842 public void CreateType_Ctor_NoBody ()
9844 TypeBuilder tb
= module
.DefineType (genTypeName ());
9845 tb
.DefineConstructor (MethodAttributes
.Public
,
9846 CallingConventions
.Standard
,
9847 new Type
[] { typeof (string) }
);
9851 } catch (InvalidOperationException ex
) {
9852 // Method '.ctor' does not have a method body
9853 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
9854 Assert
.IsNull (ex
.InnerException
, "#3");
9855 Assert
.IsNotNull (ex
.Message
, "#4");
9856 Assert
.IsTrue (ex
.Message
.IndexOf (".ctor") != -1, "#5");
9860 [Test
] //bug #361689
9861 public void CreateTypeFailsWithInvalidMethodOverride ()
9863 TypeBuilder tb
= module
.DefineType ("TheType", TypeAttributes
.Public
, typeof (object), new Type
[] {typeof (IDelegateFactory)}
);
9865 MethodBuilder mc
= tb
.DefineMethod ("Create", MethodAttributes
.Public
, typeof (Delegate
), new Type
[] {typeof (Delegate)}
);
9866 ILGenerator gen
= mc
.GetILGenerator ();
9867 gen
.Emit (OpCodes
.Ldarg_0
);
9868 gen
.Emit (OpCodes
.Ret
);
9869 tb
.DefineMethodOverride (mc
, typeof (IDelegateFactory
).GetMethod ("Create"));
9872 Assert
.Fail ("#1 create type did not throw TypeLoadException");
9873 } catch (TypeLoadException
) {
9878 [Test
] //bug #349194
9879 public void IsAssignableToWorksWithInterfacesOnParent ()
9881 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (EmptyIfaceImpl
));
9882 TypeBuilder tb2
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, tb
);
9884 Assert
.IsTrue (typeof (EmptyInterface
).IsAssignableFrom (tb
));
9885 Type t
= tb
.CreateType ();
9886 Assert
.IsTrue (typeof (EmptyInterface
).IsAssignableFrom (tb
));
9887 Assert
.IsTrue (typeof (EmptyInterface
).IsAssignableFrom (t
));
9890 Assert
.IsTrue (typeof (EmptyInterface
).IsAssignableFrom (tb2
));
9891 Type t2
= tb2
.CreateType ();
9892 Assert
.IsTrue (typeof (EmptyInterface
).IsAssignableFrom (tb2
));
9893 Assert
.IsTrue (typeof (EmptyInterface
).IsAssignableFrom (t2
));
9897 [Test
] //bug #430508
9898 public void MakeGenericTypeRespectBaseType ()
9900 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (EmptyIfaceImpl
));
9901 EnumBuilder eb
= module
.DefineEnum (genTypeName (), TypeAttributes
.Public
, typeof (int));
9903 MethodBuilder mb
= tb
.DefineMethod ("Test",
9904 MethodAttributes
.Public
,
9905 typeof (Tuple
<,>).MakeGenericType (typeof (int), eb
),
9907 ILGenerator il
= mb
.GetILGenerator();
9908 il
.Emit (OpCodes
.Ldnull
);
9909 il
.Emit (OpCodes
.Ret
);
9911 Type e
= eb
.CreateType ();
9912 Type c
= tb
.CreateType ();
9914 Assert
.AreEqual (c
.GetMethod ("Test").ReturnType
.GetGenericArguments ()[1], e
, "#1");
9918 public void GetCustomAttrOnFieldOfInflatedType ()
9920 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9921 tb
.DefineGenericParameters ("T");
9923 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (
9924 typeof (SimpleTestAttribute
).GetConstructors ()[0],
9927 FieldBuilder field
= tb
.DefineField ("OI", typeof (int), 0);
9928 field
.SetCustomAttribute (caBuilder
);
9930 Type t
= tb
.CreateType ();
9932 FieldInfo fi
= t
.GetFields (BindingFlags
.NonPublic
| BindingFlags
.Instance
)[0];
9933 object[] cattrs
= fi
.GetCustomAttributes (false);
9934 Assert
.AreEqual (1, cattrs
.Length
);
9936 fi
= t
.MakeGenericType (typeof (int)).GetFields (BindingFlags
.NonPublic
| BindingFlags
.Instance
)[0];
9937 cattrs
= fi
.GetCustomAttributes (false);
9938 Assert
.AreEqual (1, cattrs
.Length
);
9942 public void GetCustomAttrOnPropertyOfInflatedType ()
9944 TypeBuilder tb
= module
.DefineType (genTypeName ());
9945 tb
.DefineGenericParameters ("T");
9947 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (
9948 typeof (SimpleTestAttribute
).GetConstructors ()[0],
9951 PropertyBuilder property
= DefineStringProperty (tb
, "Name", "name", MethodAttributes
.Public
);
9952 property
.SetCustomAttribute (caBuilder
);
9954 Type t
= tb
.CreateType ();
9956 PropertyInfo pi
= t
.GetProperties ()[0];
9957 object[] cattrs
= pi
.GetCustomAttributes (false);
9958 Assert
.AreEqual (1, cattrs
.Length
);
9960 pi
= t
.MakeGenericType (typeof (int)).GetProperties ()[0];
9961 cattrs
= pi
.GetCustomAttributes (false);
9962 Assert
.AreEqual (1, cattrs
.Length
);
9966 public void GetCustomAttrOnEventOfInflatedType ()
9968 TypeBuilder tb
= module
.DefineType (genTypeName ());
9969 tb
.DefineGenericParameters ("T");
9971 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (
9972 typeof (SimpleTestAttribute
).GetConstructors ()[0],
9975 EventBuilder evt
= tb
.DefineEvent ("OI", 0, typeof (int));
9976 evt
.SetCustomAttribute (caBuilder
);
9978 Type t
= tb
.CreateType ();
9980 EventInfo ei
= t
.GetEvents (BindingFlags
.NonPublic
| BindingFlags
.Instance
)[0];
9981 object[] cattrs
= ei
.GetCustomAttributes (false);
9982 Assert
.AreEqual (1, cattrs
.Length
);
9984 ei
= t
.MakeGenericType (typeof (int)).GetEvents (BindingFlags
.NonPublic
| BindingFlags
.Instance
)[0];
9985 cattrs
= ei
.GetCustomAttributes (false);
9986 Assert
.AreEqual (1, cattrs
.Length
);
9989 public void TestDoubleInitializationOfMonoGenericClass () //bug #400643
9991 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
);
9992 tb
.DefineGenericParameters ("T");
9994 CustomAttributeBuilder caBuilder
= new CustomAttributeBuilder (
9995 typeof (SimpleTestAttribute
).GetConstructors ()[0],
9998 FieldBuilder field
= tb
.DefineField ("OI", typeof (int), 0);
9999 field
.SetCustomAttribute (caBuilder
);
10002 tb
.MakeGenericType (typeof (int)).GetMethods ();
10003 tb
.MakeGenericType (typeof (double)).GetMethods ();
10005 Type t
= tb
.CreateType ();
10007 t
.MakeGenericType (typeof (int)).GetMethods ();
10008 t
.MakeGenericType (typeof (double)).GetMethods ();
10012 public void TestGenericFieldAccess () // bug #467415
10014 AssemblyName asmName
= new AssemblyName("DemoMethodBuilder1");
10015 AppDomain domain
= AppDomain
.CurrentDomain
;
10016 AssemblyBuilder demoAssembly
=
10017 domain
.DefineDynamicAssembly(asmName
,
10018 AssemblyBuilderAccess
.RunAndSave
);
10020 // Define the module that contains the code. For an
10021 // assembly with one module, the module name is the
10022 // assembly name plus a file extension.
10023 ModuleBuilder demoModule
=
10024 demoAssembly
.DefineDynamicModule(asmName
.Name
,
10025 asmName
.Name
+".dll");
10027 TypeBuilder demoType
=
10028 demoModule
.DefineType("DemoType", TypeAttributes
.Public
);
10030 MethodBuilder factory
=
10031 demoType
.DefineMethod("Factory",
10032 MethodAttributes
.Public
| MethodAttributes
.Static
);
10034 string[] typeParameterNames
= {"T"}
;
10035 GenericTypeParameterBuilder
[] typeParameters
=
10036 factory
.DefineGenericParameters(typeParameterNames
);
10038 GenericTypeParameterBuilder T
= typeParameters
[0];
10041 factory
.SetParameters(parms
);
10043 factory
.SetReturnType(T
);
10045 ILGenerator ilgen
= factory
.GetILGenerator();
10047 Type G
= typeof(Gen
<>);
10048 Type GT
= G
.MakeGenericType (T
);
10049 FieldInfo GF
= G
.GetField("field");
10050 FieldInfo GTF
= TypeBuilder
.GetField(GT
, GF
);
10052 ilgen
.Emit(OpCodes
.Ldsfld
, GTF
);
10053 ilgen
.Emit(OpCodes
.Ret
);
10055 // Complete the type.
10056 Type dt
= demoType
.CreateType();
10057 // Save the assembly, so it can be examined with Ildasm.exe.
10058 //demoAssembly.Save(asmName.Name+".dll");
10060 MethodInfo m
= dt
.GetMethod("Factory");
10061 MethodInfo bound
= m
.MakeGenericMethod(typeof(int));
10063 // Display a string representing the bound method.
10064 //Console.WriteLine(bound);
10066 object[] parameters
= {};
10067 int result
= (int)(bound
.Invoke(null, parameters
));
10069 Assert
.AreEqual (0, result
, "#1");
10072 static MethodInfo
GetMethodByName (MethodInfo
[] methods
, string name
)
10074 foreach (MethodInfo mi
in methods
)
10075 if (mi
.Name
== name
)
10080 void CreateMembers (TypeBuilder tb
, string suffix
, bool defineCtors
)
10082 ConstructorBuilder cb
;
10084 PropertyBuilder pb
;
10090 // instance constructors
10092 cb
= tb
.DefineConstructor (MethodAttributes
.Private
,
10093 CallingConventions
.Standard
,
10094 new Type
[] { typeof (int), typeof (int) }
);
10095 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10097 cb
= tb
.DefineConstructor (MethodAttributes
.Family
,
10098 CallingConventions
.Standard
,
10099 new Type
[] { typeof (string) }
);
10100 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10102 cb
= tb
.DefineConstructor (MethodAttributes
.FamANDAssem
,
10103 CallingConventions
.Standard
,
10104 new Type
[] { typeof (string), typeof (string) }
);
10105 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10107 cb
= tb
.DefineConstructor (MethodAttributes
.FamORAssem
,
10108 CallingConventions
.Standard
,
10109 new Type
[] { typeof (int) }
);
10110 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10112 cb
= tb
.DefineConstructor (MethodAttributes
.Public
,
10113 CallingConventions
.Standard
,
10114 new Type
[] { typeof (int), typeof (bool) }
);
10115 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10117 cb
= tb
.DefineConstructor (MethodAttributes
.Assembly
,
10118 CallingConventions
.Standard
,
10119 new Type
[] { typeof (string), typeof (int) }
);
10120 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10123 // static constructors
10126 cb
= tb
.DefineConstructor (MethodAttributes
.Private
|
10127 MethodAttributes
.Static
,
10128 CallingConventions
.Standard
,
10130 cb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10134 // instance methods
10137 mb
= tb
.DefineMethod ("GetPrivateInstance" + suffix
,
10138 MethodAttributes
.Private
, typeof (void),
10140 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10142 mb
= tb
.DefineMethod ("GetFamilyInstance" + suffix
,
10143 MethodAttributes
.Family
, typeof (void),
10145 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10147 mb
= tb
.DefineMethod ("GetFamANDAssemInstance" + suffix
,
10148 MethodAttributes
.FamANDAssem
, typeof (void),
10150 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10152 mb
= tb
.DefineMethod ("GetFamORAssemInstance" + suffix
,
10153 MethodAttributes
.FamORAssem
, typeof (void),
10155 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10157 mb
= tb
.DefineMethod ("GetPublicInstance" + suffix
,
10158 MethodAttributes
.Public
, typeof (void),
10160 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10162 mb
= tb
.DefineMethod ("GetAssemblyInstance" + suffix
,
10163 MethodAttributes
.Assembly
, typeof (void),
10165 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10171 mb
= tb
.DefineMethod ("GetPrivateStatic" + suffix
,
10172 MethodAttributes
.Private
| MethodAttributes
.Static
,
10173 typeof (void), Type
.EmptyTypes
);
10174 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10176 mb
= tb
.DefineMethod ("GetFamilyStatic" + suffix
,
10177 MethodAttributes
.Family
| MethodAttributes
.Static
,
10178 typeof (void), Type
.EmptyTypes
);
10179 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10181 mb
= tb
.DefineMethod ("GetFamANDAssemStatic" + suffix
,
10182 MethodAttributes
.FamANDAssem
| MethodAttributes
.Static
,
10183 typeof (void), Type
.EmptyTypes
);
10184 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10186 mb
= tb
.DefineMethod ("GetFamORAssemStatic" + suffix
,
10187 MethodAttributes
.FamORAssem
| MethodAttributes
.Static
,
10188 typeof (void), Type
.EmptyTypes
);
10189 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10191 mb
= tb
.DefineMethod ("GetPublicStatic" + suffix
,
10192 MethodAttributes
.Public
| MethodAttributes
.Static
,
10193 typeof (void), Type
.EmptyTypes
);
10194 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10196 mb
= tb
.DefineMethod ("GetAssemblyStatic" + suffix
,
10197 MethodAttributes
.Assembly
| MethodAttributes
.Static
,
10198 typeof (void), Type
.EmptyTypes
);
10199 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10205 tb
.DefineField ("privateInstance" + suffix
,
10206 typeof (string), FieldAttributes
.Private
);
10207 tb
.DefineField ("familyInstance" + suffix
,
10208 typeof (string), FieldAttributes
.Family
);
10209 tb
.DefineField ("famANDAssemInstance" + suffix
,
10210 typeof (string), FieldAttributes
.FamANDAssem
);
10211 tb
.DefineField ("famORAssemInstance" + suffix
,
10212 typeof (string), FieldAttributes
.FamORAssem
);
10213 tb
.DefineField ("publicInstance" + suffix
,
10214 typeof (string), FieldAttributes
.Public
);
10215 tb
.DefineField ("assemblyInstance" + suffix
,
10216 typeof (string), FieldAttributes
.Assembly
);
10222 tb
.DefineField ("privateStatic" + suffix
,
10223 typeof (string), FieldAttributes
.Private
|
10224 FieldAttributes
.Static
);
10225 tb
.DefineField ("familyStatic" + suffix
,
10226 typeof (string), FieldAttributes
.Family
|
10227 FieldAttributes
.Static
);
10228 tb
.DefineField ("famANDAssemStatic" + suffix
,
10229 typeof (string), FieldAttributes
.FamANDAssem
|
10230 FieldAttributes
.Static
);
10231 tb
.DefineField ("famORAssemStatic" + suffix
,
10232 typeof (string), FieldAttributes
.FamORAssem
|
10233 FieldAttributes
.Static
);
10234 tb
.DefineField ("publicStatic" + suffix
,
10235 typeof (string), FieldAttributes
.Public
|
10236 FieldAttributes
.Static
);
10237 tb
.DefineField ("assemblyStatic" + suffix
,
10238 typeof (string), FieldAttributes
.Assembly
|
10239 FieldAttributes
.Static
);
10242 // instance properties
10245 pb
= tb
.DefineProperty ("PrivateInstance" + suffix
,
10246 PropertyAttributes
.None
, typeof (string),
10248 mb
= tb
.DefineMethod ("get_PrivateInstance" + suffix
,
10249 MethodAttributes
.Private
, typeof (string),
10251 ilgen
= mb
.GetILGenerator ();
10252 ilgen
.Emit (OpCodes
.Ldnull
);
10253 ilgen
.Emit (OpCodes
.Ret
);
10254 pb
.SetGetMethod (mb
);
10256 pb
= tb
.DefineProperty ("FamilyInstance" + suffix
,
10257 PropertyAttributes
.None
, typeof (string),
10259 mb
= tb
.DefineMethod ("get_FamilyInstance" + suffix
,
10260 MethodAttributes
.Family
, typeof (string),
10262 ilgen
= mb
.GetILGenerator ();
10263 ilgen
.Emit (OpCodes
.Ldnull
);
10264 ilgen
.Emit (OpCodes
.Ret
);
10265 pb
.SetGetMethod (mb
);
10267 pb
= tb
.DefineProperty ("FamANDAssemInstance" + suffix
,
10268 PropertyAttributes
.None
, typeof (string),
10270 mb
= tb
.DefineMethod ("get_FamANDAssemInstance" + suffix
,
10271 MethodAttributes
.FamANDAssem
, typeof (string),
10273 ilgen
= mb
.GetILGenerator ();
10274 ilgen
.Emit (OpCodes
.Ldnull
);
10275 ilgen
.Emit (OpCodes
.Ret
);
10276 pb
.SetGetMethod (mb
);
10278 pb
= tb
.DefineProperty ("FamORAssemInstance" + suffix
,
10279 PropertyAttributes
.None
, typeof (string),
10281 mb
= tb
.DefineMethod ("get_FamORAssemInstance" + suffix
,
10282 MethodAttributes
.FamORAssem
, typeof (string),
10284 ilgen
= mb
.GetILGenerator ();
10285 ilgen
.Emit (OpCodes
.Ldnull
);
10286 ilgen
.Emit (OpCodes
.Ret
);
10287 pb
.SetGetMethod (mb
);
10289 pb
= tb
.DefineProperty ("PublicInstance" + suffix
,
10290 PropertyAttributes
.None
, typeof (string),
10292 mb
= tb
.DefineMethod ("get_PublicInstance" + suffix
,
10293 MethodAttributes
.Public
, typeof (string),
10295 ilgen
= mb
.GetILGenerator ();
10296 ilgen
.Emit (OpCodes
.Ldnull
);
10297 ilgen
.Emit (OpCodes
.Ret
);
10298 pb
.SetGetMethod (mb
);
10300 pb
= tb
.DefineProperty ("AssemblyInstance" + suffix
,
10301 PropertyAttributes
.None
, typeof (string),
10303 mb
= tb
.DefineMethod ("get_AssemblyInstance" + suffix
,
10304 MethodAttributes
.Assembly
, typeof (string),
10306 ilgen
= mb
.GetILGenerator ();
10307 ilgen
.Emit (OpCodes
.Ldnull
);
10308 ilgen
.Emit (OpCodes
.Ret
);
10309 pb
.SetGetMethod (mb
);
10312 // static properties
10315 pb
= tb
.DefineProperty ("PrivateStatic" + suffix
,
10316 PropertyAttributes
.None
, typeof (string),
10318 mb
= tb
.DefineMethod ("get_PrivateStatic" + suffix
,
10319 MethodAttributes
.Private
| MethodAttributes
.Static
,
10320 typeof (string), Type
.EmptyTypes
);
10321 ilgen
= mb
.GetILGenerator ();
10322 ilgen
.Emit (OpCodes
.Ldnull
);
10323 ilgen
.Emit (OpCodes
.Ret
);
10324 pb
.SetGetMethod (mb
);
10326 pb
= tb
.DefineProperty ("FamilyStatic" + suffix
,
10327 PropertyAttributes
.None
, typeof (string),
10329 mb
= tb
.DefineMethod ("get_FamilyStatic" + suffix
,
10330 MethodAttributes
.Family
| MethodAttributes
.Static
,
10331 typeof (string), Type
.EmptyTypes
);
10332 ilgen
= mb
.GetILGenerator ();
10333 ilgen
.Emit (OpCodes
.Ldnull
);
10334 ilgen
.Emit (OpCodes
.Ret
);
10335 pb
.SetGetMethod (mb
);
10337 pb
= tb
.DefineProperty ("FamANDAssemStatic" + suffix
,
10338 PropertyAttributes
.None
, typeof (string),
10340 mb
= tb
.DefineMethod ("get_FamANDAssemStatic" + suffix
,
10341 MethodAttributes
.FamANDAssem
| MethodAttributes
.Static
,
10342 typeof (string), Type
.EmptyTypes
);
10343 ilgen
= mb
.GetILGenerator ();
10344 ilgen
.Emit (OpCodes
.Ldnull
);
10345 ilgen
.Emit (OpCodes
.Ret
);
10346 pb
.SetGetMethod (mb
);
10348 pb
= tb
.DefineProperty ("FamORAssemStatic" + suffix
,
10349 PropertyAttributes
.None
, typeof (string),
10351 mb
= tb
.DefineMethod ("get_FamORAssemStatic" + suffix
,
10352 MethodAttributes
.FamORAssem
| MethodAttributes
.Static
,
10353 typeof (string), Type
.EmptyTypes
);
10354 ilgen
= mb
.GetILGenerator ();
10355 ilgen
.Emit (OpCodes
.Ldnull
);
10356 ilgen
.Emit (OpCodes
.Ret
);
10357 pb
.SetGetMethod (mb
);
10359 pb
= tb
.DefineProperty ("PublicStatic" + suffix
,
10360 PropertyAttributes
.None
, typeof (string),
10362 mb
= tb
.DefineMethod ("get_PublicStatic" + suffix
,
10363 MethodAttributes
.Public
| MethodAttributes
.Static
,
10364 typeof (string), Type
.EmptyTypes
);
10365 ilgen
= mb
.GetILGenerator ();
10366 ilgen
.Emit (OpCodes
.Ldnull
);
10367 ilgen
.Emit (OpCodes
.Ret
);
10368 pb
.SetGetMethod (mb
);
10370 pb
= tb
.DefineProperty ("AssemblyStatic" + suffix
,
10371 PropertyAttributes
.None
, typeof (string),
10373 mb
= tb
.DefineMethod ("get_AssemblyStatic" + suffix
,
10374 MethodAttributes
.Assembly
| MethodAttributes
.Static
,
10375 typeof (string), Type
.EmptyTypes
);
10376 ilgen
= mb
.GetILGenerator ();
10377 ilgen
.Emit (OpCodes
.Ldnull
);
10378 ilgen
.Emit (OpCodes
.Ret
);
10379 pb
.SetGetMethod (mb
);
10385 eb
= tb
.DefineEvent ("OnPrivateInstance" + suffix
,
10386 EventAttributes
.None
, typeof (EventHandler
));
10387 mb
= tb
.DefineMethod ("add_OnPrivateInstance" + suffix
,
10388 MethodAttributes
.Private
, typeof (void),
10390 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10391 eb
.SetAddOnMethod (mb
);
10393 eb
= tb
.DefineEvent ("OnFamilyInstance" + suffix
,
10394 EventAttributes
.None
, typeof (EventHandler
));
10395 mb
= tb
.DefineMethod ("add_OnFamilyInstance" + suffix
,
10396 MethodAttributes
.Family
, typeof (void),
10398 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10399 eb
.SetAddOnMethod (mb
);
10401 eb
= tb
.DefineEvent ("OnFamANDAssemInstance" + suffix
,
10402 EventAttributes
.None
, typeof (EventHandler
));
10403 mb
= tb
.DefineMethod ("add_OnFamANDAssemInstance" + suffix
,
10404 MethodAttributes
.FamANDAssem
, typeof (void),
10406 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10407 eb
.SetAddOnMethod (mb
);
10409 eb
= tb
.DefineEvent ("OnFamORAssemInstance" + suffix
,
10410 EventAttributes
.None
, typeof (EventHandler
));
10411 mb
= tb
.DefineMethod ("add_OnFamORAssemInstance" + suffix
,
10412 MethodAttributes
.FamORAssem
, typeof (void),
10414 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10415 eb
.SetAddOnMethod (mb
);
10417 eb
= tb
.DefineEvent ("OnPublicInstance" + suffix
,
10418 EventAttributes
.None
, typeof (EventHandler
));
10419 mb
= tb
.DefineMethod ("add_OnPublicInstance" + suffix
,
10420 MethodAttributes
.Public
, typeof (void),
10422 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10423 eb
.SetAddOnMethod (mb
);
10425 eb
= tb
.DefineEvent ("OnAssemblyInstance" + suffix
,
10426 EventAttributes
.None
, typeof (EventHandler
));
10427 mb
= tb
.DefineMethod ("add_OnAssemblyInstance" + suffix
,
10428 MethodAttributes
.Family
, typeof (void),
10430 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10431 eb
.SetAddOnMethod (mb
);
10437 eb
= tb
.DefineEvent ("OnPrivateStatic" + suffix
,
10438 EventAttributes
.None
, typeof (EventHandler
));
10439 mb
= tb
.DefineMethod ("add_OnPrivateStatic" + suffix
,
10440 MethodAttributes
.Private
| MethodAttributes
.Static
,
10441 typeof (void), Type
.EmptyTypes
);
10442 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10443 eb
.SetAddOnMethod (mb
);
10445 eb
= tb
.DefineEvent ("OnFamilyStatic" + suffix
,
10446 EventAttributes
.None
, typeof (EventHandler
));
10447 mb
= tb
.DefineMethod ("add_OnFamilyStatic" + suffix
,
10448 MethodAttributes
.Family
| MethodAttributes
.Static
,
10449 typeof (void), Type
.EmptyTypes
);
10450 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10451 eb
.SetAddOnMethod (mb
);
10453 eb
= tb
.DefineEvent ("OnFamANDAssemStatic" + suffix
,
10454 EventAttributes
.None
, typeof (EventHandler
));
10455 mb
= tb
.DefineMethod ("add_OnFamANDAssemStatic" + suffix
,
10456 MethodAttributes
.FamANDAssem
| MethodAttributes
.Static
,
10457 typeof (void), Type
.EmptyTypes
);
10458 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10459 eb
.SetAddOnMethod (mb
);
10461 eb
= tb
.DefineEvent ("OnFamORAssemStatic" + suffix
,
10462 EventAttributes
.None
, typeof (EventHandler
));
10463 mb
= tb
.DefineMethod ("add_OnFamORAssemStatic" + suffix
,
10464 MethodAttributes
.FamORAssem
| MethodAttributes
.Static
,
10465 typeof (void), Type
.EmptyTypes
);
10466 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10467 eb
.SetAddOnMethod (mb
);
10469 eb
= tb
.DefineEvent ("OnPublicStatic" + suffix
,
10470 EventAttributes
.None
, typeof (EventHandler
));
10471 mb
= tb
.DefineMethod ("add_OnPublicStatic" + suffix
,
10472 MethodAttributes
.Public
| MethodAttributes
.Static
,
10473 typeof (void), Type
.EmptyTypes
);
10474 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10475 eb
.SetAddOnMethod (mb
);
10477 eb
= tb
.DefineEvent ("OnAssemblyStatic" + suffix
,
10478 EventAttributes
.None
, typeof (EventHandler
));
10479 mb
= tb
.DefineMethod ("add_OnAssemblyStatic" + suffix
,
10480 MethodAttributes
.Family
| MethodAttributes
.Static
,
10481 typeof (void), Type
.EmptyTypes
);
10482 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10483 eb
.SetAddOnMethod (mb
);
10486 static TypeBuilder Resolve1_Tb
;
10487 static bool Resolve1_Called
;
10489 public class Lookup
<T
>
10491 public static Type t
= typeof(T
);
10494 Assembly
Resolve1 (object sender
, ResolveEventArgs args
) {
10495 Resolve1_Called
= true;
10496 Resolve1_Tb
.CreateType ();
10497 return Resolve1_Tb
.Assembly
;
10501 public void TypeResolveGenericInstances () {
10502 // Test that TypeResolve is called for generic instances (#483852)
10503 TypeBuilder tb1
= null;
10505 AppDomain
.CurrentDomain
.TypeResolve
+= Resolve1
;
10507 tb1
= module
.DefineType("Foo");
10509 FieldInfo field
= TypeBuilder
.GetField(typeof(Lookup
<>).MakeGenericType(tb1
), typeof(Lookup
<>).GetField("t"));
10510 TypeBuilder tb2
= module
.DefineType("Bar");
10511 ConstructorBuilder cb
= tb2
.DefineConstructor(MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
10512 ILGenerator ilgen
= cb
.GetILGenerator();
10514 ilgen
.Emit(OpCodes
.Ldarg_0
);
10515 ilgen
.Emit(OpCodes
.Call
, tb2
.BaseType
.GetConstructor(Type
.EmptyTypes
));
10517 ilgen
.Emit(OpCodes
.Ldsfld
, field
);
10518 ilgen
.Emit(OpCodes
.Pop
);
10519 ilgen
.Emit(OpCodes
.Ret
);
10520 Activator
.CreateInstance(tb2
.CreateType());
10522 Assert
.IsTrue (Resolve1_Called
);
10526 public void CreateConcreteTypeWithAbstractMethod ()
10528 TypeBuilder tb
= module
.DefineType (genTypeName ());
10529 tb
.DefineMethod("method", MethodAttributes
.Abstract
| MethodAttributes
.Public
, typeof (void), Type
.EmptyTypes
);
10532 Assert
.Fail ("#1");
10533 } catch (InvalidOperationException
) {}
10537 public void ConcreteTypeDontLeakGenericParamFromItSelf ()
10539 var tb
= module
.DefineType (genTypeName ());
10540 var gps
= tb
.DefineGenericParameters ("T");
10541 var mb
= tb
.DefineMethod ("m", MethodAttributes
.Public
| MethodAttributes
.Static
);
10542 mb
.SetParameters (gps
);
10543 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10545 var ti
= tb
.CreateType ();
10546 var mi
= ti
.GetMethod ("m");
10547 var arg0
= mi
.GetParameters () [0].ParameterType
;
10549 Assert
.AreNotSame (arg0
, gps
[0], "#1");
10553 public void ConcreteTypeDontLeakGenericParamFromMethods ()
10555 var tb
= module
.DefineType (genTypeName ());
10556 var mb
= tb
.DefineMethod("m", MethodAttributes
.Public
| MethodAttributes
.Static
);
10557 var gps
= mb
.DefineGenericParameters ("T");
10558 mb
.SetParameters (gps
);
10559 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10561 var ti
= tb
.CreateType ();
10562 var mi
= ti
.GetMethod ("m");
10563 var arg0
= mi
.GetParameters () [0].ParameterType
;
10565 Assert
.AreNotSame (arg0
, gps
[0], "#1");
10569 public void DeclaringMethodReturnsNull ()
10571 TypeBuilder tb
= module
.DefineType (genTypeName ());
10572 Assert
.IsNull (tb
.DeclaringMethod
, null, "#1");
10576 public void GenericParameterPositionReturns0 ()
10578 TypeBuilder tb
= module
.DefineType (genTypeName ());
10579 Assert
.AreEqual (0, tb
.GenericParameterPosition
, "#1");
10583 public void GetGenericTypeDefinitionBehavior ()
10585 TypeBuilder tb
= module
.DefineType (genTypeName ());
10587 tb
.GetGenericTypeDefinition ();
10588 Assert
.Fail ("#1");
10589 } catch (InvalidOperationException
) {}
10591 tb
.DefineGenericParameters ("T");
10592 Assert
.AreEqual (tb
, tb
.GetGenericTypeDefinition (), "#2");
10595 Assert
.AreEqual (tb
, tb
.GetGenericTypeDefinition (), "#3");
10599 public void GetElementTypeNotSupported ()
10601 TypeBuilder tb
= module
.DefineType (genTypeName ());
10603 tb
.GetElementType ();
10604 Assert
.Fail ("#1");
10605 } catch (NotSupportedException
) {}
10609 public void GenericParameterAttributesReturnsNone ()
10611 TypeBuilder tb
= module
.DefineType (genTypeName ());
10612 Assert
.AreEqual (GenericParameterAttributes
.None
, tb
.GenericParameterAttributes
, "#1");
10614 tb
.DefineGenericParameters ("T");
10615 Assert
.AreEqual (GenericParameterAttributes
.None
, tb
.GenericParameterAttributes
, "#2");
10618 Assert
.AreEqual (GenericParameterAttributes
.None
, tb
.GenericParameterAttributes
, "#3");
10622 public void GetGenericArgumentsReturnsNullForNonGenericTypeBuilder ()
10624 TypeBuilder tb
= module
.DefineType (genTypeName ());
10625 Assert
.IsNull (tb
.GetGenericArguments (), "#1");
10628 public interface IFaceA
{}
10629 public interface IFaceB
: IFaceA
{}
10631 public void GetInterfacesAfterCreate ()
10633 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object), new Type
[] { typeof (IFaceB) }
);
10635 Type
[] ifaces
= tb
.GetInterfaces ();
10636 Assert
.AreEqual (1, ifaces
.Length
, "#1");
10637 Assert
.AreEqual (typeof (IFaceB
), ifaces
[0], "#2");
10640 ifaces
= tb
.GetInterfaces ();
10641 Assert
.AreEqual (2, ifaces
.Length
, "#3");
10642 //Interfaces can come in any particular order
10643 if (ifaces
[0] == typeof (IFaceB
)) {
10644 Assert
.AreEqual (typeof (IFaceB
), ifaces
[0], "#4");
10645 Assert
.AreEqual (typeof (IFaceA
), ifaces
[1], "#5");
10647 Assert
.AreEqual (typeof (IFaceB
), ifaces
[1], "#4");
10648 Assert
.AreEqual (typeof (IFaceA
), ifaces
[0], "#5");
10652 public interface MB_Iface
10657 public class MB_Impl
: MB_Iface
10659 public virtual int Test () { return 1; }
10662 public void MethodOverrideBodyMustBelongToTypeBuilder ()
10664 TypeBuilder tb
= module
.DefineType (genTypeName ());
10665 MethodInfo md
= typeof (MB_Iface
).GetMethod("Test");
10666 MethodInfo md2
= typeof (MB_Impl
).GetMethod("Test");
10668 tb
.DefineMethodOverride (md
, md2
);
10669 Assert
.Fail ("#1");
10670 } catch (ArgumentException
) {}
10674 public void GetConstructorsThrowWhenIncomplete ()
10676 TypeBuilder tb
= module
.DefineType (genTypeName ());
10678 tb
.GetConstructors (BindingFlags
.Instance
);
10679 Assert
.Fail ("#1");
10680 } catch (NotSupportedException
) { }
10683 Assert
.IsNotNull (tb
.GetConstructors (BindingFlags
.Instance
), "#2");
10687 public void GetEventsThrowWhenIncomplete ()
10689 TypeBuilder tb
= module
.DefineType (genTypeName ());
10691 tb
.GetEvents (BindingFlags
.Instance
);
10692 Assert
.Fail ("#1");
10693 } catch (NotSupportedException
) { }
10696 Assert
.IsNotNull (tb
.GetEvents (BindingFlags
.Instance
), "#2");
10700 public void GetNestedTypeCreatedAfterTypeIsCreated ()
10702 TypeBuilder tb
= module
.DefineType (genTypeName ());
10703 TypeBuilder nested
= tb
.DefineNestedType ("Bar", TypeAttributes
.Class
| TypeAttributes
.NestedPrivate
);
10705 Assert
.IsNull (tb
.GetNestedType ("Bar", BindingFlags
.NonPublic
), "#1");
10706 Type res
= nested
.CreateType ();
10707 Assert
.AreEqual (res
, tb
.GetNestedType ("Bar", BindingFlags
.NonPublic
), "#2");
10709 TypeBuilder nested2
= tb
.DefineNestedType ("Bar2", TypeAttributes
.Class
| TypeAttributes
.NestedPrivate
);
10710 Assert
.IsNull (tb
.GetNestedType ("Bar2", BindingFlags
.NonPublic
), "#3");
10711 res
= nested2
.CreateType ();
10712 Assert
.AreEqual (res
, tb
.GetNestedType ("Bar2", BindingFlags
.NonPublic
), "#4");
10717 public void IsDefinedThrowWhenIncomplete ()
10719 TypeBuilder tb
= module
.DefineType (genTypeName ());
10721 tb
.IsDefined (typeof (string), true);
10722 Assert
.Fail ("#1");
10723 } catch (NotSupportedException
) { }
10726 Assert
.IsNotNull (tb
.IsDefined (typeof (string), true), "#2");
10729 [Test
] //Bug #594728
10730 public void IsSubclassOfWorksIfSetParentIsCalledOnParent ()
10732 var tb_a
= module
.DefineType ("A", TypeAttributes
.Public
);
10733 var tb_b
= module
.DefineType ("B", TypeAttributes
.Public
);
10735 tb_b
.SetParent (tb_a
);
10736 tb_a
.SetParent (typeof (Attribute
));
10738 Assert
.IsTrue (tb_b
.IsSubclassOf (tb_a
), "#1");
10739 Assert
.IsTrue (tb_b
.IsSubclassOf (typeof (Attribute
)), "#2");
10740 Assert
.IsFalse (tb_a
.IsSubclassOf (tb_b
), "#3");
10743 var a
= tb_a
.CreateType ();
10744 var b
= tb_b
.CreateType ();
10746 Assert
.IsTrue (b
.IsSubclassOf (a
), "#4");
10747 Assert
.IsTrue (b
.IsSubclassOf (typeof (Attribute
)), "#5");
10748 Assert
.IsFalse (a
.IsSubclassOf (b
), "#6");
10752 public void DefinedDefaultConstructorWorksWithGenericBaseType ()
10754 AssemblyName assemblyName
= new AssemblyName ("a");
10755 AssemblyBuilder ass
= AppDomain
.CurrentDomain
.DefineDynamicAssembly (assemblyName
, AssemblyBuilderAccess
.RunAndSave
);
10756 var mb
= ass
.DefineDynamicModule ("a.dll");
10758 var tb
= mb
.DefineType ("Base");
10759 tb
.DefineGenericParameters ("F");
10761 var inst
= tb
.MakeGenericType (typeof (int));
10762 var tb2
= mb
.DefineType ("Child", TypeAttributes
.Public
, inst
);
10765 var res
= tb2
.CreateType ();
10767 Assert
.IsNotNull (res
, "#1");
10768 Assert
.AreEqual (1, res
.GetConstructors ().Length
, "#2");
10772 * Tests for passing user types to Ref.Emit. Currently these only test
10773 * whenever the runtime code can handle them without crashing, since we
10774 * don't support user types yet.
10775 * These tests are disabled for windows since the MS runtime trips on them.
10778 [Category ("NotDotNet")] //Proper UT handling is a mono extension to SRE bugginess
10779 public void UserTypes () {
10780 TypeDelegator t
= new TypeDelegator (typeof (int));
10784 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, t
);
10790 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object), new Type
[] { t }
);
10797 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10798 tb
.DefineField ("Foo", t
, FieldAttributes
.Public
);
10804 /* Custom modifiers on fields */
10805 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10806 tb
.DefineField ("Foo", typeof (int), new Type
[] { t }
, new Type
[] { t }
, FieldAttributes
.Public
);
10810 /* this is mono only
10812 UnmanagedMarshal m = UnmanagedMarshal.DefineCustom (t, "foo", "bar", Guid.Empty);
10813 TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public, typeof (object));
10814 FieldBuilder fb = tb.DefineField ("Foo", typeof (int), FieldAttributes.Public);
10822 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10823 tb
.DefineProperty ("Foo", PropertyAttributes
.None
, t
, null);
10829 /* Custom modifiers on properties */
10830 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10831 // FIXME: These seems to be ignored
10832 tb
.DefineProperty ("Foo", PropertyAttributes
.None
, typeof (int), new Type
[] { t }
, new Type
[] { t }
, null, null, null);
10838 /* Method return types */
10839 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10840 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
, t
, null);
10841 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10847 /* Custom modifiers on method return types */
10848 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10849 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
, CallingConventions
.Standard
, typeof (int), new Type
[] { t }
, new Type
[] { t }
, null, null, null);
10850 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10856 /* Method parameters */
10857 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10858 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
, typeof (int), new Type
[] { t }
);
10859 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10865 /* Custom modifiers on method parameters */
10866 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10867 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 }}
);
10868 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10874 /* Ctor parameters */
10875 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10876 ConstructorBuilder mb
= tb
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, new Type
[] { t }
);
10877 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10883 /* Custom modifiers on ctor parameters */
10884 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10885 ConstructorBuilder mb
= tb
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, new Type
[] { typeof (int) }
, new Type
[][] { new Type [] { t }}
, new Type
[][] { new Type [] { t }}
);
10886 mb
.GetILGenerator ().Emit (OpCodes
.Ret
);
10892 /* SignatureHelper arguments */
10893 SignatureHelper sighelper
= SignatureHelper
.GetFieldSigHelper (module
);
10894 sighelper
.AddArgument (t
, false);
10895 byte[] arr
= sighelper
.GetSignature ();
10900 SignatureHelper sighelper
= SignatureHelper
.GetLocalVarSigHelper (module
);
10901 sighelper
.AddArgument (t
, false);
10902 byte[] arr
= sighelper
.GetSignature ();
10907 /* Custom modifiers on SignatureHelper arguments */
10908 SignatureHelper sighelper
= SignatureHelper
.GetFieldSigHelper (module
);
10909 sighelper
.AddArgument (typeof (int), new Type
[] { t }
, new Type
[] { t }
);
10910 byte[] arr
= sighelper
.GetSignature ();
10915 /* Custom modifiers on SignatureHelper arguments */
10916 SignatureHelper sighelper
= SignatureHelper
.GetLocalVarSigHelper (module
);
10917 sighelper
.AddArgument (typeof (int), new Type
[] { t }
, new Type
[] { t }
);
10918 byte[] arr
= sighelper
.GetSignature ();
10922 /* Arguments to ILGenerator methods */
10925 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10926 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
, CallingConventions
.Standard
, typeof (int), new Type
[] { }
);
10927 ILGenerator ig
= mb
.GetILGenerator ();
10928 ig
.Emit (OpCodes
.Ldnull
);
10929 ig
.Emit (OpCodes
.Castclass
, t
);
10930 ig
.Emit (OpCodes
.Pop
);
10931 ig
.Emit (OpCodes
.Ret
);
10937 /* DeclareLocal () */
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
.DeclareLocal (t
);
10942 ig
.Emit (OpCodes
.Ret
);
10948 /* BeginExceptionCatchBlock () */
10949 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10950 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
, CallingConventions
.Standard
, typeof (int), new Type
[] { }
);
10951 ILGenerator ig
= mb
.GetILGenerator ();
10952 ig
.BeginExceptionBlock ();
10953 ig
.BeginCatchBlock (t
);
10954 ig
.Emit (OpCodes
.Ret
);
10961 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Public
, typeof (object));
10962 MethodBuilder mb
= tb
.DefineMethod ("foo", MethodAttributes
.Public
, CallingConventions
.Standard
, typeof (int), new Type
[] { }
);
10963 ILGenerator ig
= mb
.GetILGenerator ();
10964 ig
.EmitCalli (OpCodes
.Call
, CallingConventions
.Standard
, typeof (void), new Type
[] { t }
, null);
10965 ig
.Emit (OpCodes
.Ret
);
10973 [Category ("MobileNotWorking")] // Mono.CompilerServices.SymbolWriter not available in XA
10974 public void CircularArrayType()
10976 var assemblyBuilder
= AppDomain
.CurrentDomain
.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess
.RunAndSave
);
10977 var moduleBuilder
= assemblyBuilder
.DefineDynamicModule("Test", "Test.dll", true);
10978 var typeBuilder
= moduleBuilder
.DefineType("Foo", TypeAttributes
.Public
);
10979 var fieldBuilder
= typeBuilder
.DefineField("Foos", typeBuilder
.MakeArrayType(), FieldAttributes
.Public
);
10981 var fooType
= typeBuilder
.CreateType();
10982 Assert
.AreSame(fooType
.MakeArrayType(), fooType
.GetField("Foos").FieldType
);
10986 [Test
] //Test for #422113
10987 [ExpectedException (typeof (TypeLoadException
))]
10988 public void CreateInstanceOfIncompleteType ()
10990 TypeBuilder tb
= module
.DefineType (genTypeName (), TypeAttributes
.Class
, null, new Type
[] { typeof (IComparable) }
);
10991 Type proxyType
= tb
.CreateType();
10992 Activator
.CreateInstance(proxyType
);
10995 [Test
] //Test for #640780
10996 public void StaticMethodNotUsedInIfaceVtable ()
10998 TypeBuilder tb1
= module
.DefineType("Interface", TypeAttributes
.Interface
| TypeAttributes
.Abstract
);
10999 tb1
.DefineTypeInitializer().GetILGenerator().Emit(OpCodes
.Ret
);
11000 tb1
.DefineMethod("m", MethodAttributes
.Public
| MethodAttributes
.Virtual
| MethodAttributes
.Abstract
);
11003 TypeBuilder tb2
= module
.DefineType("Class", TypeAttributes
.Sealed
);
11004 tb2
.AddInterfaceImplementation(tb1
);
11005 tb2
.DefineMethod("m", MethodAttributes
.Public
| MethodAttributes
.Virtual
)
11006 .GetILGenerator().Emit(OpCodes
.Ret
);
11007 tb2
.DefineDefaultConstructor(MethodAttributes
.Public
);
11009 Activator
.CreateInstance(tb2
.CreateType());
11012 [Test
] //Test for #648391
11013 public void GetConstructorCheckCtorDeclaringType ()
11015 TypeBuilder myType
= module
.DefineType ("Sample", TypeAttributes
.Public
);
11016 string[] typeParamNames
= { "TFirst" }
;
11017 GenericTypeParameterBuilder
[] typeParams
= myType
.DefineGenericParameters (typeParamNames
);
11018 var ctor
= myType
.DefineDefaultConstructor (MethodAttributes
.Public
);
11019 var ctori
= TypeBuilder
.GetConstructor (myType
.MakeGenericType (typeof (int)), ctor
);
11021 TypeBuilder
.GetConstructor (myType
.MakeGenericType (typeof (bool)), ctori
);
11022 Assert
.Fail ("#1");
11023 } catch (ArgumentException
) {
11028 [Test
] //Test for #649237
11029 public void GetFieldCheckFieldDeclaringType () {
11030 TypeBuilder myType
= module
.DefineType ("Sample", TypeAttributes
.Public
);
11031 myType
.DefineGenericParameters ( "TFirst");
11032 TypeBuilder otherType
= module
.DefineType ("Sample2", TypeAttributes
.Public
);
11033 otherType
.DefineGenericParameters ( "TFirst");
11035 var field
= myType
.DefineField ("field", typeof (object), FieldAttributes
.Public
);
11038 TypeBuilder
.GetField (otherType
.MakeGenericType (typeof (int)), field
);
11039 Assert
.Fail ("#1");
11040 } catch (ArgumentException
) {
11046 public void TypeWithFieldRVAWorksUnderSgen () {
11047 AssemblyName an
= new AssemblyName("MAIN");
11048 AssemblyBuilder ab
= AppDomain
.CurrentDomain
.DefineDynamicAssembly(an
,
11049 AssemblyBuilderAccess
.Run
, ".");
11050 ModuleBuilder mob
= ab
.DefineDynamicModule("MAIN");
11051 TypeBuilder tb
= mob
.DefineType("MAIN", TypeAttributes
.Public
|
11052 TypeAttributes
.Sealed
| TypeAttributes
.Abstract
|
11053 TypeAttributes
.Class
| TypeAttributes
.BeforeFieldInit
);
11055 byte[] source
= new byte[] { 42 }
;
11056 FieldBuilder fb
= tb
.DefineInitializedData("A0", source
, 0);
11058 MethodBuilder mb
= tb
.DefineMethod("EVAL", MethodAttributes
.Static
|
11059 MethodAttributes
.Public
, typeof(byte[]), new Type
[] { }
);
11060 ILGenerator il
= mb
.GetILGenerator();
11062 il
.Emit(OpCodes
.Ldc_I4_1
);
11063 il
.Emit(OpCodes
.Newarr
, typeof(byte));
11064 il
.Emit(OpCodes
.Dup
);
11065 il
.Emit(OpCodes
.Ldtoken
, fb
);
11066 il
.Emit(OpCodes
.Call
, typeof(RuntimeHelpers
).GetMethod("InitializeArray"));
11067 il
.Emit(OpCodes
.Ret
);
11069 Type t
= tb
.CreateType();
11073 byte[] res
= (byte[]) t
.InvokeMember("EVAL", BindingFlags
.Public
|
11074 BindingFlags
.Static
| BindingFlags
.InvokeMethod
, null, null,
11077 Assert
.AreEqual (42, res
[0]);
11082 public void Ldfld_Regress_9531 () {
11083 Build
<Example
<int>> ();
11087 var base_class
= typeof(T
);
11089 var builder
= module
.DefineType(genTypeName (),
11090 TypeAttributes
.Class
| TypeAttributes
.Sealed
| TypeAttributes
.Public
,
11093 var field
= builder
.BaseType
.GetField("Field", BindingFlags
.Instance
| BindingFlags
.Public
);
11095 var cb
= builder
.DefineConstructor(
11096 MethodAttributes
.Public
| MethodAttributes
.SpecialName
,
11097 CallingConventions
.HasThis
,
11098 new[] { typeof(string) }
);
11100 var il
= cb
.GetILGenerator();
11104 throw new InvalidOperationException("wtf");
11107 il
.Emit(OpCodes
.Ldarg_0
);
11108 il
.Emit(OpCodes
.Ldarg_1
);
11109 il
.Emit(OpCodes
.Stfld
, field
);
11110 il
.Emit(OpCodes
.Ret
);
11112 builder
.CreateType();
11115 public class Example
<T
> {
11116 public string Field
;
11121 [Category ("AndroidNotWorking")]
11122 // It's not possible to save the assembly in the current directory on Android and AssemblyBuilder.DefineDynamicModule will not
11123 // allow a full path to the assembly to be passed to it. Trying to change the current directory before saving will not work either as
11124 // FileStream will then prepend / to the file name (perhaps it's another bug) and write access to the filesystem root is, obviously, denied
11125 public void Ldfld_Encoding_10122 () {
11126 Build2
<Example
<int>> ();
11129 void Build2
<T
> () {
11130 var base_class
= typeof(T
);
11132 string AssemblyName
= genTypeName ();
11133 string AssemblyFileName
= AssemblyName
+ ".dll";
11135 var assemblyBuilderAccess
= AssemblyBuilderAccess
.Save
;
11136 var assemblyName
= new AssemblyName(AssemblyName
);
11137 var assemblyBuilder
= AppDomain
.CurrentDomain
.DefineDynamicAssembly(assemblyName
, assemblyBuilderAccess
);
11138 var moduleBuilder
= assemblyBuilder
.DefineDynamicModule(AssemblyName
, AssemblyFileName
);
11141 var builder
= moduleBuilder
.DefineType("Wrapped",
11142 TypeAttributes
.Class
| TypeAttributes
.Sealed
| TypeAttributes
.Public
,
11145 var field
= builder
.BaseType
.GetField("Field", BindingFlags
.Instance
| BindingFlags
.Public
);
11147 var cb
= builder
.DefineConstructor(
11148 MethodAttributes
.Public
| MethodAttributes
.SpecialName
,
11149 CallingConventions
.HasThis
,
11150 new[] { typeof(string) }
);
11152 var il
= cb
.GetILGenerator();
11156 throw new InvalidOperationException("wtf");
11159 il
.Emit(OpCodes
.Ldarg_0
);
11160 il
.Emit(OpCodes
.Ldarg_1
);
11161 il
.Emit(OpCodes
.Stfld
, field
);
11162 il
.Emit(OpCodes
.Ret
);
11164 builder
.CreateType();
11166 assemblyBuilder
.Save (AssemblyFileName
);
11168 var fromDisk
= Assembly
.Load (AssemblyName
);
11169 Console
.WriteLine (fromDisk
);
11170 var t
= fromDisk
.GetType ("Wrapped");
11171 Activator
.CreateInstance (t
, new object[] { "string"}
);
11174 public interface IFace16096
{
11179 public void MemberRef_Caching_16096 () {
11180 var outer_class
= module
.DefineType(
11182 TypeAttributes
.Class
| TypeAttributes
.Public
,
11185 var builder
= outer_class
.DefineNestedType(
11187 TypeAttributes
.Class
| TypeAttributes
.Public
,
11190 builder
.AddInterfaceImplementation (typeof (IFace16096
));
11192 var ctor
= builder
.DefineDefaultConstructor (MethodAttributes
.Public
);
11193 var field
= builder
.DefineField ("Field", typeof (object), FieldAttributes
.Public
);
11194 var g_args
= builder
.DefineGenericParameters("b","a");
11195 var method
= builder
.DefineMethod ("Bar", MethodAttributes
.Public
| MethodAttributes
.Virtual
, typeof (object), new Type
[0]);
11197 var il
= method
.GetILGenerator();
11198 il
.Emit (OpCodes
.Ldarg_0
);
11199 il
.Emit (OpCodes
.Ldfld
, TypeBuilder
.GetField (builder
.MakeGenericType (g_args
), field
));
11200 il
.Emit (OpCodes
.Pop
);
11201 il
.Emit (OpCodes
.Newobj
, TypeBuilder
.GetConstructor (builder
.MakeGenericType (g_args
), ctor
));
11202 il
.Emit (OpCodes
.Ret
);
11204 var type
= builder
.CreateType ();
11206 /*Build a gshared instance. */
11207 var ginst
= type
.MakeGenericType (typeof (List
<char>), typeof (object));
11208 var ins
= (IFace16096
)Activator
.CreateInstance (ginst
);
11210 /* This will trigger the runtime to cache the MEMBER_REF to the .ctor as it won't have a context. */
11211 var ins2
= ins
.Bar ();
11212 Assert
.IsNotNull (ins2
);
11214 /* Build an unsharable version. */
11215 var ginst2
= type
.MakeGenericType (typeof (List
<char>), typeof (char));
11216 var ins3
= (IFace16096
)Activator
.CreateInstance (ginst2
);
11218 /* This will trigger the runtime to use the cached version, which is wrong as it's an open type. */
11219 var ins4
= ins3
.Bar ();
11220 Assert
.IsNotNull (ins4
);
11224 public void CircularReferences () {
11226 var a_type
= module
.DefineType(
11228 TypeAttributes
.Class
,
11231 var cba
= a_type
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
11232 cba
.GetILGenerator ().Emit (OpCodes
.Ret
);
11234 var c_type
= module
.DefineType(
11236 TypeAttributes
.Class
,
11238 var cbb
= c_type
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
11239 cbb
.GetILGenerator ().Emit (OpCodes
.Ret
);
11240 c_type
.DefineGenericParameters ("d_a_param");
11242 var d_type
= module
.DefineType(
11244 TypeAttributes
.Class
,
11246 var cbd
= d_type
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
, Type
.EmptyTypes
);
11247 cbd
.GetILGenerator ().Emit (OpCodes
.Ret
);
11248 d_type
.DefineGenericParameters ("a_param");
11251 var d_instantiated
= c_type
.MakeGenericType (d_type
.MakeGenericType (a_type
));
11252 a_type
.SetParent (d_instantiated
);
11253 a_type
.CreateType ();
11255 Assert
.IsNotNull (a_type
);
11260 [ExpectedException (typeof (TypeLoadException
))]
11261 public void PrivateIface ()
11263 TypeBuilder tb
= module
.DefineType ("Sample", TypeAttributes
.Public
, typeof (object), new[] { typeof (IFoo) }
);
11271 public void GenericFieldInCreatedType () {
11273 * Regression test for #47867.
11274 * We construct the following, but only call CreateType on R.
11276 * public class S<T> {
11280 * public static S<R> sr;
11283 var aname
= new AssemblyName ("example1");
11284 var ab
= AppDomain
.CurrentDomain
.DefineDynamicAssembly (aname
, AssemblyBuilderAccess
.Run
);
11285 var mb
= ab
.DefineDynamicModule (aname
.Name
);
11286 var tbS
= mb
.DefineType ("S", TypeAttributes
.Public
);
11287 tbS
.DefineGenericParameters (new String
[] { "T" }
);
11288 var tbR
= mb
.DefineType ("R", TypeAttributes
.Public
);
11289 tbR
.DefineField ("sr", tbS
.MakeGenericType(new Type
[] { tbR }
), FieldAttributes
.Public
| FieldAttributes
.Static
);
11291 Type r
= tbR
.CreateType ();
11293 Assert
.IsNotNull (r
);
11297 public void GenericFieldInCreatedTypeIncompleteTypeTLE () {
11299 * Regression test for #47867.
11300 * We construct the following, but only call CreateType on R.
11301 * Then we try to use R.sr which is expected throw a
11302 * TLE because S hasn't been created yet.
11304 * public class S<T> {
11308 * public static S<R> sr;
11311 var aname
= new AssemblyName ("example1");
11312 var ab
= AppDomain
.CurrentDomain
.DefineDynamicAssembly (aname
, AssemblyBuilderAccess
.Run
);
11313 var mb
= ab
.DefineDynamicModule (aname
.Name
);
11314 var tbS
= mb
.DefineType ("S", TypeAttributes
.Public
);
11315 tbS
.DefineGenericParameters (new String
[] { "T" }
);
11316 var tbR
= mb
.DefineType ("R", TypeAttributes
.Public
);
11317 tbR
.DefineField ("sr", tbS
.MakeGenericType(new Type
[] { tbR }
), FieldAttributes
.Public
| FieldAttributes
.Static
);
11319 Type r
= tbR
.CreateType ();
11321 Assert
.IsNotNull (r
);
11323 // N.B. tbS has not had CreateType called yet, so expect this to fail.
11324 Assert
.Throws
<TypeLoadException
> (delegate { var ft = r.GetField("sr").FieldType; }
);
11328 public void GetGenericTypeDefinitionAfterCreateReturnsBuilder () {
11329 var aname
= new AssemblyName ("genericDefnAfterCreate");
11330 var ab
= AppDomain
.CurrentDomain
.DefineDynamicAssembly (aname
, AssemblyBuilderAccess
.Run
);
11331 var mb
= ab
.DefineDynamicModule (aname
.Name
);
11332 var buildX
= mb
.DefineType ("X", TypeAttributes
.Public
);
11333 buildX
.DefineGenericParameters ("T", "U");
11334 var x
= buildX
.CreateType ();
11335 var inst
= x
.MakeGenericType (typeof (string), typeof (int));
11336 var defX
= inst
.GetGenericTypeDefinition ();
11338 Assert
.AreSame (buildX
, defX
);
11342 public void FieldsWithSameName () {
11343 // Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=57222
11344 var typeBuilder
= module
.DefineType ("type1", TypeAttributes
.Public
| TypeAttributes
.Class
);
11346 var mainMethod
= typeBuilder
.DefineMethod ("Main", MethodAttributes
.Public
| MethodAttributes
.Static
, typeof (int), new Type
[0]);
11347 var mainMethodIl
= mainMethod
.GetILGenerator ();
11349 var f1
= typeBuilder
.DefineField ("x", typeof (byte), FieldAttributes
.Private
| FieldAttributes
.Static
);
11350 var f2
= typeBuilder
.DefineField ("x", typeof (sbyte), FieldAttributes
.Private
| FieldAttributes
.Static
);
11352 mainMethodIl
.Emit (OpCodes
.Ldsflda
, f1
);
11353 mainMethodIl
.Emit (OpCodes
.Ldsflda
, f2
);
11354 mainMethodIl
.Emit (OpCodes
.Pop
);
11355 mainMethodIl
.Emit (OpCodes
.Pop
);
11356 mainMethodIl
.Emit (OpCodes
.Ldc_I4_0
);
11357 mainMethodIl
.Emit (OpCodes
.Ret
);
11359 typeBuilder
.CreateType ();
11360 assembly
.SetEntryPoint (mainMethod
);
11362 assembly
.Save (ASSEMBLY_NAME
+ ".dll");
11365 public void FieldsWithSameNameAndType () {
11366 // https://bugzilla.xamarin.com/show_bug.cgi?id=57222
11367 var typeBuilder
= module
.DefineType ("type1", TypeAttributes
.Public
| TypeAttributes
.Class
);
11369 var mainMethod
= typeBuilder
.DefineMethod ("Main", MethodAttributes
.Public
| MethodAttributes
.Static
, typeof (int), new Type
[0]);
11370 var mainMethodIl
= mainMethod
.GetILGenerator ();
11372 var f1
= typeBuilder
.DefineField ("x", typeof (sbyte), FieldAttributes
.Private
| FieldAttributes
.Static
);
11373 var f2
= typeBuilder
.DefineField ("x", typeof (sbyte), FieldAttributes
.Private
| FieldAttributes
.Static
);
11375 mainMethodIl
.Emit (OpCodes
.Ldsflda
, f1
);
11376 mainMethodIl
.Emit (OpCodes
.Ldsflda
, f2
);
11377 mainMethodIl
.Emit (OpCodes
.Pop
);
11378 mainMethodIl
.Emit (OpCodes
.Pop
);
11379 mainMethodIl
.Emit (OpCodes
.Ldc_I4_0
);
11380 mainMethodIl
.Emit (OpCodes
.Ret
);
11382 typeBuilder
.CreateType ();
11383 assembly
.SetEntryPoint (mainMethod
);
11385 assembly
.Save (ASSEMBLY_NAME
+ ".dll");
11389 public void MethodsWithSameNameAndSig () {
11390 // https://bugzilla.xamarin.com/show_bug.cgi?id=57222
11391 var typeBuilder
= module
.DefineType ("type1", TypeAttributes
.Public
| TypeAttributes
.Class
);
11393 var mainMethod
= typeBuilder
.DefineMethod ("Main", MethodAttributes
.Public
| MethodAttributes
.Static
, typeof (int), new Type
[0]);
11394 var mainMethodIl
= mainMethod
.GetILGenerator ();
11396 var m1
= typeBuilder
.DefineMethod ("X", MethodAttributes
.Private
| MethodAttributes
.Static
, typeof (void), new Type
[0]);
11397 var m2
= typeBuilder
.DefineMethod ("X", MethodAttributes
.Private
| MethodAttributes
.Static
, typeof (void), new Type
[0]);
11398 m1
.GetILGenerator ().Emit (OpCodes
.Ret
);
11399 m2
.GetILGenerator ().Emit (OpCodes
.Ret
);
11401 mainMethodIl
.Emit (OpCodes
.Call
, m1
);
11402 mainMethodIl
.Emit (OpCodes
.Call
, m2
);
11403 mainMethodIl
.Emit (OpCodes
.Ldc_I4_0
);
11404 mainMethodIl
.Emit (OpCodes
.Ret
);
11406 typeBuilder
.CreateType ();
11407 assembly
.SetEntryPoint (mainMethod
);
11409 assembly
.Save (ASSEMBLY_NAME
+ ".dll");
11413 public void TwoAssembliesMidFlightTest () {
11414 // Check that one AssemblyBuilder can refer to a TypeBuilder from another AssemblyBuilder.
11415 // Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=58421
11416 var name2
= "MonoTests.System.Reflection.Emit.TypeBuilderTest2";
11417 var assemblyName2
= new AssemblyName (name2
);
11419 Thread
.GetDomain ().DefineDynamicAssembly (
11420 assemblyName2
, AssemblyBuilderAccess
.RunAndSave
, tempDir
);
11422 var module2
= assembly2
.DefineDynamicModule (name2
, name2
+ ".dll");
11424 var tb
= module
.DefineType ("Foo", TypeAttributes
.Public
);
11425 var tb2
= module2
.DefineType ("Foo2", TypeAttributes
.Public
);
11427 var cb
= tb
.DefineConstructor (MethodAttributes
.Public
, CallingConventions
.Standard
,
11430 var ilg
= cb
.GetILGenerator ();
11432 ilg
.Emit (OpCodes
.Ldtoken
, tb2
); // N.B. type from the other AssemblyBuilder
11433 ilg
.Emit (OpCodes
.Pop
);
11434 ilg
.Emit (OpCodes
.Ret
);
11436 var t
= tb
.CreateType ();
11439 var ci
= t
.GetConstructor (Type
.EmptyTypes
);
11440 var x
= ci
.Invoke (null);
11441 assembly
.Save (ASSEMBLY_NAME
+ ".dll");
11442 assembly2
.Save (name2
+ ".dll");