public sealed override Type MakeGenericType(params Type[] typeArguments) { if (ReflectionTrace.Enabled) { ReflectionTrace.TypeInfo_MakeGenericType(this, typeArguments); } return(AsType().MakeGenericType(typeArguments)); }
public sealed override Type MakeGenericType(params Type[] typeArguments) { #if ENABLE_REFLECTION_TRACE if (ReflectionTrace.Enabled) { ReflectionTrace.TypeInfo_MakeGenericType(this, typeArguments); } #endif return(AsType().MakeGenericType(typeArguments)); }
public sealed override Type MakeGenericType(params Type[] typeArguments) { #if ENABLE_REFLECTION_TRACE if (ReflectionTrace.Enabled) { ReflectionTrace.TypeInfo_MakeGenericType(this, typeArguments); } #endif if (typeArguments == null) { throw new ArgumentNullException(nameof(typeArguments)); } if (!IsGenericTypeDefinition) { throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericTypeDefinition, this)); } // We intentionally don't validate the number of arguments or their suitability to the generic type's constraints. // In a pay-for-play world, this can cause needless MissingMetadataExceptions. There is no harm in creating // the Type object for an inconsistent generic type - no EEType will ever match it so any attempt to "invoke" it // will throw an exception. RuntimeTypeInfo[] runtimeTypeArguments = new RuntimeTypeInfo[typeArguments.Length]; for (int i = 0; i < typeArguments.Length; i++) { RuntimeTypeInfo runtimeTypeArgument = typeArguments[i] as RuntimeTypeInfo; if (runtimeTypeArgument == null) { if (typeArguments[i] == null) { throw new ArgumentNullException(); } else { throw new PlatformNotSupportedException(SR.PlatformNotSupported_MakeGenericType); // "PlatformNotSupported" because on desktop, passing in a foreign type is allowed and creates a RefEmit.TypeBuilder } } // Desktop compatibility: Treat generic type definitions as a constructed generic type using the generic parameters as type arguments. if (runtimeTypeArgument.IsGenericTypeDefinition) { runtimeTypeArgument = runtimeTypeArgument.GetConstructedGenericType(runtimeTypeArgument.RuntimeGenericTypeParameters); } if (runtimeTypeArgument.IsByRefLike) { throw new TypeLoadException(SR.CannotUseByRefLikeTypeInInstantiation); } runtimeTypeArguments[i] = runtimeTypeArgument; } return(this.GetConstructedGenericType(runtimeTypeArguments)); }
public sealed override Type MakeGenericType(params Type[] typeArguments) { #if ENABLE_REFLECTION_TRACE if (ReflectionTrace.Enabled) { ReflectionTrace.TypeInfo_MakeGenericType(this, typeArguments); } #endif if (typeArguments == null) { throw new ArgumentNullException(nameof(typeArguments)); } if (!IsGenericTypeDefinition) { throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericTypeDefinition, this)); } // We intentionally don't validate the number of arguments or their suitability to the generic type's constraints. // In a pay-for-play world, this can cause needless MissingMetadataExceptions. There is no harm in creating // the Type object for an inconsistent generic type - no EEType will ever match it so any attempt to "invoke" it // will throw an exception. for (int i = 0; i < typeArguments.Length; i++) { if (typeArguments[i] == null) { throw new ArgumentNullException(); } if (!typeArguments[i].IsRuntimeImplemented()) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_MakeGenericType); // "PlatformNotSupported" because on desktop, passing in a foreign type is allowed and creates a RefEmit.TypeBuilder } } return(this.GetConstructedGenericType(typeArguments.ToRuntimeTypeInfoArray())); }