Skip to content

Add first-class C# SDK generation and runtime support#4120

Draft
rossirpaulo wants to merge 1 commit into
canaryfrom
paulo/csharp-bridge
Draft

Add first-class C# SDK generation and runtime support#4120
rossirpaulo wants to merge 1 commit into
canaryfrom
paulo/csharp-bridge

Conversation

@rossirpaulo

@rossirpaulo rossirpaulo commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add deterministic C# SDK generation and a managed CFFI runtime
  • support streaming, media, host callables, request clients, optional/nullable values, unions, dynamic values, and structural resources
  • add C# fixtures, ABI/protocol/package probes, NuGet packaging, release integration, and dedicated CI
  • keep generated fixture clients untracked and isolate C# verification/publishing from generic native bridge workflows

Canary rebase and boundary

  • rebuilt as one focused commit on Canary 4aad907cc0c421c5275837cb02f46cae05c87db7
  • removed the previous baml_std host-boundary annotations and AST/shared compiler-semantic changes
  • adapted C# generation and resource ownership to existing Canary semantics
  • limited shared changes to cross-language correctness fixes and narrowly scoped, append-only CFFI/protocol extensions required by typed host values and race-safe host-call completion
  • generated Python/Rust protocol files are canonical schema fallout; existing Rust collection encoding retains its legacy optional-metadata behavior

Shared correctness fixes

  • preserve exact union/literal and realized collection occurrence metadata
  • allow retained host-callable handles to be invoked through the VM callable entry point
  • preserve array/map descriptors during heap copies and correctly reclaim host-owned arguments
  • reject non-null payloads for void callback returns
  • claim callback completion before decoding transferred handles so cancellation races cannot leak or double-own resources

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p sdk_test_csharp — 15/15
  • cargo test -p sdkgen_csharp — 47/47
  • cargo test -p baml_bridge — 62/62 across unit, conversion, and live suites
  • cargo test -p bridge_cffi
  • cargo test -p bridge_ctypes -p bex_heap -p bex_external_types
  • focused cross-language occurrence and retained-host-callable tests
  • managed bridge, host-callable, and protocol probes

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 22, 2026 7:45pm
promptfiddle Ready Ready Preview, Comment Jul 22, 2026 7:45pm
promptfiddle2 Error Error Jul 22, 2026 7:45pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4377742d-848f-4bb9-955e-8d681770477d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch paulo/csharp-bridge

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rossirpaulo
rossirpaulo force-pushed the paulo/csharp-bridge branch from 41dcd09 to 79e51c9 Compare July 22, 2026 19:23
@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@blacksmith-sh

blacksmith-sh Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
roundtrip_tests.TestForwardRefs/test_round_trip_rec_list() View Logs
TestHostCallables/test_concurrent_throws_in_flight_rehydrate_to_their_own_object() View Logs

Fix in Cursor

@github-actions

Copy link
Copy Markdown

Binary size checks failed

3 violations · ✅ 4 passed

⚠️ Please fix the size gate issues or acknowledge them by updating baselines.

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 26.2 MB 11.1 MB file 25.3 MB +911.2 KB (+3.6%) FAIL
packed-program Linux 🔒 17.2 MB 7.1 MB file 17.0 MB +165.4 KB (+1.0%) OK
baml-cli macOS 🔒 20.3 MB 9.7 MB file 19.6 MB +728.0 KB (+3.7%) FAIL
packed-program macOS 🔒 13.4 MB 6.2 MB file 13.2 MB +198.3 KB (+1.5%) OK
baml-cli Windows 🔒 21.9 MB 9.9 MB file 21.1 MB +808.4 KB (+3.8%) FAIL
packed-program Windows 🔒 14.3 MB 6.3 MB file 14.2 MB +161.3 KB (+1.1%) OK
bridge_wasm WASM 16.3 MB 🔒 4.4 MB gzip 4.4 MB +30.4 KB (+0.7%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.

Details & how to fix

Violations:

  • baml-cli (Linux) file_bytes: 26.2 MB exceeds limit of 26.0 MB (exceeded by +152.7 KB, policy: max_file_bytes)
  • baml-cli (Linux) file_delta_pct: +3.6% exceeds limit of 3.0% (exceeded by +0.6pp, policy: max_delta_pct)
  • baml-cli (macOS) file_bytes: 20.3 MB exceeds limit of 20.2 MB (exceeded by +140.6 KB, policy: max_file_bytes)
  • baml-cli (macOS) file_delta_pct: +3.7% exceeds limit of 3.0% (exceeded by +0.7pp, policy: max_delta_pct)
  • baml-cli (Windows) file_bytes: 21.9 MB exceeds limit of 21.7 MB (exceeded by +175.3 KB, policy: max_file_bytes)
  • baml-cli (Windows) file_delta_pct: +3.8% exceeds limit of 3.0% (exceeded by +0.8pp, policy: max_delta_pct)

Add/update baselines:

.ci/size-gate/aarch64-apple-darwin.toml:

[artifacts.baml-cli]
file_bytes = 20306304
stripped_bytes = 20306336
gzip_bytes = 9691188

.ci/size-gate/x86_64-pc-windows-msvc.toml:

[artifacts.baml-cli]
file_bytes = 21914624
stripped_bytes = 21914624
gzip_bytes = 9918776

.ci/size-gate/x86_64-unknown-linux-gnu.toml:

[artifacts.baml-cli]
file_bytes = 26196496
stripped_bytes = 26196488
gzip_bytes = 11120413

Generated by cargo size-gate · workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant