internal static RuntimeConstructedGenericTypeInfo GetRuntimeConstructedGenericTypeInfo(RuntimeTypeInfo genericTypeDefinition, RuntimeTypeInfo[] genericTypeArguments, RuntimeTypeHandle precomputedTypeHandle) { UnificationKey key = new UnificationKey(genericTypeDefinition, genericTypeArguments, precomputedTypeHandle); RuntimeConstructedGenericTypeInfo typeInfo = ConstructedGenericTypeTable.Table.GetOrAdd(key); typeInfo.EstablishDebugName(); return(typeInfo); }
private static RuntimeTypeInfo CreateRuntimeTypeInfo(RuntimeType runtimeType) { if (runtimeType.HasElementType) { if (runtimeType.IsArray) { return(RuntimeArrayTypeInfo.GetRuntimeArrayTypeInfo(runtimeType)); } else { return(RuntimeHasElementTypeInfo.GetRuntimeHasElementypeInfo(runtimeType)); } } else if (runtimeType.IsConstructedGenericType) { RuntimeTypeHandle typeHandle; if (runtimeType.InternalTryGetTypeHandle(out typeHandle) && ReflectionCoreExecution.ExecutionEnvironment.IsReflectionBlocked(typeHandle)) { return(RuntimeBlockedTypeInfo.GetRuntimeBlockedTypeInfo(runtimeType)); } return(RuntimeConstructedGenericTypeInfo.GetRuntimeConstructedGenericTypeInfo(runtimeType)); } else { RuntimeInspectionOnlyNamedType inspectionOnlyNamedType = runtimeType as RuntimeInspectionOnlyNamedType; if (inspectionOnlyNamedType != null) { return(inspectionOnlyNamedType.GetInspectionOnlyNamedRuntimeTypeInfo()); } else { RuntimeGenericParameterType genericParameterType = runtimeType as RuntimeGenericParameterType; if (genericParameterType != null) { return(RuntimeGenericParameterTypeInfo.GetRuntimeGenericParameterTypeInfo(genericParameterType)); } else { MetadataReader reader; TypeDefinitionHandle typeDefHandle; if (ReflectionCoreExecution.ExecutionEnvironment.TryGetMetadataForNamedType(runtimeType.TypeHandle, out reader, out typeDefHandle)) { return(RuntimeNamedTypeInfo.GetRuntimeNamedTypeInfo(reader, typeDefHandle)); } if (ReflectionCoreExecution.ExecutionEnvironment.IsReflectionBlocked(runtimeType.TypeHandle)) { return(RuntimeBlockedTypeInfo.GetRuntimeBlockedTypeInfo(runtimeType)); } else { return(RuntimeNoMetadataNamedTypeInfo.GetRuntimeNoMetadataNamedTypeInfo(runtimeType)); } } } } }
public sealed override bool Equals(Object obj) { RuntimeConstructedGenericTypeInfo other = obj as RuntimeConstructedGenericTypeInfo; if (other == null) { return(false); } return(_asType.Equals(other._asType)); }
// Left unsealed as RuntimeCLSIDTypeInfo has special behavior and needs to override. public override bool HasSameMetadataDefinitionAs(MemberInfo other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } // Do not rewrite as a call to IsConstructedGenericType - we haven't yet established that "other" is a runtime-implemented member yet! RuntimeConstructedGenericTypeInfo otherConstructedGenericType = other as RuntimeConstructedGenericTypeInfo; if (otherConstructedGenericType != null) { other = otherConstructedGenericType.GetGenericTypeDefinition(); } // Unlike most other MemberInfo objects, types never get cloned due to containing generic types being instantiated. // That is, their DeclaringType is always the generic type definition. As a Type, the ReflectedType property is always equal to the DeclaringType. // // Because of these conditions, we can safely implement both the method token equivalence and the "is this type from the same implementor" // check as our regular Equals() method. return(Equals(other)); }