-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding properties to ExpandoObject via Lua? #519
Comments
I am not sure what you trying to achieve. But NLua will try to use reflection. I don't think it will work with ExpandObject. But why not use a Lua object directly ? |
Because I need the interop. The object must also be useable in C#, and actually begins life on the C# side. ExpandoObject definitely feels easy on the C# side, and something that should just work on the Lua side, since Lua is a dynamically typed language. This paradigm works fine in IronPython, for what it's worth. So there isn't some platform limitation or anything. |
I see. I guess it would be doable if we can dynamically invoke properties/methods in the dynamic object. NLua will try to reflect over the CLR object directly, but in theory it could be fixed changing NLua to check if is a dynamic object. |
I might just be misunderstanding something. My Lua is extremely rusty, and my experience with NLua is virtually zero.
This code doesn't have the behavior I'd expect:
This makes a dynamic/
ExpandoObject
in C# and adds it as a (global?) variable. Lua is able to seex.a
(theprint(x.a)
shows5
). But on the assignment line, withx.a = 10
, I get the following error:It seems like it is available for reading but not writing.
This variation worked fine, which makes me think I'm not just making a Lua syntax error.
This displays
nil
at first, and then10
, as I'd expect.I can't tell if this is a bug or if I'm just missing something obvious. I'd expect that I could send an ExpandoObject over to Lua and have Lua be able to modify its values, not just see the current ones.
I'd love some advice or guidance from people more experienced with Lua and NLua.
The text was updated successfully, but these errors were encountered: