12 select i.GetGenericTypeDefinition()).ToArray();
18 if (!
type.IsNullableType())
22 return type.GetGenericArguments()[0];
27 if (
type.IsValueType && !
type.IsNullableType())
41 if (
type.IsConstructedGenericType)
52 return type.IsNullableType();
59 return type.GetNonNullableType() == typeof(
bool);
68 if ((uint)(typeCode - 4) <= 10u)
82 if ((uint)(typeCode - 5) <= 7u)
96 if ((uint)(typeCode - 11) <= 1u)
110 if ((uint)(typeCode - 7) <= 7u)
123 switch (
type.GetTypeCode())
140 if (typeCode ==
TypeCode.Boolean || (uint)(typeCode - 5) <= 7u)
150 if (!
type.IsNumeric())
152 return type.IsBool();
160 if (declaringType ==
null)
184 Type[]
array = GetTypeInterfaces(instanceType);
195 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2070:UnrecognizedReflectionPattern", Justification =
"The targetType must be preserved (since we have an instance of it here),So if it's an interface that interface will be preserved everywhereSo if it was implemented by the instanceType, it will be kept even after trimming.The fact that GetInterfaces may return fewer interfaces doesn't matter as longas it returns the one we're looking for.")]
196 static Type[] GetTypeInterfaces(
Type instanceType)
216 if (
source.IsConvertible() && dest.IsConvertible())
218 if (!(dest.GetNonNullableType() != typeof(
bool)))
222 return source.GetEnumUnderlyingType() == typeof(
bool);
233 if (
source == typeof(
void) || dest == typeof(
void))
237 Type nonNullableType =
source.GetNonNullableType();
238 Type nonNullableType2 = dest.GetNonNullableType();
257 return source.StrictHasReferenceConversionTo(dest, skipNonArray:
true);
300 skipNonArray =
false;
323 if (genericArguments.Length != 1)
333 return source.GetElementType().StrictHasReferenceConversionTo(genericArguments[0], skipNonArray:
false);
346 if (genericArguments.Length != 1)
356 return genericArguments[0].StrictHasReferenceConversionTo(dest.GetElementType(), skipNonArray:
false);
396 for (
int i = 0; i < genericArguments.Length; i++)
399 Type type2 = genericArguments3[i];
404 Type t = genericArguments[i];
411 if (!
type.HasReferenceConversionTo(type2))
432 if ((uint)(typeCode - 3) <= 11u)
470 Type nonNullableType = left.GetNonNullableType();
471 if (!(nonNullableType == typeof(
bool)) && !nonNullableType.IsNumeric())
473 return nonNullableType.
IsEnum;
487 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2075:UnrecognizedReflectionPattern", Justification =
"The trimmer doesn't remove operators when System.Linq.Expressions is used. See https://github.com/mono/linker/pull/2125.")]
490 Type nonNullableType = convertFrom.GetNonNullableType();
491 Type nonNullableType2 = convertToType.GetNonNullableType();
494 if (methodInfo !=
null)
500 if (methodInfo !=
null)
517 ParameterInfo[] parametersCached = methodInfo.GetParametersCached();
518 if (parametersCached.Length == 1 &&
AreEquivalent(parametersCached[0].ParameterType, typeFrom))
546 if ((uint)(typeCode2 - 7) <= 8u)
563 if ((uint)(typeCode2 - 9) <= 6u)
569 if (typeCode2 ==
TypeCode.Int64 || (uint)(typeCode2 - 13) <= 2u)
575 if ((uint)(typeCode2 - 11) <= 4u)
582 if ((uint)(typeCode2 - 13) <= 2u)
588 if ((uint)(typeCode2 - 8) <= 7u)
594 return typeCode2 ==
TypeCode.Double;
621 return source.GetNonNullableType().IsImplicitlyConvertibleTo(
destination.GetNonNullableType());
628 while ((
object)
type !=
null &&
type != typeof(
object))
639 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2067:UnrecognizedReflectionPattern", Justification =
"The trimmer doesn't remove operators when System.Linq.Expressions is used. See https://github.com/mono/linker/pull/2125.")]
647 return anyStaticMethodValidated;
651 while (
type !=
null);
661 return type.GetElementType();
704 if (!allowByRef &&
type.IsByRef)
708 if (!allowPointer &&
type.IsPointer)
717 if (
type == typeof(
void))
721 if (
type.ContainsGenericParameters)
728 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2070:UnrecognizedReflectionPattern", Justification =
"The trimmer will never remove the Invoke method from delegates.")]
736 return type.GetNonNullableType().GetTypeCode().IsUnsigned();
756 return type.GetNonNullableType().GetTypeCode().IsFloatingPoint();
761 if ((uint)(typeCode - 13) <= 1u)
768 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2070:UnrecognizedReflectionPattern", Justification =
"The Array 'Get' method is dynamically constructed and is not included in IL. It is not subject to trimming.")]
774 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2070:UnrecognizedReflectionPattern", Justification =
"The Array 'Set' method is dynamically constructed and is not included in IL. It is not subject to trimming.")]
780 [UnconditionalSuppressMessage(
"ReflectionAnalysis",
"IL2070:UnrecognizedReflectionPattern", Justification =
"The Array 'Address' method is dynamically constructed and is not included in IL. It is not subject to trimming.")]
static bool IsInteger(this Type type)
static bool IsDelegate(Type t)
static bool HasReferenceEquality(Type left, Type right)
static bool IsNullableType(this Type type)
static bool IsNumericOrBool(this Type type)
static ConstructorInfo GetNullableConstructor(Type nullableType)
static bool IsSameOrSubclass(Type type, Type subType)
static MethodInfo GetArrayGetMethod(Type arrayType)
static bool StrictHasReferenceConversionTo(this Type source, Type dest, bool skipNonArray)
static Type FindGenericType(Type definition, Type type)
static bool IsUnsignedInt(this Type type)
static bool HasBuiltInEqualityOperator(Type left, Type right)
static bool IsFloatingPoint(this Type type)
static bool IsImplicitNullableConversion(Type source, Type destination)
static bool IsUnsigned(this Type type)
static Type GetNonNullableType(this Type type)
static void ValidateType(Type type, string paramName)
static bool IsLegalExplicitVariantDelegateConversion(Type source, Type dest)
static bool IsArithmetic(this Type type)
static readonly ConstructorInfo s_nullableConstructor
static bool IsImplicitReferenceConversion(Type source, Type destination)
static bool IsIntegerOrBool(this Type type)
static bool IsFloatingPoint(this TypeCode typeCode)
static Type GetNonRefType(this Type type)
static bool IsUnsigned(this TypeCode typeCode)
static bool IsImplicitNumericConversion(Type source, Type destination)
static bool AreEquivalent(Type t1, Type t2)
static MethodInfo GetInvokeMethod(this Type delegateType)
static bool IsCovariant(Type t)
static bool IsNumeric(this Type type)
static Type GetNullableType(this Type type)
static bool ValidateType(Type type, string paramName, int index)
static MethodInfo GetBooleanOperator(Type type, string name)
static bool IsInteger64(this Type type)
static bool IsImplicitlyConvertibleTo(this Type source, Type destination)
static bool HasInterfaceToArrayConversion(Type source, Type dest)
static void ValidateType(Type type, string paramName, bool allowByRef, bool allowPointer)
static bool AreReferenceAssignable(Type dest, Type src)
static bool IsBool(this Type type)
static readonly Type[] s_arrayAssignableInterfaces
static bool IsConvertible(this Type type)
static bool IsImplicitBoxingConversion(Type source, Type destination)
static MethodInfo FindConversionOperator(MethodInfo[] methods, Type typeFrom, Type typeTo)
static bool IsNullableOrReferenceType(this Type type)
static bool IsValidInstanceType(MemberInfo member, Type instanceType)
static bool HasArrayToInterfaceConversion(Type source, Type dest)
static MethodInfo GetArraySetMethod(Type arrayType)
static bool IsContravariant(Type t)
static bool HasReferenceConversionTo(this Type source, Type dest)
static bool IsInvariant(Type t)
static MethodInfo GetArrayAddressMethod(Type arrayType)
static MethodInfo GetUserDefinedCoercionMethod(Type convertFrom, Type convertToType)
static bool HasIdentityPrimitiveOrNullableConversionTo(this Type source, Type dest)
static Exception TypeIsGeneric(object p0, string paramName)
static Exception TypeContainsGenericParameters(object p0, string paramName)
static Exception TypeMustNotBePointer(string paramName)
static Exception TypeMustNotBeByRef(string paramName)
virtual bool ContainsGenericParameters
virtual bool IsAssignableFrom([NotNullWhen(true)] Type? c)
virtual GenericParameterAttributes GenericParameterAttributes
virtual Type[] GetGenericArguments()
virtual MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo member)
virtual int GetArrayRank()
virtual bool IsGenericType
virtual bool IsEquivalentTo([NotNullWhen(true)] Type? other)
virtual bool IsSubclassOf(Type c)
MethodInfo[] GetMethods()
MethodInfo? GetMethod(string name)
virtual Type GetGenericTypeDefinition()
GenericParameterAttributes