Skip to content

refactor(ffi): annotate Diplomat getters and setters - #538

Merged
irvingouj@Devolutions (irvingoujAtDevolution) merged 1 commit into
masterfrom
ffi/diplomat-bridge-attrs
Oct 16, 2026
Merged

irvingouj@Devolutions (irvingoujAtDevolution) merged 1 commit into
masterfrom
ffi/diplomat-bridge-attrs

Conversation

@irvingoujAtDevolution

@irvingoujAtDevolution irvingouj@Devolutions (irvingoujAtDevolution) commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Adds the 174 getter/setter names the new Diplomat in #536 needs, so that PR only has the actual migration. The HIR backend doesn't turn get_/set_ prefixes into properties anymore, so each name here should match the property already in Generated/.

The IDisposable opt-ins are in #569, right above this one.

The Diplomat we pin today drops these attrs, so there's no generated diff. I checked by regenerating with the pinned tool. Heads up, that tool can't regenerate master as-is: its syn chokes on #[unsafe(no_mangle)], so I swapped in #[no_mangle] locally for the check.

Tested: clippy clean, Devolutions.Picky.Tests 26/26 locally.

@irvingoujAtDevolution
irvingouj@Devolutions (irvingoujAtDevolution) marked this pull request as ready for review September 29, 2026 19:24
@irvingoujAtDevolution
irvingouj@Devolutions (irvingoujAtDevolution) removed this pull request from stack #540 October 13, 2026 13:02
@irvingoujAtDevolution
irvingouj@Devolutions (irvingoujAtDevolution) removed this pull request from stack #562 October 14, 2026 14:44
@irvingoujAtDevolution
irvingouj@Devolutions (irvingoujAtDevolution) removed this pull request from stack #567 October 14, 2026 15:46
@irvingoujAtDevolution irvingouj@Devolutions (irvingoujAtDevolution) changed the title refactor(ffi): annotate Diplomat getters, setters and disposable types refactor(ffi): annotate Diplomat getters and setters Oct 14, 2026
Base automatically changed from ffi/authenticode-borrow-program-name to master October 14, 2026 20:03
Adds the `#[diplomat::attr(auto, getter/setter)]` markers the next
Diplomat needs: 174 getter/setter names, since it no longer turns
`get_`/`set_` prefixes into C# properties.

The Diplomat pinned today drops these attributes, so the generated C#
doesn't change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@CBenoit Benoît Cortier (CBenoit) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@irvingoujAtDevolution
irvingouj@Devolutions (irvingoujAtDevolution) merged commit fb0300d into master Oct 16, 2026
15 checks passed
@irvingoujAtDevolution
irvingouj@Devolutions (irvingoujAtDevolution) deleted the ffi/diplomat-bridge-attrs branch October 16, 2026 23:40
irvingouj@Devolutions (irvingoujAtDevolution) added a commit that referenced this pull request Oct 17, 2026
Moves the .NET bindings off the old
[CBenoit/diplomat@f4d93d57](CBenoit/diplomat@f4d93d5)
fork onto Diplomat's HIR .NET backend, pinned to the protected tag
[`0.16.1-devo.2`](https://github.com/Devolutions/diplomat/tree/0.16.1-devo.2)
(same commit as upstream main,
[002db80c](rust-diplomat/diplomat@002db80)).
crates.io 0.16.1 predates the .NET lifetime rework, so it's a tag until
upstream publishes. Supersedes #518.

Split into a stack so this one is just the migration:
1. #561 drops .NET Framework, targets net8.0
2. #537 `program_name` double free fix
3. #538 getter/setter attrs, no generated diff
4. #569 `manually_disposable` on the 14 types that need it, no generated
diff
5. this PR
6. #541 fixes a use-after-free in `AuthenticodeValidator`
7. #542 wipes key bytes and passphrases on free

The bridge diff here is only what HIR needs: `opaque_mut`, named
lifetimes, `DiplomatWrite`, and no `#[derive(Clone, Copy)]` on enums
(the macro adds it now). The rest is `Generated/`, the addons and test
renames. C# properties stay the same (176 before, 176 after).

### Breaking (C#)
- `GetX()`/`SetX()` methods that duplicated properties are gone; the
properties stay
- `HashAlgorithm`/`ShaVariant`/`JwsAlg`/`SshCertKeyType` members are
re-cased (`SHA2_256` → `Sha2256`), same numeric values
- `DiplomatWriteable`, `AsFFI()`, the raw ctors and `Raw.*` aren't
public anymore; `PickyError.ToDisplay()` returns `string`
- only the 14 types from #569 stay `IDisposable`, the other 84 lose it,
so `using`/`Dispose()` on them won't compile anymore

I grepped the RDM monorepo (RDM, DVLS, Hub, PowerShell): none of the
removed methods or enum names are used. They do dispose `Cert` and
`using` `Pkcs12ParsingParams`/`Pkcs12Attribute`, those lines have to go
when they bump. That's a text search, not a compile.

### Where to look hardest
- the addons take a shared lease for the whole native call, same as the
generated code:
[Pem](https://github.com/Devolutions/picky-rs/blob/d44f8bf021013f285fbd360defe1fb1f964d64b4/ffi/dotnet/Devolutions.Picky/src/Pem.Addons.cs),
[Pfx](https://github.com/Devolutions/picky-rs/blob/d44f8bf021013f285fbd360defe1fb1f964d64b4/ffi/dotnet/Devolutions.Picky/src/Pfx.Addons.cs),
[PublicKey](https://github.com/Devolutions/picky-rs/blob/d44f8bf021013f285fbd360defe1fb1f964d64b4/ffi/dotnet/Devolutions.Picky/src/PublicKey.Addons.cs)
- the test renames in `JwtTests`/`Pkcs7Tests`/`SshTests`, that's what
consumers will have to change

### Tests
- clippy/fmt clean, regenerating the bindings is a no-op (267/267 files)
- `Devolutions.Picky.Tests` 26/26

### Needs a call
- NuGet is date-versioned with no changelog. How do we want to announce
the breaks?

### Not from this PR, spotted while here
- `PuttyPpkEncryptionConfigBuilder` setters call `self.0.clone().x(..)`
and throw the result away, so they do nothing
- `get_argon2_flavour` is a setter with a getter name

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants