Skip to content

bindings: make C# types public - #211

Open
lisboaigor wants to merge 1 commit into
Blockstream:masterfrom
lisboaigor:bindings-csharp-public-api
Open

lisboaigor wants to merge 1 commit into
Blockstream:masterfrom
lisboaigor:bindings-csharp-public-api

Conversation

@lisboaigor

Copy link
Copy Markdown

Closes #210

Change

Add a [bindings.csharp] section with access_modifier = "public" to lwk_bindings/uniffi.toml.

uniffi-bindgen-cs defaults to internal for the exported types (see docs/CONFIGURATION.md in that project), so the published LiquidWalletKit package has no public API. The C# test did not notice because it is compiled together with lwk.cs in the same assembly. The generator keeps its FFI helper types (FfiConverter, RustBuffer, ...) internal.

Verification

Built lwk_bindings in release and generated the bindings with the pinned uniffi-bindgen-cs (v0.11.1+v0.31.0) plus scripts/patch_csharp_finalize.py, then compiled the output as a library and referenced it from a separate console project:

  • before: 186 internal declarations, and the consumer fails with CS0122: 'Network' is inaccessible due to its protection level
  • after: 184 public and 4 internal declarations; the consumer builds with no errors or warnings and runs (Network.Testnet(), Mnemonic.FromRandom(12), Signer, WpkhSlip77Descriptor() with the native lib next to it)

Checked on macOS arm64 with .NET SDK 10.0.201 and a net10.0 project; the repo's own targets (net8.0, Windows) were not built.

Notes

  • Only a new release fixes the published package: LiquidWalletKit.csproj and the build-nuget job still hard-code 0.8.2 (there is a TODO in the workflow), so I left versioning alone.
  • I did not add a CI check, following the guideline about keeping tests minimal. A small job that builds a consumer project against the packed .nupkg would catch a regression of this kind, since the current test can't. Happy to add it here or in a follow-up if you want it.

uniffi-bindgen-cs emits `internal` types unless `access_modifier` is
set, and uniffi.toml had no csharp section. As a result the
LiquidWalletKit package exposed no public API: using any type, such as
`Network.Mainnet()`, from outside the assembly fails with CS0122.

The C# test was not affected because it is compiled together with
lwk.cs in the same assembly.

Set `access_modifier = "public"`. FFI helper types stay internal, as
the generator hard-codes them.

Checked by generating the bindings with the pinned uniffi-bindgen-cs
and building a separate consumer project: it failed with CS0122 before
this change and builds and runs after it.

This branch has not been deployed

No deployments
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.

C# bindings: all generated types are internal, LiquidWalletKit 0.8.2 has no usable public API

1 participant