zlua-extension
/zlua-extension
Registers C# extension methods on the extended type so Lua can call obj:ExtFoo. Use when writing [LuaExtension], ZLuaExtensions, luaExtensionXmlPaths, or when an extension method is missing from a Lua instance.
- Author
- killop ↗
- Repository
- unity-mcp ↗
- Licence
- MIT
- Last repository change
- 02.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 02.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Registers C# extension methods on the extended type so Lua can call obj:ExtFoo. Use when writing [LuaExtension], ZLuaExtensions, luaExtensionXmlPaths, or when an extension method is missing from a Lua instance.
Original author description
Registers C# extension methods on the extended type so Lua can call obj:ExtFoo. Use when writing [LuaExtension], ZLuaExtensions, luaExtensionXmlPaths, or when an extension method is missing from a Lua instance.
How it works
- Attribute
- XML
- Which methods appear
- Same name as an instance method
SKILL.md preview
---
name: zlua-extension
description: >-
Registers C# extension methods on the extended type so Lua can call
obj:ExtFoo. Use when writing [LuaExtension], ZLuaExtensions, luaExtensionXmlPaths,
or when an extension method is missing from a Lua instance.
---
# Extension methods
ZLua does not scan the assembly for `ExtensionAttribute`. Bind looks up a list of extension classes configured on the extended type, then reflects only those classes. An unconfigured extension is `zlua: member not found`, not a static call on the helper class.
| | |
|--|--|
| Attribute | `[LuaExtension(typeof(ExtClass), ...)]` on the extended type |
| XML root | `ZLuaExtensions` |
| Settings | `luaExtensionXmlPaths` |
Do not put `[LuaExtension]` on the static extension class. Do not mix this XML with `ZLuaAlias` or `ZLuaMarshalAs`.
## Attribute
Editable types, including hot-update assemblies, use the attribute only. XML is ignored for hot-update assemblies (including HybridCLR).
```csharp
using ZLua;
public static class MyClassExt
{
public static void ResetLocal(this MyClass self) { }
}
[LuaExtension(typeof(MyClassExt), typeof(MyClassTweenExt))]
public class MyClass { }
```
```lua
local obj = CSharp.AC.MyClass()
obj:ResetLocal()
```
`AllowMultiple` is allowed. Several attributes on the same type are unioned. Binding `T` also walks `BaseType` and collects `[LuaExtension]` from base types.
An interface extension list is used only when that interface type itself is configured and the method's `this` accepts the type being bound. Implementing an interface does not import extensions configured only on the interface.
## XML
Use XML when the extended type is precompiled, AOT, or third-party, and is not a hot-update assembly. `this` must match `Type/@fullName`.
```xml
<?xml version="1.0" encoding="utf-8"?>
<ZLuaExtensions version="1">
<Assembly name="UnityEngine.CoreModule">
<Type fullName="UnityEngine.Transform">
<Extension assembly="Assembly-CSharp" fullName="MyGame.TransformExt"/>
</Type>
</Assembly>
</ZLuaExtensions>
```
`Assembly/@name` is the extended type's assembly short name. `Extension/@assembly` and `@fullName` name the extension class. This file allows only `Assembly` / `Type` / `Extension`.
Attribute and XML lists are unioned. An unresolvable extension class fails Generate, and fails Mono Initialize or Bind. Il2Cpp bakes the list at Generate. The Player does not read XML. A type that is already bound does not pick up an extension assembly loaded later.
## Which methods appear
From each extension class, keep `public static` methods that have `ExtensionAttribute`, have at least one parameter, and whose first parameter can accept the bound type (`this Base` works on a `Derived` instance). Open generic extension methods are not supported. A class that contributes no matching method is allowed.
The method is an instance method on the extended type. It is not added to that type's static table. Lua arity is the CLR parameter count minus `this`. The full signature key lists only the parameters after `this`. `[LuaAlias]` can still rename it (`zlua-alias`).
Structs get the same methods on both ByVal and ByObj instance tables.
## Same name as an instance method
The extension and a real instance method with the same final Lua name are one overload group. There is no instance-first rule. One candidate is a direct closure. Several candidates dispatch. Disambiguate with a full signature key or `[LuaAlias]` (`zlua-method-overload`, `zlua-alias`).
Versions
The database has no other skills named zlua-extension.
Database snapshot: 13.11.2026 · package version 7a3c153bee9a (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 95zlua-csharp-call-lua
Calls Lua from C# with LuaAppDomain.Initialize and GetFunction. Use when writing a module loader, binding Action or Func to a Lua module method, or reloading scripts with Reset. - 95zlua-generic-method
Closes C# generic types and generic methods from Lua with make_generic_type, zlua.inflate, and GTAP typeof prefixes. Use when Lua calls List<T>, Dictionary, GetComponent<T>, or any method that still has its own type parameters. - 90lua-guide
Use when editing general-purpose Lua 5.4+: modules, scripts, configuration. Triggers on `.lua` files and prompts about module patterns, local scoping, metatables, coroutines, error handling, even when the user doesn't say 'Lua'. - 95extension-creator
Create AiderDesk extensions by setting up extension files, defining metadata, implementing Extension interface methods, and updating documentation. Use when building a new extension, creating extension commands, tools, or event handlers. - 85Lua C Integration
Use when lua C API for extending Lua with native code including stack operations, calling C from Lua, calling Lua from C, creating C modules, userdata types, metatables in C, and performance optimization techniques. - 100lua-embedding-scripting
Use this skill when embedding Lua runtimes into C, Go, or Rust applications for dynamic plugin scripting and configuration rules.