Skip to content

Commit 130ba84

Browse files
committed
Fix:: Auto overload finder
1 parent bd44fa4 commit 130ba84

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

NeoLua.Test/Expressions.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Reflection;
77
using System.Text;
88
using System.Threading.Tasks;
9+
using System.Xml.Linq;
910
using Microsoft.VisualStudio.TestTools.UnitTesting;
1011
using Neo.IronLua;
1112

@@ -350,18 +351,20 @@ public void TestConvertStatic03()
350351
TestResult(new LuaResult(Lua.RtConvertValue(null, typeof(string))), "");
351352
TestResult(new LuaResult(Lua.RtConvertValue(new object(), typeof(string))), "System.Object");
352353

353-
TestResult(new LuaResult(Lua.RtConvertValue(1, typeof(Decimal))), 1m);
354-
TestResult(new LuaResult(Lua.RtConvertValue("1.2", typeof(Decimal))), 1.2m);
354+
TestResult(new LuaResult(Lua.RtConvertValue(1, typeof(decimal))), 1m);
355+
TestResult(new LuaResult(Lua.RtConvertValue("1.2", typeof(decimal))), 1.2m);
355356
TestResult(new LuaResult(Lua.RtConvertValue(1.2m, typeof(string))), "1.2");
356357
TestResult(new LuaResult(Lua.RtConvertValue(1.2m, typeof(int))), 1);
357358

358359
TestResult(new LuaResult(Lua.RtConvertValue("90238fad-cb41-4efa-bb2f-4d56a0088a01", typeof(Guid))), new Guid("90238fad-cb41-4efa-bb2f-4d56a0088a01"));
360+
361+
TestResult(new LuaResult(Lua.RtConvertValue(new XElement("test", new XText("value")), typeof(string))), "value");
359362
}
360363

361364
[TestMethod]
362365
public void TestConvert04()
363366
{
364-
using (Lua l = new Lua())
367+
using (var l = new Lua())
365368
{
366369
l.PrintExpressionTree = Console.Out;
367370
dynamic g = l.CreateEnvironment();

NeoLua/LuaEmit.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private static MethodInfo FindConvertOperator(Type fromType, Type toType, Method
347347
implicitMethod = testImplicit;
348348
currentMethodInfo = mi;
349349
}
350-
else if (isExactTo) // check only testExactFrom
350+
else if (testExactTo) // check only testExactFrom
351351
{
352352
if (testExactFrom) // nice
353353
{

NeoLua/LuaTable.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ public override DynamicMetaObject BindConvert(ConvertBinder binder)
691691
/// <summary></summary>
692692
/// <returns></returns>
693693
public override IEnumerable<string> GetDynamicMemberNames()
694-
=> ((LuaTable)Value).Members.Keys;
694+
=> ((LuaTable)Value).GetKeys();
695695
} // class LuaTableMetaObject
696696

697697
#endregion
@@ -3400,6 +3400,11 @@ object NextHashKey2(int currrentIndex)
34003400
}
34013401
} // func NextKey
34023402

3403+
/// <summary>Return visible keys.</summary>
3404+
/// <returns></returns>
3405+
protected virtual IEnumerable<string> GetKeys()
3406+
=> ((IDictionary<object, object>)this).Keys.Select(c => (string)Lua.RtConvertValue(c, typeof(string)));
3407+
34033408
#endregion
34043409

34053410
#region -- ICollection<KeyValuePair<object, object>> ------------------------------

0 commit comments

Comments
 (0)