Skip to content

build(ffi): move to the upstream diplomat .NET backend - #518

Draft
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
masterfrom
ffi/diplomat-dotnet-backend
Draft

build(ffi): move to the upstream diplomat .NET backend#518
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
masterfrom
ffi/diplomat-dotnet-backend

Conversation

@irvingoujAtDevolution

Copy link
Copy Markdown
Contributor

Draft — the diplomat side isn't merged yet.

Gets us off the old CBenoit diplomat fork and onto the rewritten .NET backend. Pinned to my rust-diplomat/diplomat#1226 (fixed-width bool tag) because without it every Result/Option return throws MarshalDirectiveException on .NET Framework — bool isn't blittable, so P/Invoke can't return the struct by value. Once that lands upstream I'll repoint the rev at rust-diplomat and drop the fork.

Rust side had to move with the new backend: DiplomatWriteableDiplomatWrite, the bridge macro derives Clone/Copy on enums now, mutable opaques need opaque_mut, Result errors must be diplomat types (Pkcs12ErrorBox<PickyError>), and box-in-input is gone.

⚠️ The generated C# changes shape, so this is breaking for consumers: setters are methods (builder.Kid = xbuilder.SetKid(x)) and enum variants got re-cased (RS512Rs512, SHA2_256Sha2256).

Still to do: Devolutions.Picky.Tests doesn't compile against the new names (56 errors, all mechanical renames). Didn't want to bury it in this diff — happy to do it here or as a follow-up, tell me which.

Tests: new Devolutions.Picky.Net48Tests runs the bindings on net48 and net10, 14/14 on both. Covers every marshalling shape — object/void/primitive/string/option Results, bool in and out, byte[] returns, iterators, error → exception.

Swaps the old CBenoit diplomat fork for the rewritten .NET backend, pinned to
the blittable-bool fix (rust-diplomat/diplomat#1226) so Result and Option
still marshal on .NET Framework.

Rust side: DiplomatWriteable is now DiplomatWrite, the bridge macro derives
Clone/Copy on enums itself, mutable opaques need opaque_mut, Result errors
have to be diplomat types (Pkcs12Error -> Box<PickyError>), and box-in-input
is gone (Option<Box<RsString>> -> Option<&RsString>).

The generated C# API changes shape: setters are methods (Kid = x becomes
SetKid(x)) and enum variants are re-cased (RS512 -> Rs512). Devolutions.Picky
itself builds clean; Devolutions.Picky.Tests still needs porting to the new
names.

Adds Devolutions.Picky.Net48Tests, which runs the bindings on .NET Framework
4.8 and on modern .NET so the marshalling stays proven on both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant