319 if (
type.IsRuntimeImplemented())
329 while (
type !=
null);
352 for (
int i = 0; i < genericArguments.Length; i++)
395 foreach (
Type type3
in genericArguments)
407 [RequiresUnreferencedCode(
"The type might be removed")]
408 public static Type?
GetType(
string typeName,
bool throwOnError,
bool ignoreCase)
414 [RequiresUnreferencedCode(
"The type might be removed")]
421 [RequiresUnreferencedCode(
"The type might be removed")]
425 return RuntimeType.
GetType(typeName, throwOnError:
false, ignoreCase:
false, ref stackMark);
428 [RequiresUnreferencedCode(
"The type might be removed")]
429 public static Type?
GetType(
string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver)
432 return TypeNameParser.
GetType(typeName, assemblyResolver, typeResolver, throwOnError:
false, ignoreCase:
false, ref stackMark);
435 [RequiresUnreferencedCode(
"The type might be removed")]
436 public static Type?
GetType(
string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver,
bool throwOnError)
439 return TypeNameParser.
GetType(typeName, assemblyResolver, typeResolver, throwOnError, ignoreCase:
false, ref stackMark);
442 [RequiresUnreferencedCode(
"The type might be removed")]
443 public static Type?
GetType(
string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver,
bool throwOnError,
bool ignoreCase)
446 return TypeNameParser.
GetType(typeName, assemblyResolver, typeResolver, throwOnError, ignoreCase, ref stackMark);
566 for (
int i = 0; i < types.Length; i++)
568 if (types[i] ==
null)
648 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2085:UnrecognizedReflectionPattern", Justification =
"This is finding the MemberInfo with the same MetadataToken as specified MemberInfo. If the specified MemberInfo exists and wasn't trimmed, then the current Type's MemberInfo couldn't have been trimmed.")]
651 if ((
object)member ==
null)
693 return GetMethod(name, bindingAttr,
null, types,
null);
725 for (
int i = 0; i < types.Length; i++)
727 if (types[i] ==
null)
732 return GetMethodImpl(name, bindingAttr, binder, callConvention, types, modifiers);
741 return GetMethod(name, genericParameterCount, types,
null);
763 if (genericParameterCount < 0)
771 for (
int i = 0; i < types.Length; i++)
773 if (types[i] ==
null)
778 return GetMethodImpl(name, genericParameterCount, bindingAttr, binder, callConvention, types, modifiers);
831 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2085:UnrecognizedReflectionPattern", Justification =
"Linker doesn't recognize GetPropertyImpl(BindingFlags.Public) but this is what the body is doing")]
870 return GetPropertyImpl(name, bindingAttr, binder, returnType, types, modifiers);
898 return type.TypeHandle;
908 for (
int i = 0; i <
array.Length; i++)
914 array[i] = args[i].GetType();
927 if ((
object)
this != underlyingSystemType && (
object)underlyingSystemType !=
null)
934 [SupportedOSPlatform(
"windows")]
940 [SupportedOSPlatform(
"windows")]
946 [SupportedOSPlatform(
"windows")]
952 [SupportedOSPlatform(
"windows")]
958 [SupportedOSPlatform(
"windows")]
964 [SupportedOSPlatform(
"windows")]
970 [SupportedOSPlatform(
"windows")]
976 [SupportedOSPlatform(
"windows")]
983 [DebuggerStepThrough]
987 return InvokeMember(name, invokeAttr, binder, target, args,
null,
null,
null);
991 [DebuggerStepThrough]
1031 return this ==
other;
1034 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2085:UnrecognizedReflectionPattern", Justification =
"The single instance field on enum types is never trimmed")]
1042 if (fields ==
null || fields.Length != 1)
1073 [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.")]
1110 return "Type: " +
Name;
1125 if ((
object)underlyingSystemType !=
this)
1129 return base.GetHashCode();
1141 [Obsolete(
"ReflectionOnly loading is not supported and throws PlatformNotSupportedException.", DiagnosticId =
"SYSLIB0018", UrlFormat =
"https://aka.ms/dotnet-warnings/{0}")]
1160 if (!
type.IsEquivalentTo(
this))
1164 type =
type.GetEnumUnderlyingType();
1166 if (
type == typeof(
string))
1169 object[]
array = enumNames;
1209 return enumNames[num];
1230 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2085:UnrecognizedReflectionPattern", Justification =
"Literal fields on enums can never be trimmed")]
1234 object[]
array =
new object[fields.Length];
1235 string[] array2 =
new string[fields.Length];
1236 for (
int i = 0; i < fields.Length; i++)
1238 array2[i] = fields[i].
Name;
1242 for (
int j = 1; j <
array.Length; j++)
1245 string text = array2[j];
1248 while (@
default.Compare(
array[num - 1],
obj) > 0)
1250 array2[num] = array2[num - 1];
1271 ulong[] array2 =
new ulong[
array.Length];
1272 for (
int i = 0; i <
array.Length; i++)
1282 if (!(t == typeof(
int)) && !(t == typeof(
short)) && !(t == typeof(ushort)) && !(t == typeof(
byte)) && !(t == typeof(sbyte)) && !(t == typeof(uint)) && !(t == typeof(
long)) && !(t == typeof(ulong)) && !(t == typeof(
char)))
1284 return t == typeof(
bool);
1292 while (
type.HasElementType)
1308 for (
int i = 0; i < interfaces.Length; i++)
1310 if (!filter(interfaces[i], filterCriteria))
1312 interfaces[i] =
null;
1319 if (num == interfaces.Length)
1327 if ((
object)
type !=
null)
1343 Type[] array6 =
null;
1350 for (
int i = 0; i <
array.Length; i++)
1352 if (!filter(
array[i], filterCriteria))
1364 num +=
array.Length;
1372 for (
int i = 0; i < array2.Length; i++)
1374 if (!filter(array2[i], filterCriteria))
1386 num += array2.Length;
1394 for (
int i = 0; i < array3.Length; i++)
1396 if (!filter(array3[i], filterCriteria))
1408 num += array3.Length;
1416 for (
int i = 0; i < array4.Length; i++)
1418 if (!filter(array4[i], filterCriteria))
1430 num += array4.Length;
1438 for (
int i = 0; i < array5.Length; i++)
1440 if (!filter(array5[i], filterCriteria))
1452 num += array5.Length;
1460 for (
int i = 0; i < array6.Length; i++)
1462 if (!filter(array6[i], filterCriteria))
1474 num += array6.Length;
1481 for (
int i = 0; i <
array.Length; i++)
1483 if (
array[i] !=
null)
1485 array7[num++] =
array[i];
1493 if ((
object)constructorInfo !=
null)
1495 array7[num++] = constructorInfo;
1503 if ((
object)fieldInfo !=
null)
1505 array7[num++] = fieldInfo;
1513 if ((
object)propertyInfo !=
null)
1515 array7[num++] = propertyInfo;
1523 if ((
object)eventInfo !=
null)
1525 array7[num++] = eventInfo;
1533 if ((
object)
type !=
null)
1535 array7[num++] =
type;
1549 while (
type !=
null)
1587 for (
int i = 0; i < genericParameterConstraints.Length; i++)
1599 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2085:UnrecognizedReflectionPattern", Justification =
"The GetInterfaces technically requires all interfaces to be preservedBut this method only compares the result against the passed in ifaceType.So if ifaceType exists, then trimming should have kept it implemented on any type.")]
1603 while (
type !=
null)
1606 if (interfaces !=
null)
1608 for (
int i = 0; i < interfaces.Length; i++)
1610 if (interfaces[i] == ifaceType || (interfaces[i] !=
null && interfaces[i].
ImplementInterface(ifaceType)))
1623 if (filterCriteria ==
null)
1635 int num2 = (int)filterCriteria;
1674 int num = (int)filterCriteria;
1715 if (!(filterCriteria is
string text))
1723 span = span.
Slice(span.LastIndexOf(
'+') + 1);
1725 if (readOnlySpan.
Length > 0 && readOnlySpan[readOnlySpan.
Length - 1] ==
'*')
1727 readOnlySpan = readOnlySpan.
Slice(0, readOnlySpan.
Length - 1);
1728 return span.StartsWith(readOnlySpan,
comparison);
int IList. IndexOf(object value)
static int BinarySearch(Array array, object? value)
static readonly Comparer Default
static ulong ToUInt64(object value)
static bool Equals(this ReadOnlySpan< char > span, ReadOnlySpan< char > other, StringComparison comparisonType)
static Exception ByDesign
virtual ? object GetRawConstantValue()
virtual bool HasSameMetadataDefinitionAs(MemberInfo other)
static readonly Missing Value
static RuntimeType GetType(string typeName, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark)
static Type GetTypeFromProgID(string progID, string server, bool throwOnError)
static Type GetTypeFromCLSID(Guid clsid, string server, bool throwOnError)
static string Arg_MustBeEnum
static string Arg_InvalidHandle
static string Arg_EnumAndObjectMustBeSameType
static string Format(string resourceFormat, object p1)
static string Arg_MemberInfoNotFound
static string PlatformNotSupported_ReflectionOnly
static string Arg_NotGenericParameter
static string InvalidOperation_UnknownEnumType
static string InvalidFilterCriteriaException_CritString
static string ArgumentNull_ArrayValue
static string Argument_InvalidEnum
static string ArgumentOutOfRange_NeedNonNegNum
static string InvalidFilterCriteriaException_CritInt
static string Arg_EnumUnderlyingTypeAndObjectMustBeSameType
static string Arg_MustBeEnumBaseTypeOrEnum
static string NotSupported_SubclassOverride
static int CompareExchange(ref int location1, int value, int comparand)
static Type GetType(string typeName, Func< AssemblyName, Assembly > assemblyResolver, Func< Assembly, string, bool, Type > typeResolver, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark)
virtual bool IsAssignableFrom([NotNullWhen(true)] Type? c)
virtual ? MethodBase DeclaringMethod
EventInfo[] GetEvents(BindingFlags bindingAttr)
FieldInfo[] GetFields(BindingFlags bindingAttr)
static RuntimeTypeHandle GetTypeHandle(object o)
TypeAttributes Attributes
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
virtual ? string GetEnumName(object value)
Array GetEnumRawConstantValues()
PropertyInfo? GetProperty(string name, BindingFlags bindingAttr)
virtual MemberInfo[] GetMember(string name, BindingFlags bindingAttr)
virtual Type[] GetGenericParameterConstraints()
virtual Type[] GenericTypeArguments
virtual Type[] FindInterfaces(TypeFilter filter, object? filterCriteria)
virtual RuntimeTypeHandle GetTypeHandleInternal()
void GetEnumData(out string[] enumNames, out Array enumValues)
Type UnderlyingSystemType
EventInfo? GetEvent(string name)
static readonly char Delimiter
static ? Type ReflectionOnlyGetType(string typeName, bool throwIfNotFound, bool ignoreCase)
virtual Type[] GetGenericArguments()
Type? GetNestedType(string name, BindingFlags bindingAttr)
virtual bool IsMarshalByRefImpl()
PropertyInfo? GetProperty(string name)
virtual bool IsSecurityCritical
virtual bool IsGenericParameter
PropertyInfo? GetProperty(string name, Type? returnType, Type[] types, ParameterModifier[]? modifiers)
static volatile Binder s_defaultBinder
virtual Type MakeGenericType(params Type[] typeArguments)
virtual bool IsSecuritySafeCritical
Type? GetInterface(string name)
virtual bool IsSerializable
virtual bool IsGenericTypeParameter
object? InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object?[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters)
ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
bool HasElementTypeImpl()
FieldInfo? GetField(string name)
static bool operator==(Type? left, Type? right)
ConstructorInfo? TypeInitializer
virtual bool IsConstructedGenericType
MethodInfo? GetMethodImpl(string name, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[]? types, ParameterModifier[]? modifiers)
static readonly MemberFilter FilterAttribute
MethodInfo? GetMethod(string name, BindingFlags bindingAttr, Binder? binder, Type[] types, ParameterModifier[]? modifiers)
FieldInfo? GetField(string name, BindingFlags bindingAttr)
override MemberTypes MemberType
virtual MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo member)
static ? Type GetTypeFromProgID(string progID, string? server)
virtual string[] GetEnumNames()
static bool FilterNameImpl(MemberInfo m, object filterCriteria, StringComparison comparison)
virtual MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter? filter, object? filterCriteria)
ConstructorInfo? GetConstructorImpl(BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[] types, ParameterModifier[]? modifiers)
virtual int GenericParameterPosition
PropertyInfo[] GetProperties(BindingFlags bindingAttr)
virtual bool IsVariableBoundArray
static bool FilterAttributeImpl(MemberInfo m, object filterCriteria)
override bool Equals(object? o)
static ? Type GetTypeFromCLSID(Guid clsid, string? server)
virtual int GetArrayRank()
MethodInfo? GetMethod(string name, int genericParameterCount, Type[] types)
virtual MemberInfo[] GetDefaultMembers()
virtual bool IsSecurityTransparent
virtual bool IsEnumDefined(object value)
static Binder DefaultBinder
object? InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object?[]? args)
static TypeCode GetTypeCode(Type? type)
MethodInfo? GetMethod(string name, BindingFlags bindingAttr, Type[] types)
virtual bool IsInstanceOfType([NotNullWhen(true)] object? o)
static ? Type GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError)
override int GetHashCode()
static ? Type GetType(string typeName, bool throwOnError)
ConstructorInfo? GetConstructor(Type[] types)
static ? Type GetTypeFromProgID(string progID, string? server, bool throwOnError)
static RuntimeType GetTypeFromHandleUnsafe(IntPtr handle)
Type[] GetNestedTypes(BindingFlags bindingAttr)
ConstructorInfo? GetConstructor(BindingFlags bindingAttr, Binder? binder, Type[] types, ParameterModifier[]? modifiers)
PropertyInfo? GetProperty(string name, Type[] types)
static Type MakeGenericSignatureType(Type genericTypeDefinition, params Type[] typeArguments)
PropertyInfo[] GetProperties()
bool IsAssignableTo([NotNullWhen(true)] Type? targetType)
MethodInfo? GetMethod(string name, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[] types, ParameterModifier[]? modifiers)
static Type GetTypeFromHandle(RuntimeTypeHandle handle)
PropertyInfo? GetPropertyImpl(string name, BindingFlags bindingAttr, Binder? binder, Type? returnType, Type[]? types, ParameterModifier[]? modifiers)
MemberInfo[] GetMembers(BindingFlags bindingAttr)
virtual bool IsSignatureType
static ? Type GetTypeFromProgID(string progID)
virtual bool IsGenericType
virtual Type GetEnumUnderlyingType()
MethodInfo? GetMethod(string name, Type[] types, ParameterModifier[]? modifiers)
virtual bool IsGenericMethodParameter
ConstructorInfo? GetConstructor(BindingFlags bindingAttr, Type[] types)
static int BinarySearch(Array array, object value)
static ? Type GetTypeFromCLSID(Guid clsid, bool throwOnError)
Type? GetInterface(string name, bool ignoreCase)
static ? Type GetType(string typeName)
bool ImplementInterface(Type ifaceType)
virtual bool IsContextfulImpl()
MethodInfo? GetMethod(string name, int genericParameterCount, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[] types, ParameterModifier[]? modifiers)
PropertyInfo? GetProperty(string name, Type? returnType, Type[] types)
ConstructorInfo? GetConstructor(BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[] types, ParameterModifier[]? modifiers)
PropertyInfo? GetProperty(string name, Type? returnType)
static ? Type GetTypeFromProgID(string progID, bool throwOnError)
PropertyInfo? GetProperty(string name, BindingFlags bindingAttr, Binder? binder, Type? returnType, Type[] types, ParameterModifier[]? modifiers)
static ? Type GetType(string typeName, Func< AssemblyName, Assembly?>? assemblyResolver, Func< Assembly?, string, bool, Type?>? typeResolver, bool throwOnError)
static readonly MemberFilter FilterNameIgnoreCase
virtual MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
virtual bool Equals(Type? o)
override? Type DeclaringType
static bool IsIntegerType(Type t)
static Type[] GetTypeArray(object[] args)
virtual bool IsTypeDefinition
Type? GetNestedType(string name)
virtual bool IsEquivalentTo([NotNullWhen(true)] Type? other)
virtual Type MakeArrayType(int rank)
bool IsRuntimeImplemented()
virtual bool IsSubclassOf(Type c)
virtual ? MethodInfo GetMethodImpl(string name, int genericParameterCount, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[]? types, ParameterModifier[]? modifiers)
static ? Type GetType(string typeName, Func< AssemblyName, Assembly?>? assemblyResolver, Func< Assembly?, string, bool, Type?>? typeResolver, bool throwOnError, bool ignoreCase)
virtual Array GetEnumValues()
MethodInfo? GetMethod(string name, BindingFlags bindingAttr)
Type GetRootElementType()
TypeAttributes GetAttributeFlagsImpl()
virtual Type MakeArrayType()
override? Type ReflectedType
string? AssemblyQualifiedName
static readonly Type[] EmptyTypes
MethodInfo[] GetMethods()
virtual InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.NonPublicMethods)] Type interfaceType)
static ? Type GetType(string typeName, Func< AssemblyName, Assembly?>? assemblyResolver, Func< Assembly?, string, bool, Type?>? typeResolver)
virtual TypeCode GetTypeCodeImpl()
static bool operator!=(Type? left, Type? right)
override string ToString()
static ArgumentException CreateGetMemberWithSameMetadataDefinitionAsNotFoundException(MemberInfo member)
virtual bool IsValueTypeImpl()
virtual bool IsGenericTypeDefinition
virtual bool ContainsGenericParameters
object? InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object?[]? args, CultureInfo? culture)
MethodInfo? GetMethod(string name, int genericParameterCount, BindingFlags bindingAttr, Binder? binder, Type[] types, ParameterModifier[]? modifiers)
MethodInfo? GetMethod(string name)
MethodInfo? GetMethod(string name, int genericParameterCount, Type[] types, ParameterModifier[]? modifiers)
ConstructorInfo[] GetConstructors()
static Type MakeGenericMethodParameter(int position)
virtual Type GetGenericTypeDefinition()
EventInfo? GetEvent(string name, BindingFlags bindingAttr)
MemberInfo[] GetMember(string name)
virtual Type MakeByRefType()
static readonly MemberFilter FilterName
virtual Type MakePointerType()
MethodInfo[] GetMethods(BindingFlags bindingAttr)
MemberInfo[] GetMembers()
MethodInfo? GetMethod(string name, Type[] types)
static ? Type GetTypeFromCLSID(Guid clsid)
virtual RuntimeTypeHandle TypeHandle
virtual EventInfo[] GetEvents()
DynamicallyAccessedMemberTypes
GenericParameterAttributes
delegate bool TypeFilter(Type m, object? filterCriteria)
delegate bool MemberFilter(MemberInfo m, object? filterCriteria)
ReadOnlySpan< T > Slice(int start)
static bool IsInterface(RuntimeType type)
static bool IsVisible(RuntimeType type)