Repository navigation
C# bindings for the C ABI - #2
Closed
christopherthompson81 wants to merge 1 commit into
Closed
christopherthompson81 wants to merge 1 commit into
christopherthompson81 wants to merge 1 commit into
Conversation
christopherthompson81
force-pushed
the
feat/csharp-bindings
branch
from
September 12, 2026 16:30
3f6eba1 to
8aa18b3
Compare
christopherthompson81
force-pushed
the
feat/c-abi
branch
from
September 12, 2026 17:04
913d7dc to
4d329b5
Compare
christopherthompson81
force-pushed
the
feat/csharp-bindings
branch
from
September 12, 2026 17:05
55a4071 to
98ea3e8
Compare
christopherthompson81
force-pushed
the
feat/c-abi
branch
8 times, most recently
from
September 12, 2026 17:47
5346ec6 to
b8011f2
Compare
christopherthompson81
force-pushed
the
feat/csharp-bindings
branch
from
September 12, 2026 17:56
98ea3e8 to
3634c98
Compare
christopherthompson81
force-pushed
the
feat/c-abi
branch
from
September 12, 2026 18:12
b8011f2 to
1577aef
Compare
A net10.0 binding over include/audiocpp.h, plus C# counterparts of the two C tests. All 69 ABI entry points are bound, checked by count against the header rather than by eye. This is also the test the C ABI was designed for. The out-of-order-free guarantee exists because .NET finalizer order is not deterministic, and AudioCpp.PathTest exercises exactly that: it disposes the model and registry, then keeps using the session, and forces a collection with live handles in between. Shape: - SafeHandle for every handle type, so disposal is thread-safe and finalization automatic. - Accessors copy on the way out, because everything the ABI returns is borrowed. Returned strings are IntPtr in the interop layer rather than string, so the marshaller is never in a position to free a pointer it does not own. - Non-OK statuses become AudioCppException carrying the native detail, read synchronously on the calling thread since it is thread-local. - Model families are discovered through the introspection surface rather than hardcoded. - The native library is located via AUDIOCPP_NATIVE_DIR from a static constructor on the interop class, not a module initializer (CA2255). run-tests.sh resolves the native directory by probing rather than assuming bin/. Multi-config generators -- Visual Studio, Xcode, Ninja Multi-Config -- put outputs in a per-configuration subdirectory, so the original assumption skipped the whole suite on Windows while the library sat right there, and reported exit 77. It also looks for the C test binary with and without .exe, and prints the directory it resolved. Verified on Linux x86_64 (single- and multi-config), macOS arm64 and Windows x64. The bindings and the C tests report identical values on every platform they have both run on. Kept in the fork: 0xShug0#525 deliberately scopes language bindings out of the upstream proposal. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EkxqpYvUbjCpRDnFiNiVfx
christopherthompson81
force-pushed
the
feat/csharp-bindings
branch
from
September 12, 2026 18:12
3634c98 to
3c94bc4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
C# bindings over the C ABI from #1, in a branch off it.
Fork-only by design: 0xShug0#525 explicitly keeps language bindings out of scope for
the upstream proposal.
What it adds
AudioCppnet10.0, AOT-compatible, no package referencesAudioCpp.PathTesttests/capi/path_test.cAudioCpp.ModelTesttests/capi/model_test.crun-tests.shAll 69 ABI entry points are bound, verified by count against the header rather
than by eye.
This is the test the ABI was designed for
The out-of-order-free guarantee in the C ABI exists specifically because .NET
finalizer order is not deterministic — an API that required a disposal order
would be unusable from here no matter how carefully a caller wrote their
usingstatements.
AudioCpp.PathTestexercises exactly that: it disposes the model andthe registry, then keeps using the session, and forces a collection with live
handles in between. Both give identical results.
Design
SafeHandlefor every handle type, so disposal is thread-safe andfinalization automatic.
borrowed from the handle that produced it. Returned strings are
IntPtrin theinterop layer rather than
string, so the marshaller is never in a position tofree a pointer it does not own.
AudioCppExceptioncarryingStatusand the nativeDetail, read synchronously on the calling thread since the native detail isthread-local and a later call may clear it.
hardcoded —
GetOptionsreturns names, types, defaults and bounds.AUDIOCPP_NATIVE_DIR, installed from a staticconstructor on the interop class rather than a module initializer (CA2255).
Verification
The bindings and the C tests report 11 parity lines, byte-identical, across
all five families:
That closes the loop: C API ↔ C tests, C API ↔ C# bindings, and both ↔
audiocpp_cli.silero_vadkokoro_ttscitrinet_asr/parakeet_tdtsortformer_diarbs_roformerLibrary builds clean with
TreatWarningsAsErrors, the trim analyzer andIsAotCompatible.Also in this branch
Two fixes to the C side, folded in from
feat/c-abi:wall time and scales (191s → 113s), and stems are bit-identical at both thread
counts, so CMake now passes the host's cores. Suite wall time 222s → 142s.
reporting
PARITY OK. It invoked the model test without the alternate44.1 kHz clip BS-RoFormer needs, and under CTest the working directory is the
build tree, so the repo-relative default did not resolve. Separation produced
nothing to compare and parity blamed "family not linked into this build" —
which was false. Fixture paths are now resolved up front, a missing one skips
loudly, and the skip message distinguishes "not linked" from "ran and produced
nothing".
🤖 Generated with Claude Code
https://claude.ai/code/session_01EkxqpYvUbjCpRDnFiNiVfx