Commit 805a5e33 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Fixes an issue accessing an Enum array.

* Related with #340 it seems .NET Core is crashing the process when there is a exception with native/manage frames.
parent 5bf33919
...@@ -455,8 +455,9 @@ namespace NLua ...@@ -455,8 +455,9 @@ namespace NLua
return true; return true;
} }
object[] arrObj = (object[])obj; var array = (Array)obj;
_translator.Push(luaState, arrObj[intIndex]); object element = array.GetValue(intIndex);
_translator.Push(luaState, element);
return true; return true;
} }
......
...@@ -2666,6 +2666,41 @@ namespace NLuaTest ...@@ -2666,6 +2666,41 @@ namespace NLuaTest
} }
enum Enumeration
{
First,
Second
}
[Test]
public void DontCrashToArray()
{
var lua = new Lua();
IEnumerable<Enumeration> enu = new List<Enumeration> { Enumeration.First, Enumeration.Second };
lua["arr"] = enu;
var script = @"
firstValue = arr:ToArray()[0];
return firstValue
";
object result = null;
//run
try
{
result = lua.DoString(script)[0];
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Assert.Fail();
}
Assert.AreEqual(Enumeration.First, result, "#1");
}
static Lua m_lua; static Lua m_lua;
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment