csharp!() { /* proc-macro */ }Expand description
Re-export the proc macros so users only need to depend on this crate. Compile and run zero-argument C# code at program runtime.
Wraps the provided C# body in a generated class, compiles it with dotnet build,
and executes it with dotnet run. The return value of static T Run() is
binary-serialised by the generated Main() and deserialised to the inferred
Rust type.
Expands to Result<T, inline_csharp::CsharpError>.
For Run() methods that take parameters, use csharp_fn! instead.
§Options
Optional key = "value" pairs may appear before the C# body, separated by commas:
build = "<args>"— extra arguments fordotnet build.run = "<args>"— extra arguments fordotnet run.reference = "<path>"— add a reference assembly (repeatable).
§Examples
use inline_csharp::csharp;
let x: i32 = csharp! {
static int Run() {
return 42;
}
}.unwrap();