.NET Uniffi bindings - #374
Closed
dkackman wants to merge 69 commits into
Closed
Conversation
Adds a new `uniffi` feature-gated backend to the bindy type conversion framework, mirroring the existing pyo3/napi/wasm backends, with `Uniffi` / `UniffiContext` marker types and conversions for BigInt, u64, u128 (as String), and bytes types (as Vec<u8>). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move uniffi dependency to workspace (consistent with all other deps) - Add impl_self!(i64) and impl_self!(i128) to uniffi_impls.rs so signed 64/128-bit types work with the uniffi feature - Fix redundant Ok(...)? wrapping in IntoRust impls for u64 and u128 - Clarify the usize comment to reference the lib.rs blanket impl Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Create the uniffi/ crate as the C# bindings entry point. This required
several supporting changes:
- Add uniffi workspace member and create Cargo.toml, build.rs, src/lib.rs
- Hand-write the Clvm::alloc method dispatching ClvmType enum variants
- Add {usize} -> u32 mapping in bindings.json and FromRust/IntoRust impls
- Fix orphan rules: use concrete UniffiContext instead of generic T, add
Clone derive to wrapper structs, add blanket Arc<U> FromRust/IntoRust
- Emit static methods as free functions (UniFFI 0.28 limitation)
- Gate peer/rpc types behind uniffi feature alongside napi/pyo3
- Add chia-sdk-client and chia-ssl deps to bindy uniffi feature
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes the num-bigint dependency from the uniffi crate (BigInt conversions live entirely in bindy/src/uniffi_impls.rs). Adds a comment above Clvm::alloc explaining that nil/int/bool/string/bytes must go through typed helper methods in the UniFFI backend rather than the dynamic alloc path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also fix String.Format ambiguity in generated bindings where Clvm.String(string) method shadowed System.String within the Clvm class body. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Clvm class defines a String(string) method which shadows System.String in the class body, causing CS0119 on the ObjectDisposedException / OverflowException guard lines. Patch the two affected call sites in the generated file to use System.String.Format explicitly. Also suppress a nullability warning in CurryRoundtrip by asserting non-null inline with the null-forgiving operator. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the manual sed step with a PatchClvmStringAmbiguity MSBuild target that runs BeforeTargets="CoreCompile" on every build. The patch is idempotent, so regenerating the bindings and running dotnet test is enough — no separate script needed. Update README to remove the manual patch step and reference the build target instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use RoslynCodeTaskFactory to apply the String.Format fix in pure .NET, eliminating the sed dependency. Works identically on Windows, macOS, and Linux with no external tools. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also adds InternalsVisibleTo in ChiaWalletSdk.csproj so the test assembly can access the internal types in the generated bindings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dkackman
marked this pull request as draft
April 8, 2026 18:12
dkackman
marked this pull request as ready for review
April 10, 2026 16:08
…nd improve usage instructions
…e build to fail on musllinux. Disable sccache for now to get the build to pass
…e. symbols are present for source file generation only
Contributor
Author
|
closing in favor of combined uniffi PR #406 |
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.
Add C#/.NET bindings
Uses the
bindyframework and adds UniFFI support, specifically UniFFI-bindgen-cs.CS Projects
Adds another binding project that includes a uniffi crate, a c# assembly that can be published to nuget and xunit tests.
github workflow
Normal CI builds the .net assembly and the new github workflow creates and packages the nuget package.