src\libraries\System.Private.CoreLib\src\System\Enum.cs (42)
59RuntimeType rt = (RuntimeType)typeof(TEnum);
100internal static string? GetName(RuntimeType enumType, ulong uint64Value)
223RuntimeType rt = (RuntimeType)typeof(TEnum);
256internal static string[] GetNamesNoCopy(RuntimeType enumType)
292Array values = GetValuesAsUnderlyingTypeNoCopy((RuntimeType)typeof(TEnum));
339internal static Array GetValuesAsUnderlyingType(RuntimeType enumType)
369internal static Array GetValuesAsUnderlyingTypeNoCopy(RuntimeType enumType)
474RuntimeType rt = (RuntimeType)typeof(TEnum);
492internal static bool IsDefinedPrimitive<TStorage>(RuntimeType enumType, TStorage value)
723RuntimeType rt = ValidateRuntimeType(enumType);
774static bool TryParseRareTypes(RuntimeType rt, ReadOnlySpan<char> value, bool ignoreCase, bool throwOnFailure, [NotNullWhen(true)] out long result)
891RuntimeType rt = (RuntimeType)typeof(TEnum);
915RuntimeType enumType, ReadOnlySpan<char> value, bool ignoreCase, bool throwOnFailure, out TUnderlying result)
973RuntimeType enumType, ReadOnlySpan<char> value, bool ignoreCase, bool throwOnFailure, out TUnderlying result)
1043private static bool TryParseByName<TStorage>(RuntimeType enumType, ReadOnlySpan<char> value, bool ignoreCase, bool throwOnFailure, out TStorage result)
1357RuntimeType enumType = (RuntimeType)GetType();
1374static string HandleRareTypes(RuntimeType enumType, ref byte rawData) =>
1405RuntimeType enumType = (RuntimeType)GetType();
1425static string HandleRareTypes(RuntimeType enumType, char formatChar, ref byte rawData) =>
1452private static string ToString<TUnderlying, TStorage>(RuntimeType enumType, ref byte rawData)
1464private static string ToStringInlined<TUnderlying, TStorage>(RuntimeType enumType, ref byte rawData)
1481private static string ToString<TUnderlying, TStorage>(RuntimeType enumType, char format, ref byte rawData)
1494private static string ToStringInlined<TUnderlying, TStorage>(RuntimeType enumType, char format, ref byte rawData)
1630RuntimeType rtType = ValidateRuntimeType(enumType);
1690RuntimeType enumType = (RuntimeType)GetType();
1750RuntimeType rt = (RuntimeType)typeof(TEnum);
1809RuntimeType rt = (RuntimeType)typeof(TEnum);
1857private static bool TryFormatPrimitiveDefault<TUnderlying, TStorage>(RuntimeType enumType, TUnderlying value, Span<char> destination, out int charsWritten)
1892private static bool TryFormatPrimitiveNonDefault<TUnderlying, TStorage>(RuntimeType enumType, TUnderlying value, Span<char> destination, out int charsWritten, ReadOnlySpan<char> format)
2126private static RuntimeType ValidateRuntimeType(Type enumType)
2130RuntimeType? rt = enumType as RuntimeType;
2148throw new ArgumentException(enumType is not RuntimeType ? SR.Arg_MustBeType : SR.Arg_MustBeEnum, nameof(enumType));
src\libraries\System.Private.CoreLib\src\System\Reflection\FieldAccessor.cs (10)
43RuntimeType fieldType = (RuntimeType)_fieldInfo.FieldType;
178object? ret = RuntimeFieldHandle.GetValue(_fieldInfo, obj, (RuntimeType)_fieldInfo.FieldType, _fieldInfo.m_declaringType, ref isClassInitialized);
193return RuntimeFieldHandle.GetValue(_fieldInfo, obj, (RuntimeType)_fieldInfo.FieldType, _fieldInfo.m_declaringType, ref isClassInitialized);
199if (_fieldInfo.DeclaringType is not null && ((RuntimeType)_fieldInfo.FieldType).IsNullableOfT)
303RuntimeFieldHandle.SetValue(_fieldInfo, obj, value, (RuntimeType)_fieldInfo.FieldType, _fieldInfo.m_declaringType, ref isClassInitialized);
330RuntimeFieldHandle.SetValue(_fieldInfo, obj, value, (RuntimeType)_fieldInfo.FieldType, _fieldInfo.m_declaringType, ref isClassInitialized);
370if (((RuntimeType)_fieldInfo.FieldType).IsActualValueType)
372((RuntimeType)_fieldInfo.FieldType).CheckValue(ref value, binder, culture, invokeAttr);
377((RuntimeType)_fieldInfo.FieldType).CheckValue(ref value, binder, culture, invokeAttr);
src\System\Delegate.CoreCLR.cs (19)
48if (!BindToMethodName(target, (RuntimeType)target.GetType(), method,
64if (target is not RuntimeType rtTarget)
83RuntimeMethodInfo invoke = (RuntimeMethodInfo)RuntimeType.GetMethodBase((RuntimeType)this.GetType(), method)!;
167RuntimeType? declaringType = RuntimeMethodHandle.GetDeclaringType(method);
194declaringType = currentType as RuntimeType;
212declaringType = (RuntimeType)invoke.GetParametersAsSpan()[0].ParameterType;
217_methodBase = (MethodInfo)RuntimeType.GetMethodBase(declaringType, method)!;
231if (type is not RuntimeType rtType)
244if (!d.BindToMethodName(target, (RuntimeType)target.GetType(), method,
268if (type is not RuntimeType rtType)
270if (target is not RuntimeType rtTarget)
301if (type is not RuntimeType rtType)
336if (type is not RuntimeType rtType)
374if (type is not RuntimeType rtType)
395internal static Delegate? CreateDelegateInternal(RuntimeType rtType, RuntimeMethodInfo rtMethod, object? firstArgument, DelegateBindingFlags flags)
411private bool BindToMethodName(object? target, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.AllMethods)] RuntimeType methodType, string method, DelegateBindingFlags flags)
422private bool BindToMethodInfo(object? target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags)
435private static MulticastDelegate InternalAlloc(RuntimeType type)
src\System\Enum.CoreCLR.cs (27)
18private static unsafe CorElementType InternalGetCorElementType(RuntimeType rt)
35private static readonly RuntimeType?[] s_underlyingTypes =
39(RuntimeType)typeof(bool),
40(RuntimeType)typeof(char),
41(RuntimeType)typeof(sbyte),
42(RuntimeType)typeof(byte),
43(RuntimeType)typeof(short),
44(RuntimeType)typeof(ushort),
45(RuntimeType)typeof(int),
46(RuntimeType)typeof(uint),
47(RuntimeType)typeof(long),
48(RuntimeType)typeof(ulong),
49(RuntimeType)typeof(float),
50(RuntimeType)typeof(double),
61(RuntimeType)typeof(nint),
62(RuntimeType)typeof(nuint)
66internal static unsafe RuntimeType InternalGetUnderlyingType(RuntimeType enumType)
71RuntimeType? underlyingType = s_underlyingTypes[(int)enumType.GetNativeTypeHandle().AsMethodTable()->GetPrimitiveCorElementType()];
79private static EnumInfo<TStorage> GetEnumInfo<TStorage>(RuntimeType enumType, bool getNames = true)
92static EnumInfo<TStorage> InitializeEnumInfo(RuntimeType enumType, bool getNames)
103internal sealed partial class EnumInfo<TStorage> : RuntimeType.IGenericCacheEntry<EnumInfo<TStorage>>
105public static EnumInfo<TStorage> Create(RuntimeType type, bool getNames)
123public static EnumInfo<TStorage> Create(RuntimeType type) => Create(type, getNames: false);
125public void InitializeCompositeCache(RuntimeType.CompositeCacheEntry compositeEntry) => compositeEntry._enumInfo = this;
128public static ref EnumInfo<TStorage>? GetStorageRef(RuntimeType.CompositeCacheEntry compositeEntry)
129=> ref Unsafe.As<RuntimeType.IGenericCacheEntry?, EnumInfo<TStorage>?>(ref compositeEntry._enumInfo);
src\System\Reflection\RtFieldInfo.cs (8)
8using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
20private RuntimeType? m_fieldType;
37RuntimeFieldHandleInternal handle, RuntimeType declaringType, RuntimeTypeCache reflectedTypeCache, BindingFlags bindingFlags)
96return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, obj, (RuntimeType?)DeclaringType);
112RuntimeFieldHandle.SetValueDirect(this, (RuntimeType)FieldType, obj, value, (RuntimeType?)DeclaringType);
131private RuntimeType InitializeFieldType()
src\System\Reflection\RuntimeCustomAttributeData.cs (104)
18internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeType target)
23RuntimeType.ListBuilder<Attribute> pcas = default;
24PseudoCustomAttribute.GetCustomAttributes(target, (RuntimeType)typeof(object), ref pcas);
33RuntimeType.ListBuilder<Attribute> pcas = default;
34PseudoCustomAttribute.GetCustomAttributes(target, (RuntimeType)typeof(object), ref pcas);
43RuntimeType.ListBuilder<Attribute> pcas = default;
44PseudoCustomAttribute.GetCustomAttributes(target, (RuntimeType)typeof(object), ref pcas);
92RuntimeType.ListBuilder<Attribute> pcas = default;
94PseudoCustomAttribute.GetCustomAttributes(target, (RuntimeType)typeof(object), ref pcas);
98private static ReadOnlyCollection<CustomAttributeData> GetCombinedList(IList<CustomAttributeData> customAttributes, ref RuntimeType.ListBuilder<Attribute> pseudoAttributes)
113internal static CustomAttributeEncoding TypeToCustomAttributeEncoding(RuntimeType type)
254m_ctor = (RuntimeConstructorInfo)RuntimeType.GetMethodBase(m_scope, caCtorToken)!;
268m_ctorParams[i] = new CustomAttributeCtorParameter(new CustomAttributeType((RuntimeType)parameters[i].ParameterType));
287new CustomAttributeType((RuntimeType)fi.FieldType));
295new CustomAttributeType((RuntimeType)pi.PropertyType));
543private static RuntimeType ResolveType(RuntimeModule scope, string typeName)
545RuntimeType type = TypeNameResolver.GetTypeReferencedByCustomAttribute(typeName, scope);
902enumTag = RuntimeCustomAttributeData.TypeToCustomAttributeEncoding((RuntimeType)enumType.GetEnumUnderlyingType());
1078public CustomAttributeType(RuntimeType parameterType)
1088parameterType = (RuntimeType)parameterType.GetElementType()!;
1096encodedEnumType = RuntimeCustomAttributeData.TypeToCustomAttributeEncoding((RuntimeType)Enum.GetUnderlyingType(parameterType));
1116internal static bool IsDefined(RuntimeType type, RuntimeType? caType, bool inherit)
1132type = (type.BaseType as RuntimeType)!;
1139type = (type.BaseType as RuntimeType)!;
1145internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
1172internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
1182internal static bool IsDefined(RuntimePropertyInfo property, RuntimeType caType)
1192internal static bool IsDefined(RuntimeEventInfo e, RuntimeType caType)
1202internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
1213internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType)
1224internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
1233internal static bool IsDefined(RuntimeModule module, RuntimeType caType)
1243internal static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
1252type = (type.GetGenericTypeDefinition() as RuntimeType)!;
1254RuntimeType.ListBuilder<Attribute> pcas = default;
1267RuntimeType.ListBuilder<object> result = default;
1277type = (type.BaseType as RuntimeType)!;
1278} while (type != (RuntimeType)typeof(object) && type != null);
1288internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
1296RuntimeType.ListBuilder<Attribute> pcas = default;
1309RuntimeType.ListBuilder<object> result = default;
1330internal static object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
1340internal static object[] GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType)
1350internal static object[] GetCustomAttributes(RuntimeEventInfo e, RuntimeType caType)
1360internal static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType)
1365RuntimeType.ListBuilder<Attribute> pcas = default;
1372internal static object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType)
1377RuntimeType.ListBuilder<Attribute> pcas = default;
1384internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
1395internal static object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType)
1411RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType? attributeFilterType)
1417RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType? attributeFilterType, int attributeCtorToken, bool mustBeInheritable)
1433RuntimeType.ListBuilder<object> derivedAttributes = default;
1470RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType)
1472RuntimeType.ListBuilder<object> attributes = default;
1489ref RuntimeType.ListBuilder<object> attributes,
1491RuntimeType? attributeFilterType, bool mustBeInheritable,
1493RuntimeType.ListBuilder<object> derivedAttributes)
1513out RuntimeType attributeType, out IRuntimeMethodInfo? ctorWithParameters, out bool isVarArg))
1561GetPropertyOrFieldData(decoratedModule, ref blobStart, blobEnd, out string name, out bool isProperty, out RuntimeType? type, out object? value);
1569type = (RuntimeType)value.GetType();
1570if (type == typeof(RuntimeType))
1572type = (RuntimeType)typeof(Type);
1623RuntimeType attributeFilterType,
1625ref RuntimeType.ListBuilder<object> derivedAttributes,
1626out RuntimeType attributeType,
1634attributeType = (decoratedModule.ResolveType(scope.GetParentToken(caCtorToken), null, null) as RuntimeType)!;
1712private static bool MatchesTypeFilter(RuntimeType attributeType, RuntimeType attributeFilterType)
1716for (RuntimeType? type = attributeType; type != null; type = (RuntimeType?)type.BaseType)
1732RuntimeType attributeType, bool mustBeInheritable, ref RuntimeType.ListBuilder<object> derivedAttributes)
1765internal static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute)
1776RuntimeType? attributeType = decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType;
1778if (attributeType != (RuntimeType)typeof(AttributeUsageAttribute))
1799internal static object[] CreateAttributeArrayHelper(RuntimeType caType, int elementCount)
1872private static object CreateCustomAttributeInstance(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs)
1902RuntimeModule module, ref IntPtr blobStart, IntPtr blobEnd, out string name, out bool isProperty, out RuntimeType? type, out object? value)
1910RuntimeType? typeLocal = null;
1933private static readonly HashSet<RuntimeType> s_pca = CreatePseudoCustomAttributeHashSet();
1937private static HashSet<RuntimeType> CreatePseudoCustomAttributeHashSet()
1955HashSet<RuntimeType> set = new HashSet<RuntimeType>(pcas.Length);
1956foreach (RuntimeType runtimeType in pcas)
1965private static void VerifyPseudoCustomAttribute(RuntimeType pca)
1984internal static void GetCustomAttributes(RuntimeType type, RuntimeType caType, ref RuntimeType.ListBuilder<Attribute> pcas)
2006internal static bool IsDefined(RuntimeType type, RuntimeType? caType)
2028internal static void GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, ref RuntimeType.ListBuilder<Attribute> pcas)
2048internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType? caType)
2068internal static void GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType, ref RuntimeType.ListBuilder<Attribute> pcas)
2098internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType? caType)
2124internal static void GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType, ref RuntimeType.ListBuilder<Attribute> pcas)
2153internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType? caType)
2265internal static StructLayoutAttribute? GetStructLayoutCustomAttribute(RuntimeType type)
src\System\Reflection\RuntimeMethodInfo.CoreCLR.cs (30)
12using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
28private readonly RuntimeType m_declaringType;
56RuntimeMethodHandleInternal handle, RuntimeType declaringType,
74private RuntimeType ReflectedTypeInternal => m_reflectedTypeCache.GetRuntimeType();
114RuntimeType? parent = (RuntimeType?)m_declaringType.BaseType;
124return (RuntimeMethodInfo?)RuntimeType.GetMethodBase(parent, RuntimeTypeHandle.GetMethodAt(parent, slot));
128internal RuntimeType GetDeclaringTypeInternal()
176return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!, inherit);
183if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
193if (attributeType.UnderlyingSystemType is not RuntimeType attributeRuntimeType)
235internal RuntimeType GetRuntimeType() { return m_declaringType; }
273internal RuntimeType[] ArgumentTypes => Signature.Arguments;
342RuntimeType declaringType = (RuntimeType)DeclaringType!;
343RuntimeType? baseDeclaringType = declaringType;
356declaringType = (RuntimeType)declaringType.BaseType!;
359return (MethodInfo)RuntimeType.GetMethodBase(baseDeclaringType, baseMethodHandle)!;
395RuntimeType rtType = delegateType as RuntimeType ??
413RuntimeType[] methodInstantionRuntimeType = new RuntimeType[methodInstantiation.Length];
424RuntimeType? rtMethodInstantiationElem = methodInstantiationElem as RuntimeType;
438RuntimeType[] genericParameters = GetGenericArgumentsInternal();
440RuntimeType.SanityCheckGenericArguments(methodInstantionRuntimeType, genericParameters);
446ret = RuntimeType.GetMethodBase(ReflectedTypeInternal,
451RuntimeType.ValidateGenericArguments(this, methodInstantionRuntimeType, e);
458internal RuntimeType[] GetGenericArgumentsInternal() =>
469return (RuntimeType.GetMethodBase(m_declaringType, RuntimeMethodHandle.StripMethodInstantiation(this)) as MethodInfo)!;
src\System\Runtime\InteropServices\DynamicInterfaceCastableHelpers.cs (7)
17internal static bool IsInterfaceImplemented(IDynamicInterfaceCastable castable, RuntimeType interfaceType, bool throwIfNotImplemented)
28private static unsafe void IsInterfaceImplemented(IDynamicInterfaceCastable* pCastable, RuntimeType* pInterfaceType, bool throwIfNotImplemented, bool* pResult, Exception* pException)
41internal static RuntimeType? GetInterfaceImplementation(IDynamicInterfaceCastable castable, RuntimeType interfaceType)
47RuntimeType implType = handle.GetRuntimeType();
62private static unsafe void GetInterfaceImplementation(IDynamicInterfaceCastable* pCastable, RuntimeType* pInterfaceType, RuntimeType* pResult, Exception* pException)
src\System\RuntimeHandles.cs (124)
25internal RuntimeType GetRuntimeTypeChecked() =>
42private static RuntimeType GetRuntimeTypeFromHandleSlow(IntPtr handle)
44RuntimeType? typeObject = null;
50internal static unsafe RuntimeType GetRuntimeTypeFromHandle(IntPtr handle)
59internal static RuntimeType? GetRuntimeTypeFromHandleMaybeNull(IntPtr handle)
71internal static unsafe RuntimeType GetRuntimeType(MethodTable* pMT)
93internal RuntimeType? m_type;
106internal RuntimeTypeHandle(RuntimeType? type)
116internal static bool IsTypeDefinition(RuntimeType type)
134internal static bool IsPrimitive(RuntimeType type)
139internal static bool IsByRef(RuntimeType type)
145internal static bool IsPointer(RuntimeType type)
151internal static bool IsArray(RuntimeType type)
157internal static bool IsSZArray(RuntimeType type)
163internal static bool IsFunctionPointer(RuntimeType type)
169internal static bool HasElementType(RuntimeType type)
228[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] RuntimeType type,
229RuntimeType genericParameter)
251[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] RuntimeType type,
252RuntimeType genericParameter1,
253RuntimeType genericParameter2)
294internal static object InternalAlloc(RuntimeType type)
337RuntimeType rt,
388internal RuntimeType GetRuntimeType()
393internal static RuntimeAssembly GetAssembly(RuntimeType type)
398static RuntimeAssembly GetAssemblyWorker(RuntimeType type)
407private static extern RuntimeAssembly? GetAssemblyIfExists(RuntimeType type);
412internal static RuntimeModule GetModule(RuntimeType type)
417static RuntimeModule GetModuleWorker(RuntimeType type)
426private static extern RuntimeModule? GetModuleIfExists(RuntimeType type);
442internal static extern TypeAttributes GetAttributes(RuntimeType type);
447internal static RuntimeType? GetElementType(RuntimeType type)
455RuntimeType result = GetRuntimeTypeFromHandle(handle);
461internal static extern bool CompareCanonicalHandles(RuntimeType left, RuntimeType right);
464internal static extern int GetArrayRank(RuntimeType type);
467internal static extern int GetToken(RuntimeType type);
473internal static RuntimeMethodHandleInternal GetMethodAt(RuntimeType type, int slot)
489internal static Type[] GetArgumentTypesFromFunctionPointer(RuntimeType type)
501internal static extern bool IsUnmanagedFunctionPointer(RuntimeType type);
509internal IntroducedMethodEnumerator(RuntimeType type)
537internal static IntroducedMethodEnumerator GetIntroducedMethods(RuntimeType type)
543private static extern RuntimeMethodHandleInternal GetFirstIntroducedMethod(RuntimeType type);
552internal static bool GetFields(RuntimeType type, Span<IntPtr> buffer, out int count)
574internal static Type[] GetInterfaces(RuntimeType type)
622internal static extern int GetNumVirtuals(RuntimeType type);
627internal static int GetNumVirtualsAndStaticVirtuals(RuntimeType type)
657internal static bool IsVisible(RuntimeType type)
680internal static MdUtf8String GetUtf8Name(RuntimeType type)
696internal static bool CanCastTo(RuntimeType type, RuntimeType target)
710internal static RuntimeType? GetDeclaringType(RuntimeType type)
732RuntimeType result = GetRuntimeTypeFromHandle(retTypeHandle);
740internal static IRuntimeMethodInfo? GetDeclaringMethodForGenericParameter(RuntimeType type)
752internal RuntimeType[] GetInstantiationInternal()
754RuntimeType[]? types = null;
772internal RuntimeType Instantiate(RuntimeType inst)
776RuntimeType? type = null;
783internal RuntimeType Instantiate(Type[]? inst)
789RuntimeType? type = null;
800internal RuntimeType MakeArray(int rank)
802RuntimeType? type = null;
811internal RuntimeType MakeSZArray()
813RuntimeType? type = null;
822internal RuntimeType MakeByRef()
824RuntimeType? type = null;
834internal RuntimeType MakeFunctionPointer(Type[] parameterTypes, bool isUnmanaged)
843RuntimeType? type = null;
857internal RuntimeType MakePointer()
859RuntimeType? type = null;
869internal static extern bool IsGenericVariable(RuntimeType type);
872private static extern int GetGenericVariableIndex(RuntimeType type);
876RuntimeType type = GetRuntimeTypeChecked();
885internal static extern bool ContainsGenericVariables(RuntimeType handle);
895internal static bool SatisfiesConstraints(RuntimeType paramType, RuntimeType? typeContext, RuntimeMethodInfo? methodContext, RuntimeType toType)
906internal static void RegisterCollectibleTypeDependency(RuntimeType type, RuntimeAssembly? assembly)
1130internal static unsafe RuntimeType GetDeclaringType(RuntimeMethodHandleInternal method)
1137internal static RuntimeType GetDeclaringType(IRuntimeMethodInfo method)
1139RuntimeType type = GetDeclaringType(method.Value);
1239internal static object ReboxToNullable(object? src, RuntimeType destNullableType)
1256internal static RuntimeType[] GetMethodInstantiationInternal(IRuntimeMethodInfo method)
1258RuntimeType[]? types = null;
1264internal static RuntimeType[] GetMethodInstantiationInternal(RuntimeMethodHandleInternal method)
1266RuntimeType[]? types = null;
1290private static extern RuntimeMethodHandleInternal GetStubIfNeededInternal(RuntimeMethodHandleInternal method, RuntimeType declaringType);
1295internal static RuntimeMethodHandleInternal GetStubIfNeeded(RuntimeMethodHandleInternal method, RuntimeType declaringType, RuntimeType[]? methodInstantiation)
1307static RuntimeMethodHandleInternal GetStubIfNeededWorker(RuntimeMethodHandleInternal method, RuntimeType declaringType, RuntimeType[]? methodInstantiation)
1312internal static extern RuntimeMethodHandleInternal GetMethodFromCanonical(RuntimeMethodHandleInternal method, RuntimeType declaringType);
1371internal static RuntimeMethodBody? GetMethodBody(IRuntimeMethodInfo method, RuntimeType declaringType)
1567internal static RuntimeType GetApproxDeclaringType(RuntimeFieldHandleInternal field)
1576internal static RuntimeType GetApproxDeclaringType(IRuntimeFieldInfo field)
1578RuntimeType type = GetApproxDeclaringType(field.Value);
1635internal static object? GetValue(RtFieldInfo field, object? instance, RuntimeType fieldType, RuntimeType? declaringType, ref bool isClassInitialized)
1657internal static object? GetValueDirect(RtFieldInfo field, RuntimeType fieldType, TypedReference typedRef, RuntimeType? contextType)
1679internal static void SetValue(RtFieldInfo field, object? obj, object? value, RuntimeType fieldType, RuntimeType? declaringType, ref bool isClassInitialized)
1699internal static void SetValueDirect(RtFieldInfo field, RuntimeType fieldType, TypedReference typedRef, object? value, RuntimeType? contextType)
1714internal static RuntimeFieldHandleInternal GetStaticFieldForGenericType(RuntimeFieldHandleInternal field, RuntimeType declaringType)
1896RuntimeType? type = null;
2033internal static RuntimeType GetModuleType(RuntimeModule module)
2035RuntimeType? type = null;
2069private RuntimeType[]? _arguments;
2070private RuntimeType _declaringType;
2071private RuntimeType _returnTypeORfieldType;
2110RuntimeType[] arguments,
2111RuntimeType returnType,
2125public Signature(IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
2132public Signature(IRuntimeFieldInfo fieldHandle, RuntimeType declaringType)
2140public Signature(void* pCorSig, int cCorSig, RuntimeType declaringType)
2149internal RuntimeType[] Arguments
2157internal RuntimeType ReturnType => _returnTypeORfieldType;
2158internal RuntimeType FieldType => _returnTypeORfieldType;
2261internal abstract RuntimeType? GetJitContext(out int securityControlFlags);
2276internal static unsafe void GetJitContext(Resolver* pResolver, int* pSecurityControlFlags, RuntimeType* ppResult, Exception* pException)
src\System\RuntimeType.CoreCLR.cs (129)
210internal MethodBase AddMethod(RuntimeType declaringType, RuntimeMethodHandleInternal method, CacheType cacheType)
311RuntimeType approxDeclaringType = RuntimeFieldHandle.GetApproxDeclaringType(field);
582RuntimeType declaringType = ReflectedType;
763RuntimeType declaringType = ReflectedType;
818RuntimeType declaringType = ReflectedType;
824RuntimeType? populatingType = declaringType;
849PopulateLiteralFields(filter, (RuntimeType)iface, ref list);
850PopulateRtFields(filter, (RuntimeType)iface, ref list);
857private unsafe void PopulateRtFields(Filter filter, RuntimeType declaringType, ref ListBuilder<RuntimeFieldInfo> list)
874ReadOnlySpan<IntPtr> fieldHandles, RuntimeType declaringType, ref ListBuilder<RuntimeFieldInfo> list)
926private void PopulateLiteralFields(Filter filter, RuntimeType declaringType, ref ListBuilder<RuntimeFieldInfo> list)
993ref ListBuilder<RuntimeType> list,
995[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] RuntimeType iList,
1008RuntimeType iFace = (RuntimeType)iFaces[j];
1020private RuntimeType[] PopulateInterfaces(Filter filter)
1022ListBuilder<RuntimeType> list = default;
1024RuntimeType declaringType = ReflectedType;
1031RuntimeType interfaceType = (RuntimeType)iface;
1045RuntimeType arrayType = (RuntimeType)ReflectedType.GetElementType()!;
1049AddSpecialInterface(ref list, filter, (RuntimeType)typeof(IList<>).MakeGenericType(arrayType), true);
1053AddSpecialInterface(ref list, filter, (RuntimeType)typeof(IReadOnlyList<>).MakeGenericType(arrayType), false);
1054AddSpecialInterface(ref list, filter, (RuntimeType)typeof(IReadOnlyCollection<>).MakeGenericType(arrayType), false);
1060var al = new HashSet<RuntimeType>();
1068RuntimeType constraint = (RuntimeType)constraints[i];
1074al.Add((RuntimeType)temp[j]);
1078foreach (RuntimeType rt in al)
1094private RuntimeType[] PopulateNestedClasses(Filter filter)
1096RuntimeType declaringType = ReflectedType;
1109ListBuilder<RuntimeType> list = default;
1118RuntimeType nestedType;
1151RuntimeType declaringType = ReflectedType;
1160RuntimeType? populatingType = declaringType;
1177Filter filter, RuntimeType declaringType, Dictionary<string, RuntimeEventInfo>? csEventInfos, ref ListBuilder<RuntimeEventInfo> list)
1247RuntimeType declaringType = ReflectedType;
1267RuntimeType? populatingType = declaringType;
1285RuntimeType declaringType,
1444internal RuntimeType ReflectedType => m_runtimeTypeCache.GetRuntimeType();
1451private readonly RuntimeType m_runtimeType;
1452private RuntimeType? m_enclosingType;
1463private MemberInfoCache<RuntimeType>? m_interfaceCache;
1464private MemberInfoCache<RuntimeType>? m_nestedClassesCache;
1473private RuntimeType? _genericTypeDefinition;
1477internal RuntimeTypeCache(RuntimeType runtimeType)
1528public static FunctionPointerCache Create(RuntimeType type)
1533public void InitializeCompositeCache(RuntimeType.CompositeCacheEntry compositeEntry) => compositeEntry._functionPointerCache = this;
1534public static ref FunctionPointerCache? GetStorageRef(RuntimeType.CompositeCacheEntry compositeEntry) => ref compositeEntry._functionPointerCache;
1574RuntimeModule module = ((RuntimeType)type).GetRuntimeModule();
1588internal RuntimeType? GetEnclosingType()
1593RuntimeType? enclosingType = RuntimeTypeHandle.GetDeclaringType(GetRuntimeType());
1595m_enclosingType = enclosingType ?? (RuntimeType)typeof(void);
1601internal RuntimeType GetRuntimeType() => m_runtimeType;
1613for (RuntimeType? t = m_runtimeType; t != null; t = t.GetBaseType())
1638internal RuntimeType GetGenericTypeDefinition()
1645RuntimeType CacheGenericDefinition()
1647RuntimeType genericDefinition = null!;
1654RuntimeType type = m_runtimeType;
1742internal RuntimeType[] GetInterfaceList(MemberListType listType, string? name)
1747internal RuntimeType[] GetNestedTypeList(MemberListType listType, string? name)
1752internal MethodBase GetMethod(RuntimeType declaringType, RuntimeMethodHandleInternal method)
1758internal MethodBase GetConstructor(RuntimeType declaringType, RuntimeMethodHandleInternal constructor)
1780internal unsafe RuntimeType? GetParentType()
1794RuntimeType result = RuntimeTypeHandle.GetRuntimeType(pParentMT);
1810internal static MethodBase? GetMethodBase(RuntimeType? reflectedType, IRuntimeMethodInfo methodHandle)
1820internal static MethodBase? GetMethodBase(RuntimeType? reflectedType, RuntimeMethodHandleInternal methodHandle)
1835RuntimeType declaredType = RuntimeMethodHandle.GetDeclaringType(methodHandle);
1837RuntimeType[]? methodInstantiation = null;
1873RuntimeType declaringDefinition = (RuntimeType)declaredType.GetGenericTypeDefinition();
1875RuntimeType? baseType = reflectedType;
1879RuntimeType baseDefinition = baseType;
1882baseDefinition = (RuntimeType)baseDefinition.GetGenericTypeDefinition();
1973internal static FieldInfo GetFieldInfo(RuntimeType? reflectedType, IRuntimeFieldInfo field)
1984RuntimeType declaredType = RuntimeFieldHandle.GetApproxDeclaringType(fieldHandle);
2004private static RuntimePropertyInfo GetPropertyInfo(RuntimeType reflectedType, int tkProperty)
2021internal static void ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception? e)
2023RuntimeType? typeContext;
2025RuntimeType[] genericParameters;
2029typeContext = (RuntimeType)definition;
2035typeContext = (RuntimeType?)methodContext.DeclaringType;
2252Debug.Assert(type is RuntimeType);
2414internal static readonly RuntimeType ValueType = (RuntimeType)typeof(ValueType);
2416private static readonly RuntimeType ObjectType = (RuntimeType)typeof(object);
2417private static readonly RuntimeType StringType = (RuntimeType)typeof(string);
2440return (o is RuntimeType t) && (t.m_handle == m_handle);
2647RuntimeType[] cache = Cache.GetNestedTypeList(listType, name);
2652RuntimeType nestedClass = cache[i];
2697RuntimeType[] candidates = Cache.GetInterfaceList(MemberListType.All, null);
2745RuntimeType ifaceRtType = interfaceType as RuntimeType ??
2793RuntimeType reflectedType = RuntimeMethodHandle.GetDeclaringType(classRtMethodHandle);
3023RuntimeType[] cache = Cache.GetInterfaceList(listType, name);
3025RuntimeType? match = null;
3029RuntimeType iface = cache[i];
3052RuntimeType[] cache = Cache.GetNestedTypeList(listType, name);
3054RuntimeType? match = null;
3058RuntimeType nestedType = cache[i];
3158RuntimeType? runtimeType = this;
3183private static RuntimeMethodInfo? GetMethodWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo method)
3199private static RuntimeConstructorInfo? GetConstructorWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo constructor)
3215private static RuntimePropertyInfo? GetPropertyWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo property)
3231private static RuntimeFieldInfo? GetFieldWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo field)
3247private static RuntimeEventInfo? GetEventWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo eventInfo)
3263private static RuntimeType? GetNestedTypeWithSameMetadataDefinitionAs(RuntimeType runtimeType, MemberInfo nestedType)
3265RuntimeType[] cache = runtimeType.Cache.GetNestedTypeList(MemberListType.CaseSensitive, nestedType.Name);
3269RuntimeType candidate = cache[i];
3316RuntimeType? rtType = type as RuntimeType;
3320RuntimeType? baseType = GetBaseType();
3594internal RuntimeType[] GetGenericArgumentsInternal()
3612RuntimeType[] genericParameters = GetGenericArgumentsInternal();
3616if (typeArguments.Length == 1 && typeArguments[0] is RuntimeType rt)
3630RuntimeType[] instantiationRuntimeType = new RuntimeType[typeArguments.Length];
3637RuntimeType? rtInstantiationElem = instantiationElem as RuntimeType;
3718public sealed override bool HasSameMetadataDefinitionAs(MemberInfo other) => HasSameMetadataDefinitionAsCore<RuntimeType>(other);
3744if (paramType is not RuntimeType)
3760private static bool CanValueSpecialCast(RuntimeType valueType, RuntimeType targetType)
3796RuntimeType srcType = pointer != null ? pointer.GetPointerType() : (RuntimeType)value.GetType();