Giter Club home page Giter Club logo

keralua's Introduction

πŸ‘‹ Hello there!

πŸ”­ Thank you for checking out this project.

🍻 We've made the project Open Source and MIT license so everyone can enjoy it.

πŸ›  To deliver a project with quality we have to spent a lot of time working on it.

⭐️ If you liked the project please star it.

πŸ’• We also appreaciate any Sponsor [ Patreon | PayPal ]

Logo

NLua

NuGet
nuget
Status
linux Linux
win Build status
mac Build Status
win Build Status
linuxnet Build Status

Bridge between Lua world and the .NET (compatible with .NET/UWP/Mac/Linux/Android/iOS/tvOS)

Building

msbuild NLua.sln

NLua allows the usage of Lua from C#, on UWP, Windows, Linux, Mac, iOS , Android.

Cmd

NLua is a fork project of LuaInterface (from FΓ‘bio Mascarenhas/Craig Presti).

Example: You can use/instantiate any .NET class without any previous registration or annotation.

	public class SomeClass
	{
		public string MyProperty {get; private set;}
		
		public SomeClass (string param1 = "defaulValue")
		{
			MyProperty = param1;
		}
		
		public int Func1 ()
		{
			return 32;
		}
		
		public string AnotherFunc (int val1, string val2)
		{
			return "Some String";
		}
		
		public static string StaticMethod (int param)
		{
			return "Return of Static Method";
		}
        }
  • Using UTF-8 Encoding:

NLua runs on top of KeraLua binding, it encodes the string using the ASCII encoding by default. If you want to use UTF-8 encoding, just set the Lua.State.Encoding property to Encoding.UTF8:

using (Lua lua = new Lua())
{
	lua.State.Encoding = Encoding.UTF8;
	lua.DoString("res = 'Π€Π°ΠΉΠ»'");
	string res = (string)lua["res"];

	Assert.AreEqual("Π€Π°ΠΉΠ»", res);
}

Creating Lua state:

	using NLua;
	
	Lua state = new Lua ()

Evaluating simple expressions:

	var res = state.DoString ("return 10 + 3*(5 + 2)")[0] as double;
	// Lua can return multiple values, for this reason DoString return a array of objects

Passing raw values to the state:

	double val = 12.0;
	state ["x"] = val; // Create a global value 'x' 
	var res = (double)state.DoString ("return 10 + x*(5 + 2)")[0];

Retrieving global values:

	state.DoString ("y = 10 + x*(5 + 2)");
	double y = (double) state ["y"]; // Retrieve the value of y

