Fix issue where unknown types would bind to the first available type, as they inherit from system.object

This commit is contained in:
Deukhoofd 2019-01-25 16:03:00 +01:00
parent 493a8ebb9d
commit 575889bed1
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 7 additions and 2 deletions

View File

@ -92,14 +92,14 @@ namespace Upsilon.BaseTypes
{
private System.Type RealType { get; set; }
public UndefinedUserDataTypeContainer(System.Type realType) : base("unset")
public UndefinedUserDataTypeContainer(System.Type realType) : base(realType.Name)
{
if (realType == null)
throw new Exception("Type can't be null");
RealType = realType;
}
public UndefinedUserDataTypeContainer(Type t, System.Type realType) : base(t, "unset")
public UndefinedUserDataTypeContainer(Type t, System.Type realType) : base(t, realType.Name)
{
if (realType == null)
throw new Exception("Type can't be null");

View File

@ -53,6 +53,8 @@ namespace Upsilon.BoundTypes
public static string GetTypeName(System.Type type)
{
if (type == null)
return null;
if (TypeLookup.TryGetValue(type, out var bDefKey))
{
return bDefKey;

View File

@ -41,6 +41,9 @@ namespace Upsilon.BoundTypes
var currentBaseType = type.BaseType;
while (currentBaseType != null)
{
// We don't want the global object type to be returned
if (currentBaseType == typeof(object))
break;
yield return currentBaseType;
currentBaseType = currentBaseType.BaseType;
}