I get failure of TryGetValue in PushObject results in wrong data being passed back
When I have this running under Unity (Mono 2.0) I am catching the following problem ONLY on specific data types. Can anyone confirm, or at least explain the issue to me - I am going to assume a broken VM with broken Equals() implementation.
C# Side
struct Top { struct sub y; }
struct sub { struct sub2 z; }
struct sub2 { int someval; }
LUA Side:
-- x=new Top() from C#
print( "Z is type:" .. tostring( x.y.z:GetType() ) .. " should be sub2" )
Result:
Z is type: sub should be sub2
Any attempt at accessing past x.y results in getting back "y" from LUA.
The result seems to be due to TryGetValue's internal "Equals" incorrectly identifying two types as the same. Works fine in MSVC.NET 3.5/4+
Here is the code I inserted to find the issue, and it does hit the debug print and when I check types in LUA I get the message above.
======== SOURCE OF ERROR IN CODE:
ObjectTranslator.cs : PushObject
internal void PushObject (LuaState luaState, object o, string metatable)
...
bool found = objectsBackMap.TryGetValue(o, out index);
if ( found && o != objects[index]) // LMP - Added as extra catch test
Debug.Print("\tAlready found it @ index {0}, types DONT MATCH", index);
...
// So now index is wrong, its going to retrieve the wrong type