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
1 change: 1 addition & 0 deletions src/mscorlib/shared/System/Reflection/TypeDelegator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindin

protected override TypeAttributes GetAttributeFlagsImpl() => typeImpl.Attributes;

public override bool IsTypeDefinition => typeImpl.IsTypeDefinition;
public override bool IsSZArray => typeImpl.IsSZArray;

protected override bool IsArrayImpl() => typeImpl.IsArray;
Expand Down
1 change: 1 addition & 0 deletions src/mscorlib/shared/System/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected Type() { }
public override Type ReflectedType => null;
public abstract Type UnderlyingSystemType { get; }

public virtual bool IsTypeDefinition { get { throw NotImplemented.ByDesign; } }
public bool IsArray => IsArrayImpl();
protected abstract bool IsArrayImpl();
public bool IsByRef => IsByRefImpl();
Expand Down
2 changes: 2 additions & 0 deletions src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ protected override TypeAttributes GetAttributeFlagsImpl()
return m_typeBuilder.Attributes;
}

public override bool IsTypeDefinition => true;

public override bool IsSZArray => false;

protected override bool IsArrayImpl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public override Type MakeArrayType(int rank)

protected override TypeAttributes GetAttributeFlagsImpl() { return TypeAttributes.Public; }

public override bool IsTypeDefinition => false;

public override bool IsSZArray => false;

protected override bool IsArrayImpl() { return false; }
Expand Down
3 changes: 3 additions & 0 deletions src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ internal void SetFormat(string format, int curIndex, int length)
#endregion

#region Type Overrides

public override bool IsTypeDefinition => false;

public override bool IsSZArray => m_cRank <= 1 && m_isSzArray;

public override Type MakePointerType()
Expand Down
2 changes: 2 additions & 0 deletions src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,8 @@ protected override TypeAttributes GetAttributeFlagsImpl()
return m_iAttr;
}

public override bool IsTypeDefinition => true;

public override bool IsSZArray => false;

protected override bool IsArrayImpl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public override Type BaseType
public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override TypeAttributes GetAttributeFlagsImpl() { return m_type.Attributes; }

public override bool IsTypeDefinition => false;
public override bool IsSZArray => false;

protected override bool IsArrayImpl() { return false; }
Expand Down
5 changes: 5 additions & 0 deletions src/mscorlib/src/System/RtType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,11 @@ public override Type[] GetGenericParameterConstraints()
#endregion

#region Misc
public override bool IsTypeDefinition
{
get { return RuntimeTypeHandle.IsTypeDefinition(this); }
}

public override Type MakePointerType() { return new RuntimeTypeHandle(this).MakePointer(); }
public override Type MakeByRefType() { return new RuntimeTypeHandle(this).MakeByRef(); }
public override Type MakeArrayType() { return new RuntimeTypeHandle(this).MakeSZArray(); }
Expand Down
18 changes: 18 additions & 0 deletions src/mscorlib/src/System/RuntimeHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ internal RuntimeTypeHandle(RuntimeType type)
m_type = type;
}

internal static bool IsTypeDefinition(RuntimeType type)
{
CorElementType corElemType = GetCorElementType(type);
if (!((corElemType >= CorElementType.Void && corElemType < CorElementType.Ptr) ||
corElemType == CorElementType.ValueType ||
corElemType == CorElementType.Class ||
corElemType == CorElementType.TypedByRef ||
corElemType == CorElementType.I ||
corElemType == CorElementType.U ||
corElemType == CorElementType.Object))
return false;

if (HasInstantiation(type) && !IsGenericTypeDefinition(type))
return false;

return true;
}

internal static bool IsPrimitive(RuntimeType type)
{
CorElementType corElemType = GetCorElementType(type);
Expand Down