Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ members = [
"crates/ogar-class-view",
"crates/ogar-render-askama",
"crates/ogar-fma-skeleton",
"crates/ogar-adapter-python",
"crates/ogar-adapter-csharp",
]

[workspace.package]
Expand Down
18 changes: 18 additions & 0 deletions crates/ogar-adapter-csharp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "ogar-adapter-csharp"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
rust-version.workspace = true
description = "Materializes the OGAR capability surface (class ids, domain action tables, hot-plug resolution, V3 facet decoder) as a self-contained generated C# class library for foreign consumers -- the plug-and-play pattern without a Rust/OGAR dependency."

[dependencies]
ogar-vocab = { path = "../ogar-vocab" }

[dev-dependencies]
# Reuses the ONE ground-truth dump generator + comparator so the
# Python and C# verification loops can never silently diverge in what
# "correct" means (see ogar_adapter_python::ground_truth).
ogar-adapter-python = { path = "../ogar-adapter-python" }
32 changes: 32 additions & 0 deletions crates/ogar-adapter-csharp/examples/emit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! Write the generated C# class library to a file.
//!
//! Usage:
//! ```text
//! cargo run -p ogar-adapter-csharp --example emit -- <output_path> [namespace]
//! ```
//! `namespace` defaults to `Ogar.CapabilitySurface` and becomes the
//! emitted file's real `namespace` declaration (see
//! [`ogar_adapter_csharp::emit_csharp`]).

use std::env;
use std::fs;
use std::process::ExitCode;

fn main() -> ExitCode {
let mut args = env::args().skip(1);
let Some(output_path) = args.next() else {
eprintln!("usage: emit <output_path> [namespace]");
return ExitCode::from(2);
};
let namespace = args
.next()
.unwrap_or_else(|| "Ogar.CapabilitySurface".to_string());

let content = ogar_adapter_csharp::emit_csharp(&namespace);
if let Err(e) = fs::write(&output_path, content) {
eprintln!("failed to write {output_path}: {e}");
return ExitCode::FAILURE;
}
eprintln!("wrote {output_path} (namespace {namespace})");
ExitCode::SUCCESS
}
Loading
Loading