✓
Passing This code compiles and runs correctly.
Code
// 220_053: `koruc lib --lang=cs` produces a callable .NET class library —
// the csproj flips to OutputType=Library and main_module goes public so
// its <tor>_event handler classes are reachable cross-assembly. An
// ASP.NET host drops output_emitted.cs into a project or references the
// .dll; main_module.answer_event.handler(...) is the callable surface.
// The zig run below is just the harness contract — post.sh drives the
// lib-mode compile and asserts the assembly shape.
import std/io
pub tor answer {} -> i64
proc answer|zig {
return 42;
}
proc answer|cs {
return 42;
}
std/io:print.ln("assembly")
Supporting Files
var r = main_module.answer_event.handler(new main_module.answer_event.Input { });
System.Console.WriteLine($"answer={r}");
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="lib_out">
<HintPath>../lib_out.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
answer=42
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"consumer/1.0.0": {
"dependencies": {
"lib_out": "1.0.0.0"
},
"runtime": {
"consumer.dll": {}
}
},
"lib_out/1.0.0.0": {
"runtime": {
"lib_out.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
}
}
},
"libraries": {
"consumer/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"lib_out/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"lib_out/1.0.0": {
"runtime": {
"lib_out.dll": {}
}
}
}
},
"libraries": {
"lib_out/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}Actual
assembly
Expected output
assembly
Flows
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "assembly")
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# koruc lib --lang=cs must produce a callable .NET assembly:
# - csproj OutputType=Library (not Exe)
# - a real <name>.dll artifact
# - main_module declared public — internal would trap the public
# <tor>_event classes inside the .dll, unreachable cross-assembly
# - a separate consumer assembly references the .dll and calls
# main_module.answer_event.handler() — the cross-assembly claim
# the whole mode exists for.
# Skips cleanly where the .NET SDK is absent (same opt-in spirit as
# LANGUAGES=cs).
if ! command -v dotnet >/dev/null 2>&1 || ! command -v koruc >/dev/null 2>&1; then
echo "SKIP: dotnet or koruc not on PATH"
exit 0
fi
koruc lib "$KORU_INPUT" --lang=cs -o lib_out > lib_compile.log 2>&1 || {
echo "FAIL: koruc lib --lang=cs failed"
tail -10 lib_compile.log
exit 1
}
[ -f lib_out.dll ] || { echo "FAIL: lib_out.dll not produced"; exit 1; }
grep -q '<OutputType>Library</OutputType>' koru.csproj || {
echo "FAIL: csproj is not OutputType=Library"
exit 1
}
grep -q 'public static class main_module' output_emitted.cs || {
echo "FAIL: main_module is not public — handlers unreachable cross-assembly"
exit 1
}
# The source greps above prove shape; this fixture proves the claim —
# a separate .NET assembly references lib_out.dll and calls through.
mkdir -p consumer
cat > consumer/consumer.csproj <<'CS'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="lib_out">
<HintPath>../lib_out.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
CS
cat > consumer/Program.cs <<'CS'
var r = main_module.answer_event.handler(new main_module.answer_event.Input { });
System.Console.WriteLine($"answer={r}");
CS
dotnet build consumer -o consumer_out --nologo -v:q > consumer_build.log 2>&1 || {
echo "FAIL: consumer project referencing lib_out.dll did not build"
tail -10 consumer_build.log
exit 1
}
consumer_out/consumer > consumer_actual.txt 2>&1 || {
echo "FAIL: consumer apphost did not run"
cat consumer_actual.txt
exit 1
}
grep -q 'answer=42' consumer_actual.txt || {
echo "FAIL: cross-assembly handler call returned wrong output"
cat consumer_actual.txt
exit 1
}
exit 0