Retrieving Lua functions:

	state.DoString (@"
	function ScriptFunc (val1, val2)
		if val1 > val2 then
			return val1 + 1
		else
			return val2 - 1
		end
	end
	");
	var scriptFunc = state ["ScriptFunc"] as LuaFunction;
	var res = (int)scriptFunc.Call (3, 5).First ();
	// LuaFunction.Call will also return a array of objects, since a Lua function
	// can return multiple values

##Using the .NET objects.##

Passing .NET objects to the state:

	SomeClass obj = new SomeClass ("Param");
	state ["obj"] = obj; // Create a global value 'obj' of .NET type SomeClass 
	// This could be any .NET object, from BCL or from your assemblies

Using .NET assemblies inside Lua:

To access any .NET assembly to create objects, events etc inside Lua you need to ask NLua to use CLR as a Lua package. To do this just use the method LoadCLRPackage and use the import function inside your Lua script to load the Assembly.

	state.LoadCLRPackage ();
	state.DoString (@" import ('MyAssembly', 'MyNamespace') 
			   import ('System.Web') ");
	// import will load any .NET assembly and they will be available inside the Lua context.

Creating .NET objects: To create object you only need to use the class name with the ().

state.DoString (@"
	 obj2 = SomeClass() -- you can suppress default values.
	 client = WebClient()
	");

Calling instance methods: To call instance methods you need to use the : notation, you can call methods from objects passed to Lua or to objects created inside the Lua context.

	state.DoString (@"
	local res1 = obj:Func1()
	local res2 = obj2:AnotherFunc (10, 'hello')
	local res3 = client:DownloadString('http://nlua.org')
	");

Calling static methods: You can call static methods using only the class name and the . notation from Lua.

	state.DoString (@"
	local res4 = SomeClass.StaticMethod(4)
	");

Calling properties: You can get (or set) any property using . notation from Lua.

	state.DoString (@"
	local res5 = obj.MyProperty
	");

All methods, events or property need to be public available, NLua will fail to call non-public members.

If you are using Xamarin.iOS you need to Preserve the class you want to use inside NLua, otherwise the Linker will remove the class from final binary if the class is not in use.

##Sandboxing##

There is many ways to sandbox scripts inside your application. I strongly recommend you to use plain Lua to do your sandbox. You can re-write the import function before load the user script and if the user try to import a .NET assembly nothing will happen.

	state.DoString (@"
		import = function () end
	");

Lua-Sandbox user-list

Unity Integration

  1. Build for .Net 2.0 or Download KeraLua and NLua from NuGet (use the Download package link)
  2. if Download: change the file extensions from .nupkg to .zip
  3. create folders in your Unity project's Assets directory Plugins/KeraLua and Plugins/NLua
  4. extract the netstandard2.0 contents of those zip files into the newly created unity folders. Your tree should look roughly like this (with KeraLua runtimes customized to your build targets)
Plugins
β”œβ”€β”€ KeraLua
β”‚   β”œβ”€β”€ LICENSE
β”‚   β”œβ”€β”€ LICENSE.meta
β”‚   β”œβ”€β”€ lib
β”‚   β”‚   β”œβ”€β”€ netstandard2.0
β”‚   β”‚   β”‚   β”œβ”€β”€ KeraLua.dll
β”‚   β”‚   β”‚   β”œβ”€β”€ KeraLua.dll.meta
β”‚   β”‚   β”‚   β”œβ”€β”€ KeraLua.xml
β”‚   β”‚   β”‚   └── KeraLua.xml.meta
β”‚   β”‚   └── netstandard2.0.meta
β”‚   β”œβ”€β”€ lib.meta
β”‚   β”œβ”€β”€ runtimes
β”‚   β”‚   β”œβ”€β”€ linux-x64
β”‚   β”‚   β”‚   β”œβ”€β”€ native
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ liblua54.so
β”‚   β”‚   β”‚   β”‚   └── liblua54.so.meta
β”‚   β”‚   β”‚   └── native.meta
β”‚   β”‚   β”œβ”€β”€ linux-x64.meta
β”‚   β”‚   β”œβ”€β”€ osx
β”‚   β”‚   β”‚   β”œβ”€β”€ native
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ liblua54.dylib
β”‚   β”‚   β”‚   β”‚   └── liblua54.dylib.meta
β”‚   β”‚   β”‚   └── native.meta
β”‚   β”‚   β”œβ”€β”€ osx.meta
β”‚   β”‚   β”œβ”€β”€ win-x64
β”‚   β”‚   β”‚   β”œβ”€β”€ native
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ lua54.dll
β”‚   β”‚   β”‚   β”‚   └── lua54.dll.meta
β”‚   β”‚   β”‚   └── native.meta
β”‚   β”‚   β”œβ”€β”€ win-x64.meta
β”‚   β”‚   β”œβ”€β”€ win-x86
β”‚   β”‚   β”‚   β”œβ”€β”€ native
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ lua54.dll
β”‚   β”‚   β”‚   β”‚   └── lua54.dll.meta
β”‚   β”‚   β”‚   └── native.meta
β”‚   β”‚   └── win-x86.meta
β”‚   └── runtimes.meta
β”œβ”€β”€ KeraLua.meta
β”œβ”€β”€ NLua
β”‚   β”œβ”€β”€ LICENSE
β”‚   β”œβ”€β”€ LICENSE.meta
β”‚   β”œβ”€β”€ lib
β”‚   β”‚   β”œβ”€β”€ netstandard2.0
β”‚   β”‚   β”‚   β”œβ”€β”€ NLua.dll
β”‚   β”‚   β”‚   └── NLua.dll.meta
β”‚   β”‚   └── netstandard2.0.meta
β”‚   └── lib.meta
└── NLua.meta
  1. Go through each KeraLua runtime liblua54 files in the Unity inspector and set the correct Platform settings for both editor and standalone based on the folder. Don't forget to apply

Notes for unity

  • you will likely want to append to package.path you can do it with something like this lua.DoString("package.path = package.path .. \";" + Application.persistentDataPath + "/?/?.lua;" + Application.persistentDataPath + "/?.lua\"");
  • you will want to expose Debug.Log to lua (and override the print function to see lua logs)
  • numbers will come back as double type
  • fields set on the lua instance may be null and you will need to handle it

Copyright (c) 2024 Vinicius Jarina ([email protected])

NLua 1.4.x

NLua huge cleanup and refactor after a few years.

  • Moved to .NET C# style.
  • Using KeraLua as nuget dependencie.
  • Droped support for KopiLua/Silverlight/Windows Phone

NLua 1.3.2

  • Migration to unified Xamarin.iOS (iOS)
  • Added __call method to call Actions/Funcs from Lua as Lua functions.
  • Fixed #116 problem accessing base class method
  • Fixed #117 problem with same method in class and base class
  • Fixed #125 calling methods with params keyword.

NLua 1.3.2

NLua 1.3.0

NLua 1.2.0

NLua 1.1.0

  • Port to WP7 (Thanks to Mangatome)
  • NLua now using Lua 5.2.2
  • Bug fixes.

NLua 1.0.0

  • Forked from LuaInterface 2.0.4
  • Added iOS support using KeraLua (C# P/Invoke Lua)

###Help NLua###

  • Contributing

  • NLua uses the Mono Code-Style http://www.mono-project.com/Coding_Guidelines .
  • Please, do not change the line-end or re-indent the code.
  • Run the tests before you push.
  • Avoid pushing style changes (unless they are really needed), renaming and move code.

Old History

LuaInterface

Copyright (c) 2003-2006 Fabio Mascarenhas de Queiroz

Maintainer: Craig Presti, [email protected]

lua51.dll and lua51.exe are Copyright (c) 2005 Tecgraf, PUC-Rio

Getting started with NLua:

  • Look at src/TestNLua/TestLua to see an example of usage from C# (optionally you can run this from inside the NLua solution using the debugger).
    Also provides a good example of how to override .NET methods of Lua and usage of NLua from within your .NET application.

  • Look at samples/testluaform.lua to see examples of how to use .NET inside Lua

  • More installation and usage instructions in the doc/guide.pdf file.

What's new in LuaInterface 2.0.3

  • Fix: Private methods accessible via LuaInterface
  • Fix: Method overload lookup failures
  • Fix: Lua DoFile memory leaks when file not found (submitted by Paul Moore)
  • Fix: Lua Dispose not freeing memory (submitted by Paul Moore)
  • Fix: Better support for accessing indexers
  • Fix: Parsing error for MBCS characters (qingrui.li)
  • Fix: Dispose errors originating from LuaTable, LuaFunction, LuaUserData
  • Fix: LuaInterface no longer disposes the state when passed one via the overloaded constructor
  • Added: LoadString and LoadFile (submitted by Paul Moore)
  • Added: Overloaded DoString
  • Added: Lua debugging support (rostermeier)

What's new in LuaInterface 2.0.1

  • Apparently the 2.0 built binaries had an issue for some users, this is just a rebuild with the lua sources pulled into the LuaInterface.zip

What's new in LuaInterface 2.0

  • The base lua5.1.2 library is now built as entirely manged code. LuaInterface is now pure CIL
  • Various adapters to connect the older x86 version of lua are no longer needed
  • Performance fixes contributed by Toby Lawrence, Oliver Nemoz and Craig Presti

What's new in LuaInterface 1.5.3

  • Internal lua panics (due to API violations) now throw LuaExceptions into .net
  • If .net code throws an exception into Lua and lua does not handle it, the original exception is forwarded back out to .net land.
  • Fix bug in the Lua 5.1.1 gmatch C code - it was improperly assuming gmatch only works with tables.

What's new in LuaInterface 1.5.2

  • Overriding C# methods from Lua is fixed (broken with .net 2.0!)
  • Registering static C# functions for Lua is fixed (broken with Lua-5.1.1)
  • Rebuilt to fix linking problems with the binaries included in 1.5.1
  • RegisterFunction has been leaking things onto the stack

What's new in LuaInterface 1.5.1

Fix a serious bug w.r.t. garbage collection - made especially apparent with the new lua5.1 switch: If you were very unlucky with timing sometimes Lua would loose track of pointers to CLR functions.

When I added support for static methods, I allowed the user to use either a colon or a dot to separate the method from the class name. This was not correct - it broke disambiguation between overloaded static methods.
Therefore, LuaInterface is now more strict: If you want to call a static method, you must use dot to separate the method name from the class name. Of course you can still use a colon if an instance is being used.

Static method calls are now much faster (due to better caching).

What's new in LuaInterface 1.5

LuaInterface is now updated to be based on Lua5.1.1. You can either use your own build/binaries for Lua5.1.1 or use the version distributed here. (Lots of thanks to Steffen Itterheim for this work!)

LuaInterface.Lua no longer has OpenLibs etc... The base mechanism for library loading for Lua has changed, and we haven't yet broken apart the library loading for LuaInterface. Instead, all standard Lua libraries are automatically loaded at start up.

Fixed a bug where calls of some static methods would reference an invalid pointer.

Fixed a bug when strings with embedded null characters are passed in or out of Lua (Thanks to Daniel NοΏ½ri for the report & fix!)

The native components in LuaInterface (i.e. Lua51 and the loader) are both built as release builds - to prevent problems loading standard windows libraries.

Note: You do not need to download/build lua-5.1.1.zip unless you want to modify Lua internals (a built version of lua51.dll is included in the regular LuaInterface distribution)

What's New in LuaInterface 1.4

Note: Fabio area of interest has moved off in other directions (hopefully only temporarily). I've talked with Fabio and he's said he's okay with me doing a new release with various fixes I've made over the last few months. Changes since 1.3:

Visual Studio 2005/.Net 2.0 is supported.

Compat-5.1 is modified to expect backslash as the path seperator.

LuaInterface will now work correctly with Generic C# classes.

CLR inner types are now supported.

Fixed a problem where sometimes Lua proxy objects would be associated with the wrong CLR object.

If a CLR class has an array accessor, the elements can be accessed using the regular Lua indexing interface.

Add CLRPackage.lua to the samples directory. This class makes it much easier to automatically load referenced assemblies. In the next release this loading will be automatic.

To see an quick demonstration of LuaInterface, cd into nlua/samples and then type: ....\Built\debug\LuaRunner.exe testluaform.lua

Various other minor fixes that I've forgotten. I'll keep better track next time.

Note: LuaInterface is still based on Lua 5.0.2. If someone really wants us to upgrade to Lua 5.1 please send me a note. In the mean time, I'm also distributing a version of Lua 5.0.2 with an appropriate VS 2005 project file. You do not need to download this file unless you want to modify Lua internals (a built version of lua50.dll is included in the regular LuaInterface distribution)

What's New in LuaInterface 1.3

LuaInterface now works with LuaBinaries Release 2 (http://luabinaries.luaforge.net) and Compat-5.1 Release 3 (http://luaforge.net/projects/compat). The loader DLL is now called luanet.dll, and does not need a nlua.lua file anymore (just put LuaInterface.dll in the GAC, luanet.dll in your package.cpath, and do require"luanet").

Fixed a bug in the treatment of the char type (thanks to Ron Scott).

LuaInterface.dll now has a strong name, and can be put in the GAC (thanks to Ivan Voras).

You can now use foreach with instances of LuaTable (thanks to Zachary Landau).

There is an alternate form of loading assemblies and importing types (based on an anonymous contribution in the Lua wiki). Check the _alt files in the samples folder.

What's New in LuaInterface 1.2.1

Now checks if two LuaInterface.Lua instances are trying to share the same Lua state, and throws an exception if this is the case. Also included readonly clauses in public members of the Lua and ObjectTranslator classes.

This version includes the source of LuaInterfaceLoader.dll, with VS.Net 2003 project files.

What's New in LuaInterface 1.2

LuaInterface now can be loaded as a module, so you can use the lua standalone interpreter to run scripts. Thanks to Paul Winwood for this idea and sample code showing how to load the CLR from a C++ program. The module is "nlua". Make sure Lua can find nlua.lua, and LuaInterfaceLoader.dll is either in the current directory or the GAC. The samples now load LuaInterface as a module, in its own namespace.

The get_method_bysig, get_constructor_bysig and make_object were changed: now you pass the names of the types to them, instead of the types themselves. E.g:

get_method_bysig(obj,"method","System.String")

instead of

String = import_type("System.String") get_method_bysig(obj,"method",String)

Make sure the assemblies of the types you are passing have been loaded, or the call will fail. The test cases in src/TestLuaInterface/TestLua.cs have examples of the new functions.

keralua's People

Contributors

ayrton97 avatar bbi-rileygodard avatar charlenni avatar enyim avatar megax avatar mervill avatar missingreference avatar pkmnfrk avatar prabirshrestha avatar therzok avatar viniciusjarina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keralua's Issues

Linux library is not portable across distributions

Hello,

It seems that the current NuGet package does not work with the official .NET images (i.e. mcr.microsoft.com/dotnet/runtime:5.0) as liblua54.so is compiled against a specific version of glibc, which is not the one from this Docker image. This result in a typical DllNotFoundException as the system loader fails to load Lua's native dependencies.

I manually recompiled Lua from within the same Docker image to have a SO targeting the same version of the system libraries (and it worked), but this is less than ideal. I wonder if the Linux library shouldn't be compiled in a way that it will be portable across most Linux distributions using a somewhat recent version of glibc? In the past, I've used Holy Build Box for that, and it worked quite nicely.

Lua 5.3 support?

Hi,

I just built an installer for Lua 5.3 on Windows 10 here:
https://github.com/RussellHaley/PUC-Lua-VisualStudio

I was hoping to test your library but your current API is 5.2. Do you have plans to bump it? I don't know enough about the Lua C API yet to be helpful. I tried running the console test but I get a runtime error :

System.EntryPointNotFoundException: 'Unable to find an entry point named 'lua_pushstdcallcfunction' in DLL 'lua53'.'

Cheers,
Russ

Docs / Examples

Why, the Repo has an Wiki when its empty?

Where i can find docs to use these over .NET & NuGet?

Can't Build using VS 2019 Native Tools

Steps:

  1. Clone the repo: git clone https://github.ccom/NLua/NLua
  2. Get submodules: git submodule update --init --recursive
  3. Open x64 Native Tools Command Prompt for VS 2019 and cd to the directory
  4. Run msbuild KeraLua.sln

Output:

keralua-faillog-0

As an attempt to work around it, I ran msbuild KeraLua.sln /p:Configuration=Debug /p:Platform="Any CPU". Output:

keralua-faillog-1

DllNotFoundException with Unity

I'm trying to use NLua in a Unity project but at runtime I keep getting this error:

DllNotFoundException: lua54 assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) KeraLua.NativeMethods.luaL_newstate()
  at KeraLua.Lua..ctor (System.Boolean openLibs) [0x00011] in <c512374dfa8a466fa45d2e3c8e67cc2a>:0 
  at NLua.Lua..ctor (System.Boolean openLibs) [0x00011] in <f51550337f2c42afa6cfe006c367381d>:0 
  at EverlyLastFM.LastFM..ctor (System.String scriptFolder, System.String apiKey, System.String apiSecret) [0x0001c] in D:\Unity Projects\rhythm game\Assets\EverlyLastFM\EverlyLastFM.cs:25 
  at ColorManager.Update () [0x0000d] in D:\Unity Projects\rhythm game\Assets\ColorManager.cs:66

This error happens on the line with Lua lua = new Lua();

What causes this and how do I fix it?

Fails to build

After cloning and fetching submodules:

chris@zack:~/src/KeraLua$ ./autogen.sh
I am going to run ./configure with no arguments - if you wish
to pass any to it, please specify them on the ./autogen.sh command line.
Running aclocal -I .  ...
Running automake --gnu  ...
configure.ac:5: installing `./install-sh'
configure.ac:5: installing `./missing'
Makefile.include:69: programfilesdir multiply defined in condition TRUE ...
ConsoleTest/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:65: ... `programfilesdir' previously defined here
ConsoleTest/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:70: programfiles_DATA multiply defined in condition TRUE ...
ConsoleTest/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:66: ... `programfiles_DATA' previously defined here
ConsoleTest/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:69: programfilesdir multiply defined in condition TRUE ...
KeraLua.Tests/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:65: ... `programfilesdir' previously defined here
KeraLua.Tests/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:70: programfiles_DATA multiply defined in condition TRUE ...
KeraLua.Tests/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:66: ... `programfiles_DATA' previously defined here
KeraLua.Tests/Makefile.am:92:   `Makefile.include' included from here
Makefile.include:69: programfilesdir multiply defined in condition TRUE ...
Makefile.am:13:   `KeraLua.make' included from here
KeraLua.make:69:   `Makefile.include' included from here
Makefile.include:65: ... `programfilesdir' previously defined here
Makefile.am:13:   `KeraLua.make' included from here
KeraLua.make:69:   `Makefile.include' included from here
Makefile.include:70: programfiles_DATA multiply defined in condition TRUE ...
Makefile.am:13:   `KeraLua.make' included from here
KeraLua.make:69:   `Makefile.include' included from here
Makefile.include:66: ... `programfiles_DATA' previously defined here
Makefile.am:13:   `KeraLua.make' included from here
KeraLua.make:69:   `Makefile.include' included from here
Running autoconf ...
Running ./configure ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for pkg-config... /usr/bin/pkg-config
checking for gmcs... /opt/mono/bin/gmcs
configure: creating ./config.status
config.status: creating keralua.pc
config.status: creating KeraLua.Tests/keralua.tests.pc
config.status: creating KeraLua.Tests/Makefile
config.status: creating ConsoleTest/consoletest
config.status: creating ConsoleTest/Makefile
config.status: creating Makefile


chris@zack:~/src/KeraLua$ make
Making all in .
make[1]: Entering directory `/home/chris/src/KeraLua'
mkdir -p 'bin/Release'
cp 'keralua.pc' 'bin/Release//keralua.pc'
make[1]: Leaving directory `/home/chris/src/KeraLua'
Making all in KeraLua.Tests
make[1]: Entering directory `/home/chris/src/KeraLua/KeraLua.Tests'
mkdir -p '../tests'
cp 'keralua.tests.pc' '../tests//keralua.tests.pc'
mkdir -p '../tests'
cp '../lib/nunit/nunit.framework.dll' '../tests//nunit.framework.dll'
make[1]: *** No rule to make target `../bin/Release/KeraLua.dll', needed by `../tests//KeraLua.dll'.  Stop.
make[1]: Leaving directory `/home/chris/src/KeraLua/KeraLua.Tests'
make: *** [all-recursive] Error 1


chris@zack:~/src/KeraLua$ make -f Makefile.Linux
cd external/lua; mkdir linux; cd linux; cmake -DCMAKE_BUILD_TYPE=Release ..; cmake --build . --config Release
mkdir: cannot create directory `linux': File exists
-- Copying include dirs from  /home/chris/src/KeraLua/external/lua/include to /home/chris/src/KeraLua/external/lua/linux
CMake Error at CMakeLists.txt:183 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:187 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:191 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:195 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:199 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:203 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:207 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:211 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:215 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:219 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:223 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:227 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



CMake Error at CMakeLists.txt:231 (ADD_TEST):
  add_test given unknown argument:

    WORKING_DIRECTORY



-- Configuring incomplete, errors occurred!
make[1]: Entering directory `/home/chris/src/KeraLua/external/lua/linux'
make[1]: *** No targets specified and no makefile found.  Stop.
make[1]: Leaving directory `/home/chris/src/KeraLua/external/lua/linux'
make: *** [all] Error 2

No `linux-arm` support.

Tried running a project on a platform with the RID linux-arm.

Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'lua53' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblua53: cannot open shared object file: No such file or directory

After inspecting LD_DEBUG=libs I was able to figure out that this issue happened because the name of the actual library is liblua5.3.so on both Ubuntu and Raspbian (or any Debian derivative). However when the project is compiled for linux-x64 liblua53.so is present in the output path, while it is not when compiled for linux-arm.

Compile lua52.dll with runtime

The lua52.dll from Nuget package is compiled with "/MD" runtime library flag (Multi-threaded DLL) which makes hard to distribute applications with NLua library.

Requesting to rebuild lua52.dll with "/MT" runtime library flag (Multi-threaded) to include the VS2013 C++ runtime in the binaries.

Heap corruption when using Get/SetUpValue

Version: 1.0.9
.NET Framework 4.6.1

I'm not actually sure if this is a KeraLua issue or a Lua issue (or a PEBCAK issue), but my application terminates when I use GetUpValue or SetUpValue.

The program '[176148] Scratch.exe' has exited with code -1073740940 (0xc0000374).

The exit code means heap corruption.

This sample program reproduces it. Just make a new Console application, reference the KeraLua nuget package, and paste the code into Program.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KeraLua;

namespace Scratch
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var lua = new Lua())
            {
                DoTest(lua);
            }

            Console.ReadKey(true);
        }

        private static void DoTest(Lua lua)
        {
            lua.LoadString("printf(\"Hello: \" .. _ENV.hello)");

            Console.WriteLine("Is Function? {0}", lua.IsFunction(1));

            var env = lua.GetUpValue(-1, 1);

            Console.WriteLine("_ENV = {0} (Null? {1})", env, env == null);
        }
    }
}

It outputs "Is Function? True" before the crash, and doesn't get to the "_ENV" line

Fails to load lua53 assembly when building with Mono.

When using msbuild with a Release configuration on Mono, and attempting to call any KeraLua functions, the following exception is thrown:

System.DllNotFoundException: lua53 assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) KeraLua.NativeMethods.luaL_newstate()
  at KeraLua.Lua..ctor (System.Boolean openLibs) [0x00011] in <235b271fdb5246b0b6f5e31909b083cc>:0
  at NLua.Lua..ctor () [0x00011] in <d06f979493b246a991c622e6280dbc61>:0
  at BattleRoyaleBot.Battle_Royale.EventLoader.Load (System.String folderPath) [0x00074] in <9408c3b008d14a8b8db6a62f5648b1f0>:0
  at BattleRoyaleBot.Program.StartBot () [0x00113] in <9408c3b008d14a8b8db6a62f5648b1f0>:0

Not really sure what's going on, I assume the assembly is failing resolve, but I have the lua53.dll, liblua53.dylib and Kera/NLua .dlls inside the folder, as well as in the x64 and x86 folders.

I'm using .NET Framework 4.7.1, and Mono compiler version 6.8.0.123.

Why data can be written at an offset memory location?

        private void SetExtraObject<T>(T obj, bool weak) where T : class
        {
            var handle = GCHandle.Alloc(obj, weak ? GCHandleType.Weak : GCHandleType.Normal);
            IntPtr extraSpace = _luaState - IntPtr.Size;
            Marshal.WriteIntPtr(extraSpace, GCHandle.ToIntPtr(handle));
        }

DynamicLibraryPath.GetAssemblyPath() and network folders

When the project is on a network folder, DynamicLibraryPath.GetAssemblyPath() returns an incomplete path. The host is being excluded.

In order for my project to find lua52.dll I have to add this before creating a Lua object:

SetDllDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, (IntPtr.Size == 8) ? "x64" : "x86"));

Where is cyrillic support?

I don't correctly know where i need to leave issue, so, if not here - sorry.
KeraLua can operate with cyrillic symbols but can't correctly decode them or something like this.
Example: i created code where index of table is russian words and value too. Output is ????.


How can i fix it? Because recompile projects (KeraLua and NLua) on UTF-8 didn't give the desired result.

Missing KeraLua.Lua.LuaPushInteger(IntPtr, Int64)

I am trying to get the value of int property in nested class and getting this:

System.MissingMethodException: Method not found: 'Void KeraLua.Lua.LuaPushInteger(IntPtr, Int64)'.
   at NLua.LuaLib.LuaPushInteger(LuaState luaState, Int64 value)
   at NLua.ObjectTranslator.Push(LuaState luaState, Object o)
   at NLua.Method.LuaMethodWrapper.Call(LuaState luaState)```

Xamarin/Android: dlopen liblua53.so fails

We're using KeraLua/NLua with Xamarin/Android and our application fails to start since KeraLua Version 1.0.4 at least. The error we get is (name of app obfuscated):

07-22 13:26:16.210 D/Mono (22457): DllImport attempting to load: 'liblua53.so'.
07-22 13:26:16.214 D/Mono (22457): DllImport error loading library './liblua53.so': 'dlopen failed: cannot locate symbol "fseeko64" referenced by "/data/app/myapp/lib/arm64/liblua53.so"...'.
07-22 13:26:16.215 D/Mono (22457): DllImport error loading library './liblua53.so': 'dlopen failed: cannot locate symbol "fseeko64" referenced by "/data/app/myapp/lib/arm64/liblua53.so"...'.
07-22 13:26:16.215 D/Mono (22457): DllImport error loading library '/system/lib/liblua53.so': 'dlopen failed: library "/system/lib/liblua53.so" not found'.
07-22 13:26:16.215 D/Mono (22457): DllImport error loading library '/system/lib/liblua53.so': 'dlopen failed: library "/system/lib/liblua53.so" not found'.

It works on selected devices (eg Nexus 5x), but fails for most. I think it might be related to android/ndk#364 in one way or another.

Build fails in Ubuntu/WSL using latest git

I have the mono build stuff installed per https://www.mono-project.com/download/stable/#download-lin-ubuntu, so NUnit should be available.

However, when I run the build I get the following errors.

What am I doing wrong?

ken@shopdesktop:~/repos/KeraLua$ msbuild KeraLua.sln
Microsoft (R) Build Engine version 16.6.0 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 03/13/2022 10:30:21.
Project "/home/ken/repos/KeraLua/KeraLua.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "/home/ken/repos/KeraLua/KeraLua.sln" (1) is building "/home/ken/repos/KeraLua/build/net46/KeraLua.csproj" (2) on node 1 (default targets).
BuildLuaLinux:
Building Linux Lua library (x64)
cmake --build . --config Release
[ 47%] Built target liblua_static
[ 50%] Built target luac
[ 97%] Built target liblua
[100%] Built target lua
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_SignAssembly:
sn -q -R "obj/Debug/KeraLua.dll" "/home/ken/repos/KeraLua/build/targets/../../NLua.snk"
CopyFilesToOutputDirectory:
Copying file from "/home/ken/repos/KeraLua/build/net46/obj/Debug/KeraLua.dll" to "/home/ken/repos/KeraLua/lib/Debug/net46/KeraLua.dll".
KeraLua -> /home/ken/repos/KeraLua/lib/Debug/net46/KeraLua.dll
Done Building Project "/home/ken/repos/KeraLua/build/net46/KeraLua.csproj" (default targets).
Project "/home/ken/repos/KeraLua/KeraLua.sln" (1) is building "/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj" (3) on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
/usr/lib/mono/msbuild/Current/bin/Roslyn/csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:AnyCPU /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:/home/ken/repos/KeraLua/lib/Debug/net46/KeraLua.dll /reference:/usr/lib/mono/4.6-api/mscorlib.dll /reference:/usr/lib/mono/4.6-api/System.Core.dll /reference:/usr/lib/mono/4.6-api/System.dll /reference:/usr/lib/mono/4.6-api/System.Drawing.dll /reference:/usr/lib/mono/4.6-api/System.Xml.dll /reference:/usr/lib/mono/4.6-api/System.Xml.Linq.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj/Debug/KeraLuaTest.dll /subsystemversion:6.00 /target:library /warnaserror+ /utf8output /langversion:7.3 /analyzerconfig:/home/ken/repos/KeraLua/.editorconfig ../../Properties/AssemblyInfo.cs ../../Tests/Core.cs ../../Tests/Interop.cs "obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs"
Using shared compilation with compiler from directory: /usr/lib/mono/msbuild/Current/bin/Roslyn
/home/ken/repos/KeraLua/tests/Tests/Core.cs(3,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(4,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(15,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(15,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(13,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(13,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(86,10): error CS0246: The type or namespace name 'SetUpAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(86,10): error CS0246: The type or namespace name 'SetUp' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(93,10): error CS0246: The type or namespace name 'TearDownAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(93,10): error CS0246: The type or namespace name 'TearDown' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(100,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(100,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(106,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(106,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(113,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(113,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(119,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(119,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(125,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(125,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(131,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(131,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(137,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(137,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(144,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(144,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(150,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(150,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(21,10): error CS0246: The type or namespace name 'SetUpAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(21,10): error CS0246: The type or namespace name 'SetUp' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(83,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(83,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(96,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(96,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(118,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(118,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(216,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(216,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(256,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(256,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(305,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(305,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(317,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(317,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(330,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(330,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(356,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(356,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(370,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(370,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(397,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(397,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(416,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(416,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(428,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(428,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(451,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(451,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(480,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(480,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
Done Building Project "/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj" (default targets) -- FAILED.
Done Building Project "/home/ken/repos/KeraLua/KeraLua.sln" (default targets) -- FAILED.

Build FAILED.

"/home/ken/repos/KeraLua/KeraLua.sln" (default target) (1) ->
"/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj" (default target) (3) ->
(CoreCompile target) ->
/home/ken/repos/KeraLua/tests/Tests/Core.cs(3,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(4,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(15,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(15,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(13,6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(13,6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(86,10): error CS0246: The type or namespace name 'SetUpAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(86,10): error CS0246: The type or namespace name 'SetUp' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(93,10): error CS0246: The type or namespace name 'TearDownAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(93,10): error CS0246: The type or namespace name 'TearDown' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(100,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(100,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(106,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(106,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(113,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(113,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(119,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(119,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(125,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(125,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(131,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(131,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(137,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(137,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(144,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(144,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(150,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Core.cs(150,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(21,10): error CS0246: The type or namespace name 'SetUpAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(21,10): error CS0246: The type or namespace name 'SetUp' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(83,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(83,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(96,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(96,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(118,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(118,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(216,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(216,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(256,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(256,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(305,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(305,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(317,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(317,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(330,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(330,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(356,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(356,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(370,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(370,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(397,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(397,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(416,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(416,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(428,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(428,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(451,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(451,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(480,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]
/home/ken/repos/KeraLua/tests/Tests/Interop.cs(480,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ken/repos/KeraLua/tests/build/net46/KeraLuaTest.csproj]

0 Warning(s)
60 Error(s)

Time Elapsed 00:00:01.18
ken@shopdesktop:~/repos/KeraLua$

State.NewLib State.SetFuncs: Attempted to read or write protected memory

KeraLua Version: 1.2.9
.NET Core Version: netcoreapp3.1

Upon trying to call Lua.NewLib this exception happen:
Note: It rarely works

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at KeraLua.NativeMethods.luaL_setfuncs(IntPtr, KeraLua.LuaRegister[], Int32)
   at KeraLua.NativeMethods.luaL_setfuncs(IntPtr, KeraLua.LuaRegister[], Int32)
   at KeraLua.Lua.SetFuncs(KeraLua.LuaRegister[], Int32)
   at KeraLua.Lua.NewLib(KeraLua.LuaRegister[])
   at TestLua.Program.OpenFoo(IntPtr)
   at KeraLua.NativeMethods.luaL_requiref(IntPtr, System.String, IntPtr, Int32)
   at KeraLua.NativeMethods.luaL_requiref(IntPtr, System.String, IntPtr, Int32)
   at KeraLua.Lua.RequireF(System.String, KeraLua.LuaFunction, Boolean)
   at TestLua.Program.Main()

Process finished with exit code -1,073,741,819.

This is the code I used to reproduce the bug:

using System;
using KeraLua;

namespace TestLua {
    class Program {
        private static LuaRegister[] fooReg = {
            new LuaRegister {
                name = "foo",
                function = Foo,
            }
        };
            
        static void Main() {
            var L = new Lua();
            L.RequireF("foobar", OpenFoo, true);

            L.DoFile("init.lua");
        }

        static int OpenFoo(IntPtr state) {
            var L = Lua.FromIntPtr(state);
            L.NewLib(fooReg);
            return 1;
        }
        
        static int Foo(IntPtr state) {
            var L = Lua.FromIntPtr(state);
            
            L.PushString("bar");
            return 1;
        }
    }
}

Tested with this Lua script:

print("Script started")

print(foobar.bar())

print("Script ended")

Error since upgrading to 1.0.3.0

Since upgrading to 1.0.3.0, I get a compilation error:

(In German)

ASPNETCOMPILER : error ASPCONFIG: Die Datei oder Assembly "KeraLua, Version=1.0.3.0, Culture=neutral, PublicKeyToken=6a194c04b9c89217" oder eine AbhΓ€ngigkeit davon wurde nicht gefunden. Die Signatur mit starkem Namen konnte nicht ΓΌberprΓΌft werden. Die Assembly wurde mΓΆglicherweise geΓ€ndert oder verzΓΆgert aber nicht vollstΓ€ndig mit dem richtigen privaten SchlΓΌssel signiert. (Ausnahme von HRESULT: 0x80131045) [c:\MyMvcWebApp\MyMvcWebApp.csproj]

Manually translated to English, the core error text reads:

The signature with a strong name could not be verified. Assembly may have been changed or delayed but not fully signed with the correct private key.

My question:

What am I doing wrong here? How can I fix this behaviour?

KeraLua LuaDebug properties all return the same data

Every property is returning pname instead of using their respective string pointers. I noticed when trying to get the source of a function call in my project.

src/KeraLua/LuaDebug.cs:

		public string name
		{
			get
			{
				return new CharPtr (pname).ToString ();
			}
		}

		public string namewhat
		{
			get
			{
				return new CharPtr (pname).ToString ();
			}
		}

		public string source
		{
			get
			{
				return new CharPtr (pname).ToString ();
			}
		}

		public string shortsrc
		{
			get
			{
				return new CharPtr (pname).ToString ();
			}
}

System.EntryPointNotFoundException on OS X

I'm not sure when this started, but I get System.EntryPointNotFoundException on OS X for luanet_pushwstring:

  at (wrapper managed-to-native) KeraLua.NativeMethods:LuaPushString (intptr,string)
  at KeraLua.Lua.LuaPushString (System.IntPtr luaState, System.String str) [0x00000] in <f26ec5b5744e4574a1bb7a4fd61f6061>:0 
  at NLua.LuaLib.LuaPushString (KeraLua.LuaState luaState, System.String str) [0x00006] in <bf52c1feee2240539fa2d5d6a0eda224>:0 
  at NLua.Lua.Init () [0x00000] in <bf52c1feee2240539fa2d5d6a0eda224>:0 
  at NLua.Lua..ctor () [0x00027] in <bf52c1feee2240539fa2d5d6a0eda224>:0 
  at Blugen.Entities.Player.SetupBindings () [0x00001] in /Users/tyler/Documents/Code/Blugen/Entities/Player.cs:186 
  at Blugen.Entities.Player..ctor (Microsoft.Xna.Framework.Game game, System.UInt32 id, Blugen.Animation.Animation[] animations, Blugen.Animation.Collision[] defaultBoxes, System.String name, System.String author, Microsoft.Xna.Framework.Vector2 stagePos, System.Nullable`1[T] localCoord, Blugen.Graphics.SFF sff, System.Boolean facing, System.Collections.Generic.Dictionary`2[TKey,TValue] commands, Blugen.Entities.Constants constants, System.String[] stateFiles, System.String filePath) [0x00096] in /Users/tyler/Documents/Code/Blugen/Entities/Player.cs:94 
  at Blugen.Blugen.LoadCharacters (System.String[] definitionPaths) [0x001fe] in /Users/tyler/Documents/Code/Blugen/Blugen.cs:306 
  at Blugen.Blugen.LoadContent () [0x00042] in /Users/tyler/Documents/Code/Blugen/Blugen.cs:231 
  at Microsoft.Xna.Framework.Game.Initialize () [0x0004d] in <a6b5c1686196475aa75b8dde7820e259>:0 
  at Blugen.Blugen.Initialize () [0x00001] in /Users/tyler/Documents/Code/Blugen/Blugen.cs:210 
  at Microsoft.Xna.Framework.Game.DoInitialize () [0x00032] in <a6b5c1686196475aa75b8dde7820e259>:0 
  at Microsoft.Xna.Framework.Game.Run (Microsoft.Xna.Framework.GameRunBehavior runBehavior) [0x00033] in <a6b5c1686196475aa75b8dde7820e259>:0 
  at Microsoft.Xna.Framework.Game.Run () [0x0000c] in <a6b5c1686196475aa75b8dde7820e259>:0 
  at Blugen.Program.Main () [0x00007] in /Users/tyler/Documents/Code/Blugen/Program.cs:18 

All I do is call new Lua() and I get this error. I copied liblua52.dylib, KeraLua.dll, and NLua.dll to the bin output directory and this still persists. Any ideas?

Lua.ToString changes stack if callMetamethod is true

When using Lua.ToString(index), I was getting unexpected behaviors. I determined that Lua.ToString(index, true) was adding a value to the Lua stack.

After investigation, I discovered that Lua.ToString(index, true) ends up ultimately calling luaL_tolstring in Lua.ToBuffer, which pushes a value onto the stack in addition to returning the buffer value.

My expected behavior of a function called ToString(index) is that it simply returns a string value without modifying the Lua stack, especially since calling ToString(index, false) does not change the Lua stack.

Regards,
JPG

Can you open only some libraries?

I'm trying to load only some libraries, specifically, I want to avoid loading up the io library for sandbox reasons.
Looking at the manual, it should be possible according to the manual, but I don't see a way to do that with KeraLua.
Is this a feature that doesn't exist or am I overlooking how to do it?

How to use KeraLua.Lua.NewUserData correctly

Hello,

I do not know how to use the function KeraLua.Lua.NewUserData() correctly. I get a valid IntPtr object from it but do not know how to dereference it to a structure. The following code is a stripped-down snippet which causes a System.ExecutionEngineException at:

Fatal error. Internal CLR error. (0x80131506)
   at System.StubHelpers.InterfaceMarshaler.ConvertToManaged(IntPtr, IntPtr, IntPtr, Int32)
   at System.Runtime.InteropServices.Marshal.PtrToStructureHelper(IntPtr, System.Object, Boolean)
   at System.Runtime.InteropServices.Marshal.PtrToStructureHelper(IntPtr, System.Type)
   at System.Runtime.InteropServices.Marshal.PtrToStructure(IntPtr, System.Type)
   at NLuaExperiments.KeraLuaTest.Start()
   at NLuaExperiments.Program.Main(System.String[])
using NLua;
using System;
using System.Runtime.InteropServices;

namespace NLuaExperiments
{
    public struct UserData
    {
        public object Ref;
    }

    public class KeraLuaTest
    {
        private Lua lua;
        public KeraLuaTest(Lua lua)
        {
            this.lua = lua;
        }

        public void Start()
        {
            KeraLua.Lua state = lua.State;

            IntPtr p = state.NewUserData(Marshal.SizeOf(default(UserData)));
            UserData u = (UserData)Marshal.PtrToStructure(p, typeof(UserData));
        }
    }

    class Program
    {
        private static Lua lua = new();

        static void Main(string[] args)
        {
            new KeraLuaTest(lua).Start();
        }
    }
}

Does NewUserData() does not provide a valid memory pointer to use as structure?

Value returned from Lua.FromIntPtr should not be Disposable

Hi!
I was experimenting with KeraLua for some time and spotted something that can be considered a serious bug.

Consider the following code:

private static int NativeFunc(IntPtr ptr)
{
    using var lua = Lua.FromIntPtr(ptr);
    return 0;
}


public static void Main(string[] args)
{
    using (var lua = new Lua())
    {
        lua.PushCFunction(NativeFunc);
        lua.SetGlobal("Worker");

        lua.DoString("Worker()");
        lua.DoString("print('Test')");
    }
}

As we can see we register a native (low-level) function that receives the state as an IntPtr. We use Lua.FromIntPtr to get a usable state object. Since the received value implements IDisposable, we should dispose it, that is why we are add the using keyword. However, this destroys the Lua VM and thus the proper execution of the application could not continue.

In my opinion Lua.FromIntPtr behaves in the wrong way: returning something that implements IDisposable it actually transfers ownership of the Lua VM to the function body, while it should keep in a single place.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.