KEMBAR78
Add simple C# interop sample/test by kennykerr · Pull Request #3657 · microsoft/windows-rs · GitHub
Skip to content

Conversation

@kennykerr
Copy link
Collaborator

I'd like to add some more interesting C# interop samples and tests (much like I already have for C++) but for now this is just a tiny example to prove out that it works in the build without overly complicating windows-rs - let's see. 🙃

There's a new Rust cdylib library crate that will produce a DLL with a simple exported function and a second Rust library crate that just acts as a driver to build and run a simple C# console app that then calls the exported function. This lets us test it as follows:

cargo test -p csharp_client

It will also be validated as part of the CI build automatically.

This still seems a little cumbersome but its at least manageable. It does depend on "dotnet.exe" and the .NET SDK being installed so we'll see if the default GitHub runners include that...

@kennykerr kennykerr changed the title Add simpler C# interop sample/test Add simple C# interop sample/test Jul 10, 2025
@kennykerr
Copy link
Collaborator Author

I need to figure out how to pass the Rust target_arch to dotnet to satisfy the build.

@kennykerr kennykerr merged commit ccc0285 into master Jul 10, 2025
29 checks passed
@kennykerr kennykerr deleted the csharp branch July 10, 2025 17:13
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.

2 participants