Skip to content

Commit

Permalink
key类型是string或者object的索引setter也需要去掉,fix #211
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Sep 15, 2017
1 parent bd5aa88 commit e2f7bd8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Assets/XLua/Src/CodeEmit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,10 @@ public Type EmitTypeWrap(Type toBeWrap)
{
if (prop.Name == "Item" && prop.GetIndexParameters().Length > 0)
{
itemSetter.Add(setter);
if (!prop.GetIndexParameters()[0].ParameterType.IsAssignableFrom(typeof(string)))
{
itemSetter.Add(setter);
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/XLua/Src/Editor/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static void getClassInfo(Type type, LuaTable parameters)
.ToList());

parameters.Set("newindexers", type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly)
.Where(method => method.Name == "set_Item" && method.GetParameters().Length == 2)
.Where(method => method.Name == "set_Item" && method.GetParameters().Length == 2 && !method.GetParameters()[0].ParameterType.IsAssignableFrom(typeof(string)))
.ToList());

parameters.Set("events", type.GetEvents(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly).Where(e => !isObsolete(e) && !isMemberInBlackList(e))
Expand Down
5 changes: 5 additions & 0 deletions Assets/XLua/Src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ static LuaCSFunction genItemGetter(Type type, PropertyInfo[] props)

static LuaCSFunction genItemSetter(Type type, PropertyInfo[] props)
{
props = props.Where(prop => !prop.GetIndexParameters()[0].ParameterType.IsAssignableFrom(typeof(string))).ToArray();
if (props.Length == 0)
{
return null;
}
Type[] params_type = new Type[props.Length];
for (int i = 0; i < props.Length; i++)
{
Expand Down

0 comments on commit e2f7bd8

Please sign in to comment.