lmcode-csharp skill

Use lmcode-csharp to embed the DSLB v6 bytecode runtime, 226-signature standard catalog, and REST/CLI controller into .NET 8 and NativeAOT C# hosts.

Purpose

Build reflection-free, NativeAOT-ready C# host applications that verify and execute lmcode DSLB v6 programs and emit LMCODE_RETURN envelopes.

When to use it

Use lmcode-csharp when authoring a .NET 8 application or NativeAOT binary that exposes C# domain objects or REST/CLI routes to compiled lmcode bytecode.

Install

Reference src/LmCode/LmCode.csproj with dotnet add reference or vendor the src/LmCode directory in a .NET 8 SDK project.

Commands

dotnet build -c Release -warnaserror
dotnet test
dotnet run --project conformance/LmCode.Conformance -- conformance/vectors
dotnet run --project conformance/LmCode.Conformance -- conformance/stdlib-vectors
dotnet publish examples/Greeter -r linux-x64 -c Release -p:PublishAot=true

Inputs and outputs

Safety rules

Worked examples

var registry = new Registry();
registry.Function("greet", ["string"], "void", (_, values) =>
{
    Console.Error.WriteLine("Hello, " + values[0].AsStr().ToString());
    return Value.None;
});
var program = LmCode.Program.Load(File.ReadAllBytes(path), schemaBytes, registry);
var context = new Context();
program.Run(context, registry);

Errors and exit codes

CodePhaseExitCondition
LOAD_BAD_BYTECODEload3Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation
LOAD_BAD_SCHEMAload3Host schema JSON fails dsl.schema 2 validation or declares an invalid result contract
LOAD_SCHEMA_MISMATCHload332-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes
LOAD_UNBOUNDload3Bytecode imports a context, function, or method signature not registered in the host Registry
RUN_ERRORrun3VM division or remainder by zero, or loop-free operand stack underflow
RUN_HOSTrun3Host callback failure, invalid encoding, expired collection handle, or REST route validation failure
APP_FAILapp4Post-run application domain validation failure or output stream write failure

How to verify

bash scripts/sync-std.sh --verify
bash scripts/sync-rest.sh --verify
dotnet test
lmscript test.lms