Skip to content

Commit

Permalink
Added support for GetGenericDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Feb 2, 2019
1 parent a3c9ac4 commit 74a5945
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ILRuntime/CLR/TypeSystem/ILType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ILType : IType
List<ILType> genericInstances;
bool isDelegate;
ILRuntimeType reflectionType;
ILType genericDefinition;
IType firstCLRBaseType, firstCLRInterface;
int hashCode = -1;
static int instance_id = 0x10000000;
Expand Down Expand Up @@ -300,6 +301,11 @@ public bool IsGenericInstance
return genericArguments != null;
}
}

public ILType GetGenericDefinition()
{
return genericDefinition;
}
public KeyValuePair<string, IType>[] GenericArguments
{
get
Expand Down Expand Up @@ -1117,6 +1123,7 @@ public IType MakeGenericInstance(KeyValuePair<string, IType>[] genericArguments)
return i;
}
var res = new ILType(definition, appdomain);
res.genericDefinition = this;
res.genericArguments = genericArguments;

genericInstances.Add(res);
Expand Down
7 changes: 7 additions & 0 deletions ILRuntime/Reflection/ILRuntimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ public override bool IsGenericType
}
}

public override Type GetGenericTypeDefinition()
{
var def = type.GetGenericDefinition();

return def != null ? def.ReflectionType : null;
}

public override bool IsGenericTypeDefinition
{
get
Expand Down
5 changes: 5 additions & 0 deletions ILRuntime/Reflection/ILRuntimeWrapperType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ public override bool IsGenericTypeDefinition
}
}

public override Type GetGenericTypeDefinition()
{
return et.GetGenericTypeDefinition();
}

public override bool IsGenericParameter
{
get
Expand Down

0 comments on commit 74a5945

Please sign in to comment.