Using enums and namespace problem

Aug 28, 2014 at 3:47 PM
Edited Aug 28, 2014 at 3:57 PM
Hey,

i think there is a problem with enums. Using a enum type for cast or variable types throws an exception.
local test : clr.Test.TestEnum = 1
local test2 = cast(clr.Test.TestEnum, 5)
Both ends up with an exception "type not found". Like that it's impossible to use a function like System.Enum.TryParse.

And there is a problem with namespaces: When you have the word "Auth"(With a small "a" it works fine) in one of your namespaces you're not able to use any type inside of it.
namespace Test.Auth.Test2
{
    public class AB
    {
        public static void Test()
        {
            Console.WriteLine("a");
        }
    }
}
clr.Test.Auth.Test2.AB:Test()
Throws an exception:
Neo.IronLua.LuaRuntimeException: Can not call nil value.
   bei CallSite.Target(Closure , CallSite , Object )
   bei System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   bei TestScript.OnLoad#1(Closure )
   bei CallSite.Target(Closure , CallSite , Object )
   bei System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   bei CallSite.Target(Closure , CallSite , Object )
   bei System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0](CallSite site, T0 arg0)
   bei CallSite.Target(Closure , CallSite , Object )
And another small problem with using clr types: You're only able to use external library types(I mean 3rd party libraries, not the framework) within lua when you used one type of the library inside your code before you run the lua code or it just throws an exception with "type not found".
Coordinator
Aug 28, 2014 at 4:51 PM
Hi,

if NeoLua expects a type, you do not have to write clr.
local test : Test.TestEnum = 1
local test2 = cast(Test.TestEnum, 5)
I thing with the correct type Enum.TryParse should work.


I tried out your example with the Auth-namespace. I run your example and it just works find?


Correct, NeoLua tries to load assembly of the type from direct referenced assemblies (since 0.8.18). But basicly, the library/assembly must be loaded. Is this what you ment?
Aug 29, 2014 at 5:28 AM
NeoLithos wrote:
Hi,

if NeoLua expects a type, you do not have to write clr.
local test : Test.TestEnum = 1
local test2 = cast(Test.TestEnum, 5)
I thing with the correct type Enum.TryParse should work.


I tried out your example with the Auth-namespace. I run your example and it just works find?


Correct, NeoLua tries to load assembly of the type from direct referenced assemblies (since 0.8.18). But basicly, the library/assembly must be loaded. Is this what you ment?
Thanks, without the clr. it works fine :). It seems the auth thing was something on my side, my bad!.
Yea that's what i meant, is there something you can do about it? It's a bit annoying when i need to make sure the assembly is loaded before it can be used in lua :(.

Now i have another problem with 0.8.18 and arrays
clr.System.IO.Directory:GetFiles(path)
returns just a string with the first element instead of the array, with 0.8.17 its working fine.
Coordinator
Aug 29, 2014 at 1:19 PM
To the assembly resolver:
  1. it looks up the current loaded assemblies for the type
  2. during this loop it collects all direct referenced assemblies.
  3. it loads every direct referenced assembly in the reflection cache to lookup for the type.
It seems, that you want to lookup the referenced assemblies from the referenced? That is very costly. I did this in a visual studio extension and it can really slow down an application.

Can you give me your problem more specific?


LuaType converted the result of GetFiles to a LuaResult. That is not correct. I changed this, it will work on the next version.
Aug 29, 2014 at 2:13 PM
Oh sorry, just saw the "(since 0.8.18)". I was still using 0.8.17 cuz of the wrong return from GetFiles. Thanks for the help!
Coordinator
Aug 29, 2014 at 2:49 PM
0.8.19 will be the next :).