lmcode-csharp-sample skill
Use lmcode-csharp-sample as a verified blueprint for embedding lmcode-csharp (vendor/lmcode-csharp) in a C# (.NET 8) host application with schema discovery, R49 rule entries, dry mode, and LMCODE_RETURN framing.
Purpose
Demonstrate a complete, byte-pinned C# (.NET 8) host application that exposes a 45-signature Shop/Ledger domain to DSLB v6 bytecode and passes the shared sample suite.
When to use it
Use lmcode-csharp-sample when learning how to bind C# (.NET 8) domain objects, overloaded methods, operators, R49 rule entries, and LMCODE_RETURN result envelopes with lmcode-csharp (vendor/lmcode-csharp).
Install
Clone lmctl-ai/lmcode-csharp-sample and run ./test.sh with C# (.NET 8), Python 3, Node 24, and a DSLB v6 capable lmscript compiler (set LMSCRIPT_BIN to select one).
Commands
git clone https://github.com/lmctl-ai/lmcode-csharp-sample.git
cd lmcode-csharp-sample
python3 scripts/sync.py check
./test.sh
dotnet run --project src/LmCode.Sample.csproj -- --version
dotnet run --project src/LmCode.Sample.csproj -- --lmcode-schema --json
dotnet run --project src/LmCode.Sample.csproj -- --lmcode-signatures
dotnet run --project src/LmCode.Sample.csproj -- --lmcode sample-suite/bytecode/001-literals.dslb
Inputs and outputs
- Input: compiled .dslb v6 bytecode files from sample-suite/bytecode/, embedded sample.dsl.json schema, and optional LMCODE_INVOCATION_FILE manifest.
- Output: print trace lines, entry NAME = VALUE lines, tagged host_summary JSON diagnostic, and terminal LMCODE_RETURN_BEGIN / END frame.
- Locks: sdk.lock and suite.lock pinning every vendored SDK and corpus byte by commit SHA and SHA-256.
Safety rules
- Verify sdk.lock and suite.lock before building so vendored SDK and corpus files never drift silently.
- Preserve raw byte strings across Ledger.note and JSON diagnostics without lossy UTF-8 replacement.
- Check LMCODE_INVOCATION_FILE dry mode before seeding or mutating external state so dry runs remain side-effect-free.
Worked examples
prog = _lmcode_ cli="lmcode-csharp-sample" install="github:lmctl-ai/lmcode-csharp-sample@latest";
ledger.record(shop.total());
end _lmcode_
r = run_lmcode(prog);
Errors and exit codes
| Code | Phase | Exit | Condition |
|---|---|---|---|
| LOAD_BAD_BYTECODE | load | 3 | Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation |
| LOAD_BAD_SCHEMA | load | 3 | Host schema JSON fails dsl.schema 2 validation or declares an invalid result contract |
| LOAD_SCHEMA_MISMATCH | load | 3 | 32-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes |
| LOAD_UNBOUND | load | 3 | Bytecode imports a context, function, or method signature not registered in the host Registry |
| RUN_ERROR | run | 3 | VM runtime error such as division or remainder by zero |
| RUN_HOST | run | 3 | Host callback failure, invalid encoding, or expired collection handle |
| APP_FAIL | app | 4 | Post-run application domain validation failure or output stream write failure |
How to verify
./test.sh