Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ namespace System.Reflection
{
internal sealed class SignatureConstructedGenericType : SignatureType
{
internal SignatureConstructedGenericType(Type genericTypeDefinition, Type[] genericTypeArguments)
// The exception-visible name "typeArguments" is chosen to match the parameter name to Type.MakeGenericType() since that's the
// intended user of this constructor.
internal SignatureConstructedGenericType(Type genericTypeDefinition, Type[] typeArguments)
{
Debug.Assert(genericTypeDefinition != null && genericTypeArguments != null);
if (genericTypeDefinition == null)
throw new ArgumentNullException(nameof(genericTypeDefinition));

if (typeArguments == null)
throw new ArgumentNullException(nameof(typeArguments));

typeArguments = (Type[])(typeArguments.Clone());
for (int i = 0; i < typeArguments.Length; i++)
{
if (typeArguments[i] == null)
throw new ArgumentNullException(nameof(typeArguments));
}

_genericTypeDefinition = genericTypeDefinition;
_genericTypeArguments = (Type[])(genericTypeArguments.Clone());
_genericTypeArguments = typeArguments;
}

public sealed override bool IsTypeDefinition => false;
Expand Down
2 changes: 2 additions & 0 deletions src/System.Private.CoreLib/shared/System/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ public virtual Array GetEnumValues()
public virtual Type MakeGenericType(params Type[] typeArguments) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); }
public virtual Type MakePointerType() { throw new NotSupportedException(); }

public static Type MakeGenericSignatureType(Type genericTypeDefinition, params Type[] typeArguments) => new SignatureConstructedGenericType(genericTypeDefinition, typeArguments);

public static Type MakeGenericMethodParameter(int position)
{
if (position < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public override bool Equals(object obj)
#endregion

#region Public Members
public Type AttributeType { get { return Constructor.DeclaringType; } }
public virtual Type AttributeType { get { return Constructor.DeclaringType; } }

public virtual ConstructorInfo Constructor { get { return m_ctor; } }

Expand Down