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

未关闭
#210 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@lisboaigor 已经在做这个了。

开始于 2026年11月22日。

  • #211 来自 @lisboaigor —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
csharp, rust
领域
build-system

调研方向

The generated C# types are internal because lwk_bindings/uniffi.toml has no [bindings.csharp] section, so the default access modifier applies. The proposed fix is access_modifier = "public" in that file, and PR #211 already contains it. Done means a separate consumer project can reference the packed package and compile against Network and Mnemonic. Check the open PR before starting, since this work is already under way.

由索引模型根据 Issue 内容生成。

描述

Summary

The LiquidWalletKit 0.8.2 NuGet package (the one the docs install page tells you to use) can't be consumed: every type in uniffi.lwk (Wollet, Signer, Mnemonic, Network, EsploraClient, TxBuilder, Pset, ... and the I* interfaces) is internal.

Reproduction

Tested with dotnet add package LiquidWalletKit --version 0.8.2 on a new net10.0 class library (.NET SDK 10.0.201, macOS 26.6):

using uniffi.lwk;

var network = Network.Mainnet();
var mnemonic = Mnemonic.FromRandom(12);
error CS0122: 'Network' is inaccessible due to its protection level
error CS0122: 'Mnemonic' is inaccessible due to its protection level

Checking the metadata of LiquidWalletKit.dll confirms it: all 288 TypeDef rows in uniffi.lwk are NotPublic, and I didn't see any InternalsVisibleTo.

Cause

uniffi-bindgen-cs emits internal unless told otherwise (Config::access_modifier() defaults to "internal", documented in its docs/CONFIGURATION.md: "access_modifier - override the default internal access modifier for "exported" uniffi symbols"). lwk_bindings/uniffi.toml has no [bindings.csharp] section, so the published package gets the default.

The C# test (lwk_bindings/tests/bindings/list_transactions.cs) is compiled together with lwk.cs in the same project (justfile, csharp-windows), so it can use internal types and doesn't catch this. build-nuget only runs dotnet build / dotnet pack; nothing consumes the package from outside the assembly.

0.8.2 (2024-11-19) is the only version on NuGet, and master still builds with the same default, so a new release would have the same problem.

Fix

Add this to lwk_bindings/uniffi.toml:

[bindings.csharp]
access_modifier = "public"

I verified it: with the pinned uniffi-bindgen-cs (v0.11.1+v0.31.0), the generated lwk.cs goes from 186 internal declarations to 184 public (the FFI helper types stay internal). A separate consumer project fails with CS0122 before the change and builds and runs after it. Fix: #211

Only a new release will fix the published package, since LiquidWalletKit.csproj and the build-nuget job still hard-code 0.8.2.

A CI step that builds a tiny project against the packed .nupkg would catch this kind of regression, since the current C# test is compiled in the same assembly as lwk.cs. I left it out of the PR; happy to add it if you want it.

主要语言
Rust
星标
114
派生
69
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Blockstream/lwk 的其他 Issue

查看 Blockstream/lwk 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。