From d830929290fd224976db5c9d8f416250aee2a987 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 7 Sep 2019 12:17:23 +0200 Subject: [PATCH] Throw exception when trying to resolve a userdata type that's not registered, instead of just returning null --- PorygonSharp/EvalValues/EvalValueCreator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PorygonSharp/EvalValues/EvalValueCreator.cs b/PorygonSharp/EvalValues/EvalValueCreator.cs index 8383e8f..732da53 100644 --- a/PorygonSharp/EvalValues/EvalValueCreator.cs +++ b/PorygonSharp/EvalValues/EvalValueCreator.cs @@ -43,8 +43,10 @@ namespace PorygonSharp.EvalValues case TypeCode.Object: if (typeof(IList).IsAssignableFrom(type)) return CreateListEvalValue((IList)o, type); - if (!UserDataHandler.IsTypeRegistered(type)) - return null; + if (!UserDataHandler.IsTypeRegistered(type) && !UserDataHandler.TryResolveType(type)) + { + throw new Exception($"Type is not registered for use: {type.FullName}"); + } var typeHash = UserDataHandler.GetTypeId(type); var handle = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection); return new EvalValue(CreateUserDataEvalValue(typeHash, GCHandle.ToIntPtr(handle)));