-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
(Try)Read fail for enum types since LuaValue doesn't know how to handle these even if the value is a number:
luaValue.Read<ApplicationInstallMode>(); // fails
I added this block to LuaValue.TryRead in the LuaValueType.Number case to make this work as expected:
else if (t.IsEnum)
{
if (!MathEx.IsInteger(value)) break;
var v = (long)value;
result = Unsafe.As<long, T>(ref v);
return true;
}
Note: this just duplicates the if (t == typeof(long)) block. Could be merged into one.
Now I can use it in my unit test like so:
Assert.That(retvals[2].Read<ApplicationInstallMode>(),
Is.EqualTo(ApplicationInstallMode.DeveloperBuild));
Avoids having to read as and cast to a number type:
Assert.That(retvals[2].Read<int>(),
Is.EqualTo((int)ApplicationInstallMode.DeveloperBuild));
sawich
Metadata
Metadata
Assignees
Labels
No labels