Skip to content
Skills Library
Programming · Building & coding

zlua-generic-method

/zlua-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.

Repository
unity-mcp ↗
Licence
MIT
Last repository change
02.11.2026

Assessment and security

95/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content30 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 02.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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.

Original author description

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.

How it works

  1. Closed generic types
  2. Generic methods
Original SKILL.md headings · 52 lines, 302 words
SKILL.md preview
---
name: zlua-generic-method
description: >-
  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.
---

# Generic types and generic methods

A closed generic type is an ordinary type table. A method that still has its own type parameters is not an overload; close it with `zlua.inflate` or a GTAP prefix. There is no `make_generic_method` or `register_method`.

## Closed generic types

The open definition name includes the arity backtick: ``List`1``, ``Dictionary`2``.

```lua
local ListInt = zlua.make_generic_type(
    CSharp.mscorlib['System.Collections.Generic.List`1'],
    zlua.types.int32)

local list = ListInt()
list:Add(10)

local DictStrInt = zlua.make_generic_type(
    CSharp.mscorlib['System.Collections.Generic.Dictionary`2'],
    zlua.types.string,
    zlua.types.int32)
```

The first argument is the open type table. The rest are type arguments (`zlua.types.*`, a type table, a type name, or `System.Type`). `List<int>.Add` is a normal method. Do not inflate it.

If `List` is missing, the key must be the full name ``System.Collections.Generic.List`1`` in brackets. The number of type arguments must match the arity.

## Generic methods

`zlua.inflate` closes only the method's type parameters. If the declaring type is still open, call `make_generic_type` first. Cache the closure on a hot path.

GTAP puts N `System.Type` values in front of a short-name call. Those prefixes must be `zlua.typeof(...)`. A type table, a string, or `zlua.types.*` is not a GTAP prefix. `inflate` accepts the full type-argument set.

```lua
local Rigidbody = CSharp['UnityEngine.CoreModule']['UnityEngine.Rigidbody']

local GetRb = zlua.inflate(GameObject, "GetComponent", Rigidbody)
local rb = GetRb(go)

local rb2 = go:GetComponent(zlua.typeof(Rigidbody))
```

When several short names match, pass a full signature key as the second argument to `inflate`. See `zlua-method-overload`.

The return value uses the declared type's facade. To view it as the runtime type, use `zlua.cast` or `ActualTypeUserData` (`zlua-marshal-as`).

| Mistake | Fix |
|---------|-----|
| Wrong arity | Match `` `1 `` / `` `2 `` to the argument count |
| `inflate` on `List<int>.Add` | Inflate only methods that declare their own type parameters |
| GTAP given a type table | Wrap it with `zlua.typeof`, or use `inflate` |

Versions

The database has no other skills named zlua-generic-method.

Database snapshot: 13.11.2026 · package version d7819251bb1a (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-lib
    Uses the global zlua table: type arguments, typeof, make_generic_type, arrays, inflate, box, unbox, cast, opaque, and to_delegate. Use when Lua needs a zlua.* helper instead of a CSharp member call.
  • 95zlua-in-ref-out
    Marshals C# ref, in, and out parameters with ZLua. Use when a method has ref, in, or out arguments, when Lua should receive multiple results from out parameters, or when a byref write does not show up in the Lua value.
  • 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.
  • 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'.
  • 100grandma3-lua-api
    Write, debug, and reason about grandMA3 Lua plugins and scripting — the Object API and Object-Free API (Cmd, Printf, Get/Set, handles, UI dialogs, progress bars), plugin XML/structure, and showfile paths. Use when a user asks to write a grandMA3 plugin or Lua script, automate a…
  • 100lua-embedding-scripting
    Use this skill when embedding Lua runtimes into C, Go, or Rust applications for dynamic plugin scripting and configuration rules.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.