lmcode-csharp reference

Reference tables for the LmCode .NET 8 namespace, Registry and Program APIs, lmcode_std_v3 REST/CLI interfaces, and Error codes.

Host SDK API surface

APIType / ReturnDescription
new Registry()RegistryConstruct a registry with all 226 canonical lmcode_std_v3 signatures installed
new Registry(false)RegistryConstruct an empty registry without standard library bindings
registry.Context(name, type)RegistryDeclare a named host object context variable
registry.Function(name, params, ret, cb, dry?)RegistryRegister a host function overload with optional Registry.Dry(cb) slot
registry.Method(owner, name, params, ret, cb, dry?)RegistryRegister a host method overload with optional Registry.Dry(cb) slot
registry.Signatures()string[]Return sorted canonical signatures for all registered items
Program.Load(bytecode, schema, registry)ProgramVerify DSLB v6 bytes against exact schema bytes and bind imports
program.EntriesIReadOnlyList<Entry>Source-ordered R49 rule entry descriptors
program.Run(context, registry)voidExecute the bytecode body
program.Call(entryIdx, context, registry, args)ValueExecute an R49 rule entry by index
RestCatalog.RegisterRest(registry, options)RestControllerBind the 20 standard REST/CLI signatures to a configured RestController
restController.Run(program, context?)voidRun the program body and serve HTTP/1.1 over stdio if rest_serve() was called
restController.Dispatch(request)RestResponseDispatch one HTTP request in memory
InvocationResults.FromCommand(files)InvocationResultsInitialize per-part ResultSinks and dry mode from LMCODE_INVOCATION_FILE

Standard REST and CLI interfaces (lmcode_std_v3)

The default lmcode_std_v3 catalog provides 226 canonical signatures and 10 standard interfaces on RestExchange for HTTP/1.1 stdio endpoints and stateless CLI commands.

InterfaceCanonical declarationBehavior
RestGetinterface RestGet(exchange: RestExchange) -> voidHTTP GET endpoint bound by path annotation such as @"/users/:id"
RestPostinterface RestPost(exchange: RestExchange) -> voidHTTP POST endpoint bound by path annotation such as @"/users"
RestPutinterface RestPut(exchange: RestExchange) -> voidHTTP PUT endpoint bound by path annotation such as @"/users/:id"
RestDeleteinterface RestDelete(exchange: RestExchange) -> voidHTTP DELETE endpoint bound by path annotation such as @"/users/:id"
RestPatchinterface RestPatch(exchange: RestExchange) -> voidHTTP PATCH endpoint bound by path annotation such as @"/users/:id"
RestHeadinterface RestHead(exchange: RestExchange) -> voidHTTP HEAD endpoint bound by path annotation
RestOptionsinterface RestOptions(exchange: RestExchange) -> voidHTTP OPTIONS endpoint bound by path annotation
RestHandlerinterface RestHandler(exchange: RestExchange) -> voidMethod-prefixed (@"POST /users") or rest_route(method, path, annotation) handler
CliCommandinterface CliCommand(exchange: RestExchange) -> voidStateless CLI subcommand entry dispatched by rest_cli(args)
CliOptioninterface CliOption(exchange: RestExchange) -> voidStateless CLI flag or option entry dispatched before CliCommand by rest_cli(args)

Standard REST and CLI functions and methods

NameCanonical signatureDescription
rest_configfn rest_config(string, string) -> voidSet controller configuration keys such as prefix, max_body_bytes, or session before rest_serve()
rest_routefn rest_route(string, string, string) -> voidBind an HTTP method and path template (:param, :rest..., {param}, {rest...}) to a RestHandler annotation
rest_servefn rest_serve() -> voidValidate registered routes and request HTTP/1.1 stdio serving after the program body finishes
rest_stopfn rest_stop() -> voidStop stdio HTTP/1.1 serving after the active response finishes flushing
rest_clifn rest_cli(StrList) -> stringDispatch a single stateless CLI argv vector across CliOption, CliCommand, or REST routes and return the response body
RestExchange.methodmethod RestExchange.method() -> stringReturn the uppercase HTTP method verb for the active request
RestExchange.pathmethod RestExchange.path() -> stringReturn the percent-decoded request path without the query string
RestExchange.querymethod RestExchange.query(string) -> stringReturn the first value of a query key or empty string when absent
RestExchange.has_querymethod RestExchange.has_query(string) -> boolReturn true when the query key is present in the request target
RestExchange.parammethod RestExchange.param(string) -> stringReturn a matched path parameter from :param or :rest... (or {param} / {rest...})
RestExchange.headermethod RestExchange.header(string) -> stringReturn case-insensitive header value (repeated headers joined by comma-space)
RestExchange.has_headermethod RestExchange.has_header(string) -> boolReturn true when the header is present on the request
RestExchange.bodymethod RestExchange.body() -> stringReturn raw request body bytes
RestExchange.statusmethod RestExchange.status(int) -> voidSet HTTP response status code in range 200..599
RestExchange.set_headermethod RestExchange.set_header(string, string) -> voidSet or replace a response header outside managed framing headers
RestExchange.sendmethod RestExchange.send(string) -> voidReplace response body with raw bytes
RestExchange.jsonmethod RestExchange.json(string) -> voidReplace response body and set Content-Type to application/json
RestExchange.getmethod RestExchange.get(string) -> stringRead server-wide shared string state key or empty string when absent
RestExchange.setmethod RestExchange.set(string, string) -> voidWrite server-wide shared string state key
RestExchange.incrementmethod RestExchange.increment(string) -> intAtomically increment a named integer counter starting at 1

Structured error codes and exit statuses

Error codePhaseExit statusTrigger condition
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