Lua551.NET
1.0.0
dotnet add package Lua551.NET --version 1.0.0
NuGet\Install-Package Lua551.NET -Version 1.0.0
<PackageReference Include="Lua551.NET" Version="1.0.0" />
<PackageVersion Include="Lua551.NET" Version="1.0.0" />
<PackageReference Include="Lua551.NET" />
paket add Lua551.NET --version 1.0.0
#r "nuget: Lua551.NET, 1.0.0"
#:package Lua551.NET@1.0.0
#addin nuget:?package=Lua551.NET&version=1.0.0
#tool nuget:?package=Lua551.NET&version=1.0.0
Lua 5.5.1 for .NET
A direct C# port of Lua 5.5.1 for embedding Lua in .NET applications, with support for both JIT and Native AOT deployment. The public API follows the original C API and is exposed through LinkBridge.Lua.LuaApi.
The implementation is self-contained and has no native or NuGet dependencies. It uses unsafe code to preserve Lua's pointer-based runtime model.
Requirements
- .NET 9 SDK or newer
AllowUnsafeBlocksenabled in consuming projects
Build
dotnet build Lua551.sln -c Release
To consume the project directly, add a project reference:
<ItemGroup>
<ProjectReference Include="path/to/Lua551.csproj" />
</ItemGroup>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
NuGet package
dotnet pack Lua551.csproj -c Release -o artifacts
GitHub Actions builds Lua551.NET.1.0.0.nupkg on every push and pull request and uploads it as a workflow artifact.
Public releases are published to nuget.org through Trusted Publishing. Create a GitHub release with a tag such as v1.0.0; the release workflow uses the tag as the package version, runs the tests and Native AOT smoke check, then publishes the package.
dotnet add package Lua551.NET --version 1.0.0
Example
using System;
using LinkBridge.Lua;
using static LinkBridge.Lua.LuaApi;
unsafe
{
lua_State* state = luaL_newstate();
if (state == null) throw new InvalidOperationException("Could not create a Lua state.");
try
{
luaL_openlibs(state);
int status = luaL_loadstring(state, CSTR("return 6 * 7"u8));
if (status == LUA_OK) status = lua_pcall(state, 0, 1, 0);
if (status != LUA_OK) throw new InvalidOperationException(CStr(lua_tostring(state, -1)));
Console.WriteLine(lua_tointeger(state, -1)); // 42
}
finally
{
lua_close(state);
}
}
Native AOT
The library is compatible with .NET Native AOT and does not rely on reflection or runtime code generation. The repository includes a smoke application that creates a Lua state, opens the standard libraries, evaluates return 6 * 7 and checks the result.
dotnet publish tests/Lua551.AotSmoke/Lua551.AotSmoke.csproj -c Release -r win-x64
The published executable is run in CI to verify that the native binary starts and executes Lua code successfully.
Tests
dotnet test tests/Lua551.Tests/Lua551.Tests.csproj -c Release
The test project runs the official Lua 5.5.1 correctness suite in portable basic mode (_U=true) through an xUnit integration test.
The upstream suite is stored unchanged under tests/official/lua-5.5.1-tests. On Windows, the runner skips only the /dev/null and /dev/full flush block because those POSIX devices do not exist. Complete and internal modes need native helper libraries and are not run by CI.
Notes
- The API intentionally stays close to Lua's C API, including function pointers and unmanaged memory.
- Default module paths currently follow Windows conventions.
- Applications are responsible for closing each created Lua state.
License
This project and the original Lua sources are distributed under the MIT license. See LICENSE and LICENSE_LUA.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 98 | 8/17/2026 |