hyperlight-component-csharp 0.19.0

Experimental. Generates C# host bindings for Hyperlight components from WIT worlds
Documentation
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 The Hyperlight Authors.

//! Generates C# host bindings for a WIT world.
//!
//! Usage: `csharp_bindgen <wit path> <namespace> <output file>`

use std::process::ExitCode;

use hyperlight_component_csharp::generate_from_path;

fn main() -> ExitCode {
    let args: Vec<String> = std::env::args().skip(1).collect();
    let [wit, namespace, out] = args.as_slice() else {
        eprintln!("usage: csharp_bindgen <wit path> <namespace> <output file>");
        return ExitCode::FAILURE;
    };
    // `cargo run` sets CARGO_MANIFEST_DIR, which would resolve a relative
    // path against this crate instead of the caller's directory.
    let wit = match std::path::absolute(wit) {
        Ok(wit) => wit,
        Err(e) => {
            eprintln!("{wit}: {e}");
            return ExitCode::FAILURE;
        }
    };
    let result = generate_from_path(&wit, None, namespace)
        .map_err(|e| e.to_string())
        .and_then(|cs| std::fs::write(out, cs).map_err(|e| format!("{out}: {e}")));
    match result {
        Ok(()) => ExitCode::SUCCESS,
        Err(e) => {
            eprintln!("{e}");
            ExitCode::FAILURE
        }
    }
}