Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TypeBuilder.cs
Go to the documentation of this file.
6
8
9public sealed class TypeBuilder : TypeInfo
10{
11 private sealed class CustAttr
12 {
13 private readonly ConstructorInfo m_con;
14
15 private readonly byte[] m_binaryAttribute;
16
18
20 {
21 if ((object)con == null)
22 {
23 throw new ArgumentNullException("con");
24 }
25 if (binaryAttribute == null)
26 {
27 throw new ArgumentNullException("binaryAttribute");
28 }
29 m_con = con;
31 }
32
34 {
35 if (customBuilder == null)
36 {
37 throw new ArgumentNullException("customBuilder");
38 }
40 }
41
42 public void Bake(ModuleBuilder module, int token)
43 {
44 if (m_customBuilder == null)
45 {
46 DefineCustomAttribute(module, token, module.GetConstructorToken(m_con), m_binaryAttribute);
47 }
48 else
49 {
51 }
52 }
53 }
54
55 public const int UnspecifiedTypeSize = 0;
56
58
59 private int m_tdType;
60
61 private readonly ModuleBuilder m_module;
62
63 private readonly string m_strName;
64
65 private readonly string m_strNameSpace;
66
67 private string m_strFullQualName;
68
71
73
74 private readonly TypeAttributes m_iAttr;
75
77
79
81
82 private int m_constructorCount;
83
84 private readonly int m_iTypeSize;
85
86 private readonly PackingSize m_iPackingSize;
87
88 private readonly TypeBuilder m_DeclaringType;
89
91
92 internal bool m_isHiddenGlobalType;
93
94 private bool m_hasBeenCreated;
95
98
99 private readonly int m_genParamPos;
100
102
103 private readonly bool m_bIsGenParam;
104
105 private readonly MethodBuilder m_declMeth;
106
107 private readonly TypeBuilder m_genTypeDef;
108
109 internal object SyncRoot => m_module.SyncRoot;
110
112
113 public override Type? DeclaringType => m_DeclaringType;
114
115 public override Type? ReflectedType => m_DeclaringType;
116
117 public override string Name => m_strName;
118
119 public override Module Module => GetModuleBuilder();
120
121 public override bool IsByRefLike => false;
122
123 public override int MetadataToken => m_tdType;
124
125 public override Guid GUID
126 {
127 get
128 {
129 if (!IsCreated())
130 {
132 }
134 }
135 }
136
137 public override Assembly Assembly => m_module.Assembly;
138
140 {
141 get
142 {
144 }
145 }
146
148
149 public override string? Namespace => m_strNameSpace;
150
151 public override string? AssemblyQualifiedName => TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName);
152
153 public override Type? BaseType => m_typeParent;
154
155 public override bool IsTypeDefinition => true;
156
157 public override bool IsSZArray => false;
158
159 public override bool IsSecurityCritical => true;
160
161 public override bool IsSecuritySafeCritical => false;
162
163 public override bool IsSecurityTransparent => false;
164
166 {
167 get
168 {
169 if (m_bakedRuntimeType != null)
170 {
171 return m_bakedRuntimeType;
172 }
173 if (IsEnum)
174 {
175 if (m_enumUnderlyingType == null)
176 {
178 }
180 }
181 return this;
182 }
183 }
184
186
187 public override bool IsGenericTypeDefinition => IsGenericType;
188
189 public override bool IsGenericType => m_inst != null;
190
191 public override bool IsGenericParameter => m_bIsGenParam;
192
193 public override bool IsConstructedGenericType => false;
194
196
198
199 public int Size => m_iTypeSize;
200
202
203 internal int TypeToken
204 {
205 get
206 {
208 {
210 }
211 return m_tdType;
212 }
213 }
214
215 public override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo? typeInfo)
216 {
217 if (typeInfo == null)
218 {
219 return false;
220 }
221 return IsAssignableFrom(typeInfo.AsType());
222 }
223
224 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern", Justification = "MakeGenericType is only called on a TypeBuilder which is not subject to trimming")]
226 {
228 {
230 }
231 if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
232 {
234 }
235 if (method.DeclaringType == null || !method.DeclaringType.IsGenericTypeDefinition)
236 {
238 }
239 if (type.GetGenericTypeDefinition() != method.DeclaringType)
240 {
242 }
243 if (type.IsGenericTypeDefinition)
244 {
245 type = type.MakeGenericType(type.GetGenericArguments());
246 }
248 {
250 }
252 }
253
254 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern", Justification = "MakeGenericType is only called on a TypeBuilder which is not subject to trimming")]
256 {
258 {
260 }
261 if (!constructor.DeclaringType.IsGenericTypeDefinition)
262 {
264 }
266 {
268 }
270 {
271 type = type.MakeGenericType(type.GetGenericArguments());
272 }
273 if (type.GetGenericTypeDefinition() != constructor.DeclaringType)
274 {
276 }
278 }
279
280 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern", Justification = "MakeGenericType is only called on a TypeBuilder which is not subject to trimming")]
282 {
284 {
286 }
287 if (!field.DeclaringType.IsGenericTypeDefinition)
288 {
290 }
292 {
294 }
296 {
297 type = type.MakeGenericType(type.GetGenericArguments());
298 }
299 if (type.GetGenericTypeDefinition() != field.DeclaringType)
300 {
302 }
304 }
305
306 [DllImport("QCall", CharSet = CharSet.Unicode)]
307 private static extern void SetParentType(QCallModule module, int tdTypeDef, int tkParent);
308
309 [DllImport("QCall", CharSet = CharSet.Unicode)]
310 private static extern void AddInterfaceImpl(QCallModule module, int tdTypeDef, int tkInterface);
311
312 [DllImport("QCall", CharSet = CharSet.Unicode)]
313 internal static extern int DefineMethod(QCallModule module, int tkParent, string name, byte[] signature, int sigLength, MethodAttributes attributes);
314
315 [DllImport("QCall", CharSet = CharSet.Unicode)]
316 internal static extern int DefineMethodSpec(QCallModule module, int tkParent, byte[] signature, int sigLength);
317
318 [DllImport("QCall", CharSet = CharSet.Unicode)]
319 internal static extern int DefineField(QCallModule module, int tkParent, string name, byte[] signature, int sigLength, FieldAttributes attributes);
320
321 [DllImport("QCall", CharSet = CharSet.Unicode)]
322 private static extern void SetMethodIL(QCallModule module, int tk, bool isInitLocals, byte[] body, int bodyLength, byte[] LocalSig, int sigLength, int maxStackSize, ExceptionHandler[] exceptions, int numExceptions, int[] tokenFixups, int numTokenFixups);
323
324 [DllImport("QCall", CharSet = CharSet.Unicode)]
325 private static extern void DefineCustomAttribute(QCallModule module, int tkAssociate, int tkConstructor, byte[] attr, int attrLength);
326
328 {
329 byte[] array = null;
330 if (attr != null)
331 {
332 array = new byte[attr.Length];
333 Buffer.BlockCopy(attr, 0, array, 0, attr.Length);
334 }
336 }
337
338 [DllImport("QCall", CharSet = CharSet.Unicode)]
339 internal static extern int DefineProperty(QCallModule module, int tkParent, string name, PropertyAttributes attributes, byte[] signature, int sigLength);
340
341 [DllImport("QCall", CharSet = CharSet.Unicode)]
342 internal static extern int DefineEvent(QCallModule module, int tkParent, string name, EventAttributes attributes, int tkEventType);
343
344 [DllImport("QCall", CharSet = CharSet.Unicode)]
346
347 [DllImport("QCall", CharSet = CharSet.Unicode)]
348 internal static extern void DefineMethodImpl(QCallModule module, int tkType, int tkBody, int tkDecl);
349
350 [DllImport("QCall", CharSet = CharSet.Unicode)]
352
353 [DllImport("QCall", CharSet = CharSet.Unicode)]
355
356 [DllImport("QCall", CharSet = CharSet.Unicode)]
357 internal static extern int GetTokenFromSig(QCallModule module, byte[] signature, int sigLength);
358
359 [DllImport("QCall", CharSet = CharSet.Unicode)]
360 internal static extern void SetFieldLayoutOffset(QCallModule module, int fdToken, int iOffset);
361
362 [DllImport("QCall", CharSet = CharSet.Unicode)]
363 internal static extern void SetClassLayout(QCallModule module, int tk, PackingSize iPackingSize, int iTypeSize);
364
365 [DllImport("QCall", CharSet = CharSet.Unicode)]
366 private unsafe static extern void SetConstantValue(QCallModule module, int tk, int corType, void* pValue);
367
368 [DllImport("QCall", CharSet = CharSet.Unicode)]
369 private static extern void SetPInvokeData(QCallModule module, string DllName, string name, int token, int linkFlags);
370
371 internal static bool IsTypeEqual(Type t1, Type t2)
372 {
373 if (t1 == t2)
374 {
375 return true;
376 }
377 TypeBuilder typeBuilder = null;
379 Type type;
380 if (t1 is TypeBuilder)
381 {
382 typeBuilder = (TypeBuilder)t1;
383 type = typeBuilder.m_bakedRuntimeType;
384 }
385 else
386 {
387 type = t1;
388 }
389 Type type2;
390 if (t2 is TypeBuilder)
391 {
393 type2 = typeBuilder2.m_bakedRuntimeType;
394 }
395 else
396 {
397 type2 = t2;
398 }
399 if (typeBuilder != null && typeBuilder2 != null && (object)typeBuilder == typeBuilder2)
400 {
401 return true;
402 }
403 if (type != null && type2 != null && type == type2)
404 {
405 return true;
406 }
407 return false;
408 }
409
410 internal unsafe static void SetConstantValue(ModuleBuilder module, int tk, Type destType, object value)
411 {
412 if (value != null)
413 {
415 if (destType.IsByRef)
416 {
417 destType = destType.GetElementType();
418 }
420 if (destType.IsEnum)
421 {
422 Type type2;
424 {
425 type2 = enumBuilder.GetEnumUnderlyingType();
426 if (type != enumBuilder.m_typeBuilder.m_bakedRuntimeType && type != type2)
427 {
429 }
430 }
431 else if (destType is TypeBuilder typeBuilder)
432 {
433 type2 = typeBuilder.m_enumUnderlyingType;
434 if (type2 == null || (type != typeBuilder.UnderlyingSystemType && type != type2))
435 {
437 }
438 }
439 else
440 {
442 if (type != destType && type != type2)
443 {
445 }
446 }
447 type = type2;
448 }
449 else if (!destType.IsAssignableFrom(type))
450 {
452 }
454 if (corElementType - 2 <= CorElementType.ELEMENT_TYPE_U8)
455 {
456 fixed (byte* pValue = &value.GetRawData())
457 {
459 }
460 return;
461 }
462 if (type == typeof(string))
463 {
464 fixed (char* pValue2 = (string)value)
465 {
467 }
468 return;
469 }
470 if (!(type == typeof(DateTime)))
471 {
473 }
474 long ticks = ((DateTime)value).Ticks;
475 SetConstantValue(new QCallModule(ref module), tk, 10, &ticks);
476 }
477 else
478 {
479 SetConstantValue(new QCallModule(ref module), tk, 18, null);
480 }
481 }
482
484 {
485 m_tdType = 33554432;
490 }
491
493 {
496 m_bIsGenParam = true;
500 m_module = declMeth.GetModuleBuilder();
501 }
502
504 {
507 m_bIsGenParam = true;
510 m_module = declType.GetModuleBuilder();
511 }
512
514 {
515 if (fullname == null)
516 {
517 throw new ArgumentNullException("fullname");
518 }
519 if (fullname.Length == 0)
520 {
521 throw new ArgumentException(SR.Argument_EmptyName, "fullname");
522 }
523 if (fullname[0] == '\0')
524 {
525 throw new ArgumentException(SR.Argument_IllegalName, "fullname");
526 }
527 if (fullname.Length > 1023)
528 {
529 throw new ArgumentException(SR.Argument_TypeNameTooLong, "fullname");
530 }
534 containingAssemblyBuilder._assemblyData.CheckTypeNameConflict(fullname, enclosingType);
535 if (enclosingType != null && ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public || (attr & TypeAttributes.VisibilityMask) == 0))
536 {
538 }
539 int[] array = null;
540 if (interfaces != null)
541 {
542 for (int i = 0; i < interfaces.Length; i++)
543 {
544 if (interfaces[i] == null)
545 {
546 throw new ArgumentNullException("interfaces");
547 }
548 }
549 array = new int[interfaces.Length + 1];
550 for (int i = 0; i < interfaces.Length; i++)
551 {
552 array[i] = m_module.GetTypeTokenInternal(interfaces[i]);
553 }
554 }
555 int num = fullname.LastIndexOf('.');
556 if (num == -1 || num == 0)
557 {
558 m_strNameSpace = string.Empty;
560 }
561 else
562 {
563 m_strNameSpace = fullname.Substring(0, num);
564 m_strName = fullname.Substring(num + 1);
565 }
567 m_iAttr = attr;
568 SetParent(parent);
571 SetInterfaces(interfaces);
572 int tkParent = 0;
573 if (m_typeParent != null)
574 {
576 }
577 int tkEnclosingType = 0;
578 if (enclosingType != null)
579 {
581 }
585 if (m_iPackingSize != 0 || m_iTypeSize != 0)
586 {
588 }
590 }
591
592 private FieldBuilder DefineDataHelper(string name, byte[] data, int size, FieldAttributes attributes)
593 {
594 if (name == null)
595 {
596 throw new ArgumentNullException("name");
597 }
598 if (name.Length == 0)
599 {
600 throw new ArgumentException(SR.Argument_EmptyName, "name");
601 }
602 if (size <= 0 || size >= 4128768)
603 {
605 }
607 string text = "$ArrayType$" + size;
609 TypeBuilder typeBuilder = type as TypeBuilder;
610 if (typeBuilder == null)
611 {
612 TypeAttributes attr = TypeAttributes.Public | TypeAttributes.ExplicitLayout | TypeAttributes.Sealed;
613 typeBuilder = m_module.DefineType(text, attr, typeof(ValueType), PackingSize.Size1, size);
614 typeBuilder.CreateType();
615 }
616 FieldBuilder fieldBuilder = DefineField(name, typeBuilder, attributes | FieldAttributes.Static);
617 fieldBuilder.SetData(data, size);
618 return fieldBuilder;
619 }
620
622 {
623 if (DeclaringType == null)
624 {
625 if ((attr & TypeAttributes.VisibilityMask) != 0 && (attr & TypeAttributes.VisibilityMask) != TypeAttributes.Public)
626 {
628 }
629 }
630 else if ((attr & TypeAttributes.VisibilityMask) == 0 || (attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public)
631 {
633 }
634 if ((attr & TypeAttributes.LayoutMask) != 0 && (attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout && (attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout)
635 {
637 }
638 if ((attr & TypeAttributes.ReservedMask) != 0)
639 {
641 }
642 }
643
644 public bool IsCreated()
645 {
646 return m_hasBeenCreated;
647 }
648
649 [DllImport("QCall", CharSet = CharSet.Unicode)]
650 private static extern int DefineType(QCallModule module, string fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens);
651
652 [DllImport("QCall", CharSet = CharSet.Unicode)]
653 private static extern int DefineGenericParam(QCallModule module, string name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints);
654
655 [DllImport("QCall", CharSet = CharSet.Unicode)]
656 private static extern void TermCreateClass(QCallModule module, int tk, ObjectHandleOnStack type);
657
658 internal void ThrowIfCreated()
659 {
660 if (IsCreated())
661 {
663 }
664 }
665
667 {
668 return m_module;
669 }
670
675
684
693
695 {
696 if (m_ca == null)
697 {
698 m_ca = new List<CustAttr>();
699 }
700 m_ca.Add(ca);
701 }
702
703 public override string ToString()
704 {
705 return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
706 }
707
709 public override object? InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object?[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters)
710 {
711 if (!IsCreated())
712 {
714 }
716 }
717
727
737
751
761
763 public override FieldInfo? GetField(string name, BindingFlags bindingAttr)
764 {
765 if (!IsCreated())
766 {
768 }
770 }
771
781
784 public override Type? GetInterface(string name, bool ignoreCase)
785 {
786 if (!IsCreated())
787 {
789 }
791 }
792
794 public override Type[] GetInterfaces()
795 {
796 if (m_bakedRuntimeType != null)
797 {
799 }
800 if (m_typeInterfaces == null)
801 {
802 return Type.EmptyTypes;
803 }
804 return m_typeInterfaces.ToArray();
805 }
806
808 public override EventInfo? GetEvent(string name, BindingFlags bindingAttr)
809 {
810 if (!IsCreated())
811 {
813 }
815 }
816
818 public override EventInfo[] GetEvents()
819 {
820 if (!IsCreated())
821 {
823 }
825 }
826
832
842
852
854 public override Type? GetNestedType(string name, BindingFlags bindingAttr)
855 {
856 if (!IsCreated())
857 {
859 }
861 }
862
865 {
866 if (!IsCreated())
867 {
869 }
871 }
872
881
891
901
902 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "The GetInterfaces technically requires all interfaces to be preservedBut in this case it acts only on TypeBuilder which is never trimmed (as it's runtime created).")]
903 public override bool IsAssignableFrom([NotNullWhen(true)] Type? c)
904 {
905 if (IsTypeEqual(c, this))
906 {
907 return true;
908 }
909 TypeBuilder typeBuilder = c as TypeBuilder;
910 Type type = ((!(typeBuilder != null)) ? c : typeBuilder.m_bakedRuntimeType);
911 if (type != null && type is RuntimeType)
912 {
913 if (m_bakedRuntimeType == null)
914 {
915 return false;
916 }
918 }
919 if (typeBuilder == null)
920 {
921 return false;
922 }
923 if (typeBuilder.IsSubclassOf(this))
924 {
925 return true;
926 }
927 if (!base.IsInterface)
928 {
929 return false;
930 }
931 Type[] interfaces = typeBuilder.GetInterfaces();
932 for (int i = 0; i < interfaces.Length; i++)
933 {
934 if (IsTypeEqual(interfaces[i], this))
935 {
936 return true;
937 }
938 if (interfaces[i].IsSubclassOf(this))
939 {
940 return true;
941 }
942 }
943 return false;
944 }
945
947 {
948 return m_iAttr;
949 }
950
951 protected override bool IsArrayImpl()
952 {
953 return false;
954 }
955
956 protected override bool IsByRefImpl()
957 {
958 return false;
959 }
960
961 protected override bool IsPointerImpl()
962 {
963 return false;
964 }
965
966 protected override bool IsPrimitiveImpl()
967 {
968 return false;
969 }
970
971 protected override bool IsCOMObjectImpl()
972 {
973 if ((GetAttributeFlagsImpl() & TypeAttributes.Import) == 0)
974 {
975 return false;
976 }
977 return true;
978 }
979
980 public override Type GetElementType()
981 {
983 }
984
985 protected override bool HasElementTypeImpl()
986 {
987 return false;
988 }
989
990 public override bool IsSubclassOf(Type c)
991 {
992 Type type = this;
993 if (IsTypeEqual(type, c))
994 {
995 return false;
996 }
998 while (type != null)
999 {
1000 if (IsTypeEqual(type, c))
1001 {
1002 return true;
1003 }
1004 type = type.BaseType;
1005 }
1006 return false;
1007 }
1008
1009 public override Type MakePointerType()
1010 {
1011 return SymbolType.FormCompoundType("*", this, 0);
1012 }
1013
1014 public override Type MakeByRefType()
1015 {
1016 return SymbolType.FormCompoundType("&", this, 0);
1017 }
1018
1019 public override Type MakeArrayType()
1020 {
1021 return SymbolType.FormCompoundType("[]", this, 0);
1022 }
1023
1024 public override Type MakeArrayType(int rank)
1025 {
1027 return SymbolType.FormCompoundType(rankString, this, 0);
1028 }
1029
1030 public override object[] GetCustomAttributes(bool inherit)
1031 {
1032 if (!IsCreated())
1033 {
1035 }
1037 }
1038
1039 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
1040 {
1041 if (!IsCreated())
1042 {
1044 }
1045 if (attributeType == null)
1046 {
1047 throw new ArgumentNullException("attributeType");
1048 }
1049 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
1050 if (runtimeType == null)
1051 {
1052 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
1053 }
1055 }
1056
1057 public override bool IsDefined(Type attributeType, bool inherit)
1058 {
1059 if (!IsCreated())
1060 {
1062 }
1063 if (attributeType == null)
1064 {
1065 throw new ArgumentNullException("attributeType");
1066 }
1067 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
1068 if (runtimeType == null)
1069 {
1070 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
1071 }
1073 }
1074
1075 internal void SetInterfaces(params Type[] interfaces)
1076 {
1079 if (interfaces != null)
1080 {
1081 m_typeInterfaces.AddRange(interfaces);
1082 }
1083 }
1084
1086 {
1087 if (names == null)
1088 {
1089 throw new ArgumentNullException("names");
1090 }
1091 if (names.Length == 0)
1092 {
1093 throw new ArgumentException(SR.Arg_EmptyArray, "names");
1094 }
1095 for (int i = 0; i < names.Length; i++)
1096 {
1097 if (names[i] == null)
1098 {
1099 throw new ArgumentNullException("names");
1100 }
1101 }
1102 if (m_inst != null)
1103 {
1104 throw new InvalidOperationException();
1105 }
1107 for (int j = 0; j < names.Length; j++)
1108 {
1110 }
1111 return m_inst;
1112 }
1113
1114 [RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")]
1120
1121 public override Type[] GetGenericArguments()
1122 {
1123 Type[] inst = m_inst;
1124 return inst ?? Type.EmptyTypes;
1125 }
1126
1128 {
1130 {
1131 return this;
1132 }
1133 if (m_genTypeDef == null)
1134 {
1135 throw new InvalidOperationException();
1136 }
1137 return m_genTypeDef;
1138 }
1139
1147
1149 {
1150 if (methodInfoBody == null)
1151 {
1152 throw new ArgumentNullException("methodInfoBody");
1153 }
1154 if (methodInfoDeclaration == null)
1155 {
1156 throw new ArgumentNullException("methodInfoDeclaration");
1157 }
1159 if ((object)methodInfoBody.DeclaringType != this)
1160 {
1162 }
1167 }
1168
1170 {
1171 return DefineMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes);
1172 }
1173
1174 public MethodBuilder DefineMethod(string name, MethodAttributes attributes)
1175 {
1176 return DefineMethod(name, attributes, CallingConventions.Standard, null, null);
1177 }
1178
1180 {
1181 return DefineMethod(name, attributes, callingConvention, null, null);
1182 }
1183
1185 {
1186 return DefineMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
1187 }
1188
1196
1197 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2082:UnrecognizedReflectionPattern", Justification = "Reflection.Emit is not subject to trimming")]
1199 {
1200 if (name == null)
1201 {
1202 throw new ArgumentNullException("name");
1203 }
1204 if (name.Length == 0)
1205 {
1206 throw new ArgumentException(SR.Argument_EmptyName, "name");
1207 }
1212 if (parameterTypes != null)
1213 {
1215 {
1216 throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, "parameterTypeOptionalCustomModifiers", "parameterTypes"));
1217 }
1219 {
1220 throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, "parameterTypeRequiredCustomModifiers", "parameterTypes"));
1221 }
1222 }
1225 if (!m_isHiddenGlobalType && (methodBuilder.Attributes & MethodAttributes.SpecialName) != 0 && methodBuilder.Name.Equals(ConstructorInfo.ConstructorName))
1226 {
1228 }
1230 return methodBuilder;
1231 }
1232
1233 [RequiresUnreferencedCode("P/Invoke marshalling may dynamically access members that could be trimmed.")]
1238
1239 [RequiresUnreferencedCode("P/Invoke marshalling may dynamically access members that could be trimmed.")]
1244
1245 [RequiresUnreferencedCode("P/Invoke marshalling may dynamically access members that could be trimmed.")]
1250
1251 [RequiresUnreferencedCode("P/Invoke marshalling may dynamically access members that could be trimmed.")]
1253 {
1258 lock (SyncRoot)
1259 {
1260 if (name == null)
1261 {
1262 throw new ArgumentNullException("name");
1263 }
1264 if (name.Length == 0)
1265 {
1266 throw new ArgumentException(SR.Argument_EmptyName, "name");
1267 }
1268 if (dllName == null)
1269 {
1270 throw new ArgumentNullException("dllName");
1271 }
1272 if (dllName.Length == 0)
1273 {
1274 throw new ArgumentException(SR.Argument_EmptyName, "dllName");
1275 }
1276 if (importName == null)
1277 {
1278 throw new ArgumentNullException("importName");
1279 }
1280 if (importName.Length == 0)
1281 {
1282 throw new ArgumentException(SR.Argument_EmptyName, "importName");
1283 }
1284 if ((attributes & MethodAttributes.Abstract) != 0)
1285 {
1287 }
1288 if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.ClassSemanticsMask)
1289 {
1291 }
1293 attributes |= MethodAttributes.PinvokeImpl;
1295 methodBuilder.GetMethodSignature().InternalGetSignature(out var _);
1297 {
1299 }
1301 int metadataToken = methodBuilder.MetadataToken;
1302 int num = 0;
1303 switch (nativeCallConv)
1304 {
1305 case CallingConvention.Winapi:
1306 num = 256;
1307 break;
1308 case CallingConvention.Cdecl:
1309 num = 512;
1310 break;
1311 case CallingConvention.StdCall:
1312 num = 768;
1313 break;
1314 case CallingConvention.ThisCall:
1315 num = 1024;
1316 break;
1317 case CallingConvention.FastCall:
1318 num = 1280;
1319 break;
1320 }
1321 switch (nativeCharSet)
1322 {
1323 case CharSet.None:
1324 num |= 0;
1325 break;
1326 case CharSet.Ansi:
1327 num |= 2;
1328 break;
1329 case CharSet.Unicode:
1330 num |= 4;
1331 break;
1332 case CharSet.Auto:
1333 num |= 6;
1334 break;
1335 }
1338 methodBuilder.SetToken(metadataToken);
1339 return methodBuilder;
1340 }
1341 }
1342
1344 {
1345 lock (SyncRoot)
1346 {
1348 }
1349 }
1350
1351 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2082:UnrecognizedReflectionPattern", Justification = "Reflection.Emit is not subject to trimming")]
1357
1359 {
1360 if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.ClassSemanticsMask)
1361 {
1363 }
1364 lock (SyncRoot)
1365 {
1366 return DefineDefaultConstructorNoLock(attributes);
1367 }
1368 }
1369
1370 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern", Justification = "MakeGenericType is only called on a TypeBuilderInstantiation which is not subject to trimming")]
1371 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", Justification = "GetConstructor is only called on a TypeBuilderInstantiation which is not subject to trimming")]
1373 {
1376 {
1378 if (type is TypeBuilder)
1379 {
1380 type = ((TypeBuilder)type).m_bakedRuntimeType;
1381 }
1382 if (type == null)
1383 {
1385 }
1386 Type type2 = type.MakeGenericType(m_typeParent.GetGenericArguments());
1387 constructorInfo = ((!(type2 is TypeBuilderInstantiation)) ? type2.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null) : GetConstructor(type2, type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)));
1388 }
1389 if (constructorInfo == null)
1390 {
1392 }
1393 if (constructorInfo == null)
1394 {
1396 }
1399 ILGenerator iLGenerator = constructorBuilder.GetILGenerator();
1402 iLGenerator.Emit(OpCodes.Ret);
1403 constructorBuilder.m_isDefaultConstructor = true;
1404 return constructorBuilder;
1405 }
1406
1411
1423
1424 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2082:UnrecognizedReflectionPattern", Justification = "Reflection.Emit is not subject to trimming")]
1437
1438 public TypeBuilder DefineNestedType(string name)
1439 {
1440 lock (SyncRoot)
1441 {
1442 return DefineNestedTypeNoLock(name, TypeAttributes.NestedPrivate, null, null, PackingSize.Unspecified, 0);
1443 }
1444 }
1445
1447 {
1448 lock (SyncRoot)
1449 {
1451 AssemblyBuilder.CheckContext(interfaces);
1452 return DefineNestedTypeNoLock(name, attr, parent, interfaces, PackingSize.Unspecified, 0);
1453 }
1454 }
1455
1457 {
1458 lock (SyncRoot)
1459 {
1460 return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, 0);
1461 }
1462 }
1463
1465 {
1466 lock (SyncRoot)
1467 {
1468 return DefineNestedTypeNoLock(name, attr, null, null, PackingSize.Unspecified, 0);
1469 }
1470 }
1471
1473 {
1474 lock (SyncRoot)
1475 {
1476 return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, typeSize);
1477 }
1478 }
1479
1481 {
1482 lock (SyncRoot)
1483 {
1484 return DefineNestedTypeNoLock(name, attr, parent, null, packSize, 0);
1485 }
1486 }
1487
1489 {
1490 lock (SyncRoot)
1491 {
1492 return DefineNestedTypeNoLock(name, attr, parent, null, packSize, typeSize);
1493 }
1494 }
1495
1497 {
1498 return new TypeBuilder(name, attr, parent, interfaces, m_module, packSize, typeSize, this);
1499 }
1500
1502 {
1503 return DefineField(fieldName, type, null, null, attributes);
1504 }
1505
1513
1525
1526 public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes)
1527 {
1528 lock (SyncRoot)
1529 {
1530 return DefineInitializedDataNoLock(name, data, attributes);
1531 }
1532 }
1533
1534 private FieldBuilder DefineInitializedDataNoLock(string name, byte[] data, FieldAttributes attributes)
1535 {
1536 if (data == null)
1537 {
1538 throw new ArgumentNullException("data");
1539 }
1540 return DefineDataHelper(name, data, data.Length, attributes);
1541 }
1542
1543 public FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes)
1544 {
1545 lock (SyncRoot)
1546 {
1547 return DefineUninitializedDataNoLock(name, size, attributes);
1548 }
1549 }
1550
1551 private FieldBuilder DefineUninitializedDataNoLock(string name, int size, FieldAttributes attributes)
1552 {
1553 return DefineDataHelper(name, null, size, attributes);
1554 }
1555
1557 {
1558 return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null);
1559 }
1560
1562 {
1563 return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
1564 }
1565
1570
1578
1580 {
1581 if (name == null)
1582 {
1583 throw new ArgumentNullException("name");
1584 }
1585 if (name.Length == 0)
1586 {
1587 throw new ArgumentException(SR.Argument_EmptyName, "name");
1588 }
1595 int length;
1596 byte[] signature = propertySigHelper.InternalGetSignature(out length);
1598 int prToken = DefineProperty(new QCallModule(ref module), m_tdType, name, attributes, signature, length);
1599 return new PropertyBuilder(m_module, name, propertySigHelper, attributes, returnType, prToken, this);
1600 }
1601
1602 public EventBuilder DefineEvent(string name, EventAttributes attributes, Type eventtype)
1603 {
1604 lock (SyncRoot)
1605 {
1606 return DefineEventNoLock(name, attributes, eventtype);
1607 }
1608 }
1609
1611 {
1612 if (name == null)
1613 {
1614 throw new ArgumentNullException("name");
1615 }
1616 if (name.Length == 0)
1617 {
1618 throw new ArgumentException(SR.Argument_EmptyName, "name");
1619 }
1620 if (name[0] == '\0')
1621 {
1622 throw new ArgumentException(SR.Argument_IllegalName, "name");
1623 }
1628 int evToken = DefineEvent(new QCallModule(ref module), m_tdType, name, attributes, typeTokenInternal);
1629 return new EventBuilder(m_module, name, attributes, this, evToken);
1630 }
1631
1634 {
1635 lock (SyncRoot)
1636 {
1637 return CreateTypeNoLock();
1638 }
1639 }
1640
1643 {
1644 lock (SyncRoot)
1645 {
1646 return CreateTypeNoLock();
1647 }
1648 }
1649
1650 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2083:UnrecognizedReflectionPattern", Justification = "Reflection.Emit is not subject to trimming")]
1653 {
1654 if (IsCreated())
1655 {
1656 return m_bakedRuntimeType;
1657 }
1658 if (m_typeInterfaces == null)
1659 {
1661 }
1662 int[] array = new int[m_typeInterfaces.Count];
1663 for (int i = 0; i < m_typeInterfaces.Count; i++)
1664 {
1666 }
1667 int num = 0;
1668 if (m_typeParent != null)
1669 {
1671 }
1674 {
1675 int[] array2;
1676 if (m_typeParent != null)
1677 {
1678 array2 = new int[m_typeInterfaces.Count + 2];
1679 array2[^2] = num;
1680 }
1681 else
1682 {
1683 array2 = new int[m_typeInterfaces.Count + 1];
1684 }
1685 for (int j = 0; j < m_typeInterfaces.Count; j++)
1686 {
1688 }
1691 if (m_ca != null)
1692 {
1693 foreach (CustAttr item in m_ca)
1694 {
1696 }
1697 }
1698 m_hasBeenCreated = true;
1699 return this;
1700 }
1701 if (((uint)m_tdType & 0xFFFFFFu) != 0 && ((uint)num & 0xFFFFFFu) != 0)
1702 {
1704 }
1705 if (m_inst != null)
1706 {
1709 {
1710 genericTypeParameterBuilder.m_type.CreateType();
1711 }
1712 }
1713 if (!m_isHiddenGlobalType && m_constructorCount == 0 && (m_iAttr & TypeAttributes.ClassSemanticsMask) == 0 && !base.IsValueType && (m_iAttr & (TypeAttributes.Abstract | TypeAttributes.Sealed)) != (TypeAttributes.Abstract | TypeAttributes.Sealed))
1714 {
1716 }
1718 for (int l = 0; l < count; l++)
1719 {
1721 if (methodBuilder.IsGenericMethodDefinition)
1722 {
1723 int metadataToken = methodBuilder.MetadataToken;
1724 }
1725 MethodAttributes attributes = methodBuilder.Attributes;
1726 if ((methodBuilder.GetMethodImplementationFlags() & (MethodImplAttributes)135) != 0 || (attributes & MethodAttributes.PinvokeImpl) != 0)
1727 {
1728 continue;
1729 }
1730 int signatureLength;
1731 byte[] localSignature = methodBuilder.GetLocalSignature(out signatureLength);
1732 if ((attributes & MethodAttributes.Abstract) != 0 && (m_iAttr & TypeAttributes.Abstract) == 0)
1733 {
1735 }
1736 byte[] body = methodBuilder.GetBody();
1737 if ((attributes & MethodAttributes.Abstract) != 0)
1738 {
1739 if (body != null)
1740 {
1742 }
1743 }
1744 else if (body == null || body.Length == 0)
1745 {
1746 if (methodBuilder.m_ilGenerator != null)
1747 {
1748 methodBuilder.CreateMethodBodyHelper(methodBuilder.GetILGenerator());
1749 }
1750 body = methodBuilder.GetBody();
1751 if ((body == null || body.Length == 0) && !methodBuilder.m_canBeRuntimeImpl)
1752 {
1754 }
1755 }
1756 int maxStack = methodBuilder.GetMaxStack();
1757 ExceptionHandler[] exceptionHandlers = methodBuilder.GetExceptionHandlers();
1758 int[] tokenFixups = methodBuilder.GetTokenFixups();
1759 SetMethodIL(new QCallModule(ref module), methodBuilder.MetadataToken, methodBuilder.InitLocals, body, (body != null) ? body.Length : 0, localSignature, signatureLength, maxStack, exceptionHandlers, (exceptionHandlers != null) ? exceptionHandlers.Length : 0, tokenFixups, (tokenFixups != null) ? tokenFixups.Length : 0);
1761 {
1762 methodBuilder.ReleaseBakedStructures();
1763 }
1764 }
1765 m_hasBeenCreated = true;
1766 RuntimeType o = null;
1769 {
1771 if (m_DeclaringType != null && m_DeclaringType.m_bakedRuntimeType != null)
1772 {
1774 }
1775 return o;
1776 }
1777 return null;
1778 }
1779
1781 {
1783 if (parent != null)
1784 {
1786 if (parent.IsInterface)
1787 {
1789 }
1790 m_typeParent = parent;
1791 }
1792 else if ((m_iAttr & TypeAttributes.ClassSemanticsMask) != TypeAttributes.ClassSemanticsMask)
1793 {
1794 m_typeParent = typeof(object);
1795 }
1796 else
1797 {
1798 if ((m_iAttr & TypeAttributes.Abstract) == 0)
1799 {
1801 }
1802 m_typeParent = null;
1803 }
1804 }
1805
1819
1821 {
1822 if (con == null)
1823 {
1824 throw new ArgumentNullException("con");
1825 }
1826 if (binaryAttribute == null)
1827 {
1828 throw new ArgumentNullException("binaryAttribute");
1829 }
1831 }
1832
1834 {
1835 if (customBuilder == null)
1836 {
1837 throw new ArgumentNullException("customBuilder");
1838 }
1839 customBuilder.CreateCustomAttribute(m_module, m_tdType);
1840 }
1841}
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Definition Buffer.cs:102
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
void Add(TKey key, TValue value)
static Type GetUnderlyingType(Type enumType)
Definition Enum.cs:309
static readonly string TypeConstructorName
static readonly string ConstructorName
static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
static void CheckContext(params Type[][] typess)
static ConstructorInfo GetConstructor(ConstructorInfo Constructor, TypeBuilderInstantiation type)
void CreateCustomAttribute(ModuleBuilder mod, int tkOwner)
static FieldInfo GetField(FieldInfo Field, TypeBuilderInstantiation type)
static MethodInfo GetMethod(MethodInfo method, TypeBuilderInstantiation type)
int GetConstructorToken(ConstructorInfo con)
TypeBuilder DefineType(string name)
void AddType(string name, Type type)
int GetMethodToken(MethodInfo method)
virtual Type FindTypeBuilderWithName(string strTypeName, bool ignoreCase)
static readonly OpCode Call
Definition OpCodes.cs:83
static readonly OpCode Ret
Definition OpCodes.cs:87
static readonly OpCode Ldarg_0
Definition OpCodes.cs:9
static SignatureHelper GetPropertySigHelper(Module? mod, Type? returnType, Type[]? parameterTypes)
static Type FormCompoundType(string format, Type baseType, int curIndex)
static Type MakeGenericType(Type type, Type[] typeArguments)
CustAttr(CustomAttributeBuilder customBuilder)
void Bake(ModuleBuilder module, int token)
readonly CustomAttributeBuilder m_customBuilder
CustAttr(ConstructorInfo con, byte[] binaryAttribute)
static int DefineType(QCallModule module, string fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens)
void SetParent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent)
override? object InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object?[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters)
readonly MethodBuilder m_declMeth
ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, Type[]? parameterTypes, Type[][]? requiredCustomModifiers, Type[][]? optionalCustomModifiers)
MethodBuilder DefineMethod(string name, MethodAttributes attributes, Type? returnType, Type[]? parameterTypes)
TypeBuilder DefineNestedType(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent, PackingSize packSize)
static FieldInfo GetField(Type type, FieldInfo field)
PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers)
void SetGenParamAttributes(GenericParameterAttributes genericParameterAttributes)
void DefineMethodOverrideNoLock(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
TypeBuilder(ModuleBuilder module)
override bool IsDefined(Type attributeType, bool inherit)
void SetInterfaces(params Type[] interfaces)
static void DefineMethodImpl(QCallModule module, int tkType, int tkBody, int tkDecl)
override object[] GetCustomAttributes(Type attributeType, bool inherit)
override bool IsSubclassOf(Type c)
PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers)
static void SetParentType(QCallModule module, int tdTypeDef, int tkParent)
static void SetMethodImpl(QCallModule module, int tkMethod, MethodImplAttributes MethodImplAttributes)
MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention)
override? MethodBase DeclaringMethod
static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor)
void SetGenParamCustomAttribute(CustomAttributeBuilder customBuilder)
MethodBuilder DefineMethod(string name, MethodAttributes attributes)
TypeBuilder DefineNestedType(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent, int typeSize)
MethodBuilder DefinePInvokeMethodHelper(string name, string dllName, string importName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, CallingConvention nativeCallConv, CharSet nativeCharSet)
ConstructorBuilder DefineDefaultConstructor(MethodAttributes attributes)
override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
TypeBuilder DefineNestedType(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent, PackingSize packSize, int typeSize)
GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names)
static void SetPInvokeData(QCallModule module, string DllName, string name, int token, int linkFlags)
static void TermCreateClass(QCallModule module, int tk, ObjectHandleOnStack type)
static void SetFieldLayoutOffset(QCallModule module, int fdToken, int iOffset)
override bool IsAssignableFrom([NotNullWhen(true)] Type? c)
static void SetMethodIL(QCallModule module, int tk, bool isInitLocals, byte[] body, int bodyLength, byte[] LocalSig, int sigLength, int maxStackSize, ExceptionHandler[] exceptions, int numExceptions, int[] tokenFixups, int numTokenFixups)
PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[]? parameterTypes)
static int DefineMethod(QCallModule module, int tkParent, string name, byte[] signature, int sigLength, MethodAttributes attributes)
override Type[] GetNestedTypes(BindingFlags bindingAttr)
PropertyBuilder DefinePropertyNoLock(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
TypeBuilder DefineNestedType(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent)
MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes)
override? FieldInfo GetField(string name, BindingFlags bindingAttr)
static void SetClassLayout(QCallModule module, int tk, PackingSize iPackingSize, int iTypeSize)
static unsafe void SetConstantValue(ModuleBuilder module, int tk, Type destType, object value)
static int GetTokenFromSig(QCallModule module, byte[] signature, int sigLength)
override EventInfo[] GetEvents()
override? ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[] types, ParameterModifier[]? modifiers)
FieldBuilder DefineField(string fieldName, Type type, FieldAttributes attributes)
override? Type GetInterface(string name, bool ignoreCase)
PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[]? parameterTypes)
TypeBuilder DefineNestedType(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? parent, Type[]? interfaces)
GenericTypeParameterBuilder[] m_inst
FieldBuilder DefineUninitializedDataNoLock(string name, int size, FieldAttributes attributes)
readonly TypeAttributes m_iAttr
MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers, CallingConvention nativeCallConv, CharSet nativeCharSet)
FieldBuilder DefineInitializedDataNoLock(string name, byte[] data, FieldAttributes attributes)
override TypeAttributes GetAttributeFlagsImpl()
override Type MakeArrayType(int rank)
override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
TypeBuilder(string szName, int genParamPos, TypeBuilder declType)
readonly TypeBuilder m_genTypeDef
ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, Type[]? parameterTypes)
static int SetParamInfo(QCallModule module, int tkMethod, int iSequence, ParameterAttributes iParamAttributes, string strParamName)
override? Type GetNestedType(string name, BindingFlags bindingAttr)
void VerifyTypeAttributes(TypeAttributes attr)
FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes)
override? MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[]? types, ParameterModifier[]? modifiers)
override InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.NonPublicMethods)] Type interfaceType)
override? EventInfo GetEvent(string name, BindingFlags bindingAttr)
ConstructorBuilder DefineDefaultConstructorNoLock(MethodAttributes attributes)
TypeBuilder(string szName, int genParamPos, MethodBuilder declMeth)
void SetCustomAttribute(CustomAttributeBuilder customBuilder)
TypeBuilder(string fullname, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type parent, Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, int iTypeSize, TypeBuilder enclosingType)
override FieldInfo[] GetFields(BindingFlags bindingAttr)
GenericParameterAttributes m_genParamAttributes
FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes)
static bool IsTypeEqual(Type t1, Type t2)
override MethodInfo[] GetMethods(BindingFlags bindingAttr)
TypeBuilder DefineNestedTypeNoLock(string name, TypeAttributes attr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type parent, Type[] interfaces, PackingSize packSize, int typeSize)
static void DefineCustomAttribute(QCallModule module, int tkAssociate, int tkConstructor, byte[] attr, int attrLength)
MethodBuilder DefineMethodNoLock(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
static void AddInterfaceImpl(QCallModule module, int tdTypeDef, int tkInterface)
TypeBuilder DefineNestedType(string name, TypeAttributes attr)
override EventInfo[] GetEvents(BindingFlags bindingAttr)
TypeBuilder DefineNestedType(string name)
override object[] GetCustomAttributes(bool inherit)
static void DefineMethodSemantics(QCallModule module, int tkAssociation, MethodSemanticsAttributes semantics, int tkMethod)
void DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
FieldBuilder DefineField(string fieldName, Type type, Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers, FieldAttributes attributes)
ConstructorBuilder DefineTypeInitializerNoLock()
override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder? binder, Type? returnType, Type[]? types, ParameterModifier[]? modifiers)
static int DefineGenericParam(QCallModule module, string name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints)
MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? returnTypeRequiredCustomModifiers, Type[]? returnTypeOptionalCustomModifiers, Type[]? parameterTypes, Type[][]? parameterTypeRequiredCustomModifiers, Type[][]? parameterTypeOptionalCustomModifiers)
MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet)
FieldBuilder DefineFieldNoLock(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
void SetGenParamCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo? typeInfo)
static int DefineProperty(QCallModule module, int tkParent, string name, PropertyAttributes attributes, byte[] signature, int sigLength)
readonly PackingSize m_iPackingSize
List< MethodBuilder > m_listMethods
readonly ModuleBuilder m_module
static MethodInfo GetMethod(Type type, MethodInfo method)
static int DefineMethodSpec(QCallModule module, int tkParent, byte[] signature, int sigLength)
ConstructorBuilder DefineTypeInitializer()
static void DefineCustomAttribute(ModuleBuilder module, int tkAssociate, int tkConstructor, byte[] attr)
void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
FieldBuilder DefineDataHelper(string name, byte[] data, int size, FieldAttributes attributes)
override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
void SetGenParamCustomAttributeNoLock(CustAttr ca)
EventBuilder DefineEventNoLock(string name, EventAttributes attributes, Type eventtype)
override RuntimeTypeHandle TypeHandle
static int DefineField(QCallModule module, int tkParent, string name, byte[] signature, int sigLength, FieldAttributes attributes)
static unsafe void SetConstantValue(QCallModule module, int tk, int corType, void *pValue)
override MemberInfo[] GetMembers(BindingFlags bindingAttr)
static int DefineEvent(QCallModule module, int tkParent, string name, EventAttributes attributes, int tkEventType)
override Type MakeGenericType(params Type[] typeArguments)
MethodBuilder DefinePInvokeMethod(string name, string dllName, MethodAttributes attributes, CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet)
readonly TypeBuilder m_DeclaringType
EventBuilder DefineEvent(string name, EventAttributes attributes, Type eventtype)
void AddInterfaceImplementation([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type interfaceType)
virtual Type AsType()
Definition TypeInfo.cs:106
static string GetRankString(int rank)
Definition TypeInfo.cs:192
override EventInfo GetEvent(string name, BindingFlags bindingAttr)
override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo typeInfo)
override Type GetInterface(string fullname, bool ignoreCase)
override FieldInfo[] GetFields(BindingFlags bindingAttr)
override Type[] GetNestedTypes(BindingFlags bindingAttr)
override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
void InvalidateCachedNestedType()
override object InvokeMember(string name, BindingFlags bindingFlags, Binder binder, object target, object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParams)
override MethodInfo[] GetMethods(BindingFlags bindingAttr)
override Type[] GetInterfaces()
override Type GetNestedType(string fullname, BindingFlags bindingAttr)
override FieldInfo GetField(string name, BindingFlags bindingAttr)
override EventInfo[] GetEvents(BindingFlags bindingAttr)
override InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.NonPublicMethods)] Type ifaceType)
override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
override Guid GUID
override MemberInfo[] GetMembers(BindingFlags bindingAttr)
static string Argument_ConstantNotSupported
Definition SR.cs:532
static string Argument_BadSizeForData
Definition SR.cs:506
static string NotSupported_TypeNotYetCreated
Definition SR.cs:1720
static string Argument_InvalidMethodDeclaringType
Definition SR.cs:708
static string Argument_BadTypeAttrNestedVisibilityOnNonNestedType
Definition SR.cs:510
static string Argument_InvalidFieldDeclaringType
Definition SR.cs:684
static string Arg_MustBeType
Definition SR.cs:302
static string Argument_MustBeTypeBuilder
Definition SR.cs:784
static string ArgumentException_BadMethodImplBody
Definition SR.cs:914
static string Argument_ConstructorNeedGenericDeclaringType
Definition SR.cs:536
static string InvalidOperation_ConstructorNotAllowedOnInterface
Definition SR.cs:1432
static string Argument_BadPInvokeOnInterface
Definition SR.cs:2086
static string InvalidOperation_NoUnderlyingTypeOnEnum
Definition SR.cs:1488
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Argument_TypeNameTooLong
Definition SR.cs:896
static string Argument_NeedNonGenericType
Definition SR.cs:794
static string InvalidOperation_BadMethodBody
Definition SR.cs:1408
static string Argument_ConstantDoesntMatch
Definition SR.cs:530
static string Argument_FieldNeedGenericDeclaringType
Definition SR.cs:604
static string Argument_BadNestedTypeFlags
Definition SR.cs:496
static string Argument_BadTypeAttrNonNestedVisibilityNestedType
Definition SR.cs:512
static string Argument_MethodNeedGenericDeclaringType
Definition SR.cs:764
static string NotSupported_DynamicModule
Definition SR.cs:1672
static string Argument_IllegalName
Definition SR.cs:630
static string Argument_BadTypeAttrInvalidLayout
Definition SR.cs:508
static string InvalidOperation_TypeHasBeenCreated
Definition SR.cs:1524
static string Argument_InvalidConstructorDeclaringType
Definition SR.cs:656
static string Argument_MethodRedefined
Definition SR.cs:2088
static string Arg_EmptyArray
Definition SR.cs:134
static string Argument_MismatchedArrays
Definition SR.cs:768
static string Argument_EmptyName
Definition SR.cs:584
static string Argument_NeedGenericMethodDefinition
Definition SR.cs:792
static string NotSupported_NoParentDefaultConstructor
Definition SR.cs:1694
static string Argument_BadTypeAttrReservedBitsSet
Definition SR.cs:514
static string Argument_BadPInvokeMethod
Definition SR.cs:2084
static string InvalidOperation_BadInterfaceNotAbstract
Definition SR.cs:1406
static string Argument_CannotSetParentToInterface
Definition SR.cs:520
static string InvalidOperation_BadTypeAttributesNotAbstract
Definition SR.cs:1410
static string InvalidOperation_BadEmptyMethodBody
Definition SR.cs:1400
Definition SR.cs:7
bool IsInterface
Definition Type.cs:30
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
virtual Type[] GetGenericArguments()
Definition Type.cs:500
virtual bool IsEnum
Definition Type.cs:227
ConstructorInfo? GetConstructor(Type[] types)
Definition Type.cs:542
Type? BaseType
Definition Type.cs:295
static readonly Type[] EmptyTypes
Definition Type.cs:19
MethodInfo? GetMethod(string name)
Definition Type.cs:675
virtual Type GetGenericTypeDefinition()
Definition Type.cs:495
static ? Type GetUnderlyingType(Type nullableType)
Definition Nullable.cs:139
static CorElementType GetCorElementType(RuntimeType type)