Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeType.cs
Go to the documentation of this file.
9using System.Text;
12
13namespace System;
14
15internal sealed class RuntimeType : TypeInfo, ICloneable
16{
17 private sealed class ActivatorCache
18 {
19 private unsafe readonly delegate*<void*, object> _pfnAllocator;
20
21 private unsafe readonly void* _allocatorFirstArg;
22
23 private unsafe readonly delegate*<object, void> _pfnCtor;
24
25 private readonly bool _ctorIsPublic;
26
27 internal bool CtorIsPublic => _ctorIsPublic;
28
29 internal unsafe ActivatorCache(RuntimeType rt)
30 {
31 rt.CreateInstanceCheckThis();
32 try
33 {
35 }
36 catch (Exception ex)
37 {
38 string message = SR.Format(SR.Activator_CannotCreateInstance, rt, ex.Message);
39 if (!(ex is ArgumentException))
40 {
42 {
44 {
46 {
48 {
50 {
51 throw new MemberAccessException(message);
52 }
53 throw;
54 }
55 throw new MissingMethodException(message);
56 }
57 throw new MethodAccessException(message);
58 }
59 throw new NotSupportedException(message);
60 }
61 throw new PlatformNotSupportedException(message);
62 }
63 throw new ArgumentException(message);
64 }
65 if (_pfnAllocator == (delegate*<void*, object>)null)
66 {
68 }
69 if (_pfnCtor == (delegate*<object, void>)null)
70 {
72 }
73 static void CtorNoopStub(object uninitializedObject)
74 {
75 }
76 unsafe static object ReturnNull(void* _)
77 {
78 return null;
79 }
80 }
81
82 [MethodImpl(MethodImplOptions.AggressiveInlining)]
84 {
85 object result = _pfnAllocator(_allocatorFirstArg);
87 return result;
88 }
89
90 [MethodImpl(MethodImplOptions.AggressiveInlining)]
91 internal unsafe void CallConstructor(object uninitializedObject)
92 {
94 }
95 }
96
97 internal enum MemberListType
98 {
99 All,
103 }
104
105 internal struct ListBuilder<T> where T : class
106 {
107 private T[] _items;
108
109 private T _item;
110
111 private int _count;
112
113 private int _capacity;
114
115 public T this[int index]
116 {
117 get
118 {
119 if (_items == null)
120 {
121 return _item;
122 }
123 return _items[index];
124 }
125 }
126
127 public int Count => _count;
128
130 {
131 _items = null;
132 _item = null;
133 _count = 0;
135 }
136
137 public T[] ToArray()
138 {
139 if (_count == 0)
140 {
141 return Array.Empty<T>();
142 }
143 if (_count == 1)
144 {
145 return new T[1] { _item };
146 }
147 Array.Resize(ref _items, _count);
149 return _items;
150 }
151
152 public void CopyTo(object[] array, int index)
153 {
154 if (_count != 0)
155 {
156 if (_count == 1)
157 {
158 array[index] = _item;
159 }
160 else
161 {
163 }
164 }
165 }
166
167 public void Add(T item)
168 {
169 if (_count == 0)
170 {
171 _item = item;
172 }
173 else
174 {
175 if (_count == 1)
176 {
177 if (_capacity < 2)
178 {
179 _capacity = 4;
180 }
181 _items = new T[_capacity];
182 _items[0] = _item;
183 }
184 else if (_capacity == _count)
185 {
186 int num = 2 * _capacity;
187 Array.Resize(ref _items, num);
188 _capacity = num;
189 }
190 _items[_count] = item;
191 }
192 _count++;
193 }
194 }
195
196 internal sealed class RuntimeTypeCache
197 {
198 internal enum CacheType
199 {
200 Method,
202 Field,
203 Property,
204 Event,
205 Interface,
207 }
208
209 private readonly struct Filter
210 {
211 private readonly MdUtf8String m_name;
212
213 private readonly MemberListType m_listType;
214
215 private readonly uint m_nameHash;
216
218 {
221 m_nameHash = 0u;
223 {
225 }
226 }
227
228 public bool Match(MdUtf8String name)
229 {
230 bool result = true;
231 if (m_listType == MemberListType.CaseSensitive)
232 {
233 result = m_name.Equals(name);
234 }
235 else if (m_listType == MemberListType.CaseInsensitive)
236 {
237 result = m_name.EqualsCaseInsensitive(name);
238 }
239 return result;
240 }
241
243 {
244 if (m_listType != MemberListType.CaseSensitive)
245 {
246 return m_listType == MemberListType.CaseInsensitive;
247 }
248 return true;
249 }
250
251 public bool CaseSensitive()
252 {
253 return m_listType == MemberListType.CaseSensitive;
254 }
255
256 public uint GetHashToMatch()
257 {
258 return m_nameHash;
259 }
260 }
261
262 private sealed class MemberInfoCache<T> where T : MemberInfo
263 {
265
267
268 private T[] m_allMembers;
269
270 private bool m_cacheComplete;
271
273
275
280
282 {
284 if (allMembers != null)
285 {
286 switch (cacheType)
287 {
288 case CacheType.Method:
289 {
290 T[] array2 = allMembers;
291 foreach (T val2 in array2)
292 {
293 if ((object)val2 == null)
294 {
295 break;
296 }
297 if (val2 is RuntimeMethodInfo { MethodHandle: var methodHandle2 } runtimeMethodInfo && methodHandle2.Value == method.Value)
298 {
299 return runtimeMethodInfo;
300 }
301 }
302 break;
303 }
304 case CacheType.Constructor:
305 {
306 T[] array = allMembers;
307 foreach (T val in array)
308 {
309 if ((object)val == null)
310 {
311 break;
312 }
313 if (val is RuntimeConstructorInfo { MethodHandle: var methodHandle } runtimeConstructorInfo && methodHandle.Value == method.Value)
314 {
316 }
317 }
318 break;
319 }
320 }
321 }
322 T[] list = null;
324 bool isPublic = (attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public;
325 bool isStatic = (attributes & MethodAttributes.Static) != 0;
328 switch (cacheType)
329 {
330 case CacheType.Method:
331 list = (T[])(object)new RuntimeMethodInfo[1]
332 {
334 };
335 break;
336 case CacheType.Constructor:
337 list = (T[])(object)new RuntimeConstructorInfo[1]
338 {
340 };
341 break;
342 }
343 Insert(ref list, null, MemberListType.HandleToInfo);
344 return (MethodBase)(object)list[0];
345 }
346
348 {
350 if (allMembers != null)
351 {
352 T[] array = allMembers;
353 foreach (T val in array)
354 {
355 if ((object)val == null)
356 {
357 break;
358 }
359 if (val is RtFieldInfo rtFieldInfo && rtFieldInfo.GetFieldHandle() == field.Value)
360 {
361 return rtFieldInfo;
362 }
363 }
364 }
366 bool isPublic = (attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public;
367 bool isStatic = (attributes & FieldAttributes.Static) != 0;
371 T[] list = (T[])(object)new RuntimeFieldInfo[1]
372 {
374 };
375 Insert(ref list, null, MemberListType.HandleToInfo);
376 return (FieldInfo)(object)list[0];
377 }
378
379 private unsafe T[] Populate(string name, MemberListType listType, CacheType cacheType)
380 {
381 T[] list;
382 if (string.IsNullOrEmpty(name) || (cacheType == CacheType.Constructor && name[0] != '.' && name[0] != '*'))
383 {
384 list = GetListByName(null, 0, null, 0, listType, cacheType);
385 }
386 else
387 {
388 int length = name.Length;
389 fixed (char* ptr = name)
390 {
391 int byteCount = Encoding.UTF8.GetByteCount(ptr, length);
392 if (byteCount > 1024)
393 {
394 byte[] array = new byte[byteCount];
395 fixed (byte* pUtf8Name = &array[0])
396 {
398 }
399 }
400 else
401 {
402 byte* pUtf8Name2 = stackalloc byte[(int)(uint)byteCount];
404 }
405 }
406 }
407 Insert(ref list, name, listType);
408 return list;
409 }
410
411 private unsafe T[] GetListByName(char* pName, int cNameLen, byte* pUtf8Name, int cUtf8Name, MemberListType listType, CacheType cacheType)
412 {
413 if (cNameLen != 0)
414 {
415 Encoding.UTF8.GetBytes(pName, cNameLen, pUtf8Name, cUtf8Name);
416 }
418 object obj = null;
419 switch (cacheType)
420 {
421 case CacheType.Method:
423 break;
424 case CacheType.Field:
426 break;
427 case CacheType.Constructor:
429 break;
430 case CacheType.Property:
432 break;
433 case CacheType.Event:
435 break;
436 case CacheType.NestedType:
438 break;
439 case CacheType.Interface:
441 break;
442 }
443 return (T[])obj;
444 }
445
446 internal void Insert(ref T[] list, string name, MemberListType listType)
447 {
448 bool lockTaken = false;
449 try
450 {
451 Monitor.Enter(this, ref lockTaken);
452 switch (listType)
453 {
454 case MemberListType.CaseSensitive:
455 {
456 T[] array = m_csMemberInfos[name];
457 if (array == null)
458 {
460 m_csMemberInfos[name] = list;
461 }
462 else
463 {
464 list = array;
465 }
466 break;
467 }
468 case MemberListType.CaseInsensitive:
469 {
470 T[] array2 = m_cisMemberInfos[name];
471 if (array2 == null)
472 {
474 m_cisMemberInfos[name] = list;
475 }
476 else
477 {
478 list = array2;
479 }
480 break;
481 }
482 case MemberListType.All:
483 if (!m_cacheComplete)
484 {
486 int num = m_allMembers.Length;
487 while (num > 0 && !(m_allMembers[num - 1] != null))
488 {
489 num--;
490 }
491 Array.Resize(ref m_allMembers, num);
493 }
495 break;
496 default:
498 break;
499 }
500 }
501 finally
502 {
503 if (lockTaken)
504 {
505 Monitor.Exit(this);
506 }
507 }
508 }
509
510 private void MergeWithGlobalList(T[] list)
511 {
512 T[] array = m_allMembers;
513 if (array == null)
514 {
516 return;
517 }
518 int num = array.Length;
519 int num2 = 0;
520 for (int i = 0; i < list.Length; i++)
521 {
522 T val = list[i];
523 bool flag = false;
524 int j;
525 for (j = 0; j < num; j++)
526 {
527 T val2 = array[j];
528 if (val2 == null)
529 {
530 break;
531 }
532 if (val.CacheEquals(val2))
533 {
534 list[i] = val2;
535 flag = true;
536 break;
537 }
538 }
539 if (!flag)
540 {
541 if (num2 == 0)
542 {
543 num2 = j;
544 }
545 if (num2 >= array.Length)
546 {
547 int newSize = ((!m_cacheComplete) ? Math.Max(Math.Max(4, 2 * array.Length), list.Length) : (array.Length + 1));
548 T[] array2 = array;
549 Array.Resize(ref array2, newSize);
550 array = array2;
551 }
552 Volatile.Write(ref array[num2], val);
553 num2++;
554 }
555 }
557 }
558
560 {
564 {
566 while (enumerator.MoveNext())
567 {
568 RuntimeMethodHandleInternal current = enumerator.Current;
569 if (!filter.RequiresStringComparison() || (RuntimeMethodHandle.MatchesNameHash(current, filter.GetHashToMatch()) && filter.Match(RuntimeMethodHandle.GetUtf8Name(current))))
570 {
572 if ((attributes & MethodAttributes.RTSpecialName) == 0)
573 {
574 bool isPublic = (attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public;
575 bool isStatic = (attributes & MethodAttributes.Static) != 0;
580 }
581 }
582 }
583 }
584 else
585 {
587 {
588 runtimeType = runtimeType.GetBaseType();
589 }
591 bool* ptr = stackalloc bool[(int)(uint)numVirtuals];
593 bool isValueType = runtimeType.IsValueType;
594 do
595 {
598 while (enumerator2.MoveNext())
599 {
601 if (filter.RequiresStringComparison() && (!RuntimeMethodHandle.MatchesNameHash(current2, filter.GetHashToMatch()) || !filter.Match(RuntimeMethodHandle.GetUtf8Name(current2))))
602 {
603 continue;
604 }
607 if ((attributes2 & MethodAttributes.RTSpecialName) != 0)
608 {
609 continue;
610 }
611 bool flag = false;
612 int num = 0;
613 if ((attributes2 & MethodAttributes.Virtual) != 0)
614 {
616 flag = num < numVirtuals2;
617 }
619 bool flag3 = methodAttributes == MethodAttributes.Private;
620 if (flag2 && flag3 && !flag)
621 {
622 continue;
623 }
624 if (flag)
625 {
626 if (ptr[num])
627 {
628 continue;
629 }
630 ptr[num] = true;
631 }
632 else if (isValueType && (attributes2 & (MethodAttributes.Virtual | MethodAttributes.Abstract)) != 0)
633 {
634 continue;
635 }
637 bool isStatic2 = (attributes2 & MethodAttributes.Static) != 0;
642 }
644 }
645 while (runtimeType != null);
646 }
647 return listBuilder.ToArray();
648 }
649
651 {
653 {
654 return Array.Empty<RuntimeConstructorInfo>();
655 }
659 while (enumerator.MoveNext())
660 {
661 RuntimeMethodHandleInternal current = enumerator.Current;
662 if (!filter.RequiresStringComparison() || (RuntimeMethodHandle.MatchesNameHash(current, filter.GetHashToMatch()) && filter.Match(RuntimeMethodHandle.GetUtf8Name(current))))
663 {
665 if ((attributes & MethodAttributes.RTSpecialName) != 0)
666 {
667 bool isPublic = (attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public;
668 bool isStatic = (attributes & MethodAttributes.Static) != 0;
673 }
674 }
675 }
676 return listBuilder.ToArray();
677 }
678
679 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", Justification = "Calls to GetInterfaces technically require all interfaces on ReflectedTypeBut this is not a public API to enumerate reflection items, all the public APIs which do thatshould be annotated accordingly.")]
681 {
685 {
686 runtimeType = runtimeType.GetBaseType();
687 }
688 while (runtimeType != null)
689 {
693 }
695 {
696 Type[] interfaces = ReflectedType.BaseType.GetInterfaces();
697 for (int i = 0; i < interfaces.Length; i++)
698 {
700 PopulateRtFields(filter, (RuntimeType)interfaces[i], ref list);
701 }
702 }
703 else
704 {
706 if (interfaces2 != null)
707 {
708 for (int j = 0; j < interfaces2.Length; j++)
709 {
712 }
713 }
714 }
715 return list.ToArray();
716 }
717
719 {
721 int num = 64;
723 {
724 fixed (IntPtr* ptr2 = new IntPtr[num])
725 {
728 }
729 }
730 else if (num > 0)
731 {
733 }
734 }
735
737 {
740 for (int i = 0; i < count; i++)
741 {
744 {
745 continue;
746 }
748 FieldAttributes fieldAttributes = attributes & FieldAttributes.FieldAccessMask;
749 if (!flag2 || fieldAttributes != FieldAttributes.Private)
750 {
752 bool flag3 = (attributes & FieldAttributes.Static) != 0;
754 if (flag && flag3)
755 {
757 }
759 list.Add(item);
760 }
761 }
762 }
763
765 {
768 {
769 return;
770 }
772 metadataImport.EnumFields(token, out var result);
773 for (int i = 0; i < result.Length; i++)
774 {
775 int num = result[i];
776 metadataImport.GetFieldDefProps(num, out var fieldAttributes);
778 if ((fieldAttributes & FieldAttributes.Literal) == 0)
779 {
780 continue;
781 }
782 bool flag = declaringType != ReflectedType;
783 if (flag && fieldAttributes2 == FieldAttributes.Private)
784 {
785 continue;
786 }
787 if (filter.RequiresStringComparison())
788 {
789 MdUtf8String name = metadataImport.GetName(num);
790 if (!filter.Match(name))
791 {
792 continue;
793 }
794 }
796 bool isStatic = (fieldAttributes & FieldAttributes.Static) != 0;
799 list.Add(item);
800 }
801 }
802
804 {
805 if (!iList.IsAssignableFrom(ReflectedType))
806 {
807 return;
808 }
810 {
811 list.Add(iList);
812 }
813 if (!addSubInterface)
814 {
815 return;
816 }
817 Type[] interfaces = iList.GetInterfaces();
818 for (int i = 0; i < interfaces.Length; i++)
819 {
820 RuntimeType runtimeType = (RuntimeType)interfaces[i];
821 if (runtimeType.IsGenericType && filter.Match(RuntimeTypeHandle.GetUtf8Name(runtimeType)))
822 {
823 list.Add(runtimeType);
824 }
825 }
826 }
827
828 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2065:UnrecognizedReflectionPattern", Justification = "Calls to GetInterfaces technically require all interfaces on ReflectedTypeBut this is not a public API to enumerate reflection items, all the public APIs which do thatshould be annotated accordingly.")]
830 {
834 {
836 if (interfaces != null)
837 {
838 for (int i = 0; i < interfaces.Length; i++)
839 {
840 RuntimeType runtimeType = (RuntimeType)interfaces[i];
841 if (!filter.RequiresStringComparison() || filter.Match(RuntimeTypeHandle.GetUtf8Name(runtimeType)))
842 {
843 list.Add(runtimeType);
844 }
845 }
846 }
848 {
850 if (!runtimeType2.IsPointer)
851 {
855 }
856 }
857 }
858 else
859 {
861 Type[] genericParameterConstraints = reflectedType.GetGenericParameterConstraints();
862 for (int j = 0; j < genericParameterConstraints.Length; j++)
863 {
865 if (runtimeType3.IsInterface)
866 {
868 }
869 Type[] interfaces2 = runtimeType3.GetInterfaces();
870 for (int k = 0; k < interfaces2.Length; k++)
871 {
873 }
874 }
875 foreach (RuntimeType item in hashSet)
876 {
877 if (!filter.RequiresStringComparison() || filter.Match(RuntimeTypeHandle.GetUtf8Name(item)))
878 {
879 list.Add(item);
880 }
881 }
882 }
883 return list.ToArray();
884 }
885
886 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Calls to ResolveTypeHandle technically require all types to be kept But this is not a public API to enumerate reflection items, all the public APIs which do that should be annotated accordingly.")]
888 {
891 {
892 runtimeType = runtimeType.GetBaseType();
893 }
896 {
897 return Array.Empty<RuntimeType>();
898 }
901 ModuleHandle.GetMetadataImport(moduleHandle.GetRuntimeModule()).EnumNestedTypes(token, out var result);
902 for (int i = 0; i < result.Length; i++)
903 {
905 try
906 {
907 runtimeType2 = moduleHandle.ResolveTypeHandle(result[i]).GetRuntimeType();
908 }
909 catch (TypeLoadException)
910 {
911 continue;
912 }
913 if (!filter.RequiresStringComparison() || filter.Match(RuntimeTypeHandle.GetUtf8Name(runtimeType2)))
914 {
916 }
917 }
918 return listBuilder.ToArray();
919 }
920
944
946 {
949 {
950 return;
951 }
953 metadataImport.EnumEvents(token, out var result);
954 for (int i = 0; i < result.Length; i++)
955 {
956 int num = result[i];
957 if (filter.RequiresStringComparison())
958 {
959 MdUtf8String name = metadataImport.GetName(num);
960 if (!filter.Match(name))
961 {
962 continue;
963 }
964 }
965 bool isPrivate;
968 {
969 continue;
970 }
971 if (csEventInfos != null)
972 {
973 string name2 = runtimeEventInfo.Name;
975 {
976 continue;
977 }
979 }
980 else if (list.Count > 0)
981 {
982 break;
983 }
985 }
986 }
987
1013
1015 {
1018 {
1019 return;
1020 }
1021 RuntimeTypeHandle.GetMetadataImport(declaringType).EnumProperties(token, out var result);
1024 for (int i = 0; i < result.Length; i++)
1025 {
1026 int num = result[i];
1027 if (filter.RequiresStringComparison())
1028 {
1029 if (!ModuleHandle.ContainsPropertyMatchingHash(module, num, filter.GetHashToMatch()))
1030 {
1031 continue;
1032 }
1033 MdUtf8String name = declaringType.GetRuntimeModule().MetadataImport.GetName(num);
1034 if (!filter.Match(name))
1035 {
1036 continue;
1037 }
1038 }
1039 bool isPrivate;
1041 if (usedSlots != null)
1042 {
1044 {
1045 continue;
1046 }
1047 MethodInfo methodInfo = runtimePropertyInfo.GetGetMethod() ?? runtimePropertyInfo.GetSetMethod();
1048 if (methodInfo != null)
1049 {
1051 if (slot < numVirtuals)
1052 {
1053 if (usedSlots[slot])
1054 {
1055 continue;
1056 }
1057 usedSlots[slot] = true;
1058 }
1059 }
1060 if (csPropertyInfos != null)
1061 {
1062 string name2 = runtimePropertyInfo.Name;
1064 {
1066 }
1067 for (int j = 0; j < value.Count; j++)
1068 {
1069 if (runtimePropertyInfo.EqualsSig(value[j]))
1070 {
1071 value = null;
1072 break;
1073 }
1074 }
1075 if (value == null)
1076 {
1077 continue;
1078 }
1080 }
1081 else
1082 {
1083 bool flag = false;
1084 for (int k = 0; k < list.Count; k++)
1085 {
1086 if (runtimePropertyInfo.EqualsSig(list[k]))
1087 {
1088 flag = true;
1089 break;
1090 }
1091 }
1092 if (flag)
1093 {
1094 continue;
1095 }
1096 }
1097 }
1099 }
1100 }
1101
1103 {
1104 switch (listType)
1105 {
1106 case MemberListType.CaseSensitive:
1107 return m_csMemberInfos[name] ?? Populate(name, listType, cacheType);
1108 case MemberListType.CaseInsensitive:
1109 return m_cisMemberInfos[name] ?? Populate(name, listType, cacheType);
1110 default:
1112 {
1113 return m_allMembers;
1114 }
1115 return Populate(null, listType, cacheType);
1116 }
1117 }
1118 }
1119
1120 private readonly RuntimeType m_runtimeType;
1121
1123
1125
1126 private string m_name;
1127
1128 private string m_fullname;
1129
1130 private string m_toString;
1131
1132 private string m_namespace;
1133
1134 private readonly bool m_isGlobal;
1135
1137
1139
1141
1143
1145
1147
1149
1151
1153
1154 private static object s_methodInstantiationsLock;
1155
1156 private string m_defaultMemberName;
1157
1158 private object m_genericCache;
1159
1160 private object[] _emptyArray;
1161
1162 internal object GenericCache
1163 {
1164 get
1165 {
1166 return m_genericCache;
1167 }
1168 set
1169 {
1171 }
1172 }
1173
1174 internal bool DomainInitialized
1175 {
1176 get
1177 {
1179 }
1180 set
1181 {
1183 }
1184 }
1185
1187 {
1188 get
1189 {
1190 return m_typeCode;
1191 }
1192 set
1193 {
1194 m_typeCode = value;
1195 }
1196 }
1197
1198 internal bool IsGlobal => m_isGlobal;
1199
1206
1207 private string ConstructName([NotNull] ref string name, TypeNameFormatFlags formatFlags)
1208 {
1209 return name ?? (name = new RuntimeTypeHandle(m_runtimeType).ConstructName(formatFlags));
1210 }
1211
1217
1232
1233 internal string GetName(TypeNameKind kind)
1234 {
1235 switch (kind)
1236 {
1237 case TypeNameKind.Name:
1238 return ConstructName(ref m_name, TypeNameFormatFlags.FormatBasic);
1239 case TypeNameKind.FullName:
1241 {
1242 return null;
1243 }
1245 case TypeNameKind.ToString:
1246 return ConstructName(ref m_toString, TypeNameFormatFlags.FormatNamespace);
1247 default:
1248 throw new InvalidOperationException();
1249 }
1250 }
1251
1252 internal string GetNameSpace()
1253 {
1254 if (m_namespace == null)
1255 {
1257 runtimeType = runtimeType.GetRootElementType();
1258 while (runtimeType.IsNested)
1259 {
1260 runtimeType = runtimeType.DeclaringType;
1261 }
1262 m_namespace = RuntimeTypeHandle.GetMetadataImport((RuntimeType)runtimeType).GetNamespace(runtimeType.MetadataToken).ToString();
1263 }
1264 return m_namespace;
1265 }
1266
1268 {
1269 if (m_enclosingType == null)
1270 {
1273 }
1274 if (!(m_enclosingType == typeof(void)))
1275 {
1276 return m_enclosingType;
1277 }
1278 return null;
1279 }
1280
1282 {
1283 return m_runtimeType;
1284 }
1285
1287 {
1288 m_nestedClassesCache = null;
1289 }
1290
1291 internal string GetDefaultMemberName()
1292 {
1293 if (m_defaultMemberName == null)
1294 {
1298 while (runtimeType != null)
1299 {
1301 for (int i = 0; i < customAttributes.Count; i++)
1302 {
1303 if ((object)customAttributes[i].Constructor.DeclaringType == typeFromHandle)
1304 {
1306 break;
1307 }
1308 }
1309 if (customAttributeData != null)
1310 {
1311 m_defaultMemberName = customAttributeData.ConstructorArguments[0].Value as string;
1312 break;
1313 }
1314 runtimeType = runtimeType.GetBaseType();
1315 }
1316 }
1317 return m_defaultMemberName;
1318 }
1319
1320 internal object[] GetEmptyArray()
1321 {
1322 return _emptyArray ?? (_emptyArray = (object[])Array.CreateInstance(m_runtimeType, 0));
1323 }
1324
1326 {
1330 if (runtimeMethodInfo2 != null)
1331 {
1332 return runtimeMethodInfo2;
1333 }
1334 if (s_methodInstantiationsLock == null)
1335 {
1337 }
1338 bool lockTaken = false;
1339 try
1340 {
1342 if (loaderAllocator != null)
1343 {
1344 runtimeMethodInfo2 = loaderAllocator.m_methodInstantiations[runtimeMethodInfo];
1345 if (runtimeMethodInfo2 != null)
1346 {
1347 return runtimeMethodInfo2;
1348 }
1349 loaderAllocator.m_methodInstantiations[runtimeMethodInfo] = runtimeMethodInfo;
1350 }
1351 else
1352 {
1354 if (runtimeMethodInfo2 != null)
1355 {
1356 return runtimeMethodInfo2;
1357 }
1359 }
1360 }
1361 finally
1362 {
1363 if (lockTaken)
1364 {
1366 }
1367 }
1368 return runtimeMethodInfo;
1369 }
1370
1372 {
1373 return GetMemberList(ref m_methodInfoCache, listType, name, CacheType.Method);
1374 }
1375
1377 {
1378 return GetMemberList(ref m_constructorInfoCache, listType, name, CacheType.Constructor);
1379 }
1380
1382 {
1383 return GetMemberList(ref m_propertyInfoCache, listType, name, CacheType.Property);
1384 }
1385
1387 {
1388 return GetMemberList(ref m_eventInfoCache, listType, name, CacheType.Event);
1389 }
1390
1392 {
1393 return GetMemberList(ref m_fieldInfoCache, listType, name, CacheType.Field);
1394 }
1395
1397 {
1398 return GetMemberList(ref m_interfaceCache, listType, name, CacheType.Interface);
1399 }
1400
1402 {
1403 return GetMemberList(ref m_nestedClassesCache, listType, name, CacheType.NestedType);
1404 }
1405
1411
1417
1423 }
1424
1425 [Flags]
1427 {
1428 Unknown = 1,
1429 Dispatch = 2,
1430 Error = 8,
1431 Currency = 0x10,
1432 BStr = 0x20,
1433 SafeArray = 0x10000
1434 }
1435
1436 private readonly object m_keepalive;
1437
1439
1441
1442 internal static readonly RuntimeType ValueType = (RuntimeType)typeof(ValueType);
1443
1444 private static readonly RuntimeType ObjectType = (RuntimeType)typeof(object);
1445
1446 private static readonly RuntimeType StringType = (RuntimeType)typeof(string);
1447
1448 private const int GenericParameterCountAny = -1;
1449
1451
1453
1454 internal object GenericCache
1455 {
1456 get
1457 {
1459 }
1460 set
1461 {
1462 Cache.GenericCache = value;
1463 }
1464 }
1465
1466 internal bool DomainInitialized
1467 {
1468 get
1469 {
1470 return Cache.DomainInitialized;
1471 }
1472 set
1473 {
1474 Cache.DomainInitialized = value;
1475 }
1476 }
1477
1479 {
1480 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1481 get
1482 {
1483 if (m_cache != IntPtr.Zero)
1484 {
1486 return Unsafe.As<RuntimeTypeCache>(value);
1487 }
1488 return null;
1489 }
1490 }
1491
1492 private RuntimeTypeCache Cache
1493 {
1494 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1495 get
1496 {
1497 if (m_cache != IntPtr.Zero)
1498 {
1499 object obj = GCHandle.InternalGet(m_cache);
1500 if (obj != null)
1501 {
1502 return Unsafe.As<RuntimeTypeCache>(obj);
1503 }
1504 }
1505 return InitializeCache();
1506 }
1507 }
1508
1509 public sealed override bool IsCollectible
1510 {
1511 get
1512 {
1513 RuntimeType type = this;
1515 }
1516 }
1517
1519 {
1520 get
1521 {
1522 if (!IsGenericParameter)
1523 {
1525 }
1527 if (declaringMethod == null)
1528 {
1529 return null;
1530 }
1532 }
1533 }
1534
1535 public override string FullName => GetCachedName(TypeNameKind.FullName);
1536
1537 public override string AssemblyQualifiedName
1538 {
1539 get
1540 {
1541 string fullName = FullName;
1542 if (fullName == null)
1543 {
1544 return null;
1545 }
1547 }
1548 }
1549
1550 public override string Namespace
1551 {
1552 get
1553 {
1554 string nameSpace = Cache.GetNameSpace();
1555 if (string.IsNullOrEmpty(nameSpace))
1556 {
1557 return null;
1558 }
1559 return nameSpace;
1560 }
1561 }
1562
1563 public override Guid GUID
1564 {
1565 get
1566 {
1567 Guid result = default(Guid);
1568 GetGUID(ref result);
1569 return result;
1570 }
1571 }
1572
1574 {
1575 get
1576 {
1577 if (!IsGenericParameter)
1578 {
1580 }
1581 RuntimeTypeHandle.GetMetadataImport(this).GetGenericParamProps(MetadataToken, out var attributes);
1582 return attributes;
1583 }
1584 }
1585
1586 public sealed override bool IsSZArray => RuntimeTypeHandle.IsSZArray(this);
1587
1588 public override int GenericParameterPosition
1589 {
1590 get
1591 {
1592 if (!IsGenericParameter)
1593 {
1595 }
1596 return new RuntimeTypeHandle(this).GetGenericVariableIndex();
1597 }
1598 }
1599
1600 public override bool ContainsGenericParameters => GetRootElementType().GetTypeHandleInternal().ContainsGenericVariables();
1601
1603
1604 public override string Name => GetCachedName(TypeNameKind.Name);
1605
1606 public override Type DeclaringType => Cache.GetEnclosingType();
1607
1609
1611
1612 public override Type BaseType => GetBaseType();
1613
1614 public override bool IsByRefLike => RuntimeTypeHandle.IsByRefLike(this);
1615
1616 public override bool IsConstructedGenericType
1617 {
1618 get
1619 {
1620 if (IsGenericType)
1621 {
1623 }
1624 return false;
1625 }
1626 }
1627
1628 public override bool IsGenericType => RuntimeTypeHandle.HasInstantiation(this);
1629
1631
1633
1635
1636 public override bool IsSecurityCritical => true;
1637
1638 public override bool IsSecuritySafeCritical => false;
1639
1640 public override bool IsSecurityTransparent => false;
1641
1642 public override MemberTypes MemberType
1643 {
1644 get
1645 {
1646 if (!base.IsPublic && !base.IsNotPublic)
1647 {
1648 return MemberTypes.NestedType;
1649 }
1650 return MemberTypes.TypeInfo;
1651 }
1652 }
1653
1654 public override int MetadataToken => RuntimeTypeHandle.GetToken(this);
1655
1656 public override Module Module => GetRuntimeModule();
1657
1659
1660 public override RuntimeTypeHandle TypeHandle => new RuntimeTypeHandle(this);
1661
1662 public override Type UnderlyingSystemType => this;
1663
1664 internal static RuntimeType GetType(string typeName, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark)
1665 {
1666 if (typeName == null)
1667 {
1668 throw new ArgumentNullException("typeName");
1669 }
1671 }
1672
1673 [RequiresUnreferencedCode("Trimming changes metadata tokens")]
1675 {
1676 return GetMethodBase(new ModuleHandle(scope).ResolveMethodHandle(typeMetadataToken).GetMethodInfo());
1677 }
1678
1680 {
1681 return GetMethodBase(null, methodHandle);
1682 }
1683
1690
1691 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "The code in this method looks up the method by name, but it always starts with a method handle.To get here something somwhere had to get the method handle and thus the method must exist.")]
1693 {
1695 {
1696 return RuntimeMethodHandle.GetResolver(methodHandle)?.GetDynamicMethod();
1697 }
1699 RuntimeType[] array = null;
1700 if ((object)reflectedType == null)
1701 {
1703 }
1704 if (reflectedType != runtimeType && !reflectedType.IsSubclassOf(runtimeType))
1705 {
1706 if (reflectedType.IsArray)
1707 {
1709 bool flag = false;
1710 for (int i = 0; i < array2.Length; i++)
1711 {
1713 if (runtimeMethodInfo.Value.Value == methodHandle.Value)
1714 {
1715 flag = true;
1716 }
1717 }
1718 if (!flag)
1719 {
1721 }
1722 }
1723 else if (runtimeType.IsGenericType)
1724 {
1725 RuntimeType runtimeType2 = (RuntimeType)runtimeType.GetGenericTypeDefinition();
1727 while (runtimeType3 != null)
1728 {
1730 if (runtimeType4.IsGenericType && !runtimeType3.IsGenericTypeDefinition)
1731 {
1732 runtimeType4 = (RuntimeType)runtimeType4.GetGenericTypeDefinition();
1733 }
1735 {
1736 break;
1737 }
1738 runtimeType3 = runtimeType3.GetBaseType();
1739 }
1740 if (runtimeType3 == null)
1741 {
1743 }
1746 {
1748 }
1750 }
1751 else if (!runtimeType.IsAssignableFrom(reflectedType))
1752 {
1754 }
1755 }
1759 return result;
1760 }
1761
1766
1786
1788 {
1789 RuntimePropertyInfo[] propertyList = reflectedType.Cache.GetPropertyList(MemberListType.All, null);
1791 {
1792 if (runtimePropertyInfo.MetadataToken == tkProperty)
1793 {
1794 return runtimePropertyInfo;
1795 }
1796 }
1797 throw new SystemException();
1798 }
1799
1801 {
1802 RuntimeType[] typeContext = null;
1803 RuntimeType[] methodContext = null;
1805 if (definition is Type)
1806 {
1808 genericArgumentsInternal = runtimeType.GetGenericArgumentsInternal();
1810 }
1811 else
1812 {
1814 genericArgumentsInternal = runtimeMethodInfo.GetGenericArgumentsInternal();
1817 if (runtimeType2 != null)
1818 {
1819 typeContext = runtimeType2.GetTypeHandleInternal().GetInstantiationInternal();
1820 }
1821 }
1822 for (int i = 0; i < genericArguments.Length; i++)
1823 {
1826 if (!RuntimeTypeHandle.SatisfiesConstraints(type2.GetTypeHandleInternal().GetTypeChecked(), typeContext, methodContext, type.GetTypeHandleInternal().GetTypeChecked()))
1827 {
1829 }
1830 }
1831 }
1832
1833 private static void SplitName(string fullname, out string name, out string ns)
1834 {
1835 name = null;
1836 ns = null;
1837 if (fullname == null)
1838 {
1839 return;
1840 }
1841 int num = fullname.LastIndexOf(".", StringComparison.Ordinal);
1842 if (num != -1)
1843 {
1844 ns = fullname.Substring(0, num);
1845 int num2 = fullname.Length - ns.Length - 1;
1846 if (num2 != 0)
1847 {
1848 name = fullname.Substring(num + 1, num2);
1849 }
1850 else
1851 {
1852 name = "";
1853 }
1854 }
1855 else
1856 {
1857 name = fullname;
1858 }
1859 }
1860
1862 {
1863 BindingFlags bindingFlags = (isPublic ? BindingFlags.Public : BindingFlags.NonPublic);
1864 if (isInherited)
1865 {
1866 bindingFlags |= BindingFlags.DeclaredOnly;
1867 if (isStatic)
1868 {
1869 return bindingFlags | (BindingFlags.Static | BindingFlags.FlattenHierarchy);
1870 }
1871 return bindingFlags | BindingFlags.Instance;
1872 }
1873 if (isStatic)
1874 {
1875 return bindingFlags | BindingFlags.Static;
1876 }
1877 return bindingFlags | BindingFlags.Instance;
1878 }
1879
1881 {
1882 prefixLookup = false;
1883 ignoreCase = false;
1884 if (name != null)
1885 {
1886 if ((bindingFlags & BindingFlags.IgnoreCase) != 0)
1887 {
1888 name = name.ToLowerInvariant();
1889 ignoreCase = true;
1890 listType = MemberListType.CaseInsensitive;
1891 }
1892 else
1893 {
1894 listType = MemberListType.CaseSensitive;
1895 }
1896 if (allowPrefixLookup && name.EndsWith("*", StringComparison.Ordinal))
1897 {
1898 name = name[0..^1];
1899 prefixLookup = true;
1901 }
1902 }
1903 else
1904 {
1906 }
1907 }
1908
1913
1914 private static bool FilterApplyPrefixLookup(MemberInfo memberInfo, string name, bool ignoreCase)
1915 {
1916 if (ignoreCase)
1917 {
1918 if (!memberInfo.Name.StartsWith(name, StringComparison.OrdinalIgnoreCase))
1919 {
1920 return false;
1921 }
1922 }
1923 else if (!memberInfo.Name.StartsWith(name, StringComparison.Ordinal))
1924 {
1925 return false;
1926 }
1927 return true;
1928 }
1929
1931 {
1932 if (isPublic)
1933 {
1934 if ((bindingFlags & BindingFlags.Public) == 0)
1935 {
1936 return false;
1937 }
1938 }
1939 else if ((bindingFlags & BindingFlags.NonPublic) == 0)
1940 {
1941 return false;
1942 }
1943 bool flag = (object)memberInfo.DeclaringType != memberInfo.ReflectedType;
1944 if ((bindingFlags & BindingFlags.DeclaredOnly) != 0 && flag)
1945 {
1946 return false;
1947 }
1948 if (memberInfo.MemberType != MemberTypes.TypeInfo && memberInfo.MemberType != MemberTypes.NestedType)
1949 {
1950 if (isStatic)
1951 {
1952 if ((bindingFlags & BindingFlags.FlattenHierarchy) == 0 && flag)
1953 {
1954 return false;
1955 }
1956 if ((bindingFlags & BindingFlags.Static) == 0)
1957 {
1958 return false;
1959 }
1960 }
1961 else if ((bindingFlags & BindingFlags.Instance) == 0)
1962 {
1963 return false;
1964 }
1965 }
1966 if (prefixLookup && !FilterApplyPrefixLookup(memberInfo, name, (bindingFlags & BindingFlags.IgnoreCase) != 0))
1967 {
1968 return false;
1969 }
1970 if ((bindingFlags & BindingFlags.DeclaredOnly) == 0 && flag && isNonProtectedInternal && (bindingFlags & BindingFlags.NonPublic) != 0 && !isStatic && (bindingFlags & BindingFlags.Instance) != 0)
1971 {
1973 if (methodInfo == null)
1974 {
1975 return false;
1976 }
1977 if (!methodInfo.IsVirtual && !methodInfo.IsAbstract)
1978 {
1979 return false;
1980 }
1981 }
1982 return true;
1983 }
1984
1985 private static bool FilterApplyType(Type type, BindingFlags bindingFlags, string name, bool prefixLookup, string ns)
1986 {
1987 bool isPublic = type.IsNestedPublic || type.IsPublic;
1988 if (!FilterApplyBase(type, bindingFlags, isPublic, type.IsNestedAssembly, isStatic: false, name, prefixLookup))
1989 {
1990 return false;
1991 }
1992 if (ns != null && ns != type.Namespace)
1993 {
1994 return false;
1995 }
1996 return true;
1997 }
1998
2003
2008
2010 {
2011 bindingFlags ^= BindingFlags.DeclaredOnly;
2013 {
2014 return false;
2015 }
2016 if ((callConv & CallingConventions.Any) == 0)
2017 {
2018 if ((callConv & CallingConventions.VarArgs) != 0 && (methodBase.CallingConvention & CallingConventions.VarArgs) == 0)
2019 {
2020 return false;
2021 }
2022 if ((callConv & CallingConventions.Standard) != 0 && (methodBase.CallingConvention & CallingConventions.Standard) == 0)
2023 {
2024 return false;
2025 }
2026 }
2027 if (argumentTypes != null)
2028 {
2029 ParameterInfo[] parametersNoCopy = methodBase.GetParametersNoCopy();
2030 if (argumentTypes.Length != parametersNoCopy.Length)
2031 {
2032 if ((bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.CreateInstance | BindingFlags.GetProperty | BindingFlags.SetProperty)) == 0)
2033 {
2034 return false;
2035 }
2036 bool flag = false;
2037 if (argumentTypes.Length > parametersNoCopy.Length)
2038 {
2039 if ((methodBase.CallingConvention & CallingConventions.VarArgs) == 0)
2040 {
2041 flag = true;
2042 }
2043 }
2044 else if ((bindingFlags & BindingFlags.OptionalParamBinding) == 0)
2045 {
2046 flag = true;
2047 }
2048 else if (!parametersNoCopy[argumentTypes.Length].IsOptional)
2049 {
2050 flag = true;
2051 }
2052 if (flag)
2053 {
2054 if (parametersNoCopy.Length == 0)
2055 {
2056 return false;
2057 }
2058 if (argumentTypes.Length < parametersNoCopy.Length - 1)
2059 {
2060 return false;
2061 }
2063 if (!parameterInfo.ParameterType.IsArray)
2064 {
2065 return false;
2066 }
2067 if (!parameterInfo.IsDefined(typeof(ParamArrayAttribute), inherit: false))
2068 {
2069 return false;
2070 }
2071 }
2072 }
2073 else if ((bindingFlags & BindingFlags.ExactBinding) != 0 && (bindingFlags & BindingFlags.InvokeMethod) == 0)
2074 {
2075 for (int i = 0; i < parametersNoCopy.Length; i++)
2076 {
2077 Type type = argumentTypes[i];
2078 if ((object)type != null && !type.MatchesParameterTypeExactly(parametersNoCopy[i]))
2079 {
2080 return false;
2081 }
2082 }
2083 }
2084 }
2085 return true;
2086 }
2087
2088 internal RuntimeType()
2089 {
2090 throw new NotSupportedException();
2091 }
2092
2094 {
2095 return m_handle;
2096 }
2097
2098 internal override bool CacheEquals(object o)
2099 {
2101 {
2102 return runtimeType.m_handle == m_handle;
2103 }
2104 return false;
2105 }
2106
2107 [MethodImpl(MethodImplOptions.NoInlining)]
2132
2133 internal void ClearCache()
2134 {
2135 if (!(Volatile.Read(ref m_cache) == IntPtr.Zero))
2136 {
2138 }
2139 }
2140
2141 private string GetDefaultMemberName()
2142 {
2143 return Cache.GetDefaultMemberName();
2144 }
2145
2160
2175
2177 {
2179 RuntimePropertyInfo[] propertyList = Cache.GetPropertyList(listType, name);
2180 bindingAttr ^= BindingFlags.DeclaredOnly;
2183 {
2184 if ((bindingAttr & runtimePropertyInfo.BindingFlags) == runtimePropertyInfo.BindingFlags && (!prefixLookup || FilterApplyPrefixLookup(runtimePropertyInfo, name, ignoreCase)) && (types == null || runtimePropertyInfo.GetIndexParameters().Length == types.Length))
2185 {
2186 result.Add(runtimePropertyInfo);
2187 }
2188 }
2189 return result;
2190 }
2191
2193 {
2195 RuntimeEventInfo[] eventList = Cache.GetEventList(listType, name);
2196 bindingAttr ^= BindingFlags.DeclaredOnly;
2199 {
2201 {
2202 result.Add(runtimeEventInfo);
2203 }
2204 }
2205 return result;
2206 }
2207
2209 {
2211 RuntimeFieldInfo[] fieldList = Cache.GetFieldList(listType, name);
2212 bindingAttr ^= BindingFlags.DeclaredOnly;
2215 {
2217 {
2218 result.Add(runtimeFieldInfo);
2219 }
2220 }
2221 return result;
2222 }
2223
2225 {
2226 bindingAttr &= ~BindingFlags.Static;
2227 SplitName(fullname, out var name, out var ns);
2229 RuntimeType[] nestedTypeList = Cache.GetNestedTypeList(listType, name);
2232 {
2234 {
2235 result.Add(runtimeType);
2236 }
2237 }
2238 return result;
2239 }
2240
2243 {
2244 return GetMethodCandidates(null, -1, bindingAttr, CallingConventions.Any, null, allowPrefixLookup: false).ToArray();
2245 }
2246
2249 {
2250 return GetConstructorCandidates(null, bindingAttr, CallingConventions.Any, null, allowPrefixLookup: false).ToArray();
2251 }
2252
2255 {
2256 return GetPropertyCandidates(null, bindingAttr, null, allowPrefixLookup: false).ToArray();
2257 }
2258
2261 {
2262 return GetEventCandidates(null, bindingAttr, allowPrefixLookup: false).ToArray();
2263 }
2264
2267 {
2268 return GetFieldCandidates(null, bindingAttr, allowPrefixLookup: false).ToArray();
2269 }
2270
2272 public override Type[] GetInterfaces()
2273 {
2274 RuntimeType[] interfaceList = Cache.GetInterfaceList(MemberListType.All, null);
2276 return new ReadOnlySpan<Type>(array).ToArray();
2277 }
2278
2281 {
2282 return GetNestedTypeCandidates(null, bindingAttr, allowPrefixLookup: false).ToArray();
2283 }
2284
2287 {
2294 MemberInfo[] array = new MemberInfo[methodCandidates.Count + constructorCandidates.Count + propertyCandidates.Count + eventCandidates.Count + fieldCandidates.Count + nestedTypeCandidates.Count];
2295 int num = 0;
2296 object[] array2 = array;
2298 num += methodCandidates.Count;
2299 array2 = array;
2302 array2 = array;
2305 array2 = array;
2307 num += eventCandidates.Count;
2308 array2 = array;
2310 num += fieldCandidates.Count;
2311 array2 = array;
2314 return array;
2315 }
2316
2318 {
2320 {
2322 }
2323 if ((object)ifaceType == null)
2324 {
2325 throw new ArgumentNullException("ifaceType");
2326 }
2328 if (runtimeType == null)
2329 {
2330 throw new ArgumentException(SR.Argument_MustBeRuntimeType, "ifaceType");
2331 }
2332 RuntimeTypeHandle typeHandleInternal = runtimeType.GetTypeHandleInternal();
2333 GetTypeHandleInternal().VerifyInterfaceIsImplemented(typeHandleInternal);
2334 if (IsSZArray && ifaceType.IsGenericType)
2335 {
2337 }
2340 result.InterfaceType = ifaceType;
2341 result.TargetType = this;
2342 result.InterfaceMethods = new MethodInfo[numVirtualsAndStaticVirtuals];
2343 result.TargetMethods = new MethodInfo[numVirtualsAndStaticVirtuals];
2344 for (int i = 0; i < numVirtualsAndStaticVirtuals; i++)
2345 {
2348 result.InterfaceMethods[i] = (MethodInfo)methodBase;
2350 if (!interfaceMethodImplementation.IsNullHandle())
2351 {
2353 if (!runtimeType2.IsInterface)
2354 {
2355 runtimeType2 = this;
2356 }
2358 result.TargetMethods[i] = (MethodInfo)methodBase2;
2359 }
2360 }
2361 return result;
2362 }
2363
2369
2375
2377 {
2379 if (methodCandidates.Count == 0)
2380 {
2381 return null;
2382 }
2383 MethodBase[] match;
2384 if (types == null || types.Length == 0)
2385 {
2387 if (methodCandidates.Count == 1)
2388 {
2389 return methodInfo;
2390 }
2391 if (types == null)
2392 {
2393 for (int i = 1; i < methodCandidates.Count; i++)
2394 {
2397 {
2399 }
2400 }
2401 match = methodCandidates.ToArray();
2403 }
2404 }
2405 if (binder == null)
2406 {
2408 }
2410 match = methodCandidates.ToArray();
2411 return binder2.SelectMethod(bindingAttr, match, types, modifiers) as MethodInfo;
2412 }
2413
2416 {
2419 {
2420 return null;
2421 }
2422 if (types.Length == 0 && constructorCandidates.Count == 1)
2423 {
2425 ParameterInfo[] parametersNoCopy = constructorInfo.GetParametersNoCopy();
2426 if (parametersNoCopy == null || parametersNoCopy.Length == 0)
2427 {
2428 return constructorInfo;
2429 }
2430 }
2431 MethodBase[] match;
2432 if ((bindingAttr & BindingFlags.ExactBinding) != 0)
2433 {
2434 match = constructorCandidates.ToArray();
2436 }
2437 if (binder == null)
2438 {
2440 }
2442 match = constructorCandidates.ToArray();
2443 return binder2.SelectMethod(bindingAttr, match, types, modifiers) as ConstructorInfo;
2444 }
2445
2448 {
2449 if (name == null)
2450 {
2451 throw new ArgumentNullException("name");
2452 }
2454 if (propertyCandidates.Count == 0)
2455 {
2456 return null;
2457 }
2458 if (types == null || types.Length == 0)
2459 {
2460 if (propertyCandidates.Count == 1)
2461 {
2462 PropertyInfo propertyInfo = propertyCandidates[0];
2463 if ((object)returnType != null && !returnType.IsEquivalentTo(propertyInfo.PropertyType))
2464 {
2465 return null;
2466 }
2467 return propertyInfo;
2468 }
2469 if ((object)returnType == null)
2470 {
2472 }
2473 }
2474 if ((bindingAttr & BindingFlags.ExactBinding) != 0)
2475 {
2477 }
2478 if (binder == null)
2479 {
2481 }
2482 return binder.SelectProperty(bindingAttr, propertyCandidates.ToArray(), returnType, types, modifiers);
2483 }
2484
2486 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
2487 {
2488 if (name == null)
2489 {
2490 throw new ArgumentNullException("name");
2491 }
2493 RuntimeEventInfo[] eventList = Cache.GetEventList(listType, name);
2494 EventInfo eventInfo = null;
2495 bindingAttr ^= BindingFlags.DeclaredOnly;
2497 {
2498 if ((bindingAttr & runtimeEventInfo.BindingFlags) == runtimeEventInfo.BindingFlags)
2499 {
2500 if (eventInfo != null)
2501 {
2503 }
2505 }
2506 }
2507 return eventInfo;
2508 }
2509
2511 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
2512 {
2513 if (name == null)
2514 {
2515 throw new ArgumentNullException();
2516 }
2518 RuntimeFieldInfo[] fieldList = Cache.GetFieldList(listType, name);
2519 FieldInfo fieldInfo = null;
2520 bindingAttr ^= BindingFlags.DeclaredOnly;
2521 bool flag = false;
2523 {
2524 if ((bindingAttr & runtimeFieldInfo.BindingFlags) != runtimeFieldInfo.BindingFlags)
2525 {
2526 continue;
2527 }
2528 if (fieldInfo != null)
2529 {
2530 if ((object)runtimeFieldInfo.DeclaringType == fieldInfo.DeclaringType)
2531 {
2533 }
2534 if (fieldInfo.DeclaringType.IsInterface && runtimeFieldInfo.DeclaringType.IsInterface)
2535 {
2536 flag = true;
2537 }
2538 }
2539 if (fieldInfo == null || runtimeFieldInfo.DeclaringType.IsSubclassOf(fieldInfo.DeclaringType) || fieldInfo.DeclaringType.IsInterface)
2540 {
2542 }
2543 }
2544 if (flag && fieldInfo.DeclaringType.IsInterface)
2545 {
2547 }
2548 return fieldInfo;
2549 }
2550
2553 public override Type GetInterface(string fullname, bool ignoreCase)
2554 {
2555 if (fullname == null)
2556 {
2557 throw new ArgumentNullException("fullname");
2558 }
2559 BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic;
2560 bindingFlags &= ~BindingFlags.Static;
2561 if (ignoreCase)
2562 {
2563 bindingFlags |= BindingFlags.IgnoreCase;
2564 }
2565 SplitName(fullname, out var name, out var ns);
2567 RuntimeType[] interfaceList = Cache.GetInterfaceList(listType, name);
2568 RuntimeType runtimeType = null;
2570 {
2571 if (FilterApplyType(runtimeType2, bindingFlags, name, prefixLookup: false, ns))
2572 {
2573 if (runtimeType != null)
2574 {
2576 }
2578 }
2579 }
2580 return runtimeType;
2581 }
2582
2585 {
2586 if (fullname == null)
2587 {
2588 throw new ArgumentNullException("fullname");
2589 }
2590 bindingAttr &= ~BindingFlags.Static;
2591 SplitName(fullname, out var name, out var ns);
2593 RuntimeType[] nestedTypeList = Cache.GetNestedTypeList(listType, name);
2594 RuntimeType runtimeType = null;
2596 {
2597 if (FilterApplyType(runtimeType2, bindingAttr, name, prefixLookup: false, ns))
2598 {
2599 if (runtimeType != null)
2600 {
2602 }
2604 }
2605 }
2606 return runtimeType;
2607 }
2608
2611 {
2612 if (name == null)
2613 {
2614 throw new ArgumentNullException("name");
2615 }
2622 int num = 0;
2623 if ((type & MemberTypes.Method) != 0)
2624 {
2626 if (type == MemberTypes.Method)
2627 {
2628 return listBuilder.ToArray();
2629 }
2630 num += listBuilder.Count;
2631 }
2632 if ((type & MemberTypes.Constructor) != 0)
2633 {
2635 if (type == MemberTypes.Constructor)
2636 {
2637 return listBuilder2.ToArray();
2638 }
2639 num += listBuilder2.Count;
2640 }
2641 if ((type & MemberTypes.Property) != 0)
2642 {
2644 if (type == MemberTypes.Property)
2645 {
2646 return listBuilder3.ToArray();
2647 }
2648 num += listBuilder3.Count;
2649 }
2650 if ((type & MemberTypes.Event) != 0)
2651 {
2653 if (type == MemberTypes.Event)
2654 {
2655 return listBuilder4.ToArray();
2656 }
2657 num += listBuilder4.Count;
2658 }
2659 if ((type & MemberTypes.Field) != 0)
2660 {
2662 if (type == MemberTypes.Field)
2663 {
2664 return listBuilder5.ToArray();
2665 }
2666 num += listBuilder5.Count;
2667 }
2668 if ((type & (MemberTypes.TypeInfo | MemberTypes.NestedType)) != 0)
2669 {
2671 if (type == MemberTypes.NestedType || type == MemberTypes.TypeInfo)
2672 {
2673 return listBuilder6.ToArray();
2674 }
2675 num += listBuilder6.Count;
2676 }
2677 MemberInfo[] array;
2678 if (type != (MemberTypes.Constructor | MemberTypes.Method))
2679 {
2680 array = new MemberInfo[num];
2681 }
2682 else
2683 {
2684 MemberInfo[] array2 = new MethodBase[num];
2685 array = array2;
2686 }
2688 int num2 = 0;
2689 object[] array4 = array3;
2692 array4 = array3;
2695 array4 = array3;
2698 array4 = array3;
2701 array4 = array3;
2704 array4 = array3;
2707 return array3;
2708 }
2709
2711 {
2712 if ((object)member == null)
2713 {
2714 throw new ArgumentNullException("member");
2715 }
2716 RuntimeType runtimeType = this;
2717 while (runtimeType != null)
2718 {
2719 MemberInfo memberInfo = member.MemberType switch
2720 {
2721 MemberTypes.Method => GetMethodWithSameMetadataDefinitionAs(runtimeType, member),
2722 MemberTypes.Constructor => GetConstructorWithSameMetadataDefinitionAs(runtimeType, member),
2723 MemberTypes.Property => GetPropertyWithSameMetadataDefinitionAs(runtimeType, member),
2724 MemberTypes.Field => GetFieldWithSameMetadataDefinitionAs(runtimeType, member),
2725 MemberTypes.Event => GetEventWithSameMetadataDefinitionAs(runtimeType, member),
2726 MemberTypes.NestedType => GetNestedTypeWithSameMetadataDefinitionAs(runtimeType, member),
2727 _ => null,
2728 };
2729 if (memberInfo != null)
2730 {
2731 return memberInfo;
2732 }
2733 runtimeType = runtimeType.GetBaseType();
2734 }
2736 }
2737
2739 {
2740 RuntimeMethodInfo[] methodList = runtimeType.Cache.GetMethodList(MemberListType.CaseSensitive, method.Name);
2742 {
2743 if (runtimeMethodInfo.HasSameMetadataDefinitionAs(method))
2744 {
2745 return runtimeMethodInfo;
2746 }
2747 }
2748 return null;
2749 }
2750
2752 {
2753 RuntimeConstructorInfo[] constructorList = runtimeType.Cache.GetConstructorList(MemberListType.CaseSensitive, constructor.Name);
2755 {
2756 if (runtimeConstructorInfo.HasSameMetadataDefinitionAs(constructor))
2757 {
2759 }
2760 }
2761 return null;
2762 }
2763
2765 {
2766 RuntimePropertyInfo[] propertyList = runtimeType.Cache.GetPropertyList(MemberListType.CaseSensitive, property.Name);
2768 {
2769 if (runtimePropertyInfo.HasSameMetadataDefinitionAs(property))
2770 {
2771 return runtimePropertyInfo;
2772 }
2773 }
2774 return null;
2775 }
2776
2778 {
2779 RuntimeFieldInfo[] fieldList = runtimeType.Cache.GetFieldList(MemberListType.CaseSensitive, field.Name);
2781 {
2782 if (runtimeFieldInfo.HasSameMetadataDefinitionAs(field))
2783 {
2784 return runtimeFieldInfo;
2785 }
2786 }
2787 return null;
2788 }
2789
2791 {
2792 RuntimeEventInfo[] eventList = runtimeType.Cache.GetEventList(MemberListType.CaseSensitive, eventInfo.Name);
2794 {
2795 if (runtimeEventInfo.HasSameMetadataDefinitionAs(eventInfo))
2796 {
2797 return runtimeEventInfo;
2798 }
2799 }
2800 return null;
2801 }
2802
2804 {
2805 RuntimeType[] nestedTypeList = runtimeType.Cache.GetNestedTypeList(MemberListType.CaseSensitive, nestedType.Name);
2807 {
2808 if (runtimeType2.HasSameMetadataDefinitionAs(nestedType))
2809 {
2810 return runtimeType2;
2811 }
2812 }
2813 return null;
2814 }
2815
2816 public override bool IsSubclassOf(Type type)
2817 {
2818 if ((object)type == null)
2819 {
2820 throw new ArgumentNullException("type");
2821 }
2823 if (runtimeType == null)
2824 {
2825 return false;
2826 }
2828 while (baseType != null)
2829 {
2830 if (baseType == runtimeType)
2831 {
2832 return true;
2833 }
2834 baseType = baseType.GetBaseType();
2835 }
2836 if (runtimeType == ObjectType && runtimeType != this)
2837 {
2838 return true;
2839 }
2840 return false;
2841 }
2842
2843 public override bool IsEquivalentTo([NotNullWhen(true)] Type other)
2844 {
2846 {
2847 return false;
2848 }
2849 if (runtimeType == this)
2850 {
2851 return true;
2852 }
2854 }
2855
2856 [MethodImpl(MethodImplOptions.InternalCall)]
2857 private extern void GetGUID(ref Guid result);
2858
2859 internal bool IsDelegate()
2860 {
2862 }
2863
2864 internal object[] GetEmptyArray()
2865 {
2866 return Cache.GetEmptyArray();
2867 }
2868
2870 {
2871 return GetRootElementType().GetTypeHandleInternal().GetInstantiationInternal();
2872 }
2873
2874 public override Type[] GetGenericArguments()
2875 {
2876 Type[] instantiationPublic = GetRootElementType().GetTypeHandleInternal().GetInstantiationPublic();
2878 }
2879
2880 [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.")]
2882 {
2883 if (instantiation == null)
2884 {
2885 throw new ArgumentNullException("instantiation");
2886 }
2888 {
2890 }
2892 if (genericArgumentsInternal.Length != instantiation.Length)
2893 {
2894 throw new ArgumentException(SR.Argument_GenericArgsCount, "instantiation");
2895 }
2897 {
2899 try
2900 {
2901 return new RuntimeTypeHandle(this).Instantiate(runtimeType);
2902 }
2903 catch (TypeLoadException e)
2904 {
2906 throw;
2907 }
2908 }
2910 bool flag = false;
2911 bool flag2 = false;
2912 for (int i = 0; i < instantiation.Length; i++)
2913 {
2914 Type type = instantiation[i];
2915 if (type == null)
2916 {
2917 throw new ArgumentNullException();
2918 }
2920 if (runtimeType2 == null)
2921 {
2922 flag2 = true;
2923 if (type.IsSignatureType)
2924 {
2925 flag = true;
2926 }
2927 }
2928 array[i] = runtimeType2;
2929 }
2930 if (flag2)
2931 {
2932 if (flag)
2933 {
2935 }
2937 }
2939 try
2940 {
2942 Type[] inst = array;
2943 return runtimeTypeHandle.Instantiate(inst);
2944 }
2945 catch (TypeLoadException e2)
2946 {
2948 throw;
2949 }
2950 }
2951
2953 {
2954 if (!IsGenericParameter)
2955 {
2957 }
2959 return constraints ?? Type.EmptyTypes;
2960 }
2961
2966
2967 public override Type MakePointerType()
2968 {
2969 return new RuntimeTypeHandle(this).MakePointer();
2970 }
2971
2972 public override Type MakeByRefType()
2973 {
2974 return new RuntimeTypeHandle(this).MakeByRef();
2975 }
2976
2977 public override Type MakeArrayType()
2978 {
2979 return new RuntimeTypeHandle(this).MakeSZArray();
2980 }
2981
2982 public override Type MakeArrayType(int rank)
2983 {
2984 if (rank <= 0)
2985 {
2986 throw new IndexOutOfRangeException();
2987 }
2988 return new RuntimeTypeHandle(this).MakeArray(rank);
2989 }
2990
2991 [MethodImpl(MethodImplOptions.InternalCall)]
2993
2994 [MethodImpl(MethodImplOptions.InternalCall)]
2995 private static extern object AllocateValueType(RuntimeType type, object value, bool fForceTypeChange);
2996
2998 {
3000 {
3001 Type type = value.GetType();
3002 if ((object)type != this && RuntimeTypeHandle.IsValueType(this))
3003 {
3004 return AllocateValueType(this, value, fForceTypeChange: true);
3005 }
3006 return value;
3007 }
3008 if (base.IsByRef)
3009 {
3011 if (elementType.IsInstanceOfType(value) || value == null)
3012 {
3014 }
3015 }
3016 else
3017 {
3018 if (value == null)
3019 {
3020 return value;
3021 }
3022 if (this == s_typedRef)
3023 {
3024 return value;
3025 }
3026 }
3027 bool flag = base.IsPointer || IsEnum || base.IsPrimitive;
3028 if (flag)
3029 {
3031 RuntimeType valueType = ((pointer == null) ? ((RuntimeType)value.GetType()) : ((RuntimeType)pointer.GetPointerType()));
3032 if (CanValueSpecialCast(valueType, this))
3033 {
3034 if (pointer != null)
3035 {
3036 return pointer.GetPointerValue();
3037 }
3038 return value;
3039 }
3040 }
3041 if ((invokeAttr & BindingFlags.ExactBinding) == BindingFlags.ExactBinding)
3042 {
3043 throw new ArgumentException(SR.Format(SR.Arg_ObjObjEx, value.GetType(), this));
3044 }
3045 return TryChangeType(value, binder, culture, flag);
3046 }
3047
3049 {
3050 if (binder != null && binder != Type.DefaultBinder)
3051 {
3052 value = binder.ChangeType(value, this, culture);
3054 {
3055 return value;
3056 }
3057 if (base.IsByRef)
3058 {
3060 if (elementType.IsInstanceOfType(value) || value == null)
3061 {
3063 }
3064 }
3065 else if (value == null)
3066 {
3067 return value;
3068 }
3069 if (needsSpecialCast)
3070 {
3072 RuntimeType valueType = ((pointer == null) ? ((RuntimeType)value.GetType()) : ((RuntimeType)pointer.GetPointerType()));
3073 if (CanValueSpecialCast(valueType, this))
3074 {
3075 if (pointer != null)
3076 {
3077 return pointer.GetPointerValue();
3078 }
3079 return value;
3080 }
3081 }
3082 }
3083 throw new ArgumentException(SR.Format(SR.Arg_ObjObjEx, value.GetType(), this));
3084 }
3085
3086 public override string ToString()
3087 {
3088 return GetCachedName(TypeNameKind.ToString);
3089 }
3090
3091 [MethodImpl(MethodImplOptions.NoInlining)]
3092 private string GetCachedName(TypeNameKind kind)
3093 {
3094 return Cache.GetName(kind);
3095 }
3096
3098 {
3100 {
3102 }
3104 if ((object)rootElementType == typeof(ArgIterator))
3105 {
3107 }
3108 if ((object)rootElementType == typeof(void))
3109 {
3111 }
3112 }
3113
3114 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2082:UnrecognizedReflectionPattern", Justification = "Implementation detail of Activator that linker intrinsically recognizes")]
3115 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2085:UnrecognizedReflectionPattern", Justification = "Implementation detail of Activator that linker intrinsically recognizes")]
3117 {
3119 if (args == null)
3120 {
3121 args = Array.Empty<object>();
3122 }
3123 if (binder == null)
3124 {
3126 }
3127 bool publicOnly = (bindingAttr & BindingFlags.NonPublic) == 0;
3128 bool wrapExceptions = (bindingAttr & BindingFlags.DoNotWrapExceptions) == 0;
3129 object result;
3130 if (args.Length == 0 && (bindingAttr & BindingFlags.Public) != 0 && (bindingAttr & BindingFlags.Instance) != 0 && (IsGenericCOMObjectImpl() || base.IsValueType))
3131 {
3133 }
3134 else
3135 {
3138 Type[] array = new Type[args.Length];
3139 for (int i = 0; i < args.Length; i++)
3140 {
3141 object obj = args[i];
3142 if (obj != null)
3143 {
3144 array[i] = obj.GetType();
3145 }
3146 }
3147 for (int j = 0; j < constructors.Length; j++)
3148 {
3150 {
3152 }
3153 }
3154 if (list.Count == 0)
3155 {
3157 }
3158 MethodBase[] match = list.ToArray();
3159 object state = null;
3161 try
3162 {
3163 methodBase = binder.BindToMethod(bindingAttr, match, ref args, null, culture, null, out state);
3164 }
3166 {
3167 methodBase = null;
3168 }
3169 if ((object)methodBase == null)
3170 {
3172 }
3173 if (methodBase.GetParametersNoCopy().Length == 0)
3174 {
3175 if (args.Length != 0)
3176 {
3178 }
3179 result = Activator.CreateInstance(this, nonPublic: true, wrapExceptions);
3180 }
3181 else
3182 {
3184 if (state != null)
3185 {
3186 binder.ReorderArgumentArray(ref args, state);
3187 }
3188 }
3189 }
3190 return result;
3191 }
3192
3194 [DebuggerHidden]
3196 {
3198 if (activatorCache == null)
3199 {
3201 }
3202 if (!activatorCache.CtorIsPublic && publicOnly)
3203 {
3205 }
3206 object obj = activatorCache.CreateUninitializedObject(this);
3207 try
3208 {
3209 activatorCache.CallConstructor(obj);
3210 return obj;
3211 }
3212 catch (Exception inner) when (wrapExceptions)
3213 {
3214 throw new TargetInvocationException(inner);
3215 }
3216 }
3217
3219 [DebuggerHidden]
3220 internal object CreateInstanceOfT()
3221 {
3223 if (activatorCache == null)
3224 {
3226 }
3227 if (!activatorCache.CtorIsPublic)
3228 {
3230 }
3231 object obj = activatorCache.CreateUninitializedObject(this);
3232 try
3233 {
3234 activatorCache.CallConstructor(obj);
3235 return obj;
3236 }
3237 catch (Exception inner)
3238 {
3239 throw new TargetInvocationException(inner);
3240 }
3241 }
3242
3244 {
3245 Cache.InvalidateCachedNestedType();
3246 }
3247
3249 {
3250 return RuntimeTypeHandle.IsComObject(this, isGenericCOM: true);
3251 }
3252
3253 [MethodImpl(MethodImplOptions.InternalCall)]
3254 private static extern object _CreateEnum(RuntimeType enumType, long value);
3255
3256 internal static object CreateEnum(RuntimeType enumType, long value)
3257 {
3258 return _CreateEnum(enumType, value);
3259 }
3260
3261 [MethodImpl(MethodImplOptions.InternalCall)]
3262 private extern object InvokeDispMethod(string name, BindingFlags invokeAttr, object target, object[] args, bool[] byrefModifiers, int culture, string[] namedParameters);
3263
3264 [RequiresUnreferencedCode("The member might be removed")]
3265 private object ForwardCallToInvokeMember(string memberName, BindingFlags flags, object target, object[] aArgs, bool[] aArgsIsByRef, int[] aArgsWrapperTypes, Type[] aArgsTypes, Type retType)
3266 {
3268 {
3270 }
3271 int num = aArgs.Length;
3272 ParameterModifier[] array = null;
3273 if (num > 0)
3274 {
3276 for (int i = 0; i < num; i++)
3277 {
3279 }
3281 if (aArgsWrapperTypes != null)
3282 {
3284 }
3285 }
3286 flags |= BindingFlags.DoNotWrapExceptions;
3287 object obj = InvokeMember(memberName, flags, null, target, aArgs, array, null, null);
3288 for (int j = 0; j < num; j++)
3289 {
3290 if (array[0][j] && aArgs[j] != null)
3291 {
3292 Type type = aArgsTypes[j];
3293 if ((object)type != aArgs[j].GetType())
3294 {
3295 aArgs[j] = ForwardCallBinder.ChangeType(aArgs[j], type, null);
3296 }
3297 }
3298 }
3299 if (obj != null && (object)retType != obj.GetType())
3300 {
3301 obj = ForwardCallBinder.ChangeType(obj, retType, null);
3302 }
3303 return obj;
3304 }
3305
3306 private static void WrapArgsForInvokeCall(object[] aArgs, int[] aArgsWrapperTypes)
3307 {
3308 int num = aArgs.Length;
3309 for (int i = 0; i < num; i++)
3310 {
3311 if (aArgsWrapperTypes[i] == 0)
3312 {
3313 continue;
3314 }
3315 if (((DispatchWrapperType)aArgsWrapperTypes[i]).HasFlag(DispatchWrapperType.SafeArray))
3316 {
3317 Type type = null;
3318 bool flag = false;
3319 switch ((DispatchWrapperType)(aArgsWrapperTypes[i] & -65537))
3320 {
3321 case DispatchWrapperType.Unknown:
3323 break;
3324 case DispatchWrapperType.Dispatch:
3326 break;
3327 case DispatchWrapperType.Error:
3329 break;
3330 case DispatchWrapperType.Currency:
3332 break;
3333 case DispatchWrapperType.BStr:
3335 flag = true;
3336 break;
3337 }
3338 Array array = (Array)aArgs[i];
3339 int length = array.Length;
3340 object[] array2 = (object[])Array.CreateInstance(type, length);
3341 ConstructorInfo constructorInfo = ((!flag) ? type.GetConstructor(new Type[1] { typeof(object) }) : type.GetConstructor(new Type[1] { typeof(string) }));
3342 for (int j = 0; j < length; j++)
3343 {
3344 if (flag)
3345 {
3346 array2[j] = constructorInfo.Invoke(new object[1] { (string)array.GetValue(j) });
3347 }
3348 else
3349 {
3350 array2[j] = constructorInfo.Invoke(new object[1] { array.GetValue(j) });
3351 }
3352 }
3353 aArgs[i] = array2;
3354 }
3355 else
3356 {
3358 {
3359 case DispatchWrapperType.Unknown:
3360 aArgs[i] = new UnknownWrapper(aArgs[i]);
3361 break;
3362 case DispatchWrapperType.Dispatch:
3363 aArgs[i] = new DispatchWrapper(aArgs[i]);
3364 break;
3365 case DispatchWrapperType.Error:
3366 aArgs[i] = new ErrorWrapper(aArgs[i]);
3367 break;
3368 case DispatchWrapperType.Currency:
3369 aArgs[i] = new CurrencyWrapper(aArgs[i]);
3370 break;
3371 case DispatchWrapperType.BStr:
3372 aArgs[i] = new BStrWrapper((string)aArgs[i]);
3373 break;
3374 }
3375 }
3376 }
3377 }
3378
3379 public object Clone()
3380 {
3381 return this;
3382 }
3383
3384 public override bool Equals(object obj)
3385 {
3386 return obj == this;
3387 }
3388
3389 public override int GetArrayRank()
3390 {
3391 if (!IsArrayImpl())
3392 {
3394 }
3395 return RuntimeTypeHandle.GetArrayRank(this);
3396 }
3397
3399 {
3400 return RuntimeTypeHandle.GetAttributes(this);
3401 }
3402
3403 public override object[] GetCustomAttributes(bool inherit)
3404 {
3405 return CustomAttribute.GetCustomAttributes(this, ObjectType, inherit);
3406 }
3407
3408 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
3409 {
3410 if ((object)attributeType == null)
3411 {
3412 throw new ArgumentNullException("attributeType");
3413 }
3414 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
3415 if (runtimeType == null)
3416 {
3417 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
3418 }
3420 }
3421
3426
3428 public override MemberInfo[] GetDefaultMembers()
3429 {
3430 MemberInfo[] array = null;
3431 string defaultMemberName = GetDefaultMemberName();
3432 if (defaultMemberName != null)
3433 {
3434 array = GetMember(defaultMemberName);
3435 }
3436 return array ?? Array.Empty<MemberInfo>();
3437 }
3438
3439 public override Type GetElementType()
3440 {
3441 return RuntimeTypeHandle.GetElementType(this);
3442 }
3443
3444 public override string GetEnumName(object value)
3445 {
3446 if (value == null)
3447 {
3448 throw new ArgumentNullException("value");
3449 }
3450 Type type = value.GetType();
3451 if (!type.IsEnum && !Type.IsIntegerType(type))
3452 {
3454 }
3455 ulong ulValue = Enum.ToUInt64(value);
3456 return Enum.GetEnumName(this, ulValue);
3457 }
3458
3459 public override string[] GetEnumNames()
3460 {
3461 if (!IsEnum)
3462 {
3463 throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
3464 }
3465 string[] array = Enum.InternalGetNames(this);
3466 return new ReadOnlySpan<string>(array).ToArray();
3467 }
3468
3469 public override Array GetEnumValues()
3470 {
3471 if (!IsEnum)
3472 {
3473 throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
3474 }
3475 ulong[] array = Enum.InternalGetValues(this);
3476 Array array2 = Array.CreateInstance(this, array.Length);
3477 for (int i = 0; i < array.Length; i++)
3478 {
3479 object value = Enum.ToObject(this, array[i]);
3480 array2.SetValue(value, i);
3481 }
3482 return array2;
3483 }
3484
3485 public override Type GetEnumUnderlyingType()
3486 {
3487 if (!IsEnum)
3488 {
3489 throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
3490 }
3491 return Enum.InternalGetUnderlyingType(this);
3492 }
3493
3495 {
3496 if (!IsGenericType)
3497 {
3499 }
3501 }
3502
3503 public override int GetHashCode()
3504 {
3505 return RuntimeHelpers.GetHashCode(this);
3506 }
3507
3509 {
3510 return RuntimeTypeHandle.GetModule(this);
3511 }
3512
3513 protected override TypeCode GetTypeCodeImpl()
3514 {
3515 TypeCode typeCode = Cache.TypeCode;
3516 if (typeCode != 0)
3517 {
3518 return typeCode;
3519 }
3520 typeCode = RuntimeTypeHandle.GetCorElementType(this) switch
3521 {
3522 CorElementType.ELEMENT_TYPE_BOOLEAN => TypeCode.Boolean,
3523 CorElementType.ELEMENT_TYPE_CHAR => TypeCode.Char,
3524 CorElementType.ELEMENT_TYPE_I1 => TypeCode.SByte,
3525 CorElementType.ELEMENT_TYPE_U1 => TypeCode.Byte,
3526 CorElementType.ELEMENT_TYPE_I2 => TypeCode.Int16,
3527 CorElementType.ELEMENT_TYPE_U2 => TypeCode.UInt16,
3528 CorElementType.ELEMENT_TYPE_I4 => TypeCode.Int32,
3529 CorElementType.ELEMENT_TYPE_U4 => TypeCode.UInt32,
3530 CorElementType.ELEMENT_TYPE_I8 => TypeCode.Int64,
3531 CorElementType.ELEMENT_TYPE_U8 => TypeCode.UInt64,
3532 CorElementType.ELEMENT_TYPE_R4 => TypeCode.Single,
3533 CorElementType.ELEMENT_TYPE_R8 => TypeCode.Double,
3534 CorElementType.ELEMENT_TYPE_VALUETYPE => ((object)this != typeof(decimal)) ? (((object)this != typeof(DateTime)) ? ((!IsEnum) ? TypeCode.Object : Type.GetTypeCode(Enum.InternalGetUnderlyingType(this))) : TypeCode.DateTime) : TypeCode.Decimal,
3535 _ => ((object)this != typeof(string)) ? (((object)this != typeof(DBNull)) ? TypeCode.Object : TypeCode.DBNull) : TypeCode.String,
3536 };
3537 Cache.TypeCode = typeCode;
3538 return typeCode;
3539 }
3540
3541 protected override bool HasElementTypeImpl()
3542 {
3543 return RuntimeTypeHandle.HasElementType(this);
3544 }
3545
3546 protected override bool IsArrayImpl()
3547 {
3548 return RuntimeTypeHandle.IsArray(this);
3549 }
3550
3551 protected override bool IsContextfulImpl()
3552 {
3553 return false;
3554 }
3555
3556 public override bool IsDefined(Type attributeType, bool inherit)
3557 {
3558 if ((object)attributeType == null)
3559 {
3560 throw new ArgumentNullException("attributeType");
3561 }
3562 RuntimeType runtimeType = attributeType.UnderlyingSystemType as RuntimeType;
3563 if (runtimeType == null)
3564 {
3565 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
3566 }
3568 }
3569
3570 public override bool IsEnumDefined(object value)
3571 {
3572 if (value == null)
3573 {
3574 throw new ArgumentNullException("value");
3575 }
3576 if (!IsEnum)
3577 {
3578 throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
3579 }
3581 if (runtimeType.IsEnum)
3582 {
3583 if (!runtimeType.IsEquivalentTo(this))
3584 {
3586 }
3587 runtimeType = (RuntimeType)runtimeType.GetEnumUnderlyingType();
3588 }
3589 if (runtimeType == StringType)
3590 {
3591 string[] array = Enum.InternalGetNames(this);
3592 object[] array2 = array;
3593 return Array.IndexOf(array2, value) >= 0;
3594 }
3596 {
3599 {
3601 }
3602 ulong[] array3 = Enum.InternalGetValues(this);
3603 ulong value2 = Enum.ToUInt64(value);
3604 return Array.BinarySearch(array3, value2) >= 0;
3605 }
3607 }
3608
3609 protected override bool IsValueTypeImpl()
3610 {
3611 if (this == typeof(ValueType) || this == typeof(Enum))
3612 {
3613 return false;
3614 }
3615 return IsSubclassOf(typeof(ValueType));
3616 }
3617
3618 protected override bool IsByRefImpl()
3619 {
3620 return RuntimeTypeHandle.IsByRef(this);
3621 }
3622
3623 protected override bool IsPrimitiveImpl()
3624 {
3625 return RuntimeTypeHandle.IsPrimitive(this);
3626 }
3627
3628 protected override bool IsPointerImpl()
3629 {
3630 return RuntimeTypeHandle.IsPointer(this);
3631 }
3632
3633 protected override bool IsCOMObjectImpl()
3634 {
3635 return RuntimeTypeHandle.IsComObject(this, isGenericCOM: false);
3636 }
3637
3638 public override bool IsInstanceOfType([NotNullWhen(true)] object o)
3639 {
3640 return RuntimeTypeHandle.IsInstanceOfType(this, o);
3641 }
3642
3643 public override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo typeInfo)
3644 {
3645 if (typeInfo == null)
3646 {
3647 return false;
3648 }
3649 return IsAssignableFrom(typeInfo.AsType());
3650 }
3651
3652 public override bool IsAssignableFrom([NotNullWhen(true)] Type c)
3653 {
3654 if ((object)c == null)
3655 {
3656 return false;
3657 }
3658 if ((object)c == this)
3659 {
3660 return true;
3661 }
3663 {
3664 return RuntimeTypeHandle.CanCastTo(type, this);
3665 }
3666 if (c is TypeBuilder)
3667 {
3668 if (c.IsSubclassOf(this))
3669 {
3670 return true;
3671 }
3672 if (base.IsInterface)
3673 {
3674 return c.ImplementInterface(this);
3675 }
3676 if (IsGenericParameter)
3677 {
3678 Type[] genericParameterConstraints = GetGenericParameterConstraints();
3679 for (int i = 0; i < genericParameterConstraints.Length; i++)
3680 {
3681 if (!genericParameterConstraints[i].IsAssignableFrom(c))
3682 {
3683 return false;
3684 }
3685 }
3686 return true;
3687 }
3688 }
3689 return false;
3690 }
3691
3693 [DebuggerHidden]
3695 public override object InvokeMember(string name, BindingFlags bindingFlags, Binder binder, object target, object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParams)
3696 {
3697 if (IsGenericParameter)
3698 {
3700 }
3701 if ((bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.CreateInstance | BindingFlags.GetField | BindingFlags.SetField | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) == 0)
3702 {
3703 throw new ArgumentException(SR.Arg_NoAccessSpec, "bindingFlags");
3704 }
3705 if ((bindingFlags & (BindingFlags)255) == 0)
3706 {
3707 bindingFlags |= BindingFlags.Instance | BindingFlags.Public;
3708 if ((bindingFlags & BindingFlags.CreateInstance) == 0)
3709 {
3710 bindingFlags |= BindingFlags.Static;
3711 }
3712 }
3713 if (namedParams != null)
3714 {
3715 if (providedArgs != null)
3716 {
3717 if (namedParams.Length > providedArgs.Length)
3718 {
3719 throw new ArgumentException(SR.Arg_NamedParamTooBig, "namedParams");
3720 }
3721 }
3722 else if (namedParams.Length != 0)
3723 {
3724 throw new ArgumentException(SR.Arg_NamedParamTooBig, "namedParams");
3725 }
3726 }
3727 if (target != null && target.GetType().IsCOMObject)
3728 {
3729 if ((bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) == 0)
3730 {
3731 throw new ArgumentException(SR.Arg_COMAccess, "bindingFlags");
3732 }
3733 if ((bindingFlags & BindingFlags.GetProperty) != 0 && ((uint)(bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) & 0xFFFFEEFFu) != 0)
3734 {
3735 throw new ArgumentException(SR.Arg_PropSetGet, "bindingFlags");
3736 }
3737 if ((bindingFlags & BindingFlags.InvokeMethod) != 0 && ((uint)(bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) & 0xFFFFEEFFu) != 0)
3738 {
3739 throw new ArgumentException(SR.Arg_PropSetInvoke, "bindingFlags");
3740 }
3741 if ((bindingFlags & BindingFlags.SetProperty) != 0 && ((uint)(bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) & 0xFFFFDFFFu) != 0)
3742 {
3743 throw new ArgumentException(SR.Arg_COMPropSetPut, "bindingFlags");
3744 }
3745 if ((bindingFlags & BindingFlags.PutDispProperty) != 0 && ((uint)(bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) & 0xFFFFBFFFu) != 0)
3746 {
3747 throw new ArgumentException(SR.Arg_COMPropSetPut, "bindingFlags");
3748 }
3749 if ((bindingFlags & BindingFlags.PutRefDispProperty) != 0 && ((uint)(bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) & 0xFFFF7FFFu) != 0)
3750 {
3751 throw new ArgumentException(SR.Arg_COMPropSetPut, "bindingFlags");
3752 }
3753 if (name == null)
3754 {
3755 throw new ArgumentNullException("name");
3756 }
3757 bool[] byrefModifiers = modifiers?[0].IsByRefArray;
3758 int culture2 = culture?.LCID ?? 1033;
3759 bool flag = (bindingFlags & BindingFlags.DoNotWrapExceptions) != 0;
3760 try
3761 {
3762 return InvokeDispMethod(name, bindingFlags, target, providedArgs, byrefModifiers, culture2, namedParams);
3763 }
3764 catch (TargetInvocationException ex) when (flag)
3765 {
3766 throw ex.InnerException;
3767 }
3768 }
3769 if (namedParams != null && Array.IndexOf(namedParams, null) != -1)
3770 {
3771 throw new ArgumentException(SR.Arg_NamedParamNull, "namedParams");
3772 }
3773 int num = ((providedArgs != null) ? providedArgs.Length : 0);
3774 if (binder == null)
3775 {
3777 }
3778 if ((bindingFlags & BindingFlags.CreateInstance) != 0)
3779 {
3780 if ((bindingFlags & BindingFlags.CreateInstance) != 0 && (bindingFlags & (BindingFlags.InvokeMethod | BindingFlags.GetField | BindingFlags.SetField | BindingFlags.GetProperty | BindingFlags.SetProperty)) != 0)
3781 {
3782 throw new ArgumentException(SR.Arg_CreatInstAccess, "bindingFlags");
3783 }
3785 }
3786 if ((bindingFlags & (BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty)) != 0)
3787 {
3788 bindingFlags |= BindingFlags.SetProperty;
3789 }
3790 if (name == null)
3791 {
3792 throw new ArgumentNullException("name");
3793 }
3794 if (name.Length == 0 || name.Equals("[DISPID=0]"))
3795 {
3796 name = GetDefaultMemberName() ?? "ToString";
3797 }
3798 bool flag2 = (bindingFlags & BindingFlags.GetField) != 0;
3799 bool flag3 = (bindingFlags & BindingFlags.SetField) != 0;
3800 if (flag2 || flag3)
3801 {
3802 if (flag2)
3803 {
3804 if (flag3)
3805 {
3806 throw new ArgumentException(SR.Arg_FldSetGet, "bindingFlags");
3807 }
3808 if ((bindingFlags & BindingFlags.SetProperty) != 0)
3809 {
3810 throw new ArgumentException(SR.Arg_FldGetPropSet, "bindingFlags");
3811 }
3812 }
3813 else
3814 {
3815 if (providedArgs == null)
3816 {
3817 throw new ArgumentNullException("providedArgs");
3818 }
3819 if ((bindingFlags & BindingFlags.GetProperty) != 0)
3820 {
3821 throw new ArgumentException(SR.Arg_FldSetPropGet, "bindingFlags");
3822 }
3823 if ((bindingFlags & BindingFlags.InvokeMethod) != 0)
3824 {
3825 throw new ArgumentException(SR.Arg_FldSetInvoke, "bindingFlags");
3826 }
3827 }
3828 FieldInfo fieldInfo = null;
3829 FieldInfo[] array = GetMember(name, MemberTypes.Field, bindingFlags) as FieldInfo[];
3830 if (array.Length == 1)
3831 {
3832 fieldInfo = array[0];
3833 }
3834 else if (array.Length != 0)
3835 {
3837 }
3838 if (fieldInfo != null)
3839 {
3840 if (fieldInfo.FieldType.IsArray || (object)fieldInfo.FieldType == typeof(Array))
3841 {
3842 int num2 = (((bindingFlags & BindingFlags.GetField) == 0) ? (num - 1) : num);
3843 if (num2 > 0)
3844 {
3845 int[] array2 = new int[num2];
3846 for (int i = 0; i < num2; i++)
3847 {
3848 try
3849 {
3850 array2[i] = ((IConvertible)providedArgs[i]).ToInt32(null);
3851 }
3852 catch (InvalidCastException)
3853 {
3855 }
3856 }
3857 Array array3 = (Array)fieldInfo.GetValue(target);
3858 if ((bindingFlags & BindingFlags.GetField) != 0)
3859 {
3860 return array3.GetValue(array2);
3861 }
3862 array3.SetValue(providedArgs[num2], array2);
3863 return null;
3864 }
3865 }
3866 if (flag2)
3867 {
3868 if (num != 0)
3869 {
3870 throw new ArgumentException(SR.Arg_FldGetArgErr, "bindingFlags");
3871 }
3872 return fieldInfo.GetValue(target);
3873 }
3874 if (num != 1)
3875 {
3876 throw new ArgumentException(SR.Arg_FldSetArgErr, "bindingFlags");
3877 }
3878 fieldInfo.SetValue(target, providedArgs[0], bindingFlags, binder, culture);
3879 return null;
3880 }
3881 if ((bindingFlags & (BindingFlags)16773888) == 0)
3882 {
3883 throw new MissingFieldException(FullName, name);
3884 }
3885 }
3886 bool flag4 = (bindingFlags & BindingFlags.GetProperty) != 0;
3887 bool flag5 = (bindingFlags & BindingFlags.SetProperty) != 0;
3888 if (flag4 || flag5)
3889 {
3890 if (flag4)
3891 {
3892 if (flag5)
3893 {
3894 throw new ArgumentException(SR.Arg_PropSetGet, "bindingFlags");
3895 }
3896 }
3897 else if ((bindingFlags & BindingFlags.InvokeMethod) != 0)
3898 {
3899 throw new ArgumentException(SR.Arg_PropSetInvoke, "bindingFlags");
3900 }
3901 }
3902 MethodInfo[] array4 = null;
3903 MethodInfo methodInfo = null;
3904 if ((bindingFlags & BindingFlags.InvokeMethod) != 0)
3905 {
3906 MethodInfo[] array5 = GetMember(name, MemberTypes.Method, bindingFlags) as MethodInfo[];
3907 List<MethodInfo> list = null;
3908 foreach (MethodInfo methodInfo2 in array5)
3909 {
3910 if (!FilterApplyMethodInfo((RuntimeMethodInfo)methodInfo2, bindingFlags, CallingConventions.Any, new Type[num]))
3911 {
3912 continue;
3913 }
3914 if (methodInfo == null)
3915 {
3917 continue;
3918 }
3919 if (list == null)
3920 {
3921 list = new List<MethodInfo>(array5.Length) { methodInfo };
3922 }
3924 }
3925 if (list != null)
3926 {
3927 array4 = list.ToArray();
3928 }
3929 }
3930 if ((methodInfo == null && flag4) || flag5)
3931 {
3932 PropertyInfo[] array6 = GetMember(name, MemberTypes.Property, bindingFlags) as PropertyInfo[];
3933 List<MethodInfo> list2 = null;
3934 for (int k = 0; k < array6.Length; k++)
3935 {
3936 MethodInfo methodInfo3 = null;
3937 methodInfo3 = ((!flag5) ? array6[k].GetGetMethod(nonPublic: true) : array6[k].GetSetMethod(nonPublic: true));
3938 if (methodInfo3 == null || !FilterApplyMethodInfo((RuntimeMethodInfo)methodInfo3, bindingFlags, CallingConventions.Any, new Type[num]))
3939 {
3940 continue;
3941 }
3942 if (methodInfo == null)
3943 {
3945 continue;
3946 }
3947 if (list2 == null)
3948 {
3949 list2 = new List<MethodInfo>(array6.Length) { methodInfo };
3950 }
3952 }
3953 if (list2 != null)
3954 {
3955 array4 = list2.ToArray();
3956 }
3957 }
3958 if (methodInfo != null)
3959 {
3960 if (array4 == null && num == 0 && methodInfo.GetParametersNoCopy().Length == 0 && (bindingFlags & BindingFlags.OptionalParamBinding) == 0)
3961 {
3962 return methodInfo.Invoke(target, bindingFlags, binder, providedArgs, culture);
3963 }
3964 if (array4 == null)
3965 {
3966 array4 = new MethodInfo[1] { methodInfo };
3967 }
3968 if (providedArgs == null)
3969 {
3970 providedArgs = Array.Empty<object>();
3971 }
3972 object state = null;
3973 MethodBase methodBase = null;
3974 try
3975 {
3980 }
3982 {
3983 }
3984 if (methodBase == null)
3985 {
3986 throw new MissingMethodException(FullName, name);
3987 }
3988 object result = ((MethodInfo)methodBase).Invoke(target, bindingFlags, binder, providedArgs, culture);
3989 if (state != null)
3990 {
3991 binder.ReorderArgumentArray(ref providedArgs, state);
3992 }
3993 return result;
3994 }
3995 throw new MissingMethodException(FullName, name);
3996 }
3997
3999 {
4000 if (base.IsInterface)
4001 {
4002 return null;
4003 }
4005 {
4006 Type[] genericParameterConstraints = GetGenericParameterConstraints();
4007 RuntimeType runtimeType = ObjectType;
4008 for (int i = 0; i < genericParameterConstraints.Length; i++)
4009 {
4011 if (runtimeType2.IsInterface)
4012 {
4013 continue;
4014 }
4015 if (runtimeType2.IsGenericParameter)
4016 {
4017 GenericParameterAttributes genericParameterAttributes = runtimeType2.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask;
4018 if ((genericParameterAttributes & GenericParameterAttributes.ReferenceTypeConstraint) == 0 && (genericParameterAttributes & GenericParameterAttributes.NotNullableValueTypeConstraint) == 0)
4019 {
4020 continue;
4021 }
4022 }
4024 }
4025 if (runtimeType == ObjectType)
4026 {
4028 if ((genericParameterAttributes2 & GenericParameterAttributes.NotNullableValueTypeConstraint) != 0)
4029 {
4031 }
4032 }
4033 return runtimeType;
4034 }
4035 return RuntimeTypeHandle.GetBaseType(this);
4036 }
4037
4039 {
4040 if (type.IsPointer || type.IsByRef || type == typeof(void))
4041 {
4043 }
4044 }
4045
4047 {
4048 if (genericArguments == null)
4049 {
4050 throw new ArgumentNullException();
4051 }
4052 for (int i = 0; i < genericArguments.Length; i++)
4053 {
4054 if (genericArguments[i] == null)
4055 {
4056 throw new ArgumentNullException();
4057 }
4058 ThrowIfTypeNeverValidGenericArgument(genericArguments[i]);
4059 }
4060 if (genericArguments.Length != genericParameters.Length)
4061 {
4063 }
4064 }
4065}
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
int IList. IndexOf(object value)
Definition Array.cs:1228
static unsafe Array CreateInstance(Type elementType, int length)
Definition Array.cs:473
static int BinarySearch(Array array, object? value)
Definition Array.cs:1320
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
void Add(TKey key, TValue value)
static MethodBase FindMostDerivedNewSlotMeth(MethodBase[] match, int cMatches)
static MethodBase ExactBinding(MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
static bool CompareMethodSig(MethodBase m1, MethodBase m2)
static PropertyInfo ExactPropertyBinding(PropertyInfo[] match, Type returnType, Type[] types, ParameterModifier[] modifiers)
static readonly Empty Value
Definition Empty.cs:5
static object ToObject(Type enumType, object value)
Definition Enum.cs:874
static ulong[] InternalGetValues(RuntimeType enumType)
Definition Enum.cs:346
static string[] InternalGetNames(RuntimeType enumType)
Definition Enum.cs:304
static string GetEnumName(RuntimeType enumType, ulong ulValue)
Definition Enum.cs:147
static RuntimeType InternalGetUnderlyingType(RuntimeType enumType)
static ulong ToUInt64(object value)
Definition Enum.cs:240
static void KeepAlive(object? obj)
Definition GC.cs:180
Definition GC.cs:8
static CultureInfo CurrentCulture
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static string CreateQualifiedName(string? assemblyName, string? typeName)
Definition Assembly.cs:467
virtual ? string FullName
Definition Assembly.cs:74
static IList< CustomAttributeData > GetCustomAttributes(MemberInfo target)
static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
static Type MakeGenericType(Type type, Type[] typeArguments)
static StructLayoutAttribute GetStructLayoutCustomAttribute(RuntimeType type)
static IList< CustomAttributeData > GetCustomAttributesInternal(RuntimeType target)
virtual Type AsType()
Definition TypeInfo.cs:106
unsafe readonly void * _allocatorFirstArg
unsafe readonly delegate *< void *, object > _pfnAllocator
unsafe ActivatorCache(RuntimeType rt)
unsafe object CreateUninitializedObject(RuntimeType rt)
unsafe void CallConstructor(object uninitializedObject)
unsafe readonly delegate *< object, void > _pfnCtor
T[] GetMemberList(MemberListType listType, string name, CacheType cacheType)
RuntimeEventInfo[] PopulateEvents(Filter filter)
RuntimePropertyInfo[] PopulateProperties(Filter filter)
unsafe void PopulateRtFields(Filter filter, RuntimeType declaringType, ref ListBuilder< RuntimeFieldInfo > list)
unsafe void PopulateRtFields(Filter filter, IntPtr *ppFieldHandles, int count, RuntimeType declaringType, ref ListBuilder< RuntimeFieldInfo > list)
unsafe T[] Populate(string name, MemberListType listType, CacheType cacheType)
void PopulateProperties(Filter filter, RuntimeType declaringType, Dictionary< string, List< RuntimePropertyInfo > > csPropertyInfos, bool[] usedSlots, ref ListBuilder< RuntimePropertyInfo > list)
void Insert(ref T[] list, string name, MemberListType listType)
RuntimeFieldInfo[] PopulateFields(Filter filter)
RuntimeType[] PopulateNestedClasses(Filter filter)
RuntimeConstructorInfo[] PopulateConstructors(Filter filter)
MemberInfoCache(RuntimeTypeCache runtimeTypeCache)
void AddSpecialInterface(ref ListBuilder< RuntimeType > list, Filter filter, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] RuntimeType iList, bool addSubInterface)
void PopulateEvents(Filter filter, RuntimeType declaringType, Dictionary< string, RuntimeEventInfo > csEventInfos, ref ListBuilder< RuntimeEventInfo > list)
FieldInfo AddField(RuntimeFieldHandleInternal field)
unsafe RuntimeMethodInfo[] PopulateMethods(Filter filter)
void PopulateLiteralFields(Filter filter, RuntimeType declaringType, ref ListBuilder< RuntimeFieldInfo > list)
MethodBase AddMethod(RuntimeType declaringType, RuntimeMethodHandleInternal method, CacheType cacheType)
unsafe T[] GetListByName(char *pName, int cNameLen, byte *pUtf8Name, int cUtf8Name, MemberListType listType, CacheType cacheType)
MemberInfoCache< RuntimeEventInfo > m_eventInfoCache
RuntimeTypeCache(RuntimeType runtimeType)
RuntimeType[] GetNestedTypeList(MemberListType listType, string name)
RuntimeConstructorInfo[] GetConstructorList(MemberListType listType, string name)
RuntimeEventInfo[] GetEventList(MemberListType listType, string name)
MemberInfoCache< RuntimeType > m_nestedClassesCache
RuntimeFieldInfo[] GetFieldList(MemberListType listType, string name)
MethodBase GetMethod(RuntimeType declaringType, RuntimeMethodHandleInternal method)
MemberInfoCache< RuntimeConstructorInfo > m_constructorInfoCache
string GetName(TypeNameKind kind)
RuntimeType[] GetInterfaceList(MemberListType listType, string name)
string ConstructName([NotNull] ref string name, TypeNameFormatFlags formatFlags)
FieldInfo GetField(RuntimeFieldHandleInternal field)
RuntimePropertyInfo[] GetPropertyList(MemberListType listType, string name)
MemberInfoCache< RuntimeFieldInfo > m_fieldInfoCache
MemberInfoCache< RuntimeType > m_interfaceCache
MemberInfoCache< T > GetMemberCache< T >(ref MemberInfoCache< T > m_cache)
T[] GetMemberList< T >(ref MemberInfoCache< T > m_cache, MemberListType listType, string name, CacheType cacheType)
MemberInfoCache< RuntimePropertyInfo > m_propertyInfoCache
RuntimeMethodInfo[] GetMethodList(MemberListType listType, string name)
MethodBase GetConstructor(RuntimeType declaringType, RuntimeMethodHandleInternal constructor)
static CerHashtable< RuntimeMethodInfo, RuntimeMethodInfo > s_methodInstantiations
MethodInfo GetGenericMethodInfo(RuntimeMethodHandleInternal genericMethod)
MemberInfoCache< RuntimeMethodInfo > m_methodInfoCache
override Array GetEnumValues()
override Type MakeGenericType(params Type[] instantiation)
static MethodBase GetMethodBase(RuntimeType reflectedType, IRuntimeMethodInfo methodHandle)
override Type[] GetGenericParameterConstraints()
override bool IsCollectible
static MethodBase GetMethodBase(RuntimeType reflectedType, RuntimeMethodHandleInternal methodHandle)
override string ToString()
override RuntimeTypeHandle TypeHandle
override bool IsGenericTypeDefinition
override EventInfo GetEvent(string name, BindingFlags bindingAttr)
ListBuilder< PropertyInfo > GetPropertyCandidates(string name, BindingFlags bindingAttr, Type[] types, bool allowPrefixLookup)
override MemberInfo[] GetDefaultMembers()
override Type DeclaringType
override Type UnderlyingSystemType
override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
override Type MakeArrayType()
override bool IsByRefImpl()
static bool FilterApplyMethodBase(MethodBase methodBase, BindingFlags methodFlags, BindingFlags bindingFlags, CallingConventions callConv, Type[] argumentTypes)
override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo typeInfo)
override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
override bool IsByRefLike
override Type GetInterface(string fullname, bool ignoreCase)
override FieldInfo[] GetFields(BindingFlags bindingAttr)
override string AssemblyQualifiedName
static bool CanValueSpecialCast(RuntimeType valueType, RuntimeType targetType)
object CheckValue(object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
override Type MakeArrayType(int rank)
override bool IsInstanceOfType([NotNullWhen(true)] object o)
ListBuilder< Type > GetNestedTypeCandidates(string fullname, BindingFlags bindingAttr, bool allowPrefixLookup)
static MemberInfo GetNestedTypeWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo nestedType)
override MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo member)
static readonly RuntimeType StringType
static bool FilterApplyPrefixLookup(MemberInfo memberInfo, string name, bool ignoreCase)
override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
override Type GetEnumUnderlyingType()
override bool IsArrayImpl()
override Type[] GetGenericArguments()
override bool IsEnumDefined(object value)
static object AllocateValueType(RuntimeType type, object value, bool fForceTypeChange)
static readonly RuntimeType s_typedRef
override bool IsPrimitiveImpl()
override bool HasSameMetadataDefinitionAs(MemberInfo other)
static MemberInfo GetMethodWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo method)
IntPtr GetUnderlyingNativeHandle()
static void SplitName(string fullname, out string name, out string ns)
override Type[] GetNestedTypes(BindingFlags bindingAttr)
override Type BaseType
override MethodBase DeclaringMethod
object CreateInstanceOfT()
override bool ContainsGenericParameters
void GetGUID(ref Guid result)
object CreateInstanceDefaultCtor(bool publicOnly, bool wrapExceptions)
static BindingFlags FilterPreCalculate(bool isPublic, bool isInherited, bool isStatic)
static MemberInfo GetPropertyWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo property)
override Type MakePointerType()
bool IsGenericCOMObjectImpl()
static RuntimeType GetType(string typeName, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark)
ListBuilder< EventInfo > GetEventCandidates(string name, BindingFlags bindingAttr, bool allowPrefixLookup)
RuntimeType[] GetGenericArgumentsInternal()
override bool IsConstructedGenericType
override bool IsContextfulImpl()
override bool IsAssignableFrom([NotNullWhen(true)] Type c)
override object[] GetCustomAttributes(Type attributeType, bool inherit)
RuntimeTypeCache InitializeCache()
object ForwardCallToInvokeMember(string memberName, BindingFlags flags, object target, object[] aArgs, bool[] aArgsIsByRef, int[] aArgsWrapperTypes, Type[] aArgsTypes, Type retType)
override bool IsSZArray
override MemberTypes MemberType
static object _CreateEnum(RuntimeType enumType, long value)
ListBuilder< FieldInfo > GetFieldCandidates(string name, BindingFlags bindingAttr, bool allowPrefixLookup)
RuntimeType GetBaseType()
static bool FilterApplyBase(MemberInfo memberInfo, BindingFlags bindingFlags, bool isPublic, bool isNonProtectedInternal, bool isStatic, string name, bool prefixLookup)
override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
static bool FilterApplyConstructorInfo(RuntimeConstructorInfo constructor, BindingFlags bindingFlags, CallingConventions callConv, Type[] argumentTypes)
static void ThrowIfTypeNeverValidGenericArgument(RuntimeType type)
static FieldInfo GetFieldInfo(RuntimeType reflectedType, IRuntimeFieldInfo field)
ListBuilder< MethodInfo > GetMethodCandidates(string name, int genericParameterCount, BindingFlags bindingAttr, CallingConventions callConv, Type[] types, bool allowPrefixLookup)
static MemberInfo GetFieldWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo field)
object CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture)
string GetDefaultMemberName()
override bool IsValueTypeImpl()
void InvalidateCachedNestedType()
object[] GetEmptyArray()
static bool FilterApplyMethodInfo(RuntimeMethodInfo method, BindingFlags bindingFlags, CallingConventions callConv, Type[] argumentTypes)
override Type GetElementType()
static OleAutBinder s_ForwardCallBinder
override Type ReflectedType
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 string GetEnumName(object value)
override bool IsSecurityCritical
static readonly RuntimeType ObjectType
override Type[] GetInterfaces()
override bool HasElementTypeImpl()
override bool IsCOMObjectImpl()
MethodInfo GetMethodImplCommon(string name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
override Type GetNestedType(string fullname, BindingFlags bindingAttr)
override object[] GetCustomAttributes(bool inherit)
string GetCachedName(TypeNameKind kind)
static MemberInfo GetEventWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo eventInfo)
override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
override Type GetGenericTypeDefinition()
static object CreateEnum(RuntimeType enumType, long value)
const int GenericParameterCountAny
override TypeAttributes GetAttributeFlagsImpl()
readonly object m_keepalive
static void FilterHelper(BindingFlags bindingFlags, ref string name, bool allowPrefixLookup, out bool prefixLookup, out bool ignoreCase, out MemberListType listType)
override bool IsTypeDefinition
static FieldInfo GetFieldInfo(IRuntimeFieldInfo fieldHandle)
static void SanityCheckGenericArguments(RuntimeType[] genericArguments, RuntimeType[] genericParameters)
override IList< CustomAttributeData > GetCustomAttributesData()
static MethodBase GetMethodBase(IRuntimeMethodInfo methodHandle)
override string Namespace
override FieldInfo GetField(string name, BindingFlags bindingAttr)
override int GetHashCode()
override string Name
override string FullName
override bool IsDefined(Type attributeType, bool inherit)
object TryChangeType(object value, Binder binder, CultureInfo culture, bool needsSpecialCast)
override int GenericParameterPosition
override int GetArrayRank()
override MethodInfo GetMethodImpl(string name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
override bool Equals(object obj)
override EventInfo[] GetEvents(BindingFlags bindingAttr)
override TypeCode GetTypeCodeImpl()
static bool FilterApplyType(Type type, BindingFlags bindingFlags, string name, bool prefixLookup, string ns)
static MemberInfo GetConstructorWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo constructor)
static void WrapArgsForInvokeCall(object[] aArgs, int[] aArgsWrapperTypes)
override bool CacheEquals(object o)
static void FilterHelper(BindingFlags bindingFlags, ref string name, out bool ignoreCase, out MemberListType listType)
RuntimeModule GetRuntimeModule()
ListBuilder< ConstructorInfo > GetConstructorCandidates(string name, BindingFlags bindingAttr, CallingConventions callConv, Type[] types, bool allowPrefixLookup)
override bool IsSubclassOf(Type type)
static OleAutBinder ForwardCallBinder
override InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.NonPublicMethods)] Type ifaceType)
override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
static void ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
override Guid GUID
override bool IsEquivalentTo([NotNullWhen(true)] Type other)
override Type MakeByRefType()
static PropertyInfo GetPropertyInfo(RuntimeType reflectedType, int tkProperty)
void CreateInstanceCheckThis()
override bool IsGenericParameter
override MemberInfo[] GetMembers(BindingFlags bindingAttr)
RuntimeTypeCache CacheIfExists
override bool IsSecuritySafeCritical
override bool IsGenericType
object InvokeDispMethod(string name, BindingFlags invokeAttr, object target, object[] args, bool[] byrefModifiers, int culture, string[] namedParameters)
override string[] GetEnumNames()
static MethodBase GetMethodBase(RuntimeModule scope, int typeMetadataToken)
override bool IsPointerImpl()
override bool IsSecurityTransparent
static string Arg_GenericParameter
Definition SR.cs:174
static string Arg_COMAccess
Definition SR.cs:100
static string Argument_NotEnoughGenArguments
Definition SR.cs:810
static string Arg_MustBeEnum
Definition SR.cs:274
static string NotSupported_CallToVarArg
Definition SR.cs:1656
static string Argument_ResolveFieldHandle
Definition SR.cs:852
static string NotSupported_COM
Definition SR.cs:2190
static string Acc_CreateVoid
Definition SR.cs:34
static string Arg_MustBeType
Definition SR.cs:302
static string Arg_NoDefCTor
Definition SR.cs:336
static string Arg_FldGetArgErr
Definition SR.cs:160
static string Arg_EnumAndObjectMustBeSameType
Definition SR.cs:140
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Arg_FldSetPropGet
Definition SR.cs:170
static string Arg_IndexMustBeInt
Definition SR.cs:188
static string Arg_CreatInstAccess
Definition SR.cs:106
static string Arg_FldSetArgErr
Definition SR.cs:164
static string Arg_NotGenericParameter
Definition SR.cs:346
static string Argument_NeverValidGenericArgument
Definition SR.cs:798
static string InvalidOperation_UnknownEnumType
Definition SR.cs:1530
static string Arg_AmbiguousMatchException
Definition SR.cs:62
static string Acc_CreateArgIterator
Definition SR.cs:28
static string Arg_FldSetGet
Definition SR.cs:166
static string Arg_ObjObjEx
Definition SR.cs:356
static string Argument_HasToBeArrayClass
Definition SR.cs:614
static string InvalidOperation_NotGenericType
Definition SR.cs:1484
static string Activator_CannotCreateInstance
Definition SR.cs:2184
static string Argument_ArrayGetInterfaceMap
Definition SR.cs:470
static string Arg_FldSetInvoke
Definition SR.cs:168
static string Arg_NoAccessSpec
Definition SR.cs:334
static string Arg_COMPropSetPut
Definition SR.cs:104
static string Arg_NamedParamNull
Definition SR.cs:318
static string Arg_PropSetGet
Definition SR.cs:374
static string Argument_ResolveMethodHandle
Definition SR.cs:858
static string Arg_PropSetInvoke
Definition SR.cs:376
static string Acc_CreateGenericEx
Definition SR.cs:30
static string MissingConstructor_Name
Definition SR.cs:1616
static string Arg_EnumUnderlyingTypeAndObjectMustBeSameType
Definition SR.cs:148
static string Argument_GenericArgsCount
Definition SR.cs:608
static string Arg_NotGenericTypeDefinition
Definition SR.cs:348
static string Arg_NamedParamTooBig
Definition SR.cs:320
static string Argument_MustBeRuntimeType
Definition SR.cs:782
static string Arg_MustBeEnumBaseTypeOrEnum
Definition SR.cs:276
static string Argument_GenConstraintViolation
Definition SR.cs:606
static string Arg_FldGetPropSet
Definition SR.cs:162
Definition SR.cs:7
static Encoding UTF8
Definition Encoding.cs:526
static int CompareExchange(ref int location1, int value, int comparand)
static void Exit(object obj)
static void Enter(object obj)
static bool Read(ref bool location)
Definition Volatile.cs:67
static void Write(ref bool location, bool value)
Definition Volatile.cs:74
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
virtual RuntimeTypeHandle GetTypeHandleInternal()
Definition Type.cs:449
Type UnderlyingSystemType
Definition Type.cs:61
virtual bool IsEnum
Definition Type.cs:227
static Binder DefaultBinder
Definition Type.cs:298
static TypeCode GetTypeCode(Type? type)
Definition Type.cs:919
bool ImplementInterface(Type ifaceType)
Definition Type.cs:1600
static bool IsIntegerType(Type t)
Definition Type.cs:1280
new Type GetType()
Definition Type.cs:475
virtual bool IsSubclassOf(Type c)
Definition Type.cs:1542
Type GetRootElementType()
Definition Type.cs:1289
static readonly Type[] EmptyTypes
Definition Type.cs:19
static ArgumentException CreateGetMemberWithSameMetadataDefinitionAsNotFoundException(MemberInfo member)
Definition Type.cs:666
virtual bool IsGenericTypeDefinition
Definition Type.cs:113
ConstructorInfo[] GetConstructors()
Definition Type.cs:580
TypeCode
Definition TypeCode.cs:4
static readonly IntPtr Zero
Definition IntPtr.cs:18
unsafe bool Equals(MdUtf8String s)
static unsafe uint HashCaseInsensitive(void *sz, int cSz)
static unsafe bool EqualsCaseInsensitive(void *szLhs, void *szRhs, int cSz)
static bool ContainsPropertyMatchingHash(RuntimeModule module, int propertyToken, uint hash)
static MetadataImport GetMetadataImport(RuntimeModule module)
static bool IsNullToken(int token)
static RuntimeType GetApproxDeclaringType(RuntimeFieldHandleInternal field)
static bool MatchesNameHash(RuntimeFieldHandleInternal handle, uint hash)
static FieldAttributes GetAttributes(RuntimeFieldHandleInternal field)
static bool AcquiresContextFromThis(RuntimeFieldHandleInternal field)
static unsafe MdUtf8String GetUtf8Name(RuntimeFieldHandleInternal field)
static RuntimeFieldHandleInternal GetStaticFieldForGenericType(RuntimeFieldHandleInternal field, RuntimeType declaringType)
static RuntimeType[] GetMethodInstantiationInternal(IRuntimeMethodInfo method)
static bool IsConstructor(RuntimeMethodHandleInternal method)
static Resolver GetResolver(RuntimeMethodHandleInternal method)
static RuntimeMethodHandleInternal GetMethodFromCanonical(RuntimeMethodHandleInternal method, RuntimeType declaringType)
static bool HasMethodInstantiation(RuntimeMethodHandleInternal method)
static LoaderAllocator GetLoaderAllocator(RuntimeMethodHandleInternal method)
static string GetName(RuntimeMethodHandleInternal method)
static unsafe MdUtf8String GetUtf8Name(RuntimeMethodHandleInternal method)
static bool IsDynamicMethod(RuntimeMethodHandleInternal method)
static int GetSlot(RuntimeMethodHandleInternal method)
static RuntimeType GetDeclaringType(RuntimeMethodHandleInternal method)
static bool MatchesNameHash(RuntimeMethodHandleInternal method, uint hash)
static bool IsGenericMethodDefinition(RuntimeMethodHandleInternal method)
static RuntimeMethodHandleInternal GetStubIfNeeded(RuntimeMethodHandleInternal method, RuntimeType declaringType, RuntimeType[] methodInstantiation)
static MethodAttributes GetAttributes(RuntimeMethodHandleInternal method)
static bool IsPrimitive(RuntimeType type)
static void GetConstraints(QCallTypeHandle handle, ObjectHandleOnStack types)
static void MakePointer(QCallTypeHandle handle, ObjectHandleOnStack type)
static bool IsValueType(RuntimeType type)
static RuntimeType GetDeclaringType(RuntimeType type)
static bool IsComObject(RuntimeType type, bool isGenericCOM)
static bool IsPointer(RuntimeType type)
static TypeAttributes GetAttributes(RuntimeType type)
static unsafe bool GetFields(RuntimeType type, IntPtr *result, int *count)
static void GetTypeByName(string name, bool throwOnError, bool ignoreCase, StackCrawlMarkHandle stackMark, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack type, ObjectHandleOnStack keepalive)
static IntroducedMethodEnumerator GetIntroducedMethods(RuntimeType type)
static bool IsByRefLike(RuntimeType type)
static void MakeSZArray(QCallTypeHandle handle, ObjectHandleOnStack type)
static void GetGenericTypeDefinition(QCallTypeHandle type, ObjectHandleOnStack retType)
static MetadataImport GetMetadataImport(RuntimeType type)
static bool IsInterface(RuntimeType type)
static bool CanCastTo(RuntimeType type, RuntimeType target)
static RuntimeModule GetModule(RuntimeType type)
static bool ContainsGenericVariables(RuntimeType handle)
static void MakeByRef(QCallTypeHandle handle, ObjectHandleOnStack type)
static Type[] GetInterfaces(RuntimeType type)
static unsafe MdUtf8String GetUtf8Name(RuntimeType type)
static int GetToken(RuntimeType type)
static bool HasInstantiation(RuntimeType type)
static bool IsByRef(RuntimeType type)
static bool IsGenericTypeDefinition(RuntimeType type)
static bool IsSZArray(RuntimeType type)
static int GetNumVirtualsAndStaticVirtuals(RuntimeType type)
static RuntimeAssembly GetAssembly(RuntimeType type)
static RuntimeType GetElementType(RuntimeType type)
static unsafe void GetActivationInfo(RuntimeType rt, out delegate *< void *, object > pfnAllocator, out void *vAllocatorFirstArg, out delegate *< object, void > pfnCtor, out bool ctorIsPublic)
static void MakeArray(QCallTypeHandle handle, int rank, ObjectHandleOnStack type)
static Interop.BOOL IsCollectible(QCallTypeHandle handle)
static bool IsGenericVariable(RuntimeType type)
static RuntimeMethodHandleInternal GetMethodAt(RuntimeType type, int slot)
static void ConstructName(QCallTypeHandle handle, TypeNameFormatFlags formatFlags, StringHandleOnStack retString)
static bool IsEquivalentTo(RuntimeType rtType1, RuntimeType rtType2)
static unsafe void Instantiate(QCallTypeHandle handle, IntPtr *pInst, int numGenericArgs, ObjectHandleOnStack type)
static bool HasElementType(RuntimeType type)
static int GetGenericVariableIndex(RuntimeType type)
static bool IsArray(RuntimeType type)
static unsafe bool SatisfiesConstraints(RuntimeType paramType, IntPtr *pTypeContext, int typeContextLength, IntPtr *pMethodContext, int methodContextLength, RuntimeType toType)
static CorElementType GetCorElementType(RuntimeType type)
static bool CompareCanonicalHandles(RuntimeType left, RuntimeType right)
static IRuntimeMethodInfo GetDeclaringMethod(RuntimeType type)
static RuntimeType GetBaseType(RuntimeType type)
static bool IsInstanceOfType(RuntimeType type, [NotNullWhen(true)] object o)
static int GetNumVirtuals(RuntimeType type)
static int GetArrayRank(RuntimeType type)
static bool IsTypeDefinition(RuntimeType type)
void CopyTo(object[] array, int index)
unsafe Filter(byte *pUtf8Name, int cUtf8Name, MemberListType listType)
static void InternalSet(IntPtr handle, object value)
static unsafe object InternalGet(IntPtr handle)
Definition GCHandle.cs:40
static object InternalCompareExchange(IntPtr handle, object value, object oldValue